diff options
| author | Jakob Kaivo <jkk@ung.org> | 2024-06-05 14:52:59 -0400 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2024-06-05 14:52:59 -0400 |
| commit | 21c4009fac9456bc921ebfa4b88467765dce71d9 (patch) | |
| tree | fa3bd319b8fc8c84373dbcb31eefc2c476cd3211 /src/wchar | |
| parent | d105976002aa32a3cbe42b7f06a0dcba5d176afd (diff) | |
handle tracking previous calls to wcstok()
Diffstat (limited to 'src/wchar')
| -rw-r--r-- | src/wchar/__wchar_h.c | 3 | ||||
| -rw-r--r-- | src/wchar/_wchar.h | 5 | ||||
| -rw-r--r-- | src/wchar/wcstok.c | 14 |
3 files changed, 16 insertions, 6 deletions
diff --git a/src/wchar/__wchar_h.c b/src/wchar/__wchar_h.c new file mode 100644 index 00000000..20eba1c2 --- /dev/null +++ b/src/wchar/__wchar_h.c @@ -0,0 +1,3 @@ +#include "_wchar.h" + +struct __wchar_h __wchar_h = { 0 }; diff --git a/src/wchar/_wchar.h b/src/wchar/_wchar.h index e5d87c7e..9b3a0cb2 100644 --- a/src/wchar/_wchar.h +++ b/src/wchar/_wchar.h @@ -6,6 +6,11 @@ #include "_safety.h" #include "locale/_locale.h" +extern struct __wchar_h { + wchar_t **wcstok; + size_t nwcstok; +} __wchar_h; + struct __mbstate_t { unsigned int ctype_epoch; enum { NONE, WTOMB, MBTOW } dir; diff --git a/src/wchar/wcstok.c b/src/wchar/wcstok.c index a9cf8d01..02d2f87e 100644 --- a/src/wchar/wcstok.c +++ b/src/wchar/wcstok.c @@ -1,19 +1,21 @@ -#if 0 - #include <wchar.h> +#include "_wchar.h" wchar_t * wcstok(wchar_t * restrict s1, const wchar_t * restrict s2, wchar_t ** restrict ptr) { SIGNAL_SAFE(0); /* TODO: overlap */ + if (s1 == NULL) { + ASSERT_PREV(*ptr, __wchar_h.wcstok, __wchar_h.nwcstok, "wcstok"); + } + + (void)s1; (void)s2; + *ptr = s1; + ADD_PREV(*ptr, __wchar_h.wcstok, __wchar_h.nwcstok); - (void)s1; (void)s2; (void)ptr; return s1; } /* STDC(199409) */ - - -#endif |
