26 char *d =
malloc(sz_1 + sz_2 + 1);
29 memcpy(d + sz_1, s2, sz_2 + 1);
34 size_t strnlen(
const char *src,
size_t max)
37 while ((*src++) && (i < max))
92 char *
strcpy(
char *dst,
const char *src)
103 int strcmp(
const char *s1,
const char *s2)
107 while ((r = (*s1 - *s2)) == 0 && *s1) {
114 int strncmp(
const char *s1,
const char *s2,
int maxlen)
118 for (i = 0; i < maxlen; i++) {
119 if ((s1[i] != s2[i]) || (s1[i] ==
'\0'))
120 return s1[i] - s2[i];
131 i = i*10 + *((*s)++) -
'0';
135 int strspn(
const char *str,
const char *spn)
141 for (p = spn; *str != *p; p++)
156 for (p = spn; *p !=
'\0'; p++)
165 char *
strstr(
const char *haystack,
const char *needle)
167 size_t needle_len =
strlen(needle);
168 for (; *haystack; haystack++) {
169 if (!
strncmp(haystack, needle, needle_len))
170 return (
char *)haystack;
175 char *
strtok_r(
char *str,
const char *delim,
char **ptr)
182 start = str +
strspn(str, delim);
183 if (start[0] ==
'\0')
186 end = start +
strcspn(start, delim);
193 char *
strtok(
char *str,
const char *delim)
195 static char *strtok_ptr;
197 return strtok_r(str, delim, &strtok_ptr);
205 str +=
strspn(str,
" \t\n\r\f\v");
210 }
else if (*str ==
'-') {
void * memcpy(void *dest, const void *src, size_t n)
static int isdigit(int c)
void * malloc(size_t size)
char * strrchr(const char *s, int c)
Find a character in a string.
int strcmp(const char *s1, const char *s2)
char * strchr(const char *s, int c)
char * strncpy(char *to, const char *from, int count)
char * strcpy(char *dst, const char *src)
char * strconcat(const char *s1, const char *s2)
unsigned int skip_atoi(char **s)
int strncmp(const char *s1, const char *s2, int maxlen)
char * strstr(const char *haystack, const char *needle)
int strcspn(const char *str, const char *spn)
char * strtok(char *str, const char *delim)
size_t strnlen(const char *src, size_t max)
int strspn(const char *str, const char *spn)
char * strdup(const char *s)
size_t strlen(const char *src)
long atol(const char *str)
char * strtok_r(char *str, const char *delim, char **ptr)
#define s(param, src_bits, pmcreg, dst_bits)
#define c(value, pmcreg, dst_bits)