mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
opt: don't need to match null str or null pattern in regex_match
This commit is contained in:
parent
de43dbc40a
commit
cebdb6af85
1 changed files with 5 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue