summaryrefslogtreecommitdiffstats
path: root/gl/uchar.in.h
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-12-28 12:13:40 +0100
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-12-28 12:13:40 +0100
commitb0afb8fe0ff1d87165af9df61501197a06240dda (patch)
tree274ac6a96c53ef4c19ab4974ce24a06a233128c5 /gl/uchar.in.h
parent68fc05381ee5fa0aee1413118fbb3d81ca888b09 (diff)
downloadmonitoring-plugins-b0afb8fe0ff1d87165af9df61501197a06240dda.tar.gz
Sync with Gnulib stable-202507 code (a8ac9f9ce5)
Diffstat (limited to 'gl/uchar.in.h')
-rw-r--r--gl/uchar.in.h912
1 files changed, 912 insertions, 0 deletions
diff --git a/gl/uchar.in.h b/gl/uchar.in.h
new file mode 100644
index 00000000..9a65ac37
--- /dev/null
+++ b/gl/uchar.in.h
@@ -0,0 +1,912 @@
1/* <uchar.h> substitute - 16-bit and 32-bit wide character types.
2 Copyright (C) 2019-2025 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
18
19/*
20 * ISO C 23 <uchar.h> for platforms that lack it.
21 */
22
23#ifndef _@GUARD_PREFIX@_UCHAR_H
24
25#if __GNUC__ >= 3
26@PRAGMA_SYSTEM_HEADER@
27#endif
28@PRAGMA_COLUMNS@
29
30/* The include_next requires a split double-inclusion guard. */
31#if (defined __cplusplus ? @CXX_HAVE_UCHAR_H@ : @HAVE_UCHAR_H@)
32# if defined __HAIKU__
33/* Work around <https://dev.haiku-os.org/ticket/17040>. */
34# include <stdint.h>
35# endif
36/* On AIX 7.2 with xlclang++, /usr/include/uchar.h produces compilation errors
37 because it contains typedef definitions of char16_t and char32_t, however
38 char16_t and char32_t are keywords in this situation. To work around it,
39 define char16_t and char32_t as macros. */
40# if defined __cplusplus && defined _AIX && defined __ibmxl__ && defined __clang__
41# define char16_t gl_char16_t
42# define char32_t gl_char32_t
43# endif
44# @INCLUDE_NEXT@ @NEXT_UCHAR_H@
45#endif
46
47#ifndef _@GUARD_PREFIX@_UCHAR_H
48#define _@GUARD_PREFIX@_UCHAR_H
49
50/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_BEGIN_C_LINKAGE,
51 _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
52#if !_GL_CONFIG_H_INCLUDED
53 #error "Please include config.h first."
54#endif
55
56/* Get uint_least16_t, uint_least32_t. */
57#include <stdint.h>
58
59/* Get mbstate_t, size_t. */
60#include <wchar.h>
61
62/* For the inline functions. */
63#include <string.h>
64#include <wctype.h>
65
66/* The __attribute__ feature is available in gcc versions 2.5 and later.
67 The attribute __pure__ was added in gcc 2.96. */
68#ifndef _GL_ATTRIBUTE_PURE
69# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
70# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
71# else
72# define _GL_ATTRIBUTE_PURE /* empty */
73# endif
74#endif
75
76/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
77
78/* The definition of _GL_ARG_NONNULL is copied here. */
79
80/* The definition of _GL_WARN_ON_USE is copied here. */
81
82
83_GL_INLINE_HEADER_BEGIN
84
85
86#if !(defined __cplusplus ? @CXX_HAVE_UCHAR_H@ || @CXX_HAS_CHAR8_TYPE@ : @HAVE_UCHAR_H@)
87
88/* An 8-bit variant of wchar_t.
89 Note: This type is only mandated by ISO C 23 or newer, and it does
90 denote UTF-8 units. */
91typedef unsigned char char8_t;
92
93#elif @GNULIBHEADERS_OVERRIDE_CHAR8_T@
94
95typedef unsigned char gl_char8_t;
96# define char8_t gl_char8_t
97
98#endif
99
100#if !(defined __cplusplus ? @CXX_HAVE_UCHAR_H@ || @CXX_HAS_UCHAR_TYPES@ : @HAVE_UCHAR_H@)
101
102/* A 16-bit variant of wchar_t.
103 Note: This type is only mandated by ISO C 11 or newer. In ISO C 23
104 and newer, it denotes UTF-16 units; in older versions of ISO C it did
105 so only on platforms on which __STDC_UTF_16__ was defined. */
106typedef uint_least16_t char16_t;
107
108#elif @GNULIBHEADERS_OVERRIDE_CHAR16_T@
109
110typedef uint_least16_t gl_char16_t;
111# define char16_t gl_char16_t
112
113#endif
114
115#if !(defined __cplusplus ? @CXX_HAVE_UCHAR_H@ || @CXX_HAS_UCHAR_TYPES@ : @HAVE_UCHAR_H@)
116
117/* A 32-bit variant of wchar_t.
118 Note: This type is only mandated by ISO C 11 or newer. In ISO C 23
119 and newer, it denotes UTF-32 code points; in older versions of ISO C
120 it did so only on platforms on which __STDC_UTF_32__ was defined.
121 In gnulib, we guarantee that it denotes UTF-32 code points if and
122 only if the module 'uchar-h-c23' is in use. */
123typedef uint_least32_t char32_t;
124
125#elif @GNULIBHEADERS_OVERRIDE_CHAR32_T@
126
127typedef uint_least32_t gl_char32_t;
128# define char32_t gl_char32_t
129
130#endif
131
132/* Define if a 'char32_t' can hold more characters than a 'wchar_t'. */
133#if @SMALL_WCHAR_T@ /* 32-bit AIX, Cygwin, native Windows */
134# define _GL_SMALL_WCHAR_T 1
135#endif
136
137/* Define if 'wchar_t', like 'char32_t',
138 - is a 32-bit type, and
139 - represents Unicode code points.
140 For this test, we can use __STDC_ISO_10646__ (defined by glibc, musl libc,
141 Cygwin) but need to consider _GL_SMALL_WCHAR_T, so as to exclude Cygwin.
142 We cannot use __STDC_UTF_16__ or __STDC_UTF_32__
143 - because these macros provide info about char16_t and char32_t (not
144 wchar_t!), and
145 - because GCC >= 4.9 defines these macros on all platforms, even on
146 FreeBSD and Solaris.
147 We should better not use __STD_UTF_16__, __STD_UTF_32__ either, because
148 these macros are misspellings, only defined by Android's <uchar.h>. */
149#if defined __STDC_ISO_10646__ && !_GL_SMALL_WCHAR_T
150/* glibc, musl libc */
151# define _GL_WCHAR_T_IS_UCS4 1
152#endif
153#if _GL_WCHAR_T_IS_UCS4
154static_assert (sizeof (char32_t) == sizeof (wchar_t));
155#endif
156
157
158/* Convert a single-byte character to a 32-bit wide character. */
159#if @GNULIB_BTOC32@
160# if _GL_WCHAR_T_IS_UCS4 && !defined IN_BTOC32
161_GL_BEGIN_C_LINKAGE
162_GL_INLINE _GL_ATTRIBUTE_PURE wint_t
163btoc32 (int c)
164{
165 return
166# if @GNULIB_BTOWC@ && defined __cplusplus && defined GNULIB_NAMESPACE
167 GNULIB_NAMESPACE::
168# endif
169 btowc (c);
170}
171_GL_END_C_LINKAGE
172# else
173_GL_FUNCDECL_SYS (btoc32, wint_t, (int c), _GL_ATTRIBUTE_PURE);
174# endif
175_GL_CXXALIAS_SYS (btoc32, wint_t, (int c));
176_GL_CXXALIASWARN (btoc32);
177#endif
178
179
180/* Test a specific property of a 32-bit wide character. */
181#if @GNULIB_C32ISALNUM@
182# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALNUM
183_GL_BEGIN_C_LINKAGE
184_GL_INLINE int
185c32isalnum (wint_t wc)
186{
187 return
188# if defined __cplusplus && defined GNULIB_NAMESPACE
189 GNULIB_NAMESPACE::
190# endif
191 iswalnum (wc);
192}
193_GL_END_C_LINKAGE
194# else
195_GL_FUNCDECL_SYS (c32isalnum, int, (wint_t wc), );
196# endif
197_GL_CXXALIAS_SYS (c32isalnum, int, (wint_t wc));
198_GL_CXXALIASWARN (c32isalnum);
199#endif
200#if @GNULIB_C32ISALPHA@
201# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALPHA
202_GL_BEGIN_C_LINKAGE
203_GL_INLINE int
204c32isalpha (wint_t wc)
205{
206 return
207# if defined __cplusplus && defined GNULIB_NAMESPACE
208 GNULIB_NAMESPACE::
209# endif
210 iswalpha (wc);
211}
212_GL_END_C_LINKAGE
213# else
214_GL_FUNCDECL_SYS (c32isalpha, int, (wint_t wc), );
215# endif
216_GL_CXXALIAS_SYS (c32isalpha, int, (wint_t wc));
217_GL_CXXALIASWARN (c32isalpha);
218#endif
219#if @GNULIB_C32ISBLANK@
220# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISBLANK
221_GL_BEGIN_C_LINKAGE
222_GL_INLINE int
223c32isblank (wint_t wc)
224{
225 return
226# if defined __cplusplus && defined GNULIB_NAMESPACE
227 GNULIB_NAMESPACE::
228# endif
229 iswblank (wc);
230}
231_GL_END_C_LINKAGE
232# else
233_GL_FUNCDECL_SYS (c32isblank, int, (wint_t wc), );
234# endif
235_GL_CXXALIAS_SYS (c32isblank, int, (wint_t wc));
236_GL_CXXALIASWARN (c32isblank);
237#endif
238#if @GNULIB_C32ISCNTRL@
239# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISCNTRL
240_GL_BEGIN_C_LINKAGE
241_GL_INLINE int
242c32iscntrl (wint_t wc)
243{
244 return
245# if defined __cplusplus && defined GNULIB_NAMESPACE
246 GNULIB_NAMESPACE::
247# endif
248 iswcntrl (wc);
249}
250_GL_END_C_LINKAGE
251# else
252_GL_FUNCDECL_SYS (c32iscntrl, int, (wint_t wc), );
253# endif
254_GL_CXXALIAS_SYS (c32iscntrl, int, (wint_t wc));
255_GL_CXXALIASWARN (c32iscntrl);
256#endif
257#if @GNULIB_C32ISDIGIT@
258# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISDIGIT
259_GL_BEGIN_C_LINKAGE
260_GL_INLINE int
261c32isdigit (wint_t wc)
262{
263 return
264# if @GNULIB_ISWDIGIT@ && defined __cplusplus && defined GNULIB_NAMESPACE
265 GNULIB_NAMESPACE::
266# endif
267 iswdigit (wc);
268}
269_GL_END_C_LINKAGE
270# else
271_GL_FUNCDECL_SYS (c32isdigit, int, (wint_t wc), );
272# endif
273_GL_CXXALIAS_SYS (c32isdigit, int, (wint_t wc));
274_GL_CXXALIASWARN (c32isdigit);
275#endif
276#if @GNULIB_C32ISGRAPH@
277# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISGRAPH
278_GL_BEGIN_C_LINKAGE
279_GL_INLINE int
280c32isgraph (wint_t wc)
281{
282 return
283# if defined __cplusplus && defined GNULIB_NAMESPACE
284 GNULIB_NAMESPACE::
285# endif
286 iswgraph (wc);
287}
288_GL_END_C_LINKAGE
289# else
290_GL_FUNCDECL_SYS (c32isgraph, int, (wint_t wc), );
291# endif
292_GL_CXXALIAS_SYS (c32isgraph, int, (wint_t wc));
293_GL_CXXALIASWARN (c32isgraph);
294#endif
295#if @GNULIB_C32ISLOWER@
296# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISLOWER
297_GL_BEGIN_C_LINKAGE
298_GL_INLINE int
299c32islower (wint_t wc)
300{
301 return
302# if defined __cplusplus && defined GNULIB_NAMESPACE
303 GNULIB_NAMESPACE::
304# endif
305 iswlower (wc);
306}
307_GL_END_C_LINKAGE
308# else
309_GL_FUNCDECL_SYS (c32islower, int, (wint_t wc), );
310# endif
311_GL_CXXALIAS_SYS (c32islower, int, (wint_t wc));
312_GL_CXXALIASWARN (c32islower);
313#endif
314#if @GNULIB_C32ISPRINT@
315# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPRINT
316_GL_BEGIN_C_LINKAGE
317_GL_INLINE int
318c32isprint (wint_t wc)
319{
320 return
321# if defined __cplusplus && defined GNULIB_NAMESPACE
322 GNULIB_NAMESPACE::
323# endif
324 iswprint (wc);
325}
326_GL_END_C_LINKAGE
327# else
328_GL_FUNCDECL_SYS (c32isprint, int, (wint_t wc), );
329# endif
330_GL_CXXALIAS_SYS (c32isprint, int, (wint_t wc));
331_GL_CXXALIASWARN (c32isprint);
332#endif
333#if @GNULIB_C32ISPUNCT@
334# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPUNCT
335_GL_BEGIN_C_LINKAGE
336_GL_INLINE int
337c32ispunct (wint_t wc)
338{
339 return
340# if defined __cplusplus && defined GNULIB_NAMESPACE
341 GNULIB_NAMESPACE::
342# endif
343 iswpunct (wc);
344}
345_GL_END_C_LINKAGE
346# else
347_GL_FUNCDECL_SYS (c32ispunct, int, (wint_t wc), );
348# endif
349_GL_CXXALIAS_SYS (c32ispunct, int, (wint_t wc));
350_GL_CXXALIASWARN (c32ispunct);
351#endif
352#if @GNULIB_C32ISSPACE@
353# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISSPACE
354_GL_BEGIN_C_LINKAGE
355_GL_INLINE int
356c32isspace (wint_t wc)
357{
358 return
359# if defined __cplusplus && defined GNULIB_NAMESPACE
360 GNULIB_NAMESPACE::
361# endif
362 iswspace (wc);
363}
364_GL_END_C_LINKAGE
365# else
366_GL_FUNCDECL_SYS (c32isspace, int, (wint_t wc), );
367# endif
368_GL_CXXALIAS_SYS (c32isspace, int, (wint_t wc));
369_GL_CXXALIASWARN (c32isspace);
370#endif
371#if @GNULIB_C32ISUPPER@
372# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISUPPER
373_GL_BEGIN_C_LINKAGE
374_GL_INLINE int
375c32isupper (wint_t wc)
376{
377 return
378# if defined __cplusplus && defined GNULIB_NAMESPACE
379 GNULIB_NAMESPACE::
380# endif
381 iswupper (wc);
382}
383_GL_END_C_LINKAGE
384# else
385_GL_FUNCDECL_SYS (c32isupper, int, (wint_t wc), );
386# endif
387_GL_CXXALIAS_SYS (c32isupper, int, (wint_t wc));
388_GL_CXXALIASWARN (c32isupper);
389#endif
390#if @GNULIB_C32ISXDIGIT@
391# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISXDIGIT
392_GL_BEGIN_C_LINKAGE
393_GL_INLINE int
394c32isxdigit (wint_t wc)
395{
396 return
397# if @GNULIB_ISWXDIGIT@ && defined __cplusplus && defined GNULIB_NAMESPACE
398 GNULIB_NAMESPACE::
399# endif
400 iswxdigit (wc);
401}
402_GL_END_C_LINKAGE
403# else
404_GL_FUNCDECL_SYS (c32isxdigit, int, (wint_t wc), );
405# endif
406_GL_CXXALIAS_SYS (c32isxdigit, int, (wint_t wc));
407_GL_CXXALIASWARN (c32isxdigit);
408#endif
409
410
411/* Case mapping of a 32-bit wide character. */
412#if @GNULIB_C32TOLOWER@
413# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32TOLOWER
414_GL_BEGIN_C_LINKAGE
415_GL_INLINE wint_t
416c32tolower (wint_t wc)
417{
418 return
419# if defined __cplusplus && defined GNULIB_NAMESPACE
420 GNULIB_NAMESPACE::
421# endif
422 towlower (wc);
423}
424_GL_END_C_LINKAGE
425# else
426_GL_FUNCDECL_SYS (c32tolower, wint_t, (wint_t wc), );
427# endif
428_GL_CXXALIAS_SYS (c32tolower, wint_t, (wint_t wc));
429_GL_CXXALIASWARN (c32tolower);
430#endif
431#if @GNULIB_C32TOUPPER@
432# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32TOUPPER
433_GL_BEGIN_C_LINKAGE
434_GL_INLINE wint_t
435c32toupper (wint_t wc)
436{
437 return
438# if defined __cplusplus && defined GNULIB_NAMESPACE
439 GNULIB_NAMESPACE::
440# endif
441 towupper (wc);
442}
443_GL_END_C_LINKAGE
444# else
445_GL_FUNCDECL_SYS (c32toupper, wint_t, (wint_t wc), );
446# endif
447_GL_CXXALIAS_SYS (c32toupper, wint_t, (wint_t wc));
448_GL_CXXALIASWARN (c32toupper);
449#endif
450
451
452/* Number of screen columns needed for a 32-bit wide character. */
453#if @GNULIB_C32WIDTH@
454# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32WIDTH
455_GL_BEGIN_C_LINKAGE
456_GL_INLINE int
457c32width (char32_t wc)
458{
459 return
460# if @GNULIB_WCWIDTH@ && defined __cplusplus && defined GNULIB_NAMESPACE
461 GNULIB_NAMESPACE::
462# endif
463 wcwidth (wc);
464}
465_GL_END_C_LINKAGE
466# else
467_GL_FUNCDECL_SYS (c32width, int, (char32_t wc), );
468# endif
469_GL_CXXALIAS_SYS (c32width, int, (char32_t wc));
470_GL_CXXALIASWARN (c32width);
471#endif
472
473
474/* Converts a 32-bit wide character to a multibyte character. */
475#if @GNULIB_C32RTOMB@
476# if @REPLACE_C32RTOMB@
477# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
478# undef c32rtomb
479# define c32rtomb rpl_c32rtomb
480# endif
481_GL_FUNCDECL_RPL (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps), );
482_GL_CXXALIAS_RPL (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps));
483# else
484# if !@HAVE_C32RTOMB@
485_GL_FUNCDECL_SYS (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps), );
486# endif
487_GL_CXXALIAS_SYS (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps));
488# endif
489# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
490_GL_CXXALIASWARN (c32rtomb);
491# endif
492#elif defined GNULIB_POSIXCHECK
493# undef c32rtomb
494# if HAVE_RAW_DECL_C32RTOMB
495_GL_WARN_ON_USE (c32rtomb, "c32rtomb is not portable - "
496 "use gnulib module c32rtomb for portability");
497# endif
498#endif
499
500
501/* Convert a 32-bit wide string to a string. */
502#if @GNULIB_C32SNRTOMBS@
503# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SNRTOMBS
504_GL_BEGIN_C_LINKAGE
505_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
506c32snrtombs (char *dest, const char32_t **srcp, size_t srclen, size_t len,
507 mbstate_t *ps)
508{
509 return
510# if @GNULIB_WCSNRTOMBS@ && defined __cplusplus && defined GNULIB_NAMESPACE
511 GNULIB_NAMESPACE::
512# endif
513 wcsnrtombs (dest, (const wchar_t **) srcp, srclen, len, ps);
514}
515_GL_END_C_LINKAGE
516# else
517_GL_FUNCDECL_SYS (c32snrtombs, size_t,
518 (char *dest, const char32_t **srcp, size_t srclen, size_t len,
519 mbstate_t *ps),
520 _GL_ARG_NONNULL ((2)));
521# endif
522_GL_CXXALIAS_SYS (c32snrtombs, size_t,
523 (char *dest, const char32_t **srcp, size_t srclen, size_t len,
524 mbstate_t *ps));
525_GL_CXXALIASWARN (c32snrtombs);
526#endif
527
528
529/* Convert a 32-bit wide string to a string. */
530#if @GNULIB_C32SRTOMBS@
531# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SRTOMBS
532_GL_BEGIN_C_LINKAGE
533_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
534c32srtombs (char *dest, const char32_t **srcp, size_t len, mbstate_t *ps)
535{
536 return
537# if @GNULIB_WCSRTOMBS@ && defined __cplusplus && defined GNULIB_NAMESPACE
538 GNULIB_NAMESPACE::
539# endif
540 wcsrtombs (dest, (const wchar_t **) srcp, len, ps);
541}
542_GL_END_C_LINKAGE
543# else
544_GL_FUNCDECL_SYS (c32srtombs, size_t,
545 (char *dest, const char32_t **srcp, size_t len,
546 mbstate_t *ps),
547 _GL_ARG_NONNULL ((2)));
548# endif
549_GL_CXXALIAS_SYS (c32srtombs, size_t,
550 (char *dest, const char32_t **srcp, size_t len,
551 mbstate_t *ps));
552_GL_CXXALIASWARN (c32srtombs);
553#endif
554
555
556/* Convert a 32-bit wide string to a string. */
557#if @GNULIB_C32STOMBS@
558# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32STOMBS
559_GL_BEGIN_C_LINKAGE
560_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
561c32stombs (char *dest, const char32_t *src, size_t len)
562{
563 mbstate_t state;
564
565 mbszero (&state);
566 return c32srtombs (dest, &src, len, &state);
567}
568_GL_END_C_LINKAGE
569# else
570_GL_FUNCDECL_SYS (c32stombs, size_t,
571 (char *dest, const char32_t *src, size_t len),
572 _GL_ARG_NONNULL ((2)));
573# endif
574_GL_CXXALIAS_SYS (c32stombs, size_t,
575 (char *dest, const char32_t *src, size_t len));
576_GL_CXXALIASWARN (c32stombs);
577#endif
578
579
580/* Number of screen columns needed for a size-bounded 32-bit wide string. */
581#if @GNULIB_C32SWIDTH@
582# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32SWIDTH
583_GL_BEGIN_C_LINKAGE
584_GL_INLINE _GL_ARG_NONNULL ((1)) int
585c32swidth (const char32_t *s, size_t n)
586{
587 return
588# if @GNULIB_WCSWIDTH@ && defined __cplusplus && defined GNULIB_NAMESPACE
589 GNULIB_NAMESPACE::
590# endif
591 wcswidth ((const wchar_t *) s, n);
592}
593_GL_END_C_LINKAGE
594# else
595_GL_FUNCDECL_SYS (c32swidth, int, (const char32_t *s, size_t n),
596 _GL_ARG_NONNULL ((1)));
597# endif
598_GL_CXXALIAS_SYS (c32swidth, int, (const char32_t *s, size_t n));
599_GL_CXXALIASWARN (c32swidth);
600#endif
601
602
603/* Converts a 32-bit wide character to unibyte character.
604 Returns the single-byte representation of WC if it exists,
605 or EOF otherwise. */
606#if @GNULIB_C32TOB@
607# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32TOB
608_GL_BEGIN_C_LINKAGE
609_GL_INLINE int
610c32tob (wint_t wc)
611{
612 return
613# if @GNULIB_WCTOB@ && defined __cplusplus && defined GNULIB_NAMESPACE
614 GNULIB_NAMESPACE::
615# endif
616 wctob (wc);
617}
618_GL_END_C_LINKAGE
619# else
620_GL_FUNCDECL_SYS (c32tob, int, (wint_t wc), );
621# endif
622_GL_CXXALIAS_SYS (c32tob, int, (wint_t wc));
623_GL_CXXALIASWARN (c32tob);
624#endif
625
626
627/* Converts a multibyte character to a 32-bit wide character. */
628#if @GNULIB_MBRTOC32@
629# if @REPLACE_MBRTOC32@
630# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
631# undef mbrtoc32
632# define mbrtoc32 rpl_mbrtoc32
633# endif
634_GL_FUNCDECL_RPL (mbrtoc32, size_t,
635 (char32_t *pc, const char *s, size_t n, mbstate_t *ps), );
636_GL_CXXALIAS_RPL (mbrtoc32, size_t,
637 (char32_t *pc, const char *s, size_t n, mbstate_t *ps));
638# else
639# if !@HAVE_MBRTOC32@
640_GL_FUNCDECL_SYS (mbrtoc32, size_t,
641 (char32_t *pc, const char *s, size_t n, mbstate_t *ps), );
642# endif
643_GL_CXXALIAS_SYS (mbrtoc32, size_t,
644 (char32_t *pc, const char *s, size_t n, mbstate_t *ps));
645# endif
646# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
647_GL_CXXALIASWARN (mbrtoc32);
648# endif
649#elif defined GNULIB_POSIXCHECK
650# undef mbrtoc32
651# if HAVE_RAW_DECL_MBRTOC32
652_GL_WARN_ON_USE (mbrtoc32, "mbrtoc32 is not portable - "
653 "use gnulib module mbrtoc32 for portability");
654# endif
655#endif
656
657
658/* Converts a multibyte character and returns the next 16-bit wide
659 character. */
660#if @GNULIB_MBRTOC16@
661# if @REPLACE_MBRTOC16@
662# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
663# undef mbrtoc16
664# define mbrtoc16 rpl_mbrtoc16
665# endif
666_GL_FUNCDECL_RPL (mbrtoc16, size_t,
667 (char16_t *pc, const char *s, size_t n, mbstate_t *ps), );
668_GL_CXXALIAS_RPL (mbrtoc16, size_t,
669 (char16_t *pc, const char *s, size_t n, mbstate_t *ps));
670# else
671# if !@HAVE_MBRTOC16@
672_GL_FUNCDECL_SYS (mbrtoc16, size_t,
673 (char16_t *pc, const char *s, size_t n, mbstate_t *ps), );
674# endif
675_GL_CXXALIAS_SYS (mbrtoc16, size_t,
676 (char16_t *pc, const char *s, size_t n, mbstate_t *ps));
677# endif
678# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
679_GL_CXXALIASWARN (mbrtoc16);
680# endif
681#elif defined GNULIB_POSIXCHECK
682# undef mbrtoc16
683# if HAVE_RAW_DECL_MBRTOC16
684_GL_WARN_ON_USE (mbrtoc16, "mbrtoc16 is not portable - "
685 "use gnulib module mbrtoc16 for portability");
686# endif
687#endif
688
689
690/* Convert a string to a 32-bit wide string. */
691#if @GNULIB_MBSNRTOC32S@
692# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSNRTOC32S
693_GL_BEGIN_C_LINKAGE
694_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
695mbsnrtoc32s (char32_t *dest, const char **srcp, size_t srclen, size_t len,
696 mbstate_t *ps)
697{
698 return
699# if @GNULIB_MBSNRTOWCS@ && defined __cplusplus && defined GNULIB_NAMESPACE
700 GNULIB_NAMESPACE::
701# endif
702 mbsnrtowcs ((wchar_t *) dest, srcp, srclen, len, ps);
703}
704_GL_END_C_LINKAGE
705# else
706_GL_FUNCDECL_SYS (mbsnrtoc32s, size_t,
707 (char32_t *dest, const char **srcp, size_t srclen, size_t len,
708 mbstate_t *ps),
709 _GL_ARG_NONNULL ((2)));
710# endif
711_GL_CXXALIAS_SYS (mbsnrtoc32s, size_t,
712 (char32_t *dest, const char **srcp, size_t srclen, size_t len,
713 mbstate_t *ps));
714_GL_CXXALIASWARN (mbsnrtoc32s);
715#endif
716
717
718/* Convert a string to a 32-bit wide string. */
719#if @GNULIB_MBSRTOC32S@
720# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSRTOC32S
721_GL_BEGIN_C_LINKAGE
722_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
723mbsrtoc32s (char32_t *dest, const char **srcp, size_t len, mbstate_t *ps)
724{
725 return
726# if @GNULIB_MBSRTOWCS@ && defined __cplusplus && defined GNULIB_NAMESPACE
727 GNULIB_NAMESPACE::
728# endif
729 mbsrtowcs ((wchar_t *) dest, srcp, len, ps);
730}
731_GL_END_C_LINKAGE
732# else
733_GL_FUNCDECL_SYS (mbsrtoc32s, size_t,
734 (char32_t *dest, const char **srcp, size_t len,
735 mbstate_t *ps),
736 _GL_ARG_NONNULL ((2)));
737# endif
738_GL_CXXALIAS_SYS (mbsrtoc32s, size_t,
739 (char32_t *dest, const char **srcp, size_t len,
740 mbstate_t *ps));
741_GL_CXXALIASWARN (mbsrtoc32s);
742#endif
743
744
745/* Convert a string to a 32-bit wide string. */
746#if @GNULIB_MBSTOC32S@
747# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSTOC32S
748_GL_BEGIN_C_LINKAGE
749_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
750mbstoc32s (char32_t *dest, const char *src, size_t len)
751{
752 mbstate_t state;
753
754 mbszero (&state);
755 return mbsrtoc32s (dest, &src, len, &state);
756}
757_GL_END_C_LINKAGE
758# else
759_GL_FUNCDECL_SYS (mbstoc32s, size_t,
760 (char32_t *dest, const char *src, size_t len),
761 _GL_ARG_NONNULL ((2)));
762# endif
763_GL_CXXALIAS_SYS (mbstoc32s, size_t,
764 (char32_t *dest, const char *src, size_t len));
765_GL_CXXALIASWARN (mbstoc32s);
766#endif
767
768
769#if @GNULIB_C32_GET_TYPE_TEST@ || @GNULIB_C32_APPLY_TYPE_TEST@
770/* A scalar type. Instances of this type, other than (c32_type_test_t) 0,
771 represent a character property, sometimes also viewed as a "character class".
772 It can be applied to 32-bit wide characters. It is the counterpart of
773 type 'wctype_t' for wide characters.
774 To test whether a given character has a certain property, use the function
775 'c32_apply_type_test'. */
776# if _GL_WCHAR_T_IS_UCS4
777typedef wctype_t c32_type_test_t;
778# else
779typedef /*bool*/int (*c32_type_test_t) (wint_t wc);
780# endif
781#endif
782
783/* Return a character property with the given name, or (c32_type_test_t) 0
784 if the designated property does not exist.
785 This function is the counterpart of function 'wctype' for wide characters.
786 */
787#if @GNULIB_C32_GET_TYPE_TEST@
788# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_TYPE_TEST
789_GL_BEGIN_C_LINKAGE
790_GL_INLINE _GL_ARG_NONNULL ((1)) c32_type_test_t
791c32_get_type_test (const char *name)
792{
793 return
794# if @GNULIB_WCTYPE@ && defined __cplusplus && defined GNULIB_NAMESPACE
795 GNULIB_NAMESPACE::
796# endif
797 wctype (name);
798}
799_GL_END_C_LINKAGE
800# else
801_GL_FUNCDECL_SYS (c32_get_type_test, c32_type_test_t, (const char *name),
802 _GL_ARG_NONNULL ((1)));
803# endif
804_GL_CXXALIAS_SYS (c32_get_type_test, c32_type_test_t, (const char *name));
805_GL_CXXALIASWARN (c32_get_type_test);
806#endif
807
808/* Test whether a given 32-bit wide character has the specified character
809 property.
810 Return non-zero if true, zero if false or if the argument is WEOF.
811 This function is the counterpart of function 'iswctype' for wide characters.
812 */
813#if @GNULIB_C32_APPLY_TYPE_TEST@
814# if _GL_WCHAR_T_IS_UCS4
815# if !defined IN_C32_APPLY_TYPE_TEST
816_GL_BEGIN_C_LINKAGE
817_GL_INLINE int
818c32_apply_type_test (wint_t wc, c32_type_test_t property)
819{
820 return
821# if @GNULIB_ISWCTYPE@ && defined __cplusplus && defined GNULIB_NAMESPACE
822 GNULIB_NAMESPACE::
823# endif
824 iswctype (wc, property);
825}
826_GL_END_C_LINKAGE
827# else
828_GL_FUNCDECL_SYS (c32_apply_type_test, int,
829 (wint_t wc, c32_type_test_t property), );
830# endif
831# else
832_GL_FUNCDECL_SYS (c32_apply_type_test, int,
833 (wint_t wc, c32_type_test_t property),
834 _GL_ARG_NONNULL ((2)));
835# endif
836_GL_CXXALIAS_SYS (c32_apply_type_test, int,
837 (wint_t wc, c32_type_test_t property));
838_GL_CXXALIASWARN (c32_apply_type_test);
839#endif
840
841
842#if @GNULIB_C32_GET_MAPPING@ || @GNULIB_C32_APPLY_MAPPING@
843/* A scalar type. Instances of this type, other than (c32_mapping_t) 0,
844 represent a character mapping. It can be applied to 32-bit wide characters.
845 It is the counterpart of type 'wctrans_t' for wide characters.
846 To apply a certain mapping to a given character, use the function
847 'c32_apply_mapping'. */
848# if _GL_WCHAR_T_IS_UCS4
849typedef wctrans_t c32_mapping_t;
850# else
851typedef wint_t (*c32_mapping_t) (wint_t wc);
852# endif
853#endif
854
855/* Return a character mapping with the given name, or (c32_mapping_t) 0
856 if the designated mapping does not exist.
857 This function is the counterpart of function 'wctrans' for wide characters.
858 */
859#if @GNULIB_C32_GET_MAPPING@
860# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_MAPPING
861_GL_BEGIN_C_LINKAGE
862_GL_INLINE _GL_ARG_NONNULL ((1)) c32_mapping_t
863c32_get_mapping (const char *name)
864{
865 return
866# if @GNULIB_WCTRANS@ && defined __cplusplus && defined GNULIB_NAMESPACE
867 GNULIB_NAMESPACE::
868# endif
869 wctrans (name);
870}
871_GL_END_C_LINKAGE
872# else
873_GL_FUNCDECL_SYS (c32_get_mapping, c32_mapping_t, (const char *name),
874 _GL_ARG_NONNULL ((1)));
875# endif
876_GL_CXXALIAS_SYS (c32_get_mapping, c32_mapping_t, (const char *name));
877_GL_CXXALIASWARN (c32_get_mapping);
878#endif
879
880/* Apply the specified character mapping to a given 32-bit wide character.
881 Return the result of this mapping. Return the WC argument unchanged if it is
882 WEOF.
883 This function is the counterpart of function 'towctrans' for wide characters.
884 */
885#if @GNULIB_C32_APPLY_MAPPING@
886# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_APPLY_MAPPING
887_GL_BEGIN_C_LINKAGE
888_GL_INLINE _GL_ARG_NONNULL ((2)) wint_t
889c32_apply_mapping (wint_t wc, c32_mapping_t mapping)
890{
891 return
892# if @GNULIB_TOWCTRANS@ && defined __cplusplus && defined GNULIB_NAMESPACE
893 GNULIB_NAMESPACE::
894# endif
895 towctrans (wc, mapping);
896}
897_GL_END_C_LINKAGE
898# else
899_GL_FUNCDECL_SYS (c32_apply_mapping, wint_t,
900 (wint_t wc, c32_mapping_t mapping),
901 _GL_ARG_NONNULL ((2)));
902# endif
903_GL_CXXALIAS_SYS (c32_apply_mapping, wint_t,
904 (wint_t wc, c32_mapping_t mapping));
905_GL_CXXALIASWARN (c32_apply_mapping);
906#endif
907
908
909_GL_INLINE_HEADER_END
910
911#endif /* _@GUARD_PREFIX@_UCHAR_H */
912#endif /* _@GUARD_PREFIX@_UCHAR_H */