libc/wchar: Add wmemset() - 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 7dcb0d9d9eee6306f01cf4788b8eef1fa9baa9c7
 (DIR) parent d7543e2d9e5bc064ac6f1b2469511aae17f0ad52
 (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
       Date:   Tue, 25 Mar 2025 19:49:46 +0100
       
       libc/wchar: Add wmemset()
       
       Diffstat:
         M src/libc/objs/common-objs.mk        |       1 +
         A src/libc/wchar/wmemset.c            |      13 +++++++++++++
         M tests/libc/execute/.gitignore       |       1 +
         A tests/libc/execute/0052-wmemset.c   |      30 ++++++++++++++++++++++++++++++
         M tests/libc/execute/libc-tests.lst   |       1 +
       
       5 files changed, 46 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/libc/objs/common-objs.mk b/src/libc/objs/common-objs.mk
       @@ -136,6 +136,7 @@ COMMON_OBJS =\
                wchar/wmemchr.$O\
                wchar/wmemcpy.$O\
                wchar/wmemmove.$O\
       +        wchar/wmemset.$O\
                wchar/wmemcmp.$O\
                wchar/putwc.$O\
                wchar/_validutf8.$O\
 (DIR) diff --git a/src/libc/wchar/wmemset.c b/src/libc/wchar/wmemset.c
       @@ -0,0 +1,13 @@
       +#include <wchar.h>
       +
       +#undef wmemset
       +
       +wchar_t *
       +wmemset(wchar_t *d, wchar_t wc, size_t n)
       +{
       +        wchar_t *ret = d;
       +
       +        while (n-- > 0)
       +                *d++ = wc;
       +        return ret;
       +}
 (DIR) diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore
       @@ -47,6 +47,7 @@
        0048-wcscpy
        0049-wmemchr
        0050-wmemcpy
       +0052-wmemset
        0051-wmemmove
        0053-wmemcmp
        test.log
 (DIR) diff --git a/tests/libc/execute/0052-wmemset.c b/tests/libc/execute/0052-wmemset.c
       @@ -0,0 +1,30 @@
       +#include <assert.h>
       +#include <stdio.h>
       +#include <wchar.h>
       +
       +/*
       +output:
       +testing
       +done
       +end:
       +*/
       +
       +int
       +main()
       +{
       +        wchar_t *p, buf[40];
       +
       +        puts("testing");
       +
       +        wmemset(buf, 2, 40);
       +        for (p = buf; p < &buf[40]; ++p)
       +                assert(*p == 2);
       +
       +        wmemset(buf, 0, 0);
       +        for (p = buf; p < &buf[40]; ++p)
       +                assert(*p == 2);
       +
       +        puts("done");
       +
       +        return 0;
       +}
 (DIR) diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst
       @@ -47,4 +47,5 @@
        0049-wmemchr
        0050-wmemcpy
        0051-wmemmove
       +0052-wmemset
        0053-wmemcmp