string.in.h 39 KB

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