| 1 |
/* A substitute <strings.h>. |
| 2 |
|
| 3 |
Copyright (C) 2007-2026 Free Software Foundation, Inc. |
| 4 |
|
| 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 |
| 7 |
published by the Free Software Foundation; either version 2.1 of the |
| 8 |
License, or (at your option) any later version. |
| 9 |
|
| 10 |
This file is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU Lesser General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU Lesser General Public License |
| 16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 17 |
|
| 18 |
#ifndef _@GUARD_PREFIX@_STRINGS_H |
| 19 |
|
| 20 |
#if __GNUC__ >= 3 |
| 21 |
@PRAGMA_SYSTEM_HEADER@ |
| 22 |
#endif |
| 23 |
@PRAGMA_COLUMNS@ |
| 24 |
|
| 25 |
/* Minix 3.1.8 has a bug: <sys/types.h> must be included before <strings.h>. |
| 26 |
But avoid namespace pollution on glibc systems. */ |
| 27 |
#if defined __minix && !defined __GLIBC__ |
| 28 |
# include <sys/types.h> |
| 29 |
#endif |
| 30 |
|
| 31 |
/* The include_next requires a split double-inclusion guard. */ |
| 32 |
#if @HAVE_STRINGS_H@ |
| 33 |
# @INCLUDE_NEXT@ @NEXT_STRINGS_H@ |
| 34 |
#endif |
| 35 |
|
| 36 |
#ifndef _@GUARD_PREFIX@_STRINGS_H |
| 37 |
#define _@GUARD_PREFIX@_STRINGS_H |
| 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 |
|
| 44 |
#if ! @HAVE_DECL_STRNCASECMP@ |
| 45 |
/* Get size_t. */ |
| 46 |
# include <stddef.h> |
| 47 |
#endif |
| 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 |
|
| 59 |
|
| 60 |
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
| 61 |
|
| 62 |
/* The definition of _GL_ARG_NONNULL is copied here. */ |
| 63 |
|
| 64 |
/* The definition of _GL_WARN_ON_USE is copied here. */ |
| 65 |
|
| 66 |
#ifdef __cplusplus |
| 67 |
extern "C" { |
| 68 |
#endif |
| 69 |
|
| 70 |
|
| 71 |
#if @GNULIB_FFS@ |
| 72 |
/* Find the index of the least-significant set bit. */ |
| 73 |
# if !@HAVE_FFS@ |
| 74 |
_GL_FUNCDECL_SYS (ffs, int, (int i), ); |
| 75 |
# endif |
| 76 |
_GL_CXXALIAS_SYS (ffs, int, (int i)); |
| 77 |
_GL_CXXALIASWARN (ffs); |
| 78 |
#elif defined GNULIB_POSIXCHECK |
| 79 |
# if HAVE_RAW_DECL_FFS |
| 80 |
_GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module"); |
| 81 |
# endif |
| 82 |
#endif |
| 83 |
|
| 84 |
#if @GNULIB_STRCASECMP@ |
| 85 |
/* Compare strings S1 and S2, ignoring case, returning less than, equal to or |
| 86 |
greater than zero if S1 is lexicographically less than, equal to or greater |
| 87 |
than S2. |
| 88 |
Note: This function does not work in multibyte locales. */ |
| 89 |
# if @REPLACE_STRCASECMP@ |
| 90 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 91 |
# undef strcasecmp |
| 92 |
# define strcasecmp rpl_strcasecmp |
| 93 |
# endif |
| 94 |
_GL_FUNCDECL_RPL (strcasecmp, int, (const char *, const char *), |
| 95 |
_GL_ARG_NONNULL ((1, 2))); |
| 96 |
_GL_CXXALIAS_RPL (strcasecmp, int, (const char *, const char *)); |
| 97 |
# else |
| 98 |
# if !@HAVE_STRCASECMP@ |
| 99 |
_GL_FUNCDECL_SYS (strcasecmp, int, (const char *, const char *), |
| 100 |
_GL_ARG_NONNULL ((1, 2))); |
| 101 |
# endif |
| 102 |
_GL_CXXALIAS_SYS (strcasecmp, int, (const char *, const char *)); |
| 103 |
# endif |
| 104 |
# if __GLIBC__ >= 2 |
| 105 |
_GL_CXXALIASWARN (strcasecmp); |
| 106 |
# endif |
| 107 |
#elif defined GNULIB_POSIXCHECK |
| 108 |
/* strcasecmp() does not work with multibyte strings: |
| 109 |
POSIX says that it operates on "strings", and "string" in POSIX is defined |
| 110 |
as a sequence of bytes, not of characters. */ |
| 111 |
# if HAVE_RAW_DECL_STRCASECMP |
| 112 |
_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character " |
| 113 |
"strings in multibyte locales and is unportable - " |
| 114 |
"use mbscasecmp if you care about " |
| 115 |
"internationalization, or use c_strcasecmp " |
| 116 |
"(gnulib module c-strcasecmp) if you want a locale " |
| 117 |
"independent function"); |
| 118 |
# endif |
| 119 |
#endif |
| 120 |
|
| 121 |
#if @GNULIB_STRCASECMP_L@ |
| 122 |
# if @REPLACE_STRCASECMP_L@ |
| 123 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 124 |
# undef strcasecmp_l |
| 125 |
# define strcasecmp_l rpl_strcasecmp_l |
| 126 |
# endif |
| 127 |
_GL_FUNCDECL_RPL (strcasecmp_l, int, |
| 128 |
(const char *s1, const char *s2, locale_t locale), |
| 129 |
_GL_ARG_NONNULL ((1, 2, 3))); |
| 130 |
_GL_CXXALIAS_RPL (strcasecmp_l, int, |
| 131 |
(const char *s1, const char *s2, locale_t locale)); |
| 132 |
# else |
| 133 |
# if !@HAVE_STRCASECMP_L@ |
| 134 |
_GL_FUNCDECL_SYS (strcasecmp_l, int, |
| 135 |
(const char *s1, const char *s2, locale_t locale), |
| 136 |
_GL_ARG_NONNULL ((1, 2, 3))); |
| 137 |
# endif |
| 138 |
_GL_CXXALIAS_SYS (strcasecmp_l, int, |
| 139 |
(const char *s1, const char *s2, locale_t locale)); |
| 140 |
# endif |
| 141 |
# if __GLIBC__ >= 2 |
| 142 |
_GL_CXXALIASWARN (strcasecmp_l); |
| 143 |
# endif |
| 144 |
#elif defined GNULIB_POSIXCHECK |
| 145 |
/* strcasecmp_l() does not work with multibyte strings: |
| 146 |
POSIX says that it operates on "strings", and "string" in POSIX is defined |
| 147 |
as a sequence of bytes, not of characters. */ |
| 148 |
# if HAVE_RAW_DECL_STRCASECMP_L |
| 149 |
_GL_WARN_ON_USE (strcasecmp_l, "strcasecmp_l cannot work correctly on " |
| 150 |
"character strings in multibyte locales and is unportable - " |
| 151 |
"use gnulib module strcasecmp_l for portability"); |
| 152 |
# endif |
| 153 |
#endif |
| 154 |
|
| 155 |
#if @GNULIB_STRNCASECMP@ |
| 156 |
/* Compare no more than N bytes of strings S1 and S2, ignoring case, |
| 157 |
returning less than, equal to or greater than zero if S1 is |
| 158 |
lexicographically less than, equal to or greater than S2. |
| 159 |
Note: This function cannot work correctly in multibyte locales. */ |
| 160 |
# if @REPLACE_STRNCASECMP@ |
| 161 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 162 |
# undef strncasecmp |
| 163 |
# define strncasecmp rpl_strncasecmp |
| 164 |
# endif |
| 165 |
_GL_FUNCDECL_RPL (strncasecmp, int, (const char *, const char *, size_t), |
| 166 |
_GL_ARG_NONNULL ((1, 2))); |
| 167 |
_GL_CXXALIAS_RPL (strncasecmp, int, (const char *, const char *, size_t)); |
| 168 |
# else |
| 169 |
# if !@HAVE_DECL_STRNCASECMP@ |
| 170 |
_GL_FUNCDECL_SYS (strncasecmp, int, (const char *, const char *, size_t), |
| 171 |
_GL_ARG_NONNULL ((1, 2))); |
| 172 |
# endif |
| 173 |
_GL_CXXALIAS_SYS (strncasecmp, int, (const char *, const char *, size_t)); |
| 174 |
# endif |
| 175 |
# if __GLIBC__ >= 2 |
| 176 |
_GL_CXXALIASWARN (strncasecmp); |
| 177 |
# endif |
| 178 |
#elif defined GNULIB_POSIXCHECK |
| 179 |
/* strncasecmp() does not work with multibyte strings: |
| 180 |
POSIX says that it operates on "strings", and "string" in POSIX is defined |
| 181 |
as a sequence of bytes, not of characters. */ |
| 182 |
# if HAVE_RAW_DECL_STRNCASECMP |
| 183 |
_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character " |
| 184 |
"strings in multibyte locales and is unportable - " |
| 185 |
"use mbsncasecmp or mbspcasecmp if you care about " |
| 186 |
"internationalization, or use c_strncasecmp " |
| 187 |
"(gnulib module c-strncasecmp) if you want a locale " |
| 188 |
"independent function"); |
| 189 |
# endif |
| 190 |
#endif |
| 191 |
|
| 192 |
#if @GNULIB_STRNCASECMP_L@ |
| 193 |
# if @REPLACE_STRNCASECMP_L@ |
| 194 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 195 |
# undef strncasecmp_l |
| 196 |
# define strncasecmp_l rpl_strncasecmp_l |
| 197 |
# endif |
| 198 |
_GL_FUNCDECL_RPL (strncasecmp_l, int, |
| 199 |
(const char *s1, const char *s2, size_t n, locale_t locale), |
| 200 |
_GL_ARG_NONNULL ((1, 2, 4))); |
| 201 |
_GL_CXXALIAS_RPL (strncasecmp_l, int, |
| 202 |
(const char *s1, const char *s2, size_t n, locale_t locale)); |
| 203 |
# else |
| 204 |
# if !@HAVE_STRNCASECMP_L@ |
| 205 |
_GL_FUNCDECL_SYS (strncasecmp_l, int, |
| 206 |
(const char *s1, const char *s2, size_t n, locale_t locale), |
| 207 |
_GL_ARG_NONNULL ((1, 2, 4))); |
| 208 |
# endif |
| 209 |
_GL_CXXALIAS_SYS (strncasecmp_l, int, |
| 210 |
(const char *s1, const char *s2, size_t n, locale_t locale)); |
| 211 |
# endif |
| 212 |
# if __GLIBC__ >= 2 |
| 213 |
_GL_CXXALIASWARN (strncasecmp_l); |
| 214 |
# endif |
| 215 |
#elif defined GNULIB_POSIXCHECK |
| 216 |
/* strncasecmp_l() does not work with multibyte strings: |
| 217 |
POSIX says that it operates on "strings", and "string" in POSIX is defined |
| 218 |
as a sequence of bytes, not of characters. */ |
| 219 |
# if HAVE_RAW_DECL_STRNCASECMP_L |
| 220 |
_GL_WARN_ON_USE (strncasecmp_l, "strncasecmp_l cannot work correctly on " |
| 221 |
"character strings in multibyte locales and is unportable - " |
| 222 |
"use gnulib module strncasecmp_l for portability"); |
| 223 |
# endif |
| 224 |
#endif |
| 225 |
|
| 226 |
|
| 227 |
#ifdef __cplusplus |
| 228 |
} |
| 229 |
#endif |
| 230 |
|
| 231 |
#endif /* _@GUARD_PREFIX@_STRING_H */ |
| 232 |
#endif /* _@GUARD_PREFIX@_STRING_H */ |