Mercurial > hg > octave-shane > gnulib-hg
annotate lib/string.in.h @ 16201:8250f2777afc
maint: update all copyright year number ranges
Run "make update-copyright".
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Sun, 01 Jan 2012 10:04:58 +0100 |
parents | 4e3a37b1ceae |
children | bb182ee4a09d |
rev | line source |
---|---|
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* A GNU-like <string.h>. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
15428
diff
changeset
|
3 Copyright (C) 1995-1996, 2001-2012 Free Software Foundation, Inc. |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 This program is free software; you can redistribute it and/or modify |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 the Free Software Foundation; either version 2, or (at your option) |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 any later version. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 along with this program; if not, write to the Free Software Foundation, |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
14840
5f709022a256
Allow multiple gnulib generated include files to be combined.
Bruno Haible <bruno@clisp.org>
parents:
14828
diff
changeset
|
19 #ifndef _@GUARD_PREFIX@_STRING_H |
13094
2ed0fc659db8
Emit #pragma system_header after the inclusion guard, not before.
Bruno Haible <bruno@clisp.org>
parents:
13055
diff
changeset
|
20 |
10655
8668b19a7032
Avoid gcc warnings because of #pragma GCC system_header on older gcc.
Bruno Haible <bruno@clisp.org>
parents:
10456
diff
changeset
|
21 #if __GNUC__ >= 3 |
10375
f96e845fc36d
Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents:
10345
diff
changeset
|
22 @PRAGMA_SYSTEM_HEADER@ |
10655
8668b19a7032
Avoid gcc warnings because of #pragma GCC system_header on older gcc.
Bruno Haible <bruno@clisp.org>
parents:
10456
diff
changeset
|
23 #endif |
13761
a19ace3ba849
Avoid line length limitation from HP NonStop system header files.
Bruno Haible <bruno@clisp.org>
parents:
13661
diff
changeset
|
24 @PRAGMA_COLUMNS@ |
10375
f96e845fc36d
Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents:
10345
diff
changeset
|
25 |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 /* The include_next requires a split double-inclusion guard. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 #@INCLUDE_NEXT@ @NEXT_STRING_H@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 |
14840
5f709022a256
Allow multiple gnulib generated include files to be combined.
Bruno Haible <bruno@clisp.org>
parents:
14828
diff
changeset
|
29 #ifndef _@GUARD_PREFIX@_STRING_H |
5f709022a256
Allow multiple gnulib generated include files to be combined.
Bruno Haible <bruno@clisp.org>
parents:
14828
diff
changeset
|
30 #define _@GUARD_PREFIX@_STRING_H |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 |
11832
ff3dd373542b
stddef: fix NetBSD 5.0 NULL bug, rather than working around it
Eric Blake <ebb9@byu.net>
parents:
11624
diff
changeset
|
32 /* NetBSD 5.0 mis-defines NULL. */ |
ff3dd373542b
stddef: fix NetBSD 5.0 NULL bug, rather than working around it
Eric Blake <ebb9@byu.net>
parents:
11624
diff
changeset
|
33 #include <stddef.h> |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 |
12602
e6c17971ef92
mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
35 /* MirBSD defines mbslen as a macro. */ |
e6c17971ef92
mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
36 #if @GNULIB_MBSLEN@ && defined __MirBSD__ |
e6c17971ef92
mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
37 # include <wchar.h> |
e6c17971ef92
mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
38 #endif |
e6c17971ef92
mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
39 |
14343
8e4360837451
Don't interfere with a program's definition of __attribute__.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
40 /* The __attribute__ feature is available in gcc versions 2.5 and later. |
8e4360837451
Don't interfere with a program's definition of __attribute__.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
41 The attribute __pure__ was added in gcc 2.96. */ |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
42 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) |
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
43 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) |
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
44 #else |
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
45 # define _GL_ATTRIBUTE_PURE /* empty */ |
9590
246fc6fd3787
Give gcc some memmem optimization hints.
Eric Blake <ebb9@byu.net>
parents:
9538
diff
changeset
|
46 #endif |
246fc6fd3787
Give gcc some memmem optimization hints.
Eric Blake <ebb9@byu.net>
parents:
9538
diff
changeset
|
47 |
13661
e1c46598fd57
strsignal: work around NetBSD bug
Eric Blake <eblake@redhat.com>
parents:
13628
diff
changeset
|
48 /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ |
13773
d06d8f66d2bd
string, sys_select: Avoid #including large headers unless necessary.
Bruno Haible <bruno@clisp.org>
parents:
13761
diff
changeset
|
49 /* But in any case avoid namespace pollution on glibc systems. */ |
d06d8f66d2bd
string, sys_select: Avoid #including large headers unless necessary.
Bruno Haible <bruno@clisp.org>
parents:
13761
diff
changeset
|
50 #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ |
13661
e1c46598fd57
strsignal: work around NetBSD bug
Eric Blake <eblake@redhat.com>
parents:
13628
diff
changeset
|
51 && ! defined __GLIBC__ |
e1c46598fd57
strsignal: work around NetBSD bug
Eric Blake <eblake@redhat.com>
parents:
13628
diff
changeset
|
52 # include <unistd.h> |
e1c46598fd57
strsignal: work around NetBSD bug
Eric Blake <eblake@redhat.com>
parents:
13628
diff
changeset
|
53 #endif |
9590
246fc6fd3787
Give gcc some memmem optimization hints.
Eric Blake <ebb9@byu.net>
parents:
9538
diff
changeset
|
54 |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
55 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
56 |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
57 /* The definition of _GL_ARG_NONNULL is copied here. */ |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
59 /* The definition of _GL_WARN_ON_USE is copied here. */ |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
60 |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 |
15428 | 62 /* Find the index of the least-significant set bit. */ |
63 #if @GNULIB_FFSL@ | |
64 # if !@HAVE_FFSL@ | |
65 _GL_FUNCDECL_SYS (ffsl, int, (long int i)); | |
66 # endif | |
67 _GL_CXXALIAS_SYS (ffsl, int, (long int i)); | |
68 _GL_CXXALIASWARN (ffsl); | |
69 #elif defined GNULIB_POSIXCHECK | |
70 # undef ffsl | |
71 # if HAVE_RAW_DECL_FFSL | |
72 _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); | |
73 # endif | |
74 #endif | |
75 | |
76 | |
77 /* Find the index of the least-significant set bit. */ | |
78 #if @GNULIB_FFSLL@ | |
79 # if !@HAVE_FFSLL@ | |
80 _GL_FUNCDECL_SYS (ffsll, int, (long long int i)); | |
81 # endif | |
82 _GL_CXXALIAS_SYS (ffsll, int, (long long int i)); | |
83 _GL_CXXALIASWARN (ffsll); | |
84 #elif defined GNULIB_POSIXCHECK | |
85 # undef ffsll | |
86 # if HAVE_RAW_DECL_FFSLL | |
87 _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); | |
88 # endif | |
89 #endif | |
90 | |
91 | |
11621
c98fca1ff8b8
memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents:
10655
diff
changeset
|
92 /* Return the first instance of C within N bytes of S, or NULL. */ |
c98fca1ff8b8
memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents:
10655
diff
changeset
|
93 #if @GNULIB_MEMCHR@ |
c98fca1ff8b8
memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents:
10655
diff
changeset
|
94 # if @REPLACE_MEMCHR@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
95 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
96 # define memchr rpl_memchr |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
97 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
98 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
99 _GL_ATTRIBUTE_PURE |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
100 _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
101 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
102 # else |
13161
c4c537d4c2f0
memchr: Avoid a possible C++ test error.
Bruno Haible <bruno@clisp.org>
parents:
13119
diff
changeset
|
103 # if ! @HAVE_MEMCHR@ |
c4c537d4c2f0
memchr: Avoid a possible C++ test error.
Bruno Haible <bruno@clisp.org>
parents:
13119
diff
changeset
|
104 _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
105 _GL_ATTRIBUTE_PURE |
13161
c4c537d4c2f0
memchr: Avoid a possible C++ test error.
Bruno Haible <bruno@clisp.org>
parents:
13119
diff
changeset
|
106 _GL_ARG_NONNULL ((1))); |
c4c537d4c2f0
memchr: Avoid a possible C++ test error.
Bruno Haible <bruno@clisp.org>
parents:
13119
diff
changeset
|
107 # endif |
12980
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
108 /* On some systems, this function is defined as an overloaded function: |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
109 extern "C" { const void * std::memchr (const void *, int, size_t); } |
12980
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
110 extern "C++" { void * std::memchr (void *, int, size_t); } */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
111 _GL_CXXALIAS_SYS_CAST2 (memchr, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
112 void *, (void const *__s, int __c, size_t __n), |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
113 void const *, (void const *__s, int __c, size_t __n)); |
11621
c98fca1ff8b8
memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents:
10655
diff
changeset
|
114 # endif |
13885 | 115 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
116 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
117 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
118 _GL_CXXALIASWARN1 (memchr, void const *, |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
119 (void const *__s, int __c, size_t __n)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
120 # else |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
121 _GL_CXXALIASWARN (memchr); |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
122 # endif |
11621
c98fca1ff8b8
memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents:
10655
diff
changeset
|
123 #elif defined GNULIB_POSIXCHECK |
c98fca1ff8b8
memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents:
10655
diff
changeset
|
124 # undef memchr |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
125 /* Assume memchr is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
126 _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
127 "use gnulib module memchr for portability" ); |
11621
c98fca1ff8b8
memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents:
10655
diff
changeset
|
128 #endif |
c98fca1ff8b8
memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents:
10655
diff
changeset
|
129 |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
130 /* Return the first occurrence of NEEDLE in HAYSTACK. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
131 #if @GNULIB_MEMMEM@ |
9538
43d9769bf4d0
Fix memmem to avoid O(n^2) worst-case complexity.
Eric Blake <ebb9@byu.net>
parents:
9496
diff
changeset
|
132 # if @REPLACE_MEMMEM@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
133 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
134 # define memmem rpl_memmem |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
135 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
136 _GL_FUNCDECL_RPL (memmem, void *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
137 (void const *__haystack, size_t __haystack_len, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
138 void const *__needle, size_t __needle_len) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
139 _GL_ATTRIBUTE_PURE |
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
140 _GL_ARG_NONNULL ((1, 3))); |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
141 _GL_CXXALIAS_RPL (memmem, void *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
142 (void const *__haystack, size_t __haystack_len, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
143 void const *__needle, size_t __needle_len)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
144 # else |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
145 # if ! @HAVE_DECL_MEMMEM@ |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
146 _GL_FUNCDECL_SYS (memmem, void *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
147 (void const *__haystack, size_t __haystack_len, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
148 void const *__needle, size_t __needle_len) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
149 _GL_ATTRIBUTE_PURE |
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
150 _GL_ARG_NONNULL ((1, 3))); |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
151 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
152 _GL_CXXALIAS_SYS (memmem, void *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
153 (void const *__haystack, size_t __haystack_len, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
154 void const *__needle, size_t __needle_len)); |
9538
43d9769bf4d0
Fix memmem to avoid O(n^2) worst-case complexity.
Eric Blake <ebb9@byu.net>
parents:
9496
diff
changeset
|
155 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
156 _GL_CXXALIASWARN (memmem); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
157 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
158 # undef memmem |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
159 # if HAVE_RAW_DECL_MEMMEM |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
160 _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
161 "use gnulib module memmem-simple for portability, " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
162 "and module memmem for speed" ); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
163 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
164 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
165 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
166 /* Copy N bytes of SRC to DEST, return pointer to bytes after the |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
167 last written byte. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
168 #if @GNULIB_MEMPCPY@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
169 # if ! @HAVE_MEMPCPY@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
170 _GL_FUNCDECL_SYS (mempcpy, void *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
171 (void *restrict __dest, void const *restrict __src, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
172 size_t __n) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
173 _GL_ARG_NONNULL ((1, 2))); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
174 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
175 _GL_CXXALIAS_SYS (mempcpy, void *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
176 (void *restrict __dest, void const *restrict __src, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
177 size_t __n)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
178 _GL_CXXALIASWARN (mempcpy); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
179 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
180 # undef mempcpy |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
181 # if HAVE_RAW_DECL_MEMPCPY |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
182 _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
183 "use gnulib module mempcpy for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
184 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
185 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
186 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
187 /* Search backwards through a block for a byte (specified as an int). */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
188 #if @GNULIB_MEMRCHR@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
189 # if ! @HAVE_DECL_MEMRCHR@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
190 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
191 _GL_ATTRIBUTE_PURE |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
192 _GL_ARG_NONNULL ((1))); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
193 # endif |
12980
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
194 /* On some systems, this function is defined as an overloaded function: |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
195 extern "C++" { const void * std::memrchr (const void *, int, size_t); } |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
196 extern "C++" { void * std::memrchr (void *, int, size_t); } */ |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
197 _GL_CXXALIAS_SYS_CAST2 (memrchr, |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
198 void *, (void const *, int, size_t), |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
199 void const *, (void const *, int, size_t)); |
13885 | 200 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
201 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
202 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
203 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
204 # else |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
205 _GL_CXXALIASWARN (memrchr); |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
206 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
207 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
208 # undef memrchr |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
209 # if HAVE_RAW_DECL_MEMRCHR |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
210 _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
211 "use gnulib module memrchr for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
212 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
213 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
214 |
9999
5f559abfabef
Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents:
9623
diff
changeset
|
215 /* Find the first occurrence of C in S. More efficient than |
5f559abfabef
Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents:
9623
diff
changeset
|
216 memchr(S,C,N), at the expense of undefined behavior if C does not |
5f559abfabef
Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents:
9623
diff
changeset
|
217 occur within N bytes. */ |
5f559abfabef
Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents:
9623
diff
changeset
|
218 #if @GNULIB_RAWMEMCHR@ |
5f559abfabef
Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents:
9623
diff
changeset
|
219 # if ! @HAVE_RAWMEMCHR@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
220 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
221 _GL_ATTRIBUTE_PURE |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
222 _GL_ARG_NONNULL ((1))); |
9999
5f559abfabef
Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents:
9623
diff
changeset
|
223 # endif |
12980
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
224 /* On some systems, this function is defined as an overloaded function: |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
225 extern "C++" { const void * std::rawmemchr (const void *, int); } |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
226 extern "C++" { void * std::rawmemchr (void *, int); } */ |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
227 _GL_CXXALIAS_SYS_CAST2 (rawmemchr, |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
228 void *, (void const *__s, int __c_in), |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
229 void const *, (void const *__s, int __c_in)); |
13885 | 230 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
231 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
232 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
233 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
234 # else |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
235 _GL_CXXALIASWARN (rawmemchr); |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
236 # endif |
9999
5f559abfabef
Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents:
9623
diff
changeset
|
237 #elif defined GNULIB_POSIXCHECK |
5f559abfabef
Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents:
9623
diff
changeset
|
238 # undef rawmemchr |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
239 # if HAVE_RAW_DECL_RAWMEMCHR |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
240 _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
241 "use gnulib module rawmemchr for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
242 # endif |
9999
5f559abfabef
Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents:
9623
diff
changeset
|
243 #endif |
5f559abfabef
Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents:
9623
diff
changeset
|
244 |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
245 /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
246 #if @GNULIB_STPCPY@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
247 # if ! @HAVE_STPCPY@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
248 _GL_FUNCDECL_SYS (stpcpy, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
249 (char *restrict __dst, char const *restrict __src) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
250 _GL_ARG_NONNULL ((1, 2))); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
251 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
252 _GL_CXXALIAS_SYS (stpcpy, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
253 (char *restrict __dst, char const *restrict __src)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
254 _GL_CXXALIASWARN (stpcpy); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
255 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
256 # undef stpcpy |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
257 # if HAVE_RAW_DECL_STPCPY |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
258 _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
259 "use gnulib module stpcpy for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
260 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
261 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
262 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
263 /* Copy no more than N bytes of SRC to DST, returning a pointer past the |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
264 last non-NUL byte written into DST. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
265 #if @GNULIB_STPNCPY@ |
13119
5fa4ec4a6e8b
stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
13094
diff
changeset
|
266 # if @REPLACE_STPNCPY@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
267 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
13558
263949fe34ae
stpncpy: Allow stpncpy to be defined as a macro.
Bruno Haible <bruno@clisp.org>
parents:
13478
diff
changeset
|
268 # undef stpncpy |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
269 # define stpncpy rpl_stpncpy |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
270 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
271 _GL_FUNCDECL_RPL (stpncpy, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
272 (char *restrict __dst, char const *restrict __src, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
273 size_t __n) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
274 _GL_ARG_NONNULL ((1, 2))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
275 _GL_CXXALIAS_RPL (stpncpy, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
276 (char *restrict __dst, char const *restrict __src, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
277 size_t __n)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
278 # else |
13119
5fa4ec4a6e8b
stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
13094
diff
changeset
|
279 # if ! @HAVE_STPNCPY@ |
5fa4ec4a6e8b
stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
13094
diff
changeset
|
280 _GL_FUNCDECL_SYS (stpncpy, char *, |
5fa4ec4a6e8b
stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
13094
diff
changeset
|
281 (char *restrict __dst, char const *restrict __src, |
5fa4ec4a6e8b
stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
13094
diff
changeset
|
282 size_t __n) |
5fa4ec4a6e8b
stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
13094
diff
changeset
|
283 _GL_ARG_NONNULL ((1, 2))); |
5fa4ec4a6e8b
stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
13094
diff
changeset
|
284 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
285 _GL_CXXALIAS_SYS (stpncpy, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
286 (char *restrict __dst, char const *restrict __src, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
287 size_t __n)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
288 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
289 _GL_CXXALIASWARN (stpncpy); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
290 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
291 # undef stpncpy |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
292 # if HAVE_RAW_DECL_STPNCPY |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
293 _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
294 "use gnulib module stpncpy for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
295 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
296 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
297 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
298 #if defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
299 /* strchr() does not work with multibyte strings if the locale encoding is |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
300 GB18030 and the character to be searched is a digit. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
301 # undef strchr |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
302 /* Assume strchr is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
303 _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
304 "in some multibyte locales - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
305 "use mbschr if you care about internationalization"); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
306 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
307 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
308 /* Find the first occurrence of C in S or the final NUL byte. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
309 #if @GNULIB_STRCHRNUL@ |
14585
1eab1082a832
strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents:
14343
diff
changeset
|
310 # if @REPLACE_STRCHRNUL@ |
1eab1082a832
strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents:
14343
diff
changeset
|
311 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
1eab1082a832
strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents:
14343
diff
changeset
|
312 # define strchrnul rpl_strchrnul |
1eab1082a832
strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents:
14343
diff
changeset
|
313 # endif |
14586
e60c0a94bedd
strchrnul: Tweak last commit.
Bruno Haible <bruno@clisp.org>
parents:
14585
diff
changeset
|
314 _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) |
e60c0a94bedd
strchrnul: Tweak last commit.
Bruno Haible <bruno@clisp.org>
parents:
14585
diff
changeset
|
315 _GL_ATTRIBUTE_PURE |
e60c0a94bedd
strchrnul: Tweak last commit.
Bruno Haible <bruno@clisp.org>
parents:
14585
diff
changeset
|
316 _GL_ARG_NONNULL ((1))); |
14585
1eab1082a832
strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents:
14343
diff
changeset
|
317 _GL_CXXALIAS_RPL (strchrnul, char *, |
1eab1082a832
strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents:
14343
diff
changeset
|
318 (const char *str, int ch)); |
1eab1082a832
strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents:
14343
diff
changeset
|
319 # else |
1eab1082a832
strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents:
14343
diff
changeset
|
320 # if ! @HAVE_STRCHRNUL@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
321 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
322 _GL_ATTRIBUTE_PURE |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
323 _GL_ARG_NONNULL ((1))); |
14585
1eab1082a832
strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents:
14343
diff
changeset
|
324 # endif |
12980
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
325 /* On some systems, this function is defined as an overloaded function: |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
326 extern "C++" { const char * std::strchrnul (const char *, int); } |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
327 extern "C++" { char * std::strchrnul (char *, int); } */ |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
328 _GL_CXXALIAS_SYS_CAST2 (strchrnul, |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
329 char *, (char const *__s, int __c_in), |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
330 char const *, (char const *__s, int __c_in)); |
14585
1eab1082a832
strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents:
14343
diff
changeset
|
331 # endif |
13885 | 332 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
333 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
334 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
335 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
336 # else |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
337 _GL_CXXALIASWARN (strchrnul); |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
338 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
339 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
340 # undef strchrnul |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
341 # if HAVE_RAW_DECL_STRCHRNUL |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
342 _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
343 "use gnulib module strchrnul for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
344 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
345 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
346 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
347 /* Duplicate S, returning an identical malloc'd string. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
348 #if @GNULIB_STRDUP@ |
10456
a821fdd7b2b7
New module 'strdup-posix'.
Bruno Haible <bruno@clisp.org>
parents:
10375
diff
changeset
|
349 # if @REPLACE_STRDUP@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
350 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
351 # undef strdup |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
352 # define strdup rpl_strdup |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
353 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
354 _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
355 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
356 # else |
13628
b8b731ae72a8
strdup: Fix compilation error in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
13558
diff
changeset
|
357 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup |
b8b731ae72a8
strdup: Fix compilation error in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
13558
diff
changeset
|
358 /* strdup exists as a function and as a macro. Get rid of the macro. */ |
b8b731ae72a8
strdup: Fix compilation error in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
13558
diff
changeset
|
359 # undef strdup |
b8b731ae72a8
strdup: Fix compilation error in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
13558
diff
changeset
|
360 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
361 # if !(@HAVE_DECL_STRDUP@ || defined strdup) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
362 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
363 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
364 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); |
10456
a821fdd7b2b7
New module 'strdup-posix'.
Bruno Haible <bruno@clisp.org>
parents:
10375
diff
changeset
|
365 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
366 _GL_CXXALIASWARN (strdup); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
367 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
368 # undef strdup |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
369 # if HAVE_RAW_DECL_STRDUP |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
370 _GL_WARN_ON_USE (strdup, "strdup is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
371 "use gnulib module strdup for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
372 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
373 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
374 |
13175 | 375 /* Append no more than N characters from SRC onto DEST. */ |
376 #if @GNULIB_STRNCAT@ | |
377 # if @REPLACE_STRNCAT@ | |
378 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
379 # undef strncat | |
380 # define strncat rpl_strncat | |
381 # endif | |
382 _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) | |
383 _GL_ARG_NONNULL ((1, 2))); | |
384 _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); | |
385 # else | |
386 _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); | |
387 # endif | |
388 _GL_CXXALIASWARN (strncat); | |
389 #elif defined GNULIB_POSIXCHECK | |
390 # undef strncat | |
391 # if HAVE_RAW_DECL_STRNCAT | |
392 _GL_WARN_ON_USE (strncat, "strncat is unportable - " | |
393 "use gnulib module strncat for portability"); | |
394 # endif | |
395 #endif | |
396 | |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
397 /* Return a newly allocated copy of at most N bytes of STRING. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
398 #if @GNULIB_STRNDUP@ |
11983
5f256f637c47
strndup: fix improper m4 caching
Eric Blake <ebb9@byu.net>
parents:
11960
diff
changeset
|
399 # if @REPLACE_STRNDUP@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
400 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
401 # undef strndup |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
402 # define strndup rpl_strndup |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
403 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
404 _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
405 _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
406 _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
407 # else |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
408 # if ! @HAVE_DECL_STRNDUP@ |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
409 _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
410 _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
411 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
412 _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
413 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
414 _GL_CXXALIASWARN (strndup); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
415 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
416 # undef strndup |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
417 # if HAVE_RAW_DECL_STRNDUP |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
418 _GL_WARN_ON_USE (strndup, "strndup is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
419 "use gnulib module strndup for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
420 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
421 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
422 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
423 /* Find the length (number of bytes) of STRING, but scan at most |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
424 MAXLEN bytes. If no '\0' terminator is found in that many bytes, |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
425 return MAXLEN. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
426 #if @GNULIB_STRNLEN@ |
13194
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
427 # if @REPLACE_STRNLEN@ |
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
428 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
429 # undef strnlen |
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
430 # define strnlen rpl_strnlen |
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
431 # endif |
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
432 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
433 _GL_ATTRIBUTE_PURE |
13194
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
434 _GL_ARG_NONNULL ((1))); |
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
435 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); |
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
436 # else |
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
437 # if ! @HAVE_DECL_STRNLEN@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
438 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
439 _GL_ATTRIBUTE_PURE |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
440 _GL_ARG_NONNULL ((1))); |
13194
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
441 # endif |
5aec4f35399f
strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
13175
diff
changeset
|
442 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
443 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
444 _GL_CXXALIASWARN (strnlen); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
445 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
446 # undef strnlen |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
447 # if HAVE_RAW_DECL_STRNLEN |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
448 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
449 "use gnulib module strnlen for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
450 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
451 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
452 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
453 #if defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
454 /* strcspn() assumes the second argument is a list of single-byte characters. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
455 Even in this simple case, it does not work with multibyte strings if the |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
456 locale encoding is GB18030 and one of the characters to be searched is a |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
457 digit. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
458 # undef strcspn |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
459 /* Assume strcspn is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
460 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
461 "in multibyte locales - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
462 "use mbscspn if you care about internationalization"); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
463 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
464 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
465 /* Find the first occurrence in S of any character in ACCEPT. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
466 #if @GNULIB_STRPBRK@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
467 # if ! @HAVE_STRPBRK@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
468 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
469 _GL_ATTRIBUTE_PURE |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
470 _GL_ARG_NONNULL ((1, 2))); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
471 # endif |
12980
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
472 /* On some systems, this function is defined as an overloaded function: |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
473 extern "C" { const char * strpbrk (const char *, const char *); } |
12980
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
474 extern "C++" { char * strpbrk (char *, const char *); } */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
475 _GL_CXXALIAS_SYS_CAST2 (strpbrk, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
476 char *, (char const *__s, char const *__accept), |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
477 const char *, (char const *__s, char const *__accept)); |
13885 | 478 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
479 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
480 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
481 _GL_CXXALIASWARN1 (strpbrk, char const *, |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
482 (char const *__s, char const *__accept)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
483 # else |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
484 _GL_CXXALIASWARN (strpbrk); |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
485 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
486 # if defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
487 /* strpbrk() assumes the second argument is a list of single-byte characters. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
488 Even in this simple case, it does not work with multibyte strings if the |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
489 locale encoding is GB18030 and one of the characters to be searched is a |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
490 digit. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
491 # undef strpbrk |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
492 _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
493 "in multibyte locales - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
494 "use mbspbrk if you care about internationalization"); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
495 # endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
496 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
497 # undef strpbrk |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
498 # if HAVE_RAW_DECL_STRPBRK |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
499 _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
500 "use gnulib module strpbrk for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
501 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
502 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
503 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
504 #if defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
505 /* strspn() assumes the second argument is a list of single-byte characters. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
506 Even in this simple case, it cannot work with multibyte strings. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
507 # undef strspn |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
508 /* Assume strspn is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
509 _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
510 "in multibyte locales - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
511 "use mbsspn if you care about internationalization"); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
512 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
513 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
514 #if defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
515 /* strrchr() does not work with multibyte strings if the locale encoding is |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
516 GB18030 and the character to be searched is a digit. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
517 # undef strrchr |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
518 /* Assume strrchr is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
519 _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
520 "in some multibyte locales - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
521 "use mbsrchr if you care about internationalization"); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
522 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
523 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
524 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
525 If one is found, overwrite it with a NUL, and advance *STRINGP |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
526 to point to the next char after it. Otherwise, set *STRINGP to NULL. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
527 If *STRINGP was already NULL, nothing happens. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
528 Return the old value of *STRINGP. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
529 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
530 This is a variant of strtok() that is multithread-safe and supports |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
531 empty fields. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
532 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
533 Caveat: It modifies the original string. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
534 Caveat: These functions cannot be used on constant strings. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
535 Caveat: The identity of the delimiting character is lost. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
536 Caveat: It doesn't work with multibyte strings unless all of the delimiter |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
537 characters are ASCII characters < 0x30. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
538 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
539 See also strtok_r(). */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
540 #if @GNULIB_STRSEP@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
541 # if ! @HAVE_STRSEP@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
542 _GL_FUNCDECL_SYS (strsep, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
543 (char **restrict __stringp, char const *restrict __delim) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
544 _GL_ARG_NONNULL ((1, 2))); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
545 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
546 _GL_CXXALIAS_SYS (strsep, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
547 (char **restrict __stringp, char const *restrict __delim)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
548 _GL_CXXALIASWARN (strsep); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
549 # if defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
550 # undef strsep |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
551 _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
552 "in multibyte locales - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
553 "use mbssep if you care about internationalization"); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
554 # endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
555 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
556 # undef strsep |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
557 # if HAVE_RAW_DECL_STRSEP |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
558 _GL_WARN_ON_USE (strsep, "strsep is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
559 "use gnulib module strsep for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
560 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
561 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
562 |
9600
99268e709d31
Avoid quadratic strstr implementations.
Eric Blake <ebb9@byu.net>
parents:
9590
diff
changeset
|
563 #if @GNULIB_STRSTR@ |
99268e709d31
Avoid quadratic strstr implementations.
Eric Blake <ebb9@byu.net>
parents:
9590
diff
changeset
|
564 # if @REPLACE_STRSTR@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
565 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
566 # define strstr rpl_strstr |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
567 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
568 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
569 _GL_ATTRIBUTE_PURE |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
570 _GL_ARG_NONNULL ((1, 2))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
571 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
572 # else |
12980
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
573 /* On some systems, this function is defined as an overloaded function: |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
574 extern "C++" { const char * strstr (const char *, const char *); } |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
575 extern "C++" { char * strstr (char *, const char *); } */ |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
576 _GL_CXXALIAS_SYS_CAST2 (strstr, |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
577 char *, (const char *haystack, const char *needle), |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
578 const char *, (const char *haystack, const char *needle)); |
9600
99268e709d31
Avoid quadratic strstr implementations.
Eric Blake <ebb9@byu.net>
parents:
9590
diff
changeset
|
579 # endif |
13885 | 580 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
581 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
582 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
583 _GL_CXXALIASWARN1 (strstr, const char *, |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
584 (const char *haystack, const char *needle)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
585 # else |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
586 _GL_CXXALIASWARN (strstr); |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
587 # endif |
9600
99268e709d31
Avoid quadratic strstr implementations.
Eric Blake <ebb9@byu.net>
parents:
9590
diff
changeset
|
588 #elif defined GNULIB_POSIXCHECK |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
589 /* strstr() does not work with multibyte strings if the locale encoding is |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
590 different from UTF-8: |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
591 POSIX says that it operates on "strings", and "string" in POSIX is defined |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
592 as a sequence of bytes, not of characters. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
593 # undef strstr |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
594 /* Assume strstr is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
595 _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
596 "work correctly on character strings in most " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
597 "multibyte locales - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
598 "use mbsstr if you care about internationalization, " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
599 "or use strstr if you care about speed"); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
600 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
601 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
602 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
603 comparison. */ |
9623
69d9307c0aa0
Convert strcasestr module to use Two-Way algorithm.
Eric Blake <ebb9@byu.net>
parents:
9622
diff
changeset
|
604 #if @GNULIB_STRCASESTR@ |
69d9307c0aa0
Convert strcasestr module to use Two-Way algorithm.
Eric Blake <ebb9@byu.net>
parents:
9622
diff
changeset
|
605 # if @REPLACE_STRCASESTR@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
606 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
607 # define strcasestr rpl_strcasestr |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
608 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
609 _GL_FUNCDECL_RPL (strcasestr, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
610 (const char *haystack, const char *needle) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
611 _GL_ATTRIBUTE_PURE |
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
612 _GL_ARG_NONNULL ((1, 2))); |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
613 _GL_CXXALIAS_RPL (strcasestr, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
614 (const char *haystack, const char *needle)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
615 # else |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
616 # if ! @HAVE_STRCASESTR@ |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
617 _GL_FUNCDECL_SYS (strcasestr, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
618 (const char *haystack, const char *needle) |
13443
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
619 _GL_ATTRIBUTE_PURE |
6c32722a9d4b
string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents:
13194
diff
changeset
|
620 _GL_ARG_NONNULL ((1, 2))); |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
621 # endif |
12980
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
622 /* On some systems, this function is defined as an overloaded function: |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
623 extern "C++" { const char * strcasestr (const char *, const char *); } |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
624 extern "C++" { char * strcasestr (char *, const char *); } */ |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
625 _GL_CXXALIAS_SYS_CAST2 (strcasestr, |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
626 char *, (const char *haystack, const char *needle), |
a9cefa7a8404
Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents:
12942
diff
changeset
|
627 const char *, (const char *haystack, const char *needle)); |
9623
69d9307c0aa0
Convert strcasestr module to use Two-Way algorithm.
Eric Blake <ebb9@byu.net>
parents:
9622
diff
changeset
|
628 # endif |
13885 | 629 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
630 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
631 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
632 _GL_CXXALIASWARN1 (strcasestr, const char *, |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
633 (const char *haystack, const char *needle)); |
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
634 # else |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
635 _GL_CXXALIASWARN (strcasestr); |
12984
e9d0fdd4293b
Fix compilation error with glibc >= 2.10 and g++ >= 4.4.
Bruno Haible <bruno@clisp.org>
parents:
12980
diff
changeset
|
636 # endif |
9623
69d9307c0aa0
Convert strcasestr module to use Two-Way algorithm.
Eric Blake <ebb9@byu.net>
parents:
9622
diff
changeset
|
637 #elif defined GNULIB_POSIXCHECK |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
638 /* strcasestr() does not work with multibyte strings: |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
639 It is a glibc extension, and glibc implements it only for unibyte |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
640 locales. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
641 # undef strcasestr |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
642 # if HAVE_RAW_DECL_STRCASESTR |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
643 _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
644 "strings in multibyte locales - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
645 "use mbscasestr if you care about " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
646 "internationalization, or use c-strcasestr if you want " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
647 "a locale independent function"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
648 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
649 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
650 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
651 /* Parse S into tokens separated by characters in DELIM. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
652 If S is NULL, the saved pointer in SAVE_PTR is used as |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
653 the next starting point. For example: |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
654 char s[] = "-abc-=-def"; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
655 char *sp; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
656 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
657 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
658 x = strtok_r(NULL, "=", &sp); // x = NULL |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
659 // s = "abc\0-def\0" |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
660 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
661 This is a variant of strtok() that is multithread-safe. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
662 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
663 For the POSIX documentation for this function, see: |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
664 http://www.opengroup.org/susv3xsh/strtok.html |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
665 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
666 Caveat: It modifies the original string. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
667 Caveat: These functions cannot be used on constant strings. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
668 Caveat: The identity of the delimiting character is lost. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
669 Caveat: It doesn't work with multibyte strings unless all of the delimiter |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
670 characters are ASCII characters < 0x30. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
671 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
672 See also strsep(). */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
673 #if @GNULIB_STRTOK_R@ |
11960
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11832
diff
changeset
|
674 # if @REPLACE_STRTOK_R@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
675 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
676 # undef strtok_r |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
677 # define strtok_r rpl_strtok_r |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
678 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
679 _GL_FUNCDECL_RPL (strtok_r, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
680 (char *restrict s, char const *restrict delim, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
681 char **restrict save_ptr) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
682 _GL_ARG_NONNULL ((2, 3))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
683 _GL_CXXALIAS_RPL (strtok_r, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
684 (char *restrict s, char const *restrict delim, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
685 char **restrict save_ptr)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
686 # else |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
687 # if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
688 # undef strtok_r |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
689 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
690 # if ! @HAVE_DECL_STRTOK_R@ |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
691 _GL_FUNCDECL_SYS (strtok_r, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
692 (char *restrict s, char const *restrict delim, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
693 char **restrict save_ptr) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
694 _GL_ARG_NONNULL ((2, 3))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
695 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
696 _GL_CXXALIAS_SYS (strtok_r, char *, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
697 (char *restrict s, char const *restrict delim, |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
698 char **restrict save_ptr)); |
11960
bc6846876d71
Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents:
11832
diff
changeset
|
699 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
700 _GL_CXXALIASWARN (strtok_r); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
701 # if defined GNULIB_POSIXCHECK |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
702 _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
703 "strings in multibyte locales - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
704 "use mbstok_r if you care about internationalization"); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
705 # endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
706 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
707 # undef strtok_r |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
708 # if HAVE_RAW_DECL_STRTOK_R |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
709 _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
710 "use gnulib module strtok_r for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
711 # endif |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
712 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
713 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
714 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
715 /* The following functions are not specified by POSIX. They are gnulib |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
716 extensions. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
717 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
718 #if @GNULIB_MBSLEN@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
719 /* Return the number of multibyte characters in the character string STRING. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
720 This considers multibyte characters, unlike strlen, which counts bytes. */ |
12602
e6c17971ef92
mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
721 # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ |
e6c17971ef92
mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
722 # undef mbslen |
e6c17971ef92
mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
723 # endif |
e6c17971ef92
mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
724 # if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
725 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
726 # define mbslen rpl_mbslen |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
727 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
728 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
729 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
730 # else |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
731 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
732 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); |
12602
e6c17971ef92
mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
733 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
734 _GL_CXXALIASWARN (mbslen); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
735 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
736 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
737 #if @GNULIB_MBSNLEN@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
738 /* Return the number of multibyte characters in the character string starting |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
739 at STRING and ending at STRING + LEN. */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
740 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
741 _GL_ARG_NONNULL ((1)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
742 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
743 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
744 #if @GNULIB_MBSCHR@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
745 /* Locate the first single-byte character C in the character string STRING, |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
746 and return a pointer to it. Return NULL if C is not found in STRING. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
747 Unlike strchr(), this function works correctly in multibyte locales with |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
748 encodings such as GB18030. */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
749 # if defined __hpux |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
750 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
751 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
752 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
753 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
754 _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
755 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
756 # else |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
757 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
758 _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
759 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
760 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
761 _GL_CXXALIASWARN (mbschr); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
762 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
763 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
764 #if @GNULIB_MBSRCHR@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
765 /* Locate the last single-byte character C in the character string STRING, |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
766 and return a pointer to it. Return NULL if C is not found in STRING. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
767 Unlike strrchr(), this function works correctly in multibyte locales with |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
768 encodings such as GB18030. */ |
14828
90514fe74451
mbsrchr: Avoid collision with system function on Interix.
Bruno Haible <bruno@clisp.org>
parents:
14586
diff
changeset
|
769 # if defined __hpux || defined __INTERIX |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
770 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
14828
90514fe74451
mbsrchr: Avoid collision with system function on Interix.
Bruno Haible <bruno@clisp.org>
parents:
14586
diff
changeset
|
771 # define mbsrchr rpl_mbsrchr /* avoid collision with system function */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
772 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
773 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
774 _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
775 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
776 # else |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
777 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
778 _GL_ARG_NONNULL ((1))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
779 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
780 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
781 _GL_CXXALIASWARN (mbsrchr); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
782 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
783 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
784 #if @GNULIB_MBSSTR@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
785 /* Find the first occurrence of the character string NEEDLE in the character |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
786 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
787 Unlike strstr(), this function works correctly in multibyte locales with |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
788 encodings different from UTF-8. */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
789 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
790 _GL_ARG_NONNULL ((1, 2)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
791 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
792 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
793 #if @GNULIB_MBSCASECMP@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
794 /* Compare the character strings S1 and S2, ignoring case, returning less than, |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
795 equal to or greater than zero if S1 is lexicographically less than, equal to |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
796 or greater than S2. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
797 Note: This function may, in multibyte locales, return 0 for strings of |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
798 different lengths! |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
799 Unlike strcasecmp(), this function works correctly in multibyte locales. */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
800 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
801 _GL_ARG_NONNULL ((1, 2)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
802 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
803 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
804 #if @GNULIB_MBSNCASECMP@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
805 /* Compare the initial segment of the character string S1 consisting of at most |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
806 N characters with the initial segment of the character string S2 consisting |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
807 of at most N characters, ignoring case, returning less than, equal to or |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
808 greater than zero if the initial segment of S1 is lexicographically less |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
809 than, equal to or greater than the initial segment of S2. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
810 Note: This function may, in multibyte locales, return 0 for initial segments |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
811 of different lengths! |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
812 Unlike strncasecmp(), this function works correctly in multibyte locales. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
813 But beware that N is not a byte count but a character count! */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
814 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
815 _GL_ARG_NONNULL ((1, 2)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
816 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
817 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
818 #if @GNULIB_MBSPCASECMP@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
819 /* Compare the initial segment of the character string STRING consisting of |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
820 at most mbslen (PREFIX) characters with the character string PREFIX, |
13478
957a79f455ba
mbspcasecmp: Fix function specification.
Bruno Haible <bruno@clisp.org>
parents:
13443
diff
changeset
|
821 ignoring case. If the two match, return a pointer to the first byte |
957a79f455ba
mbspcasecmp: Fix function specification.
Bruno Haible <bruno@clisp.org>
parents:
13443
diff
changeset
|
822 after this prefix in STRING. Otherwise, return NULL. |
957a79f455ba
mbspcasecmp: Fix function specification.
Bruno Haible <bruno@clisp.org>
parents:
13443
diff
changeset
|
823 Note: This function may, in multibyte locales, return non-NULL if STRING |
957a79f455ba
mbspcasecmp: Fix function specification.
Bruno Haible <bruno@clisp.org>
parents:
13443
diff
changeset
|
824 is of smaller length than PREFIX! |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
825 Unlike strncasecmp(), this function works correctly in multibyte |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
826 locales. */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
827 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
828 _GL_ARG_NONNULL ((1, 2)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
829 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
830 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
831 #if @GNULIB_MBSCASESTR@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
832 /* Find the first occurrence of the character string NEEDLE in the character |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
833 string HAYSTACK, using case-insensitive comparison. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
834 Note: This function may, in multibyte locales, return success even if |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
835 strlen (haystack) < strlen (needle) ! |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
836 Unlike strcasestr(), this function works correctly in multibyte locales. */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
837 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
838 _GL_ARG_NONNULL ((1, 2)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
839 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
840 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
841 #if @GNULIB_MBSCSPN@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
842 /* Find the first occurrence in the character string STRING of any character |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
843 in the character string ACCEPT. Return the number of bytes from the |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
844 beginning of the string to this occurrence, or to the end of the string |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
845 if none exists. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
846 Unlike strcspn(), this function works correctly in multibyte locales. */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
847 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
848 _GL_ARG_NONNULL ((1, 2)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
849 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
850 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
851 #if @GNULIB_MBSPBRK@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
852 /* Find the first occurrence in the character string STRING of any character |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
853 in the character string ACCEPT. Return the pointer to it, or NULL if none |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
854 exists. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
855 Unlike strpbrk(), this function works correctly in multibyte locales. */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
856 # if defined __hpux |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
857 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
858 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
859 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
860 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
861 _GL_ARG_NONNULL ((1, 2))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
862 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
863 # else |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
864 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
865 _GL_ARG_NONNULL ((1, 2))); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
866 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
867 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
868 _GL_CXXALIASWARN (mbspbrk); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
869 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
870 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
871 #if @GNULIB_MBSSPN@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
872 /* Find the first occurrence in the character string STRING of any character |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
873 not in the character string REJECT. Return the number of bytes from the |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
874 beginning of the string to this occurrence, or to the end of the string |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
875 if none exists. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
876 Unlike strspn(), this function works correctly in multibyte locales. */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
877 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
878 _GL_ARG_NONNULL ((1, 2)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
879 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
880 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
881 #if @GNULIB_MBSSEP@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
882 /* Search the next delimiter (multibyte character listed in the character |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
883 string DELIM) starting at the character string *STRINGP. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
884 If one is found, overwrite it with a NUL, and advance *STRINGP to point |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
885 to the next multibyte character after it. Otherwise, set *STRINGP to NULL. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
886 If *STRINGP was already NULL, nothing happens. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
887 Return the old value of *STRINGP. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
888 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
889 This is a variant of mbstok_r() that supports empty fields. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
890 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
891 Caveat: It modifies the original string. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
892 Caveat: These functions cannot be used on constant strings. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
893 Caveat: The identity of the delimiting character is lost. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
894 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
895 See also mbstok_r(). */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
896 _GL_EXTERN_C char * mbssep (char **stringp, const char *delim) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
897 _GL_ARG_NONNULL ((1, 2)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
898 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
899 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
900 #if @GNULIB_MBSTOK_R@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
901 /* Parse the character string STRING into tokens separated by characters in |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
902 the character string DELIM. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
903 If STRING is NULL, the saved pointer in SAVE_PTR is used as |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
904 the next starting point. For example: |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
905 char s[] = "-abc-=-def"; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
906 char *sp; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
907 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
908 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
909 x = mbstok_r(NULL, "=", &sp); // x = NULL |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11983
diff
changeset
|
910 // s = "abc\0-def\0" |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
911 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
912 Caveat: It modifies the original string. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
913 Caveat: These functions cannot be used on constant strings. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
914 Caveat: The identity of the delimiting character is lost. |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
915 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
916 See also mbssep(). */ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
917 _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
918 _GL_ARG_NONNULL ((2, 3)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
919 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
920 |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
921 /* Map any int, typically from errno, into an error message. */ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
922 #if @GNULIB_STRERROR@ |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
923 # if @REPLACE_STRERROR@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
924 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
925 # undef strerror |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
926 # define strerror rpl_strerror |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
927 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
928 _GL_FUNCDECL_RPL (strerror, char *, (int)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
929 _GL_CXXALIAS_RPL (strerror, char *, (int)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
930 # else |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
931 _GL_CXXALIAS_SYS (strerror, char *, (int)); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
932 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
933 _GL_CXXALIASWARN (strerror); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
934 #elif defined GNULIB_POSIXCHECK |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
935 # undef strerror |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
936 /* Assume strerror is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
937 _GL_WARN_ON_USE (strerror, "strerror is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
938 "use gnulib module strerror to guarantee non-NULL result"); |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
939 #endif |
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
940 |
13847
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
941 /* Map any int, typically from errno, into an error message. Multithread-safe. |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
942 Uses the POSIX declaration, not the glibc declaration. */ |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
943 #if @GNULIB_STRERROR_R@ |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
944 # if @REPLACE_STRERROR_R@ |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
945 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
946 # undef strerror_r |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
947 # define strerror_r rpl_strerror_r |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
948 # endif |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
949 _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
950 _GL_ARG_NONNULL ((2))); |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
951 _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
952 # else |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
953 # if !@HAVE_DECL_STRERROR_R@ |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
954 _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
955 _GL_ARG_NONNULL ((2))); |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
956 # endif |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
957 _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
958 # endif |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
959 # if @HAVE_DECL_STRERROR_R@ |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
960 _GL_CXXALIASWARN (strerror_r); |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
961 # endif |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
962 #elif defined GNULIB_POSIXCHECK |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
963 # undef strerror_r |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
964 # if HAVE_RAW_DECL_STRERROR_R |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
965 _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
966 "use gnulib module strerror_r-posix for portability"); |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
967 # endif |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
968 #endif |
99dd2b4fab8b
New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents:
13773
diff
changeset
|
969 |
9616
878f41b0e41e
New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
9613
diff
changeset
|
970 #if @GNULIB_STRSIGNAL@ |
9622
7b32838d1079
Replace strsignal if it does not work fine.
Bruno Haible <bruno@clisp.org>
parents:
9616
diff
changeset
|
971 # if @REPLACE_STRSIGNAL@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
972 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
973 # define strsignal rpl_strsignal |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
974 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
975 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
976 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
977 # else |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
978 # if ! @HAVE_DECL_STRSIGNAL@ |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
979 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
980 # endif |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
981 /* Need to cast, because on Cygwin 1.5.x systems, the return type is |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
982 'const char *'. */ |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
983 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); |
9622
7b32838d1079
Replace strsignal if it does not work fine.
Bruno Haible <bruno@clisp.org>
parents:
9616
diff
changeset
|
984 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
985 _GL_CXXALIASWARN (strsignal); |
9616
878f41b0e41e
New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
9613
diff
changeset
|
986 #elif defined GNULIB_POSIXCHECK |
878f41b0e41e
New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
9613
diff
changeset
|
987 # undef strsignal |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
988 # if HAVE_RAW_DECL_STRSIGNAL |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
989 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
990 "use gnulib module strsignal for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
991 # endif |
9616
878f41b0e41e
New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
9613
diff
changeset
|
992 #endif |
878f41b0e41e
New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
9613
diff
changeset
|
993 |
10345
8d80c477e0ad
strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents:
9999
diff
changeset
|
994 #if @GNULIB_STRVERSCMP@ |
8d80c477e0ad
strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents:
9999
diff
changeset
|
995 # if !@HAVE_STRVERSCMP@ |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
996 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
997 _GL_ARG_NONNULL ((1, 2))); |
10345
8d80c477e0ad
strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents:
9999
diff
changeset
|
998 # endif |
12942
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
999 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); |
17ee1f140456
string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
1000 _GL_CXXALIASWARN (strverscmp); |
10345
8d80c477e0ad
strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents:
9999
diff
changeset
|
1001 #elif defined GNULIB_POSIXCHECK |
8d80c477e0ad
strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents:
9999
diff
changeset
|
1002 # undef strverscmp |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
1003 # if HAVE_RAW_DECL_STRVERSCMP |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
1004 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
1005 "use gnulib module strverscmp for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12602
diff
changeset
|
1006 # endif |
10345
8d80c477e0ad
strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents:
9999
diff
changeset
|
1007 #endif |
8d80c477e0ad
strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents:
9999
diff
changeset
|
1008 |
9264
a1355710e330
Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1009 |
14840
5f709022a256
Allow multiple gnulib generated include files to be combined.
Bruno Haible <bruno@clisp.org>
parents:
14828
diff
changeset
|
1010 #endif /* _@GUARD_PREFIX@_STRING_H */ |
5f709022a256
Allow multiple gnulib generated include files to be combined.
Bruno Haible <bruno@clisp.org>
parents:
14828
diff
changeset
|
1011 #endif /* _@GUARD_PREFIX@_STRING_H */ |