Module Name:    src
Committed By:   rillig
Date:           Thu Oct  7 21:38:25 UTC 2021

Modified Files:
        src/usr.bin/indent: indent.c io.c parse.c pr_comment.c

Log Message:
indent: remove redundant comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.75 -r1.76 src/usr.bin/indent/io.c
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/indent/parse.c
cvs rdiff -u -r1.53 -r1.54 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.115 src/usr.bin/indent/indent.c:1.116
--- src/usr.bin/indent/indent.c:1.115	Thu Oct  7 21:16:36 2021
+++ src/usr.bin/indent/indent.c	Thu Oct  7 21:38:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.115 2021/10/07 21:16:36 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.116 2021/10/07 21:38:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.115 2021/10/07 21:16:36 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.116 2021/10/07 21:38:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -427,9 +427,8 @@ main_init_globals(void)
 {
     found_err = false;
 
-    ps.p_stack[0] = stmt;	/* this is the parser's stack */
-    ps.last_nl = true;		/* this is true if the last thing scanned was
-				 * a newline */
+    ps.p_stack[0] = stmt;
+    ps.last_nl = true;
     ps.last_token = semicolon;
     buf_init(&com);
     buf_init(&lab);
@@ -597,7 +596,7 @@ process_comment_in_code(token_type ttype
 static void
 process_form_feed(void)
 {
-    ps.use_ff = true;		/* a form feed is treated much like a newline */
+    ps.use_ff = true;
     dump_line();
     ps.want_blank = false;
 }
@@ -610,7 +609,7 @@ process_newline(void)
 	dump_line();
 	ps.want_blank = false;
     }
-    ++line_no;			/* keep track of input line number */
+    ++line_no;
 }
 
 static bool
@@ -901,9 +900,8 @@ process_lbrace(bool *force_nl, bool *sp_
 	ps.in_decl = false;
     }
     *decl_ind = 0;
-    parse(lbrace);		/* let parser know about this */
-    if (ps.want_blank)		/* put a blank before '{' if '{' is not at
-				 * start of line */
+    parse(lbrace);
+    if (ps.want_blank)
 	*code.e++ = ' ';
     ps.want_blank = false;
     *code.e++ = '{';
@@ -1290,41 +1288,41 @@ main_loop(void)
 	    process_rparen_or_rbracket(&sp_sw, &force_nl, hd_type);
 	    break;
 
-	case unary_op:		/* this could be any unary operation */
+	case unary_op:
 	    process_unary_op(decl_ind, tabs_to_var);
 	    break;
 
-	case binary_op:		/* any binary operation */
+	case binary_op:
 	    process_binary_op();
 	    break;
 
-	case postfix_op:	/* got a trailing ++ or -- */
+	case postfix_op:
 	    process_postfix_op();
 	    break;
 
-	case question:		/* got a ? */
+	case question:
 	    process_question(&seen_quest);
 	    break;
 
 	case case_label:	/* got word 'case' or 'default' */
-	    seen_case = true;	/* so we can process the later colon properly */
+	    seen_case = true;
 	    goto copy_token;
 
-	case colon:		/* got a ':' */
+	case colon:
 	    process_colon(&seen_quest, &force_nl, &seen_case);
 	    break;
 
-	case semicolon:		/* got a ';' */
+	case semicolon:
 	    process_semicolon(&seen_case, &seen_quest, decl_ind, tabs_to_var,
 		&sp_sw, hd_type, &force_nl);
 	    break;
 
-	case lbrace:		/* got a '{' */
+	case lbrace:
 	    process_lbrace(&force_nl, &sp_sw, hd_type, di_stack,
 		(int)nitems(di_stack), &decl_ind);
 	    break;
 
-	case rbrace:		/* got a '}' */
+	case rbrace:
 	    process_rbrace(&sp_sw, &decl_ind, di_stack);
 	    break;
 

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.75 src/usr.bin/indent/io.c:1.76
--- src/usr.bin/indent/io.c:1.75	Thu Oct  7 19:35:50 2021
+++ src/usr.bin/indent/io.c	Thu Oct  7 21:38:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.75 2021/10/07 19:35:50 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.76 2021/10/07 21:38:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.75 2021/10/07 19:35:50 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.76 2021/10/07 21:38:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -257,14 +257,8 @@ dump_line(void)
 	&& token.s < token.e && isspace((unsigned char)token.s[0]))
 	output_range(token.s, token.e);
 
-    ps.decl_on_line = ps.in_decl;	/* if we are in the middle of a
-					 * declaration, remember that fact for
-					 * proper comment indentation */
-    ps.ind_stmt = ps.in_stmt && !ps.in_decl;	/* next line should be
-						 * indented if we have not
-						 * completed this stmt and if
-						 * we are not in the middle of
-						 * a declaration */
+    ps.decl_on_line = ps.in_decl;	/* for proper comment indentation */
+    ps.ind_stmt = ps.in_stmt && !ps.in_decl;
     ps.use_ff = false;
     ps.dumped_decl_indent = false;
     *(lab.e = lab.s) = '\0';	/* reset buffers */

Index: src/usr.bin/indent/parse.c
diff -u src/usr.bin/indent/parse.c:1.29 src/usr.bin/indent/parse.c:1.30
--- src/usr.bin/indent/parse.c:1.29	Tue Oct  5 06:55:24 2021
+++ src/usr.bin/indent/parse.c	Thu Oct  7 21:38:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.29 2021/10/05 06:55:24 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.30 2021/10/07 21:38:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -70,9 +70,7 @@ parse(token_type ttype)
 	reduce();		/* see if this allows any reduction */
     }
 
