opt: don't need to match null str or null pattern in regex_match

This commit is contained in:
DreamMaoMao 2025-06-20 11:43:03 +08:00
parent de43dbc40a
commit cebdb6af85

View file

@ -52,6 +52,11 @@ int fd_set_nonblock(int fd) {
int regex_match(const char *pattern, const char *str) {
int errnum;
PCRE2_SIZE erroffset;
if (!pattern || !str) {
return 0;
}
pcre2_code *re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED,
PCRE2_UTF, // 启用 UTF-8 支持
&errnum, &erroffset, NULL);