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: fix line number counting at beginning...
details: https://anonhg.NetBSD.org/src/rev/b657ab8f5240
branches: trunk
changeset: 1024452:b657ab8f5240
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Oct 24 16:51:44 2021 +0000
description:
indent: fix line number counting at beginning of function body
diffstat:
tests/usr.bin/indent/t_misc.sh | 8 +++++---
usr.bin/indent/indent.c | 6 ++++--
2 files changed, 9 insertions(+), 5 deletions(-)
diffs (58 lines):
diff -r ecb6456fa694 -r b657ab8f5240 tests/usr.bin/indent/t_misc.sh
--- a/tests/usr.bin/indent/t_misc.sh Sun Oct 24 16:46:12 2021 +0000
+++ b/tests/usr.bin/indent/t_misc.sh Sun Oct 24 16:51:44 2021 +0000
@@ -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 @@
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 @@
}
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' \
diff -r ecb6456fa694 -r b657ab8f5240 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Sun Oct 24 16:46:12 2021 +0000
+++ b/usr.bin/indent/indent.c Sun Oct 24 16:51:44 2021 +0000
@@ -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 @@
#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 @@
}
*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
Home |
Main Index |
Thread Index |
Old Index