Module Name:    src
Committed By:   rillig
Date:           Tue Oct  5 06:24:06 UTC 2021

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

Log Message:
indent: rename local char variable, reduce scope of counters

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/indent/io.c
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/indent/parse.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/io.c
diff -u src/usr.bin/indent/io.c:1.70 src/usr.bin/indent/io.c:1.71
--- src/usr.bin/indent/io.c:1.70	Tue Oct  5 06:15:24 2021
+++ src/usr.bin/indent/io.c	Tue Oct  5 06:24:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.70 2021/10/05 06:15:24 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.71 2021/10/05 06:24:06 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.70 2021/10/05 06:15:24 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.71 2021/10/05 06:24:06 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -393,7 +393,7 @@ fill_buffer(void)
 {
     /* this routine reads stuff from the input */
     char *p;
-    int i;
+    int ch;
     FILE *f = input;
 
     if (bp_save != NULL) {	/* there is a partly filled input buffer left */
@@ -413,15 +413,15 @@ fill_buffer(void)
 	    p = in_buffer + offset;
 	    in_buffer_limit = in_buffer + size - 2;
 	}
-	if ((i = getc(f)) == EOF) {
+	if ((ch = getc(f)) == EOF) {
 	    *p++ = ' ';
 	    *p++ = '\n';
 	    had_eof = true;
 	    break;
 	}
-	if (i != '\0')
-	    *p++ = i;
-	if (i == '\n')
+	if (ch != '\0')
+	    *p++ = (char)ch;
+	if (ch == '\n')
 	    break;
     }
     buf_ptr = in_buffer;

Index: src/usr.bin/indent/parse.c
diff -u src/usr.bin/indent/parse.c:1.27 src/usr.bin/indent/parse.c:1.28
--- src/usr.bin/indent/parse.c:1.27	Sun Sep 26 19:37:11 2021
+++ src/usr.bin/indent/parse.c	Tue Oct  5 06:24:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.27 2021/09/26 19:37:11 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.28 2021/10/05 06:24:06 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -58,7 +58,6 @@ static void reduce(void);
 void
 parse(token_type ttype)
 {
-    int i;
 
 #ifdef debug
     printf("parse token: '%s' \"%s\"\n", token_type_name(ttype), token.s);
@@ -88,7 +87,7 @@ parse(token_type ttype)
 	    if (opt.ljust_decl) {	/* only do if we want left justified
 					 * declarations */
 		ps.ind_level = 0;
-		for (i = ps.tos - 1; i > 0; --i)
+		for (int i = ps.tos - 1; i > 0; --i)
 		    if (ps.p_stack[i] == decl)
 			++ps.ind_level;	/* indentation is number of
 					 * declaration levels deep we are */
@@ -218,7 +217,7 @@ parse(token_type ttype)
 
 #ifdef debug
     printf("parse stack:");
-    for (i = 1; i <= ps.tos; ++i)
+    for (int i = 1; i <= ps.tos; ++i)
 	printf(" ('%s' at %d)", token_type_name(ps.p_stack[i]), ps.il[i]);
     if (ps.tos == 0)
 	printf(" empty");

Reply via email to