ChangeLog | 2 +- Makefile.am | 9 +++--- configure.ac | 6 ++-- pcre-config.in | 23 +++------------ pcre_info.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pcrecpp.cc | 6 ++++ pcrecpp.h | 2 ++ pcreposix.h | 13 ++++++--- 8 files changed, 120 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 359b412..e63e889 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2535,7 +2535,7 @@ Version 7.7 07-May-08 18. Changed CMakeLists.txt and cmake/FindReadline.cmake to arrange for the ncurses library to be included for pcretest when ReadLine support is requested, but also to allow for it to be overridden. This patch came from - Daniel Bergström. + Daniel Bergström. 19. There was a typo in the file ucpinternal.h where f0_rangeflag was defined as 0x00f00000 instead of 0x00800000. Luckily, this would not have caused diff --git a/Makefile.am b/Makefile.am index 5f640b0..53e0773 100644 --- a/Makefile.am +++ b/Makefile.am @@ -233,6 +233,7 @@ libpcre_la_SOURCES = \ pcre_fullinfo.c \ pcre_get.c \ pcre_globals.c \ + pcre_info.c \ pcre_internal.h \ pcre_jit_compile.c \ pcre_maketables.c \ @@ -459,19 +460,19 @@ TESTS += pcrecpp_unittest noinst_PROGRAMS += pcrecpp_unittest pcrecpp_unittest_SOURCES = pcrecpp_unittest.cc pcrecpp_unittest_CXXFLAGS = $(AM_CXXFLAGS) -pcrecpp_unittest_LDADD = libpcrecpp.la +pcrecpp_unittest_LDADD = libpcrecpp.la libpcre.la TESTS += pcre_scanner_unittest noinst_PROGRAMS += pcre_scanner_unittest pcre_scanner_unittest_SOURCES = pcre_scanner_unittest.cc pcre_scanner_unittest_CXXFLAGS = $(AM_CXXFLAGS) -pcre_scanner_unittest_LDADD = libpcrecpp.la +pcre_scanner_unittest_LDADD = libpcrecpp.la libpcre.la TESTS += pcre_stringpiece_unittest noinst_PROGRAMS += pcre_stringpiece_unittest pcre_stringpiece_unittest_SOURCES = pcre_stringpiece_unittest.cc pcre_stringpiece_unittest_CXXFLAGS = $(AM_CXXFLAGS) -pcre_stringpiece_unittest_LDADD = libpcrecpp.la +pcre_stringpiece_unittest_LDADD = libpcrecpp.la libpcre.la if WITH_GCOV libpcrecpp_la_CXXFLAGS += $(GCOV_CXXFLAGS) @@ -647,7 +648,7 @@ test: check ; # nice DLL for Windows use". (It is used by the pcre.dll target.) DLL_OBJS= pcre_byte_order.o pcre_compile.o pcre_config.o \ pcre_dfa_exec.o pcre_exec.o pcre_fullinfo.o pcre_get.o \ - pcre_globals.o pcre_jit_compile.o pcre_maketables.o \ + pcre_globals.o pcre_info.o pcre_jit_compile.o pcre_maketables.o \ pcre_newline.o pcre_ord2utf8.o pcre_refcount.o \ pcre_study.o pcre_tables.o pcre_ucd.o \ pcre_valid_utf8.o pcre_version.o pcre_chartables.o \ diff --git a/configure.ac b/configure.ac index 38d1dba..c7cbc9d 100644 --- a/configure.ac +++ b/configure.ac @@ -17,11 +17,11 @@ m4_define(pcre_date, [2015-04-28]) # 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:5:2]) +m4_define(libpcre_version, [18:5:15]) m4_define(libpcre16_version, [2:5:2]) m4_define(libpcre32_version, [0:5:0]) -m4_define(libpcreposix_version, [0:3:0]) -m4_define(libpcrecpp_version, [0:1:0]) +m4_define(libpcreposix_version, [18:3:15]) +m4_define(libpcrecpp_version, [3:1:0]) AC_PREREQ(2.57) AC_INIT(PCRE, pcre_major.pcre_minor[]pcre_prerelease, , pcre) diff --git a/pcre-config.in b/pcre-config.in index ac06a33..936b447 100644 --- a/pcre-config.in +++ b/pcre-config.in @@ -32,21 +32,6 @@ if test $# -eq 0; then exit 1 fi -libR= -case `uname -s` in - *SunOS*) - libR=" -R@libdir@" - ;; - *BSD*) - libR=" -Wl,-R@libdir@" - ;; -esac - -libS= -if test @libdir@ != /usr/lib ; then - libS=-L@libdir@ -fi - while test $# -gt 0; do case "$1" in -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; @@ -91,21 +76,21 @@ while test $# -gt 0; do ;; --libs-posix) if test @enable_pcre8@ = yes ; then - echo $libS$libR -lpcreposix -lpcre + echo -lpcreposix -lpcre else echo "${usage}" 1>&2 fi ;; --libs) if test @enable_pcre8@ = yes ; then - echo $libS$libR -lpcre + echo -lpcre else echo "${usage}" 1>&2 fi ;; --libs16) if test @enable_pcre16@ = yes ; then - echo $libS$libR -lpcre16 + echo -lpcre16 else echo "${usage}" 1>&2 fi @@ -119,7 +104,7 @@ while test $# -gt 0; do ;; --libs-cpp) if test @enable_cpp@ = yes ; then - echo $libS$libR -lpcrecpp -lpcre + echo -lpcrecpp -lpcre else echo "${usage}" 1>&2 fi diff --git a/pcre_info.c b/pcre_info.c new file mode 100644 index 0000000..17dafea --- /dev/null +++ b/pcre_info.c @@ -0,0 +1,90 @@ +/************************************************* +* 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-2009 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 the external function pcre_info(), which gives some +information about a compiled pattern. However, use of this function is now +deprecated, as it has been superseded by pcre_fullinfo(). */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "pcre_internal.h" + + +/************************************************* +* (Obsolete) Return info about compiled pattern * +*************************************************/ + +/* This is the original "info" function. It picks potentially useful data out +of the private structure, but its interface was too rigid. It remains for +backwards compatibility. The public options are passed back in an int - though +the re->options field has been expanded to a long int, all the public options +at the low end of it, and so even on 16-bit systems this will still be OK. +Therefore, I haven't changed the API for pcre_info(). + +Arguments: + argument_re points to compiled code + optptr where to pass back the options + first_byte where to pass back the first character, + or -1 if multiline and all branches start ^, + or -2 otherwise + +Returns: number of capturing subpatterns + or negative values on error +*/ + +PCRE_EXP_DEFN int PCRE_CALL_CONVENTION +pcre_info(const pcre *argument_re, int *optptr, int *first_byte) +{ +const real_pcre *re = (const real_pcre *)argument_re; +if (re == NULL) return PCRE_ERROR_NULL; +if (re->magic_number != MAGIC_NUMBER) + return PCRE_ERROR_BADMAGIC; + +if (optptr != NULL) *optptr = (int)(re->options & PUBLIC_COMPILE_OPTIONS); +if (first_byte != NULL) + *first_byte = ((re->flags & PCRE_FIRSTSET) != 0)? re->first_char : + ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2; +return re->top_bracket; +} + +/* End of pcre_info.c */ diff --git a/pcrecpp.cc b/pcrecpp.cc index c595cbc..1b8ebd2 100644 --- a/pcrecpp.cc +++ b/pcrecpp.cc @@ -80,6 +80,12 @@ static const string empty_string; // If the user doesn't ask for any options, we just use this one static RE_Options default_options; +// PCRE6.x compatible API +void RE::Init(const char *c_pat, const RE_Options* options) { + const string cxx_pat(c_pat); + Init(cxx_pat, options); +} + void RE::Init(const string& pat, const RE_Options* options) { pattern_ = pat; if (options == NULL) { diff --git a/pcrecpp.h b/pcrecpp.h index 3e594b0..a520057 100644 --- a/pcrecpp.h +++ b/pcrecpp.h @@ -658,6 +658,8 @@ class PCRECPP_EXP_DEFN RE { private: void Init(const string& pattern, const RE_Options* options); + // Old version from PCRE 6.x, for compatibility + void Init(const char *pattern, const RE_Options* options); void Cleanup(); // Match against "text", filling in "vec" (up to "vecsize" * 2/3) with diff --git a/pcreposix.h b/pcreposix.h index c77c0b0..4527f78 100644 --- a/pcreposix.h +++ b/pcreposix.h @@ -133,14 +133,19 @@ file. */ /* The functions */ -PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int); -PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t, +PCREPOSIX_EXP_DECL int pcreposix_regcomp(regex_t *, const char *, int); +PCREPOSIX_EXP_DECL int pcreposix_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 *); +PCREPOSIX_EXP_DECL size_t pcreposix_regerror(int, const regex_t *, char *, size_t); +PCREPOSIX_EXP_DECL void pcreposix_regfree(regex_t *); #ifdef __cplusplus } /* extern "C" */ #endif +#define regcomp pcreposix_regcomp +#define regexec pcreposix_regexec +#define regerror pcreposix_regerror +#define regfree pcreposix_regfree + #endif /* End of pcreposix.h */