647903ad6a3f94a621203a58b4814667e58d523c
[gnulib.git] / lib / strings.in.h
1 /* A substitute <strings.h>.
2
3    Copyright (C) 2007-2011 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program 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 General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #ifndef _@GUARD_PREFIX@_STRINGS_H
20
21 #if __GNUC__ >= 3
22 @PRAGMA_SYSTEM_HEADER@
23 #endif
24 @PRAGMA_COLUMNS@
25
26 /* The include_next requires a split double-inclusion guard.  */
27 #@INCLUDE_NEXT@ @NEXT_STRINGS_H@
28
29 #ifndef _@GUARD_PREFIX@_STRINGS_H
30 #define _@GUARD_PREFIX@_STRINGS_H
31
32
33 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
34
35 /* The definition of _GL_ARG_NONNULL is copied here.  */
36
37 /* The definition of _GL_WARN_ON_USE is copied here.  */
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43
44   /* Find the index of the least-significant set bit.  */
45 #if @GNULIB_FFS@
46 # if !@HAVE_FFS@
47 _GL_FUNCDECL_SYS (ffs, int, (int i));
48 # endif
49 _GL_CXXALIAS_SYS (ffs, int, (int i));
50 _GL_CXXALIASWARN (ffs);
51 #elif defined GNULIB_POSIXCHECK
52 # undef ffs
53 # if HAVE_RAW_DECL_FFS
54 _GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
55 # endif
56 #endif
57
58 /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
59    greater than zero if S1 is lexicographically less than, equal to or greater
60    than S2.
61    Note: This function does not work in multibyte locales.  */
62 #if ! @HAVE_STRCASECMP@
63 extern int strcasecmp (char const *s1, char const *s2)
64      _GL_ARG_NONNULL ((1, 2));
65 #endif
66 #if defined GNULIB_POSIXCHECK
67 /* strcasecmp() does not work with multibyte strings:
68    POSIX says that it operates on "strings", and "string" in POSIX is defined
69    as a sequence of bytes, not of characters.   */
70 # undef strcasecmp
71 # if HAVE_RAW_DECL_STRCASECMP
72 _GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
73                  "strings in multibyte locales - "
74                  "use mbscasecmp if you care about "
75                  "internationalization, or use c_strcasecmp , "
76                  "gnulib module c-strcase) if you want a locale "
77                  "independent function");
78 # endif
79 #endif
80
81 /* Compare no more than N bytes of strings S1 and S2, ignoring case,
82    returning less than, equal to or greater than zero if S1 is
83    lexicographically less than, equal to or greater than S2.
84    Note: This function cannot work correctly in multibyte locales.  */
85 #if ! @HAVE_DECL_STRNCASECMP@
86 extern int strncasecmp (char const *s1, char const *s2, size_t n)
87      _GL_ARG_NONNULL ((1, 2));
88 #endif
89 #if defined GNULIB_POSIXCHECK
90 /* strncasecmp() does not work with multibyte strings:
91    POSIX says that it operates on "strings", and "string" in POSIX is defined
92    as a sequence of bytes, not of characters.  */
93 # undef strncasecmp
94 # if HAVE_RAW_DECL_STRNCASECMP
95 _GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
96                  "strings in multibyte locales - "
97                  "use mbsncasecmp or mbspcasecmp if you care about "
98                  "internationalization, or use c_strncasecmp , "
99                  "gnulib module c-strcase) if you want a locale "
100                  "independent function");
101 # endif
102 #endif
103
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif /* _@GUARD_PREFIX@_STRING_H */
110 #endif /* _@GUARD_PREFIX@_STRING_H */