From 6559e8e73e294a712405fcac59d80223dccdee51 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Thu, 1 Mar 2007 14:02:55 +0100 Subject: [PATCH] Update. --- gl/Makefile.am | 30 +++++++++- gl/m4/gnulib-cache.m4 | 2 +- gl/m4/gnulib-comp.m4 | 3 +- gl/m4/string_h.m4 | 45 +++++++-------- gl/m4/unistd_h.m4 | 50 +++++++++------- gl/string_.h | 149 +++++++++++++++++++++++++++++++----------------- gl/unistd_.h | 154 +++++++++++++++++++++++++++++++++++++++++++++++--- 7 files changed, 327 insertions(+), 106 deletions(-) diff --git a/gl/Makefile.am b/gl/Makefile.am index 0838cad..700c216 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=. --libtool --macro-prefix=gl gendocs getopt maintainer-makefile memmove progname read-file strdup version-etc-fsf +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --libtool --macro-prefix=gl gendocs getopt maintainer-makefile memmove progname read-file strdup version-etc-fsf AUTOMAKE_OPTIONS = 1.5 gnits @@ -60,6 +60,12 @@ libgnu_la_SOURCES += gettext.h ## end gnulib module gettext-h +## begin gnulib module link-warning + +LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h + +## end gnulib module link-warning + ## begin gnulib module memmove @@ -108,6 +114,8 @@ string.h: string_.h -e 's|@''GNULIB_MBSRCHR''@|$(GNULIB_MBSRCHR)|g' \ -e 's|@''GNULIB_MBSSTR''@|$(GNULIB_MBSSTR)|g' \ -e 's|@''GNULIB_MBSCASECMP''@|$(GNULIB_MBSCASECMP)|g' \ + -e 's|@''GNULIB_MBSNCASECMP''@|$(GNULIB_MBSNCASECMP)|g' \ + -e 's|@''GNULIB_MBSPCASECMP''@|$(GNULIB_MBSPCASECMP)|g' \ -e 's|@''GNULIB_MBSCASESTR''@|$(GNULIB_MBSCASESTR)|g' \ -e 's|@''GNULIB_MBSCSPN''@|$(GNULIB_MBSCSPN)|g' \ -e 's|@''GNULIB_MBSPBRK''@|$(GNULIB_MBSPBRK)|g' \ @@ -143,6 +151,7 @@ string.h: string_.h -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/string_.h; \ } > $@-t mv $@-t $@ @@ -154,14 +163,29 @@ EXTRA_DIST += string_.h ## begin gnulib module unistd -BUILT_SOURCES += $(UNISTD_H) +BUILT_SOURCES += unistd.h # We need the following in order to create an empty placeholder for # when the system doesn't have one. unistd.h: unistd_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''ABSOLUTE_UNISTD_H''@|$(ABSOLUTE_UNISTD_H)|g' \ + sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ + -e 's|@''ABSOLUTE_UNISTD_H''@|$(ABSOLUTE_UNISTD_H)|g' \ + -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ + -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \ + -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \ + -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ + -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ + -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ + -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ + -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ + -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ + -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ + -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ + -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ + -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ < $(srcdir)/unistd_.h; \ } > $@-t mv $@-t $@ diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index 8173bb5..aae8bfa 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -15,7 +15,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=. --libtool --macro-prefix=gl gendocs getopt maintainer-makefile memmove progname read-file strdup version-etc-fsf +# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --libtool --macro-prefix=gl gendocs getopt maintainer-makefile memmove progname read-file strdup version-etc-fsf # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([gl/override]) diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 74fe924..3678239 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -51,7 +51,7 @@ AC_DEFUN([gl_INIT], gl_FUNC_STRDUP gl_STRING_MODULE_INDICATOR([strdup]) gl_HEADER_STRING_H - gl_HEADER_UNISTD + gl_UNISTD_H m4_popdef([AC_LIBSOURCES]) m4_popdef([AC_REPLACE_FUNCS]) m4_popdef([AC_LIBOBJ]) @@ -91,6 +91,7 @@ AC_DEFUN([gl_LIBSOURCES], AC_DEFUN([gl_FILE_LIST], [ build-aux/GNUmakefile build-aux/gendocs.sh + build-aux/link-warning.h build-aux/maint.mk doc/gendocs_template lib/getopt.c diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4 index 9f5ba87..f706d49 100644 --- a/gl/m4/string_h.m4 +++ b/gl/m4/string_h.m4 @@ -18,41 +18,19 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY], [ AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - AC_REQUIRE([gl_STRING_MODULE_INDICATOR_DEFAULTS]) gl_ABSOLUTE_HEADER([string.h]) ABSOLUTE_STRING_H=\"$gl_cv_absolute_string_h\" AC_SUBST([ABSOLUTE_STRING_H]) ]) -AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], -[ - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) - HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) - HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) - HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) - HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) - HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP]) - HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP]) - HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) - HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP]) - HAVE_STRNDUP=1; AC_SUBST([HAVE_STRNDUP]) - HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP]) - HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN]) - HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK]) - HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) - HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) - HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) -]) - AC_DEFUN([gl_STRING_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_STRING_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 ]) -AC_DEFUN([gl_STRING_MODULE_INDICATOR_DEFAULTS], +AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], [ GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM]) GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY]) @@ -72,10 +50,29 @@ AC_DEFUN([gl_STRING_MODULE_INDICATOR_DEFAULTS], GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR]) GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR]) GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP]) + GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP]) + GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP]) GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR]) GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN]) GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK]) GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN]) GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP]) GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) + HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) + HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) + HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) + HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) + HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP]) + HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP]) + HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) + HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP]) + HAVE_STRNDUP=1; AC_SUBST([HAVE_STRNDUP]) + HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP]) + HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN]) + HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK]) + HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) + HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) + HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) ]) diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4 index d38de90..628b818 100644 --- a/gl/m4/unistd_h.m4 +++ b/gl/m4/unistd_h.m4 @@ -1,39 +1,51 @@ -# unistd_h.m4 serial 4 +# unistd_h.m4 serial 5 dnl Copyright (C) 2006-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -dnl Written by Simon Josefsson +dnl Written by Simon Josefsson, Bruno Haible. -AC_DEFUN([gl_HEADER_UNISTD], +AC_DEFUN([gl_UNISTD_H], [ dnl Use AC_REQUIRE here, so that the default behavior below is expanded dnl once only, before all statements that occur in other macros. - AC_REQUIRE([gl_HEADER_UNISTD_DEFAULTS]) + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) - AC_CHECK_HEADERS([unistd.h], [], [ - UNISTD_H='unistd.h' - ]) - dnl This module decides to build unistd.h if it is missing. - dnl The fchdir module decides to build unistd.h if fchdir() is missing. - dnl Therefore check for the prerequisites of lib/unistd.h always. - gl_PREREQ_UNISTD -]) - -dnl Prerequisites of lib/unistd.h. -AC_DEFUN([gl_PREREQ_UNISTD], -[ AC_CHECK_HEADERS_ONCE([unistd.h]) if test $ac_cv_header_unistd_h = yes; then + HAVE_UNISTD_H=1 gl_ABSOLUTE_HEADER([unistd.h]) ABSOLUTE_UNISTD_H=\"$gl_cv_absolute_unistd_h\" + else + HAVE_UNISTD_H=0 fi + AC_SUBST([HAVE_UNISTD_H]) AC_SUBST([ABSOLUTE_UNISTD_H]) ]) -AC_DEFUN([gl_HEADER_UNISTD_DEFAULTS], +AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 +]) + +AC_DEFUN([gl_UNISTD_H_DEFAULTS], [ - UNISTD_H= - AC_SUBST(UNISTD_H) + GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN]) + GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2]) + GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR]) + GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE]) + GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD]) + GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) + GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DUP2=1; AC_SUBST([HAVE_DUP2]) + HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) + HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) + HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) + REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) + REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR]) + REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) ]) diff --git a/gl/string_.h b/gl/string_.h index 8a5cd50..483c9fc 100644 --- a/gl/string_.h +++ b/gl/string_.h @@ -19,37 +19,16 @@ #ifndef _GL_STRING_H #define _GL_STRING_H +/* This #pragma avoids a warning with "gcc -Wmissing-prototypes" on some + mingw systems. */ +#ifdef __GNUC__ +# pragma GCC system_header +#endif + #include @ABSOLUTE_STRING_H@ -/* GL_LINK_WARNING("literal string") arranges to emit the literal string as - a linker warning on most glibc systems. - We use a linker warning rather than a preprocessor warning, because - #warning cannot be used inside macros. */ -#ifndef GL_LINK_WARNING - /* This works on platforms with GNU ld and ELF object format. - Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. - Testing __ELF__ guarantees the ELF object format. - Testing __GNUC__ is necessary for the compound expression syntax. */ -# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ -# define GL_LINK_WARNING(message) \ - GL_LINK_WARNING1 (__FILE__, __LINE__, message) -# define GL_LINK_WARNING1(file, line, message) \ - GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ -# define GL_LINK_WARNING2(file, line, message) \ - GL_LINK_WARNING3 (file ":" #line ": warning: " message) -# define GL_LINK_WARNING3(message) \ - ({ static const char warning[sizeof (message)] \ - __attribute__ ((__unused__, \ - __section__ (".gnu.warning"), \ - __aligned__ (1))) \ - = message "\n"; \ - (void)0; \ - }) -# else -# define GL_LINK_WARNING(message) ((void) 0) -# endif -#endif +/* The definition of GL_LINK_WARNING is copied here. */ #ifdef __cplusplus @@ -65,7 +44,8 @@ extern void *memmem (void const *__haystack, size_t __haystack_len, #elif defined GNULIB_POSIXCHECK # undef memmem # define memmem(a,al,b,bl) \ - (GL_LINK_WARNING ("memmem is unportable - use gnulib module memmem for portability"), \ + (GL_LINK_WARNING ("memmem is unportable - " \ + "use gnulib module memmem for portability"), \ memmem (a, al, b, bl)) #endif @@ -79,7 +59,8 @@ extern void *mempcpy (void *restrict __dest, void const *restrict __src, #elif defined GNULIB_POSIXCHECK # undef mempcpy # define mempcpy(a,b,n) \ - (GL_LINK_WARNING ("mempcpy is unportable - use gnulib module mempcpy for portability"), \ + (GL_LINK_WARNING ("mempcpy is unportable - " \ + "use gnulib module mempcpy for portability"), \ mempcpy (a, b, n)) #endif @@ -91,7 +72,8 @@ extern void *memrchr (void const *, int, size_t); #elif defined GNULIB_POSIXCHECK # undef memrchr # define memrchr(a,b,c) \ - (GL_LINK_WARNING ("memrchr is unportable - use gnulib module memrchr for portability"), \ + (GL_LINK_WARNING ("memrchr is unportable - " \ + "use gnulib module memrchr for portability"), \ memrchr (a, b, c)) #endif @@ -103,7 +85,8 @@ extern char *stpcpy (char *restrict __dst, char const *restrict __src); #elif defined GNULIB_POSIXCHECK # undef stpcpy # define stpcpy(a,b) \ - (GL_LINK_WARNING ("stpcpy is unportable - use gnulib module stpcpy for portability"), \ + (GL_LINK_WARNING ("stpcpy is unportable - " \ + "use gnulib module stpcpy for portability"), \ stpcpy (a, b)) #endif @@ -118,7 +101,8 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src, #elif defined GNULIB_POSIXCHECK # undef stpncpy # define stpncpy(a,b,n) \ - (GL_LINK_WARNING ("stpncpy is unportable - use gnulib module stpncpy for portability"), \ + (GL_LINK_WARNING ("stpncpy is unportable - " \ + "use gnulib module stpncpy for portability"), \ stpncpy (a, b, n)) #endif @@ -135,7 +119,12 @@ extern int strcasecmp (char const *s1, char const *s2); as a sequence of bytes, not of characters. */ # undef strcasecmp # define strcasecmp(a,b) \ - (GL_LINK_WARNING ("strcasecmp cannot work correctly on character strings in multibyte locales - use mbscasecmp if you care about internationalization, or use c_strcasecmp (from gnulib module c-strcase) if you want a locale independent function"), \ + (GL_LINK_WARNING ("strcasecmp cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbscasecmp if you care about " \ + "internationalization, or use c_strcasecmp (from " \ + "gnulib module c-strcase) if you want a locale " \ + "independent function"), \ strcasecmp (a, b)) #endif @@ -152,7 +141,12 @@ extern int strncasecmp (char const *s1, char const *s2, size_t n); as a sequence of bytes, not of characters. */ # undef strncasecmp # define strncasecmp(a,b,n) \ - (GL_LINK_WARNING ("strncasecmp cannot work correctly on character strings in multibyte locales - don't use it if you care about internationalization; use c_strncasecmp (from gnulib module c-strcase) if you want a locale independent function"), \ + (GL_LINK_WARNING ("strncasecmp cannot work correctly on character " \ + "strings in multibyte locales - " \ + "use mbsncasecmp or mbspcasecmp if you care about " \ + "internationalization, or use c_strncasecmp (from " \ + "gnulib module c-strcase) if you want a locale " \ + "independent function"), \ strncasecmp (a, b, n)) #endif @@ -161,7 +155,9 @@ extern int strncasecmp (char const *s1, char const *s2, size_t n); GB18030 and the character to be searched is a digit. */ # undef strchr # define strchr(s,c) \ - (GL_LINK_WARNING ("strchr cannot work correctly on character strings in some multibyte locales - use mbschr if you care about internationalization"), \ + (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \ + "in some multibyte locales - " \ + "use mbschr if you care about internationalization"), \ strchr (s, c)) #endif @@ -173,7 +169,8 @@ extern char *strchrnul (char const *__s, int __c_in); #elif defined GNULIB_POSIXCHECK # undef strchrnul # define strchrnul(a,b) \ - (GL_LINK_WARNING ("strchrnul is unportable - use gnulib module strchrnul for portability"), \ + (GL_LINK_WARNING ("strchrnul is unportable - " \ + "use gnulib module strchrnul for portability"), \ strchrnul (a, b)) #endif @@ -185,7 +182,8 @@ extern char *strdup (char const *__s); #elif defined GNULIB_POSIXCHECK # undef strdup # define strdup(a) \ - (GL_LINK_WARNING ("strdup is unportable - use gnulib module strdup for portability"), \ + (GL_LINK_WARNING ("strdup is unportable - " \ + "use gnulib module strdup for portability"), \ strdup (a)) #endif @@ -201,7 +199,8 @@ extern char *strndup (char const *__string, size_t __n); #elif defined GNULIB_POSIXCHECK # undef strndup # define strndup(a,n) \ - (GL_LINK_WARNING ("strndup is unportable - use gnulib module strndup for portability"), \ + (GL_LINK_WARNING ("strndup is unportable - " \ + "use gnulib module strndup for portability"), \ strndup (a, n)) #endif @@ -215,7 +214,8 @@ extern size_t strnlen (char const *__string, size_t __maxlen); #elif defined GNULIB_POSIXCHECK # undef strnlen # define strnlen(a,n) \ - (GL_LINK_WARNING ("strnlen is unportable - use gnulib module strnlen for portability"), \ + (GL_LINK_WARNING ("strnlen is unportable - " \ + "use gnulib module strnlen for portability"), \ strnlen (a, n)) #endif @@ -226,7 +226,9 @@ extern size_t strnlen (char const *__string, size_t __maxlen); digit. */ # undef strcspn # define strcspn(s,a) \ - (GL_LINK_WARNING ("strcspn cannot work correctly on character strings in multibyte locales - use mbscspn if you care about internationalization"), \ + (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbscspn if you care about internationalization"), \ strcspn (s, a)) #endif @@ -242,13 +244,16 @@ extern char *strpbrk (char const *__s, char const *__accept); digit. */ # undef strpbrk # define strpbrk(s,a) \ - (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings in multibyte locales - use mbspbrk if you care about internationalization"), \ + (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbspbrk if you care about internationalization"), \ strpbrk (s, a)) # endif #elif defined GNULIB_POSIXCHECK # undef strpbrk # define strpbrk(s,a) \ - (GL_LINK_WARNING ("strpbrk is unportable - use gnulib module strpbrk for portability"), \ + (GL_LINK_WARNING ("strpbrk is unportable - " \ + "use gnulib module strpbrk for portability"), \ strpbrk (s, a)) #endif @@ -257,7 +262,9 @@ extern char *strpbrk (char const *__s, char const *__accept); Even in this simple case, it cannot work with multibyte strings. */ # undef strspn # define strspn(s,a) \ - (GL_LINK_WARNING ("strspn cannot work correctly on character strings in multibyte locales - use mbsspn if you care about internationalization"), \ + (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbsspn if you care about internationalization"), \ strspn (s, a)) #endif @@ -266,7 +273,9 @@ extern char *strpbrk (char const *__s, char const *__accept); GB18030 and the character to be searched is a digit. */ # undef strrchr # define strrchr(s,c) \ - (GL_LINK_WARNING ("strrchr cannot work correctly on character strings in some multibyte locales - use mbsrchr if you care about internationalization"), \ + (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \ + "in some multibyte locales - " \ + "use mbsrchr if you care about internationalization"), \ strrchr (s, c)) #endif @@ -293,13 +302,16 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim); # if defined GNULIB_POSIXCHECK # undef strsep # define strsep(s,d) \ - (GL_LINK_WARNING ("strsep cannot work correctly on character strings in multibyte locales - use mbssep if you care about internationalization"), \ + (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbssep if you care about internationalization"), \ strsep (s, d)) # endif #elif defined GNULIB_POSIXCHECK # undef strsep # define strsep(s,d) \ - (GL_LINK_WARNING ("strsep is unportable - use gnulib module strsep for portability"), \ + (GL_LINK_WARNING ("strsep is unportable - " \ + "use gnulib module strsep for portability"), \ strsep (s, d)) #endif @@ -310,7 +322,9 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim); as a sequence of bytes, not of characters. */ # undef strstr # define strstr(a,b) \ - (GL_LINK_WARNING ("strstr cannot work correctly on character strings in most multibyte locales - use mbsstr if you care about internationalization"), \ + (GL_LINK_WARNING ("strstr cannot work correctly on character strings " \ + "in most multibyte locales - " \ + "use mbsstr if you care about internationalization"), \ strstr (a, b)) #endif @@ -325,7 +339,11 @@ extern char *strcasestr (const char *haystack, const char *needle); locales. */ # undef strcasestr # define strcasestr(a,b) \ - (GL_LINK_WARNING ("strcasestr does work correctly on character strings in multibyte locales - use mbscasestr if you care about internationalization, or use c-strcasestr if you want a locale independent function"), \ + (GL_LINK_WARNING ("strcasestr does work correctly on character strings " \ + "in multibyte locales - " \ + "use mbscasestr if you care about " \ + "internationalization, or use c-strcasestr if you want " \ + "a locale independent function"), \ strcasestr (a, b)) #endif @@ -359,13 +377,16 @@ extern char *strtok_r (char *restrict s, char const *restrict delim, # if defined GNULIB_POSIXCHECK # undef strtok_r # define strtok_r(s,d,p) \ - (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings in multibyte locales - use mbstok_r if you care about internationalization"), \ + (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbstok_r if you care about internationalization"), \ strtok_r (s, d, p)) # endif #elif defined GNULIB_POSIXCHECK # undef strtok_r # define strtok_r(s,d,p) \ - (GL_LINK_WARNING ("strtok_r is unportable - use gnulib module strtok_r for portability"), \ + (GL_LINK_WARNING ("strtok_r is unportable - " \ + "use gnulib module strtok_r for portability"), \ strtok_r (s, d, p)) #endif @@ -415,6 +436,32 @@ extern char * mbsstr (const char *haystack, const char *needle); extern int mbscasecmp (const char *s1, const char *s2); #endif +#if @GNULIB_MBSNCASECMP@ +/* Compare the initial segment of the character string S1 consisting of at most + N characters with the initial segment of the character string S2 consisting + of at most N characters, ignoring case, returning less than, equal to or + greater than zero if the initial segment of S1 is lexicographically less + than, equal to or greater than the initial segment of S2. + Note: This function may, in multibyte locales, return 0 for initial segments + of different lengths! + Unlike strncasecmp(), this function works correctly in multibyte locales. + But beware that N is not a byte count but a character count! */ +extern int mbsncasecmp (const char *s1, const char *s2, size_t n); +#endif + +#if @GNULIB_MBSPCASECMP@ +/* Compare the initial segment of the character string STRING consisting of + at most mbslen (PREFIX) characters with the character string PREFIX, + ignoring case, returning less than, equal to or greater than zero if this + initial segment is lexicographically less than, equal to or greater than + PREFIX. + Note: This function may, in multibyte locales, return 0 if STRING is of + smaller length than PREFIX! + Unlike strncasecmp(), this function works correctly in multibyte + locales. */ +extern char * mbspcasecmp (const char *string, const char *prefix); +#endif + #if @GNULIB_MBSCASESTR@ /* Find the first occurrence of the character string NEEDLE in the character string HAYSTACK, using case-insensitive comparison. diff --git a/gl/unistd_.h b/gl/unistd_.h index 36fa673..77df861 100644 --- a/gl/unistd_.h +++ b/gl/unistd_.h @@ -1,5 +1,5 @@ /* Substitute for and wrapper around . - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2004-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,32 +18,172 @@ #ifndef _GL_UNISTD_H #define _GL_UNISTD_H -#if HAVE_UNISTD_H +#if @HAVE_UNISTD_H@ # include @ABSOLUTE_UNISTD_H@ #endif +/* The definition of GL_LINK_WARNING is copied here. */ + + /* Declare overridden functions. */ #ifdef __cplusplus extern "C" { #endif -#ifdef FCHDIR_REPLACEMENT + +#if @GNULIB_CHOWN@ +# if @REPLACE_CHOWN@ +/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE + to GID (if GID is not -1). + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +# define chown rpl_chown +extern int chown (const char *file, uid_t uid, gid_t gid); +# endif +#elif defined GNULIB_POSIXCHECK +# undef chown +# define chown(f,u,g) \ + (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \ + "doesn't treat a uid or gid of -1 on some systems - " \ + "use gnulib module chown for portability"), \ + chown (f, u, g)) +#endif + + +#if @GNULIB_DUP2@ +# if !@HAVE_DUP2@ +/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if + NEWFD = OLDFD, otherwise close NEWFD first if it is open. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +extern int dup2 (int oldfd, int newfd); +# endif +#elif defined GNULIB_POSIXCHECK +# undef dup2 +# define dup2(o,n) \ + (GL_LINK_WARNING ("dup2 is unportable - " \ + "use gnulib module dup2 for portability"), \ + dup2 (o, n)) +#endif + + +#if @GNULIB_FCHDIR@ +# if @REPLACE_FCHDIR@ /* Change the process' current working directory to the directory on which - the given file descriptor is open. */ + the given file descriptor is open. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ extern int fchdir (int /*fd*/); -# define close rpl_close +# define close rpl_close extern int close (int); -# define dup rpl_dup +# define dup rpl_dup extern int dup (int); -# define dup2 rpl_dup2 +# define dup2 rpl_dup2 extern int dup2 (int, int); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fchdir +# define fchdir(f) \ + (GL_LINK_WARNING ("fchdir is unportable - " \ + "use gnulib module fchdir for portability"), \ + fchdir (f)) +#endif + + +#if @GNULIB_FTRUNCATE@ +# if !@HAVE_FTRUNCATE@ +/* Change the size of the file to which FD is opened to become equal to LENGTH. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +extern int ftruncate (int fd, off_t length); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ftruncate +# define ftruncate(f,l) \ + (GL_LINK_WARNING ("ftruncate is unportable - " \ + "use gnulib module ftruncate for portability"), \ + ftruncate (f, l)) #endif + +#if @GNULIB_GETCWD@ +/* Include the headers that might declare getcwd so that they will not + cause confusion if included after this file. */ +# include +# if @REPLACE_GETCWD@ +/* Get the name of the current working directory, and put it in SIZE bytes + of BUF. + Return BUF if successful, or NULL if the directory couldn't be determined + or SIZE was too small. + See the POSIX:2001 specification + . + Additionally, the gnulib module 'getcwd' guarantees the following GNU + extension: If BUF is NULL, an array is allocated with 'malloc'; the array + is SIZE bytes long, unless SIZE == 0, in which case it is as big as + necessary. */ +# define getcwd rpl_getcwd +extern char * getcwd (char *buf, size_t size); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getcwd +# define getcwd(b,s) \ + (GL_LINK_WARNING ("getcwd is unportable - " \ + "use gnulib module getcwd for portability"), \ + getcwd (b, s)) +#endif + + +#if @GNULIB_GETLOGIN_R@ +/* Copies the user's login name to NAME. + The array pointed to by NAME has room for SIZE bytes. + + Returns 0 if successful. Upon error, an error number is returned, or -1 in + the case that the login name cannot be found but no specific error is + provided (this case is hopefully rare but is left open by the POSIX spec). + + See . + */ +# if !@HAVE_DECL_GETLOGIN_R@ +# include +extern int getlogin_r (char *name, size_t size); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getlogin_r +# define getlogin_r(n,s) \ + (GL_LINK_WARNING ("getlogin_r is unportable - " \ + "use gnulib module getlogin_r for portability"), \ + getlogin_r (n, s)) +#endif + + +#if @GNULIB_READLINK@ +/* Read the contents of the symbolic link FILE and place the first BUFSIZE + bytes of it into BUF. Return the number of bytes placed into BUF if + successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +# if !@HAVE_READLINK@ +# include +extern int readlink (const char *file, char *buf, size_t bufsize); +# endif +#elif defined GNULIB_POSIXCHECK +# undef readlink +# define readlink(f,b,s) \ + (GL_LINK_WARNING ("readlink is unportable - " \ + "use gnulib module readlink for portability"), \ + readlink (f, b, s)) +#endif + + #ifdef __cplusplus } #endif -- 2.11.4.GIT