summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2024-08-18 20:53:07 +0900
committerMichele Calgaro <[email protected]>2024-08-18 23:20:10 +0900
commit51fdc21a48e4e576f83a778a93d3f1e52732d88a (patch)
tree0f7dde76082772729b5d1a567e8e269dbb1a1058
parente2ed07078655c4ee47d532f0d72d4320cbfdce42 (diff)
downloadtdebase-51fdc21a48e4e576f83a778a93d3f1e52732d88a.tar.gz
tdebase-51fdc21a48e4e576f83a778a93d3f1e52732d88a.zip
twin compton: use libpcre2 instead of libpcre
Signed-off-by: Michele Calgaro <[email protected]> (cherry picked from commit 2bc7176522c8cb2b154894312e2687686d7885d8)
-rw-r--r--CMakeLists.txt6
-rw-r--r--ConfigureChecks.cmake12
-rw-r--r--twin/compton-tde/CMakeLists.txt16
-rw-r--r--twin/compton-tde/c2.c51
-rw-r--r--twin/compton-tde/c2.h21
-rw-r--r--twin/compton-tde/common.h10
-rw-r--r--twin/compton-tde/compton_config.h.cmake10
-rw-r--r--twin/compton-tde/man/compton-tde.1.html4
-rw-r--r--twin/compton-tde/man/compton.14
9 files changed, 60 insertions, 74 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a8321e9be..1c30ac10f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,7 +99,7 @@ option( WITH_XFIXES "Enable xfixes support" ${WITH_ALL_OPTIONS} )
option( WITH_XRANDR "Enable xrandr support" ${WITH_ALL_OPTIONS} )
option( WITH_XRENDER "Enable xrender support" ${WITH_ALL_OPTIONS} )
option( WITH_LIBCONFIG "Enable libconfig support" ${WITH_ALL_OPTIONS} )
-option( WITH_PCRE "Enable pcre regex support" ON )
+option( WITH_PCRE2 "Enable pcre2 regex support" ON )
option( WITH_XTEST "Enable xtest support" ${WITH_ALL_OPTIONS} )
option( WITH_OPENGL "Enable openGL support" ${WITH_ALL_OPTIONS} )
option( WITH_XSCREENSAVER "Enable xscreensaver support" ${WITH_ALL_OPTIONS} )
@@ -152,8 +152,8 @@ option( WITH_XKB_TRANSLATIONS "Use translations for xkb messages provided by xke
# WITH_PAM affects tdm kdesktop kcheckpass
# WITH_SHADOW affects tdm kcheckpass
# WITH_UPOWER affects ksmserver
-# WITH_LIBCONFIG affects twin/compot-tde
-# WITH_PCRE affects twin/compot-tde
+# WITH_LIBCONFIG affects twin/compton-tde
+# WITH_PCRE2 affects twin/compton-tde
# WITH_SUDO_TDESU_BACKEND affects tdesu
# WITH_SUDO_KONSOLE_SUPER_USER_COMMAND affects launching Konsole super user sessions
# WITH_XKB_TRANSLATIONS affects kxkb
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index e038287c3..771d5b1f7 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -275,12 +275,12 @@ if( WITH_LIBCONFIG )
endif( )
-# pcre (twin/compton-tde)
-if( WITH_PCRE )
- pkg_search_module( LIBPCRE libpcre )
- if( NOT LIBPCRE_FOUND )
- tde_message_fatal( "pcre support is requested, but not found on your system" )
- endif( NOT LIBPCRE_FOUND )
+# pcre2 (twin/compton-tde)
+if( WITH_PCRE2 )
+ pkg_check_modules( LIBPCRE2 libpcre2-8 libpcre2-posix )
+ if( NOT LIBPCRE2_FOUND )
+ tde_message_fatal( "pcre2 support was requested, but not found on your system" )
+ endif( )
endif( )
diff --git a/twin/compton-tde/CMakeLists.txt b/twin/compton-tde/CMakeLists.txt
index d432b533f..8e29dd12c 100644
--- a/twin/compton-tde/CMakeLists.txt
+++ b/twin/compton-tde/CMakeLists.txt
@@ -24,7 +24,7 @@ include_directories(
${XINERAMA_INCLUDE_DIRS}
${XRANDR_INCLUDE_DIRS}
${GL_INCLUDE_DIRS}
- ${LIBPCRE_INCLUDE_DIRS}
+ ${LIBPCRE2_INCLUDE_DIRS}
)
link_directories(
@@ -33,7 +33,7 @@ link_directories(
${XINERAMA_LIBRARY_DIRS}
${XRANDR_LIBRARY_DIRS}
${GL_LIBRARY_DIRS}
- ${LIBPCRE_LIBRARY_DIRS}
+ ${LIBPCRE2_LIBRARY_DIRS}
)
@@ -46,8 +46,8 @@ link_directories(
# WITH_OPENGL -> CONFIG_VSYNC_OPENGL
# WITH_OPENGL -> CONFIG_VSYNC_OPENGL_GLSL
# WITH_OPENGL -> CONFIG_VSYNC_OPENGL_FBO
-# WITH_PCRE -> CONFIG_REGEX_PCRE
-# WITH_PCRE -> CONFIG_REGEX_PCRE_JIT
+# WITH_PCRE2 -> CONFIG_REGEX_PCRE2
+# WITH_PCRE2 -> CONFIG_REGEX_PCRE2_JIT
# WITH_LIBCONFIG -> CONFIG_LIBCONFIG
#
# HAVE_LIBCONFIG_OLD_API -> CONFIG_LIBCONFIG_LEGACY (set up in compton_config.h)
@@ -90,10 +90,10 @@ if( WITH_XRANDR )
list( APPEND compton_LIBRARIES ${XRANDR_LIBRARIES} )
endif( )
-if( WITH_PCRE )
- set( CONFIG_REGEX_PCRE ${WITH_PCRE} )
- set( CONFIG_REGEX_PCRE_JIT ${WITH_PCRE} )
- list( APPEND compton_LIBRARIES ${LIBPCRE_LIBRARIES} )
+if( WITH_PCRE2 )
+ set( CONFIG_REGEX_PCRE2 ${WITH_PCRE2} )
+ set( CONFIG_REGEX_PCRE2_JIT ${WITH_PCRE2} )
+ list( APPEND compton_LIBRARIES ${LIBPCRE2_LIBRARIES} )
endif( )
configure_file( compton_config.h.cmake compton_config.h )
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
diff --git a/twin/compton-tde/c2.h b/twin/compton-tde/c2.h
index 9e04c09a8..c84836c25 100644
--- a/twin/compton-tde/c2.h
+++ b/twin/compton-tde/c2.h
@@ -13,18 +13,10 @@
#include <fnmatch.h>
#include <ctype.h>
-// libpcre
-#ifdef CONFIG_REGEX_PCRE
-#include <pcre.h>
-
-// For compatiblity with <libpcre-8.20
-#ifndef PCRE_STUDY_JIT_COMPILE
-#define PCRE_STUDY_JIT_COMPILE 0
-#define LPCRE_FREE_STUDY(extra) pcre_free(extra)
-#else
-#define LPCRE_FREE_STUDY(extra) pcre_free_study(extra)
-#endif
-
+// libpcre2
+#ifdef CONFIG_REGEX_PCRE2
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
#endif
#define C2_MAX_LEVELS 10
@@ -139,9 +131,8 @@ struct _c2_l {
} ptntype;
char *ptnstr;
long ptnint;
-#ifdef CONFIG_REGEX_PCRE
- pcre *regex_pcre;
- pcre_extra *regex_pcre_extra;
+#ifdef CONFIG_REGEX_PCRE2
+ pcre2_code *regex_pcre;
#endif
};
diff --git a/twin/compton-tde/common.h b/twin/compton-tde/common.h
index 9091fc582..d92396cdf 100644
--- a/twin/compton-tde/common.h
+++ b/twin/compton-tde/common.h
@@ -38,12 +38,10 @@
// #define MONITOR_REPAINT 1
// #define DEBUG_FADE 1
-// Whether to enable PCRE regular expression support in blacklists, enabled
-// by default
-// #define CONFIG_REGEX_PCRE 1
-// Whether to enable JIT support of libpcre. This may cause problems on PaX
-// kernels.
-// #define CONFIG_REGEX_PCRE_JIT 1
+// Whether to enable PCRE2 regular expression support in blacklists, enabled by default
+// #define CONFIG_REGEX_PCRE2 1
+// Whether to enable JIT support of libpcre2. This may cause problems on PaX kernels.
+// #define CONFIG_REGEX_PCRE2_JIT 1
// Whether to enable parsing of configuration files using libconfig.
// #define CONFIG_LIBCONFIG 1
// Whether we are using a legacy version of libconfig (1.3.x).
diff --git a/twin/compton-tde/compton_config.h.cmake b/twin/compton-tde/compton_config.h.cmake
index bf3f22543..b534b1b80 100644
--- a/twin/compton-tde/compton_config.h.cmake
+++ b/twin/compton-tde/compton_config.h.cmake
@@ -1,11 +1,9 @@
#include "config.h"
-// Whether to enable PCRE regular expression support in blacklists, enabled
-// by default
-#cmakedefine CONFIG_REGEX_PCRE 1
-// Whether to enable JIT support of libpcre. This may cause problems on PaX
-// kernels.
-#cmakedefine CONFIG_REGEX_PCRE_JIT 1
+// Whether to enable PCRE2 regular expression support in blacklists, enabled by default
+#cmakedefine CONFIG_REGEX_PCRE2 1
+// Whether to enable JIT support of libpcre2. This may cause problems on PaX kernels.
+#cmakedefine CONFIG_REGEX_PCRE2_JIT 1
// Whether to enable parsing of configuration files using libconfig.
#cmakedefine CONFIG_LIBCONFIG 1
diff --git a/twin/compton-tde/man/compton-tde.1.html b/twin/compton-tde/man/compton-tde.1.html
index 26d2a3b21..34243b08e 100644
--- a/twin/compton-tde/man/compton-tde.1.html
+++ b/twin/compton-tde/man/compton-tde.1.html
@@ -1422,7 +1422,7 @@ compton(1) Manual Page
<div class="paragraph"><p><em>FORMAT</em> (optional) specifies the format of the property, 8, 16, or 32. On absence we use format X reports. Do not specify it for predefined or string targets.</p></div>
<div class="paragraph"><p><em>TYPE</em> is a single character representing the type of the property to match for: <tt>c</tt> for <em>CARDINAL</em>, <tt>a</tt> for <em>ATOM</em>, <tt>w</tt> for <em>WINDOW</em>, <tt>d</tt> for <em>DRAWABLE</em>, <tt>s</tt> for <em>STRING</em> (and any other string types, such as <em>UTF8_STRING</em>). Do not specify it for predefined targets.</p></div>
<div class="paragraph"><p><em>OP QUALIFIER</em> (optional), applicable only for equals operator, could be <tt>?</tt> (ignore-case).</p></div>
-<div class="paragraph"><p><em>MATCH TYPE</em> (optional), applicable only for equals operator, could be nothing (exact match), <tt>*</tt> (match anywhere), <tt>^</tt> (match from start), <tt>%</tt> (wildcard), or <tt>~</tt> (PCRE regular expression).</p></div>
+<div class="paragraph"><p><em>MATCH TYPE</em> (optional), applicable only for equals operator, could be nothing (exact match), <tt>*</tt> (match anywhere), <tt>^</tt> (match from start), <tt>%</tt> (wildcard), or <tt>~</tt> (PCRE2 regular expression).</p></div>
<div class="paragraph"><p><em>OPERATOR</em> is one of <tt>=</tt> (equals), <tt>&lt;</tt>, <tt>&gt;</tt>, <tt>&lt;=</tt>, <tt>=&gt;</tt>, or nothing (exists). Exists operator checks whether a property exists on a window (but for predefined targets, exists means != 0 then).</p></div>
<div class="paragraph"><p><em>PATTERN</em> is either an integer or a string enclosed by single or double quotes. Python-3-style escape sequences and raw string are supported in the string format.</p></div>
<div class="paragraph"><p>Supported logical operators are <tt>&amp;&amp;</tt> (and) and <tt>||</tt> (or). <tt>&amp;&amp;</tt> has higher precedence than <tt>||</tt>, left-to-right associativity. Use parentheses to change precedence.</p></div>
@@ -1468,7 +1468,7 @@ name = r"\x64\x64\o64"</tt></pre>
<pre><tt>condition = TARGET:TYPE[FLAGS]:PATTERN</tt></pre>
</div></div>
<div class="paragraph"><p><em>TARGET</em> is one of "n" (window name), "i" (window class instance), "g" (window general class), and "r" (window role).</p></div>
-<div class="paragraph"><p><em>TYPE</em> is one of "e" (exact match), "a" (match anywhere), "s" (match from start), "w" (wildcard), and "p" (PCRE regular expressions, if compiled with the support).</p></div>
+<div class="paragraph"><p><em>TYPE</em> is one of "e" (exact match), "a" (match anywhere), "s" (match from start), "w" (wildcard), and "p" (PCRE2 regular expressions, if compiled with the support).</p></div>
<div class="paragraph"><p><em>FLAGS</em> could be a series of flags. Currently the only defined flag is "i" (ignore case).</p></div>
<div class="paragraph"><p><em>PATTERN</em> is the actual pattern string.</p></div>
</div>
diff --git a/twin/compton-tde/man/compton.1 b/twin/compton-tde/man/compton.1
index 964c4158d..a4e4dd7d9 100644
--- a/twin/compton-tde/man/compton.1
+++ b/twin/compton-tde/man/compton.1
@@ -659,7 +659,7 @@ With greater\-than/less\-than operators it looks like:
.sp
\fIOP QUALIFIER\fR (optional), applicable only for equals operator, could be ? (ignore\-case)\&.
.sp
-\fIMATCH TYPE\fR (optional), applicable only for equals operator, could be nothing (exact match), * (match anywhere), ^ (match from start), % (wildcard), or ~ (PCRE regular expression)\&.
+\fIMATCH TYPE\fR (optional), applicable only for equals operator, could be nothing (exact match), * (match anywhere), ^ (match from start), % (wildcard), or ~ (PCRE2 regular expression)\&.
.sp
\fIOPERATOR\fR is one of = (equals), <, >, <=, =>, or nothing (exists)\&. Exists operator checks whether a property exists on a window (but for predefined targets, exists means != 0 then)\&.
.sp
@@ -720,7 +720,7 @@ condition = TARGET:TYPE[FLAGS]:PATTERN
.sp
\fITARGET\fR is one of "n" (window name), "i" (window class instance), "g" (window general class), and "r" (window role)\&.
.sp
-\fITYPE\fR is one of "e" (exact match), "a" (match anywhere), "s" (match from start), "w" (wildcard), and "p" (PCRE regular expressions, if compiled with the support)\&.
+\fITYPE\fR is one of "e" (exact match), "a" (match anywhere), "s" (match from start), "w" (wildcard), and "p" (PCRE2 regular expressions, if compiled with the support)\&.
.sp
\fIFLAGS\fR could be a series of flags\&. Currently the only defined flag is "i" (ignore case)\&.
.sp