|
version 1.1, 2012/02/21 22:57:48
|
version 1.1.1.2, 2012/05/29 09:29:43
|
|
Line 1
|
Line 1
|
| /* A GNU-like <string.h>. |
/* A GNU-like <string.h>. |
| |
|
| Copyright (C) 1995-1996, 2001-2009 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 |
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 |
it under the terms of the GNU General Public License as published by |
|
Line 16
|
Line 16
|
| along with this program; if not, write to the Free Software Foundation, |
along with this program; if not, write to the Free Software Foundation, |
| Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
| |
|
| #ifndef _GL_STRING_H | #ifndef _@GUARD_PREFIX@_STRING_H |
| |
|
| #if __GNUC__ >= 3 |
#if __GNUC__ >= 3 |
| @PRAGMA_SYSTEM_HEADER@ |
@PRAGMA_SYSTEM_HEADER@ |
| #endif |
#endif |
| |
@PRAGMA_COLUMNS@ |
| |
|
| /* The include_next requires a split double-inclusion guard. */ |
/* The include_next requires a split double-inclusion guard. */ |
| #@INCLUDE_NEXT@ @NEXT_STRING_H@ |
#@INCLUDE_NEXT@ @NEXT_STRING_H@ |
| |
|
| #ifndef _GL_STRING_H | #ifndef _@GUARD_PREFIX@_STRING_H |
| #define _GL_STRING_H | #define _@GUARD_PREFIX@_STRING_H |
| |
|
| |
/* NetBSD 5.0 mis-defines NULL. */ |
| |
#include <stddef.h> |
| |
|
| #ifndef __attribute__ | /* MirBSD defines mbslen as a macro. */ |
| /* This feature is available in gcc versions 2.5 and later. */ | #if @GNULIB_MBSLEN@ && defined __MirBSD__ |
| # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) | # include <wchar.h> |
| # 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 | |
| #endif |
#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 |
| |
|
| /* The definition of GL_LINK_WARNING is copied here. */ | /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ |
| | /* But in any case avoid namespace pollution on glibc systems. */ |
| | #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ |
| | && ! defined __GLIBC__ |
| | # include <unistd.h> |
| | #endif |
| |
|
| |
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
| |
|
| #ifdef __cplusplus | /* The definition of _GL_ARG_NONNULL is copied here. */ |
| extern "C" { | |
| | /* The definition of _GL_WARN_ON_USE is copied here. */ |
| | |
| | |
| | /* Find the index of the least-significant set bit. */ |
| | #if @GNULIB_FFSL@ |
| | # if !@HAVE_FFSL@ |
| | _GL_FUNCDECL_SYS (ffsl, int, (long int i)); |
| | # endif |
| | _GL_CXXALIAS_SYS (ffsl, int, (long int i)); |
| | _GL_CXXALIASWARN (ffsl); |
| | #elif defined GNULIB_POSIXCHECK |
| | # undef ffsl |
| | # if HAVE_RAW_DECL_FFSL |
| | _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); |
| | # endif |
| #endif |
#endif |
| |
|
| |
|
| |
/* Find the index of the least-significant set bit. */ |
| |
#if @GNULIB_FFSLL@ |
| |
# if !@HAVE_FFSLL@ |
| |
_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); |
| |
# endif |
| |
_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); |
| |
_GL_CXXALIASWARN (ffsll); |
| |
#elif defined GNULIB_POSIXCHECK |
| |
# undef ffsll |
| |
# if HAVE_RAW_DECL_FFSLL |
| |
_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); |
| |
# endif |
| |
#endif |
| |
|
| |
|
| /* Return the first instance of C within N bytes of S, or NULL. */ |
/* Return the first instance of C within N bytes of S, or NULL. */ |
| #if @GNULIB_MEMCHR@ |
#if @GNULIB_MEMCHR@ |
| # if @REPLACE_MEMCHR@ |
# if @REPLACE_MEMCHR@ |
| # define memchr rpl_memchr | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| extern void *memchr (void const *__s, int __c, size_t __n) | # endif |
| __attribute__ ((__pure__)); | # endif |
| | _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) |
| | _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) |
| | _GL_ATTRIBUTE_PURE |
| | _GL_ARG_NONNULL ((1))); |
| | # endif |
| | /* On some systems, this function is defined as an overloaded function: |
| | extern "C" { const void * std::memchr (const void *, int, size_t); } |
| | extern "C++" { void * std::memchr (void *, int, size_t); } */ |
| | _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 |
# endif |
| |
# 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 *, |
| |
(void const *__s, int __c, size_t __n)); |
| |
# else |
| |
_GL_CXXALIASWARN (memchr); |
| |
# endif |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef memchr |
# undef memchr |
| # define memchr(s,c,n) \ | /* Assume memchr is always declared. */ |
| (GL_LINK_WARNING ("memchr has platform-specific bugs - " \ | _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " |
| "use gnulib module memchr for portability" ), \ | "use gnulib module memchr for portability" ); |
| memchr (s, c, n)) | |
| #endif |
#endif |
| |
|
| /* Return the first occurrence of NEEDLE in HAYSTACK. */ |
/* Return the first occurrence of NEEDLE in HAYSTACK. */ |
| #if @GNULIB_MEMMEM@ |
#if @GNULIB_MEMMEM@ |
| # if @REPLACE_MEMMEM@ |
# if @REPLACE_MEMMEM@ |
| # define memmem rpl_memmem | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| | # define memmem rpl_memmem |
| | # endif |
| | _GL_FUNCDECL_RPL (memmem, void *, |
| | (void const *__haystack, size_t __haystack_len, |
| | void const *__needle, size_t __needle_len) |
| | _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)); |
| | # else |
| | # if ! @HAVE_DECL_MEMMEM@ |
| | _GL_FUNCDECL_SYS (memmem, void *, |
| | (void const *__haystack, size_t __haystack_len, |
| | void const *__needle, size_t __needle_len) |
| | _GL_ATTRIBUTE_PURE |
| | _GL_ARG_NONNULL ((1, 3))); |
| | # endif |
| | _GL_CXXALIAS_SYS (memmem, void *, |
| | (void const *__haystack, size_t __haystack_len, |
| | void const *__needle, size_t __needle_len)); |
| # endif |
# endif |
| # if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@ | _GL_CXXALIASWARN (memmem); |
| extern void *memmem (void const *__haystack, size_t __haystack_len, | |
| void const *__needle, size_t __needle_len) | |
| __attribute__ ((__pure__)); | |
| # endif | |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef memmem |
# undef memmem |
| # define memmem(a,al,b,bl) \ | # if HAVE_RAW_DECL_MEMMEM |
| (GL_LINK_WARNING ("memmem is unportable and often quadratic - " \ | _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " |
| "use gnulib module memmem-simple for portability, " \ | "use gnulib module memmem-simple for portability, " |
| "and module memmem for speed" ), \ | "and module memmem for speed" ); |
| memmem (a, al, b, bl)) | # endif |
| #endif |
#endif |
| |
|
| /* Copy N bytes of SRC to DEST, return pointer to bytes after the |
/* Copy N bytes of SRC to DEST, return pointer to bytes after the |
| last written byte. */ |
last written byte. */ |
| #if @GNULIB_MEMPCPY@ |
#if @GNULIB_MEMPCPY@ |
| # if ! @HAVE_MEMPCPY@ |
# if ! @HAVE_MEMPCPY@ |
| extern void *mempcpy (void *restrict __dest, void const *restrict __src, | _GL_FUNCDECL_SYS (mempcpy, void *, |
| size_t __n); | (void *restrict __dest, void const *restrict __src, |
| | size_t __n) |
| | _GL_ARG_NONNULL ((1, 2))); |
| # endif |
# endif |
| |
_GL_CXXALIAS_SYS (mempcpy, void *, |
| |
(void *restrict __dest, void const *restrict __src, |
| |
size_t __n)); |
| |
_GL_CXXALIASWARN (mempcpy); |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef mempcpy |
# undef mempcpy |
| # define mempcpy(a,b,n) \ | # if HAVE_RAW_DECL_MEMPCPY |
| (GL_LINK_WARNING ("mempcpy is unportable - " \ | _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " |
| "use gnulib module mempcpy for portability"), \ | "use gnulib module mempcpy for portability"); |
| mempcpy (a, b, n)) | # endif |
| #endif |
#endif |
| |
|
| /* Search backwards through a block for a byte (specified as an int). */ |
/* Search backwards through a block for a byte (specified as an int). */ |
| #if @GNULIB_MEMRCHR@ |
#if @GNULIB_MEMRCHR@ |
| # if ! @HAVE_DECL_MEMRCHR@ |
# if ! @HAVE_DECL_MEMRCHR@ |
| extern void *memrchr (void const *, int, size_t) | _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) |
| __attribute__ ((__pure__)); | _GL_ATTRIBUTE_PURE |
| | _GL_ARG_NONNULL ((1))); |
| # endif |
# endif |
| |
/* On some systems, this function is defined as an overloaded function: |
| |
extern "C++" { const void * std::memrchr (const void *, int, size_t); } |
| |
extern "C++" { void * std::memrchr (void *, 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) && !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)); |
| |
# else |
| |
_GL_CXXALIASWARN (memrchr); |
| |
# endif |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef memrchr |
# undef memrchr |
| # define memrchr(a,b,c) \ | # if HAVE_RAW_DECL_MEMRCHR |
| (GL_LINK_WARNING ("memrchr is unportable - " \ | _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " |
| "use gnulib module memrchr for portability"), \ | "use gnulib module memrchr for portability"); |
| memrchr (a, b, c)) | # endif |
| #endif |
#endif |
| |
|
| /* Find the first occurrence of C in S. More efficient than |
/* Find the first occurrence of C in S. More efficient than |
|
Line 117 extern void *memrchr (void const *, int, size_t)
|
Line 217 extern void *memrchr (void const *, int, size_t)
|
| occur within N bytes. */ |
occur within N bytes. */ |
| #if @GNULIB_RAWMEMCHR@ |
#if @GNULIB_RAWMEMCHR@ |
| # if ! @HAVE_RAWMEMCHR@ |
# if ! @HAVE_RAWMEMCHR@ |
| extern void *rawmemchr (void const *__s, int __c_in) | _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) |
| __attribute__ ((__pure__)); | _GL_ATTRIBUTE_PURE |
| | _GL_ARG_NONNULL ((1))); |
| # endif |
# endif |
| |
/* On some systems, this function is defined as an overloaded function: |
| |
extern "C++" { const void * std::rawmemchr (const void *, int); } |
| |
extern "C++" { void * std::rawmemchr (void *, int); } */ |
| |
_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) && !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)); |
| |
# else |
| |
_GL_CXXALIASWARN (rawmemchr); |
| |
# endif |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef rawmemchr |
# undef rawmemchr |
| # define rawmemchr(a,b) \ | # if HAVE_RAW_DECL_RAWMEMCHR |
| (GL_LINK_WARNING ("rawmemchr is unportable - " \ | _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " |
| "use gnulib module rawmemchr for portability"), \ | "use gnulib module rawmemchr for portability"); |
| rawmemchr (a, b)) | # endif |
| #endif |
#endif |
| |
|
| /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ |
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ |
| #if @GNULIB_STPCPY@ |
#if @GNULIB_STPCPY@ |
| # if ! @HAVE_STPCPY@ |
# if ! @HAVE_STPCPY@ |
| extern char *stpcpy (char *restrict __dst, char const *restrict __src); | _GL_FUNCDECL_SYS (stpcpy, char *, |
| | (char *restrict __dst, char const *restrict __src) |
| | _GL_ARG_NONNULL ((1, 2))); |
| # endif |
# endif |
| |
_GL_CXXALIAS_SYS (stpcpy, char *, |
| |
(char *restrict __dst, char const *restrict __src)); |
| |
_GL_CXXALIASWARN (stpcpy); |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef stpcpy |
# undef stpcpy |
| # define stpcpy(a,b) \ | # if HAVE_RAW_DECL_STPCPY |
| (GL_LINK_WARNING ("stpcpy is unportable - " \ | _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " |
| "use gnulib module stpcpy for portability"), \ | "use gnulib module stpcpy for portability"); |
| stpcpy (a, b)) | # endif |
| #endif |
#endif |
| |
|
| /* Copy no more than N bytes of SRC to DST, returning a pointer past the |
/* Copy no more than N bytes of SRC to DST, returning a pointer past the |
| last non-NUL byte written into DST. */ |
last non-NUL byte written into DST. */ |
| #if @GNULIB_STPNCPY@ |
#if @GNULIB_STPNCPY@ |
| # if ! @HAVE_STPNCPY@ | # if @REPLACE_STPNCPY@ |
| # define stpncpy gnu_stpncpy | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| extern char *stpncpy (char *restrict __dst, char const *restrict __src, | # undef stpncpy |
| size_t __n); | # define stpncpy rpl_stpncpy |
| | # endif |
| | _GL_FUNCDECL_RPL (stpncpy, char *, |
| | (char *restrict __dst, char const *restrict __src, |
| | size_t __n) |
| | _GL_ARG_NONNULL ((1, 2))); |
| | _GL_CXXALIAS_RPL (stpncpy, char *, |
| | (char *restrict __dst, char const *restrict __src, |
| | size_t __n)); |
| | # else |
| | # if ! @HAVE_STPNCPY@ |
| | _GL_FUNCDECL_SYS (stpncpy, char *, |
| | (char *restrict __dst, char const *restrict __src, |
| | size_t __n) |
| | _GL_ARG_NONNULL ((1, 2))); |
| | # endif |
| | _GL_CXXALIAS_SYS (stpncpy, char *, |
| | (char *restrict __dst, char const *restrict __src, |
| | size_t __n)); |
| # endif |
# endif |
| |
_GL_CXXALIASWARN (stpncpy); |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef stpncpy |
# undef stpncpy |
| # define stpncpy(a,b,n) \ | # if HAVE_RAW_DECL_STPNCPY |
| (GL_LINK_WARNING ("stpncpy is unportable - " \ | _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " |
| "use gnulib module stpncpy for portability"), \ | "use gnulib module stpncpy for portability"); |
| stpncpy (a, b, n)) | # endif |
| #endif |
#endif |
| |
|
| #if defined GNULIB_POSIXCHECK |
#if defined GNULIB_POSIXCHECK |
| /* strchr() does not work with multibyte strings if the locale encoding is |
/* strchr() does not work with multibyte strings if the locale encoding is |
| GB18030 and the character to be searched is a digit. */ |
GB18030 and the character to be searched is a digit. */ |
| # undef strchr |
# undef strchr |
| # define strchr(s,c) \ | /* Assume strchr is always declared. */ |
| (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \ | _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " |
| "in some multibyte locales - " \ | "in some multibyte locales - " |
| "use mbschr if you care about internationalization"), \ | "use mbschr if you care about internationalization"); |
| strchr (s, c)) | |
| #endif |
#endif |
| |
|
| /* Find the first occurrence of C in S or the final NUL byte. */ |
/* Find the first occurrence of C in S or the final NUL byte. */ |
| #if @GNULIB_STRCHRNUL@ |
#if @GNULIB_STRCHRNUL@ |
| # if ! @HAVE_STRCHRNUL@ | # if @REPLACE_STRCHRNUL@ |
| extern char *strchrnul (char const *__s, int __c_in) | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| __attribute__ ((__pure__)); | # define strchrnul rpl_strchrnul |
| | # endif |
| | _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) |
| | _GL_ATTRIBUTE_PURE |
| | _GL_ARG_NONNULL ((1))); |
| | _GL_CXXALIAS_RPL (strchrnul, char *, |
| | (const char *str, int ch)); |
| | # else |
| | # if ! @HAVE_STRCHRNUL@ |
| | _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) |
| | _GL_ATTRIBUTE_PURE |
| | _GL_ARG_NONNULL ((1))); |
| | # endif |
| | /* On some systems, this function is defined as an overloaded function: |
| | extern "C++" { const char * std::strchrnul (const char *, int); } |
| | extern "C++" { char * std::strchrnul (char *, int); } */ |
| | _GL_CXXALIAS_SYS_CAST2 (strchrnul, |
| | char *, (char const *__s, int __c_in), |
| | char const *, (char const *__s, int __c_in)); |
| # endif |
# endif |
| |
# 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)); |
| |
# else |
| |
_GL_CXXALIASWARN (strchrnul); |
| |
# endif |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef strchrnul |
# undef strchrnul |
| # define strchrnul(a,b) \ | # if HAVE_RAW_DECL_STRCHRNUL |
| (GL_LINK_WARNING ("strchrnul is unportable - " \ | _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " |
| "use gnulib module strchrnul for portability"), \ | "use gnulib module strchrnul for portability"); |
| strchrnul (a, b)) | # endif |
| #endif |
#endif |
| |
|
| /* Duplicate S, returning an identical malloc'd string. */ |
/* Duplicate S, returning an identical malloc'd string. */ |
| #if @GNULIB_STRDUP@ |
#if @GNULIB_STRDUP@ |
| # if @REPLACE_STRDUP@ |
# if @REPLACE_STRDUP@ |
| # undef strdup | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| # define strdup rpl_strdup | # endif |
| | # define strdup rpl_strdup |
| | # endif |
| | _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 |
| | _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); |
| # endif |
# endif |
| # if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@ | _GL_CXXALIASWARN (strdup); |
| extern char *strdup (char const *__s); | |
| # endif | |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef strdup |
# undef strdup |
| # define strdup(a) \ | # if HAVE_RAW_DECL_STRDUP |
| (GL_LINK_WARNING ("strdup is unportable - " \ | _GL_WARN_ON_USE (strdup, "strdup is unportable - " |
| "use gnulib module strdup for portability"), \ | "use gnulib module strdup for portability"); |
| strdup (a)) | # endif |
| #endif |
#endif |
| |
|
| |
/* Append no more than N characters from SRC onto DEST. */ |
| |
#if @GNULIB_STRNCAT@ |
| |
# if @REPLACE_STRNCAT@ |
| |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| |
# undef strncat |
| |
# define strncat rpl_strncat |
| |
# endif |
| |
_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) |
| |
_GL_ARG_NONNULL ((1, 2))); |
| |
_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); |
| |
# else |
| |
_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); |
| |
# endif |
| |
_GL_CXXALIASWARN (strncat); |
| |
#elif defined GNULIB_POSIXCHECK |
| |
# undef strncat |
| |
# if HAVE_RAW_DECL_STRNCAT |
| |
_GL_WARN_ON_USE (strncat, "strncat is unportable - " |
| |
"use gnulib module strncat for portability"); |
| |
# endif |
| |
#endif |
| |
|
| /* Return a newly allocated copy of at most N bytes of STRING. */ |
/* Return a newly allocated copy of at most N bytes of STRING. */ |
| #if @GNULIB_STRNDUP@ |
#if @GNULIB_STRNDUP@ |
| # if ! @HAVE_STRNDUP@ | # if @REPLACE_STRNDUP@ |
| # undef strndup | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| # define strndup rpl_strndup | # undef strndup |
| | # define strndup rpl_strndup |
| | # endif |
| | _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) |
| | _GL_ARG_NONNULL ((1))); |
| | _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); |
| | # else |
| | # if ! @HAVE_DECL_STRNDUP@ |
| | _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) |
| | _GL_ARG_NONNULL ((1))); |
| | # endif |
| | _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); |
| # endif |
# endif |
| # if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@ | _GL_CXXALIASWARN (strndup); |
| extern char *strndup (char const *__string, size_t __n); | |
| # endif | |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef strndup |
# undef strndup |
| # define strndup(a,n) \ | # if HAVE_RAW_DECL_STRNDUP |
| (GL_LINK_WARNING ("strndup is unportable - " \ | _GL_WARN_ON_USE (strndup, "strndup is unportable - " |
| "use gnulib module strndup for portability"), \ | "use gnulib module strndup for portability"); |
| strndup (a, n)) | # endif |
| #endif |
#endif |
| |
|
| /* Find the length (number of bytes) of STRING, but scan at most |
/* Find the length (number of bytes) of STRING, but scan at most |
| MAXLEN bytes. If no '\0' terminator is found in that many bytes, |
MAXLEN bytes. If no '\0' terminator is found in that many bytes, |
| return MAXLEN. */ |
return MAXLEN. */ |
| #if @GNULIB_STRNLEN@ |
#if @GNULIB_STRNLEN@ |
| # if ! @HAVE_DECL_STRNLEN@ | # if @REPLACE_STRNLEN@ |
| extern size_t strnlen (char const *__string, size_t __maxlen) | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| __attribute__ ((__pure__)); | # 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) |
| | _GL_ATTRIBUTE_PURE |
| | _GL_ARG_NONNULL ((1))); |
| | # endif |
| | _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); |
| # endif |
# endif |
| |
_GL_CXXALIASWARN (strnlen); |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef strnlen |
# undef strnlen |
| # define strnlen(a,n) \ | # if HAVE_RAW_DECL_STRNLEN |
| (GL_LINK_WARNING ("strnlen is unportable - " \ | _GL_WARN_ON_USE (strnlen, "strnlen is unportable - " |
| "use gnulib module strnlen for portability"), \ | "use gnulib module strnlen for portability"); |
| strnlen (a, n)) | # endif |
| #endif |
#endif |
| |
|
| #if defined GNULIB_POSIXCHECK |
#if defined GNULIB_POSIXCHECK |
|
Line 238 extern size_t strnlen (char const *__string, size_t __
|
Line 456 extern size_t strnlen (char const *__string, size_t __
|
| locale encoding is GB18030 and one of the characters to be searched is a |
locale encoding is GB18030 and one of the characters to be searched is a |
| digit. */ |
digit. */ |
| # undef strcspn |
# undef strcspn |
| # define strcspn(s,a) \ | /* Assume strcspn is always declared. */ |
| (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \ | _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " |
| "in multibyte locales - " \ | "in multibyte locales - " |
| "use mbscspn if you care about internationalization"), \ | "use mbscspn if you care about internationalization"); |
| strcspn (s, a)) | |
| #endif |
#endif |
| |
|
| /* Find the first occurrence in S of any character in ACCEPT. */ |
/* Find the first occurrence in S of any character in ACCEPT. */ |
| #if @GNULIB_STRPBRK@ |
#if @GNULIB_STRPBRK@ |
| # if ! @HAVE_STRPBRK@ |
# if ! @HAVE_STRPBRK@ |
| extern char *strpbrk (char const *__s, char const *__accept) | _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) |
| __attribute__ ((__pure__)); | _GL_ATTRIBUTE_PURE |
| | _GL_ARG_NONNULL ((1, 2))); |
| # endif |
# endif |
| |
/* On some systems, this function is defined as an overloaded function: |
| |
extern "C" { const char * strpbrk (const char *, const char *); } |
| |
extern "C++" { char * strpbrk (char *, const char *); } */ |
| |
_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) && !defined __UCLIBC__) \ |
| |
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
| |
_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); |
| |
_GL_CXXALIASWARN1 (strpbrk, char const *, |
| |
(char const *__s, char const *__accept)); |
| |
# else |
| |
_GL_CXXALIASWARN (strpbrk); |
| |
# endif |
| # if defined GNULIB_POSIXCHECK |
# if defined GNULIB_POSIXCHECK |
| /* strpbrk() assumes the second argument is a list of single-byte characters. |
/* strpbrk() assumes the second argument is a list of single-byte characters. |
| Even in this simple case, it does not work with multibyte strings if the |
Even in this simple case, it does not work with multibyte strings if the |
| locale encoding is GB18030 and one of the characters to be searched is a |
locale encoding is GB18030 and one of the characters to be searched is a |
| digit. */ |
digit. */ |
| # undef strpbrk |
# undef strpbrk |
| # define strpbrk(s,a) \ | _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " |
| (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \ | "in multibyte locales - " |
| "in multibyte locales - " \ | "use mbspbrk if you care about internationalization"); |
| "use mbspbrk if you care about internationalization"), \ | |
| strpbrk (s, a)) | |
| # endif |
# endif |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef strpbrk |
# undef strpbrk |
| # define strpbrk(s,a) \ | # if HAVE_RAW_DECL_STRPBRK |
| (GL_LINK_WARNING ("strpbrk is unportable - " \ | _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " |
| "use gnulib module strpbrk for portability"), \ | "use gnulib module strpbrk for portability"); |
| strpbrk (s, a)) | # endif |
| #endif |
#endif |
| |
|
| #if defined GNULIB_POSIXCHECK |
#if defined GNULIB_POSIXCHECK |
| /* strspn() assumes the second argument is a list of single-byte characters. |
/* strspn() assumes the second argument is a list of single-byte characters. |
| Even in this simple case, it cannot work with multibyte strings. */ |
Even in this simple case, it cannot work with multibyte strings. */ |
| # undef strspn |
# undef strspn |
| # define strspn(s,a) \ | /* Assume strspn is always declared. */ |
| (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \ | _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " |
| "in multibyte locales - " \ | "in multibyte locales - " |
| "use mbsspn if you care about internationalization"), \ | "use mbsspn if you care about internationalization"); |
| strspn (s, a)) | |
| #endif |
#endif |
| |
|
| #if defined GNULIB_POSIXCHECK |
#if defined GNULIB_POSIXCHECK |
| /* strrchr() does not work with multibyte strings if the locale encoding is |
/* strrchr() does not work with multibyte strings if the locale encoding is |
| GB18030 and the character to be searched is a digit. */ |
GB18030 and the character to be searched is a digit. */ |
| # undef strrchr |
# undef strrchr |
| # define strrchr(s,c) \ | /* Assume strrchr is always declared. */ |
| (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \ | _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " |
| "in some multibyte locales - " \ | "in some multibyte locales - " |
| "use mbsrchr if you care about internationalization"), \ | "use mbsrchr if you care about internationalization"); |
| strrchr (s, c)) | |
| #endif |
#endif |
| |
|
| /* Search the next delimiter (char listed in DELIM) starting at *STRINGP. |
/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. |
|
Line 311 extern char *strpbrk (char const *__s, char const *__a
|
Line 539 extern char *strpbrk (char const *__s, char const *__a
|
| See also strtok_r(). */ |
See also strtok_r(). */ |
| #if @GNULIB_STRSEP@ |
#if @GNULIB_STRSEP@ |
| # if ! @HAVE_STRSEP@ |
# if ! @HAVE_STRSEP@ |
| extern char *strsep (char **restrict __stringp, char const *restrict __delim); | _GL_FUNCDECL_SYS (strsep, char *, |
| | (char **restrict __stringp, char const *restrict __delim) |
| | _GL_ARG_NONNULL ((1, 2))); |
| # endif |
# endif |
| |
_GL_CXXALIAS_SYS (strsep, char *, |
| |
(char **restrict __stringp, char const *restrict __delim)); |
| |
_GL_CXXALIASWARN (strsep); |
| # if defined GNULIB_POSIXCHECK |
# if defined GNULIB_POSIXCHECK |
| # undef strsep |
# undef strsep |
| # define strsep(s,d) \ | _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings " |
| (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \ | "in multibyte locales - " |
| "in multibyte locales - " \ | "use mbssep if you care about internationalization"); |
| "use mbssep if you care about internationalization"), \ | |
| strsep (s, d)) | |
| # endif |
# endif |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef strsep |
# undef strsep |
| # define strsep(s,d) \ | # if HAVE_RAW_DECL_STRSEP |
| (GL_LINK_WARNING ("strsep is unportable - " \ | _GL_WARN_ON_USE (strsep, "strsep is unportable - " |
| "use gnulib module strsep for portability"), \ | "use gnulib module strsep for portability"); |
| strsep (s, d)) | # endif |
| #endif |
#endif |
| |
|
| #if @GNULIB_STRSTR@ |
#if @GNULIB_STRSTR@ |
| # if @REPLACE_STRSTR@ |
# if @REPLACE_STRSTR@ |
| # define strstr rpl_strstr | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| char *strstr (const char *haystack, const char *needle) | # endif |
| __attribute__ ((__pure__)); | # endif |
| | _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) |
| | _GL_ATTRIBUTE_PURE |
| | _GL_ARG_NONNULL ((1, 2))); |
| | _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); |
| | # else |
| | /* On some systems, this function is defined as an overloaded function: |
| | extern "C++" { const char * strstr (const char *, const char *); } |
| | extern "C++" { char * strstr (char *, const char *); } */ |
| | _GL_CXXALIAS_SYS_CAST2 (strstr, |
| | char *, (const char *haystack, const char *needle), |
| | const char *, (const char *haystack, const char *needle)); |
| # endif |
# endif |
| |
# 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 *, |
| |
(const char *haystack, const char *needle)); |
| |
# else |
| |
_GL_CXXALIASWARN (strstr); |
| |
# endif |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| /* strstr() does not work with multibyte strings if the locale encoding is |
/* strstr() does not work with multibyte strings if the locale encoding is |
| different from UTF-8: |
different from UTF-8: |
| POSIX says that it operates on "strings", and "string" in POSIX is defined |
POSIX says that it operates on "strings", and "string" in POSIX is defined |
| as a sequence of bytes, not of characters. */ |
as a sequence of bytes, not of characters. */ |
| # undef strstr |
# undef strstr |
| # define strstr(a,b) \ | /* Assume strstr is always declared. */ |
| (GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \ | _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " |
| "work correctly on character strings in most " \ | "work correctly on character strings in most " |
| "multibyte locales - " \ | "multibyte locales - " |
| "use mbsstr if you care about internationalization, " \ | "use mbsstr if you care about internationalization, " |
| "or use strstr if you care about speed"), \ | "or use strstr if you care about speed"); |
| strstr (a, b)) | |
| #endif |
#endif |
| |
|
| /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive |
/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive |
| comparison. */ |
comparison. */ |
| #if @GNULIB_STRCASESTR@ |
#if @GNULIB_STRCASESTR@ |
| # if @REPLACE_STRCASESTR@ |
# if @REPLACE_STRCASESTR@ |
| # define strcasestr rpl_strcasestr | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| | # define strcasestr rpl_strcasestr |
| | # endif |
| | _GL_FUNCDECL_RPL (strcasestr, char *, |
| | (const char *haystack, const char *needle) |
| | _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) |
| | _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 *); } |
| | extern "C++" { char * strcasestr (char *, const char *); } */ |
| | _GL_CXXALIAS_SYS_CAST2 (strcasestr, |
| | char *, (const char *haystack, const char *needle), |
| | const char *, (const char *haystack, const char *needle)); |
| # endif |
# endif |
| # if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@ | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
| extern char *strcasestr (const char *haystack, const char *needle) | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
| __attribute__ ((__pure__)); | _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); |
| | _GL_CXXALIASWARN1 (strcasestr, const char *, |
| | (const char *haystack, const char *needle)); |
| | # else |
| | _GL_CXXALIASWARN (strcasestr); |
| # endif |
# endif |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| /* strcasestr() does not work with multibyte strings: |
/* strcasestr() does not work with multibyte strings: |
| It is a glibc extension, and glibc implements it only for unibyte |
It is a glibc extension, and glibc implements it only for unibyte |
| locales. */ |
locales. */ |
| # undef strcasestr |
# undef strcasestr |
| # define strcasestr(a,b) \ | # if HAVE_RAW_DECL_STRCASESTR |
| (GL_LINK_WARNING ("strcasestr does work correctly on character strings " \ | _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " |
| "in multibyte locales - " \ | "strings in multibyte locales - " |
| "use mbscasestr if you care about " \ | "use mbscasestr if you care about " |
| "internationalization, or use c-strcasestr if you want " \ | "internationalization, or use c-strcasestr if you want " |
| "a locale independent function"), \ | "a locale independent function"); |
| strcasestr (a, b)) | # endif |
| #endif |
#endif |
| |
|
| /* Parse S into tokens separated by characters in DELIM. |
/* Parse S into tokens separated by characters in DELIM. |
| If S is NULL, the saved pointer in SAVE_PTR is used as |
If S is NULL, the saved pointer in SAVE_PTR is used as |
| the next starting point. For example: |
the next starting point. For example: |
| char s[] = "-abc-=-def"; | char s[] = "-abc-=-def"; |
| char *sp; | char *sp; |
| x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" | x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" |
| x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL | x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL |
| x = strtok_r(NULL, "=", &sp); // x = NULL | x = strtok_r(NULL, "=", &sp); // x = NULL |
| // s = "abc\0-def\0" | // s = "abc\0-def\0" |
| |
|
| This is a variant of strtok() that is multithread-safe. |
This is a variant of strtok() that is multithread-safe. |
| |
|
|
Line 397 extern char *strcasestr (const char *haystack, const c
|
Line 671 extern char *strcasestr (const char *haystack, const c
|
| |
|
| See also strsep(). */ |
See also strsep(). */ |
| #if @GNULIB_STRTOK_R@ |
#if @GNULIB_STRTOK_R@ |
| # if ! @HAVE_DECL_STRTOK_R@ | # if @REPLACE_STRTOK_R@ |
| extern char *strtok_r (char *restrict s, char const *restrict delim, | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| char **restrict save_ptr); | # undef strtok_r |
| | # define strtok_r rpl_strtok_r |
| | # endif |
| | _GL_FUNCDECL_RPL (strtok_r, char *, |
| | (char *restrict s, char const *restrict delim, |
| | char **restrict save_ptr) |
| | _GL_ARG_NONNULL ((2, 3))); |
| | _GL_CXXALIAS_RPL (strtok_r, char *, |
| | (char *restrict s, char const *restrict delim, |
| | char **restrict save_ptr)); |
| | # else |
| | # if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK |
| | # undef strtok_r |
| | # endif |
| | # if ! @HAVE_DECL_STRTOK_R@ |
| | _GL_FUNCDECL_SYS (strtok_r, char *, |
| | (char *restrict s, char const *restrict delim, |
| | char **restrict save_ptr) |
| | _GL_ARG_NONNULL ((2, 3))); |
| | # endif |
| | _GL_CXXALIAS_SYS (strtok_r, char *, |
| | (char *restrict s, char const *restrict delim, |
| | char **restrict save_ptr)); |
| # endif |
# endif |
| |
_GL_CXXALIASWARN (strtok_r); |
| # if defined GNULIB_POSIXCHECK |
# if defined GNULIB_POSIXCHECK |
| # undef strtok_r | _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character " |
| # define strtok_r(s,d,p) \ | "strings in multibyte locales - " |
| (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \ | "use mbstok_r if you care about internationalization"); |
| "in multibyte locales - " \ | |
| "use mbstok_r if you care about internationalization"), \ | |
| strtok_r (s, d, p)) | |
| # endif |
# endif |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef strtok_r |
# undef strtok_r |
| # define strtok_r(s,d,p) \ | # if HAVE_RAW_DECL_STRTOK_R |
| (GL_LINK_WARNING ("strtok_r is unportable - " \ | _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " |
| "use gnulib module strtok_r for portability"), \ | "use gnulib module strtok_r for portability"); |
| strtok_r (s, d, p)) | # endif |
| #endif |
#endif |
| |
|
| |
|
|
Line 424 extern char *strtok_r (char *restrict s, char const *r
|
Line 718 extern char *strtok_r (char *restrict s, char const *r
|
| #if @GNULIB_MBSLEN@ |
#if @GNULIB_MBSLEN@ |
| /* Return the number of multibyte characters in the character string STRING. |
/* Return the number of multibyte characters in the character string STRING. |
| This considers multibyte characters, unlike strlen, which counts bytes. */ |
This considers multibyte characters, unlike strlen, which counts bytes. */ |
| extern size_t mbslen (const char *string); | # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ |
| | # undef mbslen |
| | # endif |
| | # if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */ |
| | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| | # define mbslen rpl_mbslen |
| | # endif |
| | _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); |
| | _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); |
| | # else |
| | _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); |
| | _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); |
| | # endif |
| | _GL_CXXALIASWARN (mbslen); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSNLEN@ |
#if @GNULIB_MBSNLEN@ |
| /* Return the number of multibyte characters in the character string starting |
/* Return the number of multibyte characters in the character string starting |
| at STRING and ending at STRING + LEN. */ |
at STRING and ending at STRING + LEN. */ |
| extern size_t mbsnlen (const char *string, size_t len); | _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) |
| | _GL_ARG_NONNULL ((1)); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSCHR@ |
#if @GNULIB_MBSCHR@ |
|
Line 438 extern size_t mbsnlen (const char *string, size_t len)
|
Line 746 extern size_t mbsnlen (const char *string, size_t len)
|
| and return a pointer to it. Return NULL if C is not found in STRING. |
and return a pointer to it. Return NULL if C is not found in STRING. |
| Unlike strchr(), this function works correctly in multibyte locales with |
Unlike strchr(), this function works correctly in multibyte locales with |
| encodings such as GB18030. */ |
encodings such as GB18030. */ |
| # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ | # if defined __hpux |
| extern char * mbschr (const char *string, int c); | #endif |
| | # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ |
| | # endif |
| | _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) |
| | _GL_ARG_NONNULL ((1))); |
| | _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); |
| | # else |
| | _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) |
| | _GL_ARG_NONNULL ((1))); |
| | _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); |
| | # endif |
| | _GL_CXXALIASWARN (mbschr); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSRCHR@ |
#if @GNULIB_MBSRCHR@ |
|
Line 447 extern char * mbschr (const char *string, int c);
|
Line 766 extern char * mbschr (const char *string, int c);
|
| and return a pointer to it. Return NULL if C is not found in STRING. |
and return a pointer to it. Return NULL if C is not found in STRING. |
| Unlike strrchr(), this function works correctly in multibyte locales with |
Unlike strrchr(), this function works correctly in multibyte locales with |
| encodings such as GB18030. */ |
encodings such as GB18030. */ |
| # define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ | # if defined __hpux || defined __INTERIX |
| extern char * mbsrchr (const char *string, int c); | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| | # define mbsrchr rpl_mbsrchr /* avoid collision with system function */ |
| | # endif |
| | _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) |
| | _GL_ARG_NONNULL ((1))); |
| | _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); |
| | # else |
| | _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) |
| | _GL_ARG_NONNULL ((1))); |
| | _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); |
| | # endif |
| | _GL_CXXALIASWARN (mbsrchr); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSSTR@ |
#if @GNULIB_MBSSTR@ |
|
Line 456 extern char * mbsrchr (const char *string, int c);
|
Line 786 extern char * mbsrchr (const char *string, int c);
|
| string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. |
string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. |
| Unlike strstr(), this function works correctly in multibyte locales with |
Unlike strstr(), this function works correctly in multibyte locales with |
| encodings different from UTF-8. */ |
encodings different from UTF-8. */ |
| extern char * mbsstr (const char *haystack, const char *needle); | _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) |
| | _GL_ARG_NONNULL ((1, 2)); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSCASECMP@ |
#if @GNULIB_MBSCASECMP@ |
|
Line 466 extern char * mbsstr (const char *haystack, const char
|
Line 797 extern char * mbsstr (const char *haystack, const char
|
| Note: This function may, in multibyte locales, return 0 for strings of |
Note: This function may, in multibyte locales, return 0 for strings of |
| different lengths! |
different lengths! |
| Unlike strcasecmp(), this function works correctly in multibyte locales. */ |
Unlike strcasecmp(), this function works correctly in multibyte locales. */ |
| extern int mbscasecmp (const char *s1, const char *s2); | _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) |
| | _GL_ARG_NONNULL ((1, 2)); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSNCASECMP@ |
#if @GNULIB_MBSNCASECMP@ |
|
Line 479 extern int mbscasecmp (const char *s1, const char *s2)
|
Line 811 extern int mbscasecmp (const char *s1, const char *s2)
|
| of different lengths! |
of different lengths! |
| Unlike strncasecmp(), this function works correctly in multibyte locales. |
Unlike strncasecmp(), this function works correctly in multibyte locales. |
| But beware that N is not a byte count but a character count! */ |
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); | _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) |
| | _GL_ARG_NONNULL ((1, 2)); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSPCASECMP@ |
#if @GNULIB_MBSPCASECMP@ |
| /* Compare the initial segment of the character string STRING consisting of |
/* Compare the initial segment of the character string STRING consisting of |
| at most mbslen (PREFIX) characters with the character string PREFIX, |
at most mbslen (PREFIX) characters with the character string PREFIX, |
| ignoring case, returning less than, equal to or greater than zero if this | ignoring case. If the two match, return a pointer to the first byte |
| initial segment is lexicographically less than, equal to or greater than | after this prefix in STRING. Otherwise, return NULL. |
| PREFIX. | Note: This function may, in multibyte locales, return non-NULL if STRING |
| Note: This function may, in multibyte locales, return 0 if STRING is of | is of smaller length than PREFIX! |
| smaller length than PREFIX! | |
| Unlike strncasecmp(), this function works correctly in multibyte |
Unlike strncasecmp(), this function works correctly in multibyte |
| locales. */ |
locales. */ |
| extern char * mbspcasecmp (const char *string, const char *prefix); | _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) |
| | _GL_ARG_NONNULL ((1, 2)); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSCASESTR@ |
#if @GNULIB_MBSCASESTR@ |
|
Line 501 extern char * mbspcasecmp (const char *string, const c
|
Line 834 extern char * mbspcasecmp (const char *string, const c
|
| Note: This function may, in multibyte locales, return success even if |
Note: This function may, in multibyte locales, return success even if |
| strlen (haystack) < strlen (needle) ! |
strlen (haystack) < strlen (needle) ! |
| Unlike strcasestr(), this function works correctly in multibyte locales. */ |
Unlike strcasestr(), this function works correctly in multibyte locales. */ |
| extern char * mbscasestr (const char *haystack, const char *needle); | _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) |
| | _GL_ARG_NONNULL ((1, 2)); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSCSPN@ |
#if @GNULIB_MBSCSPN@ |
|
Line 510 extern char * mbscasestr (const char *haystack, const
|
Line 844 extern char * mbscasestr (const char *haystack, const
|
| beginning of the string to this occurrence, or to the end of the string |
beginning of the string to this occurrence, or to the end of the string |
| if none exists. |
if none exists. |
| Unlike strcspn(), this function works correctly in multibyte locales. */ |
Unlike strcspn(), this function works correctly in multibyte locales. */ |
| extern size_t mbscspn (const char *string, const char *accept); | _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) |
| | _GL_ARG_NONNULL ((1, 2)); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSPBRK@ |
#if @GNULIB_MBSPBRK@ |
|
Line 518 extern size_t mbscspn (const char *string, const char
|
Line 853 extern size_t mbscspn (const char *string, const char
|
| in the character string ACCEPT. Return the pointer to it, or NULL if none |
in the character string ACCEPT. Return the pointer to it, or NULL if none |
| exists. |
exists. |
| Unlike strpbrk(), this function works correctly in multibyte locales. */ |
Unlike strpbrk(), this function works correctly in multibyte locales. */ |
| # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ | # if defined __hpux |
| extern char * mbspbrk (const char *string, const char *accept); | #endif |
| | # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ |
| | # endif |
| | _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) |
| | _GL_ARG_NONNULL ((1, 2))); |
| | _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); |
| | # else |
| | _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) |
| | _GL_ARG_NONNULL ((1, 2))); |
| | _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); |
| | # endif |
| | _GL_CXXALIASWARN (mbspbrk); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSSPN@ |
#if @GNULIB_MBSSPN@ |
|
Line 528 extern char * mbspbrk (const char *string, const char
|
Line 874 extern char * mbspbrk (const char *string, const char
|
| beginning of the string to this occurrence, or to the end of the string |
beginning of the string to this occurrence, or to the end of the string |
| if none exists. |
if none exists. |
| Unlike strspn(), this function works correctly in multibyte locales. */ |
Unlike strspn(), this function works correctly in multibyte locales. */ |
| extern size_t mbsspn (const char *string, const char *reject); | _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) |
| | _GL_ARG_NONNULL ((1, 2)); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSSEP@ |
#if @GNULIB_MBSSEP@ |
|
Line 546 extern size_t mbsspn (const char *string, const char *
|
Line 893 extern size_t mbsspn (const char *string, const char *
|
| Caveat: The identity of the delimiting character is lost. |
Caveat: The identity of the delimiting character is lost. |
| |
|
| See also mbstok_r(). */ |
See also mbstok_r(). */ |
| extern char * mbssep (char **stringp, const char *delim); | _GL_EXTERN_C char * mbssep (char **stringp, const char *delim) |
| | _GL_ARG_NONNULL ((1, 2)); |
| #endif |
#endif |
| |
|
| #if @GNULIB_MBSTOK_R@ |
#if @GNULIB_MBSTOK_R@ |
|
Line 554 extern char * mbssep (char **stringp, const char *deli
|
Line 902 extern char * mbssep (char **stringp, const char *deli
|
| the character string DELIM. |
the character string DELIM. |
| If STRING is NULL, the saved pointer in SAVE_PTR is used as |
If STRING is NULL, the saved pointer in SAVE_PTR is used as |
| the next starting point. For example: |
the next starting point. For example: |
| char s[] = "-abc-=-def"; | char s[] = "-abc-=-def"; |
| char *sp; | char *sp; |
| x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" | x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" |
| x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL | x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL |
| x = mbstok_r(NULL, "=", &sp); // x = NULL | x = mbstok_r(NULL, "=", &sp); // x = NULL |
| // s = "abc\0-def\0" | // s = "abc\0-def\0" |
| |
|
| Caveat: It modifies the original string. |
Caveat: It modifies the original string. |
| Caveat: These functions cannot be used on constant strings. |
Caveat: These functions cannot be used on constant strings. |
| Caveat: The identity of the delimiting character is lost. |
Caveat: The identity of the delimiting character is lost. |
| |
|
| See also mbssep(). */ |
See also mbssep(). */ |
| extern char * mbstok_r (char *string, const char *delim, char **save_ptr); | _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) |
| | _GL_ARG_NONNULL ((2, 3)); |
| #endif |
#endif |
| |
|
| /* Map any int, typically from errno, into an error message. */ |
/* Map any int, typically from errno, into an error message. */ |
| #if @GNULIB_STRERROR@ |
#if @GNULIB_STRERROR@ |
| # if @REPLACE_STRERROR@ |
# if @REPLACE_STRERROR@ |
| # undef strerror | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| # define strerror rpl_strerror | # undef strerror |
| extern char *strerror (int); | # endif |
| | # endif |
| | _GL_FUNCDECL_RPL (strerror, char *, (int)); |
| | _GL_CXXALIAS_RPL (strerror, char *, (int)); |
| | # else |
| | _GL_CXXALIAS_SYS (strerror, char *, (int)); |
| # endif |
# endif |
| |
_GL_CXXALIASWARN (strerror); |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef strerror |
# undef strerror |
| # define strerror(e) \ | /* Assume strerror is always declared. */ |
| (GL_LINK_WARNING ("strerror is unportable - " \ | _GL_WARN_ON_USE (strerror, "strerror is unportable - " |
| "use gnulib module strerror to guarantee non-NULL result"), \ | "use gnulib module strerror to guarantee non-NULL result"); |
| strerror (e)) | |
| #endif |
#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 @GNULIB_STRSIGNAL@ |
| # if @REPLACE_STRSIGNAL@ |
# if @REPLACE_STRSIGNAL@ |
| # define strsignal rpl_strsignal | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| | # define strsignal rpl_strsignal |
| | # endif |
| | _GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); |
| | _GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); |
| | # else |
| | # if ! @HAVE_DECL_STRSIGNAL@ |
| | _GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); |
| | # endif |
| | /* Need to cast, because on Cygwin 1.5.x systems, the return type is |
| | 'const char *'. */ |
| | _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); |
| # endif |
# endif |
| # if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@ | _GL_CXXALIASWARN (strsignal); |
| extern char *strsignal (int __sig); | |
| # endif | |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef strsignal |
# undef strsignal |
| # define strsignal(a) \ | # if HAVE_RAW_DECL_STRSIGNAL |
| (GL_LINK_WARNING ("strsignal is unportable - " \ | _GL_WARN_ON_USE (strsignal, "strsignal is unportable - " |
| "use gnulib module strsignal for portability"), \ | "use gnulib module strsignal for portability"); |
| strsignal (a)) | # endif |
| #endif |
#endif |
| |
|
| #if @GNULIB_STRVERSCMP@ |
#if @GNULIB_STRVERSCMP@ |
| # if !@HAVE_STRVERSCMP@ |
# if !@HAVE_STRVERSCMP@ |
| extern int strverscmp (const char *, const char *); | _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) |
| | _GL_ARG_NONNULL ((1, 2))); |
| # endif |
# endif |
| |
_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); |
| |
_GL_CXXALIASWARN (strverscmp); |
| #elif defined GNULIB_POSIXCHECK |
#elif defined GNULIB_POSIXCHECK |
| # undef strverscmp |
# undef strverscmp |
| # define strverscmp(a, b) \ | # if HAVE_RAW_DECL_STRVERSCMP |
| (GL_LINK_WARNING ("strverscmp is unportable - " \ | _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " |
| "use gnulib module strverscmp for portability"), \ | "use gnulib module strverscmp for portability"); |
| strverscmp (a, b)) | # endif |
| #endif |
#endif |
| |
|
| |
|
| #ifdef __cplusplus | #endif /* _@GUARD_PREFIX@_STRING_H */ |
| } | #endif /* _@GUARD_PREFIX@_STRING_H */ |
| #endif | |
| |
| #endif /* _GL_STRING_H */ | |
| #endif /* _GL_STRING_H */ | |