diff options
Diffstat (limited to 'src/sp_pcre_compat.h')
| -rw-r--r-- | src/sp_pcre_compat.h | 34 |
1 files changed, 34 insertions, 0 deletions
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 @@ | |||
| 1 | #ifndef SP_PCRE_COMPAT_H | ||
| 2 | #define SP_PCRE_COMPAT_H | ||
| 3 | |||
| 4 | #include <stdlib.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | |||
| 7 | #undef pcre_exec | ||
| 8 | #undef pcre_compile | ||
| 9 | |||
| 10 | /* We're not supporting pcre2 when it's not bundled with php7, | ||
| 11 | * yet. Pull-requests are welcome. */ | ||
| 12 | #if HAVE_BUNDLED_PCRE | ||
| 13 | #if PHP_VERSION_ID >= 70300 | ||
| 14 | #define SP_HAS_PCRE2 | ||
| 15 | #include "ext/pcre/pcre2lib/pcre2.h" | ||
| 16 | #else | ||
| 17 | #include "ext/pcre/pcrelib/pcre.h" | ||
| 18 | #endif | ||
| 19 | #else | ||
| 20 | #include "pcre.h" | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #ifdef SP_HAS_PCRE2 | ||
| 24 | #define sp_pcre pcre2_code | ||
| 25 | #else | ||
| 26 | #define sp_pcre pcre | ||
| 27 | #endif | ||
| 28 | |||
| 29 | sp_pcre* sp_pcre_compile(const char* str); | ||
| 30 | #define sp_is_regexp_matching(regexp, str) \ | ||
| 31 | sp_is_regexp_matching_len(regexp, str, strlen(str)) | ||
| 32 | bool sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, size_t len); | ||
| 33 | |||
| 34 | #endif // SP_PCRE_COMPAT_H | ||
