summary refs log tree commit diff
path: root/Src
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 /Src
parent1ff8518b16525776c932d8856d62b79343a53b72 (diff)
downloadzsh-1859bb2d0a1aa8e3d04d6964d8920f15dca202e8.tar.gz
zsh-1859bb2d0a1aa8e3d04d6964d8920f15dca202e8.tar.xz
zsh-1859bb2d0a1aa8e3d04d6964d8920f15dca202e8.zip
12548: Tweak 12547.
Diffstat (limited to 'Src')
-rw-r--r--Src/compat.c25
1 files changed, 12 insertions, 13 deletions
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;