Created
September 6, 2023 20:33
-
-
Save dsvensson/8aa1202b8439718a53b04dcd82c24fec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qbool ReSearchInitEx(const char *wildcard, qbool case_sensitive) | |
{ | |
int error; | |
pcre2_code *re; | |
PCRE2_SIZE error_offset; | |
if (wildcard_level == 4) { | |
Com_Printf("Error: Regexp commands nested too deep\n"); | |
return false; | |
} | |
re = pcre2_compile((PCRE2_SPTR)wildcard, PCRE2_ZERO_TERMINATED, (case_sensitive ? 0 : PCRE2_CASELESS), &error, &error_offset, NULL); | |
if (re == NULL) { | |
PCRE2_UCHAR message[256]; | |
if (pcre2_get_error_message(error, message, sizeof(message)) > 0) | |
{ | |
Com_Printf ("Invalid regexp: %s\n", message); | |
} else | |
{ | |
Com_Printf ("Unknown regexp error: %d\n", error); | |
} | |
return false; | |
} | |
wildcard_re[wildcard_level] = re; | |
wildcard_level++; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment