Module Name: src
Committed By: rillig
Date: Sun Oct 24 16:51:44 UTC 2021
Modified Files:
src/tests/usr.bin/indent: t_misc.sh
src/usr.bin/indent: indent.c
Log Message:
indent: fix line number counting at beginning of function body
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/t_misc.sh
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/indent/indent.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/indent/t_misc.sh
diff -u src/tests/usr.bin/indent/t_misc.sh:1.6 src/tests/usr.bin/indent/t_misc.sh:1.7
--- src/tests/usr.bin/indent/t_misc.sh:1.6 Sun Oct 24 16:46:12 2021
+++ src/tests/usr.bin/indent/t_misc.sh Sun Oct 24 16:51:44 2021
@@ -1,5 +1,5 @@
#! /bin/sh
-# $NetBSD: t_misc.sh,v 1.6 2021/10/24 16:46:12 rillig Exp $
+# $NetBSD: t_misc.sh,v 1.7 2021/10/24 16:51:44 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -309,6 +309,9 @@ opt_U_body()
atf_test_case 'line_no_counting'
line_no_counting_body()
{
+ # Before NetBSD indent.c 1.147 from 2021-10-24, indent reported the
+ # warning in line 2 instead of the correct line 3.
+
cat <<-\EOF > code.c
void line_no_counting(void)
{
@@ -316,9 +319,8 @@ line_no_counting_body()
}
EOF
- # FIXME: the wrong ')' is in line 3, not 2.
cat <<-\EOF > code.err
- /**INDENT** Warning@2: Extra ) */
+ /**INDENT** Warning@3: Extra ) */
EOF
atf_check -o 'ignore' -e 'file:code.err' \
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.146 src/usr.bin/indent/indent.c:1.147
--- src/usr.bin/indent/indent.c:1.146 Sun Oct 24 11:19:25 2021
+++ src/usr.bin/indent/indent.c Sun Oct 24 16:51:44 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.146 2021/10/24 11:19:25 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.147 2021/10/24 16:51:44 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.1
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.146 2021/10/24 11:19:25 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.147 2021/10/24 16:51:44 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -150,6 +150,8 @@ search_brace_newline(bool *force_nl)
}
*sc_end++ = '\n';
+ line_no++;
+
/*
* We may have inherited a force_nl == true from the previous token (like
* a semicolon). But once we know that a newline has been scanned in this