+2023-07-02 Bruno Haible <bruno@clisp.org>
+
+ mbswidth: Overcome wchar_t limitations.
+ * lib/mbswidth.c: Include <uchar.h> instead of <wctype.h>.
+ (mbsnwidth): Use mbrtoc32 instead of mbrtowc. Use c32width instead of
+ wcwidth. Use c32iscntrl instead of iswcntrl.
+ * modules/mbswidth (Depends-on): Remove wctype-h, mbrtowc, wcwidth. Add
+ uchar, mbrtoc32, c32width, c32iscntrl.
+ (Link): Add $(LIBC32CONV).
+
2023-07-01 Paul Eggert <eggert@cs.ucla.edu>
Fix long bootstrap lines
/* Get isprint(). */
#include <ctype.h>
-/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */
+/* Get mbstate_t, mbsinit(). */
#include <wchar.h>
-/* Get iswcntrl(). */
-#include <wctype.h>
+/* Get char32_t, mbrtoc32(), c32iscntrl(), c32width(). */
+#include <uchar.h>
/* Get INT_MAX. */
#include <limits.h>
memset (&mbstate, 0, sizeof mbstate);
do
{
- wchar_t wc;
+ char32_t wc;
size_t bytes;
int w;
- bytes = mbrtowc (&wc, p, plimit - p, &mbstate);
+ bytes = mbrtoc32 (&wc, p, plimit - p, &mbstate);
if (bytes == (size_t) -1)
/* An invalid multibyte sequence was encountered. */
if (bytes == 0)
/* A null wide character was encountered. */
bytes = 1;
+ else if (bytes == (size_t) -3)
+ bytes = 0;
- w = wcwidth (wc);
+ w = c32width (wc);
if (w >= 0)
/* A printable multibyte character. */
{
/* An unprintable multibyte character. */
if (!(flags & MBSW_REJECT_UNPRINTABLE))
{
- if (!iswcntrl (wc))
+ if (!c32iscntrl (wc))
{
if (width == INT_MAX)
goto overflow;
Depends-on:
wchar
-wctype-h
-mbrtowc
+uchar
+mbrtoc32
mbsinit
-wcwidth
+c32width
+c32iscntrl
extensions
configure.ac:
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL