1 /* A GNU-like <string.h>.
3 Copyright (C) 1995-1996, 2001-2022 Free Software Foundation, Inc.
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19 @PRAGMA_SYSTEM_HEADER@
23 #if defined _GL_ALREADY_INCLUDING_STRING_H
24 /* Special invocation convention:
25 - On OS X/NetBSD we have a sequence of nested includes
26 <string.h> -> <strings.h> -> "string.h"
27 In this situation system _chk variants due to -D_FORTIFY_SOURCE
28 might be used after any replacements defined here. */
30 #@INCLUDE_NEXT@ @NEXT_STRING_H@
33 /* Normal invocation convention. */
35 #ifndef _@GUARD_PREFIX@_STRING_H
37 #define _GL_ALREADY_INCLUDING_STRING_H
39 /* The include_next requires a split double-inclusion guard. */
40 #@INCLUDE_NEXT@ @NEXT_STRING_H@
42 #undef _GL_ALREADY_INCLUDING_STRING_H
44 #ifndef _@GUARD_PREFIX@_STRING_H
45 #define _@GUARD_PREFIX@_STRING_H
47 /* NetBSD 5.0 mis-defines NULL. */
50 /* MirBSD defines mbslen as a macro. */
51 #if @GNULIB_MBSLEN@ && defined __MirBSD__
55 /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
56 /* But in any case avoid namespace pollution on glibc systems. */
57 #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
58 && ! defined __GLIBC__
62 /* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>. */
63 /* But in any case avoid namespace pollution on glibc systems. */
64 #if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \
66 && ! defined __GLIBC__
70 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
71 that can be freed by passing them as the Ith argument to the
73 #ifndef _GL_ATTRIBUTE_DEALLOC
75 # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
77 # define _GL_ATTRIBUTE_DEALLOC(f, i)
81 /* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
82 can be freed via 'free'; it can be used only after declaring 'free'. */
83 /* Applies to: functions. Cannot be used on inline functions. */
84 #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
85 # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
88 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
90 /* Applies to: functions. */
91 #ifndef _GL_ATTRIBUTE_MALLOC
92 # if __GNUC__ >= 3 || defined __clang__
93 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
95 # define _GL_ATTRIBUTE_MALLOC
99 /* The __attribute__ feature is available in gcc versions 2.5 and later.
100 The attribute __pure__ was added in gcc 2.96. */
101 #ifndef _GL_ATTRIBUTE_PURE
102 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
103 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
105 # define _GL_ATTRIBUTE_PURE /* empty */
109 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
111 /* The definition of _GL_ARG_NONNULL is copied here. */
113 /* The definition of _GL_WARN_ON_USE is copied here. */
115 /* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
116 been included yet. */
117 #if @GNULIB_FREE_POSIX@
118 # if (@REPLACE_FREE@ && !defined free \
119 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
120 /* We can't do '#define free rpl_free' here. */
121 _GL_EXTERN_C
void rpl_free (void *);
122 # undef _GL_ATTRIBUTE_DEALLOC_FREE
123 # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
125 # if defined _MSC_VER
126 _GL_EXTERN_C
void __cdecl
free (void *);
128 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
129 _GL_EXTERN_C
void free (void *) throw ();
131 _GL_EXTERN_C
void free (void *);
136 # if defined _MSC_VER
137 _GL_EXTERN_C
void __cdecl
free (void *);
139 # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
140 _GL_EXTERN_C
void free (void *) throw ();
142 _GL_EXTERN_C
void free (void *);
147 /* Clear a block of memory. The compiler will not delete a call to
148 this function, even if the block is dead after the call. */
149 #if @GNULIB_EXPLICIT_BZERO@
150 # if ! @HAVE_EXPLICIT_BZERO@
151 _GL_FUNCDECL_SYS (explicit_bzero
, void,
152 (void *__dest
, size_t __n
) _GL_ARG_NONNULL ((1)));
154 _GL_CXXALIAS_SYS (explicit_bzero
, void, (void *__dest
, size_t __n
));
155 _GL_CXXALIASWARN (explicit_bzero
);
156 #elif defined GNULIB_POSIXCHECK
157 # undef explicit_bzero
158 # if HAVE_RAW_DECL_EXPLICIT_BZERO
159 _GL_WARN_ON_USE (explicit_bzero
, "explicit_bzero is unportable - "
160 "use gnulib module explicit_bzero for portability");
164 /* Find the index of the least-significant set bit. */
167 _GL_FUNCDECL_SYS (ffsl
, int, (long int i
));
169 _GL_CXXALIAS_SYS (ffsl
, int, (long int i
));
170 _GL_CXXALIASWARN (ffsl
);
171 #elif defined GNULIB_POSIXCHECK
173 # if HAVE_RAW_DECL_FFSL
174 _GL_WARN_ON_USE (ffsl
, "ffsl is not portable - use the ffsl module");
179 /* Find the index of the least-significant set bit. */
182 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
183 # define ffsll rpl_ffsll
185 _GL_FUNCDECL_RPL (ffsll
, int, (long long int i
));
186 _GL_CXXALIAS_RPL (ffsll
, int, (long long int i
));
189 _GL_FUNCDECL_SYS (ffsll
, int, (long long int i
));
191 _GL_CXXALIAS_SYS (ffsll
, int, (long long int i
));
193 _GL_CXXALIASWARN (ffsll
);
194 #elif defined GNULIB_POSIXCHECK
196 # if HAVE_RAW_DECL_FFSLL
197 _GL_WARN_ON_USE (ffsll
, "ffsll is not portable - use the ffsll module");
202 #if @GNULIB_MDA_MEMCCPY@
203 /* On native Windows, map 'memccpy' to '_memccpy', so that -loldnames is not
204 required. In C++ with GNULIB_NAMESPACE, avoid differences between
205 platforms by defining GNULIB_NAMESPACE::memccpy always. */
206 # if defined _WIN32 && !defined __CYGWIN__
207 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
209 # define memccpy _memccpy
211 _GL_CXXALIAS_MDA (memccpy
, void *,
212 (void *dest
, const void *src
, int c
, size_t n
));
214 _GL_CXXALIAS_SYS (memccpy
, void *,
215 (void *dest
, const void *src
, int c
, size_t n
));
217 _GL_CXXALIASWARN (memccpy
);
221 /* Return the first instance of C within N bytes of S, or NULL. */
223 # if @REPLACE_MEMCHR@
224 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
226 # define memchr rpl_memchr
228 _GL_FUNCDECL_RPL (memchr
, void *, (void const *__s
, int __c
, size_t __n
)
230 _GL_ARG_NONNULL ((1)));
231 _GL_CXXALIAS_RPL (memchr
, void *, (void const *__s
, int __c
, size_t __n
));
233 /* On some systems, this function is defined as an overloaded function:
234 extern "C" { const void * std::memchr (const void *, int, size_t); }
235 extern "C++" { void * std::memchr (void *, int, size_t); } */
236 _GL_CXXALIAS_SYS_CAST2 (memchr
,
237 void *, (void const *__s
, int __c
, size_t __n
),
238 void const *, (void const *__s
, int __c
, size_t __n
));
240 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
241 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
242 || defined __clang__)
243 _GL_CXXALIASWARN1 (memchr
, void *, (void *__s
, int __c
, size_t __n
) throw ());
244 _GL_CXXALIASWARN1 (memchr
, void const *,
245 (void const *__s
, int __c
, size_t __n
) throw ());
246 # elif __GLIBC__ >= 2
247 _GL_CXXALIASWARN (memchr
);
249 #elif defined GNULIB_POSIXCHECK
251 /* Assume memchr is always declared. */
252 _GL_WARN_ON_USE (memchr
, "memchr has platform-specific bugs - "
253 "use gnulib module memchr for portability" );
256 /* Return the first occurrence of NEEDLE in HAYSTACK. */
258 # if @REPLACE_MEMMEM@
259 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
260 # define memmem rpl_memmem
262 _GL_FUNCDECL_RPL (memmem
, void *,
263 (void const *__haystack
, size_t __haystack_len
,
264 void const *__needle
, size_t __needle_len
)
266 _GL_ARG_NONNULL ((1, 3)));
267 _GL_CXXALIAS_RPL (memmem
, void *,
268 (void const *__haystack
, size_t __haystack_len
,
269 void const *__needle
, size_t __needle_len
));
271 # if ! @HAVE_DECL_MEMMEM@
272 _GL_FUNCDECL_SYS (memmem
, void *,
273 (void const *__haystack
, size_t __haystack_len
,
274 void const *__needle
, size_t __needle_len
)
276 _GL_ARG_NONNULL ((1, 3)));
278 _GL_CXXALIAS_SYS (memmem
, void *,
279 (void const *__haystack
, size_t __haystack_len
,
280 void const *__needle
, size_t __needle_len
));
282 _GL_CXXALIASWARN (memmem
);
283 #elif defined GNULIB_POSIXCHECK
285 # if HAVE_RAW_DECL_MEMMEM
286 _GL_WARN_ON_USE (memmem
, "memmem is unportable and often quadratic - "
287 "use gnulib module memmem-simple for portability, "
288 "and module memmem for speed" );
292 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
293 last written byte. */
295 # if ! @HAVE_MEMPCPY@
296 _GL_FUNCDECL_SYS (mempcpy
, void *,
297 (void *restrict __dest
, void const *restrict __src
,
299 _GL_ARG_NONNULL ((1, 2)));
301 _GL_CXXALIAS_SYS (mempcpy
, void *,
302 (void *restrict __dest
, void const *restrict __src
,
304 _GL_CXXALIASWARN (mempcpy
);
305 #elif defined GNULIB_POSIXCHECK
307 # if HAVE_RAW_DECL_MEMPCPY
308 _GL_WARN_ON_USE (mempcpy
, "mempcpy is unportable - "
309 "use gnulib module mempcpy for portability");
313 /* Search backwards through a block for a byte (specified as an int). */
315 # if ! @HAVE_DECL_MEMRCHR@
316 _GL_FUNCDECL_SYS (memrchr
, void *, (void const *, int, size_t)
318 _GL_ARG_NONNULL ((1)));
320 /* On some systems, this function is defined as an overloaded function:
321 extern "C++" { const void * std::memrchr (const void *, int, size_t); }
322 extern "C++" { void * std::memrchr (void *, int, size_t); } */
323 _GL_CXXALIAS_SYS_CAST2 (memrchr
,
324 void *, (void const *, int, size_t),
325 void const *, (void const *, int, size_t));
326 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
327 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
328 || defined __clang__)
329 _GL_CXXALIASWARN1 (memrchr
, void *, (void *, int, size_t) throw ());
330 _GL_CXXALIASWARN1 (memrchr
, void const *, (void const *, int, size_t) throw ());
332 _GL_CXXALIASWARN (memrchr
);
334 #elif defined GNULIB_POSIXCHECK
336 # if HAVE_RAW_DECL_MEMRCHR
337 _GL_WARN_ON_USE (memrchr
, "memrchr is unportable - "
338 "use gnulib module memrchr for portability");
342 /* Find the first occurrence of C in S. More efficient than
343 memchr(S,C,N), at the expense of undefined behavior if C does not
344 occur within N bytes. */
345 #if @GNULIB_RAWMEMCHR@
346 # if ! @HAVE_RAWMEMCHR@
347 _GL_FUNCDECL_SYS (rawmemchr
, void *, (void const *__s
, int __c_in
)
349 _GL_ARG_NONNULL ((1)));
351 /* On some systems, this function is defined as an overloaded function:
352 extern "C++" { const void * std::rawmemchr (const void *, int); }
353 extern "C++" { void * std::rawmemchr (void *, int); } */
354 _GL_CXXALIAS_SYS_CAST2 (rawmemchr
,
355 void *, (void const *__s
, int __c_in
),
356 void const *, (void const *__s
, int __c_in
));
357 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
358 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
359 || defined __clang__)
360 _GL_CXXALIASWARN1 (rawmemchr
, void *, (void *__s
, int __c_in
) throw ());
361 _GL_CXXALIASWARN1 (rawmemchr
, void const *,
362 (void const *__s
, int __c_in
) throw ());
364 _GL_CXXALIASWARN (rawmemchr
);
366 #elif defined GNULIB_POSIXCHECK
368 # if HAVE_RAW_DECL_RAWMEMCHR
369 _GL_WARN_ON_USE (rawmemchr
, "rawmemchr is unportable - "
370 "use gnulib module rawmemchr for portability");
374 /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
377 _GL_FUNCDECL_SYS (stpcpy
, char *,
378 (char *restrict __dst
, char const *restrict __src
)
379 _GL_ARG_NONNULL ((1, 2)));
381 _GL_CXXALIAS_SYS (stpcpy
, char *,
382 (char *restrict __dst
, char const *restrict __src
));
383 _GL_CXXALIASWARN (stpcpy
);
384 #elif defined GNULIB_POSIXCHECK
386 # if HAVE_RAW_DECL_STPCPY
387 _GL_WARN_ON_USE (stpcpy
, "stpcpy is unportable - "
388 "use gnulib module stpcpy for portability");
392 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
393 last non-NUL byte written into DST. */
395 # if @REPLACE_STPNCPY@
396 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
398 # define stpncpy rpl_stpncpy
400 _GL_FUNCDECL_RPL (stpncpy
, char *,
401 (char *restrict __dst
, char const *restrict __src
,
403 _GL_ARG_NONNULL ((1, 2)));
404 _GL_CXXALIAS_RPL (stpncpy
, char *,
405 (char *restrict __dst
, char const *restrict __src
,
408 # if ! @HAVE_STPNCPY@
409 _GL_FUNCDECL_SYS (stpncpy
, char *,
410 (char *restrict __dst
, char const *restrict __src
,
412 _GL_ARG_NONNULL ((1, 2)));
414 _GL_CXXALIAS_SYS (stpncpy
, char *,
415 (char *restrict __dst
, char const *restrict __src
,
418 _GL_CXXALIASWARN (stpncpy
);
419 #elif defined GNULIB_POSIXCHECK
421 # if HAVE_RAW_DECL_STPNCPY
422 _GL_WARN_ON_USE (stpncpy
, "stpncpy is unportable - "
423 "use gnulib module stpncpy for portability");
427 #if defined GNULIB_POSIXCHECK
428 /* strchr() does not work with multibyte strings if the locale encoding is
429 GB18030 and the character to be searched is a digit. */
431 /* Assume strchr is always declared. */
432 _GL_WARN_ON_USE_CXX (strchr
,
433 const char *, char *, (const char *, int),
434 "strchr cannot work correctly on character strings "
435 "in some multibyte locales - "
436 "use mbschr if you care about internationalization");
439 /* Find the first occurrence of C in S or the final NUL byte. */
440 #if @GNULIB_STRCHRNUL@
441 # if @REPLACE_STRCHRNUL@
442 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
443 # define strchrnul rpl_strchrnul
445 _GL_FUNCDECL_RPL (strchrnul
, char *, (const char *__s
, int __c_in
)
447 _GL_ARG_NONNULL ((1)));
448 _GL_CXXALIAS_RPL (strchrnul
, char *,
449 (const char *str
, int ch
));
451 # if ! @HAVE_STRCHRNUL@
452 _GL_FUNCDECL_SYS (strchrnul
, char *, (char const *__s
, int __c_in
)
454 _GL_ARG_NONNULL ((1)));
456 /* On some systems, this function is defined as an overloaded function:
457 extern "C++" { const char * std::strchrnul (const char *, int); }
458 extern "C++" { char * std::strchrnul (char *, int); } */
459 _GL_CXXALIAS_SYS_CAST2 (strchrnul
,
460 char *, (char const *__s
, int __c_in
),
461 char const *, (char const *__s
, int __c_in
));
463 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
464 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
465 || defined __clang__)
466 _GL_CXXALIASWARN1 (strchrnul
, char *, (char *__s
, int __c_in
) throw ());
467 _GL_CXXALIASWARN1 (strchrnul
, char const *,
468 (char const *__s
, int __c_in
) throw ());
470 _GL_CXXALIASWARN (strchrnul
);
472 #elif defined GNULIB_POSIXCHECK
474 # if HAVE_RAW_DECL_STRCHRNUL
475 _GL_WARN_ON_USE (strchrnul
, "strchrnul is unportable - "
476 "use gnulib module strchrnul for portability");
480 /* Duplicate S, returning an identical malloc'd string. */
482 # if @REPLACE_STRDUP@
483 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
485 # define strdup rpl_strdup
487 _GL_FUNCDECL_RPL (strdup
, char *,
489 _GL_ARG_NONNULL ((1))
490 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
491 _GL_CXXALIAS_RPL (strdup
, char *, (char const *__s
));
492 # elif defined _WIN32 && !defined __CYGWIN__
493 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
495 # define strdup _strdup
497 _GL_CXXALIAS_MDA (strdup
, char *, (char const *__s
));
499 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
500 /* strdup exists as a function and as a macro. Get rid of the macro. */
503 # if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup
504 _GL_FUNCDECL_SYS (strdup
, char *,
506 _GL_ARG_NONNULL ((1))
507 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
509 _GL_CXXALIAS_SYS (strdup
, char *, (char const *__s
));
511 _GL_CXXALIASWARN (strdup
);
513 # if __GNUC__ >= 11 && !defined strdup
514 /* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */
515 _GL_FUNCDECL_SYS (strdup
, char *,
517 _GL_ARG_NONNULL ((1))
518 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
520 # if defined GNULIB_POSIXCHECK
522 # if HAVE_RAW_DECL_STRDUP
523 _GL_WARN_ON_USE (strdup
, "strdup is unportable - "
524 "use gnulib module strdup for portability");
526 # elif @GNULIB_MDA_STRDUP@
527 /* On native Windows, map 'creat' to '_creat', so that -loldnames is not
528 required. In C++ with GNULIB_NAMESPACE, avoid differences between
529 platforms by defining GNULIB_NAMESPACE::strdup always. */
530 # if defined _WIN32 && !defined __CYGWIN__
531 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
533 # define strdup _strdup
535 _GL_CXXALIAS_MDA (strdup
, char *, (char const *__s
));
537 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
540 _GL_CXXALIAS_SYS (strdup
, char *, (char const *__s
));
542 _GL_CXXALIASWARN (strdup
);
546 /* Append no more than N characters from SRC onto DEST. */
548 # if @REPLACE_STRNCAT@
549 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
551 # define strncat rpl_strncat
553 _GL_FUNCDECL_RPL (strncat
, char *,
554 (char *restrict dest
, const char *restrict src
, size_t n
)
555 _GL_ARG_NONNULL ((1, 2)));
556 _GL_CXXALIAS_RPL (strncat
, char *,
557 (char *restrict dest
, const char *restrict src
, size_t n
));
559 _GL_CXXALIAS_SYS (strncat
, char *,
560 (char *restrict dest
, const char *restrict src
, size_t n
));
563 _GL_CXXALIASWARN (strncat
);
565 #elif defined GNULIB_POSIXCHECK
567 # if HAVE_RAW_DECL_STRNCAT
568 _GL_WARN_ON_USE (strncat
, "strncat is unportable - "
569 "use gnulib module strncat for portability");
573 /* Return a newly allocated copy of at most N bytes of STRING. */
575 # if @REPLACE_STRNDUP@
576 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
578 # define strndup rpl_strndup
580 _GL_FUNCDECL_RPL (strndup
, char *,
581 (char const *__s
, size_t __n
)
582 _GL_ARG_NONNULL ((1))
583 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
584 _GL_CXXALIAS_RPL (strndup
, char *, (char const *__s
, size_t __n
));
586 # if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup)
587 _GL_FUNCDECL_SYS (strndup
, char *,
588 (char const *__s
, size_t __n
)
589 _GL_ARG_NONNULL ((1))
590 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
592 _GL_CXXALIAS_SYS (strndup
, char *, (char const *__s
, size_t __n
));
594 _GL_CXXALIASWARN (strndup
);
596 # if __GNUC__ >= 11 && !defined strndup
597 /* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */
598 _GL_FUNCDECL_SYS (strndup
, char *,
599 (char const *__s
, size_t __n
)
600 _GL_ARG_NONNULL ((1))
601 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
);
603 # if defined GNULIB_POSIXCHECK
605 # if HAVE_RAW_DECL_STRNDUP
606 _GL_WARN_ON_USE (strndup
, "strndup is unportable - "
607 "use gnulib module strndup for portability");
612 /* Find the length (number of bytes) of STRING, but scan at most
613 MAXLEN bytes. If no '\0' terminator is found in that many bytes,
616 # if @REPLACE_STRNLEN@
617 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
619 # define strnlen rpl_strnlen
621 _GL_FUNCDECL_RPL (strnlen
, size_t, (char const *__s
, size_t __maxlen
)
623 _GL_ARG_NONNULL ((1)));
624 _GL_CXXALIAS_RPL (strnlen
, size_t, (char const *__s
, size_t __maxlen
));
626 # if ! @HAVE_DECL_STRNLEN@
627 _GL_FUNCDECL_SYS (strnlen
, size_t, (char const *__s
, size_t __maxlen
)
629 _GL_ARG_NONNULL ((1)));
631 _GL_CXXALIAS_SYS (strnlen
, size_t, (char const *__s
, size_t __maxlen
));
633 _GL_CXXALIASWARN (strnlen
);
634 #elif defined GNULIB_POSIXCHECK
636 # if HAVE_RAW_DECL_STRNLEN
637 _GL_WARN_ON_USE (strnlen
, "strnlen is unportable - "
638 "use gnulib module strnlen for portability");
642 #if defined GNULIB_POSIXCHECK
643 /* strcspn() assumes the second argument is a list of single-byte characters.
644 Even in this simple case, it does not work with multibyte strings if the
645 locale encoding is GB18030 and one of the characters to be searched is a
648 /* Assume strcspn is always declared. */
649 _GL_WARN_ON_USE (strcspn
, "strcspn cannot work correctly on character strings "
650 "in multibyte locales - "
651 "use mbscspn if you care about internationalization");
654 /* Find the first occurrence in S of any character in ACCEPT. */
656 # if ! @HAVE_STRPBRK@
657 _GL_FUNCDECL_SYS (strpbrk
, char *, (char const *__s
, char const *__accept
)
659 _GL_ARG_NONNULL ((1, 2)));
661 /* On some systems, this function is defined as an overloaded function:
662 extern "C" { const char * strpbrk (const char *, const char *); }
663 extern "C++" { char * strpbrk (char *, const char *); } */
664 _GL_CXXALIAS_SYS_CAST2 (strpbrk
,
665 char *, (char const *__s
, char const *__accept
),
666 const char *, (char const *__s
, char const *__accept
));
667 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
668 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
669 || defined __clang__)
670 _GL_CXXALIASWARN1 (strpbrk
, char *, (char *__s
, char const *__accept
) throw ());
671 _GL_CXXALIASWARN1 (strpbrk
, char const *,
672 (char const *__s
, char const *__accept
) throw ());
673 # elif __GLIBC__ >= 2
674 _GL_CXXALIASWARN (strpbrk
);
676 # if defined GNULIB_POSIXCHECK
677 /* strpbrk() assumes the second argument is a list of single-byte characters.
678 Even in this simple case, it does not work with multibyte strings if the
679 locale encoding is GB18030 and one of the characters to be searched is a
682 _GL_WARN_ON_USE_CXX (strpbrk
,
683 const char *, char *, (const char *, const char *),
684 "strpbrk cannot work correctly on character strings "
685 "in multibyte locales - "
686 "use mbspbrk if you care about internationalization");
688 #elif defined GNULIB_POSIXCHECK
690 # if HAVE_RAW_DECL_STRPBRK
691 _GL_WARN_ON_USE_CXX (strpbrk
,
692 const char *, char *, (const char *, const char *),
693 "strpbrk is unportable - "
694 "use gnulib module strpbrk for portability");
698 #if defined GNULIB_POSIXCHECK
699 /* strspn() assumes the second argument is a list of single-byte characters.
700 Even in this simple case, it cannot work with multibyte strings. */
702 /* Assume strspn is always declared. */
703 _GL_WARN_ON_USE (strspn
, "strspn cannot work correctly on character strings "
704 "in multibyte locales - "
705 "use mbsspn if you care about internationalization");
708 #if defined GNULIB_POSIXCHECK
709 /* strrchr() does not work with multibyte strings if the locale encoding is
710 GB18030 and the character to be searched is a digit. */
712 /* Assume strrchr is always declared. */
713 _GL_WARN_ON_USE_CXX (strrchr
,
714 const char *, char *, (const char *, int),
715 "strrchr cannot work correctly on character strings "
716 "in some multibyte locales - "
717 "use mbsrchr if you care about internationalization");
720 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
721 If one is found, overwrite it with a NUL, and advance *STRINGP
722 to point to the next char after it. Otherwise, set *STRINGP to NULL.
723 If *STRINGP was already NULL, nothing happens.
724 Return the old value of *STRINGP.
726 This is a variant of strtok() that is multithread-safe and supports
729 Caveat: It modifies the original string.
730 Caveat: These functions cannot be used on constant strings.
731 Caveat: The identity of the delimiting character is lost.
732 Caveat: It doesn't work with multibyte strings unless all of the delimiter
733 characters are ASCII characters < 0x30.
735 See also strtok_r(). */
738 _GL_FUNCDECL_SYS (strsep
, char *,
739 (char **restrict __stringp
, char const *restrict __delim
)
740 _GL_ARG_NONNULL ((1, 2)));
742 _GL_CXXALIAS_SYS (strsep
, char *,
743 (char **restrict __stringp
, char const *restrict __delim
));
744 _GL_CXXALIASWARN (strsep
);
745 # if defined GNULIB_POSIXCHECK
747 _GL_WARN_ON_USE (strsep
, "strsep cannot work correctly on character strings "
748 "in multibyte locales - "
749 "use mbssep if you care about internationalization");
751 #elif defined GNULIB_POSIXCHECK
753 # if HAVE_RAW_DECL_STRSEP
754 _GL_WARN_ON_USE (strsep
, "strsep is unportable - "
755 "use gnulib module strsep for portability");
760 # if @REPLACE_STRSTR@
761 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
762 # define strstr rpl_strstr
764 _GL_FUNCDECL_RPL (strstr
, char *, (const char *haystack
, const char *needle
)
766 _GL_ARG_NONNULL ((1, 2)));
767 _GL_CXXALIAS_RPL (strstr
, char *, (const char *haystack
, const char *needle
));
769 /* On some systems, this function is defined as an overloaded function:
770 extern "C++" { const char * strstr (const char *, const char *); }
771 extern "C++" { char * strstr (char *, const char *); } */
772 _GL_CXXALIAS_SYS_CAST2 (strstr
,
773 char *, (const char *haystack
, const char *needle
),
774 const char *, (const char *haystack
, const char *needle
));
776 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
777 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
778 || defined __clang__)
779 _GL_CXXALIASWARN1 (strstr
, char *,
780 (char *haystack
, const char *needle
) throw ());
781 _GL_CXXALIASWARN1 (strstr
, const char *,
782 (const char *haystack
, const char *needle
) throw ());
783 # elif __GLIBC__ >= 2
784 _GL_CXXALIASWARN (strstr
);
786 #elif defined GNULIB_POSIXCHECK
787 /* strstr() does not work with multibyte strings if the locale encoding is
788 different from UTF-8:
789 POSIX says that it operates on "strings", and "string" in POSIX is defined
790 as a sequence of bytes, not of characters. */
792 /* Assume strstr is always declared. */
793 _GL_WARN_ON_USE (strstr
, "strstr is quadratic on many systems, and cannot "
794 "work correctly on character strings in most "
795 "multibyte locales - "
796 "use mbsstr if you care about internationalization, "
797 "or use strstr if you care about speed");
800 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
802 #if @GNULIB_STRCASESTR@
803 # if @REPLACE_STRCASESTR@
804 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
805 # define strcasestr rpl_strcasestr
807 _GL_FUNCDECL_RPL (strcasestr
, char *,
808 (const char *haystack
, const char *needle
)
810 _GL_ARG_NONNULL ((1, 2)));
811 _GL_CXXALIAS_RPL (strcasestr
, char *,
812 (const char *haystack
, const char *needle
));
814 # if ! @HAVE_STRCASESTR@
815 _GL_FUNCDECL_SYS (strcasestr
, char *,
816 (const char *haystack
, const char *needle
)
818 _GL_ARG_NONNULL ((1, 2)));
820 /* On some systems, this function is defined as an overloaded function:
821 extern "C++" { const char * strcasestr (const char *, const char *); }
822 extern "C++" { char * strcasestr (char *, const char *); } */
823 _GL_CXXALIAS_SYS_CAST2 (strcasestr
,
824 char *, (const char *haystack
, const char *needle
),
825 const char *, (const char *haystack
, const char *needle
));
827 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
828 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
829 || defined __clang__)
830 _GL_CXXALIASWARN1 (strcasestr
, char *,
831 (char *haystack
, const char *needle
) throw ());
832 _GL_CXXALIASWARN1 (strcasestr
, const char *,
833 (const char *haystack
, const char *needle
) throw ());
835 _GL_CXXALIASWARN (strcasestr
);
837 #elif defined GNULIB_POSIXCHECK
838 /* strcasestr() does not work with multibyte strings:
839 It is a glibc extension, and glibc implements it only for unibyte
842 # if HAVE_RAW_DECL_STRCASESTR
843 _GL_WARN_ON_USE (strcasestr
, "strcasestr does work correctly on character "
844 "strings in multibyte locales - "
845 "use mbscasestr if you care about "
846 "internationalization, or use c-strcasestr if you want "
847 "a locale independent function");
851 /* Parse S into tokens separated by characters in DELIM.
852 If S is NULL, the saved pointer in SAVE_PTR is used as
853 the next starting point. For example:
854 char s[] = "-abc-=-def";
856 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
857 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
858 x = strtok_r(NULL, "=", &sp); // x = NULL
861 This is a variant of strtok() that is multithread-safe.
863 For the POSIX documentation for this function, see:
864 https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html
866 Caveat: It modifies the original string.
867 Caveat: These functions cannot be used on constant strings.
868 Caveat: The identity of the delimiting character is lost.
869 Caveat: It doesn't work with multibyte strings unless all of the delimiter
870 characters are ASCII characters < 0x30.
872 See also strsep(). */
873 #if @GNULIB_STRTOK_R@
874 # if @REPLACE_STRTOK_R@
875 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
877 # define strtok_r rpl_strtok_r
879 _GL_FUNCDECL_RPL (strtok_r
, char *,
880 (char *restrict s
, char const *restrict delim
,
881 char **restrict save_ptr
)
882 _GL_ARG_NONNULL ((2, 3)));
883 _GL_CXXALIAS_RPL (strtok_r
, char *,
884 (char *restrict s
, char const *restrict delim
,
885 char **restrict save_ptr
));
887 # if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
890 # if ! @HAVE_DECL_STRTOK_R@
891 _GL_FUNCDECL_SYS (strtok_r
, char *,
892 (char *restrict s
, char const *restrict delim
,
893 char **restrict save_ptr
)
894 _GL_ARG_NONNULL ((2, 3)));
896 _GL_CXXALIAS_SYS (strtok_r
, char *,
897 (char *restrict s
, char const *restrict delim
,
898 char **restrict save_ptr
));
900 _GL_CXXALIASWARN (strtok_r
);
901 # if defined GNULIB_POSIXCHECK
902 _GL_WARN_ON_USE (strtok_r
, "strtok_r cannot work correctly on character "
903 "strings in multibyte locales - "
904 "use mbstok_r if you care about internationalization");
906 #elif defined GNULIB_POSIXCHECK
908 # if HAVE_RAW_DECL_STRTOK_R
909 _GL_WARN_ON_USE (strtok_r
, "strtok_r is unportable - "
910 "use gnulib module strtok_r for portability");
915 /* The following functions are not specified by POSIX. They are gnulib
919 /* Return the number of multibyte characters in the character string STRING.
920 This considers multibyte characters, unlike strlen, which counts bytes. */
921 # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
924 # if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
925 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
926 # define mbslen rpl_mbslen
928 _GL_FUNCDECL_RPL (mbslen
, size_t, (const char *string
)
930 _GL_ARG_NONNULL ((1)));
931 _GL_CXXALIAS_RPL (mbslen
, size_t, (const char *string
));
933 _GL_FUNCDECL_SYS (mbslen
, size_t, (const char *string
)
935 _GL_ARG_NONNULL ((1)));
936 _GL_CXXALIAS_SYS (mbslen
, size_t, (const char *string
));
938 _GL_CXXALIASWARN (mbslen
);
942 /* Return the number of multibyte characters in the character string starting
943 at STRING and ending at STRING + LEN. */
944 _GL_EXTERN_C
size_t mbsnlen (const char *string
, size_t len
)
946 _GL_ARG_NONNULL ((1));
950 /* Locate the first single-byte character C in the character string STRING,
951 and return a pointer to it. Return NULL if C is not found in STRING.
952 Unlike strchr(), this function works correctly in multibyte locales with
953 encodings such as GB18030. */
955 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
956 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */
958 _GL_FUNCDECL_RPL (mbschr
, char *, (const char *string
, int c
)
960 _GL_ARG_NONNULL ((1)));
961 _GL_CXXALIAS_RPL (mbschr
, char *, (const char *string
, int c
));
963 _GL_FUNCDECL_SYS (mbschr
, char *, (const char *string
, int c
)
965 _GL_ARG_NONNULL ((1)));
966 _GL_CXXALIAS_SYS (mbschr
, char *, (const char *string
, int c
));
968 _GL_CXXALIASWARN (mbschr
);
972 /* Locate the last single-byte character C in the character string STRING,
973 and return a pointer to it. Return NULL if C is not found in STRING.
974 Unlike strrchr(), this function works correctly in multibyte locales with
975 encodings such as GB18030. */
976 # if defined __hpux || defined __INTERIX
977 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
978 # define mbsrchr rpl_mbsrchr /* avoid collision with system function */
980 _GL_FUNCDECL_RPL (mbsrchr
, char *, (const char *string
, int c
)
982 _GL_ARG_NONNULL ((1)));
983 _GL_CXXALIAS_RPL (mbsrchr
, char *, (const char *string
, int c
));
985 _GL_FUNCDECL_SYS (mbsrchr
, char *, (const char *string
, int c
)
987 _GL_ARG_NONNULL ((1)));
988 _GL_CXXALIAS_SYS (mbsrchr
, char *, (const char *string
, int c
));
990 _GL_CXXALIASWARN (mbsrchr
);
994 /* Find the first occurrence of the character string NEEDLE in the character
995 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
996 Unlike strstr(), this function works correctly in multibyte locales with
997 encodings different from UTF-8. */
998 _GL_EXTERN_C
char * mbsstr (const char *haystack
, const char *needle
)
1000 _GL_ARG_NONNULL ((1, 2));
1003 #if @GNULIB_MBSCASECMP@
1004 /* Compare the character strings S1 and S2, ignoring case, returning less than,
1005 equal to or greater than zero if S1 is lexicographically less than, equal to
1007 Note: This function may, in multibyte locales, return 0 for strings of
1009 Unlike strcasecmp(), this function works correctly in multibyte locales. */
1010 _GL_EXTERN_C
int mbscasecmp (const char *s1
, const char *s2
)
1012 _GL_ARG_NONNULL ((1, 2));
1015 #if @GNULIB_MBSNCASECMP@
1016 /* Compare the initial segment of the character string S1 consisting of at most
1017 N characters with the initial segment of the character string S2 consisting
1018 of at most N characters, ignoring case, returning less than, equal to or
1019 greater than zero if the initial segment of S1 is lexicographically less
1020 than, equal to or greater than the initial segment of S2.
1021 Note: This function may, in multibyte locales, return 0 for initial segments
1022 of different lengths!
1023 Unlike strncasecmp(), this function works correctly in multibyte locales.
1024 But beware that N is not a byte count but a character count! */
1025 _GL_EXTERN_C
int mbsncasecmp (const char *s1
, const char *s2
, size_t n
)
1027 _GL_ARG_NONNULL ((1, 2));
1030 #if @GNULIB_MBSPCASECMP@
1031 /* Compare the initial segment of the character string STRING consisting of
1032 at most mbslen (PREFIX) characters with the character string PREFIX,
1033 ignoring case. If the two match, return a pointer to the first byte
1034 after this prefix in STRING. Otherwise, return NULL.
1035 Note: This function may, in multibyte locales, return non-NULL if STRING
1036 is of smaller length than PREFIX!
1037 Unlike strncasecmp(), this function works correctly in multibyte
1039 _GL_EXTERN_C
char * mbspcasecmp (const char *string
, const char *prefix
)
1041 _GL_ARG_NONNULL ((1, 2));
1044 #if @GNULIB_MBSCASESTR@
1045 /* Find the first occurrence of the character string NEEDLE in the character
1046 string HAYSTACK, using case-insensitive comparison.
1047 Note: This function may, in multibyte locales, return success even if
1048 strlen (haystack) < strlen (needle) !
1049 Unlike strcasestr(), this function works correctly in multibyte locales. */
1050 _GL_EXTERN_C
char * mbscasestr (const char *haystack
, const char *needle
)
1052 _GL_ARG_NONNULL ((1, 2));
1055 #if @GNULIB_MBSCSPN@
1056 /* Find the first occurrence in the character string STRING of any character
1057 in the character string ACCEPT. Return the number of bytes from the
1058 beginning of the string to this occurrence, or to the end of the string
1060 Unlike strcspn(), this function works correctly in multibyte locales. */
1061 _GL_EXTERN_C
size_t mbscspn (const char *string
, const char *accept
)
1063 _GL_ARG_NONNULL ((1, 2));
1066 #if @GNULIB_MBSPBRK@
1067 /* Find the first occurrence in the character string STRING of any character
1068 in the character string ACCEPT. Return the pointer to it, or NULL if none
1070 Unlike strpbrk(), this function works correctly in multibyte locales. */
1072 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1073 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1075 _GL_FUNCDECL_RPL (mbspbrk
, char *, (const char *string
, const char *accept
)
1077 _GL_ARG_NONNULL ((1, 2)));
1078 _GL_CXXALIAS_RPL (mbspbrk
, char *, (const char *string
, const char *accept
));
1080 _GL_FUNCDECL_SYS (mbspbrk
, char *, (const char *string
, const char *accept
)
1082 _GL_ARG_NONNULL ((1, 2)));
1083 _GL_CXXALIAS_SYS (mbspbrk
, char *, (const char *string
, const char *accept
));
1085 _GL_CXXALIASWARN (mbspbrk
);
1089 /* Find the first occurrence in the character string STRING of any character
1090 not in the character string REJECT. Return the number of bytes from the
1091 beginning of the string to this occurrence, or to the end of the string
1093 Unlike strspn(), this function works correctly in multibyte locales. */
1094 _GL_EXTERN_C
size_t mbsspn (const char *string
, const char *reject
)
1096 _GL_ARG_NONNULL ((1, 2));
1100 /* Search the next delimiter (multibyte character listed in the character
1101 string DELIM) starting at the character string *STRINGP.
1102 If one is found, overwrite it with a NUL, and advance *STRINGP to point
1103 to the next multibyte character after it. Otherwise, set *STRINGP to NULL.
1104 If *STRINGP was already NULL, nothing happens.
1105 Return the old value of *STRINGP.
1107 This is a variant of mbstok_r() that supports empty fields.
1109 Caveat: It modifies the original string.
1110 Caveat: These functions cannot be used on constant strings.
1111 Caveat: The identity of the delimiting character is lost.
1113 See also mbstok_r(). */
1114 _GL_EXTERN_C
char * mbssep (char **stringp
, const char *delim
)
1115 _GL_ARG_NONNULL ((1, 2));
1118 #if @GNULIB_MBSTOK_R@
1119 /* Parse the character string STRING into tokens separated by characters in
1120 the character string DELIM.
1121 If STRING is NULL, the saved pointer in SAVE_PTR is used as
1122 the next starting point. For example:
1123 char s[] = "-abc-=-def";
1125 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
1126 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
1127 x = mbstok_r(NULL, "=", &sp); // x = NULL
1128 // s = "abc\0-def\0"
1130 Caveat: It modifies the original string.
1131 Caveat: These functions cannot be used on constant strings.
1132 Caveat: The identity of the delimiting character is lost.
1134 See also mbssep(). */
1135 _GL_EXTERN_C
char * mbstok_r (char *restrict string
, const char *delim
,
1137 _GL_ARG_NONNULL ((2, 3));
1140 /* Map any int, typically from errno, into an error message. */
1141 #if @GNULIB_STRERROR@
1142 # if @REPLACE_STRERROR@
1143 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145 # define strerror rpl_strerror
1147 _GL_FUNCDECL_RPL (strerror
, char *, (int));
1148 _GL_CXXALIAS_RPL (strerror
, char *, (int));
1150 _GL_CXXALIAS_SYS (strerror
, char *, (int));
1153 _GL_CXXALIASWARN (strerror
);
1155 #elif defined GNULIB_POSIXCHECK
1157 /* Assume strerror is always declared. */
1158 _GL_WARN_ON_USE (strerror
, "strerror is unportable - "
1159 "use gnulib module strerror to guarantee non-NULL result");
1162 /* Map any int, typically from errno, into an error message. Multithread-safe.
1163 Uses the POSIX declaration, not the glibc declaration. */
1164 #if @GNULIB_STRERROR_R@
1165 # if @REPLACE_STRERROR_R@
1166 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1168 # define strerror_r rpl_strerror_r
1170 _GL_FUNCDECL_RPL (strerror_r
, int, (int errnum
, char *buf
, size_t buflen
)
1171 _GL_ARG_NONNULL ((2)));
1172 _GL_CXXALIAS_RPL (strerror_r
, int, (int errnum
, char *buf
, size_t buflen
));
1174 # if !@HAVE_DECL_STRERROR_R@
1175 _GL_FUNCDECL_SYS (strerror_r
, int, (int errnum
, char *buf
, size_t buflen
)
1176 _GL_ARG_NONNULL ((2)));
1178 _GL_CXXALIAS_SYS (strerror_r
, int, (int errnum
, char *buf
, size_t buflen
));
1180 # if @HAVE_DECL_STRERROR_R@
1181 _GL_CXXALIASWARN (strerror_r
);
1183 #elif defined GNULIB_POSIXCHECK
1185 # if HAVE_RAW_DECL_STRERROR_R
1186 _GL_WARN_ON_USE (strerror_r
, "strerror_r is unportable - "
1187 "use gnulib module strerror_r-posix for portability");
1191 /* Return the name of the system error code ERRNUM. */
1192 #if @GNULIB_STRERRORNAME_NP@
1193 # if @REPLACE_STRERRORNAME_NP@
1194 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1195 # undef strerrorname_np
1196 # define strerrorname_np rpl_strerrorname_np
1198 _GL_FUNCDECL_RPL (strerrorname_np
, const char *, (int errnum
));
1199 _GL_CXXALIAS_RPL (strerrorname_np
, const char *, (int errnum
));
1201 # if !@HAVE_STRERRORNAME_NP@
1202 _GL_FUNCDECL_SYS (strerrorname_np
, const char *, (int errnum
));
1204 _GL_CXXALIAS_SYS (strerrorname_np
, const char *, (int errnum
));
1206 _GL_CXXALIASWARN (strerrorname_np
);
1207 #elif defined GNULIB_POSIXCHECK
1208 # undef strerrorname_np
1209 # if HAVE_RAW_DECL_STRERRORNAME_NP
1210 _GL_WARN_ON_USE (strerrorname_np
, "strerrorname_np is unportable - "
1211 "use gnulib module strerrorname_np for portability");
1215 /* Return an abbreviation string for the signal number SIG. */
1216 #if @GNULIB_SIGABBREV_NP@
1217 # if ! @HAVE_SIGABBREV_NP@
1218 _GL_FUNCDECL_SYS (sigabbrev_np
, const char *, (int sig
));
1220 _GL_CXXALIAS_SYS (sigabbrev_np
, const char *, (int sig
));
1221 _GL_CXXALIASWARN (sigabbrev_np
);
1222 #elif defined GNULIB_POSIXCHECK
1223 # undef sigabbrev_np
1224 # if HAVE_RAW_DECL_SIGABBREV_NP
1225 _GL_WARN_ON_USE (sigabbrev_np
, "sigabbrev_np is unportable - "
1226 "use gnulib module sigabbrev_np for portability");
1230 /* Return an English description string for the signal number SIG. */
1231 #if @GNULIB_SIGDESCR_NP@
1232 # if ! @HAVE_SIGDESCR_NP@
1233 _GL_FUNCDECL_SYS (sigdescr_np
, const char *, (int sig
));
1235 _GL_CXXALIAS_SYS (sigdescr_np
, const char *, (int sig
));
1236 _GL_CXXALIASWARN (sigdescr_np
);
1237 #elif defined GNULIB_POSIXCHECK
1239 # if HAVE_RAW_DECL_SIGDESCR_NP
1240 _GL_WARN_ON_USE (sigdescr_np
, "sigdescr_np is unportable - "
1241 "use gnulib module sigdescr_np for portability");
1245 #if @GNULIB_STRSIGNAL@
1246 # if @REPLACE_STRSIGNAL@
1247 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1248 # define strsignal rpl_strsignal
1250 _GL_FUNCDECL_RPL (strsignal
, char *, (int __sig
));
1251 _GL_CXXALIAS_RPL (strsignal
, char *, (int __sig
));
1253 # if ! @HAVE_DECL_STRSIGNAL@
1254 _GL_FUNCDECL_SYS (strsignal
, char *, (int __sig
));
1256 /* Need to cast, because on Cygwin 1.5.x systems, the return type is
1258 _GL_CXXALIAS_SYS_CAST (strsignal
, char *, (int __sig
));
1260 _GL_CXXALIASWARN (strsignal
);
1261 #elif defined GNULIB_POSIXCHECK
1263 # if HAVE_RAW_DECL_STRSIGNAL
1264 _GL_WARN_ON_USE (strsignal
, "strsignal is unportable - "
1265 "use gnulib module strsignal for portability");
1269 #if @GNULIB_STRVERSCMP@
1270 # if !@HAVE_STRVERSCMP@
1271 _GL_FUNCDECL_SYS (strverscmp
, int, (const char *, const char *)
1273 _GL_ARG_NONNULL ((1, 2)));
1275 _GL_CXXALIAS_SYS (strverscmp
, int, (const char *, const char *));
1276 _GL_CXXALIASWARN (strverscmp
);
1277 #elif defined GNULIB_POSIXCHECK
1279 # if HAVE_RAW_DECL_STRVERSCMP
1280 _GL_WARN_ON_USE (strverscmp
, "strverscmp is unportable - "
1281 "use gnulib module strverscmp for portability");
1286 #endif /* _@GUARD_PREFIX@_STRING_H */
1287 #endif /* _@GUARD_PREFIX@_STRING_H */