From 4cbca117a3f2ef2d6695504970378ec4c483d19f Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 5 Feb 2018 17:27:45 +0100 Subject: Compatibility layer for pcre2 This should close #129--- src/sp_pcre_compat.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/sp_pcre_compat.h (limited to 'src/sp_pcre_compat.h') diff --git a/src/sp_pcre_compat.h b/src/sp_pcre_compat.h new file mode 100644 index 0000000..a9eb253 --- /dev/null +++ b/src/sp_pcre_compat.h @@ -0,0 +1,34 @@ +#ifndef SP_PCRE_COMPAT_H +#define SP_PCRE_COMPAT_H + +#include +#include + +#undef pcre_exec +#undef pcre_compile + +/* We're not supporting pcre2 when it's not bundled with php7, + * yet. Pull-requests are welcome. */ +#if HAVE_BUNDLED_PCRE + #if PHP_VERSION_ID >= 70300 + #define SP_HAS_PCRE2 + #include "ext/pcre/pcre2lib/pcre2.h" + #else + #include "ext/pcre/pcrelib/pcre.h" + #endif +#else + #include "pcre.h" +#endif + +#ifdef SP_HAS_PCRE2 + #define sp_pcre pcre2_code +#else + #define sp_pcre pcre +#endif + +sp_pcre* sp_pcre_compile(const char* str); +#define sp_is_regexp_matching(regexp, str) \ + sp_is_regexp_matching_len(regexp, str, strlen(str)) +bool sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, size_t len); + +#endif // SP_PCRE_COMPAT_H -- cgit v1.3