Module Name: src
Committed By: rillig
Date: Thu Mar 11 22:15:44 UTC 2021
Modified Files:
src/usr.bin/indent: lexi.c pr_comment.c
Log Message:
indent: use consistent array indexing
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.15 -r1.16 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/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.32 src/usr.bin/indent/lexi.c:1.33
--- src/usr.bin/indent/lexi.c:1.32 Thu Mar 11 21:47:36 2021
+++ src/usr.bin/indent/lexi.c Thu Mar 11 22:15:44 2021
@@ -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 @@ static char sccsid[] = "@(#)lexi.c 8.1 (
#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 @@ lexi(struct parser_state *state)
*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 @@ stop_lit:
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
*/
Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.15 src/usr.bin/indent/pr_comment.c:1.16
--- src/usr.bin/indent/pr_comment.c:1.15 Tue Mar 9 16:48:28 2021
+++ src/usr.bin/indent/pr_comment.c Thu Mar 11 22:15:44 2021
@@ -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 @@ static char sccsid[] = "@(#)pr_comment.c
#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 @@ pr_comment(void)
}
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