Thu Mar 11 22:15:44 2021 UTC ()
indent: use consistent array indexing

No functional change.


(rillig)
diff -r1.32 -r1.33 src/usr.bin/indent/lexi.c
diff -r1.15 -r1.16 src/usr.bin/indent/pr_comment.c

cvs diff -r1.32 -r1.33 src/usr.bin/indent/lexi.c (expand / switch to context diff)
--- src/usr.bin/indent/lexi.c 2021/03/11 21:47:36 1.32
+++ src/usr.bin/indent/lexi.c 2021/03/11 22:15:44 1.33
@@ -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
 	     */

cvs diff -r1.15 -r1.16 src/usr.bin/indent/pr_comment.c (expand / switch to context diff)
--- src/usr.bin/indent/pr_comment.c 2021/03/09 16:48:28 1.15
+++ src/usr.bin/indent/pr_comment.c 2021/03/11 22:15:44 1.16
@@ -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