summaryrefslogtreecommitdiff
path: root/xs_regex.h
diff options
context:
space:
mode:
authorGravatar default2024-08-30 19:10:26 +0200
committerGravatar default2024-08-30 19:10:26 +0200
commit0218e964b0d73340c8d0c5d9e37991359d7c4be9 (patch)
tree9cfc1650abf8780be52dc219e37a311244a294e2 /xs_regex.h
parenttimeline_del() also deletes from the pinned and bookmark caches. (diff)
downloadpenes-snac2-0218e964b0d73340c8d0c5d9e37991359d7c4be9.tar.gz
penes-snac2-0218e964b0d73340c8d0c5d9e37991359d7c4be9.tar.xz
penes-snac2-0218e964b0d73340c8d0c5d9e37991359d7c4be9.zip
Backport from xs.
Diffstat (limited to '')
-rw-r--r--xs_regex.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/xs_regex.h b/xs_regex.h
index d8d2d1d..3ba504b 100644
--- a/xs_regex.h
+++ b/xs_regex.h
@@ -71,13 +71,12 @@ xs_list *xs_regex_select_n(const char *str, const char *rx, int count)
71 xs *split = NULL; 71 xs *split = NULL;
72 const xs_val *v; 72 const xs_val *v;
73 int n = 0; 73 int n = 0;
74 int c = 0;
75 74
76 /* split */ 75 /* split */
77 split = xs_regex_split_n(str, rx, count); 76 split = xs_regex_split_n(str, rx, count);
78 77
79 /* now iterate to get only the 'separators' (odd ones) */ 78 /* now iterate to get only the 'separators' (odd ones) */
80 while (xs_list_next(split, &v, &c)) { 79 xs_list_foreach(split, v) {
81 if (n & 0x1) 80 if (n & 0x1)
82 list = xs_list_append(list, v); 81 list = xs_list_append(list, v);
83 82
@@ -96,10 +95,9 @@ xs_list *xs_regex_replace_in(xs_str *str, const char *rx, const char *rep, int c
96 xs *split = xs_regex_split_n(str, rx, count); 95 xs *split = xs_regex_split_n(str, rx, count);
97 const xs_val *v; 96 const xs_val *v;
98 int n = 0; 97 int n = 0;
99 int c = 0;
100 int pholder = !!strchr(rep, '&'); 98 int pholder = !!strchr(rep, '&');
101 99
102 while (xs_list_next(split, &v, &c)) { 100 xs_list_foreach(split, v) {
103 if (n & 0x1) { 101 if (n & 0x1) {
104 if (pholder) { 102 if (pholder) {
105 /* rep has a placeholder; process char by char */ 103 /* rep has a placeholder; process char by char */