|
|
@ -55,6 +55,13 @@ config(cfg_t *cfg, const char *key, const char *value) { |
|
|
|
} |
|
|
|
} |
|
|
|
if (strcmp(key, "usejit") == 0) { |
|
|
|
if (strcmp(key, "usejit") == 0) { |
|
|
|
cfg->usejit = (strcmp(value, "yes") == 0) ? true : false; |
|
|
|
cfg->usejit = (strcmp(value, "yes") == 0) ? true : false; |
|
|
|
|
|
|
|
#ifndef PCRE_CONFIG_JIT |
|
|
|
|
|
|
|
if (cfg->usejit) { |
|
|
|
|
|
|
|
cfg->usejit = false; |
|
|
|
|
|
|
|
strlcpy(cfg->error, "seems like your pcre library doesn't support jit") |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -99,8 +106,10 @@ append(cfg_t *cfg, const char *pattern) { |
|
|
|
|
|
|
|
|
|
|
|
if (cfg->study) { |
|
|
|
if (cfg->study) { |
|
|
|
flags = 0; |
|
|
|
flags = 0; |
|
|
|
|
|
|
|
#ifdef PCRE_CONFIG_JIT |
|
|
|
if (cfg->usejit) |
|
|
|
if (cfg->usejit) |
|
|
|
flags |= PCRE_STUDY_JIT_COMPILE; |
|
|
|
flags |= PCRE_STUDY_JIT_COMPILE; |
|
|
|
|
|
|
|
#endif |
|
|
|
if ((regex->data = pcre_study(regex->regex, 0, &errptr)) == NULL) { |
|
|
|
if ((regex->data = pcre_study(regex->regex, 0, &errptr)) == NULL) { |
|
|
|
snprintf(cfg->error, sizeof(cfg->error), "regex learn failed: %s", errptr); |
|
|
|
snprintf(cfg->error, sizeof(cfg->error), "regex learn failed: %s", errptr); |
|
|
|
pcre_free(regex->regex); |
|
|
|
pcre_free(regex->regex); |
|
|
@ -189,8 +198,13 @@ flush(cfg_t *cfg) { |
|
|
|
|
|
|
|
|
|
|
|
for (r = cfg->regexps; r != NULL; r = next) { |
|
|
|
for (r = cfg->regexps; r != NULL; r = next) { |
|
|
|
next = r->next; |
|
|
|
next = r->next; |
|
|
|
|
|
|
|
#ifdef PCRE_CONFIG_JIT |
|
|
|
if (cfg->study) |
|
|
|
if (cfg->study) |
|
|
|
pcre_free_study(r->data); |
|
|
|
pcre_free_study(r->data); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
if (cfg->study) |
|
|
|
|
|
|
|
pcre_free(r->data); |
|
|
|
|
|
|
|
#endif |
|
|
|
pcre_free(r->regex); |
|
|
|
pcre_free(r->regex); |
|
|
|
free(r); |
|
|
|
free(r); |
|
|
|
} |
|
|
|
} |
|
|
|