summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-09-11 12:18:10 -0600
committerEric Blake <ebb9@byu.net>2009-09-17 19:16:24 -0600
commit99ad8ac789556142ef090fcaefae36aabef00ca4 (patch)
tree242e67e4150c55b20d71144283319f7749ae1925
parent8e7fa996cb189829ed7c9a4f2f489b9150a6571d (diff)
downloadgnulib-99ad8ac789556142ef090fcaefae36aabef00ca4.tar.gz
canonicalize, canonicalize-lgpl: use <stdlib.h>
Match current gnulib conventions of glibc functions being declared in the same header as glibc. This makes it easier to replace broken canonicalize_file_name. canonicalize still requires "canonicalize.h" because canonicalize_filename_mode is not in glibc. With this patch, canonicalize-lgpl always provides realpath and canonicalize_file_name, while canonicalize can provide canonicalize_file_name but not realpath; if both modules are in use, canonicalize_file_name comes from the LGPLv2+ sources, but the testing comes from canonicalize. * modules/canonicalize-lgpl (Files): Drop canonicalize.h. (Include): Mention <stdlib.h>. (configure.ac): Mention functions we provide. * modules/canonicalize (configure.ac): Likewise. * m4/canonicalize-lgpl.m4 (gl_CANONICALIZE_LGPL): Always replace realpath if canonicalize_file_name is missing. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Provide defaults. * modules/stdlib (Makefile.am): Substitute witnesses. * lib/stdlib.in.h (canonicalize_file_name, realpath): Declare. * lib/canonicalize-lgpl.c (includes): Adjust accordingly. * lib/canonicalize.h (canonicalize_file_name): Drop declaration. * NEWS: Document this. * doc/glibc-functions/canonicalize_file_name.texi (canonicalize_file_name): Likewise. * doc/posix-functions/realpath.texi (realpath): Likewise. * tests/test-canonicalize-lgpl.c (includes): Use <stdlib.h>. Signed-off-by: Eric Blake <ebb9@byu.net>
-rw-r--r--ChangeLog18
-rw-r--r--NEWS4
-rw-r--r--doc/glibc-functions/canonicalize_file_name.texi8
-rw-r--r--doc/posix-functions/realpath.texi21
-rw-r--r--lib/canonicalize-lgpl.c9
-rw-r--r--lib/canonicalize.h15
-rw-r--r--lib/stdlib.in.h25
-rw-r--r--m4/canonicalize-lgpl.m48
-rw-r--r--m4/stdlib_h.m46
-rw-r--r--modules/canonicalize1
-rw-r--r--modules/canonicalize-lgpl7
-rw-r--r--modules/stdlib4
-rw-r--r--tests/test-canonicalize-lgpl.c3
13 files changed, 88 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 301d75624e..1d89bb335a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2009-09-17 Eric Blake <ebb9@byu.net>
+ canonicalize, canonicalize-lgpl: use <stdlib.h>
+ * modules/canonicalize-lgpl (Files): Drop canonicalize.h.
+ (Include): Mention <stdlib.h>.
+ (configure.ac): Mention functions we provide.
+ * modules/canonicalize (configure.ac): Likewise.
+ * m4/canonicalize-lgpl.m4 (gl_CANONICALIZE_LGPL): Always replace
+ realpath if canonicalize_file_name is missing.
+ * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Provide defaults.
+ * modules/stdlib (Makefile.am): Substitute witnesses.
+ * lib/stdlib.in.h (canonicalize_file_name, realpath): Declare.
+ * lib/canonicalize-lgpl.c (includes): Adjust accordingly.
+ * lib/canonicalize.h (canonicalize_file_name): Drop declaration.
+ * NEWS: Document this.
+ * doc/glibc-functions/canonicalize_file_name.texi
+ (canonicalize_file_name): Likewise.
+ * doc/posix-functions/realpath.texi (realpath): Likewise.
+ * tests/test-canonicalize-lgpl.c (includes): Use <stdlib.h>.
+
test-canonicalize: consolidate into single C program
* tests/test-canonicalize.sh: Delete; move setup into...
* tests/test-canonicalize.c (main): ...the program, making it
diff --git a/NEWS b/NEWS
index f506cba99a..62c631f1e5 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ User visible incompatible changes
Date Modules Changes
+2009-09-16 canonicalize-lgpl
+ The include file is changed from "canonicalize.h"
+ to <stdlib.h>.
+
2009-09-04 link-follow The macro LINK_FOLLOWS_SYMLINK is now tri-state,
rather than only defined to 1.
diff --git a/doc/glibc-functions/canonicalize_file_name.texi b/doc/glibc-functions/canonicalize_file_name.texi
index c19a9b1d1e..f034f8175e 100644
--- a/doc/glibc-functions/canonicalize_file_name.texi
+++ b/doc/glibc-functions/canonicalize_file_name.texi
@@ -2,15 +2,15 @@
@subsection @code{canonicalize_file_name}
@findex canonicalize_file_name
-Gnulib module: ---
+Gnulib module: canonicalize-lgpl
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on all non-glibc platforms:
+MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, Interix 3.5, BeOS.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on all non-glibc platforms:
-MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, Interix 3.5, BeOS.
@end itemize
diff --git a/doc/posix-functions/realpath.texi b/doc/posix-functions/realpath.texi
index 2515254719..01ce781cf2 100644
--- a/doc/posix-functions/realpath.texi
+++ b/doc/posix-functions/realpath.texi
@@ -4,22 +4,27 @@
POSIX specification: @url{http://www.opengroup.org/onlinepubs/9699919799/functions/realpath.html}
-Gnulib module: ---
+Gnulib module: canonicalize-lgpl
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on some platforms:
+mingw, BeOS.
+@item
+This function does not allow for a NULL @samp{resolved} parameter on
+some platforms:
+Solaris.
+@item
+This function does not always return an absolute path on some
+platforms:
+Solaris.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
-This function is missing on some platforms:
-mingw, BeOS.
-@item
This function does not allow to determine the required size of output buffer;
+the use of a non-NULL @samp{resolved} buffer is non-portable, since
PATH_MAX --- if it is defined --- is nothing more than a guess.
@end itemize
-
-Extension: Gnulib provides a module @samp{canonicalize-lgpl} that defines a
-function @code{canonicalize_file_name} that is like @code{realpath} but without
-size limitations.
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index ce52cbc22f..c8f7e167aa 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -17,19 +17,14 @@
#include <config.h>
-/* Avoid a clash of our rpl_realpath() function with the prototype in
- <stdlib.h> on Solaris 2.5.1. */
-#undef realpath
-
#if !HAVE_CANONICALIZE_FILE_NAME || defined _LIBC
#include <alloca.h>
/* Specification. */
-#include "canonicalize.h"
+#include <stdlib.h>
#include <stddef.h>
-#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -61,7 +56,7 @@
# define compat_symbol(lib, local, symbol, version)
# define weak_alias(local, symbol)
# define __canonicalize_file_name canonicalize_file_name
-# define __realpath rpl_realpath
+# define __realpath realpath
# include "pathmax.h"
# include "malloca.h"
# if HAVE_GETCWD
diff --git a/lib/canonicalize.h b/lib/canonicalize.h
index e068c20ea4..bcf84f6f9b 100644
--- a/lib/canonicalize.h
+++ b/lib/canonicalize.h
@@ -17,7 +17,8 @@
#ifndef CANONICALIZE_H_
# define CANONICALIZE_H_
-# if GNULIB_CANONICALIZE
+#include <stdlib.h> /* for canonicalize_file_name */
+
enum canonicalize_mode_t
{
/* All components must exist. */
@@ -36,17 +37,5 @@ typedef enum canonicalize_mode_t canonicalize_mode_t;
whether components must exist depends on the canonicalize_mode_t
argument. */
char *canonicalize_filename_mode (const char *, canonicalize_mode_t);
-# endif
-
-# if HAVE_CANONICALIZE_FILE_NAME
-# include <stdlib.h>
-# else
-/* Return a malloc'd string containing the canonical absolute name of
- the named file. If any file name component does not exist or is a
- symlink to a nonexistent file, return NULL. A canonical name does
- not contain any `.', `..' components nor any repeated file name
- separators ('/') or symlinks. */
-char *canonicalize_file_name (const char *);
-# endif
#endif /* !CANONICALIZE_H_ */
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index f05962ea59..a6512c59c2 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -115,6 +115,18 @@ extern void * calloc (size_t nmemb, size_t size);
calloc (n, s))
#endif
+#if @GNULIB_CANONICALIZE_FILE_NAME@
+# if !@HAVE_CANONICALIZE_FILE_NAME@
+extern char *canonicalize_file_name (const char *name);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef canonicalize_file_name
+# define canonicalize_file_name(n) \
+ (GL_LINK_WARNING ("canonicalize_file_name is unportable - " \
+ "use gnulib module canonicalize-lgpl for portability"), \
+ canonicalize_file_name (n))
+#endif
+
#if @GNULIB_GETLOADAVG@
# if !@HAVE_DECL_GETLOADAVG@
/* Store max(NELEM,3) load average numbers in LOADAVG[].
@@ -292,6 +304,19 @@ extern void * realloc (void *ptr, size_t size);
realloc (p, s))
#endif
+#if @GNULIB_REALPATH@
+# if @REPLACE_REALPATH@
+# define realpath rpl_realpath
+extern char *realpath (const char *name, char *resolved);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef realpath
+# define realpath(n,r) \
+ (GL_LINK_WARNING ("realpath is unportable - use gnulib module " \
+ "canonicalize or canonicalize-lgpl for portability"), \
+ realpath (n, r))
+#endif
+
#if @GNULIB_RPMATCH@
# if !@HAVE_RPMATCH@
/* Test a user response to a question.
diff --git a/m4/canonicalize-lgpl.m4 b/m4/canonicalize-lgpl.m4
index bd3a381424..d040c6866b 100644
--- a/m4/canonicalize-lgpl.m4
+++ b/m4/canonicalize-lgpl.m4
@@ -1,4 +1,4 @@
-# canonicalize-lgpl.m4 serial 6
+# canonicalize-lgpl.m4 serial 7
dnl Copyright (C) 2003, 2006-2007, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -10,10 +10,12 @@ AC_DEFUN([gl_CANONICALIZE_LGPL],
dnl than the function name.
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
AC_CHECK_FUNCS_ONCE([canonicalize_file_name])
+ dnl Assume that all platforms with canonicalize_file_name also have
+ dnl a working realpath; otherwise assume realpath is broken.
if test $ac_cv_func_canonicalize_file_name = no; then
+ HAVE_CANONICALIZE_FILE_NAME=0
AC_LIBOBJ([canonicalize-lgpl])
- AC_DEFINE([realpath], [rpl_realpath],
- [Define to a replacement function name for realpath().])
+ REPLACE_REALPATH=1
gl_PREREQ_CANONICALIZE_LGPL
fi
])
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index b7cf18c3fa..8cb5d484fe 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 17
+# stdlib_h.m4 serial 18
dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -35,6 +35,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
[
GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL])
GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX])
+ GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME])
GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG])
GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
@@ -44,6 +45,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
+ GNULIB_REALPATH=0; AC_SUBST([GNULIB_REALPATH])
GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH])
GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV])
GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
@@ -53,6 +55,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
HAVE_CALLOC_POSIX=1; AC_SUBST([HAVE_CALLOC_POSIX])
+ HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME])
HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX])
@@ -70,6 +73,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV])
REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
+ REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
VOID_UNSETENV=0; AC_SUBST([VOID_UNSETENV])
])
diff --git a/modules/canonicalize b/modules/canonicalize
index ec94c7670c..d039854f13 100644
--- a/modules/canonicalize
+++ b/modules/canonicalize
@@ -22,6 +22,7 @@ xgetcwd
configure.ac:
gl_FUNC_CANONICALIZE_FILENAME_MODE
gl_MODULE_INDICATOR([canonicalize])
+gl_STDLIB_MODULE_INDICATOR([canonicalize_file_name])
Makefile.am:
diff --git a/modules/canonicalize-lgpl b/modules/canonicalize-lgpl
index 45a9a432b4..c5ecd4fd44 100644
--- a/modules/canonicalize-lgpl
+++ b/modules/canonicalize-lgpl
@@ -1,8 +1,7 @@
Description:
-Canonical absolute file name (LGPLed version).
+realpath, canonical_file_name: Provide canonical absolute file name
Files:
-lib/canonicalize.h
lib/canonicalize-lgpl.c
m4/canonicalize-lgpl.m4
@@ -21,11 +20,13 @@ sys_stat
configure.ac:
gl_CANONICALIZE_LGPL
gl_MODULE_INDICATOR([canonicalize-lgpl])
+gl_STDLIB_MODULE_INDICATOR([canonicalize_file_name])
+gl_STDLIB_MODULE_INDICATOR([realpath])
Makefile.am:
Include:
-"canonicalize.h"
+<stdlib.h>
License:
LGPLv2+
diff --git a/modules/stdlib b/modules/stdlib
index 507a8f67ad..c404ca26fe 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -28,6 +28,7 @@ stdlib.h: stdlib.in.h
-e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
-e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
-e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
+ -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \
-e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
-e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
-e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
@@ -37,6 +38,7 @@ stdlib.h: stdlib.in.h
-e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
-e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
-e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
+ -e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \
-e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
-e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
-e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
@@ -45,6 +47,7 @@ stdlib.h: stdlib.in.h
-e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
-e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
-e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \
+ -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
-e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
-e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
-e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \
@@ -63,6 +66,7 @@ stdlib.h: stdlib.in.h
-e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \
-e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
-e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
+ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
-e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
-e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
diff --git a/tests/test-canonicalize-lgpl.c b/tests/test-canonicalize-lgpl.c
index bc58d59049..704c0ecc5a 100644
--- a/tests/test-canonicalize-lgpl.c
+++ b/tests/test-canonicalize-lgpl.c
@@ -18,12 +18,11 @@
#include <config.h>
-#include "canonicalize.h"
+#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>