bare-arm/lib: Add minimal strncmp implementation.
Required by upcoming qstr sorting. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
78f4f30cb1
commit
e910533012
@ -109,16 +109,23 @@ char *strchr(const char *s, int c) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int strcmp(const char *s1, const char *s2) {
|
||||
while (*s1 && *s2) {
|
||||
int strncmp(const char *s1, const char *s2, size_t n) {
|
||||
while (*s1 && *s2 && n-- > 0) {
|
||||
int c = *s1++ - *s2++;
|
||||
if (c) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
return *s1 - *s2;
|
||||
}
|
||||
|
||||
int strcmp(const char *s1, const char *s2) {
|
||||
return strncmp(s1, s2, 0x7fffffff);
|
||||
}
|
||||
|
||||
size_t strlen(const char *s) {
|
||||
const char *ss = s;
|
||||
while (*ss) {
|
||||
|
Loading…
Reference in New Issue
Block a user