* lib/uchar.in.h (mbstoc32s): New declaration.
* lib/mbstoc32s.c: New file.
* m4/uchar.m4 (gl_UCHAR_H_DEFAULTS): Initialize GNULIB_MBSTOC32S.
* modules/uchar (Makefile.am): Substitute GNULIB_MBSTOC32S.
* modules/mbstoc32s: New file.
* tests/test-uchar-c++.cc: Test the signature of mbstoc32s.
* doc/posix-functions/mbstowcs.texi: Mention the new module.
+2020-01-05 Bruno Haible <bruno@clisp.org>
+
+ mbstoc32s: New module.
+ * lib/uchar.in.h (mbstoc32s): New declaration.
+ * lib/mbstoc32s.c: New file.
+ * m4/uchar.m4 (gl_UCHAR_H_DEFAULTS): Initialize GNULIB_MBSTOC32S.
+ * modules/uchar (Makefile.am): Substitute GNULIB_MBSTOC32S.
+ * modules/mbstoc32s: New file.
+ * tests/test-uchar-c++.cc: Test the signature of mbstoc32s.
+ * doc/posix-functions/mbstowcs.texi: Mention the new module.
+
2020-01-05 Bruno Haible <bruno@clisp.org>
Tweak recently added tests.
Portability problems not fixed by Gnulib:
@itemize
@item
-On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
-accommodate all Unicode characters.
+On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and
+therefore cannot accommodate all Unicode characters.
+However, the Gnulib function @code{mbstoc32s}, provided by Gnulib module
+@code{mbstoc32s}, operates on 32-bit wide characters and therefore does not
+have this limitation.
@end itemize
--- /dev/null
+/* Convert string to 32-bit wide string.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2020.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <uchar.h>
+
+#include <string.h>
+#include <wchar.h>
+
+size_t
+mbstoc32s (char32_t *dest, const char *src, size_t len)
+{
+ mbstate_t state;
+
+ memset (&state, '\0', sizeof (mbstate_t));
+ return mbsrtoc32s (dest, &src, len, &state);
+}
#endif
+/* Convert a string to a 32-bit wide string. */
+#if @GNULIB_MBSTOC32S@
+_GL_FUNCDECL_SYS (mbstoc32s, size_t,
+ (char32_t *dest, const char *src, size_t len)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_SYS (mbstoc32s, size_t,
+ (char32_t *dest, const char *src, size_t len));
+_GL_CXXALIASWARN (mbstoc32s);
+#endif
+
+
#endif /* _@GUARD_PREFIX@_UCHAR_H */
-# uchar.m4 serial 7
+# uchar.m4 serial 8
dnl Copyright (C) 2019-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
GNULIB_MBRTOC32=0; AC_SUBST([GNULIB_MBRTOC32])
GNULIB_MBSNRTOC32S=0; AC_SUBST([GNULIB_MBSNRTOC32S])
GNULIB_MBSRTOC32S=0; AC_SUBST([GNULIB_MBSRTOC32S])
+ GNULIB_MBSTOC32S=0; AC_SUBST([GNULIB_MBSTOC32S])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_MBRTOC32=1; AC_SUBST([HAVE_MBRTOC32])
REPLACE_MBRTOC32=0; AC_SUBST([REPLACE_MBRTOC32])
--- /dev/null
+Description:
+mbstoc32s() function: convert string to 32-bit wide string.
+
+Files:
+lib/mbstoc32s.c
+
+Depends-on:
+uchar
+wchar
+mbsrtoc32s
+
+configure.ac:
+gl_UCHAR_MODULE_INDICATOR([mbstoc32s])
+
+Makefile.am:
+lib_SOURCES += mbstoc32s.c
+
+Include:
+<uchar.h>
+
+Link:
+$(LIB_MBRTOWC)
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible
-e 's/@''GNULIB_MBRTOC32''@/$(GNULIB_MBRTOC32)/g' \
-e 's/@''GNULIB_MBSNRTOC32S''@/$(GNULIB_MBSNRTOC32S)/g' \
-e 's/@''GNULIB_MBSRTOC32S''@/$(GNULIB_MBSRTOC32S)/g' \
+ -e 's/@''GNULIB_MBSTOC32S''@/$(GNULIB_MBSTOC32S)/g' \
-e 's|@''HAVE_MBRTOC32''@|$(HAVE_MBRTOC32)|g' \
-e 's|@''REPLACE_MBRTOC32''@|$(REPLACE_MBRTOC32)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
(char32_t *, const char **, size_t, mbstate_t *));
#endif
+#if GNULIB_TEST_MBSTOC32S
+SIGNATURE_CHECK (GNULIB_NAMESPACE::mbstoc32s, size_t,
+ (char32_t *, const char *, size_t));
+#endif
+
int
main ()