diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-04-02 13:32:07 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-04-02 13:32:07 +0000 |
commit | 538ef4f8d6632b422169714282844c34b4bfc271 (patch) | |
tree | 67867bc84c7834cad2a0c7c65340605c1a02ea9d | |
parent | f8735bf7b631d53067a040bd9f2c04b8f80c6dae (diff) | |
download | pcre-538ef4f8d6632b422169714282844c34b4bfc271.tar.gz |
Daniel's patches to add to the CMake support.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@144 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | CMakeLists.txt | 96 | ||||
-rw-r--r-- | Makefile.am | 12 | ||||
-rw-r--r-- | NON-UNIX-USE | 24 | ||||
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | RunTest.bat | 48 | ||||
-rw-r--r-- | config-cmake.h.in | 2 | ||||
-rw-r--r-- | pcre_dfa_exec.c | 2 | ||||
-rw-r--r-- | pcre_exec.c | 2 | ||||
-rw-r--r-- | pcre_scanner_unittest.cc | 4 | ||||
-rw-r--r-- | pcretest.c | 6 |
10 files changed, 142 insertions, 59 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 49f1715..a683995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,12 +38,12 @@ CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG) # (Note: CMakeSetup displays these in alphabetical order, regardless of # the order we use here) -SET(BUILD_SHARED_LIBS "SHARED" CACHE STRING - "What type of libraries to build. Set to SHARED or STATIC.") +SET(BUILD_SHARED_LIBS OFF CACHE BOOL + "Build shared libraries instead of static ones.") OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON) -SET(PCRE_EBCDIC FALSE CACHE BOOL +SET(PCRE_EBCDIC OFF CACHE BOOL "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems)") SET(PCRE_LINK_SIZE "2" CACHE STRING @@ -58,16 +58,16 @@ SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING SET(PCRE_NEWLINE "LF" CACHE STRING "What to recognize as a newline (one of CR, LF, CRLF, ANY).") -SET(PCRE_NO_RECURSE TRUE CACHE BOOL +SET(PCRE_NO_RECURSE ON 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_UNICODE_PROPERTIES FALSE CACHE BOOL +SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL "Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)") -SET(PCRE_SUPPORT_UTF8 FALSE CACHE BOOL +SET(PCRE_SUPPORT_UTF8 OFF CACHE BOOL "Enable support for the Unicode UTF-8 encoding.") # Prepare build configuration @@ -94,6 +94,10 @@ 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(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES) SET(SUPPORT_UTF8 1) ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES) @@ -102,23 +106,24 @@ IF(PCRE_SUPPORT_UNICODE_PROPERTIES) SET(SUPPORT_UCP 1) ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES) +SET(NEWLINE "") + IF(PCRE_NEWLINE STREQUAL "LF") - SET(NEWLINE "10") -ELSE(PCRE_NEWLINE STREQUAL "LF") - IF(PCRE_NEWLINE STREQUAL "CR") - SET(NEWLINE "13") - ELSE(PCRE_NEWLINE STREQUAL "CR") - IF(PCRE_NEWLINE STREQUAL "CRLF") - SET(NEWLINE "3338") - ELSE(PCRE_NEWLINE STREQUAL "CRLF") - IF(PCRE_NEWLINE STREQUAL "ANY") + SET(NEWLINE "10") +ENDIF(PCRE_NEWLINE STREQUAL "LF") +IF(PCRE_NEWLINE STREQUAL "CR") + SET(NEWLINE "13") +ENDIF(PCRE_NEWLINE STREQUAL "CR") +IF(PCRE_NEWLINE STREQUAL "CRLF") + SET(NEWLINE "3338") +ENDIF(PCRE_NEWLINE STREQUAL "CRLF") +IF(PCRE_NEWLINE STREQUAL "ANY") SET(NEWLINE "-1") - ELSE(PCRE_NEWLINE STREQUAL "ANY") +ENDIF(PCRE_NEWLINE STREQUAL "ANY") + +IF(NEWLINE STREQUAL "") MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\".") - ENDIF(PCRE_NEWLINE STREQUAL "ANY") - ENDIF(PCRE_NEWLINE STREQUAL "CRLF") - ENDIF(PCRE_NEWLINE STREQUAL "CR") -ENDIF(PCRE_NEWLINE STREQUAL "LF") +ENDIF(NEWLINE STREQUAL "") IF(PCRE_EBCDIC) SET(EBCDIC 1) @@ -244,18 +249,57 @@ TARGET_LINK_LIBRARIES(pcretest pcreposix) ADD_EXECUTABLE(pcregrep pcregrep.c) TARGET_LINK_LIBRARIES(pcregrep pcreposix) +IF(PCRE_BUILD_PCRECPP) + ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc) + TARGET_LINK_LIBRARIES(pcrecpp_unittest pcrecpp) + + ADD_EXECUTABLE(pcre_scanner_unittest pcre_scanner_unittest.cc) + TARGET_LINK_LIBRARIES(pcre_scanner_unittest pcrecpp) + + ADD_EXECUTABLE(pcre_stringpiece_unittest pcre_stringpiece_unittest.cc) + TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp) +ENDIF(PCRE_BUILD_PCRECPP) + # Testing ENABLE_TESTING() +GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION) +GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION) + +# Write out a CTest configuration file that sets some needed environment +# variables for the test scripts. +# +FILE(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.ctest +"# This is a generated file. +SET(ENV{srcdir} ${CMAKE_SOURCE_DIR}) +SET(ENV{pcregrep} ${PCREGREP_EXE}) +SET(ENV{pcretest} ${PCRETEST_EXE}) +") + IF(UNIX) - ADD_TEST(test1 sh -c "srcdir=${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/RunTest") - ADD_TEST(test2 sh -c "srcdir=${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/RunGrepTest") -ELSE(UNIX) - IF(WIN32) - ADD_TEST(test1 ${CMAKE_SOURCE_DIR}/RunTest.bat ${CMAKE_SOURCE_DIR}) - ENDIF(WIN32) + ADD_TEST(pcre_test ${CMAKE_SOURCE_DIR}/RunTest) + ADD_TEST(pcre_grep_test ${CMAKE_SOURCE_DIR}/RunGrepTest) ENDIF(UNIX) +IF(WIN32) + ADD_TEST(pcre_test cmd /C ${CMAKE_SOURCE_DIR}/RunTest.bat) +ENDIF(WIN32) + +GET_TARGET_PROPERTY(PCRECPP_UNITTEST_EXE + pcrecpp_unittest + DEBUG_LOCATION) + +GET_TARGET_PROPERTY(PCRE_SCANNER_UNITTEST_EXE + pcre_scanner_unittest + DEBUG_LOCATION) + +GET_TARGET_PROPERTY(PCRE_STRINGPIECE_UNITTEST_EXE + pcre_stringpiece_unittest + DEBUG_LOCATION) + +ADD_TEST(pcrecpp_test ${PCRECPP_UNITTEST_EXE}) +ADD_TEST(pcre_scanner_test ${PCRE_SCANNER_UNITTEST_EXE}) +ADD_TEST(pcre_stringpiece_test ${PCRE_STRINGPIECE_UNITTEST_EXE}) # Installation diff --git a/Makefile.am b/Makefile.am index 5986f36..9906793 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,7 +63,7 @@ lib_LTLIBRARIES = # TESTS is for binary unit tests, check_SCRIPTS for script-based tests TESTS = check_SCRIPTS = -noinst_SCRIPTS = +dist_noinst_SCRIPTS = # Some of the binaries we make are to be installed, and others are # (non-user-visible) helper programs needed to build libpcre. @@ -106,6 +106,12 @@ EXTRA_DIST += \ pcre.h.generic \ config.h.generic +pcre.h.generic: configure.ac + rm -f $@ + cp -p pcre.h $@ + +MAINTAINERCLEANFILES += pcre.h.generic + # These are the header files we'll install. We do not distribute pcre.h because # it is generated from pcre.h.in. nodist_include_HEADERS = \ @@ -231,14 +237,14 @@ endif # WITH_PCRE_CPP # ways. We install these test binaries in case folks find it helpful. TESTS += RunTest -noinst_SCRIPTS += RunTest +dist_noinst_SCRIPTS += RunTest EXTRA_DIST += RunTest.bat bin_PROGRAMS += pcretest pcretest_SOURCES = pcretest.c pcretest_LDADD = libpcreposix.la TESTS += RunGrepTest -noinst_SCRIPTS += RunGrepTest +dist_noinst_SCRIPTS += RunGrepTest bin_PROGRAMS += pcregrep pcregrep_SOURCES = pcregrep.c pcregrep_LDADD = libpcreposix.la diff --git a/NON-UNIX-USE b/NON-UNIX-USE index 90f0258..2b82b7c 100644 --- a/NON-UNIX-USE +++ b/NON-UNIX-USE @@ -23,11 +23,15 @@ site that you may find useful. See ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib -If you want to compile PCRE for a non-Unix system (or perhaps, more strictly, -for a system that does not support "configure" and "make" files), note that -the basic PCRE library consists entirely of code written in Standard C, and so -should compile successfully on any system that has a Standard C compiler and -library. The C++ wrapper functions are a separate issue (see below). +If you want to compile PCRE for a non-Unix system (especially for a system that +does not support "configure" and "make" files), note that the basic PCRE +library consists entirely of code written in Standard C, and so should compile +successfully on any system that has a Standard C compiler and library. The C++ +wrapper functions are a separate issue (see below). + +The PCRE distribution contains some experimental support for "cmake", but this +is incomplete and not documented. However if you are a "cmake" user you might +like to try building with "cmake". GENERIC INSTRUCTIONS FOR THE PCRE C LIBRARY @@ -123,9 +127,13 @@ for use with VP/Borland: makevp_c.txt, makevp_l.txt, makevp.bat, pcregexp.pas. COMMENTS ABOUT WIN32 BUILDS -There are two ways of building PCRE on Windows systems: using MinGW or using -Cygwin. These are not at all the same thing, and are completely different from -each other. +There are two ways of building PCRE using the "congifure, make, make install" +paradigm on Windows systems: using MinGW or using Cygwin. These are not at all +the same thing; they are completely different from each other. There is also +some experimental, undocumented support for building using "cmake", which you +might like to try if you are familiar with "cmake". However, at the present +time, the "cmake" process builds only a static library (not a dll), and the +tests are not automatically run. The MinGW home page (http://www.mingw.org/) says this: @@ -116,6 +116,11 @@ Building PCRE on Unix-like systems If you are using HP's ANSI C++ compiler (aCC), please see the special note in the section entitled "Using HP's ANSI C++ compiler (aCC)" below. +The following instructions assume the use of the widely used "configure, make, +make install" process. There is also some experimental support for "cmake" in +the PCRE distribution, but it is incomplete and not documented. However, if you +are a "cmake" user, you might want to try it. + To build PCRE on a Unix-like system, first run the "configure" command from the PCRE distribution directory, with your current directory set to the directory where you want the files to be created. This command is a standard GNU diff --git a/RunTest.bat b/RunTest.bat index f9b3519..1db39e5 100644 --- a/RunTest.bat +++ b/RunTest.bat @@ -1,20 +1,34 @@ -rem This file was contributed by Ralf Junker. -rem -rem MS Windows batch file to run pcretest on testfiles with the correct options. -rem -rem Assumes that this file as well as pcretest.exe is located in the PCRE root folder. -rem -rem Output written to a newly generated subfolder named "testdata". +@rem This file was contributed by Ralf Junker, and touched up by +@rem Daniel Richard G. +@rem +@rem MS Windows batch file to run pcretest on testfiles with the correct +@rem options. +@rem +@rem Output is written to a newly created subfolder named "testdata". -if not exist .\testout\ md .\testout\ +setlocal -pcretest -q testdata\testinput1 > testout\testoutput1 -pcretest -q testdata\testinput2 > testout\testoutput2 -pcretest -q testdata\testinput3 > testout\testoutput3 -pcretest -q testdata\testinput4 > testout\testoutput4 -pcretest -q testdata\testinput5 > testout\testoutput5 -pcretest -q testdata\testinput6 > testout\testoutput6 -pcretest -q -dfa testdata\testinput7 > testout\testoutput7 -pcretest -q -dfa testdata\testinput8 > testout\testoutput8 -pcretest -q -dfa testdata\testinput9 > testout\testoutput9 +if [%srcdir%]==[] set srcdir=. +if [%pcretest%]==[] set pcretest=pcretest +if not exist testout md testout + +%pcretest% -q %srcdir%\testdata\testinput1 > testout\testoutput1 +%pcretest% -q %srcdir%\testdata\testinput2 > testout\testoutput2 +%pcretest% -q %srcdir%\testdata\testinput3 > testout\testoutput3 +%pcretest% -q %srcdir%\testdata\testinput4 > testout\testoutput4 +%pcretest% -q %srcdir%\testdata\testinput5 > testout\testoutput5 +%pcretest% -q %srcdir%\testdata\testinput6 > testout\testoutput6 +%pcretest% -q -dfa %srcdir%\testdata\testinput7 > testout\testoutput7 +%pcretest% -q -dfa %srcdir%\testdata\testinput8 > testout\testoutput8 +%pcretest% -q -dfa %srcdir%\testdata\testinput9 > testout\testoutput9 + +fc /n %srcdir%\testdata\testoutput1 testout\testoutput1 +fc /n %srcdir%\testdata\testoutput2 testout\testoutput2 +rem fc /n %srcdir%\testdata\testoutput3 testout\testoutput3 +fc /n %srcdir%\testdata\testoutput4 testout\testoutput4 +fc /n %srcdir%\testdata\testoutput5 testout\testoutput5 +fc /n %srcdir%\testdata\testoutput6 testout\testoutput6 +fc /n %srcdir%\testdata\testoutput7 testout\testoutput7 +fc /n %srcdir%\testdata\testoutput8 testout\testoutput8 +fc /n %srcdir%\testdata\testoutput9 testout\testoutput9 diff --git a/config-cmake.h.in b/config-cmake.h.in index a17e2fa..0f6c1e5 100644 --- a/config-cmake.h.in +++ b/config-cmake.h.in @@ -11,6 +11,8 @@ #cmakedefine HAVE_MEMMOVE #cmakedefine HAVE_STRERROR +#cmakedefine PCRE_STATIC + #cmakedefine SUPPORT_UTF8 #cmakedefine SUPPORT_UCP #cmakedefine EBCDIC diff --git a/pcre_dfa_exec.c b/pcre_dfa_exec.c index 8ffad82..77ec44f 100644 --- a/pcre_dfa_exec.c +++ b/pcre_dfa_exec.c @@ -2166,7 +2166,7 @@ md->poptions = re->options; /* Handle different types of newline. The three bits give eight cases. If nothing is set at run time, whatever was used at compile time applies. */ -switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : options) & +switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)options) & PCRE_NEWLINE_BITS) { case 0: newline = NEWLINE; break; /* Compile-time default */ diff --git a/pcre_exec.c b/pcre_exec.c index f8e325d..2212420 100644 --- a/pcre_exec.c +++ b/pcre_exec.c @@ -3831,7 +3831,7 @@ md->ctypes = tables + ctypes_offset; /* Handle different types of newline. The three bits give eight cases. If nothing is set at run time, whatever was used at compile time applies. */ -switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : options) & +switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)options) & PCRE_NEWLINE_BITS) { case 0: newline = NEWLINE; break; /* Compile-time default */ diff --git a/pcre_scanner_unittest.cc b/pcre_scanner_unittest.cc index d939fed..8e1a598 100644 --- a/pcre_scanner_unittest.cc +++ b/pcre_scanner_unittest.cc @@ -38,6 +38,10 @@ #include <pcre_stringpiece.h> #include <pcre_scanner.h> +#ifdef _WIN32 +# define snprintf _snprintf +#endif + #define FLAGS_unittest_stack_size 49152 // Dies with a fatal error if the two values are not equal. @@ -2220,7 +2220,7 @@ while (!done) advance of one character just passes the \r, whereas we should prefer the longer newline sequence, as does the code in pcre_exec(). Fudge the offset value to achieve this. - + Otherwise, in the case of UTF-8 matching, the advance must be one character, not one byte. */ @@ -2230,12 +2230,12 @@ while (!done) { int onechar = 1; use_offsets[0] = start_offset; - if ((((real_pcre *)re)->options & PCRE_NEWLINE_BITS) == + if ((((real_pcre *)re)->options & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANY && start_offset < len - 1 && bptr[start_offset] == '\r' && bptr[start_offset+1] == '\n') - onechar++; + onechar++; else if (use_utf8) { while (start_offset + onechar < len) |