diff options
| author | 2025-02-17 20:54:36 +0100 | |
|---|---|---|
| committer | 2025-02-17 20:54:36 +0100 | |
| commit | 7eb2556f26baf8ff79fcb7388712d8b714efc4f6 (patch) | |
| tree | 0d11017b6431c514bd6afd16138a06851cd2f09e /xs_regex.h | |
| parent | Merge tag '2.72' into curl-smtp (diff) | |
| parent | Merge pull request 'doc/snac8: elaborate regex blocking' (#305) from Menelmac... (diff) | |
| download | snac2-7eb2556f26baf8ff79fcb7388712d8b714efc4f6.tar.gz snac2-7eb2556f26baf8ff79fcb7388712d8b714efc4f6.tar.xz snac2-7eb2556f26baf8ff79fcb7388712d8b714efc4f6.zip | |
Merge remote-tracking branch 'upstream/master' into curl-smtp
Diffstat (limited to 'xs_regex.h')
| -rw-r--r-- | xs_regex.h | 6 |
1 files changed, 4 insertions, 2 deletions
| @@ -43,11 +43,13 @@ xs_list *xs_regex_split_n(const char *str, const char *rx, int count) | |||
| 43 | while (count > 0 && !regexec(&re, (p = str + offset), 1, &rm, offset > 0 ? REG_NOTBOL : 0)) { | 43 | while (count > 0 && !regexec(&re, (p = str + offset), 1, &rm, offset > 0 ? REG_NOTBOL : 0)) { |
| 44 | /* add first the leading part of the string */ | 44 | /* add first the leading part of the string */ |
| 45 | xs *s1 = xs_str_new_sz(p, rm.rm_so); | 45 | xs *s1 = xs_str_new_sz(p, rm.rm_so); |
| 46 | list = xs_list_append(list, s1); | 46 | |
| 47 | list = xs_list_append(list, xs_is_string(s1) ? s1 : ""); | ||
| 47 | 48 | ||
| 48 | /* add now the matched text as the separator */ | 49 | /* add now the matched text as the separator */ |
| 49 | xs *s2 = xs_str_new_sz(p + rm.rm_so, rm.rm_eo - rm.rm_so); | 50 | xs *s2 = xs_str_new_sz(p + rm.rm_so, rm.rm_eo - rm.rm_so); |
| 50 | list = xs_list_append(list, s2); | 51 | |
| 52 | list = xs_list_append(list, xs_is_string(s2) ? s2 : ""); | ||
| 51 | 53 | ||
| 52 | /* move forward */ | 54 | /* move forward */ |
| 53 | offset += rm.rm_eo; | 55 | offset += rm.rm_eo; |