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: don't print null filename in stack traces



details:   https://anonhg.NetBSD.org/src/rev/7fe95443c671
branches:  trunk
changeset: 374720:7fe95443c671
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed May 10 16:10:02 2023 +0000

description:
make: don't print null filename in stack traces

~~~makefile
!= printf '%s\n' '.include "2.mk"' > 1.mk
!= printf '%s\n' '!= rm 1.mk' '.info message' > 2.mk

.MAKEFLAGS: -dp
.include "1.mk"
.MAKEFLAGS: -d0

all:
~~~

diffstat:

 usr.bin/make/parse.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r 1a1eeaef9272 -r 7fe95443c671 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Wed May 10 15:57:16 2023 +0000
+++ b/usr.bin/make/parse.c      Wed May 10 16:10:02 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.697 2023/05/10 15:57:16 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.698 2023/05/10 16:10:02 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.697 2023/05/10 15:57:16 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.698 2023/05/10 16:10:02 rillig Exp $");
 
 /*
  * A file being read.
@@ -384,8 +384,11 @@ PrintStackTrace(bool includingInnermost)
                const char *fname = entry->name.str;
                char dirbuf[MAXPATHLEN + 1];
 
-               if (fname[0] != '/' && strcmp(fname, "(stdin)") != 0)
-                       fname = realpath(fname, dirbuf);
+               if (fname[0] != '/' && strcmp(fname, "(stdin)") != 0) {
+                       const char *realPath = realpath(fname, dirbuf);
+                       if (realPath != NULL)
+                               fname = realPath;
+               }
 
                if (entry->forLoop != NULL) {
                        char *details = ForLoop_Details(entry->forLoop);



Home | Main Index | Thread Index | Old Index