summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2004-11-29 16:26:12 +0000
committerWayne Davison <wayned@users.sourceforge.net>2004-11-29 16:26:12 +0000
commit8b136c84d2b233f71844039a6378ececae4290a1 (patch)
treea921f6d5b735d06c415cf448b6863597bae01bba /Src
parentd2c67e5e19953c2bee353635c3e8aec7c38f8d57 (diff)
downloadzsh-8b136c84d2b233f71844039a6378ececae4290a1.tar.gz
zsh-8b136c84d2b233f71844039a6378ececae4290a1.tar.xz
zsh-8b136c84d2b233f71844039a6378ececae4290a1.zip
Corrected the error-return comment for zchdir() and optimized the
HAVE_FCHDIR error-return code.
Diffstat (limited to 'Src')
-rw-r--r--Src/compat.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/Src/compat.c b/Src/compat.c
index ba077d3a0..b8e1a6f0f 100644
--- a/Src/compat.c
+++ b/Src/compat.c
@@ -376,7 +376,7 @@ zgetcwd(void)
     return zgetdir(NULL);
 }
 
-/* chdir with arbitrary long pathname.  Returns 0 on success, 0 on normal *
+/* chdir with arbitrary long pathname.  Returns 0 on success, -1 on normal *
  * failure and -2 when chdir failed and the current directory is lost.  */
 
 /**/
@@ -418,17 +418,16 @@ zchdir(char *dir)
 	dir = s;
     }
 #ifdef HAVE_FCHDIR
-    if (currdir == -1 || (currdir >= 0 && fchdir(currdir))) {
-	if (currdir >= 0)
+    if (currdir >= 0) {
+	if (fchdir(currdir) < 0) {
 	    close(currdir);
-	return -2;
-    }
-    if (currdir >= 0)
+	    return -2;
+	}
 	close(currdir);
-    return -1;
-#else
-    return currdir == -2 ? -1 : -2;
+	return -1;
+    }
 #endif
+    return currdir == -2 ? -1 : -2;
 }
 
 /*