summaryrefslogtreecommitdiff
path: root/xs_regex.h
diff options
context:
space:
mode:
Diffstat (limited to 'xs_regex.h')
-rw-r--r--xs_regex.h8
1 files changed, 4 insertions, 4 deletions
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;