libc/wchar: Add wcspbrk() - 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 0cc26f9abb8c7f8a5ad30563d63bda35a5345322
 (DIR) parent 281fd80448d875367f4be096a00ebbc847a06c1b
 (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
       Date:   Wed, 26 Mar 2025 14:46:30 +0100
       
       libc/wchar: Add wcspbrk()
       
       Diffstat:
         M src/libc/objs/common-objs.mk        |       1 +
         A src/libc/wchar/wcspbrk.c            |      10 ++++++++++
         M tests/libc/execute/.gitignore       |       1 +
         A tests/libc/execute/0063-wcspbrk.c   |      28 ++++++++++++++++++++++++++++
         M tests/libc/execute/libc-tests.lst   |       1 +
       
       5 files changed, 41 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/libc/objs/common-objs.mk b/src/libc/objs/common-objs.mk
       @@ -139,6 +139,7 @@ COMMON_OBJS =\
                wchar/wcsxfrm.$O\
                wchar/wcsspn.$O\
                wchar/wcscspn.$O\
       +        wchar/wcspbrk.$O\
                wchar/wcsrtombs.$O\
                wchar/wcwidth.$O\
                wchar/wmemchr.$O\
 (DIR) diff --git a/src/libc/wchar/wcspbrk.c b/src/libc/wchar/wcspbrk.c
       @@ -0,0 +1,10 @@
       +#include <wchar.h>
       +
       +#undef wcspbrk
       +
       +wchar_t *
       +wcspbrk(const wchar_t *s1, const wchar_t *s2)
       +{
       +        s1 += wcscspn(s1, s2);
       +        return (*s1 != L'\0') ? (wchar_t *) s1 : NULL;
       +}
 (DIR) diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore
       @@ -59,4 +59,5 @@
        0060-wcsxfrm
        0061-wcsspn
        0062-wcscspn
       +0063-wcspbrk
        test.log
 (DIR) diff --git a/tests/libc/execute/0063-wcspbrk.c b/tests/libc/execute/0063-wcspbrk.c
       @@ -0,0 +1,28 @@
       +#include <assert.h>
       +#include <stdio.h>
       +#include <wchar.h>
       +
       +/*
       +output:
       +testing
       +done
       +end:
       +*/
       +
       +int
       +main()
       +{
       +        wchar_t buf[] = L"abcdef";
       +
       +        puts("testing");
       +        assert(wcspbrk(buf, L"a") == buf);
       +        assert(wcspbrk(buf, L"") == NULL);
       +        assert(wcspbrk(L"", L"a") == NULL);
       +        assert(wcspbrk(L"", L"") == NULL);
       +        assert(wcspbrk(buf, L"1234") == NULL);
       +        assert(wcspbrk(buf, L"f") == buf + 5);
       +        assert(wcspbrk(buf, L"12345a") == buf);
       +        puts("done");
       +
       +        return 0;
       +}
 (DIR) diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst
       @@ -58,3 +58,4 @@
        0060-wcsxfrm
        0061-wcsspn
        0062-wcscspn
       +0063-wcspbrk