mirror of
https://git.stationery.faith/corn/corn.git
synced 2024-11-22 06:32:18 +00:00
more lib fns
This commit is contained in:
parent
90c70043be
commit
eec8119eee
2 changed files with 23 additions and 0 deletions
|
@ -31,6 +31,18 @@ extern void *memset(void *restrict dest, int c, unsigned long n);
|
||||||
*/
|
*/
|
||||||
extern int strncmp(const char *restrict s1, const char *restrict s2, unsigned long n);
|
extern int strncmp(const char *restrict s1, const char *restrict s2, unsigned long n);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copys the string pointed to by src , into a string at the buffer pointer to by dest.
|
||||||
|
* The dest buffer must be long enough to hold src.
|
||||||
|
*/
|
||||||
|
extern char *strcpy(char *restrict dest, const char *restrict src);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copys the string pointed to by src , into a string at the buffer pointer to by dest.
|
||||||
|
* The dest buffer must be long enough to hold src or size n.
|
||||||
|
*/
|
||||||
|
extern char *strncpy(char *restrict dest, const char *restrict src, unsigned long n);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns 1 if c is a space
|
* @returns 1 if c is a space
|
||||||
*/
|
*/
|
||||||
|
|
11
src/lib.c
11
src/lib.c
|
@ -43,6 +43,17 @@ int strncmp(const char *restrict lhs, const char *restrict rhs, unsigned long n)
|
||||||
return *l - *r;
|
return *l - *r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *strcpy(char *restrict dest, const char *restrict src) {
|
||||||
|
for(; (*dest = *src); dest++, src++);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *strncpy(char *restrict dest, const char *restrict src, unsigned long n) {
|
||||||
|
for(; (*dest = *src) && n; dest++, src++, n--);
|
||||||
|
memset(dest, 0, n);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
int isspace(int c) {
|
int isspace(int c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case ' ':
|
case ' ':
|
||||||
|
|
Loading…
Reference in a new issue