Files
graphene/Pal/lib/string/strcmp.c
T
Dmitrii Kuvaiskii bd5d56b1a0 [Pal/lib] Add strncmp() and strspn() string manipulation funcs
These functions are required by the TOML C source code, which will be
embedded into Graphene in a future commit.
2020-10-15 08:27:43 -07:00

25 lines
515 B
C

/* SPDX-License-Identifier: LGPL-3.0-or-later */
#include "api.h"
int strcmp(const char* lhs, const char* rhs) {
while (*lhs == *rhs && *lhs) {
lhs++;
rhs++;
}
return *(unsigned char*)lhs - *(unsigned char*)rhs;
}
int strncmp(const char* lhs, const char* rhs, size_t maxlen) {
if (!maxlen)
return 0;
maxlen--;
while (*lhs == *rhs && *lhs && maxlen) {
lhs++;
rhs++;
maxlen--;
}
return *(unsigned char*)lhs - *(unsigned char*)rhs;
}