-
-char *strcat(char *s, const char *append)
-{
- char *save = s;
-
- for (; *s; ++s);
- while ((*s++ = *append++));
- return save;
-}
-
-
-char *strchr(const char *s, int c)
-{
- char cc = c;
-
- while (*s)
- {
- if (*s == cc)
- return (char *)s;
- s++;
- }
-
- if (cc == 0)
- return (char *)s;
-
- return 0;
-}
-
-
-int strcmp(const char *s1, const char *s2)
-{
- while (*s1 == *s2)
- {
- if (*s1 == 0)
- return 0;
- s1++;
- s2++;
- }
-
- return *(unsigned const char *)s1 - *(unsigned const char *)(s2);
-}
-
-
-char* strcpy(char *to, const char *from)
-{
- char *save = to;
-
- for (; (*to = *from); ++from, ++to);
-
- return save;
-}
-
-
-size_t strlen(const char *str)
-{
- const char *s;
-
- if (str == 0)
- return 0;
- for (s = str; *s; ++s);
-
- return s-str;
-}
-
-
-char *strncat(char *dst, const char *src, size_t n)
-{
- if (n != 0)
- {
- char *d = dst;
- const char *s = src;
-
- while (*d != 0)
- d++;
- do
- {
- if ((*d = *s++) == 0)
- break;
- d++;
- }
- while (--n != 0);
- *d = 0;
- }
-
- return dst;
-}
-
-
-int strncmp(const char *s1, const char *s2, size_t n)
-{
- if (n == 0)
- return 0;
- do
- {
- if (*s1 != *s2++)
- return *(unsigned const char *)s1 - *(unsigned const char *)--s2;
- if (*s1++ == 0)
- break;
- }
- while (--n != 0);
-
- return 0;
-}
-
-
-char *strncpy(char *dst, const char *src, size_t n)
-{
- if (n != 0)
- {
- char *d = dst;
- const char *s = src;
-
- do
- {
- if ((*d++ = *s++) == 0)
- {
- while (--n != 0)
- *d++ = 0;
- break;
- }
- }
- while (--n != 0);
- d[0] = 0;
- }
- else
- {
- dst[0] = 0;
- }
- return dst;
-}
-
-
-char *strrchr(const char *s, int c)
-{
- char cc = c;
- const char *sp=(char *)0;
-
- while (*s)
- {
- if (*s == cc)
- sp = s;
- s++;
- }
-
- if (cc == 0)
- sp = s;
-
- return (char *)sp;
-}
-
-
-size_t strspn(const char *s1, const char *s2)
-{
- const char *p = s1, *spanp;
- char c, sc;
-
- cont:
- c = *p++;
- for (spanp = s2; (sc = *spanp++) != 0;)
- if (sc == c)
- goto cont;
-
- return (p - 1 - s1);
-}
-
-