wchar.in.h 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  1. /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
  2. Copyright (C) 2007-2022 Free Software Foundation, Inc.
  3. This file is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as
  5. published by the Free Software Foundation; either version 2.1 of the
  6. License, or (at your option) any later version.
  7. This file 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 <https://www.gnu.org/licenses/>. */
  13. /* Written by Eric Blake. */
  14. /*
  15. * ISO C 99 <wchar.h> for platforms that have issues.
  16. * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wchar.h.html>
  17. *
  18. * For now, this just ensures proper prerequisite inclusion order and
  19. * the declaration of wcwidth().
  20. */
  21. #if __GNUC__ >= 3
  22. @PRAGMA_SYSTEM_HEADER@
  23. #endif
  24. @PRAGMA_COLUMNS@
  25. #if (((defined __need_mbstate_t || defined __need_wint_t) \
  26. && !defined __MINGW32__) \
  27. || (defined __hpux \
  28. && ((defined _INTTYPES_INCLUDED \
  29. && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
  30. || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
  31. || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
  32. || defined _GL_ALREADY_INCLUDING_WCHAR_H)
  33. /* Special invocation convention:
  34. - Inside glibc and uClibc header files, but not MinGW.
  35. - On HP-UX 11.00 we have a sequence of nested includes
  36. <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
  37. once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
  38. and once directly. In both situations 'wint_t' is not yet defined,
  39. therefore we cannot provide the function overrides; instead include only
  40. the system's <wchar.h>.
  41. - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
  42. <wchar.h> is actually processed, and that doesn't include 'mbstate_t'.
  43. - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
  44. the latter includes <wchar.h>. But here, we have no way to detect whether
  45. <wctype.h> is completely included or is still being included. */
  46. #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
  47. #else
  48. /* Normal invocation convention. */
  49. #ifndef _@GUARD_PREFIX@_WCHAR_H
  50. #define _GL_ALREADY_INCLUDING_WCHAR_H
  51. #if @HAVE_FEATURES_H@
  52. # include <features.h> /* for __GLIBC__ */
  53. #endif
  54. /* In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
  55. by <stddef.h>.
  56. But avoid namespace pollution on glibc systems. */
  57. #if !(defined __GLIBC__ && !defined __UCLIBC__)
  58. # include <stddef.h>
  59. #endif
  60. /* Include the original <wchar.h> if it exists.
  61. Some builds of uClibc lack it. */
  62. /* The include_next requires a split double-inclusion guard. */
  63. #if @HAVE_WCHAR_H@
  64. # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
  65. #endif
  66. #undef _GL_ALREADY_INCLUDING_WCHAR_H
  67. #ifndef _@GUARD_PREFIX@_WCHAR_H
  68. #define _@GUARD_PREFIX@_WCHAR_H
  69. /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
  70. that can be freed by passing them as the Ith argument to the
  71. function F. */
  72. #ifndef _GL_ATTRIBUTE_DEALLOC
  73. # if __GNUC__ >= 11
  74. # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
  75. # else
  76. # define _GL_ATTRIBUTE_DEALLOC(f, i)
  77. # endif
  78. #endif
  79. /* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
  80. can be freed via 'free'; it can be used only after declaring 'free'. */
  81. /* Applies to: functions. Cannot be used on inline functions. */
  82. #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
  83. # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
  84. #endif
  85. /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
  86. allocated memory. */
  87. /* Applies to: functions. */
  88. #ifndef _GL_ATTRIBUTE_MALLOC
  89. # if __GNUC__ >= 3 || defined __clang__
  90. # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
  91. # else
  92. # define _GL_ATTRIBUTE_MALLOC
  93. # endif
  94. #endif
  95. /* The __attribute__ feature is available in gcc versions 2.5 and later.
  96. The attribute __pure__ was added in gcc 2.96. */
  97. #ifndef _GL_ATTRIBUTE_PURE
  98. # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
  99. # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
  100. # else
  101. # define _GL_ATTRIBUTE_PURE /* empty */
  102. # endif
  103. #endif
  104. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  105. /* The definition of _GL_ARG_NONNULL is copied here. */
  106. /* The definition of _GL_WARN_ON_USE is copied here. */
  107. /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
  108. #if !@HAVE_WINT_T@ && !defined wint_t
  109. # define wint_t int
  110. # ifndef WEOF
  111. # define WEOF -1
  112. # endif
  113. #else
  114. /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
  115. <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
  116. wint_t must be "unchanged by default argument promotions". Override it. */
  117. # if @GNULIBHEADERS_OVERRIDE_WINT_T@
  118. # if !GNULIB_defined_wint_t
  119. # if @HAVE_CRTDEFS_H@
  120. # include <crtdefs.h>
  121. # else
  122. # include <stddef.h>
  123. # endif
  124. typedef unsigned int rpl_wint_t;
  125. # undef wint_t
  126. # define wint_t rpl_wint_t
  127. # define GNULIB_defined_wint_t 1
  128. # endif
  129. # endif
  130. # ifndef WEOF
  131. # define WEOF ((wint_t) -1)
  132. # endif
  133. #endif
  134. /* Override mbstate_t if it is too small.
  135. On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
  136. implementing mbrtowc for encodings like UTF-8.
  137. On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is
  138. large enough and overriding it would cause problems in C++ mode. */
  139. #if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
  140. # if !GNULIB_defined_mbstate_t
  141. # if !(defined _AIX || defined _MSC_VER)
  142. typedef int rpl_mbstate_t;
  143. # undef mbstate_t
  144. # define mbstate_t rpl_mbstate_t
  145. # endif
  146. # define GNULIB_defined_mbstate_t 1
  147. # endif
  148. #endif
  149. /* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
  150. been included yet. */
  151. #if @GNULIB_FREE_POSIX@
  152. # if (@REPLACE_FREE@ && !defined free \
  153. && !(defined __cplusplus && defined GNULIB_NAMESPACE))
  154. /* We can't do '#define free rpl_free' here. */
  155. _GL_EXTERN_C void rpl_free (void *);
  156. # undef _GL_ATTRIBUTE_DEALLOC_FREE
  157. # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
  158. # else
  159. # if defined _MSC_VER && !defined free
  160. _GL_EXTERN_C
  161. # if defined _DLL
  162. __declspec (dllimport)
  163. # endif
  164. void __cdecl free (void *);
  165. # else
  166. # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
  167. _GL_EXTERN_C void free (void *) throw ();
  168. # else
  169. _GL_EXTERN_C void free (void *);
  170. # endif
  171. # endif
  172. # endif
  173. #else
  174. # if defined _MSC_VER && !defined free
  175. _GL_EXTERN_C
  176. # if defined _DLL
  177. __declspec (dllimport)
  178. # endif
  179. void __cdecl free (void *);
  180. # else
  181. # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
  182. _GL_EXTERN_C void free (void *) throw ();
  183. # else
  184. _GL_EXTERN_C void free (void *);
  185. # endif
  186. # endif
  187. #endif
  188. /* Convert a single-byte character to a wide character. */
  189. #if @GNULIB_BTOWC@
  190. # if @REPLACE_BTOWC@
  191. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  192. # undef btowc
  193. # define btowc rpl_btowc
  194. # endif
  195. _GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
  196. _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
  197. # else
  198. # if !@HAVE_BTOWC@
  199. _GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
  200. # endif
  201. /* Need to cast, because on mingw, the return type is 'unsigned short'. */
  202. _GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
  203. # endif
  204. # if __GLIBC__ >= 2
  205. _GL_CXXALIASWARN (btowc);
  206. # endif
  207. #elif defined GNULIB_POSIXCHECK
  208. # undef btowc
  209. # if HAVE_RAW_DECL_BTOWC
  210. _GL_WARN_ON_USE (btowc, "btowc is unportable - "
  211. "use gnulib module btowc for portability");
  212. # endif
  213. #endif
  214. /* Convert a wide character to a single-byte character. */
  215. #if @GNULIB_WCTOB@
  216. # if @REPLACE_WCTOB@
  217. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  218. # undef wctob
  219. # define wctob rpl_wctob
  220. # endif
  221. _GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
  222. _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
  223. # else
  224. # if !defined wctob && !@HAVE_DECL_WCTOB@
  225. /* wctob is provided by gnulib, or wctob exists but is not declared. */
  226. _GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
  227. # endif
  228. _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
  229. # endif
  230. # if __GLIBC__ >= 2
  231. _GL_CXXALIASWARN (wctob);
  232. # endif
  233. #elif defined GNULIB_POSIXCHECK
  234. # undef wctob
  235. # if HAVE_RAW_DECL_WCTOB
  236. _GL_WARN_ON_USE (wctob, "wctob is unportable - "
  237. "use gnulib module wctob for portability");
  238. # endif
  239. #endif
  240. /* Test whether *PS is in the initial state. */
  241. #if @GNULIB_MBSINIT@
  242. # if @REPLACE_MBSINIT@
  243. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  244. # undef mbsinit
  245. # define mbsinit rpl_mbsinit
  246. # endif
  247. _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
  248. _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
  249. # else
  250. # if !@HAVE_MBSINIT@
  251. _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
  252. # endif
  253. _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
  254. # endif
  255. # if __GLIBC__ >= 2
  256. _GL_CXXALIASWARN (mbsinit);
  257. # endif
  258. #elif defined GNULIB_POSIXCHECK
  259. # undef mbsinit
  260. # if HAVE_RAW_DECL_MBSINIT
  261. _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
  262. "use gnulib module mbsinit for portability");
  263. # endif
  264. #endif
  265. /* Convert a multibyte character to a wide character. */
  266. #if @GNULIB_MBRTOWC@
  267. # if @REPLACE_MBRTOWC@
  268. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  269. # undef mbrtowc
  270. # define mbrtowc rpl_mbrtowc
  271. # endif
  272. _GL_FUNCDECL_RPL (mbrtowc, size_t,
  273. (wchar_t *restrict pwc, const char *restrict s, size_t n,
  274. mbstate_t *restrict ps));
  275. _GL_CXXALIAS_RPL (mbrtowc, size_t,
  276. (wchar_t *restrict pwc, const char *restrict s, size_t n,
  277. mbstate_t *restrict ps));
  278. # else
  279. # if !@HAVE_MBRTOWC@
  280. _GL_FUNCDECL_SYS (mbrtowc, size_t,
  281. (wchar_t *restrict pwc, const char *restrict s, size_t n,
  282. mbstate_t *restrict ps));
  283. # endif
  284. _GL_CXXALIAS_SYS (mbrtowc, size_t,
  285. (wchar_t *restrict pwc, const char *restrict s, size_t n,
  286. mbstate_t *restrict ps));
  287. # endif
  288. # if __GLIBC__ >= 2
  289. _GL_CXXALIASWARN (mbrtowc);
  290. # endif
  291. #elif defined GNULIB_POSIXCHECK
  292. # undef mbrtowc
  293. # if HAVE_RAW_DECL_MBRTOWC
  294. _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
  295. "use gnulib module mbrtowc for portability");
  296. # endif
  297. #endif
  298. /* Recognize a multibyte character. */
  299. #if @GNULIB_MBRLEN@
  300. # if @REPLACE_MBRLEN@
  301. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  302. # undef mbrlen
  303. # define mbrlen rpl_mbrlen
  304. # endif
  305. _GL_FUNCDECL_RPL (mbrlen, size_t,
  306. (const char *restrict s, size_t n, mbstate_t *restrict ps));
  307. _GL_CXXALIAS_RPL (mbrlen, size_t,
  308. (const char *restrict s, size_t n, mbstate_t *restrict ps));
  309. # else
  310. # if !@HAVE_MBRLEN@
  311. _GL_FUNCDECL_SYS (mbrlen, size_t,
  312. (const char *restrict s, size_t n, mbstate_t *restrict ps));
  313. # endif
  314. _GL_CXXALIAS_SYS (mbrlen, size_t,
  315. (const char *restrict s, size_t n, mbstate_t *restrict ps));
  316. # endif
  317. # if __GLIBC__ >= 2
  318. _GL_CXXALIASWARN (mbrlen);
  319. # endif
  320. #elif defined GNULIB_POSIXCHECK
  321. # undef mbrlen
  322. # if HAVE_RAW_DECL_MBRLEN
  323. _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
  324. "use gnulib module mbrlen for portability");
  325. # endif
  326. #endif
  327. /* Convert a string to a wide string. */
  328. #if @GNULIB_MBSRTOWCS@
  329. # if @REPLACE_MBSRTOWCS@
  330. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  331. # undef mbsrtowcs
  332. # define mbsrtowcs rpl_mbsrtowcs
  333. # endif
  334. _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
  335. (wchar_t *restrict dest,
  336. const char **restrict srcp, size_t len,
  337. mbstate_t *restrict ps)
  338. _GL_ARG_NONNULL ((2)));
  339. _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
  340. (wchar_t *restrict dest,
  341. const char **restrict srcp, size_t len,
  342. mbstate_t *restrict ps));
  343. # else
  344. # if !@HAVE_MBSRTOWCS@
  345. _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
  346. (wchar_t *restrict dest,
  347. const char **restrict srcp, size_t len,
  348. mbstate_t *restrict ps)
  349. _GL_ARG_NONNULL ((2)));
  350. # endif
  351. _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
  352. (wchar_t *restrict dest,
  353. const char **restrict srcp, size_t len,
  354. mbstate_t *restrict ps));
  355. # endif
  356. # if __GLIBC__ >= 2
  357. _GL_CXXALIASWARN (mbsrtowcs);
  358. # endif
  359. #elif defined GNULIB_POSIXCHECK
  360. # undef mbsrtowcs
  361. # if HAVE_RAW_DECL_MBSRTOWCS
  362. _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
  363. "use gnulib module mbsrtowcs for portability");
  364. # endif
  365. #endif
  366. /* Convert a string to a wide string. */
  367. #if @GNULIB_MBSNRTOWCS@
  368. # if @REPLACE_MBSNRTOWCS@
  369. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  370. # undef mbsnrtowcs
  371. # define mbsnrtowcs rpl_mbsnrtowcs
  372. # endif
  373. _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
  374. (wchar_t *restrict dest,
  375. const char **restrict srcp, size_t srclen, size_t len,
  376. mbstate_t *restrict ps)
  377. _GL_ARG_NONNULL ((2)));
  378. _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
  379. (wchar_t *restrict dest,
  380. const char **restrict srcp, size_t srclen, size_t len,
  381. mbstate_t *restrict ps));
  382. # else
  383. # if !@HAVE_MBSNRTOWCS@
  384. _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
  385. (wchar_t *restrict dest,
  386. const char **restrict srcp, size_t srclen, size_t len,
  387. mbstate_t *restrict ps)
  388. _GL_ARG_NONNULL ((2)));
  389. # endif
  390. _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
  391. (wchar_t *restrict dest,
  392. const char **restrict srcp, size_t srclen, size_t len,
  393. mbstate_t *restrict ps));
  394. # endif
  395. _GL_CXXALIASWARN (mbsnrtowcs);
  396. #elif defined GNULIB_POSIXCHECK
  397. # undef mbsnrtowcs
  398. # if HAVE_RAW_DECL_MBSNRTOWCS
  399. _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
  400. "use gnulib module mbsnrtowcs for portability");
  401. # endif
  402. #endif
  403. /* Convert a wide character to a multibyte character. */
  404. #if @GNULIB_WCRTOMB@
  405. # if @REPLACE_WCRTOMB@
  406. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  407. # undef wcrtomb
  408. # define wcrtomb rpl_wcrtomb
  409. # endif
  410. _GL_FUNCDECL_RPL (wcrtomb, size_t,
  411. (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
  412. _GL_CXXALIAS_RPL (wcrtomb, size_t,
  413. (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
  414. # else
  415. # if !@HAVE_WCRTOMB@
  416. _GL_FUNCDECL_SYS (wcrtomb, size_t,
  417. (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
  418. # endif
  419. _GL_CXXALIAS_SYS (wcrtomb, size_t,
  420. (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
  421. # endif
  422. # if __GLIBC__ >= 2
  423. _GL_CXXALIASWARN (wcrtomb);
  424. # endif
  425. #elif defined GNULIB_POSIXCHECK
  426. # undef wcrtomb
  427. # if HAVE_RAW_DECL_WCRTOMB
  428. _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
  429. "use gnulib module wcrtomb for portability");
  430. # endif
  431. #endif
  432. /* Convert a wide string to a string. */
  433. #if @GNULIB_WCSRTOMBS@
  434. # if @REPLACE_WCSRTOMBS@
  435. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  436. # undef wcsrtombs
  437. # define wcsrtombs rpl_wcsrtombs
  438. # endif
  439. _GL_FUNCDECL_RPL (wcsrtombs, size_t,
  440. (char *restrict dest, const wchar_t **restrict srcp,
  441. size_t len,
  442. mbstate_t *restrict ps)
  443. _GL_ARG_NONNULL ((2)));
  444. _GL_CXXALIAS_RPL (wcsrtombs, size_t,
  445. (char *restrict dest, const wchar_t **restrict srcp,
  446. size_t len,
  447. mbstate_t *restrict ps));
  448. # else
  449. # if !@HAVE_WCSRTOMBS@
  450. _GL_FUNCDECL_SYS (wcsrtombs, size_t,
  451. (char *restrict dest, const wchar_t **restrict srcp,
  452. size_t len,
  453. mbstate_t *restrict ps)
  454. _GL_ARG_NONNULL ((2)));
  455. # endif
  456. _GL_CXXALIAS_SYS (wcsrtombs, size_t,
  457. (char *restrict dest, const wchar_t **restrict srcp,
  458. size_t len,
  459. mbstate_t *restrict ps));
  460. # endif
  461. # if __GLIBC__ >= 2
  462. _GL_CXXALIASWARN (wcsrtombs);
  463. # endif
  464. #elif defined GNULIB_POSIXCHECK
  465. # undef wcsrtombs
  466. # if HAVE_RAW_DECL_WCSRTOMBS
  467. _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
  468. "use gnulib module wcsrtombs for portability");
  469. # endif
  470. #endif
  471. /* Convert a wide string to a string. */
  472. #if @GNULIB_WCSNRTOMBS@
  473. # if @REPLACE_WCSNRTOMBS@
  474. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  475. # undef wcsnrtombs
  476. # define wcsnrtombs rpl_wcsnrtombs
  477. # endif
  478. _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
  479. (char *restrict dest,
  480. const wchar_t **restrict srcp, size_t srclen,
  481. size_t len,
  482. mbstate_t *restrict ps)
  483. _GL_ARG_NONNULL ((2)));
  484. _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
  485. (char *restrict dest,
  486. const wchar_t **restrict srcp, size_t srclen,
  487. size_t len,
  488. mbstate_t *restrict ps));
  489. # else
  490. # if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun)
  491. _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
  492. (char *restrict dest,
  493. const wchar_t **restrict srcp, size_t srclen,
  494. size_t len,
  495. mbstate_t *restrict ps)
  496. _GL_ARG_NONNULL ((2)));
  497. # endif
  498. _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
  499. (char *restrict dest,
  500. const wchar_t **restrict srcp, size_t srclen,
  501. size_t len,
  502. mbstate_t *restrict ps));
  503. # endif
  504. # if __GLIBC__ >= 2
  505. _GL_CXXALIASWARN (wcsnrtombs);
  506. # endif
  507. #elif defined GNULIB_POSIXCHECK
  508. # undef wcsnrtombs
  509. # if HAVE_RAW_DECL_WCSNRTOMBS
  510. _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
  511. "use gnulib module wcsnrtombs for portability");
  512. # endif
  513. #endif
  514. /* Return the number of screen columns needed for WC. */
  515. #if @GNULIB_WCWIDTH@
  516. # if @REPLACE_WCWIDTH@
  517. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  518. # undef wcwidth
  519. # define wcwidth rpl_wcwidth
  520. # endif
  521. _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
  522. _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
  523. # else
  524. # if !@HAVE_DECL_WCWIDTH@
  525. /* wcwidth exists but is not declared. */
  526. _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
  527. # endif
  528. _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
  529. # endif
  530. # if __GLIBC__ >= 2
  531. _GL_CXXALIASWARN (wcwidth);
  532. # endif
  533. #elif defined GNULIB_POSIXCHECK
  534. # undef wcwidth
  535. # if HAVE_RAW_DECL_WCWIDTH
  536. _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
  537. "use gnulib module wcwidth for portability");
  538. # endif
  539. #endif
  540. /* Search N wide characters of S for C. */
  541. #if @GNULIB_WMEMCHR@
  542. # if !@HAVE_WMEMCHR@
  543. _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n)
  544. _GL_ATTRIBUTE_PURE);
  545. # endif
  546. /* On some systems, this function is defined as an overloaded function:
  547. extern "C++" {
  548. const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
  549. wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
  550. } */
  551. _GL_CXXALIAS_SYS_CAST2 (wmemchr,
  552. wchar_t *, (const wchar_t *, wchar_t, size_t),
  553. const wchar_t *, (const wchar_t *, wchar_t, size_t));
  554. # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
  555. && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
  556. _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
  557. _GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
  558. (const wchar_t *s, wchar_t c, size_t n));
  559. # elif __GLIBC__ >= 2
  560. _GL_CXXALIASWARN (wmemchr);
  561. # endif
  562. #elif defined GNULIB_POSIXCHECK
  563. # undef wmemchr
  564. # if HAVE_RAW_DECL_WMEMCHR
  565. _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
  566. "use gnulib module wmemchr for portability");
  567. # endif
  568. #endif
  569. /* Compare N wide characters of S1 and S2. */
  570. #if @GNULIB_WMEMCMP@
  571. # if !@HAVE_WMEMCMP@
  572. _GL_FUNCDECL_SYS (wmemcmp, int,
  573. (const wchar_t *s1, const wchar_t *s2, size_t n)
  574. _GL_ATTRIBUTE_PURE);
  575. # endif
  576. _GL_CXXALIAS_SYS (wmemcmp, int,
  577. (const wchar_t *s1, const wchar_t *s2, size_t n));
  578. # if __GLIBC__ >= 2
  579. _GL_CXXALIASWARN (wmemcmp);
  580. # endif
  581. #elif defined GNULIB_POSIXCHECK
  582. # undef wmemcmp
  583. # if HAVE_RAW_DECL_WMEMCMP
  584. _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
  585. "use gnulib module wmemcmp for portability");
  586. # endif
  587. #endif
  588. /* Copy N wide characters of SRC to DEST. */
  589. #if @GNULIB_WMEMCPY@
  590. # if !@HAVE_WMEMCPY@
  591. _GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
  592. (wchar_t *restrict dest,
  593. const wchar_t *restrict src, size_t n));
  594. # endif
  595. _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
  596. (wchar_t *restrict dest,
  597. const wchar_t *restrict src, size_t n));
  598. # if __GLIBC__ >= 2
  599. _GL_CXXALIASWARN (wmemcpy);
  600. # endif
  601. #elif defined GNULIB_POSIXCHECK
  602. # undef wmemcpy
  603. # if HAVE_RAW_DECL_WMEMCPY
  604. _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
  605. "use gnulib module wmemcpy for portability");
  606. # endif
  607. #endif
  608. /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
  609. overlapping memory areas. */
  610. #if @GNULIB_WMEMMOVE@
  611. # if !@HAVE_WMEMMOVE@
  612. _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
  613. (wchar_t *dest, const wchar_t *src, size_t n));
  614. # endif
  615. _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
  616. (wchar_t *dest, const wchar_t *src, size_t n));
  617. # if __GLIBC__ >= 2
  618. _GL_CXXALIASWARN (wmemmove);
  619. # endif
  620. #elif defined GNULIB_POSIXCHECK
  621. # undef wmemmove
  622. # if HAVE_RAW_DECL_WMEMMOVE
  623. _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
  624. "use gnulib module wmemmove for portability");
  625. # endif
  626. #endif
  627. /* Copy N wide characters of SRC to DEST.
  628. Return pointer to wide characters after the last written wide character. */
  629. #if @GNULIB_WMEMPCPY@
  630. # if !@HAVE_WMEMPCPY@
  631. _GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
  632. (wchar_t *restrict dest,
  633. const wchar_t *restrict src, size_t n));
  634. # endif
  635. _GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
  636. (wchar_t *restrict dest,
  637. const wchar_t *restrict src, size_t n));
  638. # if __GLIBC__ >= 2
  639. _GL_CXXALIASWARN (wmempcpy);
  640. # endif
  641. #elif defined GNULIB_POSIXCHECK
  642. # undef wmempcpy
  643. # if HAVE_RAW_DECL_WMEMPCPY
  644. _GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
  645. "use gnulib module wmempcpy for portability");
  646. # endif
  647. #endif
  648. /* Set N wide characters of S to C. */
  649. #if @GNULIB_WMEMSET@
  650. # if !@HAVE_WMEMSET@
  651. _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
  652. # endif
  653. _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
  654. # if __GLIBC__ >= 2
  655. _GL_CXXALIASWARN (wmemset);
  656. # endif
  657. #elif defined GNULIB_POSIXCHECK
  658. # undef wmemset
  659. # if HAVE_RAW_DECL_WMEMSET
  660. _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
  661. "use gnulib module wmemset for portability");
  662. # endif
  663. #endif
  664. /* Return the number of wide characters in S. */
  665. #if @GNULIB_WCSLEN@
  666. # if !@HAVE_WCSLEN@
  667. _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE);
  668. # endif
  669. _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
  670. # if __GLIBC__ >= 2
  671. _GL_CXXALIASWARN (wcslen);
  672. # endif
  673. #elif defined GNULIB_POSIXCHECK
  674. # undef wcslen
  675. # if HAVE_RAW_DECL_WCSLEN
  676. _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
  677. "use gnulib module wcslen for portability");
  678. # endif
  679. #endif
  680. /* Return the number of wide characters in S, but at most MAXLEN. */
  681. #if @GNULIB_WCSNLEN@
  682. # if !@HAVE_WCSNLEN@
  683. _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)
  684. _GL_ATTRIBUTE_PURE);
  685. # endif
  686. _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
  687. _GL_CXXALIASWARN (wcsnlen);
  688. #elif defined GNULIB_POSIXCHECK
  689. # undef wcsnlen
  690. # if HAVE_RAW_DECL_WCSNLEN
  691. _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
  692. "use gnulib module wcsnlen for portability");
  693. # endif
  694. #endif
  695. /* Copy SRC to DEST. */
  696. #if @GNULIB_WCSCPY@
  697. # if !@HAVE_WCSCPY@
  698. _GL_FUNCDECL_SYS (wcscpy, wchar_t *,
  699. (wchar_t *restrict dest, const wchar_t *restrict src));
  700. # endif
  701. _GL_CXXALIAS_SYS (wcscpy, wchar_t *,
  702. (wchar_t *restrict dest, const wchar_t *restrict src));
  703. # if __GLIBC__ >= 2
  704. _GL_CXXALIASWARN (wcscpy);
  705. # endif
  706. #elif defined GNULIB_POSIXCHECK
  707. # undef wcscpy
  708. # if HAVE_RAW_DECL_WCSCPY
  709. _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
  710. "use gnulib module wcscpy for portability");
  711. # endif
  712. #endif
  713. /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
  714. #if @GNULIB_WCPCPY@
  715. # if !@HAVE_WCPCPY@
  716. _GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
  717. (wchar_t *restrict dest, const wchar_t *restrict src));
  718. # endif
  719. _GL_CXXALIAS_SYS (wcpcpy, wchar_t *,
  720. (wchar_t *restrict dest, const wchar_t *restrict src));
  721. _GL_CXXALIASWARN (wcpcpy);
  722. #elif defined GNULIB_POSIXCHECK
  723. # undef wcpcpy
  724. # if HAVE_RAW_DECL_WCPCPY
  725. _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
  726. "use gnulib module wcpcpy for portability");
  727. # endif
  728. #endif
  729. /* Copy no more than N wide characters of SRC to DEST. */
  730. #if @GNULIB_WCSNCPY@
  731. # if !@HAVE_WCSNCPY@
  732. _GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
  733. (wchar_t *restrict dest,
  734. const wchar_t *restrict src, size_t n));
  735. # endif
  736. _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
  737. (wchar_t *restrict dest,
  738. const wchar_t *restrict src, size_t n));
  739. # if __GLIBC__ >= 2
  740. _GL_CXXALIASWARN (wcsncpy);
  741. # endif
  742. #elif defined GNULIB_POSIXCHECK
  743. # undef wcsncpy
  744. # if HAVE_RAW_DECL_WCSNCPY
  745. _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
  746. "use gnulib module wcsncpy for portability");
  747. # endif
  748. #endif
  749. /* Copy no more than N characters of SRC to DEST, returning the address of
  750. the last character written into DEST. */
  751. #if @GNULIB_WCPNCPY@
  752. # if !@HAVE_WCPNCPY@
  753. _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
  754. (wchar_t *restrict dest,
  755. const wchar_t *restrict src, size_t n));
  756. # endif
  757. _GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
  758. (wchar_t *restrict dest,
  759. const wchar_t *restrict src, size_t n));
  760. _GL_CXXALIASWARN (wcpncpy);
  761. #elif defined GNULIB_POSIXCHECK
  762. # undef wcpncpy
  763. # if HAVE_RAW_DECL_WCPNCPY
  764. _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
  765. "use gnulib module wcpncpy for portability");
  766. # endif
  767. #endif
  768. /* Append SRC onto DEST. */
  769. #if @GNULIB_WCSCAT@
  770. # if !@HAVE_WCSCAT@
  771. _GL_FUNCDECL_SYS (wcscat, wchar_t *,
  772. (wchar_t *restrict dest, const wchar_t *restrict src));
  773. # endif
  774. _GL_CXXALIAS_SYS (wcscat, wchar_t *,
  775. (wchar_t *restrict dest, const wchar_t *restrict src));
  776. # if __GLIBC__ >= 2
  777. _GL_CXXALIASWARN (wcscat);
  778. # endif
  779. #elif defined GNULIB_POSIXCHECK
  780. # undef wcscat
  781. # if HAVE_RAW_DECL_WCSCAT
  782. _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
  783. "use gnulib module wcscat for portability");
  784. # endif
  785. #endif
  786. /* Append no more than N wide characters of SRC onto DEST. */
  787. #if @GNULIB_WCSNCAT@
  788. # if !@HAVE_WCSNCAT@
  789. _GL_FUNCDECL_SYS (wcsncat, wchar_t *,
  790. (wchar_t *restrict dest, const wchar_t *restrict src,
  791. size_t n));
  792. # endif
  793. _GL_CXXALIAS_SYS (wcsncat, wchar_t *,
  794. (wchar_t *restrict dest, const wchar_t *restrict src,
  795. size_t n));
  796. # if __GLIBC__ >= 2
  797. _GL_CXXALIASWARN (wcsncat);
  798. # endif
  799. #elif defined GNULIB_POSIXCHECK
  800. # undef wcsncat
  801. # if HAVE_RAW_DECL_WCSNCAT
  802. _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
  803. "use gnulib module wcsncat for portability");
  804. # endif
  805. #endif
  806. /* Compare S1 and S2. */
  807. #if @GNULIB_WCSCMP@
  808. # if !@HAVE_WCSCMP@
  809. _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
  810. _GL_ATTRIBUTE_PURE);
  811. # endif
  812. _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
  813. # if __GLIBC__ >= 2
  814. _GL_CXXALIASWARN (wcscmp);
  815. # endif
  816. #elif defined GNULIB_POSIXCHECK
  817. # undef wcscmp
  818. # if HAVE_RAW_DECL_WCSCMP
  819. _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
  820. "use gnulib module wcscmp for portability");
  821. # endif
  822. #endif
  823. /* Compare no more than N wide characters of S1 and S2. */
  824. #if @GNULIB_WCSNCMP@
  825. # if !@HAVE_WCSNCMP@
  826. _GL_FUNCDECL_SYS (wcsncmp, int,
  827. (const wchar_t *s1, const wchar_t *s2, size_t n)
  828. _GL_ATTRIBUTE_PURE);
  829. # endif
  830. _GL_CXXALIAS_SYS (wcsncmp, int,
  831. (const wchar_t *s1, const wchar_t *s2, size_t n));
  832. # if __GLIBC__ >= 2
  833. _GL_CXXALIASWARN (wcsncmp);
  834. # endif
  835. #elif defined GNULIB_POSIXCHECK
  836. # undef wcsncmp
  837. # if HAVE_RAW_DECL_WCSNCMP
  838. _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
  839. "use gnulib module wcsncmp for portability");
  840. # endif
  841. #endif
  842. /* Compare S1 and S2, ignoring case. */
  843. #if @GNULIB_WCSCASECMP@
  844. # if !@HAVE_WCSCASECMP@
  845. _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)
  846. _GL_ATTRIBUTE_PURE);
  847. # endif
  848. _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
  849. _GL_CXXALIASWARN (wcscasecmp);
  850. #elif defined GNULIB_POSIXCHECK
  851. # undef wcscasecmp
  852. # if HAVE_RAW_DECL_WCSCASECMP
  853. _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
  854. "use gnulib module wcscasecmp for portability");
  855. # endif
  856. #endif
  857. /* Compare no more than N chars of S1 and S2, ignoring case. */
  858. #if @GNULIB_WCSNCASECMP@
  859. # if !@HAVE_WCSNCASECMP@
  860. _GL_FUNCDECL_SYS (wcsncasecmp, int,
  861. (const wchar_t *s1, const wchar_t *s2, size_t n)
  862. _GL_ATTRIBUTE_PURE);
  863. # endif
  864. _GL_CXXALIAS_SYS (wcsncasecmp, int,
  865. (const wchar_t *s1, const wchar_t *s2, size_t n));
  866. _GL_CXXALIASWARN (wcsncasecmp);
  867. #elif defined GNULIB_POSIXCHECK
  868. # undef wcsncasecmp
  869. # if HAVE_RAW_DECL_WCSNCASECMP
  870. _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
  871. "use gnulib module wcsncasecmp for portability");
  872. # endif
  873. #endif
  874. /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
  875. category of the current locale. */
  876. #if @GNULIB_WCSCOLL@
  877. # if !@HAVE_WCSCOLL@
  878. _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
  879. # endif
  880. _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
  881. # if __GLIBC__ >= 2
  882. _GL_CXXALIASWARN (wcscoll);
  883. # endif
  884. #elif defined GNULIB_POSIXCHECK
  885. # undef wcscoll
  886. # if HAVE_RAW_DECL_WCSCOLL
  887. _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
  888. "use gnulib module wcscoll for portability");
  889. # endif
  890. #endif
  891. /* Transform S2 into array pointed to by S1 such that if wcscmp is applied
  892. to two transformed strings the result is the as applying 'wcscoll' to the
  893. original strings. */
  894. #if @GNULIB_WCSXFRM@
  895. # if !@HAVE_WCSXFRM@
  896. _GL_FUNCDECL_SYS (wcsxfrm, size_t,
  897. (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
  898. # endif
  899. _GL_CXXALIAS_SYS (wcsxfrm, size_t,
  900. (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
  901. # if __GLIBC__ >= 2
  902. _GL_CXXALIASWARN (wcsxfrm);
  903. # endif
  904. #elif defined GNULIB_POSIXCHECK
  905. # undef wcsxfrm
  906. # if HAVE_RAW_DECL_WCSXFRM
  907. _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
  908. "use gnulib module wcsxfrm for portability");
  909. # endif
  910. #endif
  911. /* Duplicate S, returning an identical malloc'd string. */
  912. #if @GNULIB_WCSDUP@
  913. # if defined _WIN32 && !defined __CYGWIN__
  914. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  915. # undef wcsdup
  916. # define wcsdup _wcsdup
  917. # endif
  918. _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
  919. # else
  920. # if !@HAVE_WCSDUP@ || __GNUC__ >= 11
  921. _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
  922. (const wchar_t *s)
  923. _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
  924. # endif
  925. _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
  926. # endif
  927. _GL_CXXALIASWARN (wcsdup);
  928. #else
  929. # if __GNUC__ >= 11 && !defined wcsdup
  930. /* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
  931. _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
  932. (const wchar_t *s)
  933. _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
  934. # endif
  935. # if defined GNULIB_POSIXCHECK
  936. # undef wcsdup
  937. # if HAVE_RAW_DECL_WCSDUP
  938. _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
  939. "use gnulib module wcsdup for portability");
  940. # endif
  941. # elif @GNULIB_MDA_WCSDUP@
  942. /* On native Windows, map 'wcsdup' to '_wcsdup', so that -loldnames is not
  943. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  944. platforms by defining GNULIB_NAMESPACE::wcsdup always. */
  945. # if defined _WIN32 && !defined __CYGWIN__
  946. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  947. # undef wcsdup
  948. # define wcsdup _wcsdup
  949. # endif
  950. _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
  951. # else
  952. _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
  953. (const wchar_t *s)
  954. _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
  955. # if @HAVE_DECL_WCSDUP@
  956. _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
  957. # endif
  958. # endif
  959. # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_WCSDUP@
  960. _GL_CXXALIASWARN (wcsdup);
  961. # endif
  962. # endif
  963. #endif
  964. /* Find the first occurrence of WC in WCS. */
  965. #if @GNULIB_WCSCHR@
  966. # if !@HAVE_WCSCHR@
  967. _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
  968. _GL_ATTRIBUTE_PURE);
  969. # endif
  970. /* On some systems, this function is defined as an overloaded function:
  971. extern "C++" {
  972. const wchar_t * std::wcschr (const wchar_t *, wchar_t);
  973. wchar_t * std::wcschr (wchar_t *, wchar_t);
  974. } */
  975. _GL_CXXALIAS_SYS_CAST2 (wcschr,
  976. wchar_t *, (const wchar_t *, wchar_t),
  977. const wchar_t *, (const wchar_t *, wchar_t));
  978. # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
  979. && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
  980. _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
  981. _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
  982. # elif __GLIBC__ >= 2
  983. _GL_CXXALIASWARN (wcschr);
  984. # endif
  985. #elif defined GNULIB_POSIXCHECK
  986. # undef wcschr
  987. # if HAVE_RAW_DECL_WCSCHR
  988. _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
  989. "use gnulib module wcschr for portability");
  990. # endif
  991. #endif
  992. /* Find the last occurrence of WC in WCS. */
  993. #if @GNULIB_WCSRCHR@
  994. # if !@HAVE_WCSRCHR@
  995. _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
  996. _GL_ATTRIBUTE_PURE);
  997. # endif
  998. /* On some systems, this function is defined as an overloaded function:
  999. extern "C++" {
  1000. const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
  1001. wchar_t * std::wcsrchr (wchar_t *, wchar_t);
  1002. } */
  1003. _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
  1004. wchar_t *, (const wchar_t *, wchar_t),
  1005. const wchar_t *, (const wchar_t *, wchar_t));
  1006. # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
  1007. && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
  1008. _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
  1009. _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
  1010. # elif __GLIBC__ >= 2
  1011. _GL_CXXALIASWARN (wcsrchr);
  1012. # endif
  1013. #elif defined GNULIB_POSIXCHECK
  1014. # undef wcsrchr
  1015. # if HAVE_RAW_DECL_WCSRCHR
  1016. _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
  1017. "use gnulib module wcsrchr for portability");
  1018. # endif
  1019. #endif
  1020. /* Return the length of the initial segmet of WCS which consists entirely
  1021. of wide characters not in REJECT. */
  1022. #if @GNULIB_WCSCSPN@
  1023. # if !@HAVE_WCSCSPN@
  1024. _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)
  1025. _GL_ATTRIBUTE_PURE);
  1026. # endif
  1027. _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
  1028. # if __GLIBC__ >= 2
  1029. _GL_CXXALIASWARN (wcscspn);
  1030. # endif
  1031. #elif defined GNULIB_POSIXCHECK
  1032. # undef wcscspn
  1033. # if HAVE_RAW_DECL_WCSCSPN
  1034. _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
  1035. "use gnulib module wcscspn for portability");
  1036. # endif
  1037. #endif
  1038. /* Return the length of the initial segmet of WCS which consists entirely
  1039. of wide characters in ACCEPT. */
  1040. #if @GNULIB_WCSSPN@
  1041. # if !@HAVE_WCSSPN@
  1042. _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)
  1043. _GL_ATTRIBUTE_PURE);
  1044. # endif
  1045. _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
  1046. # if __GLIBC__ >= 2
  1047. _GL_CXXALIASWARN (wcsspn);
  1048. # endif
  1049. #elif defined GNULIB_POSIXCHECK
  1050. # undef wcsspn
  1051. # if HAVE_RAW_DECL_WCSSPN
  1052. _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
  1053. "use gnulib module wcsspn for portability");
  1054. # endif
  1055. #endif
  1056. /* Find the first occurrence in WCS of any character in ACCEPT. */
  1057. #if @GNULIB_WCSPBRK@
  1058. # if !@HAVE_WCSPBRK@
  1059. _GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
  1060. (const wchar_t *wcs, const wchar_t *accept)
  1061. _GL_ATTRIBUTE_PURE);
  1062. # endif
  1063. /* On some systems, this function is defined as an overloaded function:
  1064. extern "C++" {
  1065. const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
  1066. wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
  1067. } */
  1068. _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
  1069. wchar_t *, (const wchar_t *, const wchar_t *),
  1070. const wchar_t *, (const wchar_t *, const wchar_t *));
  1071. # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
  1072. && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
  1073. _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
  1074. (wchar_t *wcs, const wchar_t *accept));
  1075. _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
  1076. (const wchar_t *wcs, const wchar_t *accept));
  1077. # elif __GLIBC__ >= 2
  1078. _GL_CXXALIASWARN (wcspbrk);
  1079. # endif
  1080. #elif defined GNULIB_POSIXCHECK
  1081. # undef wcspbrk
  1082. # if HAVE_RAW_DECL_WCSPBRK
  1083. _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
  1084. "use gnulib module wcspbrk for portability");
  1085. # endif
  1086. #endif
  1087. /* Find the first occurrence of NEEDLE in HAYSTACK. */
  1088. #if @GNULIB_WCSSTR@
  1089. # if !@HAVE_WCSSTR@
  1090. _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
  1091. (const wchar_t *restrict haystack,
  1092. const wchar_t *restrict needle)
  1093. _GL_ATTRIBUTE_PURE);
  1094. # endif
  1095. /* On some systems, this function is defined as an overloaded function:
  1096. extern "C++" {
  1097. const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
  1098. wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
  1099. } */
  1100. _GL_CXXALIAS_SYS_CAST2 (wcsstr,
  1101. wchar_t *,
  1102. (const wchar_t *restrict, const wchar_t *restrict),
  1103. const wchar_t *,
  1104. (const wchar_t *restrict, const wchar_t *restrict));
  1105. # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
  1106. && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
  1107. _GL_CXXALIASWARN1 (wcsstr, wchar_t *,
  1108. (wchar_t *restrict haystack,
  1109. const wchar_t *restrict needle));
  1110. _GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
  1111. (const wchar_t *restrict haystack,
  1112. const wchar_t *restrict needle));
  1113. # elif __GLIBC__ >= 2
  1114. _GL_CXXALIASWARN (wcsstr);
  1115. # endif
  1116. #elif defined GNULIB_POSIXCHECK
  1117. # undef wcsstr
  1118. # if HAVE_RAW_DECL_WCSSTR
  1119. _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
  1120. "use gnulib module wcsstr for portability");
  1121. # endif
  1122. #endif
  1123. /* Divide WCS into tokens separated by characters in DELIM. */
  1124. #if @GNULIB_WCSTOK@
  1125. # if @REPLACE_WCSTOK@
  1126. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1127. # undef wcstok
  1128. # define wcstok rpl_wcstok
  1129. # endif
  1130. _GL_FUNCDECL_RPL (wcstok, wchar_t *,
  1131. (wchar_t *restrict wcs, const wchar_t *restrict delim,
  1132. wchar_t **restrict ptr));
  1133. _GL_CXXALIAS_RPL (wcstok, wchar_t *,
  1134. (wchar_t *restrict wcs, const wchar_t *restrict delim,
  1135. wchar_t **restrict ptr));
  1136. # else
  1137. # if !@HAVE_WCSTOK@
  1138. _GL_FUNCDECL_SYS (wcstok, wchar_t *,
  1139. (wchar_t *restrict wcs, const wchar_t *restrict delim,
  1140. wchar_t **restrict ptr));
  1141. # endif
  1142. _GL_CXXALIAS_SYS (wcstok, wchar_t *,
  1143. (wchar_t *restrict wcs, const wchar_t *restrict delim,
  1144. wchar_t **restrict ptr));
  1145. # endif
  1146. # if __GLIBC__ >= 2
  1147. _GL_CXXALIASWARN (wcstok);
  1148. # endif
  1149. #elif defined GNULIB_POSIXCHECK
  1150. # undef wcstok
  1151. # if HAVE_RAW_DECL_WCSTOK
  1152. _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
  1153. "use gnulib module wcstok for portability");
  1154. # endif
  1155. #endif
  1156. /* Determine number of column positions required for first N wide
  1157. characters (or fewer if S ends before this) in S. */
  1158. #if @GNULIB_WCSWIDTH@
  1159. # if @REPLACE_WCSWIDTH@
  1160. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1161. # undef wcswidth
  1162. # define wcswidth rpl_wcswidth
  1163. # endif
  1164. _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n)
  1165. _GL_ATTRIBUTE_PURE);
  1166. _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
  1167. # else
  1168. # if !@HAVE_WCSWIDTH@
  1169. _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n)
  1170. _GL_ATTRIBUTE_PURE);
  1171. # endif
  1172. _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
  1173. # endif
  1174. # if __GLIBC__ >= 2
  1175. _GL_CXXALIASWARN (wcswidth);
  1176. # endif
  1177. #elif defined GNULIB_POSIXCHECK
  1178. # undef wcswidth
  1179. # if HAVE_RAW_DECL_WCSWIDTH
  1180. _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
  1181. "use gnulib module wcswidth for portability");
  1182. # endif
  1183. #endif
  1184. /* Convert *TP to a date and time wide string. See
  1185. <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
  1186. #if @GNULIB_WCSFTIME@
  1187. # if @REPLACE_WCSFTIME@
  1188. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1189. # undef wcsftime
  1190. # define wcsftime rpl_wcsftime
  1191. # endif
  1192. _GL_FUNCDECL_RPL (wcsftime, size_t,
  1193. (wchar_t *restrict __buf, size_t __bufsize,
  1194. const wchar_t *restrict __fmt,
  1195. const struct tm *restrict __tp)
  1196. _GL_ARG_NONNULL ((1, 3, 4)));
  1197. _GL_CXXALIAS_RPL (wcsftime, size_t,
  1198. (wchar_t *restrict __buf, size_t __bufsize,
  1199. const wchar_t *restrict __fmt,
  1200. const struct tm *restrict __tp));
  1201. # else
  1202. # if !@HAVE_WCSFTIME@
  1203. _GL_FUNCDECL_SYS (wcsftime, size_t,
  1204. (wchar_t *restrict __buf, size_t __bufsize,
  1205. const wchar_t *restrict __fmt,
  1206. const struct tm *restrict __tp)
  1207. _GL_ARG_NONNULL ((1, 3, 4)));
  1208. # endif
  1209. _GL_CXXALIAS_SYS (wcsftime, size_t,
  1210. (wchar_t *restrict __buf, size_t __bufsize,
  1211. const wchar_t *restrict __fmt,
  1212. const struct tm *restrict __tp));
  1213. # endif
  1214. # if __GLIBC__ >= 2
  1215. _GL_CXXALIASWARN (wcsftime);
  1216. # endif
  1217. #elif defined GNULIB_POSIXCHECK
  1218. # undef wcsftime
  1219. # if HAVE_RAW_DECL_WCSFTIME
  1220. _GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
  1221. "use gnulib module wcsftime for portability");
  1222. # endif
  1223. #endif
  1224. #endif /* _@GUARD_PREFIX@_WCHAR_H */
  1225. #endif /* _@GUARD_PREFIX@_WCHAR_H */
  1226. #endif