From a634557a881b59b8be1dc156f9822c6d20bd8741 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sun, 13 Nov 2022 00:43:43 -0500 Subject: fix strptokspn, add strcspn, fix splash.c fix off by 1 error in strptokspn, add strcspn, fix fallout in splash.c Change-Id: I61475d9633fc35db5a8ae30cbe588f69f2f7fabc --- firmware/libc/strcspn.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 firmware/libc/strcspn.c (limited to 'firmware/libc/strcspn.c') diff --git a/firmware/libc/strcspn.c b/firmware/libc/strcspn.c new file mode 100644 index 0000000000..ee50066ed1 --- /dev/null +++ b/firmware/libc/strcspn.c @@ -0,0 +1,45 @@ +/* +FUNCTION + <>---count characters not in string +INDEX + strcspn +ANSI_SYNOPSIS + size_t strcspn(const char *<[s1]>, const char *<[s2]>); +TRAD_SYNOPSIS + size_t strcspn(<[s1]>, <[s2]>) + char *<[s1]>; + char *<[s2]>; +DESCRIPTION + This function computes the length of the initial part of + the string pointed to by <[s1]> which consists entirely of + characters <[NOT]> from the string pointed to by <[s2]> + (excluding the terminating null character). +RETURNS + <> returns the length of the substring found. +PORTABILITY +<> is ANSI C. +<> requires no supporting OS subroutines. + */ +#include +#include "_ansi.h" /* for _DEFUN */ + +size_t +_DEFUN (strcspn, (s1, s2), + _CONST char *s1 _AND + _CONST char *s2) +{ + _CONST char *s = s1; + _CONST char *c; + while (*s1) + { + for (c = s2; *c; c++) + { + if (*s1 == *c) + break; + } + if (*c) + break; + s1++; + } + return s1 - s; +} -- cgit v1.2.3