summaryrefslogtreecommitdiff
path: root/tests/btowc.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-03-03 19:11:32 +0100
committerJörg Frings-Fürst <debian@jff.email>2024-03-03 19:11:32 +0100
commit00893e79fc62966067af1a106567db96bd170338 (patch)
tree52b35cd0b42ca28e62a2ffbecade2e13dd8332cf /tests/btowc.c
parent26112352a774737e1ce5580c93654a26c1e82b39 (diff)
New upstream version 1.2upstream/1.2
Diffstat (limited to 'tests/btowc.c')
-rw-r--r--tests/btowc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/btowc.c b/tests/btowc.c
index 4af58bb0..8bf21aa6 100644
--- a/tests/btowc.c
+++ b/tests/btowc.c
@@ -1,5 +1,5 @@
/* Convert unibyte character to wide character.
- Copyright (C) 2008, 2010-2022 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
wint_t
btowc (int c)
@@ -32,7 +33,14 @@ btowc (int c)
wchar_t wc;
buf[0] = c;
+#if HAVE_MBRTOWC
+ mbstate_t state;
+ mbszero (&state);
+ size_t ret = mbrtowc (&wc, buf, 1, &state);
+ if (!(ret == (size_t)(-1) || ret == (size_t)(-2)))
+#else
if (mbtowc (&wc, buf, 1) >= 0)
+#endif
return wc;
}
return WEOF;