about summary refs log tree commit diff
path: root/configure.ac
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-06-14 11:48:06 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-06-14 11:48:06 +0000
commit825c1a1141a5724b980d0c1af7fe138ff7d10ae4 (patch)
treee080ee07d30d4dfad0f1ab5039e398f03738d907 /configure.ac
parent27254b788f2ebeb4f6a2c7f308a9c774022070b0 (diff)
downloadzsh-825c1a1141a5724b980d0c1af7fe138ff7d10ae4.tar.gz
zsh-825c1a1141a5724b980d0c1af7fe138ff7d10ae4.tar.xz
zsh-825c1a1141a5724b980d0c1af7fe138ff7d10ae4.zip
28010: use getcwd() as fallback
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac30
1 files changed, 29 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 262fe5d14..a93eb5115 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1170,7 +1170,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \
 	       regcomp regexec regerror regfree \
 	       gdbm_open getxattr \
 	       realpath canonicalize_file_name \
-	       symlink)
+	       symlink getcwd)
 AC_FUNC_STRCOLL
 
 if test x$enable_cap = xyes; then
@@ -1898,6 +1898,34 @@ if test x$zsh_cv_use_getcwd = xyes; then
   AC_DEFINE(USE_GETCWD)
 fi
 
+dnl GNU getcwd() can allocate as much space as necessary for a
+dnl directory name, preventing guessing games.
+AH_TEMPLATE([GETCWD_CALLS_MALLOC],
+[Define to 1 if getcwd() calls malloc to allocate memory.])
+if test x$ac_cv_func_getcwd = xyes; then
+  AC_CACHE_CHECK(whether getcwd calls malloc to allocate memory,
+  zsh_cv_getcwd_malloc,
+  [AC_TRY_RUN([
+#include <unistd.h>
+#include <string.h>
+int main() {
+    char buf[1024], *ptr1, *ptr2;
+    ptr1 = getcwd(buf, 1024);
+    ptr2 = getcwd(NULL, 0);
+    if (ptr1 && ptr2 && !strcmp(ptr1, ptr2)) {
+      return 0;
+    }
+    return 1;
+}
+],
+  zsh_cv_getcwd_malloc=yes,
+  zsh_cv_getcwd_malloc=no,
+  zsh_cv_getcwd_malloc=no)])
+  if test x$zsh_cv_getcwd_malloc = xyes; then
+    AC_DEFINE(GETCWD_CALLS_MALLOC)
+  fi
+fi
+
 dnl CHECK FOR setproctitle() FOR jobs -Z / ARGV0
 AH_TEMPLATE([HAVE_SETPROCTITLE],
 [Define to 1 if the system supports `setproctitle' to change process name])