From 5be04ec2ceb1df77afbca4fcbf9e92a712612d6f Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:27:12 +0100 Subject: Sync with the latest Gnulib code (d4ec02b3cc) --- gl/btowc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gl/btowc.c') diff --git a/gl/btowc.c b/gl/btowc.c index caadbd76..8bf21aa6 100644 --- a/gl/btowc.c +++ b/gl/btowc.c @@ -1,5 +1,5 @@ /* Convert unibyte character to wide character. - Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. + Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This file is free software: you can redistribute it and/or modify @@ -22,6 +22,7 @@ #include #include +#include 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; -- cgit v1.2.3-74-g34f1