Mercurial > hg > octave-nkf > gnulib-hg
changeset 12015:9317d4a9ac96
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>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Fri, 11 Sep 2009 12:18:10 -0600 |
parents | 63cfe4168142 |
children | 4fac822214af |
files | ChangeLog NEWS doc/glibc-functions/canonicalize_file_name.texi doc/posix-functions/realpath.texi lib/canonicalize-lgpl.c lib/canonicalize.h lib/stdlib.in.h m4/canonicalize-lgpl.m4 m4/stdlib_h.m4 modules/canonicalize modules/canonicalize-lgpl modules/stdlib tests/test-canonicalize-lgpl.c |
diffstat | 13 files changed, 89 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ 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.
--- 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 -@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 + +Portability problems not fixed by Gnulib: +@itemize +@end itemize
--- 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.
--- 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
--- 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 @@ 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_ */
--- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -115,6 +115,18 @@ 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 @@ 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.
--- 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 @@ 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 ])
--- 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 @@ [ 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 @@ 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 @@ 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 @@ 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]) ])
--- a/modules/canonicalize +++ b/modules/canonicalize @@ -22,6 +22,7 @@ configure.ac: gl_FUNC_CANONICALIZE_FILENAME_MODE gl_MODULE_INDICATOR([canonicalize]) +gl_STDLIB_MODULE_INDICATOR([canonicalize_file_name]) Makefile.am:
--- 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 @@ 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+
--- a/modules/stdlib +++ b/modules/stdlib @@ -28,6 +28,7 @@ -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 @@ -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 @@ -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 @@ -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)' \
--- 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>