Go to the documentation of this file.
38 #define PCRE2_CODE_UNIT_WIDTH 8
46 static bool pcre2_has_unicode(
void)
48 static uint32_t checked = -1;
51 pcre2_config(PCRE2_CONFIG_UNICODE, &checked);
74 pcre2_match_data *mdata;
81 #define PREX_MONTH "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"
82 #define PREX_DOW "(Mon|Tue|Wed|Thu|Fri|Sat|Sun)"
83 #define PREX_DOW_NOCASE \
84 "([Mm][Oo][Nn]|[Tt][Uu][Ee]|[Ww][Ee][Dd]|[Tt][Hh][Uu]|[Ff][Rr][Ii]|" \
85 "[Ss][Aa][Tt]|[Ss][Uu][Nn])"
86 #define PREX_TIME "([[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2})"
87 #define PREX_YEAR "([[:digit:]]{4})"
106 #define UNR_PCTENC_SUBDEL "][\\p{L}\\p{N}._~%!$&'()*+,;="
108 #define UNR_PCTENC_SUBDEL "][[:alnum:]._~%!$&'()*+,;="
111 "^([[:alpha:]][-+.[:alnum:]]+):"
123 "(\\[[[:xdigit:]:.]+\\])"
137 #undef UNR_PCTENC_SUBDEL
142 #define QUERY_PART "^&=" // Should be: "-[:alnum:]._~%!$'()*+,;:@/"
150 "([^][()<>@,;:\\\"/?. =]+)"
160 "^\\#H ([[:alnum:]_\\.-]+) ([[:alnum:]]{4}( [[:alnum:]]{4}){7})[ \t]*$"
169 "([[:digit:]]{1,2}) "
171 " ([[:digit:]]{2,4}) "
174 "(:([[:digit:]]{2}))?"
177 "([+-][[:digit:]]{4})|"
186 #define C "(\\(.*\\))?"
187 #define CFWS FWS C FWS
190 "(([[:alpha:]]+)" CFWS ", *)?"
191 CFWS "([[:digit:]]{1,2}) "
193 CFWS "([[:digit:]]{2,4}) "
194 CFWS "([[:digit:]]{1,2})"
195 ":" CFWS "([[:digit:]]{1,2})"
197 "(:" CFWS "([[:digit:]]{1,2}))?"
200 "([+-][[:digit:]]{4})|"
210 "( ([[:digit:]])|([[:digit:]]{2}))"
214 " ([+-][[:digit:]]{4})"
225 " ( ([[:digit:]])|([[:digit:]]{2}))"
238 "( at [^[:space:]]+)?"
269 assert((
which == h->
which) &&
"Fix 'storage' array");
273 uint32_t opt = pcre2_has_unicode() ? PCRE2_UTF : 0;
276 h->
re = pcre2_compile((PCRE2_SPTR8) h->
str, PCRE2_ZERO_TERMINATED, opt,
280 assert(
"Fix your RE");
282 h->mdata = pcre2_match_data_create_from_pattern(h->
re, NULL);
284 pcre2_pattern_info(h->
re, PCRE2_INFO_CAPTURECOUNT, &ccount);
285 assert(ccount + 1 == h->
nmatches &&
"Number of matches do not match (...)");
289 if (regcomp(h->
re, h->
str, REG_EXTENDED) != 0)
291 assert(
"Fix your RE");
313 size_t len = strlen(
str);
314 int rc = pcre2_match(h->
re, (PCRE2_SPTR8)
str, len, 0, 0, h->mdata, NULL);
317 PCRE2_UCHAR errmsg[1024];
318 pcre2_get_error_message(rc, errmsg,
sizeof(errmsg));
322 PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(h->mdata);
326 h->
matches[i].rm_so = ovector[i * 2];
327 h->
matches[i].rm_eo = ovector[i * 2 + 1];
338 assert((h->
re->re_nsub == (h->
nmatches - 1)) &&
339 "Regular expression and matches enum are out of sync");
353 pcre2_match_data_free(h->mdata);
354 pcre2_code_free(h->
re);
@ PREX_MBOX_FROM_MATCH_MAX
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
@ PREX_MBOX_FROM_LAX
[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]
@ PREX_RFC5322_DATE_LAX_MATCH_MAX
#define UNR_PCTENC_SUBDEL
@ PREX_RFC5322_DATE_LAX
[Mon, (Comment) 16 Mar 2020 15:09:35 -0700]
@ PREX_URL_QUERY_KEY_VAL
https://example.com/?[q=foo]
@ PREX_RFC2047_ENCODED_WORD_MATCH_MAX
regex_t * re
Compiled regex.
Prex
Predefined list of regular expressions.
enum Prex which
Regex type, e.g. PREX_URL.
@ PREX_GNUTLS_CERT_HOST_HASH
[#H foo.com A76D 954B EB79 1F49 5B3A 0A0E 0681 65B1]
@ PREX_URL_QUERY_KEY_VAL_MATCH_MAX
static struct PrexStorage * prex(enum Prex which)
Compile on demand and get data for a predefined regex.
@ PREX_RFC5322_DATE
[Mon, 16 Mar 2020 15:09:35 -0700]
#define mutt_debug(LEVEL,...)
const char * str
Regex string.
regmatch_t * matches
Resulting matches.
@ PREX_RFC5322_DATE_MATCH_MAX
@ PREX_GNUTLS_CERT_HOST_HASH_MATCH_MAX
@ PREX_URL
[imaps://user:pass@example.com/INBOX?foo=bar]
void mutt_prex_free(void)
@ PREX_RFC2047_ENCODED_WORD
[=?utf-8?Q?=E8=81=AA=E6=98=8E=E7=9A=84?=]
@ PREX_MBOX_FROM
[From god@heaven.af.mil Sat Jan 3 01:05:34 1996]
A predefined / precompiled regex.
@ PREX_MBOX_FROM_LAX_MATCH_MAX
size_t nmatches
Number of regex matches.
@ PREX_IMAP_DATE
[16-MAR-2020 15:09:35 -0700]
@ PREX_IMAP_DATE_MATCH_MAX
@ LL_DEBUG2
Log at debug level 2.
regmatch_t * mutt_prex_capture(enum Prex which, const char *str)