Skip to content

Commit 0061c71

Browse files
committed
tinystdio: vfwprintf and vfwscanf need an unsigned wchar_t type
The numeric conversion code all assumes it has an unsigned char, so when that code is used on wchar_t, we need a type which is known to be unsigned. wchar_t is not such a type. borrow the UCHAR stuff from conv_flt. Signed-off-by: Keith Packard <[email protected]>
1 parent 0bfd28f commit 0061c71

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

newlib/libc/tinystdio/vfprintf.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@
6565

6666
#ifdef WIDE_CHARS
6767
# define CHAR wchar_t
68-
# define UCHAR wchar_t
68+
# if __SIZEOF_WCHAR_T__ == 2
69+
# define UCHAR uint16_t
70+
# elif __SIZEOF_WCHAR_T__ == 4
71+
# define UCHAR uint32_t
72+
# endif
6973
#else
7074
# define CHAR char
7175
# define UCHAR unsigned char

newlib/libc/tinystdio/vfscanf.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ typedef long int_scanf_t;
7373
# define INT wint_t
7474
# define MY_EOF WEOF
7575
# define CHAR wchar_t
76-
# define UCHAR wchar_t
76+
# if __SIZEOF_WCHAR_T__ == 2
77+
# define UCHAR uint16_t
78+
# elif __SIZEOF_WCHAR_T__ == 4
79+
# define UCHAR uint32_t
80+
# endif
7781
# define GETC(s) getwc_unlocked(s)
7882
# define UNGETC(c,s) ungetwc(c,s)
7983
# define ISSPACE(c) iswspace(c)

0 commit comments

Comments
 (0)