Skip to content

Commit 4554600

Browse files
authored
Fix definition of wint_t (#19584)
This type, just like wchar and char, is signed by default under emscripten. Also, use the clang builtin __WINT_TYPE__ to avoid the possibility of getting it wrong.. Fixes: #19583
1 parent 551540f commit 4554600

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

system/lib/libc/musl/arch/emscripten/bits/alltypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef int wchar_t;
4848
#endif
4949
#endif
5050
#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t)
51-
typedef unsigned wint_t;
51+
typedef __WINT_TYPE__ wint_t;
5252
#define __DEFINED_wint_t
5353
#endif
5454

test/vswprintf_utf8.c renamed to test/core/test_vswprintf_utf8.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#include <errno.h>
1313
#include <assert.h>
1414

15-
void test_vswprintf(const wchar_t *format, ...)
16-
{
15+
void test_vswprintf(const wchar_t *format, ...) {
1716
wchar_t buffer[256];
1817
va_list args;
1918
va_start(args, format);
@@ -25,9 +24,13 @@ void test_vswprintf(const wchar_t *format, ...)
2524
assert(errno == 0);
2625
}
2726

28-
int main ()
29-
{
27+
int main() {
3028
setlocale(LC_ALL, "");
31-
test_vswprintf(L"This is a character: %lc.\n", 0xF6 /* Unicode Character 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6): http://www.fileformat.info/info/unicode/char/00f6/index.htm */);
29+
/* Unicode Character 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6):
30+
* http://www.fileformat.info/info/unicode/char/00f6/index.htm */
31+
wint_t wint = 0xF6;
32+
wchar_t wchar = 0xF6;
33+
printf("This is a wint: %lc.\n", wint);
34+
test_vswprintf(L"This is a character: %lc.\n", wint, wchar);
3235
return 0;
3336
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
This is a wint: ö.
12
This is a character: ö.
23
number of characters in above string: 24. errno: 0

test/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8141,7 +8141,7 @@ def test_setlocale(self):
81418141
self.do_run_in_out_file_test('core/test_setlocale.c')
81428142

81438143
def test_vswprintf_utf8(self):
8144-
self.do_run_in_out_file_test('vswprintf_utf8.c')
8144+
self.do_core_test('test_vswprintf_utf8.c')
81458145

81468146
# Test that a main with arguments is automatically asyncified.
81478147
@no_wasm64('TODO: asyncify for wasm64')

0 commit comments

Comments
 (0)