From 4105e737e6ec9b9d8aca508ac5bedb69947b202d Mon Sep 17 00:00:00 2001 From: default Date: Wed, 13 Sep 2023 18:19:19 +0200 Subject: Backport from xs. --- xs_regex.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'xs_regex.h') diff --git a/xs_regex.h b/xs_regex.h index 7e1c80f..3425661 100644 --- a/xs_regex.h +++ b/xs_regex.h @@ -33,12 +33,12 @@ xs_list *xs_regex_split_n(const char *str, const char *rx, int count) while (count > 0 && !regexec(&re, (p = str + offset), 1, &rm, offset > 0 ? REG_NOTBOL : 0)) { /* add first the leading part of the string */ - list = xs_list_append_m(list, p, rm.rm_so); - list = xs_insert_m(list, xs_size(list) - 1, "", 1); + xs *s1 = xs_str_new_sz(p, rm.rm_so); + list = xs_list_append(list, s1); /* add now the matched text as the separator */ - list = xs_list_append_m(list, p + rm.rm_so, rm.rm_eo - rm.rm_so); - list = xs_insert_m(list, xs_size(list) - 1, "", 1); + xs *s2 = xs_str_new_sz(p + rm.rm_so, rm.rm_eo - rm.rm_so); + list = xs_list_append(list, s2); /* move forward */ offset += rm.rm_eo; -- cgit v1.2.3