📄 string_.h
字号:
strrchr (s, c))#endif/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. If one is found, overwrite it with a NUL, and advance *STRINGP to point to the next char after it. Otherwise, set *STRINGP to NULL. If *STRINGP was already NULL, nothing happens. Return the old value of *STRINGP. This is a variant of strtok() that is multithread-safe and supports empty fields. Caveat: It modifies the original string. Caveat: These functions cannot be used on constant strings. Caveat: The identity of the delimiting character is lost. Caveat: It doesn't work with multibyte strings unless all of the delimiter characters are ASCII characters < 0x30. See also strtok_r(). */#if @GNULIB_STRSEP@# if ! @HAVE_STRSEP@extern char *strsep (char **restrict __stringp, char const *restrict __delim);# endif# 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"), \ 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"), \ strsep (s, d))#endif#if defined GNULIB_POSIXCHECK/* strstr() does not work with multibyte strings if the locale encoding is different from UTF-8: POSIX says that it operates on "strings", and "string" in POSIX is defined 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"), \ strstr (a, b))#endif/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive comparison. */#if ! @HAVE_STRCASESTR@extern char *strcasestr (const char *haystack, const char *needle);#endif#if defined GNULIB_POSIXCHECK/* strcasestr() does not work with multibyte strings: It is a glibc extension, and glibc implements it only for unibyte 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"), \ strcasestr (a, b))#endif/* Parse S into tokens separated by characters in DELIM. If S is NULL, the saved pointer in SAVE_PTR is used as the next starting point. For example: char s[] = "-abc-=-def"; char *sp; x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL x = strtok_r(NULL, "=", &sp); // x = NULL // s = "abc\0-def\0" This is a variant of strtok() that is multithread-safe. For the POSIX documentation for this function, see: http://www.opengroup.org/susv3xsh/strtok.html Caveat: It modifies the original string. Caveat: These functions cannot be used on constant strings. Caveat: The identity of the delimiting character is lost. Caveat: It doesn't work with multibyte strings unless all of the delimiter characters are ASCII characters < 0x30. See also strsep(). */#if @GNULIB_STRTOK_R@# if ! @HAVE_DECL_STRTOK_R@extern char *strtok_r (char *restrict s, char const *restrict delim, char **restrict save_ptr);# endif# 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"), \ 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"), \ strtok_r (s, d, p))#endif/* The following functions are not specified by POSIX. They are gnulib extensions. */#if @GNULIB_MBSLEN@/* Return the number of multibyte characters in the character string STRING. This considers multibyte characters, unlike strlen, which counts bytes. */extern size_t mbslen (const char *string);#endif#if @GNULIB_MBSNLEN@/* Return the number of multibyte characters in the character string starting at STRING and ending at STRING + LEN. */extern size_t mbsnlen (const char *string, size_t len);#endif#if @GNULIB_MBSCHR@/* Locate the first single-byte character C in the character string 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 encodings such as GB18030. */# define mbschr rpl_mbschr /* avoid collision with HP-UX function */extern char * mbschr (const char *string, int c);#endif#if @GNULIB_MBSRCHR@/* Locate the last single-byte character C in the character string 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 encodings such as GB18030. */# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */extern char * mbsrchr (const char *string, int c);#endif#if @GNULIB_MBSSTR@/* Find the first occurrence of the character string NEEDLE in the character string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. Unlike strstr(), this function works correctly in multibyte locales with encodings different from UTF-8. */extern char * mbsstr (const char *haystack, const char *needle);#endif#if @GNULIB_MBSCASECMP@/* Compare the character 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 may, in multibyte locales, return 0 for strings of different lengths! Unlike strcasecmp(), this function works correctly in multibyte locales. */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. Note: This function may, in multibyte locales, return success even if strlen (haystack) < strlen (needle) ! Unlike strcasestr(), this function works correctly in multibyte locales. */extern char * mbscasestr (const char *haystack, const char *needle);#endif#if @GNULIB_MBSCSPN@/* Find the first occurrence in the character string STRING of any character in the character string ACCEPT. Return the number of bytes from the beginning of the string to this occurrence, or to the end of the string if none exists. Unlike strcspn(), this function works correctly in multibyte locales. */extern size_t mbscspn (const char *string, const char *accept);#endif#if @GNULIB_MBSPBRK@/* Find the first occurrence in the character string STRING of any character in the character string ACCEPT. Return the pointer to it, or NULL if none exists. Unlike strpbrk(), this function works correctly in multibyte locales. */# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */extern char * mbspbrk (const char *string, const char *accept);#endif#if @GNULIB_MBSSPN@/* Find the first occurrence in the character string STRING of any character not in the character string REJECT. Return the number of bytes from the beginning of the string to this occurrence, or to the end of the string if none exists. Unlike strspn(), this function works correctly in multibyte locales. */extern size_t mbsspn (const char *string, const char *reject);#endif#if @GNULIB_MBSSEP@/* Search the next delimiter (multibyte character listed in the character string DELIM) starting at the character string *STRINGP. If one is found, overwrite it with a NUL, and advance *STRINGP to point to the next multibyte character after it. Otherwise, set *STRINGP to NULL. If *STRINGP was already NULL, nothing happens. Return the old value of *STRINGP. This is a variant of mbstok_r() that supports empty fields. Caveat: It modifies the original string. Caveat: These functions cannot be used on constant strings. Caveat: The identity of the delimiting character is lost. See also mbstok_r(). */extern char * mbssep (char **stringp, const char *delim);#endif#if @GNULIB_MBSTOK_R@/* Parse the character string STRING into tokens separated by characters in the character string DELIM. If STRING is NULL, the saved pointer in SAVE_PTR is used as the next starting point. For example: char s[] = "-abc-=-def"; char *sp; x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL x = mbstok_r(NULL, "=", &sp); // x = NULL // s = "abc\0-def\0" Caveat: It modifies the original string. Caveat: These functions cannot be used on constant strings. Caveat: The identity of the delimiting character is lost. See also mbssep(). */extern char * mbstok_r (char *string, const char *delim, char **save_ptr);#endif#ifdef __cplusplus}#endif#endif /* _GL_STRING_H */#endif /* _GL_STRING_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -