mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-18 06:31:23 +00:00
Add strcmp() and strncmp()
This commit is contained in:
parent
7d9746cf92
commit
4505b72ea2
@ -10,7 +10,8 @@ LIBRARY = libunix.a
|
|||||||
|
|
||||||
SOURCES = divsi3.S modsi3.S mulsi3.S udivsi3.S umodsi3.S free.c malloc.c \
|
SOURCES = divsi3.S modsi3.S mulsi3.S udivsi3.S umodsi3.S free.c malloc.c \
|
||||||
memcpy.c memset.c printf.c putchar.c puts.c read.c sprintf.c \
|
memcpy.c memset.c printf.c putchar.c puts.c read.c sprintf.c \
|
||||||
strcpy.c strlen.c strncpy.c vsprintf.c write.c
|
strcpy.c strlen.c strncpy.c vsprintf.c write.c strcmp.c \
|
||||||
|
strncmp.c
|
||||||
|
|
||||||
HEADERS =
|
HEADERS =
|
||||||
|
|
||||||
|
12
libunix/strcmp.c
Normal file
12
libunix/strcmp.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int strcmp(const char *__s1, const char *__s2)
|
||||||
|
{
|
||||||
|
while (*__s1 && *__s1 == *__s2)
|
||||||
|
{
|
||||||
|
__s1++;
|
||||||
|
__s2++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (*__s1 - *__s2);;
|
||||||
|
}
|
17
libunix/strncmp.c
Normal file
17
libunix/strncmp.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int strncmp(const char *__s1, const char *__s2, size_t __n)
|
||||||
|
{
|
||||||
|
int tmp;
|
||||||
|
while (__n--)
|
||||||
|
{
|
||||||
|
tmp = *__s1 - *__s2;
|
||||||
|
if (tmp)
|
||||||
|
return tmp;
|
||||||
|
if (!*__s1)
|
||||||
|
break;
|
||||||
|
__s1++; __s2++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user