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: the '+ 1' in dump_line_code is not an...
details: https://anonhg.NetBSD.org/src/rev/6c1d3a633210
branches: trunk
changeset: 991050:6c1d3a633210
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Nov 05 21:39:12 2021 +0000
description:
indent: the '+ 1' in dump_line_code is not an off-by-one error
diffstat:
usr.bin/indent/indent.h | 5 +++--
usr.bin/indent/io.c | 7 +++----
2 files changed, 6 insertions(+), 6 deletions(-)
diffs (47 lines):
diff -r 440d8dbb48d3 -r 6c1d3a633210 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Fri Nov 05 21:08:04 2021 +0000
+++ b/usr.bin/indent/indent.h Fri Nov 05 21:39:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.77 2021/11/05 19:33:28 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.78 2021/11/05 21:39:12 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -283,7 +283,8 @@
* statement */
short paren_indents[20]; /* indentation of the operand/argument of each
* level of parentheses or brackets, relative
- * to the enclosing statement */
+ * to the enclosing statement; if negative,
+ * reflected at -1 */
int cast_mask; /* indicates which close parentheses
* potentially close off casts */
int not_cast_mask; /* indicates which close parentheses
diff -r 440d8dbb48d3 -r 6c1d3a633210 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c Fri Nov 05 21:08:04 2021 +0000
+++ b/usr.bin/indent/io.c Fri Nov 05 21:39:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.114 2021/11/04 19:23:57 rillig Exp $ */
+/* $NetBSD: io.c,v 1.115 2021/11/05 21:39:12 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.114 2021/11/04 19:23:57 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.115 2021/11/05 21:39:12 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -150,8 +150,7 @@
for (int i = 0; i < ps.p_l_follow; i++) {
if (ps.paren_indents[i] >= 0) {
int paren_ind = ps.paren_indents[i];
- /* XXX: the '+ 1' smells like an off-by-one error. */
- ps.paren_indents[i] = (short)-(paren_ind + target_ind + 1);
+ ps.paren_indents[i] = (short)(-1 - (paren_ind + target_ind));
debug_println(
"setting paren_indents[%d] from %d to %d for column %d",
i, paren_ind, ps.paren_indents[i], target_ind + 1);
Home |
Main Index |
Thread Index |
Old Index