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: rename pr_comment to process_comment,...



details:   https://anonhg.NetBSD.org/src/rev/dc090ea7fe44
branches:  trunk
changeset: 953576:dc090ea7fe44
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 13 13:25:23 2021 +0000

description:
indent: rename pr_comment to process_comment, clean up documentation

No functional change.

diffstat:

 usr.bin/indent/indent.c       |  10 +++++-----
 usr.bin/indent/indent.h       |   6 +++---
 usr.bin/indent/indent_globs.h |   4 ++--
 usr.bin/indent/pr_comment.c   |  41 ++++++++++++++---------------------------
 4 files changed, 24 insertions(+), 37 deletions(-)

diffs (161 lines):

diff -r d2c183126437 -r dc090ea7fe44 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sat Mar 13 13:14:14 2021 +0000
+++ b/usr.bin/indent/indent.c   Sat Mar 13 13:25:23 2021 +0000
@@ -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 @@
 #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 @@
            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 @@
        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:
diff -r d2c183126437 -r dc090ea7fe44 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Sat Mar 13 13:14:14 2021 +0000
+++ b/usr.bin/indent/indent.h   Sat Mar 13 13:25:23 2021 +0000
@@ -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   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 *);
diff -r d2c183126437 -r dc090ea7fe44 usr.bin/indent/indent_globs.h
--- a/usr.bin/indent/indent_globs.h     Sat Mar 13 13:14:14 2021 +0000
+++ b/usr.bin/indent/indent_globs.h     Sat Mar 13 13:25:23 2021 +0000
@@ -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 @@
     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
diff -r d2c183126437 -r dc090ea7fe44 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Sat Mar 13 13:14:14 2021 +0000
+++ b/usr.bin/indent/pr_comment.c       Sat Mar 13 13:25:23 2021 +0000
@@ -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 @@
 #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 @@
 }
 
 /*
- * 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 @@
 
     /* 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;



Home | Main Index | Thread Index | Old Index