Module Name: src Committed By: rillig Date: Fri Nov 5 21:39:12 UTC 2021
Modified Files: src/usr.bin/indent: indent.h io.c Log Message: indent: the '+ 1' in dump_line_code is not an off-by-one error To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/usr.bin/indent/indent.h cvs rdiff -u -r1.114 -r1.115 src/usr.bin/indent/io.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/indent.h diff -u src/usr.bin/indent/indent.h:1.77 src/usr.bin/indent/indent.h:1.78 --- src/usr.bin/indent/indent.h:1.77 Fri Nov 5 19:33:28 2021 +++ src/usr.bin/indent/indent.h Fri Nov 5 21:39:12 2021 @@ -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 @@ extern struct parser_state { * 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 Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.114 src/usr.bin/indent/io.c:1.115 --- src/usr.bin/indent/io.c:1.114 Thu Nov 4 19:23:57 2021 +++ src/usr.bin/indent/io.c Fri Nov 5 21:39:12 2021 @@ -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 @@ static char sccsid[] = "@(#)io.c 8.1 (Be #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 @@ dump_line_code(int ind) 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);