123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- #include <assert.h>
- #include <string.h>
- #include "lt__strl.h"
- #if !defined HAVE_STRLCAT
- size_t
- lt_strlcat(char *dst, const char *src, const size_t dstsize)
- {
- size_t length;
- char *p;
- const char *q;
- assert(dst != NULL);
- assert(src != (const char *) NULL);
- assert(dstsize >= 1);
- length=strlen(dst);
-
- for ( p = dst + length, q = src;
- (*q != 0) && (length < dstsize - 1);
- length++, p++, q++ )
- *p = *q;
- dst[length]='\0';
-
- while (*q++)
- length++;
- return length;
- }
- #endif
- #if !defined HAVE_STRLCPY
- size_t
- lt_strlcpy(char *dst, const char *src, const size_t dstsize)
- {
- size_t length=0;
- char *p;
- const char *q;
- assert(dst != NULL);
- assert(src != (const char *) NULL);
- assert(dstsize >= 1);
-
- for ( p=dst, q=src, length=0;
- (*q != 0) && (length < dstsize-1);
- length++, p++, q++ )
- *p = *q;
- dst[length]='\0';
-
- while (*q++)
- length++;
- return length;
- }
- #endif
|