summary refs log tree commit diff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2008-05-02 14:23:47 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2008-05-02 14:23:47 +0800
commitf0f930d60cd62f5fe5ba28460b43f333e8062b94 (patch)
treecd5cf2363e169277d8f30e7914600acfb3de3265
parent[JOBS] Fix cmdtxt crash on if statements (diff)
downloaddash-f0f930d60cd62f5fe5ba28460b43f333e8062b94.tar.gz
dash-f0f930d60cd62f5fe5ba28460b43f333e8062b94.zip
[CD] Restored non-glibc getcwd support
These days dash is expected to build with libraries other than
glibc so we need to support the old way of calling getcwd again.

Thanks to Dan McGee for reporting this bug when dash is built with
klibc.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-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