bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

use of PATH_MAX in *.m4 files


From: Bruno Haible
Subject: use of PATH_MAX in *.m4 files
Date: Thu, 22 Sep 2011 02:11:35 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Hi Jim,

Here's another prososed patch

On MSVC, I got a link error because save-cwd.c was compiled to invoke the
chdir_long() function, but lib/chdir-long.c was not compiled.

The reason is that while save-cwd.c uses pathmax.h to define PATH_MAX when
it makes sense and bases its decisions on the 'pathmax' module, the 3 .m4 files
  m4/chdir-long.m4
  m4/getcwd-abort-bug.m4
  m4/getcwd-path-max.m4
use their own way of getting PATH_MAX. On MSVC, it thus happens that
m4/chdir-long.m4 considers PATH_MAX to be undefined, while save-cwd.c then
considers it as defined.

Here's a patch that moves all logic regarding PATH_MAX to the 'pathmax' module
and the m4/pathmax.m4 file.


2011-09-21  Bruno Haible  <address@hidden>

        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.

--- m4/pathmax.m4.orig  Thu Sep 22 02:02:10 2011
+++ m4/pathmax.m4       Wed Sep 21 23:59:14 2011
@@ -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])
+])
--- m4/chdir-long.m4.orig       Thu Sep 22 02:02:10 2011
+++ m4/chdir-long.m4    Wed Sep 21 23:59:13 2011
@@ -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,
--- m4/getcwd-abort-bug.m4.orig Thu Sep 22 02:02:10 2011
+++ m4/getcwd-abort-bug.m4      Wed Sep 21 23:59:13 2011
@@ -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
 
--- m4/getcwd-path-max.m4.orig  Thu Sep 22 02:02:10 2011
+++ m4/getcwd-path-max.m4       Wed Sep 21 23:59:14 2011
@@ -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
--- modules/chdir-long.orig     Thu Sep 22 02:02:10 2011
+++ modules/chdir-long  Wed Sep 21 23:48:01 2011
@@ -5,6 +5,7 @@
 lib/chdir-long.h
 lib/chdir-long.c
 m4/chdir-long.m4
+m4/pathmax.m4
 
 Depends-on:
 unistd
--- modules/getcwd.orig Thu Sep 22 02:02:10 2011
+++ modules/getcwd      Thu Sep 22 01:49:01 2011
@@ -6,6 +6,7 @@
 m4/getcwd-abort-bug.m4
 m4/getcwd-path-max.m4
 m4/getcwd.m4
+m4/pathmax.m4
 
 Depends-on:
 unistd
-- 
In memoriam Orlando Letelier <http://en.wikipedia.org/wiki/Orlando_Letelier>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]