Module Name: src
Committed By: rillig
Date: Thu Dec 16 03:53:13 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint2: t_lint2.sh
src/usr.bin/xlint/lint2: read.c
Log Message:
lint: improve error message for missing newline in .ln file
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint2/t_lint2.sh
cvs rdiff -u -r1.71 -r1.72 src/usr.bin/xlint/lint2/read.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/xlint/lint2/t_lint2.sh
diff -u src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.11 src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.12
--- src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.11 Thu Dec 16 03:44:48 2021
+++ src/tests/usr.bin/xlint/lint2/t_lint2.sh Thu Dec 16 03:53:13 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_lint2.sh,v 1.11 2021/12/16 03:44:48 rillig Exp $
+# $NetBSD: t_lint2.sh,v 1.12 2021/12/16 03:53:13 rillig Exp $
#
# Copyright (c) 2021 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -182,12 +182,14 @@ missing_newline_head()
missing_newline_body()
{
+ # Before read.c 1.71 from 2021-12-16, the error message was just 'c'
+ # without any textual description or context, and the line number was
+ # off by one, it was reported as line 0.
+
printf '1d1.1e5func' > 'input.ln'
- # FIXME: The error message is not understandable.
- # FIXME: The line number is off by one.
atf_check -s 'exit:1' \
- -e 'match:^.*: error: input\.ln:0: c \(for .1d1\.1e5func.\)$' \
+ -e 'match:^.*: error: input\.ln:1: missing newline after .c. \(for .1d1\.1e5func.\)$' \
"$lint2" 'input.ln'
}
Index: src/usr.bin/xlint/lint2/read.c
diff -u src/usr.bin/xlint/lint2/read.c:1.71 src/usr.bin/xlint/lint2/read.c:1.72
--- src/usr.bin/xlint/lint2/read.c:1.71 Sun Nov 28 09:16:46 2021
+++ src/usr.bin/xlint/lint2/read.c Thu Dec 16 03:53:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.71 2021/11/28 09:16:46 rillig Exp $ */
+/* $NetBSD: read.c,v 1.72 2021/12/16 03:53:13 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: read.c,v 1.71 2021/11/28 09:16:46 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.72 2021/12/16 03:53:13 rillig Exp $");
#endif
#include <ctype.h>
@@ -147,8 +147,6 @@ read_ln_line(const char *line, size_t le
char rt;
pos_t pos;
- flines[srcfile]++;
-
cp = line;
/* line number in csrcfile */
@@ -229,9 +227,11 @@ readfile(const char *name)
err(1, "cannot open %s", name);
while ((line = fgetln(inp, &len)) != NULL) {
+ flines[srcfile]++;
+
readfile_line = line;
if (len == 0 || line[len - 1] != '\n')
- inperr("%s", &line[len - 1]);
+ inperr("missing newline after '%s'", &line[len - 1]);
line[len - 1] = '\0';
read_ln_line(line, len);