summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2020-09-18 11:04:13 +0200
committerPatrick Steinhardt <ps@pks.im>2020-09-18 12:41:53 +0200
commit21299ee61728f02cd0386d5568fd39e5f3725a1f (patch)
treee2e5ad808c3c38650b1d02ca013b7fbe73c90403
parent9e81711bace51b1d3e233675c85b289743f5fdd7 (diff)
downloadlibgit2-pks-pcre-8.44.tar.gz
deps: pcre: upgrade to v8.44pks-pcre-8.44
With CVE-2019-20838, a vulnerability was found in PCRE v8.42 and lower causing a buffer overread with crafted queries. This commit thus upgrades the vendored copy of libpcre from v8.42 to v8.44.
-rw-r--r--deps/pcre/CMakeLists.txt906
-rw-r--r--deps/pcre/LICENCE93
-rw-r--r--deps/pcre/config-cmake.h.in (renamed from deps/pcre/config.h.in)0
-rw-r--r--deps/pcre/configure.ac1126
-rw-r--r--deps/pcre/pcre.h.in (renamed from deps/pcre/pcre.h)46
-rw-r--r--deps/pcre/pcre_chartables.c.dist (renamed from deps/pcre/pcre_chartables.c)0
-rw-r--r--deps/pcre/pcre_compile.c53
-rw-r--r--deps/pcre/pcre_internal.h26
-rw-r--r--deps/pcre/pcre_jit_compile.c8
-rw-r--r--deps/pcre/pcre_printint.c834
-rw-r--r--deps/pcre/pcreposix.c254
-rw-r--r--deps/pcre/pcreposix.h111
-rw-r--r--src/CMakeLists.txt19
13 files changed, 2422 insertions, 1054 deletions
diff --git a/deps/pcre/CMakeLists.txt b/deps/pcre/CMakeLists.txt
index aff2d751b..858a34bd0 100644
--- a/deps/pcre/CMakeLists.txt
+++ b/deps/pcre/CMakeLists.txt
@@ -1,4 +1,93 @@
+# CMakeLists.txt
+#
+#
+# This file allows building PCRE with the CMake configuration and build
+# tool. Download CMake in source or binary form from http://www.cmake.org/
+#
+# Original listfile by Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
+# Refined and expanded by Daniel Richard G. <skunk@iSKUNK.ORG>
+# 2007-09-14 mod by Sheri so 7.4 supported configuration options can be entered
+# 2007-09-19 Adjusted by PH to retain previous default settings
+# 2007-12-26 (a) On UNIX, use names libpcre instead of just pcre
+# (b) Ensure pcretest and pcregrep link with the local library,
+# not a previously-installed one.
+# (c) Add PCRE_SUPPORT_LIBREADLINE, PCRE_SUPPORT_LIBZ, and
+# PCRE_SUPPORT_LIBBZ2.
+# 2008-01-20 Brought up to date to include several new features by Christian
+# Ehrlicher.
+# 2008-01-22 Sheri added options for backward compatibility of library names
+# when building with minGW:
+# if "ON", NON_STANDARD_LIB_PREFIX causes shared libraries to
+# be built without "lib" as prefix. (The libraries will be named
+# pcre.dll, pcreposix.dll and pcrecpp.dll).
+# if "ON", NON_STANDARD_LIB_SUFFIX causes shared libraries to
+# be built with suffix of "-0.dll". (The libraries will be named
+# libpcre-0.dll, libpcreposix-0.dll and libpcrecpp-0.dll - same names
+# built by default with Configure and Make.
+# 2008-01-23 PH removed the automatic build of pcredemo.
+# 2008-04-22 PH modified READLINE support so it finds NCURSES when needed.
+# 2008-07-03 PH updated for revised UCP property support (change of files)
+# 2009-03-23 PH applied Steven Van Ingelgem's patch to change the name
+# CMAKE_BINARY_DIR to PROJECT_BINARY_DIR so that it works when PCRE
+# is included within another project.
+# 2009-03-23 PH applied a modified version of Steven Van Ingelgem's patches to
+# add options to stop the building of pcregrep and the tests, and
+# to disable the final configuration report.
+# 2009-04-11 PH applied Christian Ehrlicher's patch to show compiler flags that
+# are set by specifying a release type.
+# 2010-01-02 PH added test for stdint.h
+# 2010-03-02 PH added test for inttypes.h
+# 2011-08-01 PH added PCREGREP_BUFSIZE
+# 2011-08-22 PH added PCRE_SUPPORT_JIT
+# 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov
+# 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT
+# 2011-10-04 Sheri added support for including coff data in windows shared libraries
+# compiled with MINGW if pcre.rc and/or pcreposix.rc are placed in
+# the source dir by the user prior to building
+# 2011-10-04 Sheri changed various add_test's to use exes' location built instead
+# of DEBUG location only (likely only matters in MSVC)
+# 2011-10-04 Sheri added scripts to provide needed variables to RunTest and
+# RunGrepTest (used for UNIX and Msys)
+# 2011-10-04 Sheri added scripts to provide needed variables and to execute
+# RunTest.bat in Win32 (for effortless testing with "make test")
+# 2011-10-04 Sheri Increased minimum required cmake version
+# 2012-01-06 PH removed pcre_info.c and added pcre_string_utils.c
+# 2012-01-10 Zoltan Herczeg added libpcre16 support
+# 2012-01-13 Stephen Kelly added out of source build support
+# 2012-01-17 PH applied Stephen Kelly's patch to parse the version data out
+# of the configure.ac file
+# 2012-02-26 PH added support for libedit
+# 2012-09-06 PH added support for PCRE_EBCDIC_NL25
+# 2012-09-08 ChPe added PCRE32 support
+# 2012-10-23 PH added support for VALGRIND and GCOV
+# 2012-12-08 PH added patch from Daniel Richard G to quash some MSVC warnings
+# 2013-07-01 PH realized that the "support" for GCOV was a total nonsense and
+# so it has been removed.
+# 2013-10-08 PH got rid of the "source" command, which is a bash-ism (use ".")
+# 2013-11-05 PH added support for PARENS_NEST_LIMIT
+# 2016-03-01 PH applied Chris Wilson's patch for MSVC static build
+# 2016-06-24 PH applied Chris Wilson's revised patch (adds a separate option)
+
+PROJECT(PCRE C CXX)
+
+# Increased minimum to 2.8.0 to support newer add_test features. Set policy
+# CMP0026 to avoid warnings for the use of LOCATION in GET_TARGET_PROPERTY.
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
+CMAKE_POLICY(SET CMP0026 OLD)
+
+SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake
+
+# external packages
+FIND_PACKAGE( BZip2 )
+FIND_PACKAGE( ZLIB )
+FIND_PACKAGE( Readline )
+FIND_PACKAGE( Editline )
+
+# Configuration checks
+
INCLUDE(CheckIncludeFile)
+INCLUDE(CheckIncludeFileCXX)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckTypeSize)
@@ -10,6 +99,9 @@ CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
+CHECK_INCLUDE_FILE_CXX(type_traits.h HAVE_TYPE_TRAITS_H)
+CHECK_INCLUDE_FILE_CXX(bits/type_traits.h HAVE_BITS_TYPE_TRAITS_H)
+
CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY)
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
@@ -20,20 +112,73 @@ CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
CHECK_TYPE_SIZE("long long" LONG_LONG)
CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
-DISABLE_WARNINGS(unused-function)
-DISABLE_WARNINGS(implicit-fallthrough)
-
# User-configurable options
+#
+# (Note: CMakeSetup displays these in alphabetical order, regardless of
+# the order we use here)
+
+SET(BUILD_SHARED_LIBS OFF CACHE BOOL
+ "Build shared libraries instead of static ones.")
+
+OPTION(PCRE_BUILD_PCRE8 "Build 8 bit PCRE library" ON)
+
+OPTION(PCRE_BUILD_PCRE16 "Build 16 bit PCRE library" OFF)
+
+OPTION(PCRE_BUILD_PCRE32 "Build 32 bit PCRE library" OFF)
+
+OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON)
+
+SET(PCRE_EBCDIC OFF CACHE BOOL
+ "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems.)")
+
+SET(PCRE_EBCDIC_NL25 OFF CACHE BOOL
+ "Use 0x25 as EBCDIC NL character instead of 0x15; implies EBCDIC.")
+
+SET(PCRE_LINK_SIZE "2" CACHE STRING
+ "Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.")
+
+SET(PCRE_PARENS_NEST_LIMIT "250" CACHE STRING
+ "Default nested parentheses limit. See PARENS_NEST_LIMIT in config.h.in for details.")
+
+SET(PCRE_MATCH_LIMIT "10000000" CACHE STRING
+ "Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.")
+
+SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING
+ "Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.")
-SET(SUPPORT_PCRE8 1)
-SET(PCRE_LINK_SIZE "2")
-SET(PCRE_PARENS_NEST_LIMIT "250")
-SET(PCRE_MATCH_LIMIT "10000000")
-SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT")
-SET(PCRE_NEWLINE "LF")
-SET(NO_RECURSE 1)
-SET(PCRE_POSIX_MALLOC_THRESHOLD "10")
-SET(BSR_ANYCRLF 0)
+SET(PCREGREP_BUFSIZE "20480" CACHE STRING
+ "Buffer size parameter for pcregrep. See PCREGREP_BUFSIZE in config.h.in for details.")
+
+SET(PCRE_NEWLINE "LF" CACHE STRING
+ "What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF).")
+
+SET(PCRE_NO_RECURSE OFF CACHE BOOL
+ "If ON, then don't use stack recursion when matching. See NO_RECURSE in config.h.in for details.")
+
+SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING
+ "Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.")
+
+SET(PCRE_SUPPORT_JIT OFF CACHE BOOL
+ "Enable support for Just-in-time compiling.")
+
+SET(PCRE_SUPPORT_PCREGREP_JIT ON CACHE BOOL
+ "Enable use of Just-in-time compiling in pcregrep.")
+
+SET(PCRE_SUPPORT_UTF OFF CACHE BOOL
+ "Enable support for Unicode Transformation Format (UTF-8/UTF-16/UTF-32) encoding.")
+
+SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL
+ "Enable support for Unicode properties (if set, UTF support will be enabled as well).")
+
+SET(PCRE_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL
+ "ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks")
+
+SET(PCRE_SUPPORT_VALGRIND OFF CACHE BOOL
+ "Enable Valgrind support.")
+
+OPTION(PCRE_SHOW_REPORT "Show the final configuration report" ON)
+OPTION(PCRE_BUILD_PCREGREP "Build pcregrep" ON)
+OPTION(PCRE_BUILD_TESTS "Build the tests" ON)
IF (MINGW)
OPTION(NON_STANDARD_LIB_PREFIX
@@ -45,8 +190,60 @@ IF (MINGW)
OFF)
ENDIF(MINGW)
+IF(MSVC)
+ OPTION(PCRE_STATIC_RUNTIME
+ "ON=Compile against the static runtime (/MT)."
+ OFF)
+ OPTION(INSTALL_MSVC_PDB
+ "ON=Install .pdb files built by MSVC, if generated"
+ OFF)
+ENDIF(MSVC)
+
+# bzip2 lib
+IF(BZIP2_FOUND)
+ OPTION (PCRE_SUPPORT_LIBBZ2 "Enable support for linking pcregrep with libbz2." ON)
+ENDIF(BZIP2_FOUND)
+IF(PCRE_SUPPORT_LIBBZ2)
+ INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
+ENDIF(PCRE_SUPPORT_LIBBZ2)
+
+# zlib
+IF(ZLIB_FOUND)
+ OPTION (PCRE_SUPPORT_LIBZ "Enable support for linking pcregrep with libz." ON)
+ENDIF(ZLIB_FOUND)
+IF(PCRE_SUPPORT_LIBZ)
+ INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
+ENDIF(PCRE_SUPPORT_LIBZ)
+
+# editline lib
+IF(EDITLINE_FOUND)
+ OPTION (PCRE_SUPPORT_LIBEDIT "Enable support for linking pcretest with libedit." OFF)
+ENDIF(EDITLINE_FOUND)
+IF(PCRE_SUPPORT_LIBEDIT)
+ INCLUDE_DIRECTORIES(${EDITLINE_INCLUDE_DIR})
+ENDIF(PCRE_SUPPORT_LIBEDIT)
+
+# readline lib
+IF(READLINE_FOUND)
+ OPTION (PCRE_SUPPORT_LIBREADLINE "Enable support for linking pcretest with libreadline." ON)
+ENDIF(READLINE_FOUND)
+IF(PCRE_SUPPORT_LIBREADLINE)
+ INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
+ENDIF(PCRE_SUPPORT_LIBREADLINE)
+
# Prepare build configuration
+SET(pcre_have_type_traits 0)
+SET(pcre_have_bits_type_traits 0)
+
+IF(HAVE_TYPE_TRAITS_H)
+ SET(pcre_have_type_traits 1)
+ENDIF(HAVE_TYPE_TRAITS_H)
+
+IF(HAVE_BITS_TYPE_TRAITS_H)
+ SET(pcre_have_bits_type_traits 1)
+ENDIF(HAVE_BITS_TYPE_TRAITS_H)
+
SET(pcre_have_long_long 0)
SET(pcre_have_ulong_long 0)
@@ -58,6 +255,93 @@ IF(HAVE_UNSIGNED_LONG_LONG)
SET(pcre_have_ulong_long 1)
ENDIF(HAVE_UNSIGNED_LONG_LONG)
+IF(NOT BUILD_SHARED_LIBS)
+ SET(PCRE_STATIC 1)
+ENDIF(NOT BUILD_SHARED_LIBS)
+
+IF(NOT PCRE_BUILD_PCRE8 AND NOT PCRE_BUILD_PCRE16 AND NOT PCRE_BUILD_PCRE32)
+ MESSAGE(FATAL_ERROR "At least one of PCRE_BUILD_PCRE8, PCRE_BUILD_PCRE16 or PCRE_BUILD_PCRE32 must be enabled")
+ENDIF(NOT PCRE_BUILD_PCRE8 AND NOT PCRE_BUILD_PCRE16 AND NOT PCRE_BUILD_PCRE32)
+
+IF(PCRE_BUILD_PCRE8)
+ SET(SUPPORT_PCRE8 1)
+ENDIF(PCRE_BUILD_PCRE8)
+
+IF(PCRE_BUILD_PCRE16)
+ SET(SUPPORT_PCRE16 1)
+ENDIF(PCRE_BUILD_PCRE16)
+
+IF(PCRE_BUILD_PCRE32)
+ SET(SUPPORT_PCRE32 1)
+ENDIF(PCRE_BUILD_PCRE32)
+
+IF(PCRE_BUILD_PCRECPP AND NOT PCRE_BUILD_PCRE8)
+ MESSAGE(STATUS "** PCRE_BUILD_PCRE8 must be enabled for the C++ library support")
+ SET(PCRE_BUILD_PCRECPP OFF)
+ENDIF(PCRE_BUILD_PCRECPP AND NOT PCRE_BUILD_PCRE8)
+
+IF(PCRE_BUILD_PCREGREP AND NOT PCRE_BUILD_PCRE8)
+ MESSAGE(STATUS "** PCRE_BUILD_PCRE8 must be enabled for the pcregrep program")
+ SET(PCRE_BUILD_PCREGREP OFF)
+ENDIF(PCRE_BUILD_PCREGREP AND NOT PCRE_BUILD_PCRE8)
+
+IF(PCRE_SUPPORT_LIBREADLINE AND PCRE_SUPPORT_LIBEDIT)
+ MESSAGE(FATAL_ERROR "Only one of libreadline or libeditline can be specified")
+ENDIF(PCRE_SUPPORT_LIBREADLINE AND PCRE_SUPPORT_LIBEDIT)
+
+IF(PCRE_SUPPORT_BSR_ANYCRLF)
+ SET(BSR_ANYCRLF 1)
+ENDIF(PCRE_SUPPORT_BSR_ANYCRLF)
+
+IF(PCRE_SUPPORT_UTF OR PCRE_SUPPORT_UNICODE_PROPERTIES)
+ SET(SUPPORT_UTF 1)
+ SET(PCRE_SUPPORT_UTF ON)
+ENDIF(PCRE_SUPPORT_UTF OR PCRE_SUPPORT_UNICODE_PROPERTIES)
+
+IF(PCRE_SUPPORT_UNICODE_PROPERTIES)
+ SET(SUPPORT_UCP 1)
+ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
+
+IF(PCRE_SUPPORT_JIT)
+ SET(SUPPORT_JIT 1)
+ENDIF(PCRE_SUPPORT_JIT)
+
+IF(PCRE_SUPPORT_PCREGREP_JIT)
+ SET(SUPPORT_PCREGREP_JIT 1)
+ENDIF(PCRE_SUPPORT_PCREGREP_JIT)
+
+IF(PCRE_SUPPORT_VALGRIND)
+ SET(SUPPORT_VALGRIND 1)
+ENDIF(PCRE_SUPPORT_VALGRIND)
+
+# This next one used to contain
+# SET(PCRETEST_LIBS ${READLINE_LIBRARY})
+# but I was advised to add the NCURSES test as well, along with
+# some modifications to cmake/FindReadline.cmake which should
+# make it possible to override the default if necessary. PH
+
+IF(PCRE_SUPPORT_LIBREADLINE)
+ SET(SUPPORT_LIBREADLINE 1)
+ SET(PCRETEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY})
+ENDIF(PCRE_SUPPORT_LIBREADLINE)
+
+# libedit is a plug-compatible alternative to libreadline
+
+IF(PCRE_SUPPORT_LIBEDIT)
+ SET(SUPPORT_LIBEDIT 1)
+ SET(PCRETEST_LIBS ${EDITLINE_LIBRARY} ${NCURSES_LIBRARY})
+ENDIF(PCRE_SUPPORT_LIBEDIT)
+
+IF(PCRE_SUPPORT_LIBZ)
+ SET(SUPPORT_LIBZ 1)
+ SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${ZLIB_LIBRARIES})
+ENDIF(PCRE_SUPPORT_LIBZ)
+
+IF(PCRE_SUPPORT_LIBBZ2)
+ SET(SUPPORT_LIBBZ2 1)
+ SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${BZIP2_LIBRARIES})
+ENDIF(PCRE_SUPPORT_LIBBZ2)
+
SET(NEWLINE "")
IF(PCRE_NEWLINE STREQUAL "LF")
@@ -80,15 +364,98 @@ IF(NEWLINE STREQUAL "")
MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
ENDIF(NEWLINE STREQUAL "")
+IF(PCRE_EBCDIC)
+ SET(EBCDIC 1)
+IF(PCRE_NEWLINE STREQUAL "LF")
+ SET(NEWLINE "21")
+ENDIF(PCRE_NEWLINE STREQUAL "LF")
+IF(PCRE_NEWLINE STREQUAL "CRLF")
+ SET(NEWLINE "3349")
+ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
+ENDIF(PCRE_EBCDIC)
+
+IF(PCRE_EBCDIC_NL25)
+ SET(EBCDIC 1)
+ SET(EBCDIC_NL25 1)
+IF(PCRE_NEWLINE STREQUAL "LF")
+ SET(NEWLINE "37")
+ENDIF(PCRE_NEWLINE STREQUAL "LF")
+IF(PCRE_NEWLINE STREQUAL "CRLF")
+ SET(NEWLINE "3365")
+ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
+ENDIF(PCRE_EBCDIC_NL25)
+
+IF(PCRE_NO_RECURSE)
+ SET(NO_RECURSE 1)
+ENDIF(PCRE_NO_RECURSE)
+
# Output files
-CONFIGURE_FILE(config.h.in
- ${PROJECT_BINARY_DIR}/src/pcre/config.h
+CONFIGURE_FILE(config-cmake.h.in
+ ${PROJECT_BINARY_DIR}/config.h
+ @ONLY)
+
+# Parse version numbers and date out of configure.ac
+
+file(STRINGS ${PROJECT_SOURCE_DIR}/configure.ac
+ configure_lines
+ LIMIT_COUNT 50 # Read only the first 50 lines of the file
+)
+
+set(SEARCHED_VARIABLES "pcre_major" "pcre_minor" "pcre_prerelease" "pcre_date")
+foreach(configure_line ${configure_lines})
+ foreach(_substitution_variable ${SEARCHED_VARIABLES})
+ string(TOUPPER ${_substitution_variable} _substitution_variable_upper)
+ if (NOT ${_substitution_variable_upper})
+ string(REGEX MATCH "m4_define\\(${_substitution_variable}, \\[(.*)\\]" MACTHED_STRING ${configure_line})
+ if (CMAKE_MATCH_1)
+ set(${_substitution_variable_upper} ${CMAKE_MATCH_1})
+ endif()
+ endif()
+ endforeach()
+endforeach()
+
+CONFIGURE_FILE(pcre.h.in
+ ${PROJECT_BINARY_DIR}/pcre.h
@ONLY)
+# What about pcre-config and libpcre.pc?
+
+IF(PCRE_BUILD_PCRECPP)
+ CONFIGURE_FILE(pcre_stringpiece.h.in
+ ${PROJECT_BINARY_DIR}/pcre_stringpiece.h
+ @ONLY)
+
+ CONFIGURE_FILE(pcrecpparg.h.in
+ ${PROJECT_BINARY_DIR}/pcrecpparg.h
+ @ONLY)
+ENDIF(PCRE_BUILD_PCRECPP)
+
+# Character table generation
+
+OPTION(PCRE_REBUILD_CHARTABLES "Rebuild char tables" OFF)
+IF(PCRE_REBUILD_CHARTABLES)
+ ADD_EXECUTABLE(dftables dftables.c)
+
+ GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION)
+
+ ADD_CUSTOM_COMMAND(
+ COMMENT "Generating character tables (pcre_chartables.c) for current locale"
+ DEPENDS dftables
+ COMMAND ${DFTABLES_EXE}
+ ARGS ${PROJECT_BINARY_DIR}/pcre_chartables.c
+ OUTPUT ${PROJECT_BINARY_DIR}/pcre_chartables.c
+ )
+ELSE(PCRE_REBUILD_CHARTABLES)
+ CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/pcre_chartables.c.dist
+ ${PROJECT_BINARY_DIR}/pcre_chartables.c
+ COPYONLY)
+ENDIF(PCRE_REBUILD_CHARTABLES)
+
# Source code
-SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/src/pcre/config.h)
+SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/pcre.h)
+IF(PCRE_BUILD_PCRE8)
SET(PCRE_SOURCES
pcre_byte_order.c
pcre_chartables.c
@@ -117,9 +484,123 @@ SET(PCREPOSIX_HEADERS pcreposix.h)
SET(PCREPOSIX_SOURCES pcreposix.c)
+ENDIF(PCRE_BUILD_PCRE8)
+
+IF(PCRE_BUILD_PCRE16)
+SET(PCRE16_SOURCES
+ pcre16_byte_order.c
+ pcre16_chartables.c
+ pcre16_compile.c
+ pcre16_config.c
+ pcre16_dfa_exec.c
+ pcre16_exec.c
+ pcre16_fullinfo.c
+ pcre16_get.c
+ pcre16_globals.c
+ pcre16_jit_compile.c
+ pcre16_maketables.c
+ pcre16_newline.c
+ pcre16_ord2utf16.c
+ pcre16_refcount.c
+ pcre16_string_utils.c
+ pcre16_study.c
+ pcre16_tables.c
+ pcre16_ucd.c
+ pcre16_utf16_utils.c
+ pcre16_valid_utf16.c
+ pcre16_version.c
+ pcre16_xclass.c
+)
+ENDIF(PCRE_BUILD_PCRE16)
+
+IF(PCRE_BUILD_PCRE32)
+SET(PCRE32_SOURCES
+ pcre32_byte_order.c
+ pcre32_chartables.c
+ pcre32_compile.c
+ pcre32_config.c
+ pcre32_dfa_exec.c
+ pcre32_exec.c
+ pcre32_fullinfo.c
+ pcre32_get.c
+ pcre32_globals.c
+ pcre32_jit_compile.c
+ pcre32_maketables.c
+ pcre32_newline.c
+ pcre32_ord2utf32.c
+ pcre32_refcount.c
+ pcre32_string_utils.c
+ pcre32_study.c
+ pcre32_tables.c
+ pcre32_ucd.c
+ pcre32_utf32_utils.c
+ pcre32_valid_utf32.c
+ pcre32_version.c
+ pcre32_xclass.c
+)
+ENDIF(PCRE_BUILD_PCRE32)
+
+IF(MINGW AND NOT PCRE_STATIC)
+IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
+ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre.o
+PRE-LINK
+COMMAND windres ARGS pcre.rc pcre.o
+WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+COMMENT Using pcre coff info in mingw build)
+SET(PCRE_SOURCES
+ ${PCRE_SOURCES} ${PROJECT_SOURCE_DIR}/pcre.o
+)
+ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
+IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
+ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcreposix.o
+PRE-LINK
+COMMAND windres ARGS pcreposix.rc pcreposix.o
+WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+COMMENT Using pcreposix coff info in mingw build)
+SET(PCREPOSIX_SOURCES
+ ${PCREPOSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcreposix.o
+)
+ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
+ENDIF(MINGW AND NOT PCRE_STATIC)
+
+IF(MSVC AND NOT PCRE_STATIC)
+IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
+SET(PCRE_SOURCES
+ ${PCRE_SOURCES} pcre.rc)
+ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
+IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
+SET(PCREPOSIX_SOURCES
+ ${PCREPOSIX_SOURCES} pcreposix.rc)
+ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
+ENDIF(MSVC AND NOT PCRE_STATIC)
+
# Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681
# This code was taken from the CMake wiki, not from WebM.
+IF(MSVC AND PCRE_STATIC_RUNTIME)
+ MESSAGE(STATUS "** MSVC and PCRE_STATIC_RUNTIME: modifying compiler flags to use static runtime library")
+ foreach(flag_var
+ CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+ endforeach()
+ENDIF(MSVC AND PCRE_STATIC_RUNTIME)
+
+SET(PCRECPP_HEADERS
+ pcrecpp.h
+ pcre_scanner.h
+ ${PROJECT_BINARY_DIR}/pcrecpparg.h
+ ${PROJECT_BINARY_DIR}/pcre_stringpiece.h
+)
+
+SET(PCRECPP_SOURCES
+ pcrecpp.cc
+ pcre_scanner.cc
+ pcre_stringpiece.cc
+)
+
# Build setup
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
@@ -129,12 +610,403 @@ IF(MSVC)
ENDIF(MSVC)
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
+# needed to make sure to not link debug libs
+# against release libs and vice versa
+IF(WIN32)
+ SET(CMAKE_DEBUG_POSTFIX "d")
+ENDIF(WIN32)
SET(targets)
# Libraries
# pcre
-INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/src/pcre)
-ADD_LIBRARY(pcre OBJECT ${PCRE_HEADERS} ${PCRE_SOURCES} ${PCREPOSIX_SOURCES})
+IF(PCRE_BUILD_PCRE8)
+ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
+SET(targets ${targets} pcre)
+ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES})
+SET(targets ${targets} pcreposix)
+TARGET_LINK_LIBRARIES(pcreposix pcre)
+
+IF(MINGW AND NOT PCRE_STATIC)
+ IF(NON_STANDARD_LIB_PREFIX)
+ SET_TARGET_PROPERTIES(pcre pcreposix
+ PROPERTIES PREFIX ""
+ )
+ ENDIF(NON_STANDARD_LIB_PREFIX)
+
+ IF(NON_STANDARD_LIB_SUFFIX)
+ SET_TARGET_PROPERTIES(pcre pcreposix
+ PROPERTIES SUFFIX "-0.dll"
+ )
+ ENDIF(NON_STANDARD_LIB_SUFFIX)
+ENDIF(MINGW AND NOT PCRE_STATIC)
+
+ENDIF(PCRE_BUILD_PCRE8)
+
+IF(PCRE_BUILD_PCRE16)
+ADD_LIBRARY(pcre16 ${PCRE_HEADERS} ${PCRE16_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
+SET(targets ${targets} pcre16)
+
+IF(MINGW AND NOT PCRE_STATIC)
+ IF(NON_STANDARD_LIB_PREFIX)
+ SET_TARGET_PROPERTIES(pcre16
+ PROPERTIES PREFIX ""
+ )
+ ENDIF(NON_STANDARD_LIB_PREFIX)
+
+ IF(NON_STANDARD_LIB_SUFFIX)
+ SET_TARGET_PROPERTIES(pcre16
+ PROPERTIES SUFFIX "-0.dll"
+ )
+ ENDIF(NON_STANDARD_LIB_SUFFIX)
+ENDIF(MINGW AND NOT PCRE_STATIC)
+
+ENDIF(PCRE_BUILD_PCRE16)
+
+IF(PCRE_BUILD_PCRE32)
+ADD_LIBRARY(pcre32 ${PCRE_HEADERS} ${PCRE32_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
+SET(targets ${targets} pcre32)
+
+IF(MINGW AND NOT PCRE_STATIC)
+ IF(NON_STANDARD_LIB_PREFIX)
+ SET_TARGET_PROPERTIES(pcre32
+ PROPERTIES PREFIX ""
+ )
+ ENDIF(NON_STANDARD_LIB_PREFIX)
+
+ IF(NON_STANDARD_LIB_SUFFIX)
+ SET_TARGET_PROPERTIES(pcre32
+ PROPERTIES SUFFIX "-0.dll"
+ )
+ ENDIF(NON_STANDARD_LIB_SUFFIX)
+ENDIF(MINGW AND NOT PCRE_STATIC)
+
+ENDIF(PCRE_BUILD_PCRE32)
+
+# pcrecpp
+IF(PCRE_BUILD_PCRECPP)
+ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES})
+SET(targets ${targets} pcrecpp)
+TARGET_LINK_LIBRARIES(pcrecpp pcre)
+
+ IF(MINGW AND NOT PCRE_STATIC)
+ IF(NON_STANDARD_LIB_PREFIX)
+ SET_TARGET_PROPERTIES(pcrecpp
+ PROPERTIES PREFIX ""
+ )
+ ENDIF(NON_STANDARD_LIB_PREFIX)
+
+ IF(NON_STANDARD_LIB_SUFFIX)
+ SET_TARGET_PROPERTIES(pcrecpp
+ PROPERTIES SUFFIX "-0.dll"
+ )
+ ENDIF(NON_STANDARD_LIB_SUFFIX)
+ ENDIF(MINGW AND NOT PCRE_STATIC)
+ENDIF(PCRE_BUILD_PCRECPP)
+
+
+# Executables
+
+# Removed by PH (2008-01-23) because pcredemo shouldn't really be built
+# automatically, and it gave trouble in some environments anyway.
+# ADD_EXECUTABLE(pcredemo pcredemo.c)
+# TARGET_LINK_LIBRARIES(pcredemo pcreposix)
+# IF(NOT BUILD_SHARED_LIBS)
+# # make sure to not use declspec(dllimport) in static mode on windows
+# SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC")
+# ENDIF(NOT BUILD_SHARED_LIBS)
+
+IF(PCRE_BUILD_PCREGREP)
+ ADD_EXECUTABLE(pcregrep pcregrep.c)
+ SET(targets ${targets} pcregrep)
+ TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS})
+ENDIF(PCRE_BUILD_PCREGREP)
+
+# Testing
+IF(PCRE_BUILD_TESTS)
+ ENABLE_TESTING()
+
+ SET(PCRETEST_SOURCES pcretest.c)
+ IF(PCRE_BUILD_PCRE8)
+ LIST(APPEND PCRETEST_SOURCES pcre_printint.c)
+ ENDIF(PCRE_BUILD_PCRE8)
+ IF(PCRE_BUILD_PCRE16)
+ LIST(APPEND PCRETEST_SOURCES pcre16_printint.c)
+ ENDIF(PCRE_BUILD_PCRE16)
+ IF(PCRE_BUILD_PCRE32)
+ LIST(APPEND PCRETEST_SOURCES pcre32_printint.c)
+ ENDIF(PCRE_BUILD_PCRE32)
+
+ ADD_EXECUTABLE(pcretest ${PCRETEST_SOURCES})
+ SET(targets ${targets} pcretest)
+ IF(PCRE_BUILD_PCRE8)
+ LIST(APPEND PCRETEST_LIBS pcreposix pcre)
+ ENDIF(PCRE_BUILD_PCRE8)
+ IF(PCRE_BUILD_PCRE16)
+ LIST(APPEND PCRETEST_LIBS pcre16)
+ ENDIF(PCRE_BUILD_PCRE16)
+ IF(PCRE_BUILD_PCRE32)
+ LIST(APPEND PCRETEST_LIBS pcre32)
+ ENDIF(PCRE_BUILD_PCRE32)
+ TARGET_LINK_LIBRARIES(pcretest ${PCRETEST_LIBS})
+
+ IF(PCRE_SUPPORT_JIT)
+ ADD_EXECUTABLE(pcre_jit_test pcre_jit_test.c)
+ SET(targets ${targets} pcre_jit_test)
+ SET(PCRE_JIT_TEST_LIBS )
+ IF(PCRE_BUILD_PCRE8)
+ LIST(APPEND PCRE_JIT_TEST_LIBS pcre)
+ ENDIF(PCRE_BUILD_PCRE8)
+ IF(PCRE_BUILD_PCRE16)
+ LIST(APPEND PCRE_JIT_TEST_LIBS pcre16)
+ ENDIF(PCRE_BUILD_PCRE16)
+ IF(PCRE_BUILD_PCRE32)
+ LIST(APPEND PCRE_JIT_TEST_LIBS pcre32)
+ ENDIF(PCRE_BUILD_PCRE32)
+ TARGET_LINK_LIBRARIES(pcre_jit_test ${PCRE_JIT_TEST_LIBS})
+ ENDIF(PCRE_SUPPORT_JIT)
+
+ IF(PCRE_BUILD_PCRECPP)
+ ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)
+ SET(targets ${targets} pcrecpp_unittest)
+ TARGET_LINK_LIBRARIES(pcrecpp_unittest pcrecpp)
+ IF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC)
+ SET_TARGET_PROPERTIES(pcrecpp
+ PROPERTIES PREFIX ""
+ )
+ ENDIF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC)
+
+ ADD_EXECUTABLE(pcre_scanner_unittest pcre_scanner_unittest.cc)
+ SET(targets ${targets} pcre_scanner_unittest)
+ TARGET_LINK_LIBRARIES(pcre_scanner_unittest pcrecpp)
+
+ ADD_EXECUTABLE(pcre_stringpiece_unittest pcre_stringpiece_unittest.cc)
+ SET(targets ${targets} pcre_stringpiece_unittest)
+ TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)
+ ENDIF(PCRE_BUILD_PCRECPP)
+
+ # exes in Debug location tested by the RunTest shell script
+ # via "make test"
+ IF(PCRE_BUILD_PCREGREP)
+ GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)
+ ENDIF(PCRE_BUILD_PCREGREP)
+
+ GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)
+
+# =================================================
+ # Write out a CTest configuration file
+ #
+ FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest
+ "# This is a generated file.
+MESSAGE(\"When testing is complete, review test output in the
+\\\"${PROJECT_BINARY_DIR}/Testing/Temporary\\\" folder.\")
+MESSAGE(\" \")
+")
+
+ FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.sh
+ "#! /bin/sh
+# This is a generated file.
+srcdir=${PROJECT_SOURCE_DIR}
+pcretest=${PCRETEST_EXE}
+. ${PROJECT_SOURCE_DIR}/RunTest
+if test \"$?\" != \"0\"; then exit 1; fi
+# End
+")
+
+ IF(UNIX)
+ ADD_TEST(pcre_test sh ${PROJECT_BINARY_DIR}/pcre_test.sh)
+ ENDIF(UNIX)
+
+ IF(PCRE_BUILD_PCREGREP)
+ FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_grep_test.sh
+ "#! /bin/sh
+# This is a generated file.
+srcdir=${PROJECT_SOURCE_DIR}
+pcregrep=${PCREGREP_EXE}
+pcretest=${PCRETEST_EXE}
+. ${PROJECT_SOURCE_DIR}/RunGrepTest
+if test \"$?\" != \"0\"; then exit 1; fi
+# End
+")
+
+ IF(UNIX)
+ ADD_TEST(pcre_grep_test sh ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
+ ENDIF(UNIX)
+ ENDIF(PCRE_BUILD_PCREGREP)
+
+ IF(WIN32)
+ # Provide environment for executing the bat file version of RunTest
+ FILE(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} winsrc)
+ FILE(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} winbin)
+ FILE(TO_NATIVE_PATH ${PCRETEST_EXE} winexe)
+
+ FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.bat
+ "\@REM This is a generated file.
+\@echo off
+setlocal
+SET srcdir=\"${winsrc}\"
+SET pcretest=\"${winexe}\"
+if not [%CMAKE_CONFIG_TYPE%]==[] SET pcretest=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcretest.exe\"
+call %srcdir%\\RunTest.Bat
+if errorlevel 1 exit /b 1
+echo RunTest.bat tests successfully completed
+")
+
+ ADD_TEST(NAME pcre_test_bat
+ COMMAND pcre_test.bat)
+ SET_TESTS_PROPERTIES(pcre_test_bat PROPERTIES
+ PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")
+
+ IF("$ENV{OSTYPE}" STREQUAL "msys")
+ # Both the sh and bat file versions of RunTest are run if make test is used
+ # in msys
+ ADD_TEST(pcre_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre_test.sh)
+ IF(PCRE_BUILD_PCREGREP)
+ ADD_TEST(pcre_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
+ ENDIF(PCRE_BUILD_PCREGREP)
+ ENDIF("$ENV{OSTYPE}" STREQUAL "msys")
+
+ ENDIF(WIN32)
+
+ # Changed to accommodate testing whichever location was just built
+
+ IF(PCRE_SUPPORT_JIT)
+ ADD_TEST(pcre_jit_test pcre_jit_test)
+ ENDIF(PCRE_SUPPORT_JIT)
+
+ IF(PCRE_BUILD_PCRECPP)
+ ADD_TEST(pcrecpp_test pcrecpp_unittest)
+ ADD_TEST(pcre_scanner_test pcre_scanner_unittest)
+ ADD_TEST(pcre_stringpiece_test pcre_stringpiece_unittest)
+ ENDIF(PCRE_BUILD_PCRECPP)
+
+ENDIF(PCRE_BUILD_TESTS)
+
+# Installation
+SET(CMAKE_INSTALL_ALWAYS 1)
+
+INSTALL(TARGETS ${targets}
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+
+INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
+
+FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html)
+FILE(GLOB man1 ${PROJECT_SOURCE_DIR}/doc/*.1)
+FILE(GLOB man3 ${PROJECT_SOURCE_DIR}/doc/*.3)
+
+IF(PCRE_BUILD_PCRECPP)
+ INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include)
+ELSE(PCRE_BUILD_PCRECPP)
+ # Remove pcrecpp.3
+ FOREACH(man ${man3})
+ GET_FILENAME_COMPONENT(man_tmp ${man} NAME)
+ IF(NOT man_tmp STREQUAL "pcrecpp.3")
+ SET(man3_new ${man3} ${man})
+ ENDIF(NOT man_tmp STREQUAL "pcrecpp.3")
+ ENDFOREACH(man ${man3})
+ SET(man3 ${man3_new})
+ENDIF(PCRE_BUILD_PCRECPP)
+
+INSTALL(FILES ${man1} DESTINATION man/man1)
+INSTALL(FILES ${man3} DESTINATION man/man3)
+INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)
+
+IF(MSVC AND INSTALL_MSVC_PDB)
+ INSTALL(FILES ${PROJECT_BINARY_DIR}/pcre.pdb
+ ${PROJECT_BINARY_DIR}/pcreposix.pdb
+ DESTINATION bin
+ CONFIGURATIONS RelWithDebInfo)
+ INSTALL(FILES ${PROJECT_BINARY_DIR}/pcred.pdb
+ ${PROJECT_BINARY_DIR}/pcreposixd.pdb
+ DESTINATION bin
+ CONFIGURATIONS Debug)
+ENDIF(MSVC AND INSTALL_MSVC_PDB)
+
+# help, only for nice output
+IF(BUILD_SHARED_LIBS)
+ SET(BUILD_STATIC_LIBS OFF)
+ELSE(BUILD_SHARED_LIBS)
+ SET(BUILD_STATIC_LIBS ON)
+ENDIF(BUILD_SHARED_LIBS)
+
+IF(PCRE_SHOW_REPORT)
+ STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype)
+ IF (CMAKE_C_FLAGS)
+ SET(cfsp " ")
+ ENDIF(CMAKE_C_FLAGS)
+ IF (CMAKE_CXX_FLAGS)
+ SET(cxxfsp " ")
+ ENDIF(CMAKE_CXX_FLAGS)
+ MESSAGE(STATUS "")
+ MESSAGE(STATUS "")
+ MESSAGE(STATUS "PCRE configuration summary:")
+ MESSAGE(STATUS "")
+ MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
+ MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}")
+ MESSAGE(STATUS " C++ compiler .................... : ${CMAKE_CXX_COMPILER}")
+ MESSAGE(STATUS " C compiler flags ................ : ${CMAKE_C_FLAGS}${cfsp}${CMAKE_C_FLAGS_${buildtype}}")
+ MESSAGE(STATUS " C++ compiler flags .............. : ${CMAKE_CXX_FLAGS}${cxxfsp}${CMAKE_CXX_FLAGS_${buildtype}}")
+ MESSAGE(STATUS "")
+ MESSAGE(STATUS " Build 8 bit PCRE library ........ : ${PCRE_BUILD_PCRE8}")
+ MESSAGE(STATUS " Build 16 bit PCRE library ....... : ${PCRE_BUILD_PCRE16}")
+ MESSAGE(STATUS " Build 32 bit PCRE library ....... : ${PCRE_BUILD_PCRE32}")
+ MESSAGE(STATUS " Build C++ library ............... : ${PCRE_BUILD_PCRECPP}")
+ MESSAGE(STATUS " Enable JIT compiling support .... : ${PCRE_SUPPORT_JIT}")
+ MESSAGE(STATUS " Enable UTF support .............. : ${PCRE_SUPPORT_UTF}")
+ MESSAGE(STATUS " Unicode properties .............. : ${PCRE_SUPPORT_UNICODE_PROPERTIES}")
+ MESSAGE(STATUS " Newline char/sequence ........... : ${PCRE_NEWLINE}")
+ MESSAGE(STATUS " \\R matches only ANYCRLF ......... : ${PCRE_SUPPORT_BSR_ANYCRLF}")
+ MESSAGE(STATUS " EBCDIC coding ................... : ${PCRE_EBCDIC}")
+ MESSAGE(STATUS " EBCDIC coding with NL=0x25 ...... : ${PCRE_EBCDIC_NL25}")
+ MESSAGE(STATUS " Rebuild char tables ............. : ${PCRE_REBUILD_CHARTABLES}")
+ MESSAGE(STATUS " No stack recursion .............. : ${PCRE_NO_RECURSE}")
+ MESSAGE(STATUS " POSIX mem threshold ............. : ${PCRE_POSIX_MALLOC_THRESHOLD}")
+ MESSAGE(STATUS " Internal link size .............. : ${PCRE_LINK_SIZE}")
+ MESSAGE(STATUS " Parentheses nest limit .......... : ${PCRE_PARENS_NEST_LIMIT}")
+ MESSAGE(STATUS " Match limit ..................... : ${PCRE_MATCH_LIMIT}")
+ MESSAGE(STATUS " Match limit recursion ........... : ${PCRE_MATCH_LIMIT_RECURSION}")
+ MESSAGE(STATUS " Build shared libs ............... : ${BUILD_SHARED_LIBS}")
+ MESSAGE(STATUS " Build static libs ............... : ${BUILD_STATIC_LIBS}")
+ MESSAGE(STATUS " Build pcregrep .................. : ${PCRE_BUILD_PCREGREP}")
+ MESSAGE(STATUS " Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}")
+ MESSAGE(STATUS " Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}")
+ MESSAGE(STATUS " Build tests (implies pcretest .. : ${PCRE_BUILD_TESTS}")
+ MESSAGE(STATUS " and pcregrep)")
+ IF(ZLIB_FOUND)
+ MESSAGE(STATUS " Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}")
+ ELSE(ZLIB_FOUND)
+ MESSAGE(STATUS " Link pcregrep with libz ......... : Library not found" )
+ ENDIF(ZLIB_FOUND)
+ IF(BZIP2_FOUND)
+ MESSAGE(STATUS " Link pcregrep with libbz2 ....... : ${PCRE_SUPPORT_LIBBZ2}")
+ ELSE(BZIP2_FOUND)
+ MESSAGE(STATUS " Link pcregrep with libbz2 ....... : Library not found" )
+ ENDIF(BZIP2_FOUND)
+ IF(EDITLINE_FOUND)
+ MESSAGE(STATUS " Link pcretest with libeditline .. : ${PCRE_SUPPORT_LIBEDIT}")
+ ELSE(EDITLINE_FOUND)
+ MESSAGE(STATUS " Link pcretest with libeditline .. : Library not found" )
+ ENDIF(EDITLINE_FOUND)
+ IF(READLINE_FOUND)
+ MESSAGE(STATUS " Link pcretest with libreadline .. : ${PCRE_SUPPORT_LIBREADLINE}")
+ ELSE(READLINE_FOUND)
+ MESSAGE(STATUS " Link pcretest with libreadline .. : Library not found" )
+ ENDIF(READLINE_FOUND)
+ MESSAGE(STATUS " Support Valgrind .................: ${PCRE_SUPPORT_VALGRIND}")
+ MESSAGE(STATUS " Support coverage .................: ${PCRE_SUPPORT_COVERAGE}")
+
+ IF(MINGW AND NOT PCRE_STATIC)
+ MESSAGE(STATUS " Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}")
+ MESSAGE(STATUS " Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}")
+ ENDIF(MINGW AND NOT PCRE_STATIC)
+
+ IF(MSVC)
+ MESSAGE(STATUS " Install MSVC .pdb files ..........: ${INSTALL_MSVC_PDB}")
+ ENDIF(MSVC)
+
+ MESSAGE(STATUS "")
+ENDIF(PCRE_SHOW_REPORT)
# end CMakeLists.txt
diff --git a/deps/pcre/LICENCE b/deps/pcre/LICENCE
new file mode 100644
index 000000000..57a544814
--- /dev/null
+++ b/deps/pcre/LICENCE
@@ -0,0 +1,93 @@
+PCRE LICENCE
+------------
+
+PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+Release 8 of PCRE is distributed under the terms of the "BSD" licence, as
+specified below. The documentation for PCRE, supplied in the "doc"
+directory, is distributed under the same terms as the software itself. The data
+in the testdata directory is not copyrighted and is in the public domain.
+
+The basic library functions are written in C and are freestanding. Also
+included in the distribution is a set of C++ wrapper functions, and a
+just-in-time compiler that can be used to optimize pattern matching. These
+are both optional features that can be omitted when the library is built.
+
+
+THE BASIC LIBRARY FUNCTIONS
+---------------------------
+
+Written by: Philip Hazel
+Email local part: ph10
+Email domain: cam.ac.uk
+
+University of Cambridge Computing Service,
+Cambridge, England.
+
+Copyright (c) 1997-2020 University of Cambridge
+All rights reserved.
+
+
+PCRE JUST-IN-TIME COMPILATION SUPPORT
+-------------------------------------
+
+Written by: Zoltan Herczeg
+Email local part: hzmester
+Email domain: freemail.hu
+
+Copyright(c) 2010-2020 Zoltan Herczeg
+All rights reserved.
+
+
+STACK-LESS JUST-IN-TIME COMPILER
+--------------------------------
+
+Written by: Zoltan Herczeg
+Email local part: hzmester
+Email domain: freemail.hu
+
+Copyright(c) 2009-2020 Zoltan Herczeg
+All rights reserved.
+
+
+THE C++ WRAPPER FUNCTIONS
+-------------------------
+
+Contributed by: Google Inc.
+
+Copyright (c) 2007-2012, Google Inc.
+All rights reserved.
+
+
+THE "BSD" LICENCE
+-----------------
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of the University of Cambridge nor the name of Google
+ Inc. nor the names of their contributors may be used to endorse or
+ promote products derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+End
diff --git a/deps/pcre/config.h.in b/deps/pcre/config-cmake.h.in
index 77d901165..77d901165 100644
--- a/deps/pcre/config.h.in
+++ b/deps/pcre/config-cmake.h.in
diff --git a/deps/pcre/configure.ac b/deps/pcre/configure.ac
new file mode 100644
index 000000000..6a3e5f35d
--- /dev/null
+++ b/deps/pcre/configure.ac
@@ -0,0 +1,1126 @@
+dnl Process this file with autoconf to produce a configure script.
+
+dnl NOTE FOR MAINTAINERS: Do not use minor version numbers 08 or 09 because
+dnl the leading zeros may cause them to be treated as invalid octal constants
+dnl if a PCRE user writes code that uses PCRE_MINOR as a number. There is now
+dnl a check further down that throws an error if 08 or 09 are used.
+
+dnl The PCRE_PRERELEASE feature is for identifying release candidates. It might
+dnl be defined as -RC2, for example. For real releases, it should be empty.
+
+m4_define(pcre_major, [8])
+m4_define(pcre_minor, [44])
+m4_define(pcre_prerelease, [])
+m4_define(pcre_date, [2020-02-12])
+
+# NOTE: The CMakeLists.txt file searches for the above variables in the first
+# 50 lines of this file. Please update that if the variables above are moved.
+
+# Libtool shared library interface versions (current:revision:age)
+m4_define(libpcre_version, [3:12:2])
+m4_define(libpcre16_version, [2:12:2])
+m4_define(libpcre32_version, [0:12:0])
+m4_define(libpcreposix_version, [0:7:0])
+m4_define(libpcrecpp_version, [0:2:0])
+
+AC_PREREQ(2.57)
+AC_INIT(PCRE, pcre_major.pcre_minor[]pcre_prerelease, , pcre)
+AC_CONFIG_SRCDIR([pcre.h.in])
+AM_INIT_AUTOMAKE([dist-bzip2 dist-zip])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+AC_CONFIG_HEADERS(config.h)
+
+# This is a new thing required to stop a warning from automake 1.12
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+
+# This was added at the suggestion of libtoolize (03-Jan-10)
+AC_CONFIG_MACRO_DIR([m4])
+
+# The default CFLAGS and CXXFLAGS in Autoconf are "-g -O2" for gcc and just
+# "-g" for any other compiler. There doesn't seem to be a standard way of
+# getting rid of the -g (which I don't think is needed for a production
+# library). This fudge seems to achieve the necessary. First, we remember the
+# externally set values of CFLAGS and CXXFLAGS. Then call the AC_PROG_CC and
+# AC_PROG_CXX macros to find the compilers - if CFLAGS and CXXFLAGS are not
+# set, they will be set to Autoconf's defaults. Afterwards, if the original
+# values were not set, remove the -g from the Autoconf defaults.
+# (PH 02-May-07)
+
+remember_set_CFLAGS="$CFLAGS"
+remember_set_CXXFLAGS="$CXXFLAGS"
+
+AC_PROG_CC
+AC_PROG_CXX
+AM_PROG_CC_C_O
+
+if test "x$remember_set_CFLAGS" = "x"
+then
+ if test "$CFLAGS" = "-g -O2"
+ then
+ CFLAGS="-O2"
+ elif test "$CFLAGS" = "-g"
+ then
+ CFLAGS=""
+ fi
+fi
+
+if test "x$remember_set_CXXFLAGS" = "x"
+then
+ if test "$CXXFLAGS" = "-g -O2"
+ then
+ CXXFLAGS="-O2"
+ elif test "$CXXFLAGS" = "-g"
+ then
+ CXXFLAGS=""
+ fi
+fi
+
+# AC_PROG_CXX will return "g++" even if no c++ compiler is installed.
+# Check for that case, and just disable c++ code if g++ doesn't run.
+AC_LANG_PUSH(C++)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],, CXX=""; CXXCP=""; CXXFLAGS="")
+AC_LANG_POP
+
+# Check for a 64-bit integer type
+AC_TYPE_INT64_T
+
+AC_PROG_INSTALL
+AC_LIBTOOL_WIN32_DLL
+LT_INIT
+AC_PROG_LN_S
+
+# Check for GCC visibility feature
+
+PCRE_VISIBILITY
+
+# Versioning
+
+PCRE_MAJOR="pcre_major"
+PCRE_MINOR="pcre_minor"
+PCRE_PRERELEASE="pcre_prerelease"
+PCRE_DATE="pcre_date"
+
+if test "$PCRE_MINOR" = "08" -o "$PCRE_MINOR" = "09"
+then
+ echo "***"
+ echo "*** Minor version number $PCRE_MINOR must not be used. ***"
+ echo "*** Use only 01 to 07 or 10 onwards, to avoid octal issues. ***"
+ echo "***"
+ exit 1
+fi
+
+AC_SUBST(PCRE_MAJOR)
+AC_SUBST(PCRE_MINOR)
+AC_SUBST(PCRE_PRERELEASE)
+AC_SUBST(PCRE_DATE)
+
+# Set a more sensible default value for $(htmldir).
+if test "x$htmldir" = 'x${docdir}'
+then
+ htmldir='${docdir}/html'
+fi
+
+# Handle --disable-pcre8 (enabled by default)
+AC_ARG_ENABLE(pcre8,
+ AS_HELP_STRING([--disable-pcre8],
+ [disable 8 bit character support]),
+ , enable_pcre8=unset)
+AC_SUBST(enable_pcre8)
+
+# Handle --enable-pcre16 (disabled by default)
+AC_ARG_ENABLE(pcre16,
+ AS_HELP_STRING([--enable-pcre16],
+ [enable 16 bit character support]),
+ , enable_pcre16=unset)
+AC_SUBST(enable_pcre16)
+
+# Handle --enable-pcre32 (disabled by default)
+AC_ARG_ENABLE(pcre32,
+ AS_HELP_STRING([--enable-pcre32],
+ [enable 32 bit character support]),
+ , enable_pcre32=unset)
+AC_SUBST(enable_pcre32)
+
+# Handle --disable-cpp. The substitution of enable_cpp is needed for use in
+# pcre-config.
+AC_ARG_ENABLE(cpp,
+ AS_HELP_STRING([--disable-cpp],
+ [disable C++ support]),
+ , enable_cpp=unset)
+AC_SUBST(enable_cpp)
+
+# Handle --enable-jit (disabled by default)
+AC_ARG_ENABLE(jit,
+ AS_HELP_STRING([--enable-jit],
+ [enable Just-In-Time compiling support]),
+ , enable_jit=no)
+
+# This code enables JIT if the hardware supports it.
+
+if test "$enable_jit" = "auto"; then
+ AC_LANG(C)
+ SAVE_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS=-I$srcdir
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ #define SLJIT_CONFIG_AUTO 1
+ #include "sljit/sljitConfigInternal.h"
+ #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
+ #error unsupported
+ #endif]])], enable_jit=yes, enable_jit=no)
+ CPPFLAGS=$SAVE_CPPFLAGS
+fi
+
+# Handle --disable-pcregrep-jit (enabled by default)
+AC_ARG_ENABLE(pcregrep-jit,
+ AS_HELP_STRING([--disable-pcregrep-jit],
+ [disable JIT support in pcregrep]),
+ , enable_pcregrep_jit=yes)
+
+# Handle --enable-rebuild-chartables
+AC_ARG_ENABLE(rebuild-chartables,
+ AS_HELP_STRING([--enable-rebuild-chartables],
+ [rebuild character tables in current locale]),
+ , enable_rebuild_chartables=no)
+
+# Handle --enable-utf8 (disabled by default)
+AC_ARG_ENABLE(utf8,
+ AS_HELP_STRING([--enable-utf8],
+ [another name for --enable-utf. Kept only for compatibility reasons]),
+ , enable_utf8=unset)
+
+# Handle --enable-utf (disabled by default)
+AC_ARG_ENABLE(utf,
+ AS_HELP_STRING([--enable-utf],
+ [enable UTF-8/16/32 support (incompatible with --enable-ebcdic)]),
+ , enable_utf=unset)
+
+# Handle --enable-unicode-properties
+AC_ARG_ENABLE(unicode-properties,
+ AS_HELP_STRING([--enable-unicode-properties],
+ [enable Unicode properties support (implies --enable-utf)]),
+ , enable_unicode_properties=no)
+
+# Handle newline options
+ac_pcre_newline=lf
+AC_ARG_ENABLE(newline-is-cr,
+ AS_HELP_STRING([--enable-newline-is-cr],
+ [use CR as newline character]),
+ ac_pcre_newline=cr)
+AC_ARG_ENABLE(newline-is-lf,
+ AS_HELP_STRING([--enable-newline-is-lf],
+ [use LF as newline character (default)]),
+ ac_pcre_newline=lf)
+AC_ARG_ENABLE(newline-is-crlf,
+ AS_HELP_STRING([--enable-newline-is-crlf],
+ [use CRLF as newline sequence]),
+ ac_pcre_newline=crlf)
+AC_ARG_ENABLE(newline-is-anycrlf,
+ AS_HELP_STRING([--enable-newline-is-anycrlf],
+ [use CR, LF, or CRLF as newline sequence]),
+ ac_pcre_newline=anycrlf)
+AC_ARG_ENABLE(newline-is-any,
+ AS_HELP_STRING([--enable-newline-is-any],
+ [use any valid Unicode newline sequence]),
+ ac_pcre_newline=any)
+enable_newline="$ac_pcre_newline"
+
+# Handle --enable-bsr-anycrlf
+AC_ARG_ENABLE(bsr-anycrlf,
+ AS_HELP_STRING([--enable-bsr-anycrlf],
+ [\R matches only CR, LF, CRLF by default]),
+ , enable_bsr_anycrlf=no)
+
+# Handle --enable-ebcdic
+AC_ARG_ENABLE(ebcdic,
+ AS_HELP_STRING([--enable-ebcdic],
+ [assume EBCDIC coding rather than ASCII; incompatible with --enable-utf; use only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
+ , enable_ebcdic=no)
+
+# Handle --enable-ebcdic-nl25
+AC_ARG_ENABLE(ebcdic-nl25,
+ AS_HELP_STRING([--enable-ebcdic-nl25],
+ [set EBCDIC code for NL to 0x25 instead of 0x15; it implies --enable-ebcdic]),
+ , enable_ebcdic_nl25=no)
+
+# Handle --disable-stack-for-recursion
+AC_ARG_ENABLE(stack-for-recursion,
+ AS_HELP_STRING([--disable-stack-for-recursion],
+ [don't use stack recursion when matching]),
+ , enable_stack_for_recursion=yes)
+
+# Handle --enable-pcregrep-libz
+AC_ARG_ENABLE(pcregrep-libz,
+ AS_HELP_STRING([--enable-pcregrep-libz],
+ [link pcregrep with libz to handle .gz files]),
+ , enable_pcregrep_libz=no)
+
+# Handle --enable-pcregrep-libbz2
+AC_ARG_ENABLE(pcregrep-libbz2,
+ AS_HELP_STRING([--enable-pcregrep-libbz2],
+ [link pcregrep with libbz2 to handle .bz2 files]),
+ , enable_pcregrep_libbz2=no)
+
+# Handle --with-pcregrep-bufsize=N
+AC_ARG_WITH(pcregrep-bufsize,
+ AS_HELP_STRING([--with-pcregrep-bufsize=N],
+ [pcregrep buffer size (default=20480, minimum=8192)]),
+ , with_pcregrep_bufsize=20480)
+
+# Handle --enable-pcretest-libedit
+AC_ARG_ENABLE(pcretest-libedit,
+ AS_HELP_STRING([--enable-pcretest-libedit],
+ [link pcretest with libedit]),
+ , enable_pcretest_libedit=no)
+
+# Handle --enable-pcretest-libreadline
+AC_ARG_ENABLE(pcretest-libreadline,
+ AS_HELP_STRING([--enable-pcretest-libreadline],
+ [link pcretest with libreadline]),
+ , enable_pcretest_libreadline=no)
+
+# Handle --with-posix-malloc-threshold=NBYTES
+AC_ARG_WITH(posix-malloc-threshold,
+ AS_HELP_STRING([--with-posix-malloc-threshold=NBYTES],
+ [threshold for POSIX malloc usage (default=10)]),
+ , with_posix_malloc_threshold=10)
+
+# Handle --with-link-size=N
+AC_ARG_WITH(link-size,
+ AS_HELP_STRING([--with-link-size=N],
+ [internal link size (2, 3, or 4 allowed; default=2)]),
+ , with_link_size=2)
+
+# Handle --with-parens-nest-limit=N
+AC_ARG_WITH(parens-nest-limit,
+ AS_HELP_STRING([--with-parens-nest-limit=N],
+ [nested parentheses limit (default=250)]),
+ , with_parens_nest_limit=250)
+
+# Handle --with-match-limit=N
+AC_ARG_WITH(match-limit,
+ AS_HELP_STRING([--with-match-limit=N],
+ [default limit on internal looping (default=10000000)]),
+ , with_match_limit=10000000)
+
+# Handle --with-match-limit_recursion=N
+#
+# Note: In config.h, the default is to define MATCH_LIMIT_RECURSION
+# symbolically as MATCH_LIMIT, which in turn is defined to be some numeric
+# value (e.g. 10000000). MATCH_LIMIT_RECURSION can otherwise be set to some
+# different numeric value (or even the same numeric value as MATCH_LIMIT,
+# though no longer defined in terms of the latter).
+#
+AC_ARG_WITH(match-limit-recursion,
+ AS_HELP_STRING([--with-match-limit-recursion=N],
+ [default limit on internal recursion (default=MATCH_LIMIT)]),
+ , with_match_limit_recursion=MATCH_LIMIT)
+
+# Handle --enable-valgrind
+AC_ARG_ENABLE(valgrind,
+ AS_HELP_STRING([--enable-valgrind],
+ [valgrind support]),
+ , enable_valgrind=no)
+
+# Enable code coverage reports using gcov
+AC_ARG_ENABLE(coverage,
+ AS_HELP_STRING([--enable-coverage],
+ [enable code coverage reports using gcov]),
+ , enable_coverage=no)
+
+# Copy enable_utf8 value to enable_utf for compatibility reasons
+if test "x$enable_utf8" != "xunset"
+then
+ if test "x$enable_utf" != "xunset"
+ then
+ AC_MSG_ERROR([--enable/disable-utf8 is kept only for compatibility reasons and its value is copied to --enable/disable-utf. Newer code must use --enable/disable-utf alone.])
+ fi
+ enable_utf=$enable_utf8
+fi
+
+# Set the default value for pcre8
+if test "x$enable_pcre8" = "xunset"
+then
+ enable_pcre8=yes
+fi
+
+# Set the default value for pcre16
+if test "x$enable_pcre16" = "xunset"
+then
+ enable_pcre16=no
+fi
+
+# Set the default value for pcre32
+if test "x$enable_pcre32" = "xunset"
+then
+ enable_pcre32=no
+fi
+
+# Make sure enable_pcre8 or enable_pcre16 was set
+if test "x$enable_pcre8$enable_pcre16$enable_pcre32" = "xnonono"
+then
+ AC_MSG_ERROR([At least one of 8, 16 or 32 bit pcre library must be enabled])
+fi
+
+# Make sure that if enable_unicode_properties was set, that UTF support is enabled.
+if test "x$enable_unicode_properties" = "xyes"
+then
+ if test "x$enable_utf" = "xno"
+ then
+ AC_MSG_ERROR([support for Unicode properties requires UTF-8/16/32 support])
+ fi
+ enable_utf=yes
+fi
+
+# enable_utf is disabled by default.
+if test "x$enable_utf" = "xunset"
+then
+ enable_utf=no
+fi
+
+# enable_cpp copies the value of enable_pcre8 by default
+if test "x$enable_cpp" = "xunset"
+then
+ enable_cpp=$enable_pcre8
+fi
+
+# Make sure that if enable_cpp was set, that enable_pcre8 support is enabled
+if test "x$enable_cpp" = "xyes"
+then
+ if test "x$enable_pcre8" = "xno"
+ then
+ AC_MSG_ERROR([C++ library requires pcre library with 8 bit characters])
+ fi
+fi
+
+# Convert the newline identifier into the appropriate integer value. The first
+# three are ASCII values 0x0a, 0x0d, and 0x0d0a, but if EBCDIC is enabled, they
+# are changed below.
+
+case "$enable_newline" in
+ lf) ac_pcre_newline_value=10 ;;
+ cr) ac_pcre_newline_value=13 ;;
+ crlf) ac_pcre_newline_value=3338 ;;
+ anycrlf) ac_pcre_newline_value=-2 ;;
+ any) ac_pcre_newline_value=-1 ;;
+ *)
+ AC_MSG_ERROR([invalid argument \"$enable_newline\" to --enable-newline option])
+ ;;
+esac
+
+# --enable-ebcdic-nl25 implies --enable-ebcdic
+if test "x$enable_ebcdic_nl25" = "xyes"; then
+ enable_ebcdic=yes
+fi
+
+# Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled,
+# and the newline value is adjusted appropriately (CR is still 13, but LF is
+# 21 or 37). Also check that UTF support is not requested, because PCRE cannot
+# handle EBCDIC and UTF in the same build. To do so it would need to use
+# different character constants depending on the mode.
+#
+if test "x$enable_ebcdic" = "xyes"; then
+ enable_rebuild_chartables=yes
+
+ if test "x$enable_utf" = "xyes"; then
+ AC_MSG_ERROR([support for EBCDIC and UTF-8/16/32 cannot be enabled at the same time])
+ fi
+
+ if test "x$enable_ebcdic_nl25" = "xno"; then
+ case "$ac_pcre_newline_value" in
+ 10) ac_pcre_newline_value=21 ;;
+ 3338) ac_pcre_newline_value=3349 ;;
+ esac
+ else
+ case "$ac_pcre_newline_value" in
+ 10) ac_pcre_newline_value=37 ;;
+ 3338) ac_pcre_newline_value=3365 ;;
+ esac
+ fi
+fi
+
+# Check argument to --with-link-size
+case "$with_link_size" in
+ 2|3|4) ;;
+ *)
+ AC_MSG_ERROR([invalid argument \"$with_link_size\" to --with-link-size option])
+ ;;
+esac
+
+AH_TOP([
+/* PCRE is written in Standard C, but there are a few non-standard things it
+can cope with, allowing it to run on SunOS4 and other "close to standard"
+systems.
+
+In environments that support the GNU autotools, config.h.in is converted into
+config.h by the "configure" script. In environments that use CMake,
+config-cmake.in is converted into config.h. If you are going to build PCRE "by
+hand" without using "configure" or CMake, you should copy the distributed
+config.h.generic to config.h, and edit the macro definitions to be the way you
+need them. You must then add -DHAVE_CONFIG_H to all of your compile commands,
+so that config.h is included at the start of every source.
+
+Alternatively, you can avoid editing by using -D on the compiler command line
+to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H,
+but if you do, default values will be taken from config.h for non-boolean
+macros that are not defined on the command line.
+
+Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE8 should either be defined
+(conventionally to 1) for TRUE, and not defined at all for FALSE. All such
+macros are listed as a commented #undef in config.h.generic. Macros such as
+MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
+surrounded by #ifndef/#endif lines so that the value can be overridden by -D.
+
+PCRE uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
+HAVE_BCOPY is defined. If your system has neither bcopy() nor memmove(), make
+sure both macros are undefined; an emulation function will then be used. */])
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(limits.h sys/types.h sys/stat.h dirent.h)
+AC_CHECK_HEADERS([windows.h], [HAVE_WINDOWS_H=1])
+
+# The files below are C++ header files.
+pcre_have_type_traits="0"
+pcre_have_bits_type_traits="0"
+
+if test "x$enable_cpp" = "xyes" -a -z "$CXX"; then
+ AC_MSG_ERROR([Invalid C++ compiler or C++ compiler flags])
+fi
+
+if test "x$enable_cpp" = "xyes" -a -n "$CXX"
+then
+AC_LANG_PUSH(C++)
+
+# Older versions of pcre defined pcrecpp::no_arg, but in new versions
+# it's called pcrecpp::RE::no_arg. For backwards ABI compatibility,
+# we want to make one an alias for the other. Different systems do
+# this in different ways. Some systems, for instance, can do it via
+# a linker flag: -alias (for os x 10.5) or -i (for os x <=10.4).
+OLD_LDFLAGS="$LDFLAGS"
+for flag in "-alias,__ZN7pcrecpp2RE6no_argE,__ZN7pcrecpp6no_argE" \
+ "-i__ZN7pcrecpp6no_argE:__ZN7pcrecpp2RE6no_argE"; do
+ AC_MSG_CHECKING([for alias support in the linker])
+ LDFLAGS="$OLD_LDFLAGS -Wl,$flag"
+ # We try to run the linker with this new ld flag. If the link fails,
+ # we give up and remove the new flag from LDFLAGS.
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([namespace pcrecpp {
+ class RE { static int no_arg; };
+ int RE::no_arg;
+ }],
+ [])],
+ [AC_MSG_RESULT([yes]);
+ EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS -Wl,$flag";
+ break;],
+ AC_MSG_RESULT([no]))
+done
+LDFLAGS="$OLD_LDFLAGS"
+
+# We could be more clever here, given we're doing AC_SUBST with this
+# (eg set a var to be the name of the include file we want). But we're not
+# so it's easy to change back to 'regular' autoconf vars if we needed to.
+AC_CHECK_HEADERS(string, [pcre_have_cpp_headers="1"],
+ [pcre_have_cpp_headers="0"])
+AC_CHECK_HEADERS(bits/type_traits.h, [pcre_have_bits_type_traits="1"],
+ [pcre_have_bits_type_traits="0"])
+AC_CHECK_HEADERS(type_traits.h, [pcre_have_type_traits="1"],
+ [pcre_have_type_traits="0"])
+
+# (This isn't c++-specific, but is only used in pcrecpp.cc, so try this
+# in a c++ context. This matters becuase strtoimax is C99 and may not
+# be supported by the C++ compiler.)
+# Figure out how to create a longlong from a string: strtoll and
+# equiv. It's not enough to call AC_CHECK_FUNCS: hpux has a
+# strtoll, for instance, but it only takes 2 args instead of 3!
+# We have to call AH_TEMPLATE since AC_DEFINE_UNQUOTED below is complex.
+AH_TEMPLATE(HAVE_STRTOQ, [Define to 1 if you have `strtoq'.])
+AH_TEMPLATE(HAVE_STRTOLL, [Define to 1 if you have `strtoll'.])
+AH_TEMPLATE(HAVE__STRTOI64, [Define to 1 if you have `_strtoi64'.])
+AH_TEMPLATE(HAVE_STRTOIMAX, [Define to 1 if you have `strtoimax'.])
+have_strto_fn=0
+for fn in strtoq strtoll _strtoi64 strtoimax; do
+ AC_MSG_CHECKING([for $fn])
+ if test "$fn" = strtoimax; then
+ include=stdint.h
+ else
+ include=stdlib.h
+ fi
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <$include>],
+ [char* e; return $fn("100", &e, 10)])],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE_UNQUOTED(HAVE_`echo $fn | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`, 1,
+ [Define to 1 if you have `$fn'.])
+ have_strto_fn=1
+ break],
+ [AC_MSG_RESULT(no)])
+done
+
+if test "$have_strto_fn" = 1; then
+ AC_CHECK_TYPES([long long],
+ [pcre_have_long_long="1"],
+ [pcre_have_long_long="0"])
+ AC_CHECK_TYPES([unsigned long long],
+ [pcre_have_ulong_long="1"],
+ [pcre_have_ulong_long="0"])
+else
+ pcre_have_long_long="0"
+ pcre_have_ulong_long="0"
+fi
+AC_SUBST(pcre_have_long_long)
+AC_SUBST(pcre_have_ulong_long)
+
+AC_LANG_POP
+fi
+# Using AC_SUBST eliminates the need to include config.h in a public .h file
+AC_SUBST(pcre_have_type_traits)
+AC_SUBST(pcre_have_bits_type_traits)
+
+# Conditional compilation
+AM_CONDITIONAL(WITH_PCRE8, test "x$enable_pcre8" = "xyes")
+AM_CONDITIONAL(WITH_PCRE16, test "x$enable_pcre16" = "xyes")
+AM_CONDITIONAL(WITH_PCRE32, test "x$enable_pcre32" = "xyes")
+AM_CONDITIONAL(WITH_PCRE_CPP, test "x$enable_cpp" = "xyes")
+AM_CONDITIONAL(WITH_REBUILD_CHARTABLES, test "x$enable_rebuild_chartables" = "xyes")
+AM_CONDITIONAL(WITH_JIT, test "x$enable_jit" = "xyes")
+AM_CONDITIONAL(WITH_UTF, test "x$enable_utf" = "xyes")
+AM_CONDITIONAL(WITH_VALGRIND, test "x$enable_valgrind" = "xyes")
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+AC_C_CONST
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+
+AC_CHECK_FUNCS(bcopy memmove strerror)
+
+# Check for the availability of libz (aka zlib)
+
+AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H=1])
+AC_CHECK_LIB([z], [gzopen], [HAVE_LIBZ=1])
+
+# Check for the availability of libbz2. Originally we just used AC_CHECK_LIB,
+# as for libz. However, this had the following problem, diagnosed and fixed by
+# a user:
+#
+# - libbz2 uses the Pascal calling convention (WINAPI) for the functions
+# under Win32.
+# - The standard autoconf AC_CHECK_LIB fails to include "bzlib.h",
+# therefore missing the function definition.
+# - The compiler thus generates a "C" signature for the test function.
+# - The linker fails to find the "C" function.
+# - PCRE fails to configure if asked to do so against libbz2.
+#
+# Solution:
+#
+# - Replace the AC_CHECK_LIB test with a custom test.
+
+AC_CHECK_HEADERS([bzlib.h], [HAVE_BZLIB_H=1])
+# Original test
+# AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])
+#
+# Custom test follows
+
+AC_MSG_CHECKING([for libbz2])
+OLD_LIBS="$LIBS"
+LIBS="$LIBS -lbz2"
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#ifdef HAVE_BZLIB_H
+#include <bzlib.h>
+#endif]],
+[[return (int)BZ2_bzopen("conftest", "rb");]])],
+[AC_MSG_RESULT([yes]);HAVE_LIBBZ2=1; break;],
+AC_MSG_RESULT([no]))
+LIBS="$OLD_LIBS"
+
+# Check for the availabiity of libreadline
+
+if test "$enable_pcretest_libreadline" = "yes"; then
+ AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])
+ AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1])
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lreadline"],
+ [unset ac_cv_lib_readline_readline;
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltinfo"],
+ [unset ac_cv_lib_readline_readline;
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lcurses"],
+ [unset ac_cv_lib_readline_readline;
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncurses"],
+ [unset ac_cv_lib_readline_readline;
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
+ [unset ac_cv_lib_readline_readline;
+ AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
+ [LIBREADLINE=""],
+ [-ltermcap])],
+ [-lncursesw])],
+ [-lncurses])],
+ [-lcurses])],
+ [-ltinfo])])
+ AC_SUBST(LIBREADLINE)
+ if test -n "$LIBREADLINE"; then
+ if test "$LIBREADLINE" != "-lreadline"; then
+ echo "-lreadline needs $LIBREADLINE"
+ LIBREADLINE="-lreadline $LIBREADLINE"
+ fi
+ fi
+fi
+
+
+# Check for the availability of libedit. Different distributions put its
+# headers in different places. Try to cover the most common ones.
+
+if test "$enable_pcretest_libedit" = "yes"; then
+ AC_CHECK_HEADERS([editline/readline.h], [HAVE_EDITLINE_READLINE_H=1],
+ [AC_CHECK_HEADERS([edit/readline/readline.h], [HAVE_READLINE_READLINE_H=1],
+ [AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_READLINE_H=1])])])
+ AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"])
+fi
+
+# This facilitates -ansi builds under Linux
+dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc])
+
+PCRE_STATIC_CFLAG=""
+if test "x$enable_shared" = "xno" ; then
+ AC_DEFINE([PCRE_STATIC], [1], [
+ Define to any value if linking statically (TODO: make nice with Libtool)])
+ PCRE_STATIC_CFLAG="-DPCRE_STATIC"
+fi
+AC_SUBST(PCRE_STATIC_CFLAG)
+
+# Here is where pcre specific defines are handled
+
+if test "$enable_pcre8" = "yes"; then
+ AC_DEFINE([SUPPORT_PCRE8], [], [
+ Define to any value to enable the 8 bit PCRE library.])
+fi
+
+if test "$enable_pcre16" = "yes"; then
+ AC_DEFINE([SUPPORT_PCRE16], [], [
+ Define to any value to enable the 16 bit PCRE library.])
+fi
+
+if test "$enable_pcre32" = "yes"; then
+ AC_DEFINE([SUPPORT_PCRE32], [], [
+ Define to any value to enable the 32 bit PCRE library.])
+fi
+
+# Unless running under Windows, JIT support requires pthreads.
+
+if test "$enable_jit" = "yes"; then
+ if test "$HAVE_WINDOWS_H" != "1"; then
+ AX_PTHREAD([], [AC_MSG_ERROR([JIT support requires pthreads])])
+ CC="$PTHREAD_CC"
+ CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ fi
+ AC_DEFINE([SUPPORT_JIT], [], [
+ Define to any value to enable support for Just-In-Time compiling.])
+else
+ enable_pcregrep_jit="no"
+fi
+
+if test "$enable_pcregrep_jit" = "yes"; then
+ AC_DEFINE([SUPPORT_PCREGREP_JIT], [], [
+ Define to any value to enable JIT support in pcregrep.])
+fi
+
+if test "$enable_utf" = "yes"; then
+ AC_DEFINE([SUPPORT_UTF], [], [
+ Define to any value to enable support for the UTF-8/16/32 Unicode encoding.
+ This will work even in an EBCDIC environment, but it is incompatible
+ with the EBCDIC macro. That is, PCRE can support *either* EBCDIC
+ code *or* ASCII/UTF-8/16/32, but not both at once.])
+fi
+
+if test "$enable_unicode_properties" = "yes"; then
+ AC_DEFINE([SUPPORT_UCP], [], [
+ Define to any value to enable support for Unicode properties.])
+fi
+
+if test "$enable_stack_for_recursion" = "no"; then
+ AC_DEFINE([NO_RECURSE], [], [
+ PCRE uses recursive function calls to handle backtracking while
+ matching. This can sometimes be a problem on systems that have
+ stacks of limited size. Define NO_RECURSE to any value to get a
+ version that doesn't use recursion in the match() function; instead
+ it creates its own stack by steam using pcre_recurse_malloc() to obtain
+ memory from the heap. For more detail, see the comments and other stuff
+ just above the match() function.])
+fi
+
+if test "$enable_pcregrep_libz" = "yes"; then
+ AC_DEFINE([SUPPORT_LIBZ], [], [
+ Define to any value to allow pcregrep to be linked with libz, so that it is
+ able to handle .gz files.])
+fi
+
+if test "$enable_pcregrep_libbz2" = "yes"; then
+ AC_DEFINE([SUPPORT_LIBBZ2], [], [
+ Define to any value to allow pcregrep to be linked with libbz2, so that it
+ is able to handle .bz2 files.])
+fi
+
+if test $with_pcregrep_bufsize -lt 8192 ; then
+ AC_MSG_WARN([$with_pcregrep_bufsize is too small for --with-pcregrep-bufsize; using 8192])
+ with_pcregrep_bufsize="8192"
+else
+ if test $? -gt 1 ; then
+ AC_MSG_ERROR([Bad value for --with-pcregrep-bufsize])
+ fi
+fi
+
+AC_DEFINE_UNQUOTED([PCREGREP_BUFSIZE], [$with_pcregrep_bufsize], [
+ The value of PCREGREP_BUFSIZE determines the size of buffer used by pcregrep
+ to hold parts of the file it is searching. This is also the minimum value.
+ The actual amount of memory used by pcregrep is three times this number,
+ because it allows for the buffering of "before" and "after" lines.])
+
+if test "$enable_pcretest_libedit" = "yes"; then
+ AC_DEFINE([SUPPORT_LIBEDIT], [], [
+ Define to any value to allow pcretest to be linked with libedit.])
+ LIBREADLINE="$LIBEDIT"
+elif test "$enable_pcretest_libreadline" = "yes"; then
+ AC_DEFINE([SUPPORT_LIBREADLINE], [], [
+ Define to any value to allow pcretest to be linked with libreadline.])
+fi
+
+AC_DEFINE_UNQUOTED([NEWLINE], [$ac_pcre_newline_value], [
+ The value of NEWLINE determines the default newline character sequence. PCRE
+ client programs can override this by selecting other values at run time. In
+ ASCII environments, the value can be 10 (LF), 13 (CR), or 3338 (CRLF); in
+ EBCDIC environments the value can be 21 or 37 (LF), 13 (CR), or 3349 or 3365
+ (CRLF) because there are two alternative codepoints (0x15 and 0x25) that are
+ used as the NL line terminator that is equivalent to ASCII LF. In both ASCII
+ and EBCDIC environments the value can also be -1 (ANY), or -2 (ANYCRLF).])
+
+if test "$enable_bsr_anycrlf" = "yes"; then
+ AC_DEFINE([BSR_ANYCRLF], [], [
+ By default, the \R escape sequence matches any Unicode line ending
+ character or sequence of characters. If BSR_ANYCRLF is defined (to any
+ value), this is changed so that backslash-R matches only CR, LF, or CRLF.
+ The build-time default can be overridden by the user of PCRE at runtime.])
+fi
+
+AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [
+ The value of LINK_SIZE determines the number of bytes used to store
+ links as offsets within the compiled regex. The default is 2, which
+ allows for compiled patterns up to 64K long. This covers the vast
+ majority of cases. However, PCRE can also be compiled to use 3 or 4
+ bytes instead. This allows for longer patterns in extreme cases.])
+
+AC_DEFINE_UNQUOTED([POSIX_MALLOC_THRESHOLD], [$with_posix_malloc_threshold], [
+ When calling PCRE via the POSIX interface, additional working storage
+ is required for holding the pointers to capturing substrings because
+ PCRE requires three integers per substring, whereas the POSIX
+ interface provides only two. If the number of expected substrings is
+ small, the wrapper function uses space on the stack, because this is
+ faster than using malloc() for each call. The threshold above which
+ the stack is no longer used is defined by POSIX_MALLOC_THRESHOLD.])
+
+AC_DEFINE_UNQUOTED([PARENS_NEST_LIMIT], [$with_parens_nest_limit], [
+ The value of PARENS_NEST_LIMIT specifies the maximum depth of nested
+ parentheses (of any kind) in a pattern. This limits the amount of system
+ stack that is used while compiling a pattern.])
+
+AC_DEFINE_UNQUOTED([MATCH_LIMIT], [$with_match_limit], [
+ The value of MATCH_LIMIT determines the default number of times the
+ internal match() function can be called during a single execution of
+ pcre_exec(). There is a runtime interface for setting a different
+ limit. The limit exists in order to catch runaway regular
+ expressions that take for ever to determine that they do not match.
+ The default is set very large so that it does not accidentally catch
+ legitimate cases.])
+
+AC_DEFINE_UNQUOTED([MATCH_LIMIT_RECURSION], [$with_match_limit_recursion], [
+ The above limit applies to all calls of match(), whether or not they
+ increase the recursion depth. In some environments it is desirable
+ to limit the depth of recursive calls of match() more strictly, in
+ order to restrict the maximum amount of stack (or heap, if
+ NO_RECURSE is defined) that is used. The value of
+ MATCH_LIMIT_RECURSION applies only to recursive calls of match(). To
+ have any useful effect, it must be less than the value of
+ MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT.
+ There is a runtime method for setting a different limit.])
+
+AC_DEFINE([MAX_NAME_SIZE], [32], [
+ This limit is parameterized just in case anybody ever wants to
+ change it. Care must be taken if it is increased, because it guards
+ against integer overflow caused by enormously large patterns.])
+
+AC_DEFINE([MAX_NAME_COUNT], [10000], [
+ This limit is parameterized just in case anybody ever wants to
+ change it. Care must be taken if it is increased, because it guards
+ against integer overflow caused by enormously large patterns.])
+
+AH_VERBATIM([PCRE_EXP_DEFN], [
+/* If you are compiling for a system other than a Unix-like system or
+ Win32, and it needs some magic to be inserted before the definition
+ of a function that is exported by the library, define this macro to
+ contain the relevant magic. If you do not define this macro, a suitable
+ __declspec value is used for Windows systems; in other environments
+ "extern" is used for a C compiler and "extern C" for a C++ compiler.
+ This macro apears at the start of every exported function that is part
+ of the external API. It does not appear on functions that are "external"
+ in the C sense, but which are internal to the library. */
+#undef PCRE_EXP_DEFN])
+
+if test "$enable_ebcdic" = "yes"; then
+ AC_DEFINE_UNQUOTED([EBCDIC], [], [
+ If you are compiling for a system that uses EBCDIC instead of ASCII
+ character codes, define this macro to any value. You must also edit the
+ NEWLINE macro below to set a suitable EBCDIC newline, commonly 21 (0x15).
+ On systems that can use "configure" or CMake to set EBCDIC, NEWLINE is
+ automatically adjusted. When EBCDIC is set, PCRE assumes that all input
+ strings are in EBCDIC. If you do not define this macro, PCRE will assume
+ input strings are ASCII or UTF-8/16/32 Unicode. It is not possible to build
+ a version of PCRE that supports both EBCDIC and UTF-8/16/32.])
+fi
+
+if test "$enable_ebcdic_nl25" = "yes"; then
+ AC_DEFINE_UNQUOTED([EBCDIC_NL25], [], [
+ In an EBCDIC environment, define this macro to any value to arrange for
+ the NL character to be 0x25 instead of the default 0x15. NL plays the role
+ that LF does in an ASCII/Unicode environment. The value must also be set in
+ the NEWLINE macro below. On systems that can use "configure" or CMake to
+ set EBCDIC_NL25, the adjustment of NEWLINE is automatic.])
+fi
+
+if test "$enable_valgrind" = "yes"; then
+ AC_DEFINE_UNQUOTED([SUPPORT_VALGRIND], [], [
+ Define to any value for valgrind support to find invalid memory reads.])
+fi
+
+# Platform specific issues
+NO_UNDEFINED=
+EXPORT_ALL_SYMBOLS=
+case $host_os in
+ cygwin* | mingw* )
+ if test X"$enable_shared" = Xyes; then
+ NO_UNDEFINED="-no-undefined"
+ EXPORT_ALL_SYMBOLS="-Wl,--export-all-symbols"
+ fi
+ ;;
+esac
+
+# The extra LDFLAGS for each particular library
+# (Note: The libpcre*_version bits are m4 variables, assigned above)
+
+EXTRA_LIBPCRE_LDFLAGS="$EXTRA_LIBPCRE_LDFLAGS \
+ $NO_UNDEFINED -version-info libpcre_version"
+
+EXTRA_LIBPCRE16_LDFLAGS="$EXTRA_LIBPCRE16_LDFLAGS \
+ $NO_UNDEFINED -version-info libpcre16_version"
+
+EXTRA_LIBPCRE32_LDFLAGS="$EXTRA_LIBPCRE32_LDFLAGS \
+ $NO_UNDEFINED -version-info libpcre32_version"
+
+EXTRA_LIBPCREPOSIX_LDFLAGS="$EXTRA_LIBPCREPOSIX_LDFLAGS \
+ $NO_UNDEFINED -version-info libpcreposix_version"
+
+EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS \
+ $NO_UNDEFINED -version-info libpcrecpp_version \
+ $EXPORT_ALL_SYMBOLS"
+
+AC_SUBST(EXTRA_LIBPCRE_LDFLAGS)
+AC_SUBST(EXTRA_LIBPCRE16_LDFLAGS)
+AC_SUBST(EXTRA_LIBPCRE32_LDFLAGS)
+AC_SUBST(EXTRA_LIBPCREPOSIX_LDFLAGS)
+AC_SUBST(EXTRA_LIBPCRECPP_LDFLAGS)
+
+# When we run 'make distcheck', use these arguments. Turning off compiler
+# optimization makes it run faster.
+DISTCHECK_CONFIGURE_FLAGS="CFLAGS='' CXXFLAGS='' --enable-pcre16 --enable-pcre32 --enable-jit --enable-cpp --enable-unicode-properties"
+AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
+
+# Check that, if --enable-pcregrep-libz or --enable-pcregrep-libbz2 is
+# specified, the relevant library is available.
+
+if test "$enable_pcregrep_libz" = "yes"; then
+ if test "$HAVE_ZLIB_H" != "1"; then
+ echo "** Cannot --enable-pcregrep-libz because zlib.h was not found"
+ exit 1
+ fi
+ if test "$HAVE_LIBZ" != "1"; then
+ echo "** Cannot --enable-pcregrep-libz because libz was not found"
+ exit 1
+ fi
+ LIBZ="-lz"
+fi
+AC_SUBST(LIBZ)
+
+if test "$enable_pcregrep_libbz2" = "yes"; then
+ if test "$HAVE_BZLIB_H" != "1"; then
+ echo "** Cannot --enable-pcregrep-libbz2 because bzlib.h was not found"
+ exit 1
+ fi
+ if test "$HAVE_LIBBZ2" != "1"; then
+ echo "** Cannot --enable-pcregrep-libbz2 because libbz2 was not found"
+ exit 1
+ fi
+ LIBBZ2="-lbz2"
+fi
+AC_SUBST(LIBBZ2)
+
+# Similarly for --enable-pcretest-readline
+
+if test "$enable_pcretest_libedit" = "yes"; then
+ if test "$enable_pcretest_libreadline" = "yes"; then
+ echo "** Cannot use both --enable-pcretest-libedit and --enable-pcretest-readline"
+ exit 1
+ fi
+ if test "$HAVE_EDITLINE_READLINE_H" != "1" -a \
+ "$HAVE_READLINE_READLINE_H" != "1"; then
+ echo "** Cannot --enable-pcretest-libedit because neither editline/readline.h"
+ echo "** nor readline/readline.h was found."
+ exit 1
+ fi
+ if test -z "$LIBEDIT"; then
+ echo "** Cannot --enable-pcretest-libedit because libedit library was not found."
+ exit 1
+ fi
+fi
+
+if test "$enable_pcretest_libreadline" = "yes"; then
+ if test "$HAVE_READLINE_H" != "1"; then
+ echo "** Cannot --enable-pcretest-readline because readline/readline.h was not found."
+ exit 1
+ fi
+ if test "$HAVE_HISTORY_H" != "1"; then
+ echo "** Cannot --enable-pcretest-readline because readline/history.h was not found."
+ exit 1
+ fi
+ if test -z "$LIBREADLINE"; then
+ echo "** Cannot --enable-pcretest-readline because readline library was not found."
+ exit 1
+ fi
+fi
+
+# Handle valgrind support
+
+if test "$enable_valgrind" = "yes"; then
+ m4_ifdef([PKG_CHECK_MODULES],
+ [PKG_CHECK_MODULES([VALGRIND],[valgrind])],
+ [AC_MSG_ERROR([pkg-config not supported])])
+fi
+
+# Handle code coverage reporting support
+if test "$enable_coverage" = "yes"; then
+ if test "x$GCC" != "xyes"; then
+ AC_MSG_ERROR([Code coverage reports can only be generated when using GCC])
+ fi
+
+ # ccache is incompatible with gcov
+ AC_PATH_PROG([SHTOOL],[shtool],[false])
+ case `$SHTOOL path $CC` in
+ *ccache*) cc_ccache=yes;;
+ *) cc_ccache=no;;
+ esac
+
+ if test "$cc_ccache" = "yes"; then
+ if test -z "$CCACHE_DISABLE" -o "$CCACHE_DISABLE" != "1"; then
+ AC_MSG_ERROR([must export CCACHE_DISABLE=1 to disable ccache for code coverage])
+ fi
+ fi
+
+ AC_ARG_VAR([LCOV],[the ltp lcov program])
+ AC_PATH_PROG([LCOV],[lcov],[false])
+ if test "x$LCOV" = "xfalse"; then
+ AC_MSG_ERROR([lcov not found])
+ fi
+
+ AC_ARG_VAR([GENHTML],[the ltp genhtml program])
+ AC_PATH_PROG([GENHTML],[genhtml],[false])
+ if test "x$GENHTML" = "xfalse"; then
+ AC_MSG_ERROR([genhtml not found])
+ fi
+
+ # Set flags needed for gcov
+ GCOV_CFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
+ GCOV_CXXFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
+ GCOV_LIBS="-lgcov"
+ AC_SUBST([GCOV_CFLAGS])
+ AC_SUBST([GCOV_CXXFLAGS])
+ AC_SUBST([GCOV_LIBS])
+fi # enable_coverage
+
+AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"])
+
+# Produce these files, in addition to config.h.
+AC_CONFIG_FILES(
+ Makefile
+ libpcre.pc
+ libpcre16.pc
+ libpcre32.pc
+ libpcreposix.pc
+ libpcrecpp.pc
+ pcre-config
+ pcre.h
+ pcre_stringpiece.h
+ pcrecpparg.h
+)
+
+# Make the generated script files executable.
+AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre-config])
+
+# Make sure that pcre_chartables.c is removed in case the method for
+# creating it was changed by reconfiguration.
+AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre_chartables.c])
+
+AC_OUTPUT
+
+# Print out a nice little message after configure is run displaying the
+# chosen options.
+
+ebcdic_nl_code=n/a
+if test "$enable_ebcdic_nl25" = "yes"; then
+ ebcdic_nl_code=0x25
+elif test "$enable_ebcdic" = "yes"; then
+ ebcdic_nl_code=0x15
+fi
+
+cat <<EOF
+
+$PACKAGE-$VERSION configuration summary:
+
+ Install prefix .................. : ${prefix}
+ C preprocessor .................. : ${CPP}
+ C compiler ...................... : ${CC}
+ C++ preprocessor ................ : ${CXXCPP}
+ C++ compiler .................... : ${CXX}
+ Linker .......................... : ${LD}
+ C preprocessor flags ............ : ${CPPFLAGS}
+ C compiler flags ................ : ${CFLAGS} ${VISIBILITY_CFLAGS}
+ C++ compiler flags .............. : ${CXXFLAGS} ${VISIBILITY_CXXFLAGS}
+ Linker flags .................... : ${LDFLAGS}
+ Extra libraries ................. : ${LIBS}
+
+ Build 8 bit pcre library ........ : ${enable_pcre8}
+ Build 16 bit pcre library ....... : ${enable_pcre16}
+ Build 32 bit pcre library ....... : ${enable_pcre32}
+ Build C++ library ............... : ${enable_cpp}
+ Enable JIT compiling support .... : ${enable_jit}
+ Enable UTF-8/16/32 support ...... : ${enable_utf}
+ Unicode properties .............. : ${enable_unicode_properties}
+ Newline char/sequence ........... : ${enable_newline}
+ \R matches only ANYCRLF ......... : ${enable_bsr_anycrlf}
+ EBCDIC coding ................... : ${enable_ebcdic}
+ EBCDIC code for NL .............. : ${ebcdic_nl_code}
+ Rebuild char tables ............. : ${enable_rebuild_chartables}
+ Use stack recursion ............. : ${enable_stack_for_recursion}
+ POSIX mem threshold ............. : ${with_posix_malloc_threshold}
+ Internal link size .............. : ${with_link_size}
+ Nested parentheses limit ........ : ${with_parens_nest_limit}
+ Match limit ..................... : ${with_match_limit}
+ Match limit recursion ........... : ${with_match_limit_recursion}
+ Build shared libs ............... : ${enable_shared}
+ Build static libs ............... : ${enable_static}
+ Use JIT in pcregrep ............. : ${enable_pcregrep_jit}
+ Buffer size for pcregrep ........ : ${with_pcregrep_bufsize}
+ Link pcregrep with libz ......... : ${enable_pcregrep_libz}
+ Link pcregrep with libbz2 ....... : ${enable_pcregrep_libbz2}
+ Link pcretest with libedit ...... : ${enable_pcretest_libedit}
+ Link pcretest with libreadline .. : ${enable_pcretest_libreadline}
+ Valgrind support ................ : ${enable_valgrind}
+ Code coverage ................... : ${enable_coverage}
+
+EOF
+
+dnl end configure.ac
diff --git a/deps/pcre/pcre.h b/deps/pcre/pcre.h.in
index 15592b9e5..d4d789269 100644
--- a/deps/pcre/pcre.h
+++ b/deps/pcre/pcre.h.in
@@ -41,12 +41,48 @@ POSSIBILITY OF SUCH DAMAGE.
/* The current PCRE version information. */
-#define PCRE_MAJOR 8
-#define PCRE_MINOR 42
-#define PCRE_PRERELEASE
-#define PCRE_DATE 2018-03-20
+#define PCRE_MAJOR @PCRE_MAJOR@
+#define PCRE_MINOR @PCRE_MINOR@
+#define PCRE_PRERELEASE @PCRE_PRERELEASE@
+#define PCRE_DATE @PCRE_DATE@
+
+/* When an application links to a PCRE DLL in Windows, the symbols that are
+imported have to be identified as such. When building PCRE, the appropriate
+export setting is defined in pcre_internal.h, which includes this file. So we
+don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
+
+#if defined(_WIN32) && !defined(PCRE_STATIC)
+# ifndef PCRE_EXP_DECL
+# define PCRE_EXP_DECL extern __declspec(dllimport)
+# endif
+# ifdef __cplusplus
+# ifndef PCRECPP_EXP_DECL
+# define PCRECPP_EXP_DECL extern __declspec(dllimport)
+# endif
+# ifndef PCRECPP_EXP_DEFN
+# define PCRECPP_EXP_DEFN __declspec(dllimport)
+# endif
+# endif
+#endif
+
+/* By default, we use the standard "extern" declarations. */
+
+#ifndef PCRE_EXP_DECL
+# ifdef __cplusplus
+# define PCRE_EXP_DECL extern "C"
+# else
+# define PCRE_EXP_DECL extern
+# endif
+#endif
-#define PCRE_EXP_DECL extern
+#ifdef __cplusplus
+# ifndef PCRECPP_EXP_DECL
+# define PCRECPP_EXP_DECL extern
+# endif
+# ifndef PCRECPP_EXP_DEFN
+# define PCRECPP_EXP_DEFN
+# endif
+#endif
/* Have to include stdlib.h in order to ensure that size_t is defined;
it is needed here for malloc. */
diff --git a/deps/pcre/pcre_chartables.c b/deps/pcre/pcre_chartables.c.dist
index 1e20ec29d..1e20ec29d 100644
--- a/deps/pcre/pcre_chartables.c
+++ b/deps/pcre/pcre_chartables.c.dist
diff --git a/deps/pcre/pcre_compile.c b/deps/pcre/pcre_compile.c
index 02de494b1..3be0fbfb1 100644
--- a/deps/pcre/pcre_compile.c
+++ b/deps/pcre/pcre_compile.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2016 University of Cambridge
+ Copyright (c) 1997-2020 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,7 @@ COMPILE_PCREx macro will already be appropriately set. */
/* Macro for setting individual bits in class bitmaps. */
-#define SETBIT(a,b) a[(b)/8] |= (1 << ((b)&7))
+#define SETBIT(a,b) a[(b)/8] |= (1U << ((b)&7))
/* Maximum length value to check against when making sure that the integer that
holds the compiled pattern length does not overflow. We make it a bit less than
@@ -129,8 +129,8 @@ overrun before it actually does run off the end of the data block. */
/* Private flags added to firstchar and reqchar. */
-#define REQ_CASELESS (1 << 0) /* Indicates caselessness */
-#define REQ_VARY (1 << 1) /* Reqchar followed non-literal item */
+#define REQ_CASELESS (1U << 0) /* Indicates caselessness */
+#define REQ_VARY (1U << 1) /* Reqchar followed non-literal item */
/* Negative values for the firstchar and reqchar flags */
#define REQ_UNSET (-2)
#define REQ_NONE (-1)
@@ -2925,7 +2925,7 @@ pcre_uint32 chr;
pcre_uint32 *clist_dest;
const pcre_uint32 *clist_src;
#else
-((void)utf); /* Suppress "unused parameter" compiler warning */
+utf = utf; /* Suppress "unused parameter" compiler warning */
#endif
list[0] = c;
@@ -3299,7 +3299,7 @@ for(;;)
if ((*xclass_flags & XCL_MAP) == 0)
{
/* No bits are set for characters < 256. */
- if (list[1] == 0) return TRUE;
+ if (list[1] == 0) return (*xclass_flags & XCL_NOT) == 0;
/* Might be an empty repeat. */
continue;
}
@@ -3611,7 +3611,7 @@ for(;;)
if (chr > 255) break;
class_bitset = (pcre_uint8 *)
((list_ptr == list ? code : base_end) - list_ptr[2]);
- if ((class_bitset[chr >> 3] & (1 << (chr & 7))) != 0) return FALSE;
+ if ((class_bitset[chr >> 3] & (1U << (chr & 7))) != 0) return FALSE;
break;
#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
@@ -4206,11 +4206,6 @@ pcre_uint32 c;
pcre_uint32 classbits_end = (end <= 0xff ? end : 0xff);
int n8 = 0;
-((void)uchardptr);
-((void)propposstab);
-((void)catposstab);
-((void)posspropstab);
-
/* If caseless matching is required, scan the range and process alternate
cases. In Unicode, there are 8-bit characters that have alternate cases that
are greater than 255 and vice-versa. Sometimes we can just extend the original
@@ -7135,17 +7130,19 @@ for (;; ptr++)
int n = 0;
ptr++;
while(IS_DIGIT(*ptr))
+ {
n = n * 10 + *ptr++ - CHAR_0;
+ if (n > 255)
+ {
+ *errorcodeptr = ERR38;
+ goto FAILED;
+ }
+ }
if (*ptr != CHAR_RIGHT_PARENTHESIS)
{
*errorcodeptr = ERR39;
goto FAILED;
}
- if (n > 255)
- {
- *errorcodeptr = ERR38;
- goto FAILED;
- }
*code++ = n;
PUT(code, 0, (int)(ptr - cd->start_pattern + 1)); /* Pattern offset */
PUT(code, LINK_SIZE, 0); /* Default length */
@@ -7461,7 +7458,7 @@ for (;; ptr++)
{
open_capitem *oc;
recno = GET2(slot, 0);
- cd->backref_map |= (recno < 32)? (1 << recno) : 1;
+ cd->backref_map |= (recno < 32)? (1U << recno) : 1;
if (recno > cd->top_backref) cd->top_backref = recno;
/* Check to see if this back reference is recursive, that it, it
@@ -7647,6 +7644,8 @@ for (;; ptr++)
/* Can't determine a first byte now */
if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
+ zerofirstchar = firstchar;
+ zerofirstcharflags = firstcharflags;
continue;
@@ -8070,7 +8069,7 @@ for (;; ptr++)
item_hwm_offset = cd->hwm - cd->start_workspace;
*code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF;
PUT2INC(code, 0, recno);
- cd->backref_map |= (recno < 32)? (1 << recno) : 1;
+ cd->backref_map |= (recno < 32)? (1U << recno) : 1;
if (recno > cd->top_backref) cd->top_backref = recno;
/* Check to see if this back reference is recursive, that it, it
@@ -8683,14 +8682,22 @@ do {
op == OP_SCBRA || op == OP_SCBRAPOS)
{
int n = GET2(scode, 1+LINK_SIZE);
- int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
+ int new_map = bracket_map | ((n < 32)? (1U << n) : 1);
if (!is_anchored(scode, new_map, cd, atomcount)) return FALSE;
}
- /* Positive forward assertions and conditions */
+ /* Positive forward assertion */
+
+ else if (op == OP_ASSERT)
+ {
+ if (!is_anchored(scode, bracket_map, cd, atomcount)) return FALSE;
+ }
+
+ /* Condition; not anchored if no second branch */
- else if (op == OP_ASSERT || op == OP_COND)
+ else if (op == OP_COND)
{
+ if (scode[GET(scode,1)] != OP_ALT) return FALSE;
if (!is_anchored(scode, bracket_map, cd, atomcount)) return FALSE;
}
@@ -8803,7 +8810,7 @@ do {
op == OP_SCBRA || op == OP_SCBRAPOS)
{
int n = GET2(scode, 1+LINK_SIZE);
- int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
+ int new_map = bracket_map | ((n < 32)? (1U << n) : 1);
if (!is_startline(scode, new_map, cd, atomcount, inassert)) return FALSE;
}
diff --git a/deps/pcre/pcre_internal.h b/deps/pcre/pcre_internal.h
index 09b09b828..97ff55d03 100644
--- a/deps/pcre/pcre_internal.h
+++ b/deps/pcre/pcre_internal.h
@@ -146,9 +146,29 @@ exported symbols. That's why, in the non-Windows case, we set PCRE_EXP_DEFN and
PCRE_EXP_DATA_DEFN only if they are not already set. */
#ifndef PCRE_EXP_DECL
-# define PCRE_EXP_DECL extern
-# define PCRE_EXP_DEFN
-# define PCRE_EXP_DATA_DEFN
+# ifdef _WIN32
+# ifndef PCRE_STATIC
+# define PCRE_EXP_DECL extern __declspec(dllexport)
+# define PCRE_EXP_DEFN __declspec(dllexport)
+# define PCRE_EXP_DATA_DEFN __declspec(dllexport)
+# else
+# define PCRE_EXP_DECL extern
+# define PCRE_EXP_DEFN
+# define PCRE_EXP_DATA_DEFN
+# endif
+# else
+# ifdef __cplusplus
+# define PCRE_EXP_DECL extern "C"
+# else
+# define PCRE_EXP_DECL extern
+# endif
+# ifndef PCRE_EXP_DEFN
+# define PCRE_EXP_DEFN PCRE_EXP_DECL
+# endif
+# ifndef PCRE_EXP_DATA_DEFN
+# define PCRE_EXP_DATA_DEFN
+# endif
+# endif
#endif
/* When compiling with the MSVC compiler, it is sometimes necessary to include
diff --git a/deps/pcre/pcre_jit_compile.c b/deps/pcre/pcre_jit_compile.c
index 2bad74b02..4dcf8fc21 100644
--- a/deps/pcre/pcre_jit_compile.c
+++ b/deps/pcre/pcre_jit_compile.c
@@ -3938,10 +3938,10 @@ static sljit_s32 character_to_int32(pcre_uchar chr)
sljit_s32 value = (sljit_s32)chr;
#if defined COMPILE_PCRE8
#define SSE2_COMPARE_TYPE_INDEX 0
-return (value << 24) | (value << 16) | (value << 8) | value;
+return ((unsigned int)value << 24) | ((unsigned int)value << 16) | ((unsigned int)value << 8) | (unsigned int)value;
#elif defined COMPILE_PCRE16
#define SSE2_COMPARE_TYPE_INDEX 1
-return (value << 16) | value;
+return ((unsigned int)value << 16) | value;
#elif defined COMPILE_PCRE32
#define SSE2_COMPARE_TYPE_INDEX 2
return value;
@@ -8507,7 +8507,7 @@ if (opcode == OP_ONCE)
/* We temporarily encode the needs_control_head in the lowest bit.
Note: on the target architectures of SLJIT the ((x << 1) >> 1) returns
the same value for small signed numbers (including negative numbers). */
- BACKTRACK_AS(bracket_backtrack)->u.framesize = (BACKTRACK_AS(bracket_backtrack)->u.framesize << 1) | (needs_control_head ? 1 : 0);
+ BACKTRACK_AS(bracket_backtrack)->u.framesize = ((unsigned int)BACKTRACK_AS(bracket_backtrack)->u.framesize << 1) | (needs_control_head ? 1 : 0);
}
return cc + repeat_length;
}
@@ -9002,7 +9002,7 @@ if (exact > 1)
#ifdef SUPPORT_UTF
&& !common->utf
#endif
- )
+ && type != OP_ANYNL && type != OP_EXTUNI)
{
OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(exact));
add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_GREATER, TMP1, 0, STR_END, 0));
diff --git a/deps/pcre/pcre_printint.c b/deps/pcre/pcre_printint.c
deleted file mode 100644
index 60dcb55ef..000000000
--- a/deps/pcre/pcre_printint.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2012 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains a PCRE private debugging function for printing out the
-internal form of a compiled regular expression, along with some supporting
-local functions. This source file is used in two places:
-
-(1) It is #included by pcre_compile.c when it is compiled in debugging mode
-(PCRE_DEBUG defined in pcre_internal.h). It is not included in production
-compiles. In this case PCRE_INCLUDED is defined.
-
-(2) It is also compiled separately and linked with pcretest.c, which can be
-asked to print out a compiled regex for debugging purposes. */
-
-#ifndef PCRE_INCLUDED
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-/* For pcretest program. */
-#define PRIV(name) name
-
-/* We have to include pcre_internal.h because we need the internal info for
-displaying the results of pcre_study() and we also need to know about the
-internal macros, structures, and other internal data values; pcretest has
-"inside information" compared to a program that strictly follows the PCRE API.
-
-Although pcre_internal.h does itself include pcre.h, we explicitly include it
-here before pcre_internal.h so that the PCRE_EXP_xxx macros get set
-appropriately for an application, not for building PCRE. */
-
-#include "pcre.h"
-#include "pcre_internal.h"
-
-/* These are the funtions that are contained within. It doesn't seem worth
-having a separate .h file just for this. */
-
-#endif /* PCRE_INCLUDED */
-
-#ifdef PCRE_INCLUDED
-static /* Keep the following function as private. */
-#endif
-
-#if defined COMPILE_PCRE8
-void pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths);
-#elif defined COMPILE_PCRE16
-void pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths);
-#elif defined COMPILE_PCRE32
-void pcre32_printint(pcre *external_re, FILE *f, BOOL print_lengths);
-#endif
-
-/* Macro that decides whether a character should be output as a literal or in
-hexadecimal. We don't use isprint() because that can vary from system to system
-(even without the use of locales) and we want the output always to be the same,
-for testing purposes. */
-
-#ifdef EBCDIC
-#define PRINTABLE(c) ((c) >= 64 && (c) < 255)
-#else
-#define PRINTABLE(c) ((c) >= 32 && (c) < 127)
-#endif
-
-/* The table of operator names. */
-
-static const char *priv_OP_names[] = { OP_NAME_LIST };
-
-/* This table of operator lengths is not actually used by the working code,
-but its size is needed for a check that ensures it is the correct size for the
-number of opcodes (thus catching update omissions). */
-
-static const pcre_uint8 priv_OP_lengths[] = { OP_LENGTHS };
-
-
-
-/*************************************************
-* Print single- or multi-byte character *
-*************************************************/
-
-static unsigned int
-print_char(FILE *f, pcre_uchar *ptr, BOOL utf)
-{
-pcre_uint32 c = *ptr;
-
-#ifndef SUPPORT_UTF
-
-(void)utf; /* Avoid compiler warning */
-if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
-else if (c <= 0x80) fprintf(f, "\\x%02x", c);
-else fprintf(f, "\\x{%x}", c);
-return 0;
-
-#else
-
-#if defined COMPILE_PCRE8
-
-if (!utf || (c & 0xc0) != 0xc0)
- {
- if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
- else if (c < 0x80) fprintf(f, "\\x%02x", c);
- else fprintf(f, "\\x{%02x}", c);
- return 0;
- }
-else
- {
- int i;
- int a = PRIV(utf8_table4)[c & 0x3f]; /* Number of additional bytes */
- int s = 6*a;
- c = (c & PRIV(utf8_table3)[a]) << s;
- for (i = 1; i <= a; i++)
- {
- /* This is a check for malformed UTF-8; it should only occur if the sanity
- check has been turned off. Rather than swallow random bytes, just stop if
- we hit a bad one. Print it with \X instead of \x as an indication. */
-
- if ((ptr[i] & 0xc0) != 0x80)
- {
- fprintf(f, "\\X{%x}", c);
- return i - 1;
- }
-
- /* The byte is OK */
-
- s -= 6;
- c |= (ptr[i] & 0x3f) << s;
- }
- fprintf(f, "\\x{%x}", c);
- return a;
- }
-
-#elif defined COMPILE_PCRE16
-
-if (!utf || (c & 0xfc00) != 0xd800)
- {
- if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
- else if (c <= 0x80) fprintf(f, "\\x%02x", c);
- else fprintf(f, "\\x{%02x}", c);
- return 0;
- }
-else
- {
- /* This is a check for malformed UTF-16; it should only occur if the sanity
- check has been turned off. Rather than swallow a low surrogate, just stop if
- we hit a bad one. Print it with \X instead of \x as an indication. */
-
- if ((ptr[1] & 0xfc00) != 0xdc00)
- {
- fprintf(f, "\\X{%x}", c);
- return 0;
- }
-
- c = (((c & 0x3ff) << 10) | (ptr[1] & 0x3ff)) + 0x10000;
- fprintf(f, "\\x{%x}", c);
- return 1;
- }
-
-#elif defined COMPILE_PCRE32
-
-if (!utf || (c & 0xfffff800u) != 0xd800u)
- {
- if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
- else if (c <= 0x80) fprintf(f, "\\x%02x", c);
- else fprintf(f, "\\x{%x}", c);
- return 0;
- }
-else
- {
- /* This is a check for malformed UTF-32; it should only occur if the sanity
- check has been turned off. Rather than swallow a surrogate, just stop if
- we hit one. Print it with \X instead of \x as an indication. */
- fprintf(f, "\\X{%x}", c);
- return 0;
- }
-
-#endif /* COMPILE_PCRE[8|16|32] */
-
-#endif /* SUPPORT_UTF */
-}
-
-/*************************************************
-* Print uchar string (regardless of utf) *
-*************************************************/
-
-static void
-print_puchar(FILE *f, PCRE_PUCHAR ptr)
-{
-while (*ptr != '\0')
- {
- register pcre_uint32 c = *ptr++;
- if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x{%x}", c);
- }
-}
-
-/*************************************************
-* Find Unicode property name *
-*************************************************/
-
-static const char *
-get_ucpname(unsigned int ptype, unsigned int pvalue)
-{
-#ifdef SUPPORT_UCP
-int i;
-for (i = PRIV(utt_size) - 1; i >= 0; i--)
- {
- if (ptype == PRIV(utt)[i].type && pvalue == PRIV(utt)[i].value) break;
- }
-return (i >= 0)? PRIV(utt_names) + PRIV(utt)[i].name_offset : "??";
-#else
-/* It gets harder and harder to shut off unwanted compiler warnings. */
-ptype = ptype * pvalue;
-return (ptype == pvalue)? "??" : "??";
-#endif
-}
-
-
-/*************************************************
-* Print Unicode property value *
-*************************************************/
-
-/* "Normal" properties can be printed from tables. The PT_CLIST property is a
-pseudo-property that contains a pointer to a list of case-equivalent
-characters. This is used only when UCP support is available and UTF mode is
-selected. It should never occur otherwise, but just in case it does, have
-something ready to print. */
-
-static void
-print_prop(FILE *f, pcre_uchar *code, const char *before, const char *after)
-{
-if (code[1] != PT_CLIST)
- {
- fprintf(f, "%s%s %s%s", before, priv_OP_names[*code], get_ucpname(code[1],
- code[2]), after);
- }
-else
- {
- const char *not = (*code == OP_PROP)? "" : "not ";
-#ifndef SUPPORT_UCP
- fprintf(f, "%s%sclist %d%s", before, not, code[2], after);
-#else
- const pcre_uint32 *p = PRIV(ucd_caseless_sets) + code[2];
- fprintf (f, "%s%sclist", before, not);
- while (*p < NOTACHAR) fprintf(f, " %04x", *p++);
- fprintf(f, "%s", after);
-#endif
- }
-}
-
-
-
-
-/*************************************************
-* Print compiled regex *
-*************************************************/
-
-/* Make this function work for a regex with integers either byte order.
-However, we assume that what we are passed is a compiled regex. The
-print_lengths flag controls whether offsets and lengths of items are printed.
-They can be turned off from pcretest so that automatic tests on bytecode can be
-written that do not depend on the value of LINK_SIZE. */
-
-#ifdef PCRE_INCLUDED
-static /* Keep the following function as private. */
-#endif
-#if defined COMPILE_PCRE8
-void
-pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
-#elif defined COMPILE_PCRE16
-void
-pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths)
-#elif defined COMPILE_PCRE32
-void
-pcre32_printint(pcre *external_re, FILE *f, BOOL print_lengths)
-#endif
-{
-REAL_PCRE *re = (REAL_PCRE *)external_re;
-pcre_uchar *codestart, *code;
-BOOL utf;
-
-unsigned int options = re->options;
-int offset = re->name_table_offset;
-int count = re->name_count;
-int size = re->name_entry_size;
-
-if (re->magic_number != MAGIC_NUMBER)
- {
- offset = ((offset << 8) & 0xff00) | ((offset >> 8) & 0xff);
- count = ((count << 8) & 0xff00) | ((count >> 8) & 0xff);
- size = ((size << 8) & 0xff00) | ((size >> 8) & 0xff);
- options = ((options << 24) & 0xff000000) |
- ((options << 8) & 0x00ff0000) |
- ((options >> 8) & 0x0000ff00) |
- ((options >> 24) & 0x000000ff);
- }
-
-code = codestart = (pcre_uchar *)re + offset + count * size;
-/* PCRE_UTF(16|32) have the same value as PCRE_UTF8. */
-utf = (options & PCRE_UTF8) != 0;
-
-for(;;)
- {
- pcre_uchar *ccode;
- const char *flag = " ";
- pcre_uint32 c;
- unsigned int extra = 0;
-
- if (print_lengths)
- fprintf(f, "%3d ", (int)(code - codestart));
- else
- fprintf(f, " ");
-
- switch(*code)
- {
-/* ========================================================================== */
- /* These cases are never obeyed. This is a fudge that causes a compile-
- time error if the vectors OP_names or OP_lengths, which are indexed
- by opcode, are not the correct length. It seems to be the only way to do
- such a check at compile time, as the sizeof() operator does not work in
- the C preprocessor. */
-
- case OP_TABLE_LENGTH:
- case OP_TABLE_LENGTH +
- ((sizeof(priv_OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) &&
- (sizeof(priv_OP_lengths) == OP_TABLE_LENGTH)):
- break;
-/* ========================================================================== */
-
- case OP_END:
- fprintf(f, " %s\n", priv_OP_names[*code]);
- fprintf(f, "------------------------------------------------------------------\n");
- return;
-
- case OP_CHAR:
- fprintf(f, " ");
- do
- {
- code++;
- code += 1 + print_char(f, code, utf);
- }
- while (*code == OP_CHAR);
- fprintf(f, "\n");
- continue;
-
- case OP_CHARI:
- fprintf(f, " /i ");
- do
- {
- code++;
- code += 1 + print_char(f, code, utf);
- }
- while (*code == OP_CHARI);
- fprintf(f, "\n");
- continue;
-
- case OP_CBRA:
- case OP_CBRAPOS:
- case OP_SCBRA:
- case OP_SCBRAPOS:
- if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
- else fprintf(f, " ");
- fprintf(f, "%s %d", priv_OP_names[*code], GET2(code, 1+LINK_SIZE));
- break;
-
- case OP_BRA:
- case OP_BRAPOS:
- case OP_SBRA:
- case OP_SBRAPOS:
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_KETRPOS:
- case OP_ALT:
- case OP_KET:
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_COND:
- case OP_SCOND:
- case OP_REVERSE:
- if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
- else fprintf(f, " ");
- fprintf(f, "%s", priv_OP_names[*code]);
- break;
-
- case OP_CLOSE:
- fprintf(f, " %s %d", priv_OP_names[*code], GET2(code, 1));
- break;
-
- case OP_CREF:
- fprintf(f, "%3d %s", GET2(code,1), priv_OP_names[*code]);
- break;
-
- case OP_DNCREF:
- {
- pcre_uchar *entry = (pcre_uchar *)re + offset + (GET2(code, 1) * size) +
- IMM2_SIZE;
- fprintf(f, " %s Cond ref <", flag);
- print_puchar(f, entry);
- fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE));
- }
- break;
-
- case OP_RREF:
- c = GET2(code, 1);
- if (c == RREF_ANY)
- fprintf(f, " Cond recurse any");
- else
- fprintf(f, " Cond recurse %d", c);
- break;
-
- case OP_DNRREF:
- {
- pcre_uchar *entry = (pcre_uchar *)re + offset + (GET2(code, 1) * size) +
- IMM2_SIZE;
- fprintf(f, " %s Cond recurse <", flag);
- print_puchar(f, entry);
- fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE));
- }
- break;
-
- case OP_DEF:
- fprintf(f, " Cond def");
- break;
-
- case OP_STARI:
- case OP_MINSTARI:
- case OP_POSSTARI:
- case OP_PLUSI:
- case OP_MINPLUSI:
- case OP_POSPLUSI:
- case OP_QUERYI:
- case OP_MINQUERYI:
- case OP_POSQUERYI:
- flag = "/i";
- /* Fall through */
- case OP_STAR:
- case OP_MINSTAR:
- case OP_POSSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_POSPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_POSQUERY:
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEPOSPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEPOSQUERY:
- fprintf(f, " %s ", flag);
- if (*code >= OP_TYPESTAR)
- {
- if (code[1] == OP_PROP || code[1] == OP_NOTPROP)
- {
- print_prop(f, code + 1, "", " ");
- extra = 2;
- }
- else fprintf(f, "%s", priv_OP_names[code[1]]);
- }
- else extra = print_char(f, code+1, utf);
- fprintf(f, "%s", priv_OP_names[*code]);
- break;
-
- case OP_EXACTI:
- case OP_UPTOI:
- case OP_MINUPTOI:
- case OP_POSUPTOI:
- flag = "/i";
- /* Fall through */
- case OP_EXACT:
- case OP_UPTO:
- case OP_MINUPTO:
- case OP_POSUPTO:
- fprintf(f, " %s ", flag);
- extra = print_char(f, code + 1 + IMM2_SIZE, utf);
- fprintf(f, "{");
- if (*code != OP_EXACT && *code != OP_EXACTI) fprintf(f, "0,");
- fprintf(f, "%d}", GET2(code,1));
- if (*code == OP_MINUPTO || *code == OP_MINUPTOI) fprintf(f, "?");
- else if (*code == OP_POSUPTO || *code == OP_POSUPTOI) fprintf(f, "+");
- break;
-
- case OP_TYPEEXACT:
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEPOSUPTO:
- if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
- {
- print_prop(f, code + IMM2_SIZE + 1, " ", " ");
- extra = 2;
- }
- else fprintf(f, " %s", priv_OP_names[code[1 + IMM2_SIZE]]);
- fprintf(f, "{");
- if (*code != OP_TYPEEXACT) fprintf(f, "0,");
- fprintf(f, "%d}", GET2(code,1));
- if (*code == OP_TYPEMINUPTO) fprintf(f, "?");
- else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+");
- break;
-
- case OP_NOTI:
- flag = "/i";
- /* Fall through */
- case OP_NOT:
- fprintf(f, " %s [^", flag);
- extra = print_char(f, code + 1, utf);
- fprintf(f, "]");
- break;
-
- case OP_NOTSTARI:
- case OP_NOTMINSTARI:
- case OP_NOTPOSSTARI:
- case OP_NOTPLUSI:
- case OP_NOTMINPLUSI:
- case OP_NOTPOSPLUSI:
- case OP_NOTQUERYI:
- case OP_NOTMINQUERYI:
- case OP_NOTPOSQUERYI:
- flag = "/i";
- /* Fall through */
-
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPOSSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTPOSPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- case OP_NOTPOSQUERY:
- fprintf(f, " %s [^", flag);
- extra = print_char(f, code + 1, utf);
- fprintf(f, "]%s", priv_OP_names[*code]);
- break;
-
- case OP_NOTEXACTI:
- case OP_NOTUPTOI:
- case OP_NOTMINUPTOI:
- case OP_NOTPOSUPTOI:
- flag = "/i";
- /* Fall through */
-
- case OP_NOTEXACT:
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- case OP_NOTPOSUPTO:
- fprintf(f, " %s [^", flag);
- extra = print_char(f, code + 1 + IMM2_SIZE, utf);
- fprintf(f, "]{");
- if (*code != OP_NOTEXACT && *code != OP_NOTEXACTI) fprintf(f, "0,");
- fprintf(f, "%d}", GET2(code,1));
- if (*code == OP_NOTMINUPTO || *code == OP_NOTMINUPTOI) fprintf(f, "?");
- else
- if (*code == OP_NOTPOSUPTO || *code == OP_NOTPOSUPTOI) fprintf(f, "+");
- break;
-
- case OP_RECURSE:
- if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
- else fprintf(f, " ");
- fprintf(f, "%s", priv_OP_names[*code]);
- break;
-
- case OP_REFI:
- flag = "/i";
- /* Fall through */
- case OP_REF:
- fprintf(f, " %s \\%d", flag, GET2(code,1));
- ccode = code + priv_OP_lengths[*code];
- goto CLASS_REF_REPEAT;
-
- case OP_DNREFI:
- flag = "/i";
- /* Fall through */
- case OP_DNREF:
- {
- pcre_uchar *entry = (pcre_uchar *)re + offset + (GET2(code, 1) * size) +
- IMM2_SIZE;
- fprintf(f, " %s \\k<", flag);
- print_puchar(f, entry);
- fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE));
- }
- ccode = code + priv_OP_lengths[*code];
- goto CLASS_REF_REPEAT;
-
- case OP_CALLOUT:
- fprintf(f, " %s %d %d %d", priv_OP_names[*code], code[1], GET(code,2),
- GET(code, 2 + LINK_SIZE));
- break;
-
- case OP_PROP:
- case OP_NOTPROP:
- print_prop(f, code, " ", "");
- break;
-
- /* OP_XCLASS cannot occur in 8-bit, non-UTF mode. However, there's no harm
- in having this code always here, and it makes it less messy without all
- those #ifdefs. */
-
- case OP_CLASS:
- case OP_NCLASS:
- case OP_XCLASS:
- {
- int i;
- unsigned int min, max;
- BOOL printmap;
- BOOL invertmap = FALSE;
- pcre_uint8 *map;
- pcre_uint8 inverted_map[32];
-
- fprintf(f, " [");
-
- if (*code == OP_XCLASS)
- {
- extra = GET(code, 1);
- ccode = code + LINK_SIZE + 1;
- printmap = (*ccode & XCL_MAP) != 0;
- if ((*ccode & XCL_NOT) != 0)
- {
- invertmap = (*ccode & XCL_HASPROP) == 0;
- fprintf(f, "^");
- }
- ccode++;
- }
- else
- {
- printmap = TRUE;
- ccode = code + 1;
- }
-
- /* Print a bit map */
-
- if (printmap)
- {
- map = (pcre_uint8 *)ccode;
- if (invertmap)
- {
- for (i = 0; i < 32; i++) inverted_map[i] = ~map[i];
- map = inverted_map;
- }
-
- for (i = 0; i < 256; i++)
- {
- if ((map[i/8] & (1 << (i&7))) != 0)
- {
- int j;
- for (j = i+1; j < 256; j++)
- if ((map[j/8] & (1 << (j&7))) == 0) break;
- if (i == '-' || i == ']') fprintf(f, "\\");
- if (PRINTABLE(i)) fprintf(f, "%c", i);
- else fprintf(f, "\\x%02x", i);
- if (--j > i)
- {
- if (j != i + 1) fprintf(f, "-");
- if (j == '-' || j == ']') fprintf(f, "\\");
- if (PRINTABLE(j)) fprintf(f, "%c", j);
- else fprintf(f, "\\x%02x", j);
- }
- i = j;
- }
- }
- ccode += 32 / sizeof(pcre_uchar);
- }
-
- /* For an XCLASS there is always some additional data */
-
- if (*code == OP_XCLASS)
- {
- pcre_uchar ch;
- while ((ch = *ccode++) != XCL_END)
- {
- BOOL not = FALSE;
- const char *notch = "";
-
- switch(ch)
- {
- case XCL_NOTPROP:
- not = TRUE;
- notch = "^";
- /* Fall through */
-
- case XCL_PROP:
- {
- unsigned int ptype = *ccode++;
- unsigned int pvalue = *ccode++;
-
- switch(ptype)
- {
- case PT_PXGRAPH:
- fprintf(f, "[:%sgraph:]", notch);
- break;
-
- case PT_PXPRINT:
- fprintf(f, "[:%sprint:]", notch);
- break;
-
- case PT_PXPUNCT:
- fprintf(f, "[:%spunct:]", notch);
- break;
-
- default:
- fprintf(f, "\\%c{%s}", (not? 'P':'p'),
- get_ucpname(ptype, pvalue));
- break;
- }
- }
- break;
-
- default:
- ccode += 1 + print_char(f, ccode, utf);
- if (ch == XCL_RANGE)
- {
- fprintf(f, "-");
- ccode += 1 + print_char(f, ccode, utf);
- }
- break;
- }
- }
- }
-
- /* Indicate a non-UTF class which was created by negation */
-
- fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");
-
- /* Handle repeats after a class or a back reference */
-
- CLASS_REF_REPEAT:
- switch(*ccode)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRPOSSTAR:
- case OP_CRPOSPLUS:
- case OP_CRPOSQUERY:
- fprintf(f, "%s", priv_OP_names[*ccode]);
- extra += priv_OP_lengths[*ccode];
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSRANGE:
- min = GET2(ccode,1);
- max = GET2(ccode,1 + IMM2_SIZE);
- if (max == 0) fprintf(f, "{%u,}", min);
- else fprintf(f, "{%u,%u}", min, max);
- if (*ccode == OP_CRMINRANGE) fprintf(f, "?");
- else if (*ccode == OP_CRPOSRANGE) fprintf(f, "+");
- extra += priv_OP_lengths[*ccode];
- break;
-
- /* Do nothing if it's not a repeat; this code stops picky compilers
- warning about the lack of a default code path. */
-
- default:
- break;
- }
- }
- break;
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_SKIP_ARG:
- case OP_THEN_ARG:
- fprintf(f, " %s ", priv_OP_names[*code]);
- print_puchar(f, code + 2);
- extra += code[1];
- break;
-
- case OP_THEN:
- fprintf(f, " %s", priv_OP_names[*code]);
- break;
-
- case OP_CIRCM:
- case OP_DOLLM:
- flag = "/m";
- /* Fall through */
-
- /* Anything else is just an item with no data, but possibly a flag. */
-
- default:
- fprintf(f, " %s %s", flag, priv_OP_names[*code]);
- break;
- }
-
- code += priv_OP_lengths[*code] + extra;
- fprintf(f, "\n");
- }
-}
-
-/* End of pcre_printint.src */
diff --git a/deps/pcre/pcreposix.c b/deps/pcre/pcreposix.c
index 77dbddb66..3042d7635 100644
--- a/deps/pcre/pcreposix.c
+++ b/deps/pcre/pcreposix.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2018 University of Cambridge
+ Copyright (c) 1997-2020 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -46,6 +46,17 @@ functions. */
#include "config.h"
#endif
+
+/* Ensure that the PCREPOSIX_EXP_xxx macros are set appropriately for
+compiling these functions. This must come before including pcreposix.h, where
+they are set for an application (using these functions) if they have not
+previously been set. */
+
+#if defined(_WIN32) && !defined(PCRE_STATIC)
+# define PCREPOSIX_EXP_DECL extern __declspec(dllexport)
+# define PCREPOSIX_EXP_DEFN __declspec(dllexport)
+#endif
+
/* We include pcre.h before pcre_internal.h so that the PCRE library functions
are declared as "import" for Windows by defining PCRE_EXP_DECL as "import".
This is needed even though pcre_internal.h itself includes pcre.h, because it
@@ -60,110 +71,110 @@ does so after it has set PCRE_EXP_DECL to "export" if it is not already set. */
static const int eint[] = {
0, /* no error */
- PCRE_REG_EESCAPE, /* \ at end of pattern */
- PCRE_REG_EESCAPE, /* \c at end of pattern */
- PCRE_REG_EESCAPE, /* unrecognized character follows \ */
- PCRE_REG_BADBR, /* numbers out of order in {} quantifier */
+ REG_EESCAPE, /* \ at end of pattern */
+ REG_EESCAPE, /* \c at end of pattern */
+ REG_EESCAPE, /* unrecognized character follows \ */
+ REG_BADBR, /* numbers out of order in {} quantifier */
/* 5 */
- PCRE_REG_BADBR, /* number too big in {} quantifier */
- PCRE_REG_EBRACK, /* missing terminating ] for character class */
- PCRE_REG_ECTYPE, /* invalid escape sequence in character class */
- PCRE_REG_ERANGE, /* range out of order in character class */
- PCRE_REG_BADRPT, /* nothing to repeat */
+ REG_BADBR, /* number too big in {} quantifier */
+ REG_EBRACK, /* missing terminating ] for character class */
+ REG_ECTYPE, /* invalid escape sequence in character class */
+ REG_ERANGE, /* range out of order in character class */
+ REG_BADRPT, /* nothing to repeat */
/* 10 */
- PCRE_REG_BADRPT, /* operand of unlimited repeat could match the empty string */
- PCRE_REG_ASSERT, /* internal error: unexpected repeat */
- PCRE_REG_BADPAT, /* unrecognized character after (? */
- PCRE_REG_BADPAT, /* POSIX named classes are supported only within a class */
- PCRE_REG_EPAREN, /* missing ) */
+ REG_BADRPT, /* operand of unlimited repeat could match the empty string */
+ REG_ASSERT, /* internal error: unexpected repeat */
+ REG_BADPAT, /* unrecognized character after (? */
+ REG_BADPAT, /* POSIX named classes are supported only within a class */
+ REG_EPAREN, /* missing ) */
/* 15 */
- PCRE_REG_ESUBREG, /* reference to non-existent subpattern */
- PCRE_REG_INVARG, /* erroffset passed as NULL */
- PCRE_REG_INVARG, /* unknown option bit(s) set */
- PCRE_REG_EPAREN, /* missing ) after comment */
- PCRE_REG_ESIZE, /* parentheses nested too deeply */
+ REG_ESUBREG, /* reference to non-existent subpattern */
+ REG_INVARG, /* erroffset passed as NULL */
+ REG_INVARG, /* unknown option bit(s) set */
+ REG_EPAREN, /* missing ) after comment */
+ REG_ESIZE, /* parentheses nested too deeply */
/* 20 */
- PCRE_REG_ESIZE, /* regular expression too large */
- PCRE_REG_ESPACE, /* failed to get memory */
- PCRE_REG_EPAREN, /* unmatched parentheses */
- PCRE_REG_ASSERT, /* internal error: code overflow */
- PCRE_REG_BADPAT, /* unrecognized character after (?< */
+ REG_ESIZE, /* regular expression too large */
+ REG_ESPACE, /* failed to get memory */
+ REG_EPAREN, /* unmatched parentheses */
+ REG_ASSERT, /* internal error: code overflow */
+ REG_BADPAT, /* unrecognized character after (?< */
/* 25 */
- PCRE_REG_BADPAT, /* lookbehind assertion is not fixed length */
- PCRE_REG_BADPAT, /* malformed number or name after (?( */
- PCRE_REG_BADPAT, /* conditional group contains more than two branches */
- PCRE_REG_BADPAT, /* assertion expected after (?( */
- PCRE_REG_BADPAT, /* (?R or (?[+-]digits must be followed by ) */
+ REG_BADPAT, /* lookbehind assertion is not fixed length */
+ REG_BADPAT, /* malformed number or name after (?( */
+ REG_BADPAT, /* conditional group contains more than two branches */
+ REG_BADPAT, /* assertion expected after (?( */
+ REG_BADPAT, /* (?R or (?[+-]digits must be followed by ) */
/* 30 */
- PCRE_REG_ECTYPE, /* unknown POSIX class name */
- PCRE_REG_BADPAT, /* POSIX collating elements are not supported */
- PCRE_REG_INVARG, /* this version of PCRE is not compiled with PCRE_UTF8 support */
- PCRE_REG_BADPAT, /* spare error */
- PCRE_REG_BADPAT, /* character value in \x{} or \o{} is too large */
+ REG_ECTYPE, /* unknown POSIX class name */
+ REG_BADPAT, /* POSIX collating elements are not supported */
+ REG_INVARG, /* this version of PCRE is not compiled with PCRE_UTF8 support */
+ REG_BADPAT, /* spare error */
+ REG_BADPAT, /* character value in \x{} or \o{} is too large */
/* 35 */
- PCRE_REG_BADPAT, /* invalid condition (?(0) */
- PCRE_REG_BADPAT, /* \C not allowed in lookbehind assertion */
- PCRE_REG_EESCAPE, /* PCRE does not support \L, \l, \N, \U, or \u */
- PCRE_REG_BADPAT, /* number after (?C is > 255 */
- PCRE_REG_BADPAT, /* closing ) for (?C expected */
+ REG_BADPAT, /* invalid condition (?(0) */
+ REG_BADPAT, /* \C not allowed in lookbehind assertion */
+ REG_EESCAPE, /* PCRE does not support \L, \l, \N, \U, or \u */
+ REG_BADPAT, /* number after (?C is > 255 */
+ REG_BADPAT, /* closing ) for (?C expected */
/* 40 */
- PCRE_REG_BADPAT, /* recursive call could loop indefinitely */
- PCRE_REG_BADPAT, /* unrecognized character after (?P */
- PCRE_REG_BADPAT, /* syntax error in subpattern name (missing terminator) */
- PCRE_REG_BADPAT, /* two named subpatterns have the same name */
- PCRE_REG_BADPAT, /* invalid UTF-8 string */
+ REG_BADPAT, /* recursive call could loop indefinitely */
+ REG_BADPAT, /* unrecognized character after (?P */
+ REG_BADPAT, /* syntax error in subpattern name (missing terminator) */
+ REG_BADPAT, /* two named subpatterns have the same name */
+ REG_BADPAT, /* invalid UTF-8 string */
/* 45 */
- PCRE_REG_BADPAT, /* support for \P, \p, and \X has not been compiled */
- PCRE_REG_BADPAT, /* malformed \P or \p sequence */
- PCRE_REG_BADPAT, /* unknown property name after \P or \p */
- PCRE_REG_BADPAT, /* subpattern name is too long (maximum 32 characters) */
- PCRE_REG_BADPAT, /* too many named subpatterns (maximum 10,000) */
+ REG_BADPAT, /* support for \P, \p, and \X has not been compiled */
+ REG_BADPAT, /* malformed \P or \p sequence */
+ REG_BADPAT, /* unknown property name after \P or \p */
+ REG_BADPAT, /* subpattern name is too long (maximum 32 characters) */
+ REG_BADPAT, /* too many named subpatterns (maximum 10,000) */
/* 50 */
- PCRE_REG_BADPAT, /* repeated subpattern is too long */
- PCRE_REG_BADPAT, /* octal value is greater than \377 (not in UTF-8 mode) */
- PCRE_REG_BADPAT, /* internal error: overran compiling workspace */
- PCRE_REG_BADPAT, /* internal error: previously-checked referenced subpattern not found */
- PCRE_REG_BADPAT, /* DEFINE group contains more than one branch */
+ REG_BADPAT, /* repeated subpattern is too long */
+ REG_BADPAT, /* octal value is greater than \377 (not in UTF-8 mode) */
+ REG_BADPAT, /* internal error: overran compiling workspace */
+ REG_BADPAT, /* internal error: previously-checked referenced subpattern not found */
+ REG_BADPAT, /* DEFINE group contains more than one branch */
/* 55 */
- PCRE_REG_BADPAT, /* repeating a DEFINE group is not allowed */
- PCRE_REG_INVARG, /* inconsistent NEWLINE options */
- PCRE_REG_BADPAT, /* \g is not followed followed by an (optionally braced) non-zero number */
- PCRE_REG_BADPAT, /* a numbered reference must not be zero */
- PCRE_REG_BADPAT, /* an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT) */
+ REG_BADPAT, /* repeating a DEFINE group is not allowed */
+ REG_INVARG, /* inconsistent NEWLINE options */
+ REG_BADPAT, /* \g is not followed followed by an (optionally braced) non-zero number */
+ REG_BADPAT, /* a numbered reference must not be zero */
+ REG_BADPAT, /* an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT) */
/* 60 */
- PCRE_REG_BADPAT, /* (*VERB) not recognized */
- PCRE_REG_BADPAT, /* number is too big */
- PCRE_REG_BADPAT, /* subpattern name expected */
- PCRE_REG_BADPAT, /* digit expected after (?+ */
- PCRE_REG_BADPAT, /* ] is an invalid data character in JavaScript compatibility mode */
+ REG_BADPAT, /* (*VERB) not recognized */
+ REG_BADPAT, /* number is too big */
+ REG_BADPAT, /* subpattern name expected */
+ REG_BADPAT, /* digit expected after (?+ */
+ REG_BADPAT, /* ] is an invalid data character in JavaScript compatibility mode */
/* 65 */
- PCRE_REG_BADPAT, /* different names for subpatterns of the same number are not allowed */
- PCRE_REG_BADPAT, /* (*MARK) must have an argument */
- PCRE_REG_INVARG, /* this version of PCRE is not compiled with PCRE_UCP support */
- PCRE_REG_BADPAT, /* \c must be followed by an ASCII character */
- PCRE_REG_BADPAT, /* \k is not followed by a braced, angle-bracketed, or quoted name */
+ REG_BADPAT, /* different names for subpatterns of the same number are not allowed */
+ REG_BADPAT, /* (*MARK) must have an argument */
+ REG_INVARG, /* this version of PCRE is not compiled with PCRE_UCP support */
+ REG_BADPAT, /* \c must be followed by an ASCII character */
+ REG_BADPAT, /* \k is not followed by a braced, angle-bracketed, or quoted name */
/* 70 */
- PCRE_REG_BADPAT, /* internal error: unknown opcode in find_fixedlength() */
- PCRE_REG_BADPAT, /* \N is not supported in a class */
- PCRE_REG_BADPAT, /* too many forward references */
- PCRE_REG_BADPAT, /* disallowed UTF-8/16/32 code point (>= 0xd800 && <= 0xdfff) */
- PCRE_REG_BADPAT, /* invalid UTF-16 string (should not occur) */
+ REG_BADPAT, /* internal error: unknown opcode in find_fixedlength() */
+ REG_BADPAT, /* \N is not supported in a class */
+ REG_BADPAT, /* too many forward references */
+ REG_BADPAT, /* disallowed UTF-8/16/32 code point (>= 0xd800 && <= 0xdfff) */
+ REG_BADPAT, /* invalid UTF-16 string (should not occur) */
/* 75 */
- PCRE_REG_BADPAT, /* overlong MARK name */
- PCRE_REG_BADPAT, /* character value in \u.... sequence is too large */
- PCRE_REG_BADPAT, /* invalid UTF-32 string (should not occur) */
- PCRE_REG_BADPAT, /* setting UTF is disabled by the application */
- PCRE_REG_BADPAT, /* non-hex character in \\x{} (closing brace missing?) */
+ REG_BADPAT, /* overlong MARK name */
+ REG_BADPAT, /* character value in \u.... sequence is too large */
+ REG_BADPAT, /* invalid UTF-32 string (should not occur) */
+ REG_BADPAT, /* setting UTF is disabled by the application */
+ REG_BADPAT, /* non-hex character in \\x{} (closing brace missing?) */
/* 80 */
- PCRE_REG_BADPAT, /* non-octal character in \o{} (closing brace missing?) */
- PCRE_REG_BADPAT, /* missing opening brace after \o */
- PCRE_REG_BADPAT, /* parentheses too deeply nested */
- PCRE_REG_BADPAT, /* invalid range in character class */
- PCRE_REG_BADPAT, /* group name must start with a non-digit */
+ REG_BADPAT, /* non-octal character in \o{} (closing brace missing?) */
+ REG_BADPAT, /* missing opening brace after \o */
+ REG_BADPAT, /* parentheses too deeply nested */
+ REG_BADPAT, /* invalid range in character class */
+ REG_BADPAT, /* group name must start with a non-digit */
/* 85 */
- PCRE_REG_BADPAT, /* parentheses too deeply nested (stack check) */
- PCRE_REG_BADPAT, /* missing digits in \x{} or \o{} */
- PCRE_REG_BADPAT /* pattern too complicated */
+ REG_BADPAT, /* parentheses too deeply nested (stack check) */
+ REG_BADPAT, /* missing digits in \x{} or \o{} */
+ REG_BADPAT /* pattern too complicated */
};
/* Table of texts corresponding to POSIX error codes */
@@ -197,7 +208,7 @@ static const char *const pstring[] = {
*************************************************/
PCREPOSIX_EXP_DEFN size_t PCRE_CALL_CONVENTION
-pcre_regerror(int errcode, const pcre_regex_t *preg, char *errbuf, size_t errbuf_size)
+regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
{
const char *message, *addmessage;
size_t length, addlength;
@@ -232,7 +243,7 @@ return length + addlength;
*************************************************/
PCREPOSIX_EXP_DEFN void PCRE_CALL_CONVENTION
-pcre_regfree(pcre_regex_t *preg)
+regfree(regex_t *preg)
{
(PUBL(free))(preg->re_pcre);
}
@@ -255,7 +266,7 @@ Returns: 0 on success
*/
PCREPOSIX_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_regcomp(pcre_regex_t *preg, const char *pattern, int cflags)
+regcomp(regex_t *preg, const char *pattern, int cflags)
{
const char *errorptr;
int erroffset;
@@ -263,13 +274,13 @@ int errorcode;
int options = 0;
int re_nsub = 0;
-if ((cflags & PCRE_REG_ICASE) != 0) options |= PCRE_CASELESS;
-if ((cflags & PCRE_REG_NEWLINE) != 0) options |= PCRE_MULTILINE;
-if ((cflags & PCRE_REG_DOTALL) != 0) options |= PCRE_DOTALL;
-if ((cflags & PCRE_REG_NOSUB) != 0) options |= PCRE_NO_AUTO_CAPTURE;
-if ((cflags & PCRE_REG_UTF8) != 0) options |= PCRE_UTF8;
-if ((cflags & PCRE_REG_UCP) != 0) options |= PCRE_UCP;
-if ((cflags & PCRE_REG_UNGREEDY) != 0) options |= PCRE_UNGREEDY;
+if ((cflags & REG_ICASE) != 0) options |= PCRE_CASELESS;
+if ((cflags & REG_NEWLINE) != 0) options |= PCRE_MULTILINE;
+if ((cflags & REG_DOTALL) != 0) options |= PCRE_DOTALL;
+if ((cflags & REG_NOSUB) != 0) options |= PCRE_NO_AUTO_CAPTURE;
+if ((cflags & REG_UTF8) != 0) options |= PCRE_UTF8;
+if ((cflags & REG_UCP) != 0) options |= PCRE_UCP;
+if ((cflags & REG_UNGREEDY) != 0) options |= PCRE_UNGREEDY;
preg->re_pcre = pcre_compile2(pattern, options, &errorcode, &errorptr,
&erroffset, NULL);
@@ -281,12 +292,13 @@ should not happen, but we all make mistakes), return REG_BADPAT. */
if (preg->re_pcre == NULL)
{
return (errorcode < (int)(sizeof(eint)/sizeof(const int)))?
- eint[errorcode] : PCRE_REG_BADPAT;
+ eint[errorcode] : REG_BADPAT;
}
(void)pcre_fullinfo((const pcre *)preg->re_pcre, NULL, PCRE_INFO_CAPTURECOUNT,
&re_nsub);
preg->re_nsub = (size_t)re_nsub;
+preg->re_erroffset = (size_t)(-1); /* No meaning after successful compile */
return 0;
}
@@ -309,8 +321,8 @@ be set. When this is the case, the nmatch and pmatch arguments are ignored, and
the only result is yes/no/error. */
PCREPOSIX_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_regexec(const pcre_regex_t *preg, const char *string, size_t nmatch,
- pcre_regmatch_t pmatch[], int eflags)
+regexec(const regex_t *preg, const char *string, size_t nmatch,
+ regmatch_t pmatch[], int eflags)
{
int rc, so, eo;
int options = 0;
@@ -320,11 +332,9 @@ BOOL allocated_ovector = FALSE;
BOOL nosub =
(REAL_PCRE_OPTIONS((const pcre *)preg->re_pcre) & PCRE_NO_AUTO_CAPTURE) != 0;
-if ((eflags & PCRE_REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
-if ((eflags & PCRE_REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
-if ((eflags & PCRE_REG_NOTEMPTY) != 0) options |= PCRE_NOTEMPTY;
-
-((pcre_regex_t *)preg)->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
+if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
+if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
+if ((eflags & REG_NOTEMPTY) != 0) options |= PCRE_NOTEMPTY;
/* When no string data is being returned, or no vector has been passed in which
to put it, ensure that nmatch is zero. Otherwise, ensure the vector for holding
@@ -340,9 +350,9 @@ else if (nmatch > 0)
}
else
{
- if (nmatch > INT_MAX/(sizeof(int) * 3)) return PCRE_REG_ESPACE;
+ if (nmatch > INT_MAX/(sizeof(int) * 3)) return REG_ESPACE;
ovector = (int *)malloc(sizeof(int) * nmatch * 3);
- if (ovector == NULL) return PCRE_REG_ESPACE;
+ if (ovector == NULL) return REG_ESPACE;
allocated_ovector = TRUE;
}
}
@@ -352,9 +362,9 @@ The man page from OS X says "REG_STARTEND affects only the location of the
string, not how it is matched". That is why the "so" value is used to bump the
start location rather than being passed as a PCRE "starting offset". */
-if ((eflags & PCRE_REG_STARTEND) != 0)
+if ((eflags & REG_STARTEND) != 0)
{
- if (pmatch == NULL) return PCRE_REG_INVARG;
+ if (pmatch == NULL) return REG_INVARG;
so = pmatch[0].rm_so;
eo = pmatch[0].rm_eo;
}
@@ -401,20 +411,20 @@ switch(rc)
case 0:
case (sizeof(eint)/sizeof(int) == ERRCOUNT):
- return PCRE_REG_ASSERT;
+ return REG_ASSERT;
/* ========================================================================== */
- case PCRE_ERROR_NOMATCH: return PCRE_REG_NOMATCH;
- case PCRE_ERROR_NULL: return PCRE_REG_INVARG;
- case PCRE_ERROR_BADOPTION: return PCRE_REG_INVARG;
- case PCRE_ERROR_BADMAGIC: return PCRE_REG_INVARG;
- case PCRE_ERROR_UNKNOWN_NODE: return PCRE_REG_ASSERT;
- case PCRE_ERROR_NOMEMORY: return PCRE_REG_ESPACE;
- case PCRE_ERROR_MATCHLIMIT: return PCRE_REG_ESPACE;
- case PCRE_ERROR_BADUTF8: return PCRE_REG_INVARG;
- case PCRE_ERROR_BADUTF8_OFFSET: return PCRE_REG_INVARG;
- case PCRE_ERROR_BADMODE: return PCRE_REG_INVARG;
- default: return PCRE_REG_ASSERT;
+ case PCRE_ERROR_NOMATCH: return REG_NOMATCH;
+ case PCRE_ERROR_NULL: return REG_INVARG;
+ case PCRE_ERROR_BADOPTION: return REG_INVARG;
+ case PCRE_ERROR_BADMAGIC: return REG_INVARG;
+ case PCRE_ERROR_UNKNOWN_NODE: return REG_ASSERT;
+ case PCRE_ERROR_NOMEMORY: return REG_ESPACE;
+ case PCRE_ERROR_MATCHLIMIT: return REG_ESPACE;
+ case PCRE_ERROR_BADUTF8: return REG_INVARG;
+ case PCRE_ERROR_BADUTF8_OFFSET: return REG_INVARG;
+ case PCRE_ERROR_BADMODE: return REG_INVARG;
+ default: return REG_ASSERT;
}
}
diff --git a/deps/pcre/pcreposix.h b/deps/pcre/pcreposix.h
index 70a195c1a..c77c0b052 100644
--- a/deps/pcre/pcreposix.h
+++ b/deps/pcre/pcreposix.h
@@ -44,48 +44,51 @@ POSSIBILITY OF SUCH DAMAGE.
#include <stdlib.h>
-#define PCREPOSIX_EXP_DEFN extern
-#define PCREPOSIX_EXP_DECL extern
+/* Allow for C++ users */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/* Options, mostly defined by POSIX, but with some extras. */
-#define PCRE_REG_ICASE 0x0001 /* Maps to PCRE_CASELESS */
-#define PCRE_REG_NEWLINE 0x0002 /* Maps to PCRE_MULTILINE */
-#define PCRE_REG_NOTBOL 0x0004 /* Maps to PCRE_NOTBOL */
-#define PCRE_REG_NOTEOL 0x0008 /* Maps to PCRE_NOTEOL */
-#define PCRE_REG_DOTALL 0x0010 /* NOT defined by POSIX; maps to PCRE_DOTALL */
-#define PCRE_REG_NOSUB 0x0020 /* Maps to PCRE_NO_AUTO_CAPTURE */
-#define PCRE_REG_UTF8 0x0040 /* NOT defined by POSIX; maps to PCRE_UTF8 */
-#define PCRE_REG_STARTEND 0x0080 /* BSD feature: pass subject string by so,eo */
-#define PCRE_REG_NOTEMPTY 0x0100 /* NOT defined by POSIX; maps to PCRE_NOTEMPTY */
-#define PCRE_REG_UNGREEDY 0x0200 /* NOT defined by POSIX; maps to PCRE_UNGREEDY */
-#define PCRE_REG_UCP 0x0400 /* NOT defined by POSIX; maps to PCRE_UCP */
+#define REG_ICASE 0x0001 /* Maps to PCRE_CASELESS */
+#define REG_NEWLINE 0x0002 /* Maps to PCRE_MULTILINE */
+#define REG_NOTBOL 0x0004 /* Maps to PCRE_NOTBOL */
+#define REG_NOTEOL 0x0008 /* Maps to PCRE_NOTEOL */
+#define REG_DOTALL 0x0010 /* NOT defined by POSIX; maps to PCRE_DOTALL */
+#define REG_NOSUB 0x0020 /* Maps to PCRE_NO_AUTO_CAPTURE */
+#define REG_UTF8 0x0040 /* NOT defined by POSIX; maps to PCRE_UTF8 */
+#define REG_STARTEND 0x0080 /* BSD feature: pass subject string by so,eo */
+#define REG_NOTEMPTY 0x0100 /* NOT defined by POSIX; maps to PCRE_NOTEMPTY */
+#define REG_UNGREEDY 0x0200 /* NOT defined by POSIX; maps to PCRE_UNGREEDY */
+#define REG_UCP 0x0400 /* NOT defined by POSIX; maps to PCRE_UCP */
/* This is not used by PCRE, but by defining it we make it easier
to slot PCRE into existing programs that make POSIX calls. */
-#define PCRE_REG_EXTENDED 0
+#define REG_EXTENDED 0
/* Error values. Not all these are relevant or used by the wrapper. */
enum {
- PCRE_REG_ASSERT = 1, /* internal error ? */
- PCRE_REG_BADBR, /* invalid repeat counts in {} */
- PCRE_REG_BADPAT, /* pattern error */
- PCRE_REG_BADRPT, /* ? * + invalid */
- PCRE_REG_EBRACE, /* unbalanced {} */
- PCRE_REG_EBRACK, /* unbalanced [] */
- PCRE_REG_ECOLLATE, /* collation error - not relevant */
- PCRE_REG_ECTYPE, /* bad class */
- PCRE_REG_EESCAPE, /* bad escape sequence */
- PCRE_REG_EMPTY, /* empty expression */
- PCRE_REG_EPAREN, /* unbalanced () */
- PCRE_REG_ERANGE, /* bad range inside [] */
- PCRE_REG_ESIZE, /* expression too big */
- PCRE_REG_ESPACE, /* failed to get memory */
- PCRE_REG_ESUBREG, /* bad back reference */
- PCRE_REG_INVARG, /* bad argument */
- PCRE_REG_NOMATCH /* match failed */
+ REG_ASSERT = 1, /* internal error ? */
+ REG_BADBR, /* invalid repeat counts in {} */
+ REG_BADPAT, /* pattern error */
+ REG_BADRPT, /* ? * + invalid */
+ REG_EBRACE, /* unbalanced {} */
+ REG_EBRACK, /* unbalanced [] */
+ REG_ECOLLATE, /* collation error - not relevant */
+ REG_ECTYPE, /* bad class */
+ REG_EESCAPE, /* bad escape sequence */
+ REG_EMPTY, /* empty expression */
+ REG_EPAREN, /* unbalanced () */
+ REG_ERANGE, /* bad range inside [] */
+ REG_ESIZE, /* expression too big */
+ REG_ESPACE, /* failed to get memory */
+ REG_ESUBREG, /* bad back reference */
+ REG_INVARG, /* bad argument */
+ REG_NOMATCH /* match failed */
};
@@ -95,23 +98,49 @@ typedef struct {
void *re_pcre;
size_t re_nsub;
size_t re_erroffset;
-} pcre_regex_t;
+} regex_t;
/* The structure in which a captured offset is returned. */
-typedef int pcre_regoff_t;
+typedef int regoff_t;
typedef struct {
- pcre_regoff_t rm_so;
- pcre_regoff_t rm_eo;
-} pcre_regmatch_t;
+ regoff_t rm_so;
+ regoff_t rm_eo;
+} regmatch_t;
+
+/* When an application links to a PCRE DLL in Windows, the symbols that are
+imported have to be identified as such. When building PCRE, the appropriate
+export settings are needed, and are set in pcreposix.c before including this
+file. */
+
+#if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL)
+# define PCREPOSIX_EXP_DECL extern __declspec(dllimport)
+# define PCREPOSIX_EXP_DEFN __declspec(dllimport)
+#endif
+
+/* By default, we use the standard "extern" declarations. */
+
+#ifndef PCREPOSIX_EXP_DECL
+# ifdef __cplusplus
+# define PCREPOSIX_EXP_DECL extern "C"
+# define PCREPOSIX_EXP_DEFN extern "C"
+# else
+# define PCREPOSIX_EXP_DECL extern
+# define PCREPOSIX_EXP_DEFN extern
+# endif
+#endif
/* The functions */
-PCREPOSIX_EXP_DECL int pcre_regcomp(pcre_regex_t *, const char *, int);
-PCREPOSIX_EXP_DECL int pcre_regexec(const pcre_regex_t *, const char *, size_t,
- pcre_regmatch_t *, int);
-PCREPOSIX_EXP_DECL size_t pcre_regerror(int, const pcre_regex_t *, char *, size_t);
-PCREPOSIX_EXP_DECL void pcre_regfree(pcre_regex_t *);
+PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int);
+PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t,
+ regmatch_t *, int);
+PCREPOSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t);
+PCREPOSIX_EXP_DECL void regfree(regex_t *);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
#endif /* End of pcreposix.h */
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d01cc6458..c2779c872 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -155,12 +155,21 @@ ELSEIF(REGEX_BACKEND STREQUAL "regcomp")
ADD_FEATURE_INFO(regex ON "using system regcomp")
SET(GIT_REGEX_REGCOMP 1)
ELSEIF(REGEX_BACKEND STREQUAL "builtin")
- ADD_FEATURE_INFO(regex ON "using bundled PCRE")
- SET(GIT_REGEX_BUILTIN 1)
+ add_feature_info(regex ON "using bundled PCRE")
+ set(GIT_REGEX_BUILTIN 1)
- ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/pcre" "${libgit2_BINARY_DIR}/deps/pcre")
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre")
- LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:pcre>)
+ set(TMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
+
+ set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
+ set(PCRE_BUILD_PCRECPP OFF CACHE BOOL "")
+ set(PCRE_BUILD_TESTS OFF CACHE BOOL "")
+ set(PCRE_BUILD_PCREGREP OFF CACHE BOOL "")
+
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/pcre" "${libgit2_BINARY_DIR}/deps/pcre")
+ list(APPEND LIBGIT2_LIBS pcre)
+
+ set(BUILD_SHARED_LIBS ${TMP_BUILD_SHARED_LIBS} CACHE BOOL "" FORCE)
+ unset(BUILD_SHARED_LIBS)
ELSE()
MESSAGE(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
ENDIF()