Skip to content
Snippets Groups Projects
Commit 8657dc5b authored by John Hodge's avatar John Hodge
Browse files

Kernel - Implemented strcat/strncat

parent e9391ef5
No related merge requests found
......@@ -335,6 +335,8 @@ extern int sprintf(char *__s, const char *__format, ...);
extern size_t strlen(const char *Str);
extern char *strcpy(char *__dest, const char *__src);
extern char *strncpy(char *__dest, const char *__src, size_t max);
extern char *strcat(char *__dest, const char *__src);
extern char *strncat(char *__dest, const char *__src, size_t n);
extern int strcmp(const char *__str1, const char *__str2);
extern int strncmp(const char *Str1, const char *Str2, size_t num);
extern int strucmp(const char *Str1, const char *Str2);
......
......@@ -62,6 +62,8 @@ EXPORT(ByteSum);
EXPORT(strlen);
EXPORT(strcpy);
EXPORT(strncpy);
EXPORT(strcat);
EXPORT(strncat);
EXPORT(strcmp);
EXPORT(strncmp);
//EXPORT(strdup);
......@@ -464,7 +466,6 @@ size_t strlen(const char *__str)
}
/**
* \fn char *strcpy(char *__str1, const char *__str2)
* \brief Copy a string to a new location
*/
char *strcpy(char *__str1, const char *__str2)
......@@ -476,8 +477,8 @@ char *strcpy(char *__str1, const char *__str2)
}
/**
* \fn char *strncpy(char *__str1, const char *__str2, size_t max)
* \brief Copy a string to a new location
* \note Copies at most `max` chars
*/
char *strncpy(char *__str1, const char *__str2, size_t max)
{
......@@ -488,6 +489,31 @@ char *strncpy(char *__str1, const char *__str2, size_t max)
return __str1;
}
/**
* \brief Append a string to another
*/
char *strcat(char *__dest, const char *__src)
{
while(*__dest++);
while(*__src)
*__dest++ = *__src++;
*__dest = '\0';
return __dest;
}
/**
* \brief Append at most \a n chars to a string from another
* \note At most n+1 chars are written (the dest is always zero terminated)
*/
char *strncat(char *__dest, const char *__src, size_t n)
{
while(*__dest++);
while(*__src && n-- >= 1)
*__dest++ = *__src++;
*__dest = '\0';
return __dest;
}
/**
* \fn int strcmp(const char *str1, const char *str2)
* \brief Compare two strings return the difference between
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment