📄 string_.h
字号:
/* A GNU-like <string.h>. Copyright (C) 1995-1996, 2001-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 the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */#ifndef _GL_STRING_H/* The include_next requires a split double-inclusion guard. */#@INCLUDE_NEXT@ @NEXT_STRING_H@#ifndef _GL_STRING_H#define _GL_STRING_H/* The definition of GL_LINK_WARNING is copied here. */#ifdef __cplusplusextern "C" {#endif/* Return the first occurrence of NEEDLE in HAYSTACK. */#if @GNULIB_MEMMEM@# if ! @HAVE_DECL_MEMMEM@extern void *memmem (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len);# endif#elif defined GNULIB_POSIXCHECK# undef memmem# define memmem(a,al,b,bl) \ (GL_LINK_WARNING ("memmem is unportable - " \ "use gnulib module memmem for portability"), \ memmem (a, al, b, bl))#endif/* Copy N bytes of SRC to DEST, return pointer to bytes after the last written byte. */#if @GNULIB_MEMPCPY@# if ! @HAVE_MEMPCPY@extern void *mempcpy (void *restrict __dest, void const *restrict __src, size_t __n);# endif#elif defined GNULIB_POSIXCHECK# undef mempcpy# define mempcpy(a,b,n) \ (GL_LINK_WARNING ("mempcpy is unportable - " \ "use gnulib module mempcpy for portability"), \ mempcpy (a, b, n))#endif/* Search backwards through a block for a byte (specified as an int). */#if @GNULIB_MEMRCHR@# if ! @HAVE_DECL_MEMRCHR@extern void *memrchr (void const *, int, size_t);# endif#elif defined GNULIB_POSIXCHECK# undef memrchr# define memrchr(a,b,c) \ (GL_LINK_WARNING ("memrchr is unportable - " \ "use gnulib module memrchr for portability"), \ memrchr (a, b, c))#endif/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */#if @GNULIB_STPCPY@# if ! @HAVE_STPCPY@extern char *stpcpy (char *restrict __dst, char const *restrict __src);# endif#elif defined GNULIB_POSIXCHECK# undef stpcpy# define stpcpy(a,b) \ (GL_LINK_WARNING ("stpcpy is unportable - " \ "use gnulib module stpcpy for portability"), \ stpcpy (a, b))#endif/* Copy no more than N bytes of SRC to DST, returning a pointer past the last non-NUL byte written into DST. */#if @GNULIB_STPNCPY@# if ! @HAVE_STPNCPY@# define stpncpy gnu_stpncpyextern char *stpncpy (char *restrict __dst, char const *restrict __src, size_t __n);# endif#elif defined GNULIB_POSIXCHECK# undef stpncpy# define stpncpy(a,b,n) \ (GL_LINK_WARNING ("stpncpy is unportable - " \ "use gnulib module stpncpy for portability"), \ stpncpy (a, b, n))#endif/* Compare strings S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. Note: This function does not work in multibyte locales. */#if ! @HAVE_STRCASECMP@extern int strcasecmp (char const *s1, char const *s2);#endif#if defined GNULIB_POSIXCHECK/* strcasecmp() does not work with multibyte strings: POSIX says that it operates on "strings", and "string" in POSIX is defined 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"), \ strcasecmp (a, b))#endif/* Compare no more than N bytes of strings S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. Note: This function cannot work correctly in multibyte locales. */#if ! @HAVE_DECL_STRNCASECMP@extern int strncasecmp (char const *s1, char const *s2, size_t n);#endif#if defined GNULIB_POSIXCHECK/* strncasecmp() does not work with multibyte strings: POSIX says that it operates on "strings", and "string" in POSIX is defined 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 - " \ "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#if defined GNULIB_POSIXCHECK/* strchr() does not work with multibyte strings if the locale encoding is 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"), \ strchr (s, c))#endif/* Find the first occurrence of C in S or the final NUL byte. */#if @GNULIB_STRCHRNUL@# if ! @HAVE_STRCHRNUL@extern char *strchrnul (char const *__s, int __c_in);# endif#elif defined GNULIB_POSIXCHECK# undef strchrnul# define strchrnul(a,b) \ (GL_LINK_WARNING ("strchrnul is unportable - " \ "use gnulib module strchrnul for portability"), \ strchrnul (a, b))#endif/* Duplicate S, returning an identical malloc'd string. */#if @GNULIB_STRDUP@# if ! @HAVE_DECL_STRDUP@ && ! defined strdupextern char *strdup (char const *__s);# endif#elif defined GNULIB_POSIXCHECK# undef strdup# define strdup(a) \ (GL_LINK_WARNING ("strdup is unportable - " \ "use gnulib module strdup for portability"), \ strdup (a))#endif/* Return a newly allocated copy of at most N bytes of STRING. */#if @GNULIB_STRNDUP@# if ! @HAVE_STRNDUP@# undef strndup# define strndup rpl_strndup# endif# if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@extern char *strndup (char const *__string, size_t __n);# endif#elif defined GNULIB_POSIXCHECK# undef strndup# define strndup(a,n) \ (GL_LINK_WARNING ("strndup is unportable - " \ "use gnulib module strndup for portability"), \ strndup (a, n))#endif/* Find the length (number of bytes) of STRING, but scan at most MAXLEN bytes. If no '\0' terminator is found in that many bytes, return MAXLEN. */#if @GNULIB_STRNLEN@# if ! @HAVE_DECL_STRNLEN@extern size_t strnlen (char const *__string, size_t __maxlen);# endif#elif defined GNULIB_POSIXCHECK# undef strnlen# define strnlen(a,n) \ (GL_LINK_WARNING ("strnlen is unportable - " \ "use gnulib module strnlen for portability"), \ strnlen (a, n))#endif#if defined GNULIB_POSIXCHECK/* strcspn() 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 locale encoding is GB18030 and one of the characters to be searched is a 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"), \ strcspn (s, a))#endif/* Find the first occurrence in S of any character in ACCEPT. */#if @GNULIB_STRPBRK@# if ! @HAVE_STRPBRK@extern char *strpbrk (char const *__s, char const *__accept);# endif# if defined GNULIB_POSIXCHECK/* 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 locale encoding is GB18030 and one of the characters to be searched is a 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"), \ 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"), \ strpbrk (s, a))#endif#if defined GNULIB_POSIXCHECK/* strspn() assumes the second argument is a list of single-byte characters. 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"), \ strspn (s, a))#endif#if defined GNULIB_POSIXCHECK/* strrchr() does not work with multibyte strings if the locale encoding is 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"), \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -