summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt285
-rw-r--r--COPYING65
-rw-r--r--Makefile.am8
-rwxr-xr-x[-rw-r--r--]RunGrepTest (renamed from RunGrepTest.in)7
-rwxr-xr-xRunTest (renamed from RunTest.in)9
-rw-r--r--config-cmake.h.in29
-rw-r--r--configure.ac12
-rw-r--r--pcre_exec.c5
-rw-r--r--pcre_internal.h6
-rw-r--r--pcrecpp.cc2
-rw-r--r--pcregrep.c8
11 files changed, 344 insertions, 92 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0d2a144..db5221b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1 +1,284 @@
-# This file is a placeholder.
+# 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>
+#
+
+PROJECT(PCRE C CXX)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6)
+
+# Configuration checks
+
+INCLUDE(CheckIncludeFile)
+INCLUDE(CheckIncludeFileCXX)
+INCLUDE(CheckFunctionExists)
+INCLUDE(CheckTypeSize)
+
+CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
+CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
+CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
+CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_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)
+
+CHECK_TYPE_SIZE("long long" LONG_LONG)
+CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
+
+# User-configurable options
+#
+# (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.")
+
+OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON)
+
+SET(PCRE_EBCDIC FALSE CACHE BOOL
+ "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems)")
+
+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_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(PCRE_NEWLINE "LF" CACHE STRING
+ "What to recognize as a newline (one of CR, LF, CRLF, ANY).")
+
+SET(PCRE_NO_RECURSE TRUE 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
+ "Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)")
+
+SET(PCRE_SUPPORT_UTF8 FALSE CACHE BOOL
+ "Enable support for the Unicode UTF-8 encoding.")
+
+# 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)
+
+IF(HAVE_LONG_LONG)
+ SET(pcre_have_long_long 1)
+ENDIF(HAVE_LONG_LONG)
+
+IF(HAVE_UNSIGNED_LONG_LONG)
+ SET(pcre_have_ulong_long 1)
+ENDIF(HAVE_UNSIGNED_LONG_LONG)
+
+IF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
+ SET(SUPPORT_UTF8 1)
+ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
+
+IF(PCRE_SUPPORT_UNICODE_PROPERTIES)
+ SET(SUPPORT_UCP 1)
+ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
+
+IF(PCRE_NEWLINE STREQUAL "LF")
+ SET(NEWLINE "10")
+ELSEIF(PCRE_NEWLINE STREQUAL "CR")
+ SET(NEWLINE "13")
+ELSEIF(PCRE_NEWLINE STREQUAL "CRLF")
+ SET(NEWLINE "3338")
+ELSEIF(PCRE_NEWLINE STREQUAL "ANY")
+ SET(NEWLINE "-1")
+ELSE(PCRE_NEWLINE STREQUAL "LF")
+ MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\".")
+ENDIF(PCRE_NEWLINE STREQUAL "LF")
+
+IF(PCRE_EBCDIC)
+ SET(EBCDIC 1)
+ENDIF(PCRE_EBCDIC)
+
+IF(PCRE_NO_RECURSE)
+ SET(NO_RECURSE 1)
+ENDIF(PCRE_NO_RECURSE)
+
+# Output files
+
+CONFIGURE_FILE(config-cmake.h.in
+ ${CMAKE_BINARY_DIR}/config.h
+ @ONLY)
+
+CONFIGURE_FILE(pcre.h.generic
+ ${CMAKE_BINARY_DIR}/pcre.h
+ COPYONLY)
+
+# What about pcre-config and libpcre.pc?
+
+IF(PCRE_BUILD_PCRECPP)
+ CONFIGURE_FILE(pcre_stringpiece.h.in
+ ${CMAKE_BINARY_DIR}/pcre_stringpiece.h
+ @ONLY)
+
+ CONFIGURE_FILE(pcrecpparg.h.in
+ ${CMAKE_BINARY_DIR}/pcrecpparg.h
+ @ONLY)
+ENDIF(PCRE_BUILD_PCRECPP)
+
+# Character table generation
+
+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 ${CMAKE_BINARY_DIR}/pcre_chartables.c
+ OUTPUT ${CMAKE_BINARY_DIR}/pcre_chartables.c
+)
+
+# Source code
+
+SET(PCRE_HEADERS ${CMAKE_BINARY_DIR}/pcre.h)
+
+SET(PCRE_SOURCES
+ ${CMAKE_BINARY_DIR}/pcre_chartables.c
+ pcre_compile.c
+ pcre_config.c
+ pcre_dfa_exec.c
+ pcre_exec.c
+ pcre_fullinfo.c
+ pcre_get.c
+ pcre_globals.c
+ pcre_info.c
+ pcre_newline.c
+ pcre_maketables.c
+ pcre_ord2utf8.c
+ pcre_refcount.c
+ pcre_study.c
+ pcre_tables.c
+ pcre_try_flipped.c
+ pcre_ucp_searchfuncs.c
+ pcre_valid_utf8.c
+ pcre_version.c
+ pcre_xclass.c
+)
+
+SET(PCREPOSIX_HEADERS pcreposix.h)
+
+SET(PCREPOSIX_SOURCES pcreposix.c)
+
+SET(PCRECPP_HEADERS
+ pcrecpp.h
+ pcre_scanner.h
+ ${CMAKE_BINARY_DIR}/pcrecpparg.h
+ ${CMAKE_BINARY_DIR}/pcre_stringpiece.h
+)
+
+SET(PCRECPP_SOURCES
+ pcrecpp.cc
+ pcre_scanner.cc
+ pcre_stringpiece.cc
+)
+
+# Build setup
+
+ADD_DEFINITIONS(-DHAVE_CONFIG_H)
+
+IF(WIN32)
+ # What about -DDLL_EXPORT?
+ ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
+ENDIF(WIN32)
+
+SET(CMAKE_INCLUDE_CURRENT_DIR 1)
+
+#SET(CMAKE_DEBUG_POSTFIX "d")
+
+# Libraries
+
+ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES})
+
+ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES})
+TARGET_LINK_LIBRARIES(pcreposix pcre)
+
+IF(PCRE_BUILD_PCRECPP)
+ ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES})
+ TARGET_LINK_LIBRARIES(pcrecpp pcre)
+ IF(MINGW)
+ SET_TARGET_PROPERTIES(pcrecpp PROPERTIES PREFIX "mingw-")
+ ENDIF(MINGW)
+ENDIF(PCRE_BUILD_PCRECPP)
+
+# Executables
+
+ADD_EXECUTABLE(pcretest pcretest.c)
+TARGET_LINK_LIBRARIES(pcretest pcreposix)
+
+ADD_EXECUTABLE(pcregrep pcregrep.c)
+TARGET_LINK_LIBRARIES(pcregrep pcreposix)
+
+# Testing
+
+ENABLE_TESTING()
+
+IF(UNIX)
+ ADD_TEST(test1 ${CMAKE_SOURCE_DIR}/RunTest srcdir=${CMAKE_SOURCE_DIR})
+ELSEIF(WIN32)
+ ADD_TEST(test1 ${CMAKE_SOURCE_DIR}/RunTest.bat ${CMAKE_SOURCE_DIR})
+ENDIF(UNIX)
+
+# Installation
+
+SET(CMAKE_INSTALL_ALWAYS 1)
+
+INSTALL(TARGETS pcre pcreposix pcregrep pcretest
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+
+INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
+
+FILE(GLOB html ${CMAKE_SOURCE_DIR}/doc/html/*.html)
+FILE(GLOB man1 ${CMAKE_SOURCE_DIR}/doc/*.1)
+FILE(GLOB man3 ${CMAKE_SOURCE_DIR}/doc/*.3)
+
+IF(PCRE_BUILD_PCRECPP)
+ INSTALL(TARGETS pcrecpp DESTINATION lib)
+ 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 doc/html)
+
+# end CMakeLists.txt
diff --git a/COPYING b/COPYING
index 4baa7d8..58eed01 100644
--- a/COPYING
+++ b/COPYING
@@ -1,68 +1,5 @@
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 7 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 basic library functions are written in C and are freestanding. Also
-included in the distribution is a set of C++ wrapper functions.
-
-
-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-2007 University of Cambridge
-All rights reserved.
-
-
-THE C++ WRAPPER FUNCTIONS
--------------------------
-
-Contributed by: Google Inc.
-
-Copyright (c) 2007, 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.
+Please see the file LICENCE in the PCRE distribution for licensing details.
End
diff --git a/Makefile.am b/Makefile.am
index 8d49cc2..5986f36 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -144,7 +144,8 @@ pcre_chartables.c: dftables$(EXEEXT)
else
pcre_chartables.c: $(srcdir)/pcre_chartables.c.dist
- cp -f $(srcdir)/pcre_chartables.c.dist pcre_chartables.c
+ rm -f $@
+ $(LN_S) $(srcdir)/pcre_chartables.c.dist $@
endif # WITH_REBUILD_CHARTABLES
@@ -342,9 +343,4 @@ EXTRA_DIST += \
CMakeLists.txt \
config-cmake.h.in
-config-cmake.h.in: config.h.in
- sed 's/#undef/#cmakedefine/g' config.h.in >$@
-
-MAINTAINERCLEANFILES += config-cmake.h.in
-
## end Makefile.am
diff --git a/RunGrepTest.in b/RunGrepTest
index 3c88b8b..c357540 100644..100755
--- a/RunGrepTest.in
+++ b/RunGrepTest
@@ -17,10 +17,11 @@ echo "Testing pcregrep"
cf="diff -ub"
valgrind=
-if [ ! -d testdata ] ; then
- ln -s @top_srcdir@/testdata testdata
+testdata=testdata
+
+if [ -n "$srcdir" -a -d "$srcdir/testdata" ] ; then
+ testdata="$srcdir/testdata"
fi
-testdata=./testdata
while [ $# -gt 0 ] ; do
case $1 in
diff --git a/RunTest.in b/RunTest
index a543a13..7aeb101 100755
--- a/RunTest.in
+++ b/RunTest
@@ -5,12 +5,13 @@
# Run PCRE tests
-cf=diff
+cf="diff -u"
valgrind=
-if [ ! -d testdata ] ; then
- ln -s @top_srcdir@/testdata testdata
+testdata=testdata
+
+if [ -n "$srcdir" -a -d "$srcdir" ] ; then
+ testdata="$srcdir/testdata"
fi
-testdata=./testdata
# Find which optional facilities are available
diff --git a/config-cmake.h.in b/config-cmake.h.in
new file mode 100644
index 0000000..a17e2fa
--- /dev/null
+++ b/config-cmake.h.in
@@ -0,0 +1,29 @@
+/* config.h for CMake builds */
+
+#cmakedefine HAVE_DIRENT_H
+#cmakedefine HAVE_UNISTD_H
+#cmakedefine HAVE_SYS_STAT_H
+#cmakedefine HAVE_SYS_TYPES_H
+#cmakedefine HAVE_TYPE_TRAITS_H
+#cmakedefine HAVE_BITS_TYPE_TRAITS_H
+
+#cmakedefine HAVE_BCOPY
+#cmakedefine HAVE_MEMMOVE
+#cmakedefine HAVE_STRERROR
+
+#cmakedefine SUPPORT_UTF8
+#cmakedefine SUPPORT_UCP
+#cmakedefine EBCDIC
+#cmakedefine NO_RECURSE
+
+#define NEWLINE @NEWLINE@
+#define POSIX_MALLOC_THRESHOLD @PCRE_POSIX_MALLOC_THRESHOLD@
+#define LINK_SIZE @PCRE_LINK_SIZE@
+#define MATCH_LIMIT @PCRE_MATCH_LIMIT@
+#define MATCH_LIMIT_RECURSION @PCRE_MATCH_LIMIT_RECURSION@
+
+#define MAX_NAME_SIZE 32
+#define MAX_NAME_COUNT 10000
+#define MAX_DUPLENGTH 30000
+
+/* end config.h for CMake builds */
diff --git a/configure.ac b/configure.ac
index 65a9ca8..72b0793 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,7 @@ AC_PROG_CXX
AC_PROG_INSTALL
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
+AC_PROG_LN_S
PCRE_MAJOR="pcre_major"
PCRE_MINOR="pcre_minor"
@@ -155,7 +156,7 @@ fi
# Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled.
#
-if test "x$enable_ebcdie" = "xyes"
+if test "x$enable_ebcdic" = "xyes"
then
enable_rebuild_chartables=yes
fi
@@ -388,8 +389,6 @@ AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
# Produce these files, in addition to config.h.
AC_CONFIG_FILES(
Makefile
- RunGrepTest
- RunTest
libpcre.pc
libpcrecpp.pc
pcre-config
@@ -399,14 +398,13 @@ AC_CONFIG_FILES(
)
# Make the generated script files executable.
-AC_CONFIG_COMMANDS([script-chmod], [chmod a+x RunTest RunGrepTest pcre-config])
-
-AC_OUTPUT
+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])
-rm -f pcre_chartables.c
+AC_OUTPUT
# Print out a nice little message after configure is run displaying your
# chosen options.
diff --git a/pcre_exec.c b/pcre_exec.c
index 3c3e780..f8e325d 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -48,6 +48,11 @@ possible. There are also some static supporting functions. */
#include "pcre_internal.h"
+/* Undefine some potentially clashing cpp symbols */
+
+#undef min
+#undef max
+
/* The chain of eptrblocks for tail recursions uses memory in stack workspace,
obtained at top level, the size of which is defined by EPTR_WORK_SIZE. */
diff --git a/pcre_internal.h b/pcre_internal.h
index fa7cff8..a59e4db 100644
--- a/pcre_internal.h
+++ b/pcre_internal.h
@@ -181,7 +181,7 @@ must begin with PCRE_. */
/* Include the public PCRE header and the definitions of UCP character property
values. */
-#include "pcre.h"
+#include <pcre.h>
#include "ucp.h"
/* When compiling for use with the Virtual Pascal compiler, these functions
@@ -202,9 +202,9 @@ define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY
is set. Otherwise, include an emulating function for those systems that have
neither (there some non-Unix environments where this is the case). */
-#if ! HAVE_MEMMOVE
+#ifndef HAVE_MEMMOVE
#undef memmove /* some systems may have a macro */
-#if HAVE_BCOPY
+#ifdef HAVE_BCOPY
#define memmove(a, b, c) bcopy(b, a, c)
#else /* HAVE_BCOPY */
static void *
diff --git a/pcrecpp.cc b/pcrecpp.cc
index 868b8e3..3fb7411 100644
--- a/pcrecpp.cc
+++ b/pcrecpp.cc
@@ -44,7 +44,7 @@
// We need this to compile the proper dll on windows/msys. This is copied
// from pcre_internal.h. It would probably be better just to include that.
#define PCRE_DEFINITION /* Win32 __declspec(export) trigger for .dll */
-#include "pcre.h"
+#include <pcre.h>
#include "pcre_stringpiece.h"
#include "pcrecpp.h"
diff --git a/pcregrep.c b/pcregrep.c
index 8c768e1..1750f20 100644
--- a/pcregrep.c
+++ b/pcregrep.c
@@ -50,9 +50,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
-#include "pcre.h"
+#include <pcre.h>
#define FALSE 0
#define TRUE 1
@@ -463,7 +465,7 @@ return FALSE;
-#if ! HAVE_STRERROR
+#ifndef HAVE_STRERROR
/*************************************************
* Provide strerror() for non-ANSI libraries *
*************************************************/