Module Name:    src
Committed By:   rillig
Date:           Thu Jan 20 19:24:53 UTC 2022

Modified Files:
        src/usr.bin/make: parse.c
        src/usr.bin/make/unit-tests: dep-duplicate.exp dep-duplicate.mk

Log Message:
make: fix filename in warning about duplicate script (since 2018-12-22)


To generate a diff of this commit:
cvs rdiff -u -r1.652 -r1.653 src/usr.bin/make/parse.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dep-duplicate.exp \
    src/usr.bin/make/unit-tests/dep-duplicate.mk

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/make/parse.c
diff -u src/usr.bin/make/parse.c:1.652 src/usr.bin/make/parse.c:1.653
--- src/usr.bin/make/parse.c:1.652	Sun Jan 16 09:41:28 2022
+++ src/usr.bin/make/parse.c	Thu Jan 20 19:24:53 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.652 2022/01/16 09:41:28 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.653 2022/01/20 19:24:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.652 2022/01/16 09:41:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.653 2022/01/20 19:24:53 rillig Exp $");
 
 /*
  * A file being read.
@@ -412,12 +412,12 @@ FindKeyword(const char *str)
 }
 
 static void
-PrintLocation(FILE *f, const char *fname, size_t lineno)
+PrintLocation(FILE *f, bool useVars, const char *fname, size_t lineno)
 {
 	char dirbuf[MAXPATHLEN + 1];
 	FStr dir, base;
 
-	if (fname[0] == '/' || strcmp(fname, "(stdin)") == 0) {
+	if (!useVars || fname[0] == '/' || strcmp(fname, "(stdin)") == 0) {
 		(void)fprintf(f, "\"%s\" line %u: ", fname, (unsigned)lineno);
 		return;
 	}
@@ -439,8 +439,8 @@ PrintLocation(FILE *f, const char *fname
 	FStr_Done(&dir);
 }
 
-static void MAKE_ATTR_PRINTFLIKE(5, 0)
-ParseVErrorInternal(FILE *f, const char *fname, size_t lineno,
+static void MAKE_ATTR_PRINTFLIKE(6, 0)
+ParseVErrorInternal(FILE *f, bool useVars, const char *fname, size_t lineno,
 		    ParseErrorLevel type, const char *fmt, va_list ap)
 {
 	static bool fatal_warning_error_printed = false;
@@ -448,7 +448,7 @@ ParseVErrorInternal(FILE *f, const char 
 	(void)fprintf(f, "%s: ", progname);
 
 	if (fname != NULL)
-		PrintLocation(f, fname, lineno);
+		PrintLocation(f, useVars, fname, lineno);
 	if (type == PARSE_WARNING)
 		(void)fprintf(f, "warning: ");
 	(void)vfprintf(f, fmt, ap);
@@ -477,13 +477,13 @@ ParseErrorInternal(const char *fname, si
 
 	(void)fflush(stdout);
 	va_start(ap, fmt);
-	ParseVErrorInternal(stderr, fname, lineno, type, fmt, ap);
+	ParseVErrorInternal(stderr, false, fname, lineno, type, fmt, ap);
 	va_end(ap);
 
 	if (opts.debug_file != stdout && opts.debug_file != stderr) {
 		va_start(ap, fmt);
-		ParseVErrorInternal(opts.debug_file, fname, lineno, type,
-		    fmt, ap);
+		ParseVErrorInternal(opts.debug_file, false, fname, lineno,
+		    type, fmt, ap);
 		va_end(ap);
 	}
 }
@@ -514,13 +514,13 @@ Parse_Error(ParseErrorLevel type, const 
 
 	(void)fflush(stdout);
 	va_start(ap, fmt);
-	ParseVErrorInternal(stderr, fname, lineno, type, fmt, ap);
+	ParseVErrorInternal(stderr, true, fname, lineno, type, fmt, ap);
 	va_end(ap);
 
 	if (opts.debug_file != stdout && opts.debug_file != stderr) {
 		va_start(ap, fmt);
-		ParseVErrorInternal(opts.debug_file, fname, lineno, type,
-		    fmt, ap);
+		ParseVErrorInternal(opts.debug_file, true, fname, lineno,
+		    type, fmt, ap);
 		va_end(ap);
 	}
 }

Index: src/usr.bin/make/unit-tests/dep-duplicate.exp
diff -u src/usr.bin/make/unit-tests/dep-duplicate.exp:1.2 src/usr.bin/make/unit-tests/dep-duplicate.exp:1.3
--- src/usr.bin/make/unit-tests/dep-duplicate.exp:1.2	Thu Jan 20 19:16:25 2022
+++ src/usr.bin/make/unit-tests/dep-duplicate.exp	Thu Jan 20 19:24:53 2022
@@ -1,4 +1,4 @@
 make: "dep-duplicate.inc" line 1: warning: duplicate script for target "all" ignored
-make: "dep-duplicate.inc" line 3: warning: using previous script for "all" defined here
+make: "dep-duplicate.main" line 3: warning: using previous script for "all" defined here
 main-output
 exit status 0
Index: src/usr.bin/make/unit-tests/dep-duplicate.mk
diff -u src/usr.bin/make/unit-tests/dep-duplicate.mk:1.2 src/usr.bin/make/unit-tests/dep-duplicate.mk:1.3
--- src/usr.bin/make/unit-tests/dep-duplicate.mk:1.2	Thu Jan 20 19:16:25 2022
+++ src/usr.bin/make/unit-tests/dep-duplicate.mk	Thu Jan 20 19:24:53 2022
@@ -1,4 +1,4 @@
-# $NetBSD: dep-duplicate.mk,v 1.2 2022/01/20 19:16:25 rillig Exp $
+# $NetBSD: dep-duplicate.mk,v 1.3 2022/01/20 19:24:53 rillig Exp $
 #
 # Test for a target whose commands are defined twice.  This generates a
 # warning, not an error, so ensure that the correct commands are kept.
@@ -6,11 +6,7 @@
 # Also ensure that the diagnostics mention the correct file in case of
 # included files.  Since parse.c 1.231 from 2018-12-22 and before parse.c
 # 1.653 from 2022-01-20, the wrong filename had been printed if the file of
-# the first commands section was in a file that was included by its relative
-# path.
-
-# expect: make: "dep-duplicate.inc" line 3: warning: using previous script for "all" defined here
-# FIXME: The file "dep-duplicate.inc" has no line 3.
+# the first commands section was included by its relative path.
 
 all: .PHONY
 	@exec > dep-duplicate.main; \

Reply via email to