2019-03-06 14:32:51 +01:00
|
|
|
//---
|
|
|
|
// gint:core:string - replicas of a few string functions
|
|
|
|
//---
|
|
|
|
|
|
|
|
#include <gint/defs/types.h>
|
|
|
|
#include <gint/defs/attributes.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2019-09-19 15:59:38 +02:00
|
|
|
GWEAK size_t strlen(char const *str)
|
2019-03-06 14:32:51 +01:00
|
|
|
{
|
|
|
|
int len = 0;
|
|
|
|
while(str[len]) len++;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2019-09-19 15:59:38 +02:00
|
|
|
GWEAK char *strncpy(char *dst, char const *src, size_t n)
|
2019-05-04 12:07:14 +02:00
|
|
|
{
|
|
|
|
size_t i = 0;
|
|
|
|
while(i < n && (dst[i] = src[i])) i++;
|
|
|
|
return dst;
|
|
|
|
}
|
2019-07-19 15:06:24 +02:00
|
|
|
|
2019-09-19 15:59:38 +02:00
|
|
|
GWEAK char *strcat(char *dest, char const *src)
|
2019-07-19 15:06:24 +02:00
|
|
|
{
|
2019-09-19 15:59:38 +02:00
|
|
|
unsigned long fin_dest = strlen(dest);
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0 ; i <= strlen(src) ; i++) dest[fin_dest + i] = src[i];
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
GWEAK int strcmp(char const *s1, char const *s2)
|
|
|
|
{
|
|
|
|
while(*s1 && *s1 == *s2) s1++, s2++;
|
|
|
|
return *s1 - *s2;
|
2019-07-19 15:06:24 +02:00
|
|
|
}
|