exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / c32snrtombs.c
blob23371c4b1e53d83172a0d4157a8402496d83336a
1 /* Convert 32-bit wide string to string.
2 Copyright (C) 2020-2024 Free Software Foundation, Inc.
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 3 of the
7 License, or (at your option) any later version.
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.
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/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2020. */
19 #include <config.h>
21 #define IN_C32SNRTOMBS
22 /* Specification. */
23 #include <uchar.h>
25 #include <wchar.h>
27 #if (HAVE_WORKING_MBRTOC32 && !_GL_WCHAR_T_IS_UCS4) || (GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION) || _GL_SMALL_WCHAR_T
28 /* The char32_t encoding of a multibyte character may be different than its
29 wchar_t encoding, or char32_t is wider than wchar_t. */
31 # include <errno.h>
32 # include <stdlib.h>
33 # include <string.h>
35 extern mbstate_t _gl_c32srtombs_state;
37 # define FUNC c32snrtombs
38 # define SCHAR_T char32_t
39 # define INTERNAL_STATE _gl_c32srtombs_state
40 # define WCRTOMB c32rtomb
41 # include "wcsnrtombs-impl.h"
43 #else
44 /* char32_t and wchar_t are equivalent. */
46 static_assert (sizeof (char32_t) == sizeof (wchar_t));
48 # if _GL_WCHAR_T_IS_UCS4
49 _GL_EXTERN_INLINE
50 # endif
51 size_t
52 c32snrtombs (char *dest, const char32_t **srcp, size_t srclen, size_t len,
53 mbstate_t *ps)
55 return wcsnrtombs (dest, (const wchar_t **) srcp, srclen, len, ps);
58 #endif