From f0f930d60cd62f5fe5ba28460b43f333e8062b94 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 2 May 2008 14:23:47 +0800 Subject: [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 --- src/cd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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 -- cgit 1.4.1