bug-gnulib
[Top][All Lists]
Advanced

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

[bug-gnulib] stat and lstat should define their replacements


From: Derek Price
Subject: [bug-gnulib] stat and lstat should define their replacements
Date: Tue, 24 May 2005 16:28:53 -0400
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Hey all,

As near as I can tell, stat and lstat do not define names for their
replacements as many of the other GNULIB modules do.  CVS has the
following defined in a header:

/* Use the function from lib/stat.c when the system version is broken.
 */
# ifdef HAVE_STAT_EMPTY_STRING_BUG
#   define CVS_STAT rpl_stat
# else /* !HAVE_STAT_EMPTY_STRING_BUG */
#   define CVS_STAT stat
# endif /* HAVE_STAT_EMPTY_STRING_BUG */
#endif

/* Open question: should CVS_STAT be lstat by default?  We need
   to use lstat in order to handle symbolic links correctly with
   the PreservePermissions option. -twp */
#ifndef CVS_LSTAT
/* Use the function from lib/lstat.c when the system version is broken.
 */
# if defined( HAVE_STAT_EMPTY_STRING_BUG ) || !defined(
LSTAT_FOLLOWS_SLASHED_SYMLINK )
#   define CVS_LSTAT rpl_lstat
# else /* !defined(HAVE_STAT_EMPTY_STRING_BUG )
        *    && defined( LSTAT_FOLLOWS_SLASHED_SYMLINK )
        */
#   define CVS_LSTAT lstat
# endif /* defined(HAVE_STAT_EMPTY_STRING_BUG )
         * || !defined( LSTAT_FOLLOWS_SLASHED_SYMLINK )
         */
#endif


This seems like a lot of needless cruft which could be replaced with the
attached patch to GNULIB:

2005-05-24  Derek Price  <address@hidden>

    * lib/stat.c (stat, lstat): Undef macros to get at system versions.
    * m4/stat.m4 (gl_STAT_SUBSTITUTE): New function.
    (gl_FUNC_STAT): Call new function.
    (gl_PREREQ_STAT): Actually require prereqs.
    * m4/lstat.m4 (gl_LSTAT_SUBSTITUTE, gl_PREREQ_LSTAT): New functions.
    (gl_FUNC_LSTAT): Call new gl_LSTAT_SUBSTITUTE when needed.

Cheers,

Derek
Index: lib/stat.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/stat.c,v
retrieving revision 1.11
diff -u -p -r1.11 stat.c
--- lib/stat.c  14 May 2005 06:03:58 -0000      1.11
+++ lib/stat.c  24 May 2005 20:25:43 -0000
@@ -24,6 +24,10 @@
 
 #include <config.h>
 
+/* Get the system versions when something else was defined by config.h.  */
+#undef lstat
+#undef stat
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
Index: m4/lstat.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/lstat.m4,v
retrieving revision 1.20
diff -u -p -r1.20 lstat.m4
--- m4/lstat.m4 2 May 2005 07:00:50 -0000       1.20
+++ m4/lstat.m4 24 May 2005 20:25:43 -0000
@@ -16,9 +16,26 @@ dnl If it does, then define HAVE_LSTAT_E
 dnl compile the wrapper function.
 dnl
 
+AC_DEFUN([gl_LSTAT_SUBSTITUTE],
+[
+  gl_PREREQ_LSTAT
+  AC_DEFINE(lstat, rpl_lstat,
+    [Define to a substitute for the `lstat' function.])
+])
+
 AC_DEFUN([gl_FUNC_LSTAT],
 [
-  AC_REQUIRE([AC_FUNC_LSTAT])
+  AC_REQUIRE([AC_FUNC_LSTAT])dnl
   dnl Note: AC_FUNC_LSTAT does AC_LIBOBJ(lstat).
+  if test $ac_cv_func_lstat_empty_string_bug = yes \
+     || test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
+    gl_LSTAT_SUBSTITUTE
+  fi
+  :
+])
+
+AC_DEFUN([gl_PREREQ_LSTAT],
+[
+  AC_REQUIRE([AC_FUNC_LSTAT])dnl
   :
 ])
Index: m4/stat.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/stat.m4,v
retrieving revision 1.18
diff -u -p -r1.18 stat.m4
--- m4/stat.m4  23 Jan 2005 08:06:57 -0000      1.18
+++ m4/stat.m4  24 May 2005 20:25:43 -0000
@@ -16,17 +16,24 @@ dnl If it does, then define HAVE_STAT_EM
 dnl compile the wrapper function.
 dnl
 
+AC_DEFUN([gl_STAT_SUBSTITUTE],
+[
+  gl_PREREQ_STAT
+  AC_DEFINE(stat, rpl_stat, [Define to a substitute for the stat function.])
+])
+
 AC_DEFUN([gl_FUNC_STAT],
 [
-  AC_FUNC_STAT
+  AC_REQUIRE([AC_FUNC_STAT])dnl
   dnl Note: AC_FUNC_STAT does AC_LIBOBJ(stat).
   if test $ac_cv_func_stat_empty_string_bug = yes; then
-    gl_PREREQ_STAT
+    gl_STAT_SUBSTITUTE
   fi
 ])
 
 # Prerequisites of lib/stat.c.
 AC_DEFUN([gl_PREREQ_STAT],
 [
+  AC_REQUIRE([AC_FUNC_STAT])dnl
   :
 ])

reply via email to

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