mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
userspace/libc: implement strncpy function
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
parent
23a17fae00
commit
24fd486764
@ -51,7 +51,7 @@ extern "C"
|
||||
size_t strlen(const char *s);
|
||||
char *strncat(char *restrict, const char *restrict, size_t);
|
||||
int strncmp(const char *s1, const char *s2, size_t n);
|
||||
char *strncpy(char *restrict, const char *restrict, size_t);
|
||||
char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
|
||||
char *strndup(const char *, size_t);
|
||||
size_t strnlen(const char *, size_t);
|
||||
char *strpbrk(const char *s1, const char *s2);
|
||||
|
@ -124,7 +124,19 @@ export int strncmp(const char *s1, const char *s2, size_t n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
export char *strncpy(char *restrict, const char *restrict, size_t);
|
||||
export char *strncpy(char *restrict s1, const char *restrict s2, size_t n)
|
||||
{
|
||||
char *dest = s1;
|
||||
while (n && (*dest++ = *s2++))
|
||||
n--;
|
||||
|
||||
if (n)
|
||||
while (--n)
|
||||
*dest++ = '\0';
|
||||
|
||||
return s1;
|
||||
}
|
||||
|
||||
export char *strndup(const char *, size_t);
|
||||
export size_t strnlen(const char *, size_t);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user