summaryrefslogtreecommitdiffstats
path: root/twin/compton-tde/c2.c
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2024-08-18 20:53:07 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2024-08-18 23:20:10 +0900
commit51fdc21a48e4e576f83a778a93d3f1e52732d88a (patch)
tree0f7dde76082772729b5d1a567e8e269dbb1a1058 /twin/compton-tde/c2.c
parente2ed07078655c4ee47d532f0d72d4320cbfdce42 (diff)
downloadtdebase-51fdc21a48e4e576f83a778a93d3f1e52732d88a.tar.gz
tdebase-51fdc21a48e4e576f83a778a93d3f1e52732d88a.zip
twin compton: use libpcre2 instead of libpcre
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 2bc7176522c8cb2b154894312e2687686d7885d8)
Diffstat (limited to 'twin/compton-tde/c2.c')
-rw-r--r--twin/compton-tde/c2.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/twin/compton-tde/c2.c b/twin/compton-tde/c2.c
index 6baf1337e..147cb781d 100644
--- a/twin/compton-tde/c2.c
+++ b/twin/compton-tde/c2.c
@@ -785,33 +785,34 @@ c2_l_postprocess(session_t *ps, c2_l_t *pleaf) {
// PCRE patterns
if (C2_L_PTSTRING == pleaf->ptntype && C2_L_MPCRE == pleaf->match) {
-#ifdef CONFIG_REGEX_PCRE
- const char *error = NULL;
- int erroffset = 0;
- int options = 0;
+#ifdef CONFIG_REGEX_PCRE2
+ int errorCode;
+ PCRE2_SIZE errorOffset;
+ uint32_t options = 0;
// Ignore case flag
if (pleaf->match_ignorecase)
- options |= PCRE_CASELESS;
+ options |= PCRE2_CASELESS;
- // Compile PCRE expression
- pleaf->regex_pcre = pcre_compile(pleaf->ptnstr, options,
- &error, &erroffset, NULL);
+ // Compile PCRE2 expression
+ pleaf->regex_pcre = pcre2_compile((PCRE2_SPTR)pleaf->ptnstr, PCRE2_ZERO_TERMINATED,
+ options, &errorCode, &errorOffset, NULL);
if (!pleaf->regex_pcre)
- c2_error("Pattern \"%s\": PCRE regular expression parsing failed on "
- "offset %d: %s", pleaf->ptnstr, erroffset, error);
-#ifdef CONFIG_REGEX_PCRE_JIT
- pleaf->regex_pcre_extra = pcre_study(pleaf->regex_pcre,
- PCRE_STUDY_JIT_COMPILE, &error);
- if (!pleaf->regex_pcre_extra) {
- printf("Pattern \"%s\": PCRE regular expression study failed: %s",
- pleaf->ptnstr, error);
+ {
+ PCRE2_UCHAR errorMsg[256];
+ pcre2_get_error_message(errorCode, errorMsg, sizeof(errorMsg));
+ c2_error("Pattern \"%s\": PCRE2 regular expression parsing failed on "
+ "offset %zu: %s", pleaf->ptnstr, errorOffset, errorMsg);
+ }
+#ifdef CONFIG_REGEX_PCRE2_JIT
+ int jit_res = pcre2_jit_compile(pleaf->regex_pcre, PCRE2_JIT_COMPLETE);
+ if (jit_res < 0)
+ {
+ printf("Pattern \"%s\": PCRE2 regular expression JIT compilation failed with error code %d",
+ pleaf->ptnstr, jit_res);
}
#endif
- // Free the target string
- // free(pleaf->tgt);
- // pleaf->tgt = NULL;
#else
c2_error("PCRE regular expression support not compiled in.");
#endif
@@ -844,9 +845,8 @@ c2_free(c2_ptr_t p) {
free(pleaf->tgt);
free(pleaf->ptnstr);
-#ifdef CONFIG_REGEX_PCRE
- pcre_free(pleaf->regex_pcre);
- LPCRE_FREE_STUDY(pleaf->regex_pcre_extra);
+#ifdef CONFIG_REGEX_PCRE2
+ pcre2_code_free(pleaf->regex_pcre);
#endif
free(pleaf);
}
@@ -1180,10 +1180,9 @@ c2_match_once_leaf(session_t *ps, win *w, const c2_l_t *pleaf,
}
break;
case C2_L_MPCRE:
-#ifdef CONFIG_REGEX_PCRE
- *pres = (pcre_exec(pleaf->regex_pcre,
- pleaf->regex_pcre_extra,
- tgt, strlen(tgt), 0, 0, NULL, 0) >= 0);
+#ifdef CONFIG_REGEX_PCRE2
+ *pres = (pcre2_match(pleaf->regex_pcre, (PCRE2_SPTR)tgt, PCRE2_ZERO_TERMINATED,
+ 0, 0, NULL, NULL) >= 0);
#else
assert(0);
#endif