opt: don't need to match null str or null pattern in regex_match
This commit is contained in:
@@ -52,6 +52,11 @@ int fd_set_nonblock(int fd) {
|
|||||||
int regex_match(const char *pattern, const char *str) {
|
int regex_match(const char *pattern, const char *str) {
|
||||||
int errnum;
|
int errnum;
|
||||||
PCRE2_SIZE erroffset;
|
PCRE2_SIZE erroffset;
|
||||||
|
|
||||||
|
if (!pattern || !str) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
pcre2_code *re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED,
|
pcre2_code *re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED,
|
||||||
PCRE2_UTF, // 启用 UTF-8 支持
|
PCRE2_UTF, // 启用 UTF-8 支持
|
||||||
&errnum, &erroffset, NULL);
|
&errnum, &erroffset, NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user