Regex progress

FossilOrigin-Name: d8b4321246842adfc9286b0bb98042efb69ba960e19e849f586cfb7962115dd6
This commit is contained in:
me@ow.nekobit.net 2022-04-19 19:34:39 +00:00
parent e16397dd03
commit 0c1f381cbb

View file

@ -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,