Consolidate all uses of PATH_MAX in *.m4 files.
authorBruno Haible <bruno@clisp.org>
Thu, 22 Sep 2011 12:17:57 +0000 (14:17 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 22 Sep 2011 12:19:43 +0000 (14:19 +0200)
* m4/pathmax.m4 (gl_PATHMAX_SNIPPET, gl_PATHMAX_SNIPPET_PREREQ): New
macros.
* m4/chdir-long.m4 (gl_FUNC_CHDIR_LONG): Use gl_PATHMAX_SNIPPET_PREREQ
and gl_PATHMAX_SNIPPET.
* m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Likewise.
* m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX): Likewise.
* modules/chdir-long (Files): Add m4/pathmax.m4.
* modules/getcwd (Files): Likewise.

ChangeLog
m4/chdir-long.m4
m4/getcwd-abort-bug.m4
m4/getcwd-path-max.m4
m4/pathmax.m4
modules/chdir-long
modules/getcwd

index f6f2750..df95702 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2011-09-21  Bruno Haible  <bruno@clisp.org>
 
+       Consolidate all uses of PATH_MAX in *.m4 files.
+       * m4/pathmax.m4 (gl_PATHMAX_SNIPPET, gl_PATHMAX_SNIPPET_PREREQ): New
+       macros.
+       * m4/chdir-long.m4 (gl_FUNC_CHDIR_LONG): Use gl_PATHMAX_SNIPPET_PREREQ
+       and gl_PATHMAX_SNIPPET.
+       * m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Likewise.
+       * m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX): Likewise.
+       * modules/chdir-long (Files): Add m4/pathmax.m4.
+       * modules/getcwd (Files): Likewise.
+
+2011-09-21  Bruno Haible  <bruno@clisp.org>
+
        ftruncate: Un-deprecate, concentrate on Win32 support.
        * modules/ftruncate (Status, Notice): Remove sections.
        (Depends-on): Add largefile.
index fdba191..8c38c04 100644 (file)
@@ -1,4 +1,4 @@
-#serial 13
+#serial 14
 
 # Use Gnulib's robust chdir function.
 # It can handle arbitrarily long directory names, which means
@@ -15,16 +15,12 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_CHDIR_LONG],
 [
-  AC_CHECK_HEADERS_ONCE([unistd.h])
+  AC_REQUIRE([gl_PATHMAX_SNIPPET_PREREQ])
   AC_CACHE_CHECK([whether this system has an arbitrary file name length limit],
     gl_cv_have_arbitrary_file_name_length_limit,
     [AC_EGREP_CPP([have_arbitrary_file_name_length_limit],
-                  [
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <limits.h>
-#if defined PATH_MAX || defined MAXPATHLEN
+                  gl_PATHMAX_SNIPPET[
+#ifdef PATH_MAX
 have_arbitrary_file_name_length_limit
 #endif],
     gl_cv_have_arbitrary_file_name_length_limit=yes,
index 0d3f34f..60ea03c 100644 (file)
@@ -1,4 +1,4 @@
-# serial 5
+# serial 6
 # Determine whether getcwd aborts when the length of the working directory
 # name is unusually large.  Any length between 4k and 16k trigger the bug
 # when using glibc-2.4.90-9 or older.
@@ -15,6 +15,7 @@ AC_DEFUN([gl_FUNC_GETCWD_ABORT_BUG],
 [
   AC_CHECK_DECLS_ONCE([getcwd])
   AC_CHECK_HEADERS_ONCE([unistd.h])
+  AC_REQUIRE([gl_PATHMAX_SNIPPET_PREREQ])
   AC_CHECK_FUNCS([getpagesize])
   AC_CACHE_CHECK([whether getcwd aborts when 4k < cwd_length < 16k],
     gl_cv_func_getcwd_abort_bug,
@@ -32,10 +33,11 @@ AC_DEFUN([gl_FUNC_GETCWD_ABORT_BUG],
 #else /* on Windows with MSVC */
 # include <direct.h>
 #endif
-#include <limits.h>
 #include <string.h>
 #include <sys/stat.h>
 
+]gl_PATHMAX_SNIPPET[
+
 /* Don't get link errors because mkdir is redefined to rpl_mkdir.  */
 #undef mkdir
 
index 65ee491..6be4b2c 100644 (file)
@@ -1,4 +1,4 @@
-# serial 17
+# serial 18
 # Check for several getcwd bugs with long file names.
 # If so, arrange to compile the wrapper function.
 
@@ -18,6 +18,7 @@ AC_DEFUN([gl_FUNC_GETCWD_PATH_MAX],
   AC_CHECK_DECLS_ONCE([getcwd])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_CHECK_HEADERS_ONCE([unistd.h])
+  AC_REQUIRE([gl_PATHMAX_SNIPPET_PREREQ])
   AC_CACHE_CHECK([whether getcwd handles long file names properly],
     gl_cv_func_getcwd_path_max,
     [# Arrange for deletion of the temporary directory this test creates.
@@ -39,6 +40,8 @@ AC_DEFUN([gl_FUNC_GETCWD_PATH_MAX],
 #include <sys/types.h>
 #include <fcntl.h>
 
+]gl_PATHMAX_SNIPPET[
+
 #ifndef AT_FDCWD
 # define AT_FDCWD 0
 #endif
index 0856722..4913fa0 100644 (file)
@@ -1,4 +1,4 @@
-# pathmax.m4 serial 9
+# pathmax.m4 serial 10
 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2011 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -10,3 +10,33 @@ AC_DEFUN([gl_PATHMAX],
   dnl Prerequisites of lib/pathmax.h.
   AC_CHECK_HEADERS_ONCE([sys/param.h])
 ])
+
+# Expands to a piece of C program that defines PATH_MAX in the same way as
+# "pathmax.h" will do.
+AC_DEFUN([gl_PATHMAX_SNIPPET], [[
+/* Arrange to define PATH_MAX, like "pathmax.h" does. */
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <limits.h>
+#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
+# include <sys/param.h>
+#endif
+#if !defined PATH_MAX && defined MAXPATHLEN
+# define PATH_MAX MAXPATHLEN
+#endif
+#ifdef __hpux
+# undef PATH_MAX
+# define PATH_MAX 1024
+#endif
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# undef PATH_MAX
+# define PATH_MAX 260
+#endif
+]])
+
+# Prerequisites of gl_PATHMAX_SNIPPET.
+AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ],
+[
+  AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h])
+])
index a456b13..7f54760 100644 (file)
@@ -5,6 +5,7 @@ Files:
 lib/chdir-long.h
 lib/chdir-long.c
 m4/chdir-long.m4
+m4/pathmax.m4
 
 Depends-on:
 unistd
index 6a030ba..c68cd8e 100644 (file)
@@ -6,6 +6,7 @@ lib/getcwd.c
 m4/getcwd-abort-bug.m4
 m4/getcwd-path-max.m4
 m4/getcwd.m4
+m4/pathmax.m4
 
 Depends-on:
 unistd