summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/cd.c7
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f5e0dbc..5216521 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-05-02  Herbert Xu <herbert@gondor.apana.org.au>
+
+	* Restored non-glibc getcwd support.
+
 2008-03-07  Larry Doolittle <ldoolitt@recycle.lbl.gov>
 
 	* Fix cmdtxt crash on if statements.
diff --git a/src/cd.c b/src/cd.c
index 1849c69..cb6e24d 100644
--- a/src/cd.c
+++ b/src/cd.c
@@ -241,8 +241,6 @@ updatepwd(const char *dir)
 }
 
 
-#define MAXPWD 256
-
 /*
  * Find out what the current directory is. If we already know the current
  * directory, this routine returns immediately.
@@ -251,8 +249,13 @@ inline
 STATIC char *
 getpwd()
 {
+#ifdef _GNU_SOURCE
 	char *dir = getcwd(0, 0);
 	return dir ? dir : nullstr;
+#else
+	char buf[PATH_MAX];
+	return getcwd(buf, sizeof(buf)) ? savestr(buf) : nullstr;
+#endif
 }
 
 int