Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make put back canonicalization, but avoid doing it f...
details: https://anonhg.NetBSD.org/src/rev/b0019c54f590
branches: trunk
changeset: 754951:b0019c54f590
user: christos <christos%NetBSD.org@localhost>
date: Mon May 17 17:01:16 2010 +0000
description:
put back canonicalization, but avoid doing it for files that don't contain /
>From dholland
diffstat:
usr.bin/make/main.c | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diffs (51 lines):
diff -r db6e52f609b0 -r b0019c54f590 usr.bin/make/main.c
--- a/usr.bin/make/main.c Mon May 17 12:38:04 2010 +0000
+++ b/usr.bin/make/main.c Mon May 17 17:01:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.186 2010/05/10 15:54:21 sjg Exp $ */
+/* $NetBSD: main.c,v 1.187 2010/05/17 17:01:16 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.186 2010/05/10 15:54:21 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.187 2010/05/17 17:01:16 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.186 2010/05/10 15:54:21 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.187 2010/05/17 17:01:16 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -900,7 +900,22 @@
* MFLAGS also gets initialized empty, for compatibility.
*/
Parse_Init();
- p1 = argv[0];
+ if (argv[0][0] == '/' || strchr(argv[0], '/') == NULL) {
+ /*
+ * Leave alone if it is an absolute path, or if it does
+ * not contain a '/' in which case we need to find it in
+ * the path, like execvp(3) and the shells do.
+ */
+ p1 = argv[0];
+ } else {
+ /*
+ * A relative path, canonicalize it.
+ */
+ p1 = realpath(argv[0], mdpath);
+ if (!p1 || *p1 != '/' || stat(p1, &sb) < 0) {
+ p1 = argv[0]; /* realpath failed */
+ }
+ }
Var_Set("MAKE", p1, VAR_GLOBAL, 0);
Var_Set(".MAKE", p1, VAR_GLOBAL, 0);
Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0);
Home |
Main Index |
Thread Index |
Old Index