Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make: fix filename in warning about duplicate s...



details:   https://anonhg.NetBSD.org/src/rev/0ac95758d44f
branches:  trunk
changeset: 359746:0ac95758d44f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jan 20 19:24:53 2022 +0000

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

diffstat:

 usr.bin/make/parse.c                      |  26 +++++++++++++-------------
 usr.bin/make/unit-tests/dep-duplicate.exp |   2 +-
 usr.bin/make/unit-tests/dep-duplicate.mk  |   8 ++------
 3 files changed, 16 insertions(+), 20 deletions(-)

diffs (118 lines):

diff -r a3a8b6e94158 -r 0ac95758d44f usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Thu Jan 20 19:16:25 2022 +0000
+++ b/usr.bin/make/parse.c      Thu Jan 20 19:24:53 2022 +0000
@@ -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 @@
 }
 
 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 @@
        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 @@
        (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 @@
 
        (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 @@
 
        (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);
        }
 }
diff -r a3a8b6e94158 -r 0ac95758d44f usr.bin/make/unit-tests/dep-duplicate.exp
--- a/usr.bin/make/unit-tests/dep-duplicate.exp Thu Jan 20 19:16:25 2022 +0000
+++ b/usr.bin/make/unit-tests/dep-duplicate.exp Thu Jan 20 19:24:53 2022 +0000
@@ -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
diff -r a3a8b6e94158 -r 0ac95758d44f usr.bin/make/unit-tests/dep-duplicate.mk
--- a/usr.bin/make/unit-tests/dep-duplicate.mk  Thu Jan 20 19:16:25 2022 +0000
+++ b/usr.bin/make/unit-tests/dep-duplicate.mk  Thu Jan 20 19:24:53 2022 +0000
@@ -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; \



Home | Main Index | Thread Index | Old Index