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 local char variable, reduce sc...



details:   https://anonhg.NetBSD.org/src/rev/2b6a3d65e471
branches:  trunk
changeset: 988234:2b6a3d65e471
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Oct 05 06:24:06 2021 +0000

description:
indent: rename local char variable, reduce scope of counters

No functional change.

diffstat:

 usr.bin/indent/io.c    |  14 +++++++-------
 usr.bin/indent/parse.c |   7 +++----
 2 files changed, 10 insertions(+), 11 deletions(-)

diffs (82 lines):

diff -r 5605c3725e1c -r 2b6a3d65e471 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Tue Oct 05 06:15:24 2021 +0000
+++ b/usr.bin/indent/io.c       Tue Oct 05 06:24:06 2021 +0000
@@ -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 @@
 
 #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 @@
 {
     /* 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 @@
            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;
diff -r 5605c3725e1c -r 2b6a3d65e471 usr.bin/indent/parse.c
--- a/usr.bin/indent/parse.c    Tue Oct 05 06:15:24 2021 +0000
+++ b/usr.bin/indent/parse.c    Tue Oct 05 06:24:06 2021 +0000
@@ -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 @@
 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 @@
            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 @@
 
 #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");



Home | Main Index | Thread Index | Old Index