summaryrefslogtreecommitdiff
path: root/xs_regex.h
diff options
context:
space:
mode:
authorGravatar default2023-09-13 18:19:19 +0200
committerGravatar default2023-09-13 18:19:19 +0200
commit4105e737e6ec9b9d8aca508ac5bedb69947b202d (patch)
treef90686ed12ef4ea2b50e65ddeee42bf3650144eb /xs_regex.h
parentUpdated RELEASE_NOTES. (diff)
downloadsnac2-4105e737e6ec9b9d8aca508ac5bedb69947b202d.tar.gz
snac2-4105e737e6ec9b9d8aca508ac5bedb69947b202d.tar.xz
snac2-4105e737e6ec9b9d8aca508ac5bedb69947b202d.zip
Backport from xs.
Diffstat (limited to '')
-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)
33 33
34 while (count > 0 && !regexec(&re, (p = str + offset), 1, &rm, offset > 0 ? REG_NOTBOL : 0)) { 34 while (count > 0 && !regexec(&re, (p = str + offset), 1, &rm, offset > 0 ? REG_NOTBOL : 0)) {
35 /* add first the leading part of the string */ 35 /* add first the leading part of the string */
36 list = xs_list_append_m(list, p, rm.rm_so); 36 xs *s1 = xs_str_new_sz(p, rm.rm_so);
37 list = xs_insert_m(list, xs_size(list) - 1, "", 1); 37 list = xs_list_append(list, s1);
38 38
39 /* add now the matched text as the separator */ 39 /* add now the matched text as the separator */
40 list = xs_list_append_m(list, p + rm.rm_so, rm.rm_eo - rm.rm_so); 40 xs *s2 = xs_str_new_sz(p + rm.rm_so, rm.rm_eo - rm.rm_so);
41 list = xs_insert_m(list, xs_size(list) - 1, "", 1); 41 list = xs_list_append(list, s2);
42 42
43 /* move forward */ 43 /* move forward */
44 offset += rm.rm_eo; 44 offset += rm.rm_eo;