Fix a bug that prevented exists() from finding "foo/", "foo/."
and "foo/.." when ".PATH: foo" was also given. PR: bin/34062
This commit is contained in:
parent
833d1871ba
commit
21159d1687
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user