Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint2 lint: improve error message for missing ...



details:   https://anonhg.NetBSD.org/src/rev/b4f1857dec35
branches:  trunk
changeset: 1027698:b4f1857dec35
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Dec 16 03:53:13 2021 +0000

description:
lint: improve error message for missing newline in .ln file

diffstat:

 tests/usr.bin/xlint/lint2/t_lint2.sh |  10 ++++++----
 usr.bin/xlint/lint2/read.c           |  10 +++++-----
 2 files changed, 11 insertions(+), 9 deletions(-)

diffs (67 lines):

diff -r 968cc4567c8e -r b4f1857dec35 tests/usr.bin/xlint/lint2/t_lint2.sh
--- a/tests/usr.bin/xlint/lint2/t_lint2.sh      Thu Dec 16 03:44:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint2/t_lint2.sh      Thu Dec 16 03:53:13 2021 +0000
@@ -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_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'
 }
 
diff -r 968cc4567c8e -r b4f1857dec35 usr.bin/xlint/lint2/read.c
--- a/usr.bin/xlint/lint2/read.c        Thu Dec 16 03:44:48 2021 +0000
+++ b/usr.bin/xlint/lint2/read.c        Thu Dec 16 03:53:13 2021 +0000
@@ -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 @@
        char rt;
        pos_t pos;
 
-       flines[srcfile]++;
-
        cp = line;
 
        /* line number in csrcfile */
@@ -229,9 +227,11 @@
                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);



Home | Main Index | Thread Index | Old Index