123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include <string.h>
- #include "memcopy.h"
- char *strncat (char *s1, const char *s2, size_t n)
- {
- reg_char c;
- char *s = s1;
-
- do
- c = *s1++;
- while (c != '\0');
-
- s1 -= 2;
- if (n >= 4)
- {
- size_t n4 = n >> 2;
- do
- {
- c = *s2++;
- *++s1 = c;
- if (c == '\0')
- return s;
- c = *s2++;
- *++s1 = c;
- if (c == '\0')
- return s;
- c = *s2++;
- *++s1 = c;
- if (c == '\0')
- return s;
- c = *s2++;
- *++s1 = c;
- if (c == '\0')
- return s;
- } while (--n4 > 0);
- n &= 3;
- }
- while (n > 0)
- {
- c = *s2++;
- *++s1 = c;
- if (c == '\0')
- return s;
- n--;
- }
- if (c != '\0')
- *++s1 = '\0';
- return s;
- }
- libc_hidden_def(strncat)
|