diff options
Diffstat (limited to 'gl/strings.in.h')
| -rw-r--r-- | gl/strings.in.h | 153 |
1 files changed, 134 insertions, 19 deletions
diff --git a/gl/strings.in.h b/gl/strings.in.h index 2cfe8b16..40c891d7 100644 --- a/gl/strings.in.h +++ b/gl/strings.in.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* A substitute <strings.h>. | 1 | /* A substitute <strings.h>. |
| 2 | 2 | ||
| 3 | Copyright (C) 2007-2023 Free Software Foundation, Inc. | 3 | Copyright (C) 2007-2025 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is free software: you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU Lesser General Public License as | 6 | it under the terms of the GNU Lesser General Public License as |
| @@ -36,11 +36,26 @@ | |||
| 36 | #ifndef _@GUARD_PREFIX@_STRINGS_H | 36 | #ifndef _@GUARD_PREFIX@_STRINGS_H |
| 37 | #define _@GUARD_PREFIX@_STRINGS_H | 37 | #define _@GUARD_PREFIX@_STRINGS_H |
| 38 | 38 | ||
| 39 | /* This file uses _GL_ARG_NONNULL, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ | ||
| 40 | #if !_GL_CONFIG_H_INCLUDED | ||
| 41 | #error "Please include config.h first." | ||
| 42 | #endif | ||
| 43 | |||
| 39 | #if ! @HAVE_DECL_STRNCASECMP@ | 44 | #if ! @HAVE_DECL_STRNCASECMP@ |
| 40 | /* Get size_t. */ | 45 | /* Get size_t. */ |
| 41 | # include <stddef.h> | 46 | # include <stddef.h> |
| 42 | #endif | 47 | #endif |
| 43 | 48 | ||
| 49 | #if @GNULIB_STRCASECMP_L@ || @GNULIB_STRNCASECMP_L@ | ||
| 50 | /* Get locale_t. */ | ||
| 51 | # include <locale.h> | ||
| 52 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ < 10) \ | ||
| 53 | || (defined __APPLE__ && defined __MACH__)) | ||
| 54 | /* Get the declaration of strcasecmp_l. */ | ||
| 55 | # include <string.h> | ||
| 56 | # endif | ||
| 57 | #endif | ||
| 58 | |||
| 44 | 59 | ||
| 45 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | 60 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
| 46 | 61 | ||
| @@ -53,10 +68,10 @@ extern "C" { | |||
| 53 | #endif | 68 | #endif |
| 54 | 69 | ||
| 55 | 70 | ||
| 56 | /* Find the index of the least-significant set bit. */ | ||
| 57 | #if @GNULIB_FFS@ | 71 | #if @GNULIB_FFS@ |
| 72 | /* Find the index of the least-significant set bit. */ | ||
| 58 | # if !@HAVE_FFS@ | 73 | # if !@HAVE_FFS@ |
| 59 | _GL_FUNCDECL_SYS (ffs, int, (int i)); | 74 | _GL_FUNCDECL_SYS (ffs, int, (int i), ); |
| 60 | # endif | 75 | # endif |
| 61 | _GL_CXXALIAS_SYS (ffs, int, (int i)); | 76 | _GL_CXXALIAS_SYS (ffs, int, (int i)); |
| 62 | _GL_CXXALIASWARN (ffs); | 77 | _GL_CXXALIASWARN (ffs); |
| @@ -67,52 +82,152 @@ _GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module"); | |||
| 67 | # endif | 82 | # endif |
| 68 | #endif | 83 | #endif |
| 69 | 84 | ||
| 85 | #if @GNULIB_STRCASECMP@ | ||
| 70 | /* Compare strings S1 and S2, ignoring case, returning less than, equal to or | 86 | /* Compare strings S1 and S2, ignoring case, returning less than, equal to or |
| 71 | greater than zero if S1 is lexicographically less than, equal to or greater | 87 | greater than zero if S1 is lexicographically less than, equal to or greater |
| 72 | than S2. | 88 | than S2. |
| 73 | Note: This function does not work in multibyte locales. */ | 89 | Note: This function does not work in multibyte locales. */ |
| 74 | #if ! @HAVE_STRCASECMP@ | 90 | # if @REPLACE_STRCASECMP@ |
| 75 | extern int strcasecmp (char const *s1, char const *s2) | 91 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 76 | _GL_ARG_NONNULL ((1, 2)); | 92 | # undef strcasecmp |
| 77 | #endif | 93 | # define strcasecmp rpl_strcasecmp |
| 78 | #if defined GNULIB_POSIXCHECK | 94 | # endif |
| 95 | _GL_FUNCDECL_RPL (strcasecmp, int, (const char *, const char *), | ||
| 96 | _GL_ARG_NONNULL ((1, 2))); | ||
| 97 | _GL_CXXALIAS_RPL (strcasecmp, int, (const char *, const char *)); | ||
| 98 | # else | ||
| 99 | # if !@HAVE_STRCASECMP@ | ||
| 100 | _GL_FUNCDECL_SYS (strcasecmp, int, (const char *, const char *), | ||
| 101 | _GL_ARG_NONNULL ((1, 2))); | ||
| 102 | # endif | ||
| 103 | _GL_CXXALIAS_SYS (strcasecmp, int, (const char *, const char *)); | ||
| 104 | # endif | ||
| 105 | # if __GLIBC__ >= 2 | ||
| 106 | _GL_CXXALIASWARN (strcasecmp); | ||
| 107 | # endif | ||
| 108 | #elif defined GNULIB_POSIXCHECK | ||
| 79 | /* strcasecmp() does not work with multibyte strings: | 109 | /* strcasecmp() does not work with multibyte strings: |
| 80 | POSIX says that it operates on "strings", and "string" in POSIX is defined | 110 | POSIX says that it operates on "strings", and "string" in POSIX is defined |
| 81 | as a sequence of bytes, not of characters. */ | 111 | as a sequence of bytes, not of characters. */ |
| 82 | # undef strcasecmp | 112 | # undef strcasecmp |
| 83 | # if HAVE_RAW_DECL_STRCASECMP | 113 | # if HAVE_RAW_DECL_STRCASECMP |
| 84 | _GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character " | 114 | _GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character " |
| 85 | "strings in multibyte locales - " | 115 | "strings in multibyte locales and is unportable - " |
| 86 | "use mbscasecmp if you care about " | 116 | "use mbscasecmp if you care about " |
| 87 | "internationalization, or use c_strcasecmp , " | 117 | "internationalization, or use c_strcasecmp " |
| 88 | "gnulib module c-strcase) if you want a locale " | 118 | "(gnulib module c-strcasecmp) if you want a locale " |
| 89 | "independent function"); | 119 | "independent function"); |
| 90 | # endif | 120 | # endif |
| 91 | #endif | 121 | #endif |
| 92 | 122 | ||
| 123 | #if @GNULIB_STRCASECMP_L@ | ||
| 124 | # if @REPLACE_STRCASECMP_L@ | ||
| 125 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 126 | # undef strcasecmp_l | ||
| 127 | # define strcasecmp_l rpl_strcasecmp_l | ||
| 128 | # endif | ||
| 129 | _GL_FUNCDECL_RPL (strcasecmp_l, int, | ||
| 130 | (const char *s1, const char *s2, locale_t locale), | ||
| 131 | _GL_ARG_NONNULL ((1, 2, 3))); | ||
| 132 | _GL_CXXALIAS_RPL (strcasecmp_l, int, | ||
| 133 | (const char *s1, const char *s2, locale_t locale)); | ||
| 134 | # else | ||
| 135 | # if !@HAVE_STRCASECMP_L@ | ||
| 136 | _GL_FUNCDECL_SYS (strcasecmp_l, int, | ||
| 137 | (const char *s1, const char *s2, locale_t locale), | ||
| 138 | _GL_ARG_NONNULL ((1, 2, 3))); | ||
| 139 | # endif | ||
| 140 | _GL_CXXALIAS_SYS (strcasecmp_l, int, | ||
| 141 | (const char *s1, const char *s2, locale_t locale)); | ||
| 142 | # endif | ||
| 143 | # if __GLIBC__ >= 2 | ||
| 144 | _GL_CXXALIASWARN (strcasecmp_l); | ||
| 145 | # endif | ||
| 146 | #elif defined GNULIB_POSIXCHECK | ||
| 147 | /* strcasecmp_l() does not work with multibyte strings: | ||
| 148 | POSIX says that it operates on "strings", and "string" in POSIX is defined | ||
| 149 | as a sequence of bytes, not of characters. */ | ||
| 150 | # undef strcasecmp_l | ||
| 151 | # if HAVE_RAW_DECL_STRCASECMP_L | ||
| 152 | _GL_WARN_ON_USE (strcasecmp_l, "strcasecmp_l cannot work correctly on " | ||
| 153 | "character strings in multibyte locales and is unportable - " | ||
| 154 | "use gnulib module strcasecmp_l for portability"); | ||
| 155 | # endif | ||
| 156 | #endif | ||
| 157 | |||
| 158 | #if @GNULIB_STRNCASECMP@ | ||
| 93 | /* Compare no more than N bytes of strings S1 and S2, ignoring case, | 159 | /* Compare no more than N bytes of strings S1 and S2, ignoring case, |
| 94 | returning less than, equal to or greater than zero if S1 is | 160 | returning less than, equal to or greater than zero if S1 is |
| 95 | lexicographically less than, equal to or greater than S2. | 161 | lexicographically less than, equal to or greater than S2. |
| 96 | Note: This function cannot work correctly in multibyte locales. */ | 162 | Note: This function cannot work correctly in multibyte locales. */ |
| 97 | #if ! @HAVE_DECL_STRNCASECMP@ | 163 | # if @REPLACE_STRNCASECMP@ |
| 98 | extern int strncasecmp (char const *s1, char const *s2, size_t n) | 164 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 99 | _GL_ARG_NONNULL ((1, 2)); | 165 | # undef strncasecmp |
| 100 | #endif | 166 | # define strncasecmp rpl_strncasecmp |
| 101 | #if defined GNULIB_POSIXCHECK | 167 | # endif |
| 168 | _GL_FUNCDECL_RPL (strncasecmp, int, (const char *, const char *, size_t), | ||
| 169 | _GL_ARG_NONNULL ((1, 2))); | ||
| 170 | _GL_CXXALIAS_RPL (strncasecmp, int, (const char *, const char *, size_t)); | ||
| 171 | # else | ||
| 172 | # if !@HAVE_DECL_STRNCASECMP@ | ||
| 173 | _GL_FUNCDECL_SYS (strncasecmp, int, (const char *, const char *, size_t), | ||
| 174 | _GL_ARG_NONNULL ((1, 2))); | ||
| 175 | # endif | ||
| 176 | _GL_CXXALIAS_SYS (strncasecmp, int, (const char *, const char *, size_t)); | ||
| 177 | # endif | ||
| 178 | # if __GLIBC__ >= 2 | ||
| 179 | _GL_CXXALIASWARN (strncasecmp); | ||
| 180 | # endif | ||
| 181 | #elif defined GNULIB_POSIXCHECK | ||
| 102 | /* strncasecmp() does not work with multibyte strings: | 182 | /* strncasecmp() does not work with multibyte strings: |
| 103 | POSIX says that it operates on "strings", and "string" in POSIX is defined | 183 | POSIX says that it operates on "strings", and "string" in POSIX is defined |
| 104 | as a sequence of bytes, not of characters. */ | 184 | as a sequence of bytes, not of characters. */ |
| 105 | # undef strncasecmp | 185 | # undef strncasecmp |
| 106 | # if HAVE_RAW_DECL_STRNCASECMP | 186 | # if HAVE_RAW_DECL_STRNCASECMP |
| 107 | _GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character " | 187 | _GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character " |
| 108 | "strings in multibyte locales - " | 188 | "strings in multibyte locales and is unportable - " |
| 109 | "use mbsncasecmp or mbspcasecmp if you care about " | 189 | "use mbsncasecmp or mbspcasecmp if you care about " |
| 110 | "internationalization, or use c_strncasecmp , " | 190 | "internationalization, or use c_strncasecmp " |
| 111 | "gnulib module c-strcase) if you want a locale " | 191 | "(gnulib module c-strncasecmp) if you want a locale " |
| 112 | "independent function"); | 192 | "independent function"); |
| 113 | # endif | 193 | # endif |
| 114 | #endif | 194 | #endif |
| 115 | 195 | ||
| 196 | #if @GNULIB_STRNCASECMP_L@ | ||
| 197 | # if @REPLACE_STRNCASECMP_L@ | ||
| 198 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 199 | # undef strncasecmp_l | ||
| 200 | # define strncasecmp_l rpl_strncasecmp_l | ||
| 201 | # endif | ||
| 202 | _GL_FUNCDECL_RPL (strncasecmp_l, int, | ||
| 203 | (const char *s1, const char *s2, size_t n, locale_t locale), | ||
| 204 | _GL_ARG_NONNULL ((1, 2, 4))); | ||
| 205 | _GL_CXXALIAS_RPL (strncasecmp_l, int, | ||
| 206 | (const char *s1, const char *s2, size_t n, locale_t locale)); | ||
| 207 | # else | ||
| 208 | # if !@HAVE_STRNCASECMP_L@ | ||
| 209 | _GL_FUNCDECL_SYS (strncasecmp_l, int, | ||
| 210 | (const char *s1, const char *s2, size_t n, locale_t locale), | ||
| 211 | _GL_ARG_NONNULL ((1, 2, 4))); | ||
| 212 | # endif | ||
| 213 | _GL_CXXALIAS_SYS (strncasecmp_l, int, | ||
| 214 | (const char *s1, const char *s2, size_t n, locale_t locale)); | ||
| 215 | # endif | ||
| 216 | # if __GLIBC__ >= 2 | ||
| 217 | _GL_CXXALIASWARN (strncasecmp_l); | ||
| 218 | # endif | ||
| 219 | #elif defined GNULIB_POSIXCHECK | ||
| 220 | /* strncasecmp_l() does not work with multibyte strings: | ||
| 221 | POSIX says that it operates on "strings", and "string" in POSIX is defined | ||
| 222 | as a sequence of bytes, not of characters. */ | ||
| 223 | # undef strncasecmp_l | ||
| 224 | # if HAVE_RAW_DECL_STRNCASECMP_L | ||
| 225 | _GL_WARN_ON_USE (strncasecmp_l, "strncasecmp_l cannot work correctly on " | ||
| 226 | "character strings in multibyte locales and is unportable - " | ||
| 227 | "use gnulib module strncasecmp_l for portability"); | ||
| 228 | # endif | ||
| 229 | #endif | ||
| 230 | |||
| 116 | 231 | ||
| 117 | #ifdef __cplusplus | 232 | #ifdef __cplusplus |
| 118 | } | 233 | } |
