forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libc: minimal: add strspn and strcspn support
These functions are useful for determining prefixes, as with file system paths. They are required by littlefs. Signed-off-by: Peter A. Bigot <[email protected]>
- Loading branch information
1 parent
b7db90d
commit 8420f43
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2019 Peter Bigot Consulting, LLC | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <string.h> | ||
#include <string.h> | ||
|
||
size_t strspn(const char *s, | ||
const char *accept) | ||
{ | ||
const char *ins = s; | ||
|
||
while ((*s != '\0') && (strchr(accept, *s) != NULL)) { | ||
++s; | ||
} | ||
|
||
return s - ins; | ||
} | ||
|
||
size_t strcspn(const char *s, | ||
const char *reject) | ||
{ | ||
const char *ins = s; | ||
|
||
while ((*s != '\0') && (strchr(reject, *s) == NULL)) { | ||
++s; | ||
} | ||
|
||
return s - ins; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters