changeset 15740:f94acfaf527e

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.
author Bruno Haible <bruno@clisp.org>
date Thu, 22 Sep 2011 14:17:57 +0200
parents 9f82d16d3139
children 4a8092c21b94
files ChangeLog m4/chdir-long.m4 m4/getcwd-abort-bug.m4 m4/getcwd-path-max.m4 m4/pathmax.m4 modules/chdir-long modules/getcwd
diffstat 7 files changed, 57 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+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.
--- a/m4/chdir-long.m4
+++ b/m4/chdir-long.m4
@@ -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 @@
 
 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,
--- a/m4/getcwd-abort-bug.m4
+++ b/m4/getcwd-abort-bug.m4
@@ -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_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 @@
 #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
 
--- a/m4/getcwd-path-max.m4
+++ b/m4/getcwd-path-max.m4
@@ -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_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 @@
 #include <sys/types.h>
 #include <fcntl.h>
 
+]gl_PATHMAX_SNIPPET[
+
 #ifndef AT_FDCWD
 # define AT_FDCWD 0
 #endif
--- a/m4/pathmax.m4
+++ b/m4/pathmax.m4
@@ -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 @@
   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])
+])
--- a/modules/chdir-long
+++ b/modules/chdir-long
@@ -5,6 +5,7 @@
 lib/chdir-long.h
 lib/chdir-long.c
 m4/chdir-long.m4
+m4/pathmax.m4
 
 Depends-on:
 unistd
--- a/modules/getcwd
+++ b/modules/getcwd
@@ -6,6 +6,7 @@
 m4/getcwd-abort-bug.m4
 m4/getcwd-path-max.m4
 m4/getcwd.m4
+m4/pathmax.m4
 
 Depends-on:
 unistd