X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibc.so_src%2Fstring.c;h=4e8dfe2e20f01858618da2bb15ca02e775ff0493;hb=1529dadb6c2170bf9899fbde46d06a3d9a392b52;hp=e85356d5b11b46f7c99922b947b9f4e352f141a7;hpb=efa38e0d56b1b620b6f4e5c4f91abc483a3065e2;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libc.so_src/string.c b/Usermode/Libraries/libc.so_src/string.c index e85356d5..4e8dfe2e 100644 --- a/Usermode/Libraries/libc.so_src/string.c +++ b/Usermode/Libraries/libc.so_src/string.c @@ -19,6 +19,19 @@ EXPORT int strcmp(const char *s1, const char *s2) return (int)*s1 - (int)*s2; } +/** + * \fn EXPORT int strncmp(const char *s1, const char *s2) + * \brief Compare two strings + */ +EXPORT int strncmp(const char *s1, const char *s2, size_t n) +{ + if( n == 0 ) return 0; + while(n -- && *s1 == *s2 && *s1 != '\0' && *s2 != '\0') { + s1++; s2++; + } + return (int)*s1 - (int)*s2; +} + /** * \fn EXPORT char *strcpy(char *dst, const char *src) * \brief Copy a string to another