kopia lustrzana https://github.com/micropython/micropython
bare-arm/lib: Add minimal strncmp implementation.
Required by upcoming qstr sorting. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>pull/12678/head
rodzic
78f4f30cb1
commit
e910533012
|
@ -109,16 +109,23 @@ char *strchr(const char *s, int c) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int strcmp(const char *s1, const char *s2) {
|
int strncmp(const char *s1, const char *s2, size_t n) {
|
||||||
while (*s1 && *s2) {
|
while (*s1 && *s2 && n-- > 0) {
|
||||||
int c = *s1++ - *s2++;
|
int c = *s1++ - *s2++;
|
||||||
if (c) {
|
if (c) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (n == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return *s1 - *s2;
|
return *s1 - *s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int strcmp(const char *s1, const char *s2) {
|
||||||
|
return strncmp(s1, s2, 0x7fffffff);
|
||||||
|
}
|
||||||
|
|
||||||
size_t strlen(const char *s) {
|
size_t strlen(const char *s) {
|
||||||
const char *ss = s;
|
const char *ss = s;
|
||||||
while (*ss) {
|
while (*ss) {
|
||||||
|
|
Ładowanie…
Reference in New Issue