diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-09-10 18:47:17 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-09-10 18:47:17 +0200 |
commit | ec66c414866572fcd77a5bf7e4a444e84d8aa804 (patch) | |
tree | 50b95bea4fdc18396e581506369bd7d67bcc438b /src/string.c | |
parent | 41aba5755c9fa6082aec99c4fec6c571f8e5062a (diff) | |
parent | 4fbd529e776527e548b343a82e14d1cb7eb30764 (diff) |
Merge branch 'release/experimental/3.25-1_exp1' into masterexperimental/3.25-1_exp1
Diffstat (limited to 'src/string.c')
-rw-r--r-- | src/string.c | 12 |
1 files changed, 7 insertions, 5 deletions
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; |