libc/stdlib: Use internal state in wctomb() - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c675740de75457783b309d357f586a768cf31fed
 (DIR) parent 6f13ed360e15b5daa1df2c2de39dc93422db4255
 (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
       Date:   Thu, 20 Mar 2025 20:23:33 +0100
       
       libc/stdlib: Use internal state in wctomb()
       
       Wctomb() must behave as if the function wcrtomb() is not called (in
       other words, it should not use the internal hidden state of wcrtomb())
       and for that reason its own static mbstate_t variable.
       
       Diffstat:
         M src/libc/stdlib/wctomb.c            |       4 +++-
       
       1 file changed, 3 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/src/libc/stdlib/wctomb.c b/src/libc/stdlib/wctomb.c
       @@ -6,5 +6,7 @@
        int
        wctomb(char *s, wchar_t wc)
        {
       -        return wcrtomb(s, wc, NULL);
       +        static mbstate_t st;
       +
       +        return wcrtomb(s, wc, &st);
        }