summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2000-08-05 06:52:14 +0000
committerBart Schaefer <barts@users.sourceforge.net>2000-08-05 06:52:14 +0000
commit1859bb2d0a1aa8e3d04d6964d8920f15dca202e8 (patch)
tree556983ce902f107e20918964eedd9f5c54410900
parent1ff8518b16525776c932d8856d62b79343a53b72 (diff)
downloadzsh-1859bb2d0a1aa8e3d04d6964d8920f15dca202e8.tar.gz
zsh-1859bb2d0a1aa8e3d04d6964d8920f15dca202e8.tar.xz
zsh-1859bb2d0a1aa8e3d04d6964d8920f15dca202e8.zip
12548: Tweak 12547.
-rw-r--r--ChangeLog2
-rw-r--r--Src/compat.c25
2 files changed, 13 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 217dac512..b738342b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
 2000-08-04  Bart Schaefer  <schaefer@zsh.org>
 
-	* 12547: configure.in, Src/compat.c, Src/Modules/files.c:
+	* 12547, 12458: configure.in, Src/compat.c, Src/Modules/files.c:
 	Handle ENOENT and ENOTDIR within zpathmax(), and therefore back
 	out the changes from 12541 and 12533.
 
diff --git a/Src/compat.c b/Src/compat.c
index f639c8b8a..e9c275df4 100644
--- a/Src/compat.c
+++ b/Src/compat.c
@@ -133,8 +133,6 @@ zpathmax(char *dir)
 {
     long pathmax;
 
-    if (!dir || !*dir)
-	dir = ".";
     errno = 0;
     if ((pathmax = pathconf(dir, _PC_PATH_MAX)) >= 0) {
 	/* This code is redundant if pathconf works correctly, but   *
@@ -152,18 +150,19 @@ zpathmax(char *dir)
 	    *tail = 0;
 	    pathmax = zpathmax(dir);
 	    *tail = '/';
-	    if (pathmax > 0) {
-		if (strlen(dir) < pathmax)
-		    return pathmax;
-		else
-		    errno = ENAMETOOLONG;
-	    }
+	} else {
+	    errno = 0;
+	    if (tail)
+		pathmax = pathconf("/", _PC_PATH_MAX);
+	    else
+		pathmax = pathconf(".", _PC_PATH_MAX);
+	}
+	if (pathmax > 0) {
+	    if (strlen(dir) < pathmax)
+		return pathmax;
+	    else
+		errno = ENAMETOOLONG;
 	}
-	/* else                                                          *
-	 * Either we're at the root (tail == dir) or we're on the first  *
-	 * component of a relative path (tail == NULL).  Either way we   *
-	 * have nothing to do here, the error from pathconf() is real.   *
-	 * Perhaps our current working directory has been removed?       */
     }
     if (errno)
 	return -1;