mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-31 22:25:29 -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 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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue