find finished
This commit is contained in:
21
user/ulib.c
21
user/ulib.c
@@ -21,12 +21,33 @@ char *strcpy(char *s, const char *t) {
|
||||
return os;
|
||||
}
|
||||
|
||||
char *strncpy(char *s, const char *t, int n) {
|
||||
char *os;
|
||||
|
||||
os = s;
|
||||
if (n <= 0)
|
||||
return os;
|
||||
while (--n > 0 && (*s++ = *t++) != 0)
|
||||
;
|
||||
while (n-- > 0)
|
||||
*s++ = 0;
|
||||
return os;
|
||||
}
|
||||
|
||||
int strcmp(const char *p, const char *q) {
|
||||
while (*p && *p == *q)
|
||||
p++, q++;
|
||||
return (uchar)*p - (uchar)*q;
|
||||
}
|
||||
|
||||
int strncmp(const char *p, const char *q, int n) {
|
||||
while (n > 0 && *p && *p == *q)
|
||||
p++, q++, n--;
|
||||
if (n == 0)
|
||||
return 0;
|
||||
return (uchar)*p - (uchar)*q;
|
||||
}
|
||||
|
||||
uint strlen(const char *s) {
|
||||
int n;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user