Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/indent indent: clean up verbose documentation commen...
details: https://anonhg.NetBSD.org/src/rev/de2f3d6b294d
branches: trunk
changeset: 981473:de2f3d6b294d
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Mar 13 00:03:29 2021 +0000
description:
indent: clean up verbose documentation comments from the 1970s
Since C90, there is no need to repeat the type of the function
parameters.
In the whole code of indent, there is a lot of confusion between the
concepts of a 'column' (which is a position on the screen, counting
starts at 1) and 'indentation' (which is a length, not a position). To
avoid this confusion, the code will be rewritten anyway very soon.
Repeatedly adding and subtracting 1 from the 'current column' is not
elegant, this should rather be done by consistently measuring only the
indentation from the left border (at offset 0), as a distance, not as an
absolute position.
diffstat:
usr.bin/indent/io.c | 55 +++-------------------------------------------------
1 files changed, 4 insertions(+), 51 deletions(-)
diffs (94 lines):
diff -r 9558415ed741 -r de2f3d6b294d usr.bin/indent/io.c
--- a/usr.bin/indent/io.c Fri Mar 12 23:27:41 2021 +0000
+++ b/usr.bin/indent/io.c Sat Mar 13 00:03:29 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.32 2021/03/12 23:27:41 rillig Exp $ */
+/* $NetBSD: io.c,v 1.33 2021/03/13 00:03:29 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
#include <sys/cdefs.h>
#ifndef lint
#if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.32 2021/03/12 23:27:41 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.33 2021/03/13 00:03:29 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -304,15 +304,7 @@
*
* All rights reserved
*
- *
- * NAME: fill_buffer
- *
- * FUNCTION: Reads one block of input into input_buffer
- *
- * HISTORY: initial coding November 1976 D A Willcox of CAC 1/7/77 A
- * Willcox of CAC Added check for switch back to partly full input
- * buffer from temporary buffer
- *
+ * FUNCTION: Reads one block of input into the input buffer
*/
void
fill_buffer(void)
@@ -407,28 +399,8 @@
*
* All rights reserved
*
- *
- * NAME: pad_output
- *
- * FUNCTION: Writes tabs and spaces to move the current column up to the desired
+ * Writes tabs and spaces to move the current column up to the desired
* position.
- *
- * ALGORITHM: Put tabs and/or blanks into pobuf, then write pobuf.
- *
- * PARAMETERS: current integer The current column target
- * nteger The desired column
- *
- * RETURNS: Integer value of the new column. (If current >= target, no action is
- * taken, and current is returned.
- *
- * GLOBALS: None
- *
- * CALLS: write (sys)
- *
- * CALLED BY: dump_line
- *
- * HISTORY: initial coding November 1976 D A Willcox of CAC
- *
*/
static int
pad_output(int current, int target)
@@ -461,28 +433,9 @@
* Copyright (C) 1976 by the Board of Trustees of the University of Illinois
*
* All rights reserved
- *
- *
- * NAME: count_spaces
- *
- * FUNCTION: Find out where printing of a given string will leave the current
- * character position on output.
- *
- * ALGORITHM: Run thru input string and add appropriate values to current
- * position.
- *
- * RETURNS: Integer value of position after printing "buffer" starting in column
- * "current".
- *
- * HISTORY: initial coding November 1976 D A Willcox of CAC
- *
*/
int
count_spaces_until(int col, const char *buffer, const char *end)
-/*
- * this routine figures out where the character position will be after
- * printing the text in buffer starting at column "current"
- */
{
for (const char *p = buffer; *p != '\0' && p != end; ++p) {
switch (*p) {
Home |
Main Index |
Thread Index |
Old Index