X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=inline;f=lib%2Fstring.in.h;h=652c9407bcaeb182be805470fe9fe67a3d5f303a;hb=93dca9da5d488fcf40c38f63d9762a9f54b1a8b0;hp=6712256f2508615cab3514459e9443f61b4785ef;hpb=097fd2f5f5900d6da3dabe27118aaaa824342352;p=gnulib.git diff --git a/lib/string.in.h b/lib/string.in.h index 6712256f2..652c9407b 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 1995-1996, 2001-2010 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 2001-2011 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 @@ -21,6 +21,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_STRING_H@ @@ -36,17 +37,20 @@ # include #endif -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) -# define __attribute__(Spec) /* empty */ -# endif -/* The attribute __pure__ was added in gcc 2.96. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) -# define __pure__ /* empty */ -# endif +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +# define _GL_ATTRIBUTE_PURE /* empty */ #endif +/* NetBSD 5.0 declares strsignal in , not in . */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ + && ! defined __GLIBC__ +# include +#endif /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ @@ -62,13 +66,13 @@ # define memchr rpl_memchr # endif _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); # else # if ! @HAVE_MEMCHR@ _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -78,7 +82,7 @@ _GL_CXXALIAS_SYS_CAST2 (memchr, void *, (void const *__s, int __c, size_t __n), void const *, (void const *__s, int __c, size_t __n)); # endif -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); _GL_CXXALIASWARN1 (memchr, void const *, @@ -102,7 +106,8 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " _GL_FUNCDECL_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 3))); _GL_CXXALIAS_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len)); @@ -111,7 +116,8 @@ _GL_CXXALIAS_RPL (memmem, void *, _GL_FUNCDECL_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 3))); # endif _GL_CXXALIAS_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, @@ -152,7 +158,7 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " #if @GNULIB_MEMRCHR@ # if ! @HAVE_DECL_MEMRCHR@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -161,7 +167,7 @@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) _GL_CXXALIAS_SYS_CAST2 (memrchr, void *, (void const *, int, size_t), void const *, (void const *, int, size_t)); -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); @@ -182,7 +188,7 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " #if @GNULIB_RAWMEMCHR@ # if ! @HAVE_RAWMEMCHR@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -191,7 +197,7 @@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) _GL_CXXALIAS_SYS_CAST2 (rawmemchr, void *, (void const *__s, int __c_in), void const *, (void const *__s, int __c_in)); -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); @@ -229,6 +235,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " #if @GNULIB_STPNCPY@ # if @REPLACE_STPNCPY@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef stpncpy # define stpncpy rpl_stpncpy # endif _GL_FUNCDECL_RPL (stpncpy, char *, @@ -272,7 +279,7 @@ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " #if @GNULIB_STRCHRNUL@ # if ! @HAVE_STRCHRNUL@ _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -281,7 +288,7 @@ _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) _GL_CXXALIAS_SYS_CAST2 (strchrnul, char *, (char const *__s, int __c_in), char const *, (char const *__s, int __c_in)); -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); @@ -306,6 +313,10 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); # else +# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup + /* strdup exists as a function and as a macro. Get rid of the macro. */ +# undef strdup +# endif # if !(@HAVE_DECL_STRDUP@ || defined strdup) _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); # endif @@ -372,12 +383,23 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - " MAXLEN bytes. If no '\0' terminator is found in that many bytes, return MAXLEN. */ #if @GNULIB_STRNLEN@ -# if ! @HAVE_DECL_STRNLEN@ +# if @REPLACE_STRNLEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strnlen +# define strnlen rpl_strnlen +# endif +_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); +# else +# if ! @HAVE_DECL_STRNLEN@ _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); +# endif _GL_CXXALIASWARN (strnlen); #elif defined GNULIB_POSIXCHECK # undef strnlen @@ -403,7 +425,7 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " #if @GNULIB_STRPBRK@ # if ! @HAVE_STRPBRK@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif /* On some systems, this function is defined as an overloaded function: @@ -412,7 +434,7 @@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) _GL_CXXALIAS_SYS_CAST2 (strpbrk, char *, (char const *__s, char const *__accept), const char *, (char const *__s, char const *__accept)); -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); _GL_CXXALIASWARN1 (strpbrk, char const *, @@ -503,7 +525,7 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - " # define strstr rpl_strstr # endif _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); # else @@ -514,7 +536,7 @@ _GL_CXXALIAS_SYS_CAST2 (strstr, char *, (const char *haystack, const char *needle), const char *, (const char *haystack, const char *needle)); # endif -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); _GL_CXXALIASWARN1 (strstr, const char *, @@ -545,14 +567,16 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " # endif _GL_FUNCDECL_RPL (strcasestr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strcasestr, char *, (const char *haystack, const char *needle)); # else # if ! @HAVE_STRCASESTR@ _GL_FUNCDECL_SYS (strcasestr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const char * strcasestr (const char *, const char *); } @@ -561,7 +585,7 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr, char *, (const char *haystack, const char *needle), const char *, (const char *haystack, const char *needle)); # endif -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); _GL_CXXALIASWARN1 (strcasestr, const char *, @@ -753,11 +777,10 @@ _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) #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! + ignoring case. If the two match, return a pointer to the first byte + after this prefix in STRING. Otherwise, return NULL. + Note: This function may, in multibyte locales, return non-NULL if STRING + is of smaller length than PREFIX! Unlike strncasecmp(), this function works correctly in multibyte locales. */ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) @@ -874,6 +897,35 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - " "use gnulib module strerror to guarantee non-NULL result"); #endif +/* Map any int, typically from errno, into an error message. Multithread-safe. + Uses the POSIX declaration, not the glibc declaration. */ +#if @GNULIB_STRERROR_R@ +# if @REPLACE_STRERROR_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strerror_r +# define strerror_r rpl_strerror_r +# endif +_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); +# else +# if !@HAVE_DECL_STRERROR_R@ +_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); +# endif +# if @HAVE_DECL_STRERROR_R@ +_GL_CXXALIASWARN (strerror_r); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strerror_r +# if HAVE_RAW_DECL_STRERROR_R +_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " + "use gnulib module strerror_r-posix for portability"); +# endif +#endif + #if @GNULIB_STRSIGNAL@ # if @REPLACE_STRSIGNAL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)