From 6ede6497ad2a63e5ff2b57abba827d0da469f923 Mon Sep 17 00:00:00 2001 From: default Date: Thu, 17 Aug 2023 17:38:39 +0200 Subject: Convert 'Link' attachments that have a media extension to something more useful. --- xs_regex.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'xs_regex.h') diff --git a/xs_regex.h b/xs_regex.h index 6fb6cca..7e1c80f 100644 --- a/xs_regex.h +++ b/xs_regex.h @@ -8,8 +8,10 @@ xs_list *xs_regex_split_n(const char *str, const char *rx, int count); #define xs_regex_split(str, rx) xs_regex_split_n(str, rx, XS_ALL) xs_list *xs_regex_match_n(const char *str, const char *rx, int count); #define xs_regex_match(str, rx) xs_regex_match_n(str, rx, XS_ALL) -xs_list *xs_regex_replace_n(const char *str, const char *rx, const char *rep, int count); -#define xs_regex_replace(str, rx, rep) xs_regex_replace_n(str, rx, rep, XS_ALL) +xs_list *xs_regex_replace_in(xs_str *str, const char *rx, const char *rep, int count); +#define xs_regex_replace_i(str, rx, rep) xs_regex_replace_in(str, rx, rep, XS_ALL) +#define xs_regex_replace_n(str, rx, rep, count) xs_regex_replace_in(xs_dup(str), rx, rep, count) +#define xs_regex_replace(str, rx, rep) xs_regex_replace_in(xs_dup(str), rx, rep, XS_ALL) #ifdef XS_IMPLEMENTATION @@ -78,7 +80,7 @@ xs_list *xs_regex_match_n(const char *str, const char *rx, int count) } -xs_list *xs_regex_replace_n(const char *str, const char *rx, const char *rep, int count) +xs_list *xs_regex_replace_in(xs_str *str, const char *rx, const char *rep, int count) /* replaces all matches with the rep string. If it contains unescaped &, they are replaced with the match */ { @@ -121,6 +123,8 @@ xs_list *xs_regex_replace_n(const char *str, const char *rx, const char *rep, in n++; } + xs_free(str); + return s; } -- cgit v1.2.3