1 /* A substitute <strings.h>.
3 Copyright (C) 2007-2024 Free Software Foundation, Inc.
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.
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.
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/>. */
18 #ifndef _@GUARD_PREFIX@_STRINGS_H
21 @PRAGMA_SYSTEM_HEADER@
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>
31 /* The include_next requires a split double-inclusion guard. */
33 # @INCLUDE_NEXT@ @NEXT_STRINGS_H@
36 #ifndef _@GUARD_PREFIX@_STRINGS_H
37 #define _@GUARD_PREFIX@_STRINGS_H
39 /* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
40 #if !_GL_CONFIG_H_INCLUDED
41 #error "Please include config.h first."
44 #if ! @HAVE_DECL_STRNCASECMP@
50 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
52 /* The definition of _GL_ARG_NONNULL is copied here. */
54 /* The definition of _GL_WARN_ON_USE is copied here. */
61 /* Find the index of the least-significant set bit. */
64 _GL_FUNCDECL_SYS (ffs
, int, (int i
));
66 _GL_CXXALIAS_SYS (ffs
, int, (int i
));
67 _GL_CXXALIASWARN (ffs
);
68 #elif defined GNULIB_POSIXCHECK
70 # if HAVE_RAW_DECL_FFS
71 _GL_WARN_ON_USE (ffs
, "ffs is not portable - use the ffs module");
75 /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
76 greater than zero if S1 is lexicographically less than, equal to or greater
78 Note: This function does not work in multibyte locales. */
79 #if ! @HAVE_STRCASECMP@
80 extern int strcasecmp (char const *s1
, char const *s2
)
81 _GL_ARG_NONNULL ((1, 2));
83 #if defined GNULIB_POSIXCHECK
84 /* strcasecmp() does not work with multibyte strings:
85 POSIX says that it operates on "strings", and "string" in POSIX is defined
86 as a sequence of bytes, not of characters. */
88 # if HAVE_RAW_DECL_STRCASECMP
89 _GL_WARN_ON_USE (strcasecmp
, "strcasecmp cannot work correctly on character "
90 "strings in multibyte locales - "
91 "use mbscasecmp if you care about "
92 "internationalization, or use c_strcasecmp , "
93 "gnulib module c-strcase) if you want a locale "
94 "independent function");
98 /* Compare no more than N bytes of strings S1 and S2, ignoring case,
99 returning less than, equal to or greater than zero if S1 is
100 lexicographically less than, equal to or greater than S2.
101 Note: This function cannot work correctly in multibyte locales. */
102 #if ! @HAVE_DECL_STRNCASECMP@
103 extern int strncasecmp (char const *s1
, char const *s2
, size_t n
)
104 _GL_ARG_NONNULL ((1, 2));
106 #if defined GNULIB_POSIXCHECK
107 /* strncasecmp() does not work with multibyte strings:
108 POSIX says that it operates on "strings", and "string" in POSIX is defined
109 as a sequence of bytes, not of characters. */
111 # if HAVE_RAW_DECL_STRNCASECMP
112 _GL_WARN_ON_USE (strncasecmp
, "strncasecmp cannot work correctly on character "
113 "strings in multibyte locales - "
114 "use mbsncasecmp or mbspcasecmp if you care about "
115 "internationalization, or use c_strncasecmp , "
116 "gnulib module c-strcase) if you want a locale "
117 "independent function");
126 #endif /* _@GUARD_PREFIX@_STRING_H */
127 #endif /* _@GUARD_PREFIX@_STRING_H */