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/string.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/string.c') diff --git a/src/string.c b/src/string.c index 2761276..354a409 100644 --- a/src/string.c +++ b/src/string.c @@ -232,7 +232,7 @@ EXPORT_SYMBOL char **HX_split(const char *str, const char *delim, return ret; } -EXPORT_SYMBOL char **HX_split4(char *s, const char *delim, int *fld, int max) +EXPORT_SYMBOL char **HX_split_inplace(char *s, const char *delim, int *fld, int max) { char **stk; const char *p = s; @@ -248,22 +248,22 @@ EXPORT_SYMBOL char **HX_split4(char *s, const char *delim, int *fld, int max) if (stk == NULL) return NULL; stk[count] = NULL; - count = HX_split5(s, delim, count, stk); + count = HX_split_fixed(s, delim, count, stk); if (fld != NULL) *fld = count; return stk; } -EXPORT_SYMBOL int HX_split5(char *s, const char *delim, int max, char **stk) +EXPORT_SYMBOL int HX_split_fixed(char *s, const char *delim, int max, char **stk) { /* - * HX_split5 - the "stack split" (we try to avoid using the heap): + * HX_split_fixed - the "stack split" (we try to avoid using the heap): * Split @s (modifies it, so must be writable!) at @delim with at most * @max fields and putting the results into @stk[0..@max-1]. * * Example on @max: * char *stk[max]; - * HX_split5(s, delim, max, stk); + * HX_split_fixed(s, delim, max, stk); */ int i = 0; char *p; @@ -336,6 +336,8 @@ EXPORT_SYMBOL char *HX_strlcat(char *dest, const char *src, size_t len) EXPORT_SYMBOL char *HX_strlcpy(char *dest, const char *src, size_t n) { + if (n == 0) + return dest; strncpy(dest, src, n); dest[n-1] = '\0'; return dest; -- cgit v1.2.3