wchar.in.h 44 KB

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