Module Name: src
Committed By: rillig
Date: Sat Mar 13 13:25:23 UTC 2021
Modified Files:
src/usr.bin/indent: indent.c indent.h indent_globs.h pr_comment.c
Log Message:
indent: rename pr_comment to process_comment, clean up documentation
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/indent/indent_globs.h
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/indent/pr_comment.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.55 src/usr.bin/indent/indent.c:1.56
--- src/usr.bin/indent/indent.c:1.55 Sat Mar 13 13:14:14 2021
+++ src/usr.bin/indent/indent.c Sat Mar 13 13:25:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.55 2021/03/13 13:14:14 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.56 2021/03/13 13:25:23 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c 5.1
#include <sys/cdefs.h>
#ifndef lint
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.55 2021/03/13 13:14:14 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.56 2021/03/13 13:25:23 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -212,7 +212,7 @@ search_brace(token_type *inout_type_code
if (sc_end == NULL) {
/*
* Copy everything from the start of the line, because
- * pr_comment() will use that to calculate original
+ * process_comment() will use that to calculate original
* indentation of a boxed comment.
*/
memcpy(sc_buf, in_buffer, buf_ptr - in_buffer - 4);
@@ -1439,8 +1439,8 @@ main_loop(void)
case preprocessing: /* '#' */
process_preprocessing();
break;
- case comment: /* we have gotten a '/' followed by '*' */
- pr_comment();
+ case comment: /* the initial '/' '*' or '//' of a comment */
+ process_comment();
break;
default:
Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.13 src/usr.bin/indent/indent.h:1.14
--- src/usr.bin/indent/indent.h:1.13 Sat Mar 13 10:32:25 2021
+++ src/usr.bin/indent/indent.h Sat Mar 13 13:25:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.13 2021/03/13 10:32:25 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.14 2021/03/13 13:25:23 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -30,7 +30,7 @@
#if 0
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.h,v 1.13 2021/03/13 10:32:25 rillig Exp $");
+__RCSID("$NetBSD: indent.h,v 1.14 2021/03/13 13:25:23 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
#endif
@@ -65,7 +65,7 @@ void diag(int, const char *, ...) __prin
void dump_line(void);
void fill_buffer(void);
void parse(token_type);
-void pr_comment(void);
+void process_comment(void);
void set_defaults(void);
void set_option(char *);
void set_profile(const char *);
Index: src/usr.bin/indent/indent_globs.h
diff -u src/usr.bin/indent/indent_globs.h:1.18 src/usr.bin/indent/indent_globs.h:1.19
--- src/usr.bin/indent/indent_globs.h:1.18 Sat Mar 13 11:19:43 2021
+++ src/usr.bin/indent/indent_globs.h Sat Mar 13 13:25:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_globs.h,v 1.18 2021/03/13 11:19:43 rillig Exp $ */
+/* $NetBSD: indent_globs.h,v 1.19 2021/03/13 13:25:23 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -254,7 +254,7 @@ extern struct parser_state {
int last_u_d; /* set to true after scanning a token which
* forces a following operator to be unary */
int out_coms; /* the number of comments processed, set by
- * pr_comment */
+ * process_comment */
int out_lines; /* the number of lines written, set by
* dump_line */
int p_l_follow; /* used to remember how to indent following
Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.27 src/usr.bin/indent/pr_comment.c:1.28
--- src/usr.bin/indent/pr_comment.c:1.27 Sat Mar 13 11:27:01 2021
+++ src/usr.bin/indent/pr_comment.c Sat Mar 13 13:25:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.27 2021/03/13 11:27:01 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.28 2021/03/13 13:25:23 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)pr_comment.c
#include <sys/cdefs.h>
#ifndef lint
#if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.27 2021/03/13 11:27:01 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.28 2021/03/13 13:25:23 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -79,38 +79,25 @@ check_size_comment(size_t desired_size,
}
/*
- * NAME:
- * pr_comment
+ * Scan, reformat and output a single comment, which is either a block comment
+ * starting with '/' '*' or an end-of-line comment starting with '//'.
*
- * FUNCTION:
- * This routine takes care of scanning and printing comments.
+ * Try to keep comments from going over the maximum line length. If a line is
+ * too long, move everything starting from the last blank to the next comment
+ * line. Blanks and tabs from the beginning of the input line are removed.
*
* ALGORITHM:
* 1) Decide where the comment should be aligned, and if lines should
* be broken.
* 2) If lines should not be broken and filled, just copy up to end of
* comment.
- * 3) If lines should be filled, then scan thru input_buffer copying
- * characters to com_buf. Remember where the last blank, tab, or
- * newline was. When line is filled, print up to last blank and
- * continue copying.
- *
- * HISTORY:
- * November 1976 D A Willcox of CAC Initial coding
- * 12/6/76 D A Willcox of CAC Modification to handle
- * UNIX-style comments
- *
- */
-
-/*
- * this routine processes comments. It makes an attempt to keep comments from
- * going over the max line length. If a line is too long, it moves everything
- * from the last blank to the next comment line. Blanks and tabs from the
- * beginning of the input line are removed
+ * 3) If lines should be filled, then scan through the input buffer,
+ * copying characters to com_buf. Remember where the last blank,
+ * tab, or newline was. When line is filled, print up to last blank
+ * and continue copying.
*/
-
void
-pr_comment(void)
+process_comment(void)
{
int adj_max_line_length; /* Adjusted max_line_length for comments
* that spill over the right margin */
@@ -130,8 +117,8 @@ pr_comment(void)
/* Figure where to align and how to treat the comment */
- if (ps.col_1 && !opt.format_col1_comments) { /* if comment starts in column
- * 1 it should not be touched */
+ if (ps.col_1 && !opt.format_col1_comments) { /* if the comment starts in
+ * column 1, it should not be touched */
ps.box_com = true;
break_delim = false;
ps.com_col = 1;