Module Name:    src
Committed By:   rillig
Date:           Fri Apr  9 15:58:43 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: err.c externs1.h lex.c

Log Message:
lint: clean up handling of preprocessing output lines

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xlint/lint1/lex.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.104 src/usr.bin/xlint/lint1/err.c:1.105
--- src/usr.bin/xlint/lint1/err.c:1.104	Thu Apr  8 22:18:27 2021
+++ src/usr.bin/xlint/lint1/err.c	Fri Apr  9 15:58:43 2021
@@ -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 @@ static struct include_level {
 
 
 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 @@ update_position(const char *filename, in
 		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);
 }

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.102 src/usr.bin/xlint/lint1/externs1.h:1.103
--- src/usr.bin/xlint/lint1/externs1.h:1.102	Thu Apr  8 22:18:27 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Fri Apr  9 15:58:43 2021
@@ -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 @@ extern	void	internal_error(const char *,
      __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

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.25 src/usr.bin/xlint/lint1/lex.c:1.26
--- src/usr.bin/xlint/lint1/lex.c:1.25	Thu Apr  8 22:18:27 2021
+++ src/usr.bin/xlint/lint1/lex.c	Fri Apr  9 15:58:43 2021
@@ -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 @@ lex_directive(const char *yytext)
 		}
 
 		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;

Reply via email to