pcre2 regex nits
I've noticed these small issues while looking at the pcre2 code in gtksourceview:
int
impl_regex_get_max_lookbehind (const ImplRegex *regex)
{
size_t value = 0;
g_return_val_if_fail (regex != NULL, 0);
g_return_val_if_fail (regex->code != NULL, 0);
pcre2_pattern_info (regex->code, PCRE2_INFO_MAXLOOKBEHIND, &value);
This is using the wrong type; PCRE2_INFO_MAXLOOKBEHIND
expects a pointer to uint32_t
, not size_t
, see man:pcre2_pattern_info(3). Also, in impl_match_info_new
, you pass an pointer to int
instead of uint32_t
, for PCRE2_INFO_CAPTURECOUNT
.
-
You could replace the use of
find_single_byte_escape()
function with passing thePCRE2_NEVER_BACKSLASH_C
compile flag.
pcre2_get_error_message (rc, errstr, sizeof errstr - 1);
errstr[sizeof errstr - 1] = 0;
pcre2_get_error_message()
already 0-terminates, even if truncating due to insufficient buffer size, so you can just pass the entire buffer to it and don't need to 0-terminate by hand.