From a1bdcfa3ca8af4ddb69ee57d716aa943cf3fe94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 16 May 2020 16:33:18 +0200 Subject: New upstream version 3.25 --- src/tc-string.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/tc-string.c') diff --git a/src/tc-string.c b/src/tc-string.c index 112a845..6e85f66 100644 --- a/src/tc-string.c +++ b/src/tc-string.c @@ -160,8 +160,8 @@ static void t_split(void) memcpy(t2, t1, sizeof(t1)); a0 = HX_split(t1, ":", &f0, 0); - a1 = HX_split4(t1, ":", &f1, 0); - f2 = HX_split5(t2, ":", ARRAY_SIZE(a2), a2); + a1 = HX_split_inplace(t1, ":", &f1, 0); + f2 = HX_split_fixed(t2, ":", ARRAY_SIZE(a2), a2); /* complete allocation */ printf("HX_split1: a0[%p]:", a0); @@ -170,7 +170,7 @@ static void t_split(void) printf("\n"); /* array allocated */ - printf("HX_split4: a1[%p]:", a1); + printf("HX_split_inplace: a1[%p]:", a1); for (wp = a1; *wp != NULL; ++wp) printf(" %s[%p]", *wp, *wp); printf("\n"); @@ -202,6 +202,8 @@ extern char *f_strlcpy_mem(char *, const char *, size_t); EXPORT_SYMBOL char *f_strlcpy_str(char *d, const char *s, size_t n) { + if (n == 0) + return d; strncpy(d, s, n); d[n-1] = '\0'; return d; @@ -279,6 +281,13 @@ static void t_strlcpy(void) } } +static void t_strlcpy2(void) +{ + char a[3] = {49, 49, 49}; + HX_strlcpy(&a[1], &a[1], 0); + assert(a[0] == 49 && a[0] == a[1] && a[1] == a[2]); +} + int main(int argc, const char **argv) { hxmc_t *tx = NULL; @@ -308,6 +317,7 @@ int main(int argc, const char **argv) t_split(); t_split2(); t_strlcpy(); + t_strlcpy2(); HXmc_free(tx); HX_exit(); return EXIT_SUCCESS; -- cgit v1.2.3