From 0c1f381cbbed8af4885c57dc1574d735e7963b5a Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Tue, 19 Apr 2022 19:34:39 +0000 Subject: [PATCH] Regex progress FossilOrigin-Name: d8b4321246842adfc9286b0bb98042efb69ba960e19e849f586cfb7962115dd6 --- src/status.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/status.c b/src/status.c index f72e801..cace828 100644 --- a/src/status.c +++ b/src/status.c @@ -161,13 +161,33 @@ char* construct_in_reply_to(mastodont_t* api, struct mstdnt_status* status, size } #define REGEX_GREENTEXT "((?:^|\\s)>.*)$" +#define REGEX_GREENTEXT_LEN 3 char* reformat_status(char* content) { const char* error; int erroffset; + int rc; + char* res = content; pcre* re = pcre_compile(REGEX_GREENTEXT, 0, &error, &erroffset, NULL); - return ""; + if (re == NULL) + { + fprintf(stderror, "Couldn't parse regex at offset %d: %s\n", erroffset, error); + free(replies); + pcre_free(re); + return res; + } + + for (int ind = 0;;) + { + rc = pcre_exec(re, NULL, content, strlen(content), ind, 0, re_results, REGEX_GREENTEXT_LEN); + if (rc < 0) + break; + + // Store to last result + + } + return res; } char* construct_status(mastodont_t* api,