diff options
Diffstat (limited to 'twin/compton-tde')
-rw-r--r-- | twin/compton-tde/CMakeLists.txt | 16 | ||||
-rw-r--r-- | twin/compton-tde/c2.c | 51 | ||||
-rw-r--r-- | twin/compton-tde/c2.h | 21 | ||||
-rw-r--r-- | twin/compton-tde/common.h | 10 | ||||
-rw-r--r-- | twin/compton-tde/compton_config.h.cmake | 10 | ||||
-rw-r--r-- | twin/compton-tde/man/compton-tde.1.html | 4 | ||||
-rw-r--r-- | twin/compton-tde/man/compton.1 | 4 |
7 files changed, 51 insertions, 65 deletions
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><</tt>, <tt>></tt>, <tt><=</tt>, <tt>=></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>&&</tt> (and) and <tt>||</tt> (or). <tt>&&</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 |