string.in.h 39 KB

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