annotate lib/string.in.h @ 14840:5f709022a256

Allow multiple gnulib generated include files to be combined. * gnulib-tool (func_compute_include_guard_prefix): New function. (func_emit_lib_Makefile_am, func_emit_tests_Makefile_am): Resolve also ${gl_include_guard_prefix} references. (func_import, func_create_testdir): Invoke func_compute_include_guard_prefix. * lib/arpa_inet.in.h: Use the @GUARD_PREFIX@ placeholder. * lib/ctype.in.h: Likewise. * lib/dirent.in.h: Likewise. * lib/errno.in.h: Likewise. * lib/fcntl.in.h: Likewise. * lib/float.in.h: Likewise. * lib/getopt.in.h: Likewise. * lib/iconv.in.h: Likewise. * lib/langinfo.in.h: Likewise. * lib/locale.in.h: Likewise. * lib/math.in.h: Likewise. * lib/netdb.in.h: Likewise. * lib/netinet_in.in.h: Likewise. * lib/poll.in.h: Likewise. * lib/pthread.in.h: Likewise. * lib/pty.in.h: Likewise. * lib/sched.in.h: Likewise. * lib/se-selinux.in.h: Likewise. * lib/search.in.h: Likewise. * lib/signal.in.h: Likewise. * lib/spawn.in.h: Likewise. * lib/stdarg.in.h: Likewise. * lib/stddef.in.h: Likewise. * lib/stdint.in.h: Likewise. * lib/stdio.in.h: Likewise. * lib/stdlib.in.h: Likewise. * lib/string.in.h: Likewise. * lib/strings.in.h: Likewise. * lib/sys_file.in.h: Likewise. * lib/sys_ioctl.in.h: Likewise. * lib/sys_select.in.h: Likewise. * lib/sys_socket.in.h: Likewise. * lib/sys_stat.in.h: Likewise. * lib/sys_time.in.h: Likewise. * lib/sys_times.in.h: Likewise. * lib/sys_uio.in.h: Likewise. * lib/sys_utsname.in.h: Likewise. * lib/sys_wait.in.h: Likewise. * lib/sysexits.in.h: Likewise. * lib/termios.in.h: Likewise. * lib/time.in.h: Likewise. * lib/unistd.in.h: Likewise. * lib/wchar.in.h: Likewise. * lib/wctype.in.h: Likewise. * modules/arpa_inet (Makefile.am): Substitute @GUARD_PREFIX@. * modules/ctype (Makefile.am): Likewise. * modules/dirent (Makefile.am): Likewise. * modules/errno (Makefile.am): Likewise. * modules/fcntl-h (Makefile.am): Likewise. * modules/float (Makefile.am): Likewise. * modules/getopt-posix (Makefile.am): Likewise. * modules/iconv-h (Makefile.am): Likewise. * modules/langinfo (Makefile.am): Likewise. * modules/locale (Makefile.am): Likewise. * modules/math (Makefile.am): Likewise. * modules/netdb (Makefile.am): Likewise. * modules/netinet_in (Makefile.am): Likewise. * modules/poll-h (Makefile.am): Likewise. * modules/pthread (Makefile.am): Likewise. * modules/pty (Makefile.am): Likewise. * modules/sched (Makefile.am): Likewise. * modules/search (Makefile.am): Likewise. * modules/selinux-h (Makefile.am): Likewise. * modules/signal (Makefile.am): Likewise. * modules/spawn (Makefile.am): Likewise. * modules/stdarg (Makefile.am): Likewise. * modules/stddef (Makefile.am): Likewise. * modules/stdint (Makefile.am): Likewise. * modules/stdio (Makefile.am): Likewise. * modules/stdlib (Makefile.am): Likewise. * modules/string (Makefile.am): Likewise. * modules/strings (Makefile.am): Likewise. * modules/sys_file (Makefile.am): Likewise. * modules/sys_ioctl (Makefile.am): Likewise. * modules/sys_select (Makefile.am): Likewise. * modules/sys_socket (Makefile.am): Likewise. * modules/sys_stat (Makefile.am): Likewise. * modules/sys_time (Makefile.am): Likewise. * modules/sys_times (Makefile.am): Likewise. * modules/sys_uio (Makefile.am): Likewise. * modules/sys_utsname (Makefile.am): Likewise. * modules/sys_wait (Makefile.am): Likewise. * modules/sysexits (Makefile.am): Likewise. * modules/termios (Makefile.am): Likewise. * modules/time (Makefile.am): Likewise. * modules/unistd (Makefile.am): Likewise. * modules/wchar (Makefile.am): Likewise. * modules/wctype-h (Makefile.am): Likewise. * modules/assert-h (Makefile.am): Replace _GL_VERIFY_H specially.
author Bruno Haible <bruno@clisp.org>
date Sun, 29 May 2011 15:44:42 +0200
parents 90514fe74451
children 4e3a37b1ceae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
14079
97fc9a21a8fb maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents: 13885
diff changeset
3 Copyright (C) 1995-1996, 2001-2011 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
11621
c98fca1ff8b8 memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents: 10655
diff changeset
62 /* 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
63 #if @GNULIB_MEMCHR@
c98fca1ff8b8 memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents: 10655
diff changeset
64 # if @REPLACE_MEMCHR@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
65 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
66 # define memchr rpl_memchr
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
67 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
68 _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
69 _GL_ATTRIBUTE_PURE
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
70 _GL_ARG_NONNULL ((1)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
71 _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
72 # else
13161
c4c537d4c2f0 memchr: Avoid a possible C++ test error.
Bruno Haible <bruno@clisp.org>
parents: 13119
diff changeset
73 # if ! @HAVE_MEMCHR@
c4c537d4c2f0 memchr: Avoid a possible C++ test error.
Bruno Haible <bruno@clisp.org>
parents: 13119
diff changeset
74 _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
75 _GL_ATTRIBUTE_PURE
13161
c4c537d4c2f0 memchr: Avoid a possible C++ test error.
Bruno Haible <bruno@clisp.org>
parents: 13119
diff changeset
76 _GL_ARG_NONNULL ((1)));
c4c537d4c2f0 memchr: Avoid a possible C++ test error.
Bruno Haible <bruno@clisp.org>
parents: 13119
diff changeset
77 # endif
12980
a9cefa7a8404 Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents: 12942
diff changeset
78 /* 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
79 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
80 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
81 _GL_CXXALIAS_SYS_CAST2 (memchr,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
82 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
83 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
84 # endif
13885
87a95303747f Port to uClibc.
Bruno Haible <bruno@clisp.org>
parents: 13847
diff changeset
85 # 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
86 && (__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
87 _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
88 _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
89 (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
90 # else
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
91 _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
92 # endif
11621
c98fca1ff8b8 memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents: 10655
diff changeset
93 #elif defined GNULIB_POSIXCHECK
c98fca1ff8b8 memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents: 10655
diff changeset
94 # undef memchr
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
95 /* Assume memchr is always declared. */
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
96 _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
97 "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
98 #endif
c98fca1ff8b8 memchr: detect broken x86_64 and alpha implementations
Eric Blake <ebb9@byu.net>
parents: 10655
diff changeset
99
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 /* Return the first occurrence of NEEDLE in HAYSTACK. */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 #if @GNULIB_MEMMEM@
9538
43d9769bf4d0 Fix memmem to avoid O(n^2) worst-case complexity.
Eric Blake <ebb9@byu.net>
parents: 9496
diff changeset
102 # if @REPLACE_MEMMEM@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
103 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
104 # define memmem rpl_memmem
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
105 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
106 _GL_FUNCDECL_RPL (memmem, void *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
107 (void const *__haystack, size_t __haystack_len,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
108 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
109 _GL_ATTRIBUTE_PURE
6c32722a9d4b string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents: 13194
diff changeset
110 _GL_ARG_NONNULL ((1, 3)));
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
111 _GL_CXXALIAS_RPL (memmem, void *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
112 (void const *__haystack, size_t __haystack_len,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
113 void const *__needle, size_t __needle_len));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
114 # else
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
115 # if ! @HAVE_DECL_MEMMEM@
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
116 _GL_FUNCDECL_SYS (memmem, void *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
117 (void const *__haystack, size_t __haystack_len,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
118 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
119 _GL_ATTRIBUTE_PURE
6c32722a9d4b string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents: 13194
diff changeset
120 _GL_ARG_NONNULL ((1, 3)));
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
121 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
122 _GL_CXXALIAS_SYS (memmem, void *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
123 (void const *__haystack, size_t __haystack_len,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
124 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
125 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
126 _GL_CXXALIASWARN (memmem);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 # undef memmem
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
129 # if HAVE_RAW_DECL_MEMMEM
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
130 _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
131 "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
132 "and module memmem for speed" );
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
133 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 /* 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
137 last written byte. */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 #if @GNULIB_MEMPCPY@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 # if ! @HAVE_MEMPCPY@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
140 _GL_FUNCDECL_SYS (mempcpy, void *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
141 (void *restrict __dest, void const *restrict __src,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
142 size_t __n)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
143 _GL_ARG_NONNULL ((1, 2)));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
145 _GL_CXXALIAS_SYS (mempcpy, void *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
146 (void *restrict __dest, void const *restrict __src,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
147 size_t __n));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
148 _GL_CXXALIASWARN (mempcpy);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 # undef mempcpy
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
151 # if HAVE_RAW_DECL_MEMPCPY
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
152 _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
153 "use gnulib module mempcpy for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
154 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 /* 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
158 #if @GNULIB_MEMRCHR@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 # if ! @HAVE_DECL_MEMRCHR@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
160 _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
161 _GL_ATTRIBUTE_PURE
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
162 _GL_ARG_NONNULL ((1)));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 # endif
12980
a9cefa7a8404 Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents: 12942
diff changeset
164 /* 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
165 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
166 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
167 _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
168 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
169 void const *, (void const *, int, size_t));
13885
87a95303747f Port to uClibc.
Bruno Haible <bruno@clisp.org>
parents: 13847
diff changeset
170 # 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
171 && (__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
172 _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
173 _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
174 # else
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
175 _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
176 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
178 # undef memrchr
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
179 # if HAVE_RAW_DECL_MEMRCHR
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
180 _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
181 "use gnulib module memrchr for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
182 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
183 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184
9999
5f559abfabef Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents: 9623
diff changeset
185 /* 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
186 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
187 occur within N bytes. */
5f559abfabef Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents: 9623
diff changeset
188 #if @GNULIB_RAWMEMCHR@
5f559abfabef Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents: 9623
diff changeset
189 # if ! @HAVE_RAWMEMCHR@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
190 _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
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)));
9999
5f559abfabef Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents: 9623
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::rawmemchr (const void *, int); }
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::rawmemchr (void *, int); } */
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 (rawmemchr,
a9cefa7a8404 Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents: 12942
diff changeset
198 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
199 void const *, (void const *__s, int __c_in));
13885
87a95303747f Port to uClibc.
Bruno Haible <bruno@clisp.org>
parents: 13847
diff changeset
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 (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
203 _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
204 # else
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
205 _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
206 # endif
9999
5f559abfabef Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents: 9623
diff changeset
207 #elif defined GNULIB_POSIXCHECK
5f559abfabef Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents: 9623
diff changeset
208 # undef rawmemchr
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
209 # if HAVE_RAW_DECL_RAWMEMCHR
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
210 _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
211 "use gnulib module rawmemchr for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
212 # endif
9999
5f559abfabef Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents: 9623
diff changeset
213 #endif
5f559abfabef Add rawmemchr module, matching glibc.
Eric Blake <ebb9@byu.net>
parents: 9623
diff changeset
214
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
215 /* 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
216 #if @GNULIB_STPCPY@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
217 # if ! @HAVE_STPCPY@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
218 _GL_FUNCDECL_SYS (stpcpy, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
219 (char *restrict __dst, char const *restrict __src)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
220 _GL_ARG_NONNULL ((1, 2)));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
221 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
222 _GL_CXXALIAS_SYS (stpcpy, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
223 (char *restrict __dst, char const *restrict __src));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
224 _GL_CXXALIASWARN (stpcpy);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
225 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
226 # undef stpcpy
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
227 # if HAVE_RAW_DECL_STPCPY
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
228 _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
229 "use gnulib module stpcpy for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
230 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
231 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
232
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
233 /* 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
234 last non-NUL byte written into DST. */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
235 #if @GNULIB_STPNCPY@
13119
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 13094
diff changeset
236 # if @REPLACE_STPNCPY@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
237 # 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
238 # undef stpncpy
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
239 # define stpncpy rpl_stpncpy
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
240 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
241 _GL_FUNCDECL_RPL (stpncpy, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
242 (char *restrict __dst, char const *restrict __src,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
243 size_t __n)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
244 _GL_ARG_NONNULL ((1, 2)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
245 _GL_CXXALIAS_RPL (stpncpy, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
246 (char *restrict __dst, char const *restrict __src,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
247 size_t __n));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
248 # else
13119
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 13094
diff changeset
249 # if ! @HAVE_STPNCPY@
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 13094
diff changeset
250 _GL_FUNCDECL_SYS (stpncpy, char *,
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 13094
diff changeset
251 (char *restrict __dst, char const *restrict __src,
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 13094
diff changeset
252 size_t __n)
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 13094
diff changeset
253 _GL_ARG_NONNULL ((1, 2)));
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 13094
diff changeset
254 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
255 _GL_CXXALIAS_SYS (stpncpy, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
256 (char *restrict __dst, char const *restrict __src,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
257 size_t __n));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
258 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
259 _GL_CXXALIASWARN (stpncpy);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
260 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
261 # undef stpncpy
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
262 # if HAVE_RAW_DECL_STPNCPY
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
263 _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
264 "use gnulib module stpncpy for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
265 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
266 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
267
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
268 #if defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 /* 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
270 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
271 # undef strchr
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
272 /* Assume strchr is always declared. */
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
273 _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
274 "in some multibyte locales - "
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
275 "use mbschr if you care about internationalization");
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 /* 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
279 #if @GNULIB_STRCHRNUL@
14585
1eab1082a832 strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents: 14343
diff changeset
280 # if @REPLACE_STRCHRNUL@
1eab1082a832 strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents: 14343
diff changeset
281 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1eab1082a832 strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents: 14343
diff changeset
282 # define strchrnul rpl_strchrnul
1eab1082a832 strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents: 14343
diff changeset
283 # endif
14586
e60c0a94bedd strchrnul: Tweak last commit.
Bruno Haible <bruno@clisp.org>
parents: 14585
diff changeset
284 _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
285 _GL_ATTRIBUTE_PURE
e60c0a94bedd strchrnul: Tweak last commit.
Bruno Haible <bruno@clisp.org>
parents: 14585
diff changeset
286 _GL_ARG_NONNULL ((1)));
14585
1eab1082a832 strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents: 14343
diff changeset
287 _GL_CXXALIAS_RPL (strchrnul, char *,
1eab1082a832 strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents: 14343
diff changeset
288 (const char *str, int ch));
1eab1082a832 strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents: 14343
diff changeset
289 # else
1eab1082a832 strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents: 14343
diff changeset
290 # if ! @HAVE_STRCHRNUL@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
291 _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
292 _GL_ATTRIBUTE_PURE
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
293 _GL_ARG_NONNULL ((1)));
14585
1eab1082a832 strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents: 14343
diff changeset
294 # endif
12980
a9cefa7a8404 Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents: 12942
diff changeset
295 /* 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
296 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
297 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
298 _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
299 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
300 char const *, (char const *__s, int __c_in));
14585
1eab1082a832 strchrnul: work around cygwin bug
Eric Blake <eblake@redhat.com>
parents: 14343
diff changeset
301 # endif
13885
87a95303747f Port to uClibc.
Bruno Haible <bruno@clisp.org>
parents: 13847
diff changeset
302 # 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
303 && (__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
304 _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
305 _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
306 # else
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
307 _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
308 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
309 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
310 # undef strchrnul
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
311 # if HAVE_RAW_DECL_STRCHRNUL
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
312 _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
313 "use gnulib module strchrnul for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
314 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
315 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
316
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
317 /* Duplicate S, returning an identical malloc'd string. */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
318 #if @GNULIB_STRDUP@
10456
a821fdd7b2b7 New module 'strdup-posix'.
Bruno Haible <bruno@clisp.org>
parents: 10375
diff changeset
319 # if @REPLACE_STRDUP@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
320 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
321 # undef strdup
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
322 # define strdup rpl_strdup
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
323 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
324 _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
325 _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
326 # else
13628
b8b731ae72a8 strdup: Fix compilation error in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 13558
diff changeset
327 # 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
328 /* 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
329 # undef strdup
b8b731ae72a8 strdup: Fix compilation error in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 13558
diff changeset
330 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
331 # if !(@HAVE_DECL_STRDUP@ || defined strdup)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
332 _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
333 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
334 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
10456
a821fdd7b2b7 New module 'strdup-posix'.
Bruno Haible <bruno@clisp.org>
parents: 10375
diff changeset
335 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
336 _GL_CXXALIASWARN (strdup);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
337 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
338 # undef strdup
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
339 # if HAVE_RAW_DECL_STRDUP
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
340 _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
341 "use gnulib module strdup for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
342 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
343 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
344
13175
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
345 /* Append no more than N characters from SRC onto DEST. */
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
346 #if @GNULIB_STRNCAT@
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
347 # if @REPLACE_STRNCAT@
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
348 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
349 # undef strncat
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
350 # define strncat rpl_strncat
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
351 # endif
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
352 _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
353 _GL_ARG_NONNULL ((1, 2)));
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
354 _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
355 # else
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
356 _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
357 # endif
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
358 _GL_CXXALIASWARN (strncat);
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
359 #elif defined GNULIB_POSIXCHECK
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
360 # undef strncat
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
361 # if HAVE_RAW_DECL_STRNCAT
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
362 _GL_WARN_ON_USE (strncat, "strncat is unportable - "
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
363 "use gnulib module strncat for portability");
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
364 # endif
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
365 #endif
5e6286661cc0 New module 'strncat'.
Bruno Haible <bruno@clisp.org>
parents: 13161
diff changeset
366
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
367 /* 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
368 #if @GNULIB_STRNDUP@
11983
5f256f637c47 strndup: fix improper m4 caching
Eric Blake <ebb9@byu.net>
parents: 11960
diff changeset
369 # if @REPLACE_STRNDUP@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
370 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
371 # undef strndup
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
372 # define strndup rpl_strndup
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
373 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
374 _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
375 _GL_ARG_NONNULL ((1)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
376 _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
377 # else
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
378 # if ! @HAVE_DECL_STRNDUP@
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
379 _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
380 _GL_ARG_NONNULL ((1)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
381 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
382 _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
383 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
384 _GL_CXXALIASWARN (strndup);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
385 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
386 # undef strndup
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
387 # if HAVE_RAW_DECL_STRNDUP
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
388 _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
389 "use gnulib module strndup for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
390 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
391 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
392
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
393 /* 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
394 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
395 return MAXLEN. */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
396 #if @GNULIB_STRNLEN@
13194
5aec4f35399f strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents: 13175
diff changeset
397 # if @REPLACE_STRNLEN@
5aec4f35399f strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents: 13175
diff changeset
398 # 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
399 # undef strnlen
5aec4f35399f strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents: 13175
diff changeset
400 # define strnlen rpl_strnlen
5aec4f35399f strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents: 13175
diff changeset
401 # endif
5aec4f35399f strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents: 13175
diff changeset
402 _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
403 _GL_ATTRIBUTE_PURE
13194
5aec4f35399f strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents: 13175
diff changeset
404 _GL_ARG_NONNULL ((1)));
5aec4f35399f strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents: 13175
diff changeset
405 _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
406 # else
5aec4f35399f strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents: 13175
diff changeset
407 # if ! @HAVE_DECL_STRNLEN@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
408 _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
409 _GL_ATTRIBUTE_PURE
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
410 _GL_ARG_NONNULL ((1)));
13194
5aec4f35399f strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents: 13175
diff changeset
411 # endif
5aec4f35399f strnlen: Fix warning in C++ mode on MacOS X.
Bruno Haible <bruno@clisp.org>
parents: 13175
diff changeset
412 _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
413 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
414 _GL_CXXALIASWARN (strnlen);
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 strnlen
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
417 # if HAVE_RAW_DECL_STRNLEN
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
418 _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
419 "use gnulib module strnlen 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 #if defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
424 /* 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
425 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
426 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
427 digit. */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
428 # undef strcspn
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
429 /* Assume strcspn is always declared. */
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
430 _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
431 "in multibyte locales - "
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
432 "use mbscspn if you care about internationalization");
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
433 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
434
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
435 /* 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
436 #if @GNULIB_STRPBRK@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
437 # if ! @HAVE_STRPBRK@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
438 _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
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, 2)));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
441 # endif
12980
a9cefa7a8404 Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents: 12942
diff changeset
442 /* 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
443 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
444 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
445 _GL_CXXALIAS_SYS_CAST2 (strpbrk,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
446 char *, (char const *__s, char const *__accept),
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
447 const char *, (char const *__s, char const *__accept));
13885
87a95303747f Port to uClibc.
Bruno Haible <bruno@clisp.org>
parents: 13847
diff changeset
448 # 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
449 && (__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
450 _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
451 _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
452 (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
453 # else
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
454 _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
455 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
456 # if defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
457 /* 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
458 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
459 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
460 digit. */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
461 # undef strpbrk
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
462 _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
463 "in multibyte locales - "
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
464 "use mbspbrk if you care about internationalization");
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
465 # endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
466 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
467 # undef strpbrk
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
468 # if HAVE_RAW_DECL_STRPBRK
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
469 _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
470 "use gnulib module strpbrk for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
471 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
472 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
473
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
474 #if defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
475 /* 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
476 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
477 # undef strspn
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
478 /* Assume strspn is always declared. */
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
479 _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
480 "in multibyte locales - "
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
481 "use mbsspn if you care about internationalization");
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
482 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
483
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
484 #if defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
485 /* 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
486 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
487 # undef strrchr
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
488 /* Assume strrchr is always declared. */
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
489 _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
490 "in some multibyte locales - "
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
491 "use mbsrchr if you care about internationalization");
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
492 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
493
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
494 /* 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
495 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
496 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
497 If *STRINGP was already NULL, nothing happens.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
498 Return the old value of *STRINGP.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
499
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
500 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
501 empty fields.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
502
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
503 Caveat: It modifies the original string.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
504 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
505 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
506 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
507 characters are ASCII characters < 0x30.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
508
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
509 See also strtok_r(). */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
510 #if @GNULIB_STRSEP@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
511 # if ! @HAVE_STRSEP@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
512 _GL_FUNCDECL_SYS (strsep, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
513 (char **restrict __stringp, char const *restrict __delim)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
514 _GL_ARG_NONNULL ((1, 2)));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
515 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
516 _GL_CXXALIAS_SYS (strsep, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
517 (char **restrict __stringp, char const *restrict __delim));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
518 _GL_CXXALIASWARN (strsep);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
519 # if defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
520 # undef strsep
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
521 _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
522 "in multibyte locales - "
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
523 "use mbssep if you care about internationalization");
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
524 # endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
525 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
526 # undef strsep
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
527 # if HAVE_RAW_DECL_STRSEP
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
528 _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
529 "use gnulib module strsep for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
530 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
531 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
532
9600
99268e709d31 Avoid quadratic strstr implementations.
Eric Blake <ebb9@byu.net>
parents: 9590
diff changeset
533 #if @GNULIB_STRSTR@
99268e709d31 Avoid quadratic strstr implementations.
Eric Blake <ebb9@byu.net>
parents: 9590
diff changeset
534 # if @REPLACE_STRSTR@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
535 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
536 # define strstr rpl_strstr
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
537 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
538 _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
539 _GL_ATTRIBUTE_PURE
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
540 _GL_ARG_NONNULL ((1, 2)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
541 _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
542 # else
12980
a9cefa7a8404 Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents: 12942
diff changeset
543 /* 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
544 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
545 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
546 _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
547 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
548 const char *, (const char *haystack, const char *needle));
9600
99268e709d31 Avoid quadratic strstr implementations.
Eric Blake <ebb9@byu.net>
parents: 9590
diff changeset
549 # endif
13885
87a95303747f Port to uClibc.
Bruno Haible <bruno@clisp.org>
parents: 13847
diff changeset
550 # 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
551 && (__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
552 _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
553 _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
554 (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
555 # else
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
556 _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
557 # endif
9600
99268e709d31 Avoid quadratic strstr implementations.
Eric Blake <ebb9@byu.net>
parents: 9590
diff changeset
558 #elif defined GNULIB_POSIXCHECK
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
559 /* 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
560 different from UTF-8:
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
561 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
562 as a sequence of bytes, not of characters. */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
563 # undef strstr
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
564 /* Assume strstr is always declared. */
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
565 _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
566 "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
567 "multibyte locales - "
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
568 "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
569 "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
570 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
571
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
572 /* 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
573 comparison. */
9623
69d9307c0aa0 Convert strcasestr module to use Two-Way algorithm.
Eric Blake <ebb9@byu.net>
parents: 9622
diff changeset
574 #if @GNULIB_STRCASESTR@
69d9307c0aa0 Convert strcasestr module to use Two-Way algorithm.
Eric Blake <ebb9@byu.net>
parents: 9622
diff changeset
575 # if @REPLACE_STRCASESTR@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
576 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
577 # define strcasestr rpl_strcasestr
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
578 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
579 _GL_FUNCDECL_RPL (strcasestr, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
580 (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
581 _GL_ATTRIBUTE_PURE
6c32722a9d4b string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents: 13194
diff changeset
582 _GL_ARG_NONNULL ((1, 2)));
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
583 _GL_CXXALIAS_RPL (strcasestr, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
584 (const char *haystack, const char *needle));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
585 # else
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
586 # if ! @HAVE_STRCASESTR@
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
587 _GL_FUNCDECL_SYS (strcasestr, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
588 (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
589 _GL_ATTRIBUTE_PURE
6c32722a9d4b string: Fix syntax error with g++ 2.96.
Bruno Haible <bruno@clisp.org>
parents: 13194
diff changeset
590 _GL_ARG_NONNULL ((1, 2)));
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
591 # endif
12980
a9cefa7a8404 Fix problems with overloaded C++ definitions of memchr, strpbrk, etc.
Bruno Haible <bruno@clisp.org>
parents: 12942
diff changeset
592 /* 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
593 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
594 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
595 _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
596 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
597 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
598 # endif
13885
87a95303747f Port to uClibc.
Bruno Haible <bruno@clisp.org>
parents: 13847
diff changeset
599 # 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
600 && (__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
601 _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
602 _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
603 (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
604 # else
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
605 _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
606 # endif
9623
69d9307c0aa0 Convert strcasestr module to use Two-Way algorithm.
Eric Blake <ebb9@byu.net>
parents: 9622
diff changeset
607 #elif defined GNULIB_POSIXCHECK
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
608 /* strcasestr() does not work with multibyte strings:
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
609 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
610 locales. */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
611 # undef strcasestr
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
612 # if HAVE_RAW_DECL_STRCASESTR
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
613 _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
614 "strings in multibyte locales - "
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
615 "use mbscasestr if you care about "
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
616 "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
617 "a locale independent function");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
618 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
619 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
620
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
621 /* 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
622 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
623 the next starting point. For example:
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11983
diff changeset
624 char s[] = "-abc-=-def";
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11983
diff changeset
625 char *sp;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11983
diff changeset
626 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
627 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
628 x = strtok_r(NULL, "=", &sp); // x = NULL
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11983
diff changeset
629 // s = "abc\0-def\0"
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
630
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
631 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
632
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
633 For the POSIX documentation for this function, see:
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
634 http://www.opengroup.org/susv3xsh/strtok.html
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
635
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
636 Caveat: It modifies the original string.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
637 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
638 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
639 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
640 characters are ASCII characters < 0x30.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
641
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
642 See also strsep(). */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
643 #if @GNULIB_STRTOK_R@
11960
bc6846876d71 Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents: 11832
diff changeset
644 # if @REPLACE_STRTOK_R@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
645 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
646 # undef strtok_r
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
647 # define strtok_r rpl_strtok_r
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
648 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
649 _GL_FUNCDECL_RPL (strtok_r, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
650 (char *restrict s, char const *restrict delim,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
651 char **restrict save_ptr)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
652 _GL_ARG_NONNULL ((2, 3)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
653 _GL_CXXALIAS_RPL (strtok_r, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
654 (char *restrict s, char const *restrict delim,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
655 char **restrict save_ptr));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
656 # else
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
657 # if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
658 # undef strtok_r
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
659 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
660 # if ! @HAVE_DECL_STRTOK_R@
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
661 _GL_FUNCDECL_SYS (strtok_r, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
662 (char *restrict s, char const *restrict delim,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
663 char **restrict save_ptr)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
664 _GL_ARG_NONNULL ((2, 3)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
665 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
666 _GL_CXXALIAS_SYS (strtok_r, char *,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
667 (char *restrict s, char const *restrict delim,
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
668 char **restrict save_ptr));
11960
bc6846876d71 Work around a glibc bug in strtok_r.
Ben Pfaff <blp@gnu.org>
parents: 11832
diff changeset
669 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
670 _GL_CXXALIASWARN (strtok_r);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
671 # if defined GNULIB_POSIXCHECK
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
672 _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
673 "strings in multibyte locales - "
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
674 "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
675 # endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
676 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
677 # undef strtok_r
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
678 # if HAVE_RAW_DECL_STRTOK_R
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
679 _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
680 "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
681 # endif
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
682 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
683
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
684
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
685 /* 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
686 extensions. */
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
687
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
688 #if @GNULIB_MBSLEN@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
689 /* 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
690 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
691 # 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
692 # undef mbslen
e6c17971ef92 mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
693 # endif
e6c17971ef92 mbslen: Avoid collision with system function.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
694 # 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
695 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
696 # define mbslen rpl_mbslen
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
697 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
698 _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
699 _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
700 # else
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
701 _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
702 _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
703 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
704 _GL_CXXALIASWARN (mbslen);
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
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
707 #if @GNULIB_MBSNLEN@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
708 /* 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
709 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
710 _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
711 _GL_ARG_NONNULL ((1));
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 #if @GNULIB_MBSCHR@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
715 /* 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
716 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
717 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
718 encodings such as GB18030. */
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
719 # if defined __hpux
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
720 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
721 # 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
722 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
723 _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
724 _GL_ARG_NONNULL ((1)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
725 _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
726 # else
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
727 _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
728 _GL_ARG_NONNULL ((1)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
729 _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
730 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
731 _GL_CXXALIASWARN (mbschr);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
732 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
733
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
734 #if @GNULIB_MBSRCHR@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
735 /* 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
736 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
737 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
738 encodings such as GB18030. */
14828
90514fe74451 mbsrchr: Avoid collision with system function on Interix.
Bruno Haible <bruno@clisp.org>
parents: 14586
diff changeset
739 # if defined __hpux || defined __INTERIX
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
740 # 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
741 # 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
742 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
743 _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
744 _GL_ARG_NONNULL ((1)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
745 _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
746 # else
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
747 _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
748 _GL_ARG_NONNULL ((1)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
749 _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
750 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
751 _GL_CXXALIASWARN (mbsrchr);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
752 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
753
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
754 #if @GNULIB_MBSSTR@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
755 /* 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
756 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
757 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
758 encodings different from UTF-8. */
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
759 _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
760 _GL_ARG_NONNULL ((1, 2));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
761 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
762
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
763 #if @GNULIB_MBSCASECMP@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
764 /* 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
765 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
766 or greater than S2.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
767 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
768 different lengths!
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
769 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
770 _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
771 _GL_ARG_NONNULL ((1, 2));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
772 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
773
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
774 #if @GNULIB_MBSNCASECMP@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
775 /* 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
776 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
777 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
778 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
779 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
780 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
781 of different lengths!
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
782 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
783 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
784 _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
785 _GL_ARG_NONNULL ((1, 2));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
786 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
787
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
788 #if @GNULIB_MBSPCASECMP@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
789 /* 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
790 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
791 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
792 after this prefix in STRING. Otherwise, return NULL.
957a79f455ba mbspcasecmp: Fix function specification.
Bruno Haible <bruno@clisp.org>
parents: 13443
diff changeset
793 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
794 is of smaller length than PREFIX!
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
795 Unlike strncasecmp(), this function works correctly in multibyte
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
796 locales. */
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
797 _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
798 _GL_ARG_NONNULL ((1, 2));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
799 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
800
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
801 #if @GNULIB_MBSCASESTR@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
802 /* 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
803 string HAYSTACK, using case-insensitive comparison.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
804 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
805 strlen (haystack) < strlen (needle) !
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
806 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
807 _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
808 _GL_ARG_NONNULL ((1, 2));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
809 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
810
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
811 #if @GNULIB_MBSCSPN@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
812 /* 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
813 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
814 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
815 if none exists.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
816 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
817 _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
818 _GL_ARG_NONNULL ((1, 2));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
819 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
820
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
821 #if @GNULIB_MBSPBRK@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
822 /* 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
823 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
824 exists.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
825 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
826 # if defined __hpux
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
827 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
828 # 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
829 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
830 _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
831 _GL_ARG_NONNULL ((1, 2)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
832 _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
833 # else
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
834 _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
835 _GL_ARG_NONNULL ((1, 2)));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
836 _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
837 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
838 _GL_CXXALIASWARN (mbspbrk);
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_MBSSPN@
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 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
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 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
847 _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
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_MBSSEP@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
852 /* 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
853 string DELIM) starting at the character string *STRINGP.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
854 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
855 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
856 If *STRINGP was already NULL, nothing happens.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
857 Return the old value of *STRINGP.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
858
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
859 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
860
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
861 Caveat: It modifies the original string.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
862 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
863 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
864
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
865 See also mbstok_r(). */
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
866 _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
867 _GL_ARG_NONNULL ((1, 2));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
868 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
869
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
870 #if @GNULIB_MBSTOK_R@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
871 /* 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
872 the character string DELIM.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
873 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
874 the next starting point. For example:
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11983
diff changeset
875 char s[] = "-abc-=-def";
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11983
diff changeset
876 char *sp;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11983
diff changeset
877 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
878 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
879 x = mbstok_r(NULL, "=", &sp); // x = NULL
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11983
diff changeset
880 // s = "abc\0-def\0"
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
881
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
882 Caveat: It modifies the original string.
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
883 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
884 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
885
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
886 See also mbssep(). */
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
887 _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
888 _GL_ARG_NONNULL ((2, 3));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
889 #endif
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 /* 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
892 #if @GNULIB_STRERROR@
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
893 # if @REPLACE_STRERROR@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
894 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
895 # undef strerror
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
896 # define strerror rpl_strerror
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
897 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
898 _GL_FUNCDECL_RPL (strerror, char *, (int));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
899 _GL_CXXALIAS_RPL (strerror, char *, (int));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
900 # else
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
901 _GL_CXXALIAS_SYS (strerror, char *, (int));
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
902 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
903 _GL_CXXALIASWARN (strerror);
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
904 #elif defined GNULIB_POSIXCHECK
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
905 # undef strerror
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
906 /* Assume strerror is always declared. */
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
907 _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
908 "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
909 #endif
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
910
13847
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
911 /* 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
912 Uses the POSIX declaration, not the glibc declaration. */
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
913 #if @GNULIB_STRERROR_R@
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
914 # if @REPLACE_STRERROR_R@
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
915 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
916 # undef strerror_r
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
917 # define strerror_r rpl_strerror_r
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
918 # endif
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
919 _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
920 _GL_ARG_NONNULL ((2)));
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
921 _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
922 # else
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
923 # if !@HAVE_DECL_STRERROR_R@
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
924 _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
925 _GL_ARG_NONNULL ((2)));
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
926 # endif
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
927 _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
928 # endif
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
929 # if @HAVE_DECL_STRERROR_R@
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
930 _GL_CXXALIASWARN (strerror_r);
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
931 # endif
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
932 #elif defined GNULIB_POSIXCHECK
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
933 # undef strerror_r
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
934 # if HAVE_RAW_DECL_STRERROR_R
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
935 _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
936 "use gnulib module strerror_r-posix for portability");
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
937 # endif
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
938 #endif
99dd2b4fab8b New module 'strerror_r-posix'.
Bruno Haible <bruno@clisp.org>
parents: 13773
diff changeset
939
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents: 9613
diff changeset
940 #if @GNULIB_STRSIGNAL@
9622
7b32838d1079 Replace strsignal if it does not work fine.
Bruno Haible <bruno@clisp.org>
parents: 9616
diff changeset
941 # if @REPLACE_STRSIGNAL@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
942 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
943 # define strsignal rpl_strsignal
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
944 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
945 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
946 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
947 # else
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
948 # if ! @HAVE_DECL_STRSIGNAL@
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
949 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
950 # endif
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
951 /* 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
952 'const char *'. */
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
953 _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
954 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
955 _GL_CXXALIASWARN (strsignal);
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents: 9613
diff changeset
956 #elif defined GNULIB_POSIXCHECK
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents: 9613
diff changeset
957 # undef strsignal
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
958 # if HAVE_RAW_DECL_STRSIGNAL
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
959 _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
960 "use gnulib module strsignal for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
961 # endif
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents: 9613
diff changeset
962 #endif
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents: 9613
diff changeset
963
10345
8d80c477e0ad strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents: 9999
diff changeset
964 #if @GNULIB_STRVERSCMP@
8d80c477e0ad strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents: 9999
diff changeset
965 # if !@HAVE_STRVERSCMP@
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
966 _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
967 _GL_ARG_NONNULL ((1, 2)));
10345
8d80c477e0ad strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents: 9999
diff changeset
968 # endif
12942
17ee1f140456 string: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12766
diff changeset
969 _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
970 _GL_CXXALIASWARN (strverscmp);
10345
8d80c477e0ad strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents: 9999
diff changeset
971 #elif defined GNULIB_POSIXCHECK
8d80c477e0ad strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents: 9999
diff changeset
972 # undef strverscmp
12766
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
973 # if HAVE_RAW_DECL_STRVERSCMP
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
974 _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
975 "use gnulib module strverscmp for portability");
2c14f1e449e5 warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents: 12602
diff changeset
976 # endif
10345
8d80c477e0ad strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents: 9999
diff changeset
977 #endif
8d80c477e0ad strverscmp: migrate from "strverscmp.h" to <string.h>
Eric Blake <ebb9@byu.net>
parents: 9999
diff changeset
978
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
979
14840
5f709022a256 Allow multiple gnulib generated include files to be combined.
Bruno Haible <bruno@clisp.org>
parents: 14828
diff changeset
980 #endif /* _@GUARD_PREFIX@_STRING_H */
5f709022a256 Allow multiple gnulib generated include files to be combined.
Bruno Haible <bruno@clisp.org>
parents: 14828
diff changeset
981 #endif /* _@GUARD_PREFIX@_STRING_H */