string.in.h 40 KB

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