core: fix number of arguments returned by string_split
When keep_eol is 2 and separators are found at the end of string, the function returned argc + 1 instead of argc.v2.8-utf8proc
parent
0bdf148491
commit
d6af8c312f
|
@ -27,6 +27,8 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
|||
[[1.5_bugs]]
|
||||
=== Bugs fixed
|
||||
|
||||
* api: fix number of arguments returned by function string_split() when
|
||||
keep_eol is 2 and the string ends with separators
|
||||
* irc: add missing completion "*" for target in command /msg
|
||||
* irc: fix /msg command with multiple targets including "*"
|
||||
|
||||
|
|
|
@ -1587,17 +1587,30 @@ string_replace_regex (const char *string, void *regex, const char *replace,
|
|||
* This function must not be called directly (call string_split or
|
||||
* string_split_shared instead).
|
||||
*
|
||||
* According to keep_eol value:
|
||||
* 0: standard split
|
||||
* 1: each argument contains the argument and all the following arguments
|
||||
* 2: same as 1, and separator is kept at the end of string.
|
||||
*
|
||||
* Examples:
|
||||
* string_split ("abc de fghi", " ", 0, 0, NULL)
|
||||
* ==> array[0] = "abc"
|
||||
* array[1] = "de"
|
||||
* array[2] = "fghi"
|
||||
* array[3] = NULL
|
||||
* string_split ("abc de fghi", " ", 1, 0, NULL)
|
||||
* ==> array[0] = "abc de fghi"
|
||||
* array[1] = "de fghi"
|
||||
* array[2] = "fghi"
|
||||
* array[3] = NULL
|
||||
* string_split ("abc de fghi ", " ", 0, 0, &argc)
|
||||
* ==> argc == 3
|
||||
* array[0] == "abc"
|
||||
* array[1] == "de"
|
||||
* array[2] == "fghi"
|
||||
* array[3] == NULL
|
||||
* string_split ("abc de fghi ", " ", 1, 0, &argc)
|
||||
* ==> argc == 3
|
||||
* array[0] == "abc de fghi"
|
||||
* array[1] == "de fghi"
|
||||
* array[2] == "fghi"
|
||||
* array[3] == NULL
|
||||
* string_split ("abc de fghi ", " ", 2, 0, &argc)
|
||||
* ==> argc == 3
|
||||
* array[0] == "abc de fghi "
|
||||
* array[1] == "de fghi "
|
||||
* array[2] == "fghi "
|
||||
* array[3] == NULL
|
||||
*/
|
||||
|
||||
char **
|
||||
|
@ -1628,7 +1641,8 @@ string_split_internal (const char *string, const char *separators, int keep_eol,
|
|||
{
|
||||
ptr++;
|
||||
}
|
||||
i++;
|
||||
if (ptr[0])
|
||||
i++;
|
||||
}
|
||||
n_items = i;
|
||||
|
||||
|
|
Loading…
Reference in New Issue