Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: clean up handling of preprocessing...



details:   https://anonhg.NetBSD.org/src/rev/5a7d689fa897
branches:  trunk
changeset: 961075:5a7d689fa897
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Apr 09 15:58:43 2021 +0000

description:
lint: clean up handling of preprocessing output lines

No functional change.

diffstat:

 usr.bin/xlint/lint1/err.c      |  16 +++++++++-------
 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/lex.c      |   8 ++++----
 3 files changed, 15 insertions(+), 13 deletions(-)

diffs (99 lines):

diff -r 5cf71fdcbccc -r 5a7d689fa897 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Fri Apr 09 14:42:00 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Fri Apr 09 15:58:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.104 2021/04/08 22:18:27 rillig Exp $ */
+/*     $NetBSD: err.c,v 1.105 2021/04/09 15:58:43 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.104 2021/04/08 22:18:27 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.105 2021/04/09 15:58:43 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -407,8 +407,7 @@
 
 
 void
-update_position(const char *filename, int lineno,
-               bool is_begin, bool is_end, bool is_system)
+update_location(const char *filename, int lineno, bool is_begin, bool is_end)
 {
        struct include_level *top;
 
@@ -431,17 +430,20 @@
                top->filename = filename;
                top->lineno = lineno;
        }
-
-       in_system_header = is_system;
 }
 
 static void
 print_stack_trace(void)
 {
-       struct include_level *top;
+       const struct include_level *top;
 
        if ((top = includes) == NULL)
                return;
+       /*
+        * Skip the innermost include level since it is already listed in the
+        * diagnostic itself.  Furthermore, its lineno is the line number of
+        * the last '#' line, not the current line.
+        */
        for (top = top->by; top != NULL; top = top->by)
                printf("\tincluded from %s(%d)\n", top->filename, top->lineno);
 }
diff -r 5cf71fdcbccc -r 5a7d689fa897 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Fri Apr 09 14:42:00 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Fri Apr 09 15:58:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.102 2021/04/08 22:18:27 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.103 2021/04/09 15:58:43 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -128,7 +128,7 @@
      __attribute__((__noreturn__,__format__(__printf__, 3, 4)));
 extern void    assert_failed(const char *, int, const char *, const char *)
                __attribute__((__noreturn__));
-extern void    update_position(const char *, int, bool, bool, bool);
+extern void    update_location(const char *, int, bool, bool);
 
 /*
  * decl.c
diff -r 5cf71fdcbccc -r 5a7d689fa897 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Fri Apr 09 14:42:00 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Fri Apr 09 15:58:43 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.25 2021/04/08 22:18:27 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.26 2021/04/09 15:58:43 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: lex.c,v 1.25 2021/04/08 22:18:27 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.26 2021/04/09 15:58:43 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -1151,8 +1151,8 @@
                }
 
                parse_line_directive_flags(cp, &is_begin, &is_end, &is_system);
-               update_position(curr_pos.p_file, (int)ln,
-                   is_begin, is_end, is_system);
+               update_location(curr_pos.p_file, (int)ln, is_begin, is_end);
+               in_system_header = is_system;
        }
        curr_pos.p_line = (int)ln - 1;
        curr_pos.p_uniq = 0;



Home | Main Index | Thread Index | Old Index