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: use consistent array indexing



details:   https://anonhg.NetBSD.org/src/rev/1b5569b0fa85
branches:  trunk
changeset: 1019480:1b5569b0fa85
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Mar 11 22:15:44 2021 +0000

description:
indent: use consistent array indexing

No functional change.

diffstat:

 usr.bin/indent/lexi.c       |  8 ++++----
 usr.bin/indent/pr_comment.c |  6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diffs (63 lines):

diff -r ad3be46fcee9 -r 1b5569b0fa85 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Thu Mar 11 21:47:36 2021 +0000
+++ b/usr.bin/indent/lexi.c     Thu Mar 11 22:15:44 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.32 2021/03/11 21:47:36 rillig Exp $ */
+/*     $NetBSD: lexi.c,v 1.33 2021/03/11 22:15:44 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.32 2021/03/11 21:47:36 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.33 2021/03/11 22:15:44 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -331,7 +331,7 @@
                *buf_ptr == '_' || *buf_ptr == '$') {
                /* fill_buffer() terminates buffer with newline */
                if (*buf_ptr == '\\') {
-                   if (*(buf_ptr + 1) == '\n') {
+                   if (buf_ptr[1] == '\n') {
                        buf_ptr += 2;
                        if (buf_ptr >= buf_end)
                            fill_buffer();
@@ -650,7 +650,7 @@
            unary_delim = state->last_u_d;
            break;
        }
-       while (*(e_token - 1) == *buf_ptr || *buf_ptr == '=') {
+       while (e_token[-1] == *buf_ptr || *buf_ptr == '=') {
            /*
             * handle ||, &&, etc, and also things as in int *****i
             */
diff -r ad3be46fcee9 -r 1b5569b0fa85 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Thu Mar 11 21:47:36 2021 +0000
+++ b/usr.bin/indent/pr_comment.c       Thu Mar 11 22:15:44 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pr_comment.c,v 1.15 2021/03/09 16:48:28 rillig Exp $   */
+/*     $NetBSD: pr_comment.c,v 1.16 2021/03/11 22:15:44 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.15 2021/03/09 16:48:28 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.16 2021/03/11 22:15:44 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -283,7 +283,7 @@
            }
            else {
                ps.last_nl = 1;
-               if (*(e_com - 1) == ' ' || *(e_com - 1) == '\t')
+               if (e_com[-1] == ' ' || e_com[-1] == '\t')
                    last_bl = e_com - 1;
                /*
                 * if there was a space at the end of the last line, remember



Home | Main Index | Thread Index | Old Index