diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-11-13 00:43:43 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2022-11-13 01:14:49 -0500 |
commit | a634557a881b59b8be1dc156f9822c6d20bd8741 (patch) | |
tree | fd953a0ea1d9a02a8d73a15f1aead27b59c5ffaa /firmware/libc/strcspn.c | |
parent | ffe2df2e92cbdeb507a49279a85ac88cac2fbe4f (diff) | |
download | rockbox-a634557a881b59b8be1dc156f9822c6d20bd8741.tar.gz rockbox-a634557a881b59b8be1dc156f9822c6d20bd8741.zip |
fix strptokspn, add strcspn, fix splash.c
fix off by 1 error in strptokspn, add strcspn, fix fallout in splash.c
Change-Id: I61475d9633fc35db5a8ae30cbe588f69f2f7fabc
Diffstat (limited to 'firmware/libc/strcspn.c')
-rw-r--r-- | firmware/libc/strcspn.c | 45 |
1 files changed, 45 insertions, 0 deletions
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 @@ | |||
1 | /* | ||
2 | FUNCTION | ||
3 | <<strcspn>>---count characters not in string | ||
4 | INDEX | ||
5 | strcspn | ||
6 | ANSI_SYNOPSIS | ||
7 | size_t strcspn(const char *<[s1]>, const char *<[s2]>); | ||
8 | TRAD_SYNOPSIS | ||
9 | size_t strcspn(<[s1]>, <[s2]>) | ||
10 | char *<[s1]>; | ||
11 | char *<[s2]>; | ||
12 | DESCRIPTION | ||
13 | This function computes the length of the initial part of | ||
14 | the string pointed to by <[s1]> which consists entirely of | ||
15 | characters <[NOT]> from the string pointed to by <[s2]> | ||
16 | (excluding the terminating null character). | ||
17 | RETURNS | ||
18 | <<strcspn>> returns the length of the substring found. | ||
19 | PORTABILITY | ||
20 | <<strcspn>> is ANSI C. | ||
21 | <<strcspn>> requires no supporting OS subroutines. | ||
22 | */ | ||
23 | #include <string.h> | ||
24 | #include "_ansi.h" /* for _DEFUN */ | ||
25 | |||
26 | size_t | ||
27 | _DEFUN (strcspn, (s1, s2), | ||
28 | _CONST char *s1 _AND | ||
29 | _CONST char *s2) | ||
30 | { | ||
31 | _CONST char *s = s1; | ||
32 | _CONST char *c; | ||
33 | while (*s1) | ||
34 | { | ||
35 | for (c = s2; *c; c++) | ||
36 | { | ||
37 | if (*s1 == *c) | ||
38 | break; | ||
39 | } | ||
40 | if (*c) | ||
41 | break; | ||
42 | s1++; | ||
43 | } | ||
44 | return s1 - s; | ||
45 | } | ||