diff options
| author | 2024-08-30 19:10:26 +0200 | |
|---|---|---|
| committer | 2024-08-30 19:10:26 +0200 | |
| commit | 0218e964b0d73340c8d0c5d9e37991359d7c4be9 (patch) | |
| tree | 9cfc1650abf8780be52dc219e37a311244a294e2 /xs_regex.h | |
| parent | timeline_del() also deletes from the pinned and bookmark caches. (diff) | |
| download | penes-snac2-0218e964b0d73340c8d0c5d9e37991359d7c4be9.tar.gz penes-snac2-0218e964b0d73340c8d0c5d9e37991359d7c4be9.tar.xz penes-snac2-0218e964b0d73340c8d0c5d9e37991359d7c4be9.zip | |
Backport from xs.
Diffstat (limited to '')
| -rw-r--r-- | xs_regex.h | 6 |
1 files changed, 2 insertions, 4 deletions
| @@ -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 */ |