summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2003-10-02 21:30:30 +0000
committerru <ru@FreeBSD.org>2003-10-02 21:30:30 +0000
commitf246003ac7f1a9c9f7ad60af2eb277214fc51f4c (patch)
treece7b4dd061a28517eb5677f21263ba45f59ffd29
parent660d6cc7c1cd42f3526f3a1a124bca9801bcf306 (diff)
downloadFreeBSD-src-f246003ac7f1a9c9f7ad60af2eb277214fc51f4c.zip
FreeBSD-src-f246003ac7f1a9c9f7ad60af2eb277214fc51f4c.tar.gz
Fix a bug that prevented exists() from finding "foo/", "foo/."
and "foo/.." when ".PATH: foo" was also given. PR: bin/34062
-rw-r--r--tools/build/make_check/Makefile11
-rw-r--r--tools/regression/usr.bin/make/Makefile11
-rw-r--r--usr.bin/make/dir.c11
3 files changed, 30 insertions, 3 deletions
diff --git a/tools/build/make_check/Makefile b/tools/build/make_check/Makefile
index bf26b44..e7bede7 100644
--- a/tools/build/make_check/Makefile
+++ b/tools/build/make_check/Makefile
@@ -44,6 +44,9 @@ all:
@echo "Running test arith_expr"
@${MAKE} arith_expr || ${MAKE} failure
@echo "PASS: Test arith_expr detected no regression."
+ @echo "Running test PATH_exists"
+ @${MAKE} PATH_exists || ${MAKE} failure
+ @echo "PASS: Test PATH_exists detected no regression."
.if make(double)
# Doubly-defined targets. make(1) will warn, but use the "right" one. If it
@@ -102,6 +105,14 @@ VALUE= 0
.endif
.endif
+.if make(PATH_exists)
+PATH_exists:
+.PATH: ${.CURDIR}
+.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..)
+.error exists() failed
+.endif
+.endif
+
failure:
@echo "FAIL: Test failed: regression detected. See above."
@false
diff --git a/tools/regression/usr.bin/make/Makefile b/tools/regression/usr.bin/make/Makefile
index bf26b44..e7bede7 100644
--- a/tools/regression/usr.bin/make/Makefile
+++ b/tools/regression/usr.bin/make/Makefile
@@ -44,6 +44,9 @@ all:
@echo "Running test arith_expr"
@${MAKE} arith_expr || ${MAKE} failure
@echo "PASS: Test arith_expr detected no regression."
+ @echo "Running test PATH_exists"
+ @${MAKE} PATH_exists || ${MAKE} failure
+ @echo "PASS: Test PATH_exists detected no regression."
.if make(double)
# Doubly-defined targets. make(1) will warn, but use the "right" one. If it
@@ -102,6 +105,14 @@ VALUE= 0
.endif
.endif
+.if make(PATH_exists)
+PATH_exists:
+.PATH: ${.CURDIR}
+.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..)
+.error exists() failed
+.endif
+.endif
+
failure:
@echo "FAIL: Test failed: regression detected. See above."
@false
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index 57d1687..137a21e 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -680,7 +680,7 @@ Dir_FindFile (char *name, Lst path)
LstNode ln; /* a list element */
char *file; /* the current filename to check */
Path *p; /* current path member */
- char *cp; /* index of first slash, if any */
+ char *cp; /* final component of the name */
Boolean hasSlash; /* true if 'name' contains a / */
struct stat stb; /* Buffer for stat, if necessary */
Hash_Entry *entry; /* Entry for mtimes table */
@@ -767,9 +767,14 @@ Dir_FindFile (char *name, Lst path)
continue;
}
if (*p1 == '\0' && p2 == cp - 1) {
- DEBUGF(DIR, ("must be here but isn't -- returing NULL\n"));
Lst_Close (path);
- return ((char *) NULL);
+ if (*cp == '\0' || ISDOT(cp) || ISDOTDOT(cp)) {
+ DEBUGF(DIR, ("returning %s\n", name));
+ return (estrdup(name));
+ } else {
+ DEBUGF(DIR, ("must be here but isn't -- returning NULL\n"));
+ return ((char *) NULL);
+ }
}
}
}
OpenPOWER on IntegriCloud