wchar.in.h 41 KB

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