Branch
Hash :
b2bf05b1
Author :
Date :
2025-02-16T22:32:33
strncasecmp_l: New module. * lib/strings.in.h (strncasecmp_l): New declaration. * lib/strncasecmp_l.c: New file, based on lib/strncasecmp.c. * m4/strncasecmp_l.m4: New file. * m4/strings_h.m4 (gl_STRINGS_H): Test for strncasecmp_l. (gl_STRINGS_H_REQUIRE_DEFAULTS): Initialize GNULIB_STRNCASECMP_L. (gl_STRINGS_H_DEFAULTS): Initialize HAVE_STRNCASECMP_L, REPLACE_STRNCASECMP_L. * modules/strings-h (Makefile.am): Substitute GNULIB_STRNCASECMP_L, HAVE_STRNCASECMP_L, REPLACE_STRNCASECMP_L. * modules/strncasecmp_l: New file. * tests/test-strings-h-c++.cc: Check declaration of strncasecmp_l. * doc/posix-functions/strncasecmp_l.texi: Mention the new module and the macOS, Solaris, Cygwin bugs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
/* A substitute <strings.h>.
Copyright (C) 2007-2025 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_STRINGS_H
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* Minix 3.1.8 has a bug: <sys/types.h> must be included before <strings.h>.
But avoid namespace pollution on glibc systems. */
#if defined __minix && !defined __GLIBC__
# include <sys/types.h>
#endif
/* The include_next requires a split double-inclusion guard. */
#if @HAVE_STRINGS_H@
# @INCLUDE_NEXT@ @NEXT_STRINGS_H@
#endif
#ifndef _@GUARD_PREFIX@_STRINGS_H
#define _@GUARD_PREFIX@_STRINGS_H
/* This file uses _GL_ARG_NONNULL, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
#if ! @HAVE_DECL_STRNCASECMP@
/* Get size_t. */
# include <stddef.h>
#endif
#if @GNULIB_STRCASECMP_L@ || @GNULIB_STRNCASECMP_L@
/* Get locale_t. */
# include <locale.h>
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ < 10) \
|| (defined __APPLE__ && defined __MACH__))
/* Get the declaration of strcasecmp_l. */
# include <string.h>
# endif
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
#ifdef __cplusplus
extern "C" {
#endif
#if @GNULIB_FFS@
/* Find the index of the least-significant set bit. */
# if !@HAVE_FFS@
_GL_FUNCDECL_SYS (ffs, int, (int i), );
# endif
_GL_CXXALIAS_SYS (ffs, int, (int i));
_GL_CXXALIASWARN (ffs);
#elif defined GNULIB_POSIXCHECK
# undef ffs
# if HAVE_RAW_DECL_FFS
_GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
# endif
#endif
#if @GNULIB_STRCASECMP@
/* 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 @REPLACE_STRCASECMP@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef strcasecmp
# define strcasecmp rpl_strcasecmp
# endif
_GL_FUNCDECL_RPL (strcasecmp, int, (const char *, const char *),
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (strcasecmp, int, (const char *, const char *));
# else
# if !@HAVE_STRCASECMP@
_GL_FUNCDECL_SYS (strcasecmp, int, (const char *, const char *),
_GL_ARG_NONNULL ((1, 2)));
# endif
_GL_CXXALIAS_SYS (strcasecmp, int, (const char *, const char *));
# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (strcasecmp);
# endif
#elif 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
# if HAVE_RAW_DECL_STRCASECMP
_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
"strings in multibyte locales and is unportable - "
"use mbscasecmp if you care about "
"internationalization, or use c_strcasecmp "
"(gnulib module c-strcasecmp) if you want a locale "
"independent function");
# endif
#endif
#if @GNULIB_STRCASECMP_L@
# if @REPLACE_STRCASECMP_L@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef strcasecmp_l
# define strcasecmp_l rpl_strcasecmp_l
# endif
_GL_FUNCDECL_RPL (strcasecmp_l, int,
(const char *s1, const char *s2, locale_t locale),
_GL_ARG_NONNULL ((1, 2, 3)));
_GL_CXXALIAS_RPL (strcasecmp_l, int,
(const char *s1, const char *s2, locale_t locale));
# else
# if !@HAVE_STRCASECMP_L@
_GL_FUNCDECL_SYS (strcasecmp_l, int,
(const char *s1, const char *s2, locale_t locale),
_GL_ARG_NONNULL ((1, 2, 3)));
# endif
_GL_CXXALIAS_SYS (strcasecmp_l, int,
(const char *s1, const char *s2, locale_t locale));
# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (strcasecmp_l);
# endif
#elif defined GNULIB_POSIXCHECK
/* strcasecmp_l() 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_l
# if HAVE_RAW_DECL_STRCASECMP_L
_GL_WARN_ON_USE (strcasecmp_l, "strcasecmp_l cannot work correctly on "
"character strings in multibyte locales and is unportable - "
"use gnulib module strcasecmp_l for portability");
# endif
#endif
#if @GNULIB_STRNCASECMP@
/* 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 @REPLACE_STRNCASECMP@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef strncasecmp
# define strncasecmp rpl_strncasecmp
# endif
_GL_FUNCDECL_RPL (strncasecmp, int, (const char *, const char *, size_t),
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (strncasecmp, int, (const char *, const char *, size_t));
# else
# if !@HAVE_DECL_STRNCASECMP@
_GL_FUNCDECL_SYS (strncasecmp, int, (const char *, const char *, size_t),
_GL_ARG_NONNULL ((1, 2)));
# endif
_GL_CXXALIAS_SYS (strncasecmp, int, (const char *, const char *, size_t));
# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (strncasecmp);
# endif
#elif 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
# if HAVE_RAW_DECL_STRNCASECMP
_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
"strings in multibyte locales and is unportable - "
"use mbsncasecmp or mbspcasecmp if you care about "
"internationalization, or use c_strncasecmp "
"(gnulib module c-strncasecmp) if you want a locale "
"independent function");
# endif
#endif
#if @GNULIB_STRNCASECMP_L@
# if @REPLACE_STRNCASECMP_L@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef strncasecmp_l
# define strncasecmp_l rpl_strncasecmp_l
# endif
_GL_FUNCDECL_RPL (strncasecmp_l, int,
(const char *s1, const char *s2, size_t n, locale_t locale),
_GL_ARG_NONNULL ((1, 2, 4)));
_GL_CXXALIAS_RPL (strncasecmp_l, int,
(const char *s1, const char *s2, size_t n, locale_t locale));
# else
# if !@HAVE_STRNCASECMP_L@
_GL_FUNCDECL_SYS (strncasecmp_l, int,
(const char *s1, const char *s2, size_t n, locale_t locale),
_GL_ARG_NONNULL ((1, 2, 4)));
# endif
_GL_CXXALIAS_SYS (strncasecmp_l, int,
(const char *s1, const char *s2, size_t n, locale_t locale));
# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (strncasecmp_l);
# endif
#elif defined GNULIB_POSIXCHECK
/* strncasecmp_l() 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_l
# if HAVE_RAW_DECL_STRNCASECMP_L
_GL_WARN_ON_USE (strncasecmp_l, "strncasecmp_l cannot work correctly on "
"character strings in multibyte locales and is unportable - "
"use gnulib module strncasecmp_l for portability");
# endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* _@GUARD_PREFIX@_STRING_H */
#endif /* _@GUARD_PREFIX@_STRING_H */