-
-    switch (ttype) {		/* go on and figure out what to do with the
-				 * input */
+    switch (ttype) {
 
     case decl:			/* scanned a declaration word */
 	ps.search_brace = opt.btype_2;
@@ -84,8 +82,7 @@ parse(token_type ttype)
 	    ps.p_stack[++ps.tos] = decl;
 	    ps.il[ps.tos] = ps.ind_level_follow;
 
-	    if (opt.ljust_decl) {	/* only do if we want left justified
-					 * declarations */
+	    if (opt.ljust_decl) {
 		ps.ind_level = 0;
 		for (int i = ps.tos - 1; i > 0; --i)
 		    if (ps.p_stack[i] == decl)
@@ -99,15 +96,14 @@ parse(token_type ttype)
     case if_expr:		/* 'if' '(' <expr> ')' */
 	if (ps.p_stack[ps.tos] == if_expr_stmt_else && opt.else_if) {
 	    /*
-	     * Note that the stack pointer here is decremented, effectively
-	     * reducing "else if" to "if". This saves a lot of stack space in
+	     * Reduce "else if" to "if". This saves a lot of stack space in
 	     * case of a long "if-else-if ... else-if" sequence.
 	     */
 	    ps.ind_level_follow = ps.il[ps.tos--];
 	}
 	/* the rest is the same as for keyword_do and for_exprs */
 	/* FALLTHROUGH */
-    case keyword_do:		/* 'do' */
+    case keyword_do:
     case for_exprs:		/* 'for' (...) */
 	ps.p_stack[++ps.tos] = ttype;
 	ps.il[ps.tos] = ps.ind_level = ps.ind_level_follow;
@@ -115,7 +111,7 @@ parse(token_type ttype)
 	ps.search_brace = opt.btype_2;
 	break;
 
-    case lbrace:		/* scanned { */
+    case lbrace:
 	break_comma = false;	/* don't break comma in an initial list */
 	if (ps.p_stack[ps.tos] == stmt || ps.p_stack[ps.tos] == decl
 		|| ps.p_stack[ps.tos] == stmt_list)
@@ -123,9 +119,6 @@ parse(token_type ttype)
 				 * group or a declaration */
 	else {
 	    if (code.s == code.e) {
-		/*
-		 * only do this if there is nothing on the line
-		 */
 		--ps.ind_level;
 		/*
 		 * it is a group as part of a while, for, etc.
@@ -166,16 +159,14 @@ parse(token_type ttype)
 	else {
 	    ps.ind_level = ps.il[ps.tos];	/* indentation for else should
 						 * be same as for if */
-	    ps.ind_level_follow = ps.ind_level + 1;	/* everything following
-							 * should be 1 level
-							 * deeper */
+	    ps.ind_level_follow = ps.ind_level + 1;
 	    ps.p_stack[ps.tos] = if_expr_stmt_else;
 	    /* remember if with else */
 	    ps.search_brace = opt.btype_2 | opt.else_if;
 	}
 	break;
 
-    case rbrace:		/* scanned a } */
+    case rbrace:
 	/* stack should have <lbrace> <stmt> or <lbrace> <stmt_list> */
 	if (ps.tos > 0 && ps.p_stack[ps.tos - 1] == lbrace) {
 	    ps.ind_level = ps.ind_level_follow = ps.il[--ps.tos];
@@ -203,12 +194,10 @@ parse(token_type ttype)
 	ps.il[ps.tos] = ps.ind_level;
 	break;
 
-    default:			/* this is an error */
+    default:
 	diag(1, "Unknown code to parser");
 	return;
-
-
-    }				/* end of switch */
+    }
 
     if (ps.tos >= STACKSIZE - 1)
 	errx(1, "Parser stack overflow");

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.53 src/usr.bin/indent/pr_comment.c:1.54
--- src/usr.bin/indent/pr_comment.c:1.53	Tue Oct  5 19:58:38 2021
+++ src/usr.bin/indent/pr_comment.c	Thu Oct  7 21:38:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.53 2021/10/05 19:58:38 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.54 2021/10/07 21:38:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.53 2021/10/05 19:58:38 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.54 2021/10/07 21:38:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -211,7 +211,6 @@ process_comment(void)
 	    check_size_comment(3);
 	    if (!ps.box_com) {	/* in a text comment, break the line here */
 		ps.use_ff = true;
-		/* fix so dump_line uses a form feed */
 		dump_line();
 		last_blank = -1;
 		if (!ps.box_com && opt.star_comment_cont)
@@ -230,7 +229,7 @@ process_comment(void)
 		++line_no;
 		goto end_of_comment;
 	    }
-	    if (had_eof) {	/* check for unexpected eof */
+	    if (had_eof) {
 		printf("Unterminated comment\n");
 		dump_line();
 		return;
@@ -255,7 +254,7 @@ process_comment(void)
 		    *com.e++ = ' ';
 		last_blank = com.e - 1 - com.buf;
 	    }
-	    ++line_no;		/* keep track of input line number */
+	    ++line_no;
 	    if (!ps.box_com) {
 		int asterisks_to_skip = 1;
 		do {		/* flush any blanks and/or tabs at start of
@@ -274,7 +273,7 @@ process_comment(void)
 	case '*':
 	    inbuf_skip();
 	    check_size_comment(4);
-	    if (*buf_ptr == '/') {	/* end of the comment */
+	    if (*buf_ptr == '/') {
 	end_of_comment:
 		inbuf_skip();
 		if (break_delim) {

Reply via email to