summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2018-12-22 21:32:17 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2018-12-22 21:32:17 +0000
commit4e6c593faabfd45028e88e42b3456080669bdabf (patch)
tree37da31a3e20012aeafc0ca71ffb41d33d5d9fe3e /parse.c
parent14ed4acf373acf4a08f80acf1689d5f967460af0 (diff)
Notes
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/parse.c b/parse.c
index 7f18fdc91433..a7d7a4d94ef5 100644
--- a/parse.c
+++ b/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.229 2018/04/05 16:31:54 christos Exp $ */
+/* $NetBSD: parse.c,v 1.231 2018/12/22 00:36:32 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.229 2018/04/05 16:31:54 christos Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.231 2018/12/22 00:36:32 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.229 2018/04/05 16:31:54 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.231 2018/12/22 00:36:32 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -691,21 +691,32 @@ ParseVErrorInternal(FILE *f, const char *cfname, size_t clineno, int type,
if (cfname != NULL) {
(void)fprintf(f, "\"");
if (*cfname != '/' && strcmp(cfname, "(stdin)") != 0) {
- char *cp;
- const char *dir;
+ char *cp, *cp2;
+ const char *dir, *fname;
/*
* Nothing is more annoying than not knowing
- * which Makefile is the culprit.
+ * which Makefile is the culprit; we try ${.PARSEDIR}
+ * and apply realpath(3) if not absolute.
*/
dir = Var_Value(".PARSEDIR", VAR_GLOBAL, &cp);
- if (dir == NULL || *dir == '\0' ||
- (*dir == '.' && dir[1] == '\0'))
- dir = Var_Value(".CURDIR", VAR_GLOBAL, &cp);
if (dir == NULL)
dir = ".";
-
- (void)fprintf(f, "%s/%s", dir, cfname);
+ if (*dir != '/') {
+ dir = cp2 = realpath(dir, NULL);
+ free(cp);
+ cp = cp2; /* cp2 set to NULL by Var_Value */
+ }
+ fname = Var_Value(".PARSEFILE", VAR_GLOBAL, &cp2);
+ if (fname == NULL) {
+ if ((fname = strrchr(cfname, '/')))
+ fname++;
+ else
+ fname = cfname;
+ }
+ (void)fprintf(f, "%s/%s", dir, fname);
+ free(cp2);
+ free(cp);
} else
(void)fprintf(f, "%s", cfname);