Check for PCRE version and disable PCRE_UCP for <= 8.10
This commit is contained in:
parent
c0d198bbc9
commit
3629934b0a
|
@ -53,6 +53,10 @@ CPPFLAGS += -DI3_VERSION=\"${GIT_VERSION}\"
|
||||||
CPPFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\"
|
CPPFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\"
|
||||||
CPPFLAGS += -DTERM_EMU=\"$(TERM_EMU)\"
|
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 += -lm
|
||||||
LIBS += $(call ldflags_for_lib, xcb-event, xcb-event)
|
LIBS += $(call ldflags_for_lib, xcb-event, xcb-event)
|
||||||
LIBS += $(call ldflags_for_lib, xcb-keysyms, xcb-keysyms)
|
LIBS += $(call ldflags_for_lib, xcb-keysyms, xcb-keysyms)
|
||||||
|
|
|
@ -25,9 +25,12 @@ struct regex *regex_new(const char *pattern) {
|
||||||
|
|
||||||
struct regex *re = scalloc(sizeof(struct regex));
|
struct regex *re = scalloc(sizeof(struct regex));
|
||||||
re->pattern = sstrdup(pattern);
|
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
|
/* We use PCRE_UCP so that \B, \b, \D, \d, \S, \s, \W, \w and some POSIX
|
||||||
* character classes play nicely with Unicode */
|
* 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))) {
|
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
|
/* If the error is that PCRE was not compiled with UTF-8 support we
|
||||||
* disable it and try again */
|
* disable it and try again */
|
||||||
|
|
Loading…
Reference in New Issue