summaryrefslogtreecommitdiff
path: root/src/string/wcscspn.c
diff options
context:
space:
mode:
authorVladimir Azarov <avm@intermediate-node.net>2024-10-01 15:47:05 +0200
committerVladimir Azarov <avm@intermediate-node.net>2024-10-01 15:47:05 +0200
commit4abab5ad6c8465a7528ccdd5f49367da05f78bbd (patch)
treeebf009bf1376a5a223a915bc27cbbd791a1316bc /src/string/wcscspn.c
Initial version
Diffstat (limited to 'src/string/wcscspn.c')
-rw-r--r--src/string/wcscspn.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/string/wcscspn.c b/src/string/wcscspn.c
new file mode 100644
index 0000000..c4e5272
--- /dev/null
+++ b/src/string/wcscspn.c
@@ -0,0 +1,10 @@
+#include <wchar.h>
+
+size_t wcscspn(const wchar_t *s, const wchar_t *c)
+{
+ const wchar_t *a;
+ if (!c[0]) return wcslen(s);
+ if (!c[1]) return (s=wcschr(a=s, *c)) ? s-a : wcslen(a);
+ for (a=s; *s && !wcschr(c, *s); s++);
+ return s-a;
+}