]> git.sur5r.net Git - i3/i3/commitdiff
Check for PCRE version and disable PCRE_UCP for <= 8.10
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 30 Sep 2011 19:31:32 +0000 (20:31 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 30 Sep 2011 19:31:32 +0000 (20:31 +0100)
common.mk
src/regex.c

index 78033946eeaf542fafb45bbdcedb0492c1e35931..b8ceea3bfc65475a72f9152db1c5c09e72999576 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -53,6 +53,10 @@ CPPFLAGS += -DI3_VERSION=\"${GIT_VERSION}\"
 CPPFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\"
 CPPFLAGS += -DTERM_EMU=\"$(TERM_EMU)\"
 
+ifeq ($(shell pkg-config --atleast-version=8.10 libpcre && echo 1),1)
+CPPFLAGS += -DPCRE_HAS_UCP=1
+endif
+
 LIBS += -lm
 LIBS += $(call ldflags_for_lib, xcb-event, xcb-event)
 LIBS += $(call ldflags_for_lib, xcb-keysyms, xcb-keysyms)
index f419e4bbf4e7d1a3cf739b17d12efeb74b1d6c85..64a2f3a4ffd4fd7a5cd73ad3a0037f37c714a2bc 100644 (file)
@@ -25,9 +25,12 @@ struct regex *regex_new(const char *pattern) {
 
     struct regex *re = scalloc(sizeof(struct regex));
     re->pattern = sstrdup(pattern);
+    int options = PCRE_UTF8;
+#ifdef PCRE_HAS_UCP
     /* We use PCRE_UCP so that \B, \b, \D, \d, \S, \s, \W, \w and some POSIX
      * character classes play nicely with Unicode */
-    int options = PCRE_UCP | PCRE_UTF8;
+    options |= PCRE_UCP;
+#endif
     while (!(re->regex = pcre_compile2(pattern, options, &errorcode, &error, &offset, NULL))) {
         /* If the error is that PCRE was not compiled with UTF-8 support we
          * disable it and try again */