1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Upgrading libpcre from version 7.2 to 7.4. Tested on Linux and Windows

This commit is contained in:
kris
2007-12-20 22:24:53 +00:00
parent aa94d1e9d1
commit a1654beda6
38 changed files with 1728 additions and 712 deletions

View File

@@ -42,6 +42,8 @@ o Nmap's output options (-oA, -oX, etc.) now support strftime()-like
means that "-oX 'scan-%T-%D.xml'" uses an XML file in the form of means that "-oX 'scan-%T-%D.xml'" uses an XML file in the form of
"scan-144840-121307.xml". [Kris] "scan-144840-121307.xml". [Kris]
o Upgraded the shipped LibPCRE from version 7.2 to 7.4 [Kris]
o Added a new NSE script (MySQLinfo) which prints MySQL server information o Added a new NSE script (MySQLinfo) which prints MySQL server information
such as the protocol and version numbers, status, thread id, capabilities, such as the protocol and version numbers, status, thread id, capabilities,
and password salt. [Kris] and password salt. [Kris]

View File

@@ -80,4 +80,3 @@ nodist_libpcre_a_SOURCES = pcre_chartables.c
# A compatibility line, the old build system worked with 'make test' # A compatibility line, the old build system worked with 'make test'
test: check ; test: check ;
## end Makefile.am

View File

@@ -40,10 +40,12 @@ noinst_PROGRAMS = $(am__EXEEXT_1)
@WITH_REBUILD_CHARTABLES_TRUE@am__append_1 = dftables @WITH_REBUILD_CHARTABLES_TRUE@am__append_1 = dftables
subdir = . subdir = .
DIST_COMMON = README $(am__configure_deps) $(include_HEADERS) \ DIST_COMMON = README $(am__configure_deps) $(include_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/../config.guess $(srcdir)/../config.sub \
$(srcdir)/config.h.in $(srcdir)/pcre-config.in \ $(srcdir)/../depcomp $(srcdir)/../install-sh \
$(srcdir)/pcre.h.in $(top_srcdir)/configure AUTHORS INSTALL \ $(srcdir)/../missing $(srcdir)/Makefile.am \
config.guess config.sub depcomp install-sh missing $(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(srcdir)/pcre-config.in $(srcdir)/pcre.h.in \
$(top_srcdir)/configure AUTHORS INSTALL
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -92,7 +94,7 @@ dftables_LDADD = $(LDADD)
binSCRIPT_INSTALL = $(INSTALL_SCRIPT) binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
SCRIPTS = $(bin_SCRIPTS) SCRIPTS = $(bin_SCRIPTS)
DEFAULT_INCLUDES = -I.@am__isrc@ DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp depcomp = $(SHELL) $(top_srcdir)/../depcomp
am__depfiles_maybe = depfiles am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

View File

@@ -1,4 +1,4 @@
This directory conains a version of LibPCRE 7.2 that has been stripped This directory contains a version of LibPCRE 7.4 that has been stripped
down to less than a third of its original uncompressed size. So if you down to less than a third of its original uncompressed size. So if you
want docs, tests and such, you should go to the PCRE website at want docs, tests and such, you should go to the PCRE website at
http://www.pcre.org . Here are the changes for the Nmap version: http://www.pcre.org . Here are the changes for the Nmap version:
@@ -30,13 +30,14 @@ makevp_c.txt
makevp_l.txt makevp_l.txt
pcregexp.pas pcregexp.pas
ltmain.sh ltmain.sh
CleanTxt
ChangeLog ChangeLog
NEWS NEWS
HACKING HACKING
COPYING [Look at LICENCE] COPYING [Look at LICENCE]
o Got rid of the C++ wrapper, which included this step: o Got rid of the C++ wrapper, which included this step:
rm -f *.cc pcrecpparg.h.in pcrecpp.h pcre_scanner.h pcre_stringpiece.h.in rm -f *.cc pcrecpparg.h.in pcrecpp.h pcrecpp_internal.h pcre_scanner.h pcre_stringpiece.h.in
o Copied pcre.h.generic to pcre.h and pcre_chartables.c.dist to, you o Copied pcre.h.generic to pcre.h and pcre_chartables.c.dist to, you
guessed it, pcre_chartables.c (for Windows). Running ./configure in guessed it, pcre_chartables.c (for Windows). Running ./configure in
@@ -56,17 +57,17 @@ o Stripped down Makefile.am and configure.ac substantially to remove
o Removed config.sub, config.guess, depcomp, install-sh, and missing. o Removed config.sub, config.guess, depcomp, install-sh, and missing.
These files are found in the parent (i.e., Nmap's) directory. These files are found in the parent (i.e., Nmap's) directory.
o Comment out some build configuration lines from pcre-internal.h because Nmap o Comment out some build configuration lines from pcre_internal.h because Nmap
builds a static library: builds a static library:
--- pcre-7.2/pcre_internal.h 2007-06-12 08:39:55.000000000 -0500 --- pcre-7.4/pcre_internal.h 2007-09-13 04:22:27.000000000 -0500
+++ libpcre/pcre_internal.h 2007-08-15 18:56:18.000000000 -0500 +++ libpcre/pcre_internal.h 2007-12-19 22:28:33.000000000 -0600
@@ -112,15 +112,19 @@ PCRE_EXP_DATA_DEFN only if they are not @@ -108,15 +108,19 @@ PCRE_EXP_DATA_DEFN only if they are not
#ifndef PCRE_EXP_DECL #ifndef PCRE_EXP_DECL
# ifdef _WIN32 # ifdef _WIN32
+/* COMMENTED OUT AS IT'S COMPILED STATICALLY +/* COMMENTED OUT AS IT'S COMPILED STATICALLY
# ifdef DLL_EXPORT # ifndef PCRE_STATIC
# define PCRE_EXP_DECL extern __declspec(dllexport) # define PCRE_EXP_DECL extern __declspec(dllexport)
# define PCRE_EXP_DEFN __declspec(dllexport) # define PCRE_EXP_DEFN __declspec(dllexport)
# define PCRE_EXP_DATA_DEFN __declspec(dllexport) # define PCRE_EXP_DATA_DEFN __declspec(dllexport)
@@ -78,25 +79,25 @@ o Comment out some build configuration lines from pcre-internal.h because Nmap
+/* +/*
# endif # endif
+*/ +*/
#
# else # else
# ifdef __cplusplus # ifdef __cplusplus
# define PCRE_EXP_DECL extern "C"
...and pcre.h.in/pcre.h.generic/pcre.h: ...and pcre.h.in/pcre.h.generic/pcre.h:
--- pcre-7.2/pcre.h.in 2007-06-04 05:18:02.000000000 -0500 --- pcre-7.4/pcre.h.in 2007-09-11 06:24:35.000000000 -0500
+++ libpcre/pcre.h.in 2007-08-15 19:24:46.000000000 -0500 +++ libpcre/pcre.h.in 2007-12-19 22:30:32.000000000 -0600
@@ -51,6 +51,7 @@ imported have to be identified as such. @@ -51,6 +51,7 @@ imported have to be identified as such.
export setting is defined in pcre_internal.h, which includes this file. So we export setting is defined in pcre_internal.h, which includes this file. So we
don't change an existing definition of PCRE_EXP_DECL. */ don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
+/* +/*
#if defined(_WIN32) && !defined(PCRE_STATIC)
# ifndef PCRE_EXP_DECL # ifndef PCRE_EXP_DECL
# ifdef _WIN32 # define PCRE_EXP_DECL extern __declspec(dllimport)
# ifndef PCRE_STATIC @@ -64,6 +65,7 @@ don't change existing definitions of PCR
@@ -58,6 +59,7 @@ don't change an existing definition of P
# endif # endif
# endif # endif
#endif #endif
@@ -108,44 +109,41 @@ o Comment out some build configuration lines from pcre-internal.h because Nmap
..and pcreposix.h: ..and pcreposix.h:
--- pcre-7.2/pcreposix.h 2007-04-04 09:04:40.000000000 -0500 --- pcre-7.4/pcreposix.h 2007-08-01 04:06:39.000000000 -0500
+++ libpcre/pcreposix.h 2007-08-15 20:31:42.000000000 -0500 +++ libpcre/pcreposix.h 2007-12-19 22:31:14.000000000 -0600
@@ -109,12 +109,14 @@ typedef struct { @@ -110,10 +110,12 @@ imported have to be identified as such.
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
export settings are needed. */ file. */
+/* +/*
#ifdef _WIN32 #if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL)
# ifndef PCREPOSIX_STATIC
# define PCREPOSIX_EXP_DECL extern __declspec(dllimport) # define PCREPOSIX_EXP_DECL extern __declspec(dllimport)
# define PCREPOSIX_EXP_DEFN __declspec(dllimport) # define PCREPOSIX_EXP_DEFN __declspec(dllimport)
#endif #endif
#endif
+*/ +*/
/* By default, we use the standard "extern" declarations. */ /* By default, we use the standard "extern" declarations. */
o Added pcre_winconfig.h, and include it in pcre_internal.h instead of config.h: o Added pcre_winconfig.h for Windows. LibPCRE used to include config.h in
pcre_internal.h, and we'd include this winconfig there instead of config.h
if WIN32 is defined. Now, however, they've moved config.h includes to a
bunch of different files, so we have to change them. We could remove the
other includes and move it back to pcre_internal.h, but they must've moved
them for a reason, so we'll follow them. Occurrences of
--- pcre-7.2/pcre_internal.h 2007-06-12 08:39:55.000000000 -0500 #ifdef HAVE_CONFIG_H
+++ libpcre/pcre_internal.h 2007-08-15 20:33:48.000000000 -0500
@@ -69,7 +69,11 @@ be absolutely sure we get our version. *
/* Get the definitions provided by running "configure" */
+#ifdef WIN32
+#include "pcre_winconfig.h"
+#else
#include "config.h" #include "config.h"
+#endif #endif
/* Standard C headers plus the external interface definition. The only time get changed to
setjmp and stdarg are used is when NO_RECURSE is set. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
o Change the pcre.h #include in pcre_internal.h from <pcre.h> to "pcre.h".
This seems to be needed on Windows.
o Regenerated everything with 'automake; aclocal; autoconf' o Regenerated everything with 'automake; aclocal; autoconf'

View File

@@ -7,14 +7,16 @@ This document contains the following sections:
Generic instructions for the PCRE C library Generic instructions for the PCRE C library
The C++ wrapper functions The C++ wrapper functions
Building for virtual Pascal Building for virtual Pascal
Stack size in Windows environments
Comments about Win32 builds Comments about Win32 builds
Building PCRE with CMake
Building under Windows with BCC5.5 Building under Windows with BCC5.5
Building PCRE on OpenVMS Building PCRE on OpenVMS
GENERAL GENERAL
I (Philip Hazel) have no knowledge of Windows or VMS sytems and how their I (Philip Hazel) have no experience of Windows or VMS sytems and how their
libraries work. The items in the PCRE distribution and Makefile that relate to libraries work. The items in the PCRE distribution and Makefile that relate to
anything other than Unix-like systems are untested by me. anything other than Unix-like systems are untested by me.
@@ -29,9 +31,10 @@ 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++ successfully on any system that has a Standard C compiler and library. The C++
wrapper functions are a separate issue (see below). wrapper functions are a separate issue (see below).
The PCRE distribution contains some experimental support for "cmake", but this The PCRE distribution includes support for CMake. This support is relatively
is incomplete and not documented. However if you are a "cmake" user you might new, but has already been used successfully to build PCRE in multiple build
like to try building with "cmake". environments on Windows. There are some instructions in the section entitled
"Building PCRE with CMake" below.
GENERIC INSTRUCTIONS FOR THE PCRE C LIBRARY GENERIC INSTRUCTIONS FOR THE PCRE C LIBRARY
@@ -41,16 +44,19 @@ The following are generic comments about building the PCRE C library "by hand".
(1) Copy or rename the file config.h.generic as config.h, and edit the macro (1) Copy or rename the file config.h.generic as config.h, and edit the macro
settings that it contains to whatever is appropriate for your environment. settings that it contains to whatever is appropriate for your environment.
In particular, if you want to force a specific value for newline, you can In particular, if you want to force a specific value for newline, you can
define the NEWLINE macro. define the NEWLINE macro. When you compile any of the PCRE modules, you
must specify -DHAVE_CONFIG_H to your compiler so that config.h is included
in the sources.
An alternative approach is not to edit config.h, but to use -D on the An alternative approach is not to edit config.h, but to use -D on the
compiler command line to make any changes that you need. compiler command line to make any changes that you need to the
configuration options. In this case -DHAVE_CONFIG_H must not be set.
NOTE: There have been occasions when the way in which certain parameters in NOTE: There have been occasions when the way in which certain parameters
config.h are used has changed between releases. (In the configure/make in config.h are used has changed between releases. (In the configure/make
world, this is handled automatically.) When upgrading to a new release, you world, this is handled automatically.) When upgrading to a new release,
are strongly advised to review config.h.generic before re-using what you you are strongly advised to review config.h.generic before re-using what
had previously. you had previously.
(2) Copy or rename the file pcre.h.generic as pcre.h. (2) Copy or rename the file pcre.h.generic as pcre.h.
@@ -58,18 +64,33 @@ The following are generic comments about building the PCRE C library "by hand".
Copy or rename file pcre_chartables.c.dist as pcre_chartables.c. Copy or rename file pcre_chartables.c.dist as pcre_chartables.c.
OR: OR:
Compile dftables.c as a stand-alone program, and then run it with the Compile dftables.c as a stand-alone program (using -DHAVE_CONFIG_H if
single argument "pcre_chartables.c". This generates a set of standard you have set up config.h), and then run it with the single argument
character tables and writes them to that file. The tables are generated "pcre_chartables.c". This generates a set of standard character tables
using the default C locale for your system. If you want to use a locale and writes them to that file. The tables are generated using the default
that is specified by LC_xxx environment variables, add the -L option to C locale for your system. If you want to use a locale that is specified
the dftables command. You must use this method if you are building on by LC_xxx environment variables, add the -L option to the dftables
a system that uses EBCDIC code. command. You must use this method if you are building on a system that
uses EBCDIC code.
The tables in pcre_chartables.c are defaults. The caller of PCRE can The tables in pcre_chartables.c are defaults. The caller of PCRE can
specify alternative tables at run time. specify alternative tables at run time.
(4) Compile the following source files: (4) Ensure that you have the following header files:
pcre_internal.h
ucp.h
ucpinternal.h
ucptable.h
(5) Also ensure that you have the following file, which is #included as source
when building a debugging version of PCRE and is also used by pcretest.
pcre_printint.src
(6) Compile the following source files, setting -DHAVE_CONFIG_H as a compiler
option if you have set up config.h with your configuration, or else use
other -D settings to change the configuration as required.
pcre_chartables.c pcre_chartables.c
pcre_compile.c pcre_compile.c
@@ -92,24 +113,33 @@ The following are generic comments about building the PCRE C library "by hand".
pcre_version.c pcre_version.c
pcre_xclass.c pcre_xclass.c
Now link them all together into an object library in whichever form your Make sure that you include -I. in the compiler command (or equivalent for
system keeps such libraries. This is the basic PCRE C library. If your an unusual compiler) so that all included PCRE header files are first
system has static and shared libraries, you may have to do this once for sought in the current directory. Otherwise you run the risk of picking up
each type. a previously-installed file from somewhere else.
(5) Similarly, compile pcreposix.c and link it (on its own) as the pcreposix (7) Now link all the compiled code into an object library in whichever form
library. your system keeps such libraries. This is the basic PCRE C library. If
your system has static and shared libraries, you may have to do this once
for each type.
(6) Compile the test program pcretest.c. This needs the functions in the (8) Similarly, compile pcreposix.c (remembering -DHAVE_CONFIG_H if necessary)
pcre and pcreposix libraries when linking. and link the result (on its own) as the pcreposix library.
(7) Run pcretest on the testinput files in the testdata directory, and check (9) Compile the test program pcretest.c (again, don't forget -DHAVE_CONFIG_H).
This needs the functions in the pcre and pcreposix libraries when linking.
It also needs the pcre_printint.src source file, which it #includes.
(10) Run pcretest on the testinput files in the testdata directory, and check
that the output matches the corresponding testoutput files. Note that the that the output matches the corresponding testoutput files. Note that the
supplied files are in Unix format, with just LF characters as line supplied files are in Unix format, with just LF characters as line
terminators. You may need to edit them to change this if your system uses a terminators. You may need to edit them to change this if your system uses
different convention. a different convention. If you are using Windows, you probably should use
the wintestinput3 file instead of testinput3 (and the corresponding output
file). This is a locale test; wintestinput3 sets the locale to "french"
rather than "fr_FR", and there some minor output differences.
(8) If you want to use the pcregrep command, compile and link pcregrep.c; it (11) If you want to use the pcregrep command, compile and link pcregrep.c; it
uses only the basic PCRE library (it does not need the pcreposix library). uses only the basic PCRE library (it does not need the pcreposix library).
@@ -131,7 +161,23 @@ additional files. The following files in the distribution are for building PCRE
for use with VP/Borland: makevp_c.txt, makevp_l.txt, makevp.bat, pcregexp.pas. for use with VP/Borland: makevp_c.txt, makevp_l.txt, makevp.bat, pcregexp.pas.
COMMENTS ABOUT WIN32 BUILDS STACK SIZE IN WINDOWS ENVIRONMENTS
The default processor stack size of 1Mb in some Windows environments is too
small for matching patterns that need much recursion. In particular, test 2 may
fail because of this. Normally, running out of stack causes a crash, but there
have been cases where the test program has just died silently. See your linker
documentation for how to increase stack size if you experience problems. The
Linux default of 8Mb is a reasonable choice for the stack, though even that can
be too small for some pattern/subject combinations.
PCRE has a compile configuration option to disable the use of stack for
recursion so that heap is used instead. However, pattern matching is
significantly slower when this is done. There is more about stack usage in the
"pcrestack" documentation.
COMMENTS ABOUT WIN32 BUILDS (see also "BUILDING PCRE WITH CMAKE" below)
There are two ways of building PCRE using the "configure, make, make install" There are two ways of building PCRE using the "configure, make, make install"
paradigm on Windows systems: using MinGW or using Cygwin. These are not at all paradigm on Windows systems: using MinGW or using Cygwin. These are not at all
@@ -206,6 +252,60 @@ terminators in order to get some of the tests to work. We hope to improve
things in this area in future. things in this area in future.
BUILDING PCRE WITH CMAKE
CMake is an alternative build facility that can be used instead of the
traditional Unix "configure". CMake version 2.4.7 supports Borland makefiles,
MinGW makefiles, MSYS makefiles, NMake makefiles, UNIX makefiles, Visual Studio
6, Visual Studio 7, Visual Studio 8, and Watcom W8. The following instructions
were contributed by a PCRE user.
1. Download CMake 2.4.7 or above from http://www.cmake.org/, install and ensure
that cmake\bin is on your path.
2. Unzip (retaining folder structure) the PCRE source tree into a source
directory such as C:\pcre.
3. Create a new, empty build directory: C:\pcre\build\
4. Run CMakeSetup from the Shell envirornment of your build tool, e.g., Msys
for Msys/MinGW or Visual Studio Command Prompt for VC/VC++
5. Enter C:\pcre\pcre-xx and C:\pcre\build for the source and build
directories, respectively
6. Hit the "Configure" button.
7. Select the particular IDE / build tool that you are using (Visual Studio,
MSYS makefiles, MinGW makefiles, etc.)
8. The GUI will then list several configuration options. This is where you can
enable UTF-8 support, etc.
9. Hit "Configure" again. The adjacent "OK" button should now be active.
10. Hit "OK".
11. The build directory should now contain a usable build system, be it a
solution file for Visual Studio, makefiles for MinGW, etc.
Testing with RunTest.bat
1. Copy RunTest.bat into the directory where pcretest.exe has been created.
2. Edit RunTest.bat and insert a line that indentifies the relative location of
the pcre source, e.g.:
set srcdir=..\pcre-7.4-RC3
3. Run RunTest.bat from a command shell environment. Test outputs will
automatically be compared to expected results, and discrepancies will
identified in the console output.
4. To test pcrecpp, run pcrecpp_unittest.exe, pcre_stringpiece_unittest.exe and
pcre_scanner_unittest.exe.
BUILDING UNDER WINDOWS WITH BCC5.5 BUILDING UNDER WINDOWS WITH BCC5.5
Michael Roy sent these comments about building PCRE under Windows with BCC5.5: Michael Roy sent these comments about building PCRE under Windows with BCC5.5:
@@ -284,5 +384,5 @@ $! Locale could not be set to fr
$! $!
========================= =========================
Last Updated: 13 June 2007 Last Updated: 21 September 2007
**** ****

View File

@@ -103,7 +103,9 @@ Building PCRE on non-Unix systems
For a non-Unix system, please read the comments in the file NON-UNIX-USE, For a non-Unix system, please read the comments in the file NON-UNIX-USE,
though if your system supports the use of "configure" and "make" you may be though if your system supports the use of "configure" and "make" you may be
able to build PCRE in the same way as for Unix-like systems. able to build PCRE in the same way as for Unix-like systems. PCRE can also be
configured in many platform environments using the GUI facility of CMake's
CMakeSetup. It creates Makefiles, solution files, etc.
PCRE has been compiled on many different operating systems. It should be PCRE has been compiled on many different operating systems. It should be
straightforward to build PCRE on any system that has a Standard C compiler and straightforward to build PCRE on any system that has a Standard C compiler and
@@ -184,6 +186,12 @@ library. You can read more about them in the pcrebuild man page.
--enable-newline-is-any, many tests should succeed, but there may be some --enable-newline-is-any, many tests should succeed, but there may be some
failures. failures.
. By default, the sequence \R in a pattern matches any Unicode line ending
sequence. This is independent of the option specifying what PCRE considers to
be the end of a line (see above). However, the caller of PCRE can restrict \R
to match only CR, LF, or CRLF. You can make this the default by adding
--enable-bsr-anycrlf to the "configure" command (bsr = "backslash R").
. When called via the POSIX interface, PCRE uses malloc() to get additional . When called via the POSIX interface, PCRE uses malloc() to get additional
storage for processing capturing parentheses if there are more than 10 of storage for processing capturing parentheses if there are more than 10 of
them in a pattern. You can increase this threshold by setting, for example, them in a pattern. You can increase this threshold by setting, for example,
@@ -500,7 +508,10 @@ in the comparison output, it means that locale is not available on your system,
despite being listed by "locale". This does not mean that PCRE is broken. despite being listed by "locale". This does not mean that PCRE is broken.
[If you are trying to run this test on Windows, you may be able to get it to [If you are trying to run this test on Windows, you may be able to get it to
work by changing "fr_FR" to "french" everywhere it occurs.] work by changing "fr_FR" to "french" everywhere it occurs. Alternatively, use
RunTest.bat. The version of RunTest.bat included with PCRE 7.4 and above uses
Windows versions of test 2. More info on using RunTest.bat is included in the
document entitled NON-UNIX-USE.]
The fourth test checks the UTF-8 support. It is not run automatically unless The fourth test checks the UTF-8 support. It is not run automatically unless
PCRE is built with UTF-8 support. To do this you must set --enable-utf8 when PCRE is built with UTF-8 support. To do this you must set --enable-utf8 when
@@ -714,4 +725,4 @@ The distribution should contain the following files:
Philip Hazel Philip Hazel
Email local part: ph10 Email local part: ph10
Email domain: cam.ac.uk Email domain: cam.ac.uk
Last updated: 24 April 2007 Last updated: 21 September 2007

View File

@@ -9,13 +9,24 @@ it to run on SunOS4 and other "close to standard" systems.
If you are going to build PCRE "by hand" on a system without "configure" you If you are going to build PCRE "by hand" on a system without "configure" you
should copy the distributed config.h.generic to config.h, and then set up the should copy the distributed config.h.generic to config.h, and then set up the
macros the way you need them. Alternatively, you can avoid editing by using -D macro definitions the way you need them. You must then add -DHAVE_CONFIG_H to
on the compiler command line to set the macro values. 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.
PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if
HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set
them both to 0; an emulation function will be used. */ them both to 0; an emulation function will be used. */
/* By default, the \R escape sequence matches any Unicode line ending
character or sequence of characters. If BSR_ANYCRLF is defined, 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. On systems that
support it, "configure" can be used to override the default. */
/* #undef BSR_ANYCRLF */
/* If you are compiling for a system that uses EBCDIC instead of ASCII /* If you are compiling for a system that uses EBCDIC instead of ASCII
character codes, define this macro as 1. On systems that can use character codes, define this macro as 1. On systems that can use
"configure", this can be done via --enable-ebcdic. */ "configure", this can be done via --enable-ebcdic. */
@@ -130,6 +141,9 @@ them both to 0; an emulation function will be used. */
/* Define to 1 if you have the <windows.h> header file. */ /* Define to 1 if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */ /* #undef HAVE_WINDOWS_H */
/* Define to 1 if you have the `_strtoi64' function. */
/* #undef HAVE__STRTOI64 */
/* The value of LINK_SIZE determines the number of bytes used to store links /* 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 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. compiled patterns up to 64K long. This covers the vast majority of cases.
@@ -164,13 +178,6 @@ them both to 0; an emulation function will be used. */
#define MATCH_LIMIT_RECURSION MATCH_LIMIT #define MATCH_LIMIT_RECURSION MATCH_LIMIT
#endif #endif
/* 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. */
#ifndef MAX_DUPLENGTH
#define MAX_DUPLENGTH 30000
#endif
/* This limit is parameterized just in case anybody ever wants to change it. /* 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 Care must be taken if it is increased, because it guards against integer
overflow caused by enormously large patterns. */ overflow caused by enormously large patterns. */
@@ -185,10 +192,10 @@ them both to 0; an emulation function will be used. */
#define MAX_NAME_SIZE 32 #define MAX_NAME_SIZE 32
#endif #endif
/* The value of NEWLINE determines the newline character sequence. On /* The value of NEWLINE determines the newline character sequence. On systems
Unix-like systems, "configure" can be used to override the default, which that support it, "configure" can be used to override the default, which is
is 10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), -1 (ANY), or 10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), -1 (ANY), or -2
-2 (ANYCRLF). */ (ANYCRLF). */
#ifndef NEWLINE #ifndef NEWLINE
#define NEWLINE 10 #define NEWLINE 10
#endif #endif
@@ -213,13 +220,13 @@ them both to 0; an emulation function will be used. */
#define PACKAGE_NAME "PCRE" #define PACKAGE_NAME "PCRE"
/* Define to the full name and version of this package. */ /* Define to the full name and version of this package. */
#define PACKAGE_STRING "PCRE 7.2" #define PACKAGE_STRING "PCRE 7.4"
/* Define to the one symbol short name of this package. */ /* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "pcre" #define PACKAGE_TARNAME "pcre"
/* Define to the version of this package. */ /* Define to the version of this package. */
#define PACKAGE_VERSION "7.2" #define PACKAGE_VERSION "7.4"
/* If you are compiling for a system other than a Unix-like system or /* If you are compiling for a system other than a Unix-like system or
@@ -261,7 +268,7 @@ them both to 0; an emulation function will be used. */
/* Version number of package */ /* Version number of package */
#ifndef VERSION #ifndef VERSION
#define VERSION "7.2" #define VERSION "7.4"
#endif #endif
/* Define to empty if `const' does not conform to ANSI C. */ /* Define to empty if `const' does not conform to ANSI C. */

View File

@@ -8,13 +8,24 @@ it to run on SunOS4 and other "close to standard" systems.
If you are going to build PCRE "by hand" on a system without "configure" you If you are going to build PCRE "by hand" on a system without "configure" you
should copy the distributed config.h.generic to config.h, and then set up the should copy the distributed config.h.generic to config.h, and then set up the
macros the way you need them. Alternatively, you can avoid editing by using -D macro definitions the way you need them. You must then add -DHAVE_CONFIG_H to
on the compiler command line to set the macro values. 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.
PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if
HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set
them both to 0; an emulation function will be used. */ them both to 0; an emulation function will be used. */
/* By default, the \R escape sequence matches any Unicode line ending
character or sequence of characters. If BSR_ANYCRLF is defined, 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. On systems that
support it, "configure" can be used to override the default. */
#undef BSR_ANYCRLF
/* If you are compiling for a system that uses EBCDIC instead of ASCII /* If you are compiling for a system that uses EBCDIC instead of ASCII
character codes, define this macro as 1. On systems that can use character codes, define this macro as 1. On systems that can use
"configure", this can be done via --enable-ebcdic. */ "configure", this can be done via --enable-ebcdic. */
@@ -23,15 +34,9 @@ them both to 0; an emulation function will be used. */
/* Define to 1 if you have the `bcopy' function. */ /* Define to 1 if you have the `bcopy' function. */
#undef HAVE_BCOPY #undef HAVE_BCOPY
/* Define to 1 if you have the <bits/type_traits.h> header file. */
#undef HAVE_BITS_TYPE_TRAITS_H
/* Define to 1 if you have the <dirent.h> header file. */ /* Define to 1 if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H #undef HAVE_DIRENT_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H #undef HAVE_INTTYPES_H
@@ -56,9 +61,6 @@ them both to 0; an emulation function will be used. */
/* Define to 1 if you have the `strerror' function. */ /* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR #undef HAVE_STRERROR
/* Define to 1 if you have the <string> header file. */
#undef HAVE_STRING
/* Define to 1 if you have the <strings.h> header file. */ /* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H #undef HAVE_STRINGS_H
@@ -77,9 +79,6 @@ them both to 0; an emulation function will be used. */
/* Define to 1 if you have the <sys/types.h> header file. */ /* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H #undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <type_traits.h> header file. */
#undef HAVE_TYPE_TRAITS_H
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H
@@ -89,6 +88,9 @@ them both to 0; an emulation function will be used. */
/* Define to 1 if you have the <windows.h> header file. */ /* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H #undef HAVE_WINDOWS_H
/* Define to 1 if you have the `_strtoi64' function. */
#undef HAVE__STRTOI64
/* The value of LINK_SIZE determines the number of bytes used to store links /* 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 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. compiled patterns up to 64K long. This covers the vast majority of cases.
@@ -97,6 +99,9 @@ them both to 0; an emulation function will be used. */
"configure" can be used to override this default. */ "configure" can be used to override this default. */
#undef LINK_SIZE #undef LINK_SIZE
/* Mac OS X on Intel */
#undef MACOSX
/* The value of MATCH_LIMIT determines the default number of times the /* The value of MATCH_LIMIT determines the default number of times the
internal match() function can be called during a single execution of internal match() function can be called during a single execution of
pcre_exec(). There is a runtime interface for setting a different limit. pcre_exec(). There is a runtime interface for setting a different limit.
@@ -117,11 +122,6 @@ them both to 0; an emulation function will be used. */
"configure" can be used to override the default. */ "configure" can be used to override the default. */
#undef MATCH_LIMIT_RECURSION #undef MATCH_LIMIT_RECURSION
/* 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. */
#undef MAX_DUPLENGTH
/* This limit is parameterized just in case anybody ever wants to change it. /* 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 Care must be taken if it is increased, because it guards against integer
overflow caused by enormously large patterns. */ overflow caused by enormously large patterns. */
@@ -132,10 +132,10 @@ them both to 0; an emulation function will be used. */
overflow caused by enormously large patterns. */ overflow caused by enormously large patterns. */
#undef MAX_NAME_SIZE #undef MAX_NAME_SIZE
/* The value of NEWLINE determines the newline character sequence. On /* The value of NEWLINE determines the newline character sequence. On systems
Unix-like systems, "configure" can be used to override the default, which that support it, "configure" can be used to override the default, which is
is 10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), -1 (ANY), or 10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), -1 (ANY), or -2
-2 (ANYCRLF). */ (ANYCRLF). */
#undef NEWLINE #undef NEWLINE
/* PCRE uses recursive function calls to handle backtracking while matching. /* PCRE uses recursive function calls to handle backtracking while matching.

58
libpcre/configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for PCRE 7.2. # Generated by GNU Autoconf 2.61 for PCRE 7.4.
# #
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@@ -572,8 +572,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package. # Identity of this package.
PACKAGE_NAME='PCRE' PACKAGE_NAME='PCRE'
PACKAGE_TARNAME='pcre' PACKAGE_TARNAME='pcre'
PACKAGE_VERSION='7.2' PACKAGE_VERSION='7.4'
PACKAGE_STRING='PCRE 7.2' PACKAGE_STRING='PCRE 7.4'
PACKAGE_BUGREPORT='' PACKAGE_BUGREPORT=''
ac_unique_file="pcre.h.in" ac_unique_file="pcre.h.in"
@@ -1226,7 +1226,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures PCRE 7.2 to adapt to many kinds of systems. \`configure' configures PCRE 7.4 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1296,7 +1296,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of PCRE 7.2:";; short | recursive ) echo "Configuration of PCRE 7.4:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@@ -1318,8 +1318,10 @@ Optional Features:
--enable-newline-is-anycrlf --enable-newline-is-anycrlf
use CR, LF, or CRLF as newline sequence use CR, LF, or CRLF as newline sequence
--enable-newline-is-any use any valid Unicode newline sequence --enable-newline-is-any use any valid Unicode newline sequence
--enable-ebcdic assume EBCDIC coding rather than ASCII (implies --enable-bsr-anycrlf \R matches only CR, LF, CRLF by default
--enable-rebuild-chartables) --enable-ebcdic assume EBCDIC coding rather than ASCII; use this
only in (uncommon) EBCDIC environments; it implies
--enable-rebuild-chartables
--disable-stack-for-recursion --disable-stack-for-recursion
don't use stack recursion when matching don't use stack recursion when matching
@@ -1407,7 +1409,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
PCRE configure 7.2 PCRE configure 7.4
generated by GNU Autoconf 2.61 generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1421,7 +1423,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by PCRE $as_me 7.2, which was It was created by PCRE $as_me 7.4, which was
generated by GNU Autoconf 2.61. Invocation command line was generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@ $ $0 $@
@@ -2112,7 +2114,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='pcre' PACKAGE='pcre'
VERSION='7.2' VERSION='7.4'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@@ -3563,9 +3565,9 @@ fi
PCRE_MAJOR="7" PCRE_MAJOR="7"
PCRE_MINOR="2" PCRE_MINOR="4"
PCRE_PRERELEASE="" PCRE_PRERELEASE=""
PCRE_DATE="2007-06-19" PCRE_DATE="2007-09-21"
@@ -3636,6 +3638,15 @@ fi
enable_newline="$ac_pcre_newline" enable_newline="$ac_pcre_newline"
# Handle --enable-bsr-anycrlf
# Check whether --enable-bsr-anycrlf was given.
if test "${enable_bsr_anycrlf+set}" = set; then
enableval=$enable_bsr_anycrlf;
else
enable_bsr_anycrlf=no
fi
# Handle --enable-ebcdic # Handle --enable-ebcdic
# Check whether --enable-ebcdic was given. # Check whether --enable-ebcdic was given.
if test "${enable_ebcdic+set}" = set; then if test "${enable_ebcdic+set}" = set; then
@@ -4861,7 +4872,8 @@ fi
for ac_func in bcopy memmove strerror strtoq strtoll
for ac_func in bcopy memmove strerror strtoq strtoll _strtoi64
do do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5 { echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -4996,6 +5008,14 @@ cat >>confdefs.h <<_ACEOF
_ACEOF _ACEOF
if test "$enable_bsr_anycrlf" = "yes"; then
cat >>confdefs.h <<\_ACEOF
#define BSR_ANYCRLF
_ACEOF
fi
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define LINK_SIZE $with_link_size #define LINK_SIZE $with_link_size
@@ -5033,12 +5053,6 @@ _ACEOF
cat >>confdefs.h <<\_ACEOF
#define MAX_DUPLENGTH 30000
_ACEOF
if test "$enable_ebcdic" = "yes"; then if test "$enable_ebcdic" = "yes"; then
@@ -5141,7 +5155,7 @@ cat >>confdefs.h <<\_ACEOF
#define MACOSX #define MACOSX
_ACEOF _ACEOF
CFLAGS="$CFLAGS -fno-thread-jumps" CFLAGS="$CFLAGS -fno-jump-threads"
;; ;;
esac esac
@@ -5584,7 +5598,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by PCRE $as_me 7.2, which was This file was extended by PCRE $as_me 7.4, which was
generated by GNU Autoconf 2.61. Invocation command line was generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@@ -5637,7 +5651,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\ ac_cs_version="\\
PCRE config.status 7.2 PCRE config.status 7.4
configured by $0, generated by GNU Autoconf 2.61, configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"

View File

@@ -7,9 +7,9 @@ dnl be defined as -RC2, for example. For real releases, it should be defined
dnl empty. dnl empty.
m4_define(pcre_major, [7]) m4_define(pcre_major, [7])
m4_define(pcre_minor, [2]) m4_define(pcre_minor, [4])
m4_define(pcre_prerelease, []) m4_define(pcre_prerelease, [])
m4_define(pcre_date, [2007-06-19]) m4_define(pcre_date, [2007-09-21])
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT(PCRE, pcre_major.pcre_minor[]pcre_prerelease, , pcre) AC_INIT(PCRE, pcre_major.pcre_minor[]pcre_prerelease, , pcre)
@@ -110,10 +110,16 @@ AC_ARG_ENABLE(newline-is-any,
ac_pcre_newline=any) ac_pcre_newline=any)
enable_newline="$ac_pcre_newline" 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 # Handle --enable-ebcdic
AC_ARG_ENABLE(ebcdic, AC_ARG_ENABLE(ebcdic,
AS_HELP_STRING([--enable-ebcdic], AS_HELP_STRING([--enable-ebcdic],
[assume EBCDIC coding rather than ASCII (implies --enable-rebuild-chartables)]), [assume EBCDIC coding rather than ASCII; use this only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
, enable_ebcdic=no) , enable_ebcdic=no)
# Handle --disable-stack-for-recursion # Handle --disable-stack-for-recursion
@@ -205,8 +211,12 @@ it to run on SunOS4 and other "close to standard" systems.
If you are going to build PCRE "by hand" on a system without "configure" you If you are going to build PCRE "by hand" on a system without "configure" you
should copy the distributed config.h.generic to config.h, and then set up the should copy the distributed config.h.generic to config.h, and then set up the
macros the way you need them. Alternatively, you can avoid editing by using -D macro definitions the way you need them. You must then add -DHAVE_CONFIG_H to
on the compiler command line to set the macro values. 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.
PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if
HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set
@@ -239,7 +249,7 @@ AC_SUBST(pcre_have_ulong_long)
# Checks for library functions. # Checks for library functions.
AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll) AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll _strtoi64)
# This facilitates -ansi builds under Linux # This facilitates -ansi builds under Linux
dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc]) dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc])
@@ -275,9 +285,19 @@ fi
AC_DEFINE_UNQUOTED([NEWLINE], [$ac_pcre_newline_value], [ AC_DEFINE_UNQUOTED([NEWLINE], [$ac_pcre_newline_value], [
The value of NEWLINE determines the newline character sequence. On The value of NEWLINE determines the newline character sequence. On
Unix-like systems, "configure" can be used to override the default, systems that support it, "configure" can be used to override the
which is 10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), default, which is 10. The possible values are 10 (LF), 13 (CR),
-1 (ANY), or -2 (ANYCRLF).]) 3338 (CRLF), -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, 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. On
systems that support it, "configure" can be used to override the
default.])
fi
AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [ AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [
The value of LINK_SIZE determines the number of bytes used to store The value of LINK_SIZE determines the number of bytes used to store
@@ -330,11 +350,6 @@ AC_DEFINE([MAX_NAME_COUNT], [10000], [
change it. Care must be taken if it is increased, because it guards change it. Care must be taken if it is increased, because it guards
against integer overflow caused by enormously large patterns.]) against integer overflow caused by enormously large patterns.])
AC_DEFINE([MAX_DUPLENGTH], [30000], [
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], [ AH_VERBATIM([PCRE_EXP_DEFN], [
/* If you are compiling for a system other than a Unix-like system or /* 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 Win32, and it needs some magic to be inserted before the definition
@@ -354,14 +369,14 @@ if test "$enable_ebcdic" = "yes"; then
"configure", this can be done via --enable-ebcdic.]) "configure", this can be done via --enable-ebcdic.])
fi fi
dnl Mac OS X on Intel hack to remove thread jumps dnl Mac OS X on Intel hack to remove jump threads
AC_CANONICAL_HOST AC_CANONICAL_HOST
case "$host" in case "$host" in
i386-apple-darwin*) i386-apple-darwin*)
macosx=yes macosx=yes
AC_DEFINE(MACOSX, [], [Mac OS X on Intel]) AC_DEFINE(MACOSX, [], [Mac OS X on Intel])
CFLAGS="$CFLAGS -fno-thread-jumps" CFLAGS="$CFLAGS -fno-jump-threads"
;; ;;
esac esac

View File

@@ -43,6 +43,12 @@ character tables for PCRE. The tables are built according to the current
locale. Now that pcre_maketables is a function visible to the outside world, we locale. Now that pcre_maketables is a function visible to the outside world, we
make use of its code from here in order to be consistent. */ make use of its code from here in order to be consistent. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -99,12 +105,17 @@ fprintf(f,
"tables are passed to PCRE by the application that calls it. The tables\n" "tables are passed to PCRE by the application that calls it. The tables\n"
"are used only for characters whose code values are less than 256.\n\n"); "are used only for characters whose code values are less than 256.\n\n");
fprintf(f, fprintf(f,
"The following #include is present because without it gcc 4.x may remove\n" "The following #includes are present because without them gcc 4.x may remove\n"
"the array definition from the final binary if PCRE is built into a static\n" "the array definition from the final binary if PCRE is built into a static\n"
"library and dead code stripping is activated. This leads to link errors.\n" "library and dead code stripping is activated. This leads to link errors.\n"
"Pulling in the header ensures that the array gets flagged as \"someone\n" "Pulling in the header ensures that the array gets flagged as \"someone\n"
"outside this compilation unit might reference this\" and so it will always\n" "outside this compilation unit might reference this\" and so it will always\n"
"be supplied to the linker. */\n\n" "be supplied to the linker. */\n\n"
"#ifdef WIN32\n"
"#include \"pcre_winconfig.h\"\n"
"#else\n"
"#include \"config.h\"\n"
"#endif\n\n"
"#include \"pcre_internal.h\"\n\n"); "#include \"pcre_internal.h\"\n\n");
fprintf(f, fprintf(f,
"const unsigned char _pcre_default_tables[] = {\n\n" "const unsigned char _pcre_default_tables[] = {\n\n"

View File

@@ -42,21 +42,27 @@ POSSIBILITY OF SUCH DAMAGE.
/* The current PCRE version information. */ /* The current PCRE version information. */
#define PCRE_MAJOR 7 #define PCRE_MAJOR 7
#define PCRE_MINOR 2 #define PCRE_MINOR 4
#define PCRE_PRERELEASE #define PCRE_PRERELEASE
#define PCRE_DATE 2007-06-19 #define PCRE_DATE 2007-09-21
/* When an application links to a PCRE DLL in Windows, the symbols that are /* 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 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 export setting is defined in pcre_internal.h, which includes this file. So we
don't change an existing definition of PCRE_EXP_DECL. */ don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
/* /*
#if defined(_WIN32) && !defined(PCRE_STATIC)
# ifndef PCRE_EXP_DECL # ifndef PCRE_EXP_DECL
# ifdef _WIN32
# ifndef PCRE_STATIC
# define PCRE_EXP_DECL extern __declspec(dllimport) # define PCRE_EXP_DECL extern __declspec(dllimport)
# endif # 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
#endif #endif
*/ */
@@ -71,6 +77,15 @@ don't change an existing definition of PCRE_EXP_DECL. */
# endif # endif
#endif #endif
#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; /* Have to include stdlib.h in order to ensure that size_t is defined;
it is needed here for malloc. */ it is needed here for malloc. */
@@ -109,6 +124,8 @@ extern "C" {
#define PCRE_NEWLINE_CRLF 0x00300000 #define PCRE_NEWLINE_CRLF 0x00300000
#define PCRE_NEWLINE_ANY 0x00400000 #define PCRE_NEWLINE_ANY 0x00400000
#define PCRE_NEWLINE_ANYCRLF 0x00500000 #define PCRE_NEWLINE_ANYCRLF 0x00500000
#define PCRE_BSR_ANYCRLF 0x00800000
#define PCRE_BSR_UNICODE 0x01000000
/* Exec-time and get/set-time error codes */ /* Exec-time and get/set-time error codes */
@@ -134,7 +151,7 @@ extern "C" {
#define PCRE_ERROR_DFA_WSSIZE (-19) #define PCRE_ERROR_DFA_WSSIZE (-19)
#define PCRE_ERROR_DFA_RECURSE (-20) #define PCRE_ERROR_DFA_RECURSE (-20)
#define PCRE_ERROR_RECURSIONLIMIT (-21) #define PCRE_ERROR_RECURSIONLIMIT (-21)
#define PCRE_ERROR_NULLWSLIMIT (-22) #define PCRE_ERROR_NULLWSLIMIT (-22) /* No longer actually used */
#define PCRE_ERROR_BADNEWLINE (-23) #define PCRE_ERROR_BADNEWLINE (-23)
/* Request types for pcre_fullinfo() */ /* Request types for pcre_fullinfo() */
@@ -154,6 +171,7 @@ extern "C" {
#define PCRE_INFO_DEFAULT_TABLES 11 #define PCRE_INFO_DEFAULT_TABLES 11
#define PCRE_INFO_OKPARTIAL 12 #define PCRE_INFO_OKPARTIAL 12
#define PCRE_INFO_JCHANGED 13 #define PCRE_INFO_JCHANGED 13
#define PCRE_INFO_HASCRORLF 14
/* Request types for pcre_config(). Do not re-arrange, in order to remain /* Request types for pcre_config(). Do not re-arrange, in order to remain
compatible. */ compatible. */
@@ -166,6 +184,7 @@ compatible. */
#define PCRE_CONFIG_STACKRECURSE 5 #define PCRE_CONFIG_STACKRECURSE 5
#define PCRE_CONFIG_UNICODE_PROPERTIES 6 #define PCRE_CONFIG_UNICODE_PROPERTIES 6
#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7 #define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7
#define PCRE_CONFIG_BSR 8
/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine /* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
these bits, just add new ones on the end, in order to remain compatible. */ these bits, just add new ones on the end, in order to remain compatible. */

View File

@@ -42,21 +42,27 @@ POSSIBILITY OF SUCH DAMAGE.
/* The current PCRE version information. */ /* The current PCRE version information. */
#define PCRE_MAJOR 7 #define PCRE_MAJOR 7
#define PCRE_MINOR 2 #define PCRE_MINOR 4
#define PCRE_PRERELEASE #define PCRE_PRERELEASE
#define PCRE_DATE 2007-06-19 #define PCRE_DATE 2007-09-21
/* When an application links to a PCRE DLL in Windows, the symbols that are /* 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 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 export setting is defined in pcre_internal.h, which includes this file. So we
don't change an existing definition of PCRE_EXP_DECL. */ don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
/* /*
#if defined(_WIN32) && !defined(PCRE_STATIC)
# ifndef PCRE_EXP_DECL # ifndef PCRE_EXP_DECL
# ifdef _WIN32
# ifndef PCRE_STATIC
# define PCRE_EXP_DECL extern __declspec(dllimport) # define PCRE_EXP_DECL extern __declspec(dllimport)
# endif # 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
#endif #endif
*/ */
@@ -71,6 +77,15 @@ don't change an existing definition of PCRE_EXP_DECL. */
# endif # endif
#endif #endif
#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; /* Have to include stdlib.h in order to ensure that size_t is defined;
it is needed here for malloc. */ it is needed here for malloc. */
@@ -109,6 +124,8 @@ extern "C" {
#define PCRE_NEWLINE_CRLF 0x00300000 #define PCRE_NEWLINE_CRLF 0x00300000
#define PCRE_NEWLINE_ANY 0x00400000 #define PCRE_NEWLINE_ANY 0x00400000
#define PCRE_NEWLINE_ANYCRLF 0x00500000 #define PCRE_NEWLINE_ANYCRLF 0x00500000
#define PCRE_BSR_ANYCRLF 0x00800000
#define PCRE_BSR_UNICODE 0x01000000
/* Exec-time and get/set-time error codes */ /* Exec-time and get/set-time error codes */
@@ -134,7 +151,7 @@ extern "C" {
#define PCRE_ERROR_DFA_WSSIZE (-19) #define PCRE_ERROR_DFA_WSSIZE (-19)
#define PCRE_ERROR_DFA_RECURSE (-20) #define PCRE_ERROR_DFA_RECURSE (-20)
#define PCRE_ERROR_RECURSIONLIMIT (-21) #define PCRE_ERROR_RECURSIONLIMIT (-21)
#define PCRE_ERROR_NULLWSLIMIT (-22) #define PCRE_ERROR_NULLWSLIMIT (-22) /* No longer actually used */
#define PCRE_ERROR_BADNEWLINE (-23) #define PCRE_ERROR_BADNEWLINE (-23)
/* Request types for pcre_fullinfo() */ /* Request types for pcre_fullinfo() */
@@ -154,6 +171,7 @@ extern "C" {
#define PCRE_INFO_DEFAULT_TABLES 11 #define PCRE_INFO_DEFAULT_TABLES 11
#define PCRE_INFO_OKPARTIAL 12 #define PCRE_INFO_OKPARTIAL 12
#define PCRE_INFO_JCHANGED 13 #define PCRE_INFO_JCHANGED 13
#define PCRE_INFO_HASCRORLF 14
/* Request types for pcre_config(). Do not re-arrange, in order to remain /* Request types for pcre_config(). Do not re-arrange, in order to remain
compatible. */ compatible. */
@@ -166,6 +184,7 @@ compatible. */
#define PCRE_CONFIG_STACKRECURSE 5 #define PCRE_CONFIG_STACKRECURSE 5
#define PCRE_CONFIG_UNICODE_PROPERTIES 6 #define PCRE_CONFIG_UNICODE_PROPERTIES 6
#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7 #define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7
#define PCRE_CONFIG_BSR 8
/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine /* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
these bits, just add new ones on the end, in order to remain compatible. */ these bits, just add new ones on the end, in order to remain compatible. */

View File

@@ -49,14 +49,20 @@ POSSIBILITY OF SUCH DAMAGE.
/* When an application links to a PCRE DLL in Windows, the symbols that are /* 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 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 export setting is defined in pcre_internal.h, which includes this file. So we
don't change an existing definition of PCRE_EXP_DECL. */ don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
/* /*
#if defined(_WIN32) && !defined(PCRE_STATIC)
# ifndef PCRE_EXP_DECL # ifndef PCRE_EXP_DECL
# ifdef _WIN32
# ifndef PCRE_STATIC
# define PCRE_EXP_DECL extern __declspec(dllimport) # define PCRE_EXP_DECL extern __declspec(dllimport)
# endif # 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
#endif #endif
*/ */
@@ -71,6 +77,15 @@ don't change an existing definition of PCRE_EXP_DECL. */
# endif # endif
#endif #endif
#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; /* Have to include stdlib.h in order to ensure that size_t is defined;
it is needed here for malloc. */ it is needed here for malloc. */
@@ -109,6 +124,8 @@ extern "C" {
#define PCRE_NEWLINE_CRLF 0x00300000 #define PCRE_NEWLINE_CRLF 0x00300000
#define PCRE_NEWLINE_ANY 0x00400000 #define PCRE_NEWLINE_ANY 0x00400000
#define PCRE_NEWLINE_ANYCRLF 0x00500000 #define PCRE_NEWLINE_ANYCRLF 0x00500000
#define PCRE_BSR_ANYCRLF 0x00800000
#define PCRE_BSR_UNICODE 0x01000000
/* Exec-time and get/set-time error codes */ /* Exec-time and get/set-time error codes */
@@ -134,7 +151,7 @@ extern "C" {
#define PCRE_ERROR_DFA_WSSIZE (-19) #define PCRE_ERROR_DFA_WSSIZE (-19)
#define PCRE_ERROR_DFA_RECURSE (-20) #define PCRE_ERROR_DFA_RECURSE (-20)
#define PCRE_ERROR_RECURSIONLIMIT (-21) #define PCRE_ERROR_RECURSIONLIMIT (-21)
#define PCRE_ERROR_NULLWSLIMIT (-22) #define PCRE_ERROR_NULLWSLIMIT (-22) /* No longer actually used */
#define PCRE_ERROR_BADNEWLINE (-23) #define PCRE_ERROR_BADNEWLINE (-23)
/* Request types for pcre_fullinfo() */ /* Request types for pcre_fullinfo() */
@@ -154,6 +171,7 @@ extern "C" {
#define PCRE_INFO_DEFAULT_TABLES 11 #define PCRE_INFO_DEFAULT_TABLES 11
#define PCRE_INFO_OKPARTIAL 12 #define PCRE_INFO_OKPARTIAL 12
#define PCRE_INFO_JCHANGED 13 #define PCRE_INFO_JCHANGED 13
#define PCRE_INFO_HASCRORLF 14
/* Request types for pcre_config(). Do not re-arrange, in order to remain /* Request types for pcre_config(). Do not re-arrange, in order to remain
compatible. */ compatible. */
@@ -166,6 +184,7 @@ compatible. */
#define PCRE_CONFIG_STACKRECURSE 5 #define PCRE_CONFIG_STACKRECURSE 5
#define PCRE_CONFIG_UNICODE_PROPERTIES 6 #define PCRE_CONFIG_UNICODE_PROPERTIES 6
#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7 #define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7
#define PCRE_CONFIG_BSR 8
/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine /* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
these bits, just add new ones on the end, in order to remain compatible. */ these bits, just add new ones on the end, in order to remain compatible. */

View File

@@ -14,12 +14,18 @@ example ISO-8859-1. When dftables is run, it creates these tables in the
current locale. If PCRE is configured with --enable-rebuild-chartables, this current locale. If PCRE is configured with --enable-rebuild-chartables, this
happens automatically. happens automatically.
The following #include is present because without it gcc 4.x may remove the The following #includes are present because without the gcc 4.x may remove the
array definition from the final binary if PCRE is built into a static library array definition from the final binary if PCRE is built into a static library
and dead code stripping is activated. This leads to link errors. Pulling in the and dead code stripping is activated. This leads to link errors. Pulling in the
header ensures that the array gets flagged as "someone outside this compilation header ensures that the array gets flagged as "someone outside this compilation
unit might reference this" and so it will always be supplied to the linker. */ unit might reference this" and so it will always be supplied to the linker. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
const unsigned char _pcre_default_tables[] = { const unsigned char _pcre_default_tables[] = {

View File

@@ -14,12 +14,18 @@ example ISO-8859-1. When dftables is run, it creates these tables in the
current locale. If PCRE is configured with --enable-rebuild-chartables, this current locale. If PCRE is configured with --enable-rebuild-chartables, this
happens automatically. happens automatically.
The following #include is present because without it gcc 4.x may remove the The following #includes are present because without the gcc 4.x may remove the
array definition from the final binary if PCRE is built into a static library array definition from the final binary if PCRE is built into a static library
and dead code stripping is activated. This leads to link errors. Pulling in the and dead code stripping is activated. This leads to link errors. Pulling in the
header ensures that the array gets flagged as "someone outside this compilation header ensures that the array gets flagged as "someone outside this compilation
unit might reference this" and so it will always be supplied to the linker. */ unit might reference this" and so it will always be supplied to the linker. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
const unsigned char _pcre_default_tables[] = { const unsigned char _pcre_default_tables[] = {

File diff suppressed because it is too large Load Diff

View File

@@ -41,6 +41,12 @@ POSSIBILITY OF SUCH DAMAGE.
/* This module contains the external function pcre_config(). */ /* This module contains the external function pcre_config(). */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
@@ -83,6 +89,14 @@ switch (what)
*((int *)where) = NEWLINE; *((int *)where) = NEWLINE;
break; break;
case PCRE_CONFIG_BSR:
#ifdef BSR_ANYCRLF
*((int *)where) = 1;
#else
*((int *)where) = 0;
#endif
break;
case PCRE_CONFIG_LINK_SIZE: case PCRE_CONFIG_LINK_SIZE:
*((int *)where) = LINK_SIZE; *((int *)where) = LINK_SIZE;
break; break;

View File

@@ -44,6 +44,12 @@ FSM). This is NOT Perl- compatible, but it has advantages in certain
applications. */ applications. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#define NLBLOCK md /* Block containing newline information */ #define NLBLOCK md /* Block containing newline information */
#define PSSTART start_subject /* Field containing processed string start */ #define PSSTART start_subject /* Field containing processed string start */
#define PSEND end_subject /* Field containing processed string end */ #define PSEND end_subject /* Field containing processed string end */
@@ -126,7 +132,9 @@ static uschar coptable[] = {
0, /* CREF */ 0, /* CREF */
0, /* RREF */ 0, /* RREF */
0, /* DEF */ 0, /* DEF */
0, 0 /* BRAZERO, BRAMINZERO */ 0, 0, /* BRAZERO, BRAMINZERO */
0, 0, 0, 0, /* PRUNE, SKIP, THEN, COMMIT */
0, 0 /* FAIL, ACCEPT */
}; };
/* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W, /* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W,
@@ -1074,15 +1082,20 @@ for (;;)
int ncount = 0; int ncount = 0;
switch (c) switch (c)
{ {
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
case 0x000a:
case 0x000b: case 0x000b:
case 0x000c: case 0x000c:
case 0x0085: case 0x0085:
case 0x2028: case 0x2028:
case 0x2029: case 0x2029:
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
goto ANYNL01;
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
ANYNL01:
case 0x000a:
if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS) if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS)
{ {
active_count--; /* Remove non-match possibility */ active_count--; /* Remove non-match possibility */
@@ -1091,6 +1104,7 @@ for (;;)
count++; count++;
ADD_NEW_DATA(-state_offset, count, ncount); ADD_NEW_DATA(-state_offset, count, ncount);
break; break;
default: default:
break; break;
} }
@@ -1307,15 +1321,20 @@ for (;;)
int ncount = 0; int ncount = 0;
switch (c) switch (c)
{ {
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
case 0x000a:
case 0x000b: case 0x000b:
case 0x000c: case 0x000c:
case 0x0085: case 0x0085:
case 0x2028: case 0x2028:
case 0x2029: case 0x2029:
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
goto ANYNL02;
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
ANYNL02:
case 0x000a:
if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR || if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR ||
codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY) codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY)
{ {
@@ -1324,6 +1343,7 @@ for (;;)
} }
ADD_NEW_DATA(-(state_offset + count), 0, ncount); ADD_NEW_DATA(-(state_offset + count), 0, ncount);
break; break;
default: default:
break; break;
} }
@@ -1539,15 +1559,20 @@ for (;;)
int ncount = 0; int ncount = 0;
switch (c) switch (c)
{ {
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
case 0x000a:
case 0x000b: case 0x000b:
case 0x000c: case 0x000c:
case 0x0085: case 0x0085:
case 0x2028: case 0x2028:
case 0x2029: case 0x2029:
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
goto ANYNL03;
case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
/* Fall through */
ANYNL03:
case 0x000a:
if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO) if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO)
{ {
active_count--; /* Remove non-match possibility */ active_count--; /* Remove non-match possibility */
@@ -1558,6 +1583,7 @@ for (;;)
else else
{ ADD_NEW_DATA(-state_offset, count, ncount); } { ADD_NEW_DATA(-state_offset, count, ncount); }
break; break;
default: default:
break; break;
} }
@@ -1738,14 +1764,17 @@ for (;;)
case OP_ANYNL: case OP_ANYNL:
if (clen > 0) switch(c) if (clen > 0) switch(c)
{ {
case 0x000a:
case 0x000b: case 0x000b:
case 0x000c: case 0x000c:
case 0x0085: case 0x0085:
case 0x2028: case 0x2028:
case 0x2029: case 0x2029:
if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
case 0x000a:
ADD_NEW(state_offset + 1, 0); ADD_NEW(state_offset + 1, 0);
break; break;
case 0x000d: case 0x000d:
if (ptr + 1 < end_subject && ptr[1] == 0x0a) if (ptr + 1 < end_subject && ptr[1] == 0x0a)
{ {
@@ -2568,6 +2597,18 @@ md->end_subject = end_subject;
md->moptions = options; md->moptions = options;
md->poptions = re->options; md->poptions = re->options;
/* If the BSR option is not set at match time, copy what was set
at compile time. */
if ((md->moptions & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) == 0)
{
if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0)
md->moptions |= re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE);
#ifdef BSR_ANYCRLF
else md->moptions |= PCRE_BSR_ANYCRLF;
#endif
}
/* Handle different types of newline. The three bits give eight cases. If /* 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. */ nothing is set at run time, whatever was used at compile time applies. */
@@ -2638,7 +2679,7 @@ if (md->tables == NULL) md->tables = _pcre_default_tables;
used in a loop when finding where to start. */ used in a loop when finding where to start. */
lcc = md->tables + lcc_offset; lcc = md->tables + lcc_offset;
startline = (re->options & PCRE_STARTLINE) != 0; startline = (re->flags & PCRE_STARTLINE) != 0;
firstline = (re->options & PCRE_FIRSTLINE) != 0; firstline = (re->options & PCRE_FIRSTLINE) != 0;
/* Set up the first character to match, if available. The first_byte value is /* Set up the first character to match, if available. The first_byte value is
@@ -2649,7 +2690,7 @@ studied, there may be a bitmap of possible first characters. */
if (!anchored) if (!anchored)
{ {
if ((re->options & PCRE_FIRSTSET) != 0) if ((re->flags & PCRE_FIRSTSET) != 0)
{ {
first_byte = re->first_byte & 255; first_byte = re->first_byte & 255;
if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE) if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
@@ -2666,7 +2707,7 @@ if (!anchored)
/* For anchored or unanchored matches, there may be a "last known required /* For anchored or unanchored matches, there may be a "last known required
character" set. */ character" set. */
if ((re->options & PCRE_REQCHSET) != 0) if ((re->flags & PCRE_REQCHSET) != 0)
{ {
req_byte = re->req_byte & 255; req_byte = re->req_byte & 255;
req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0; req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
@@ -2836,16 +2877,17 @@ for (;;)
} }
if (current_subject > end_subject) break; if (current_subject > end_subject) break;
/* If we have just passed a CR and the newline option is CRLF or ANY or /* If we have just passed a CR and we are now at a LF, and the pattern does
ANYCRLF, and we are now at a LF, advance the match position by one more not contain any explicit matches for \r or \n, and the newline option is CRLF
character. */ or ANY or ANYCRLF, advance the match position by one more character. */
if (current_subject[-1] == '\r' && if (current_subject[-1] == '\r' &&
current_subject < end_subject &&
*current_subject == '\n' &&
(re->flags & PCRE_HASCRORLF) == 0 &&
(md->nltype == NLTYPE_ANY || (md->nltype == NLTYPE_ANY ||
md->nltype == NLTYPE_ANYCRLF || md->nltype == NLTYPE_ANYCRLF ||
md->nllen == 2) && md->nllen == 2))
current_subject < end_subject &&
*current_subject == '\n')
current_subject++; current_subject++;
} /* "Bumpalong" loop */ } /* "Bumpalong" loop */

View File

@@ -42,6 +42,12 @@ POSSIBILITY OF SUCH DAMAGE.
pattern matching using an NFA algorithm, trying to mimic Perl as closely as pattern matching using an NFA algorithm, trying to mimic Perl as closely as
possible. There are also some static supporting functions. */ possible. There are also some static supporting functions. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#define NLBLOCK md /* Block containing newline information */ #define NLBLOCK md /* Block containing newline information */
#define PSSTART start_subject /* Field containing processed string start */ #define PSSTART start_subject /* Field containing processed string start */
#define PSEND end_subject /* Field containing processed string end */ #define PSEND end_subject /* Field containing processed string end */
@@ -53,16 +59,10 @@ possible. There are also some static supporting functions. */
#undef min #undef min
#undef max #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. */
#define EPTR_WORK_SIZE (1000)
/* Flag bits for the match() function */ /* Flag bits for the match() function */
#define match_condassert 0x01 /* Called to check a condition assertion */ #define match_condassert 0x01 /* Called to check a condition assertion */
#define match_cbegroup 0x02 /* Could-be-empty unlimited repeat group */ #define match_cbegroup 0x02 /* Could-be-empty unlimited repeat group */
#define match_tail_recursed 0x04 /* Tail recursive call */
/* Non-error returns from the match() function. Error returns are externally /* Non-error returns from the match() function. Error returns are externally
defined PCRE_ERROR_xxx codes, which are all negative. */ defined PCRE_ERROR_xxx codes, which are all negative. */
@@ -70,6 +70,14 @@ defined PCRE_ERROR_xxx codes, which are all negative. */
#define MATCH_MATCH 1 #define MATCH_MATCH 1
#define MATCH_NOMATCH 0 #define MATCH_NOMATCH 0
/* Special internal returns from the match() function. Make them sufficiently
negative to avoid the external error codes. */
#define MATCH_COMMIT (-999)
#define MATCH_PRUNE (-998)
#define MATCH_SKIP (-997)
#define MATCH_THEN (-996)
/* Maximum number of ints of offset to save on the stack for recursive calls. /* Maximum number of ints of offset to save on the stack for recursive calls.
If the offset vector is bigger, malloc is used. This should be a multiple of 3, If the offset vector is bigger, malloc is used. This should be a multiple of 3,
because the offset vector is always a multiple of 3 long. */ because the offset vector is always a multiple of 3 long. */
@@ -205,15 +213,15 @@ variable instead of being passed in the frame.
**************************************************************************** ****************************************************************************
***************************************************************************/ ***************************************************************************/
/* Numbers for RMATCH calls. When this list is changed, the code at HEAP_RETURN
/* Numbers for RMATCH calls */ below must be updated in sync. */
enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10, enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10,
RM11, RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20, RM11, RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20,
RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,
RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
RM41, RM42, RM43, RM44, RM45, RM46, RM47 }; RM41, RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
RM51, RM52, RM53, RM54 };
/* These versions of the macros use the stack, as normal. There are debugging /* These versions of the macros use the stack, as normal. There are debugging
versions and production versions. Note that the "rw" argument of RMATCH isn't versions and production versions. Note that the "rw" argument of RMATCH isn't
@@ -384,7 +392,6 @@ Arguments:
match_condassert - this is an assertion condition match_condassert - this is an assertion condition
match_cbegroup - this is the start of an unlimited repeat match_cbegroup - this is the start of an unlimited repeat
group that can match an empty string group that can match an empty string
match_tail_recursed - this is a tail_recursed group
rdepth the recursion depth rdepth the recursion depth
Returns: MATCH_MATCH if matched ) these values are >= 0 Returns: MATCH_MATCH if matched ) these values are >= 0
@@ -586,22 +593,16 @@ original_ims = ims; /* Save for resetting on ')' */
string, the match_cbegroup flag is set. When this is the case, add the current string, the match_cbegroup flag is set. When this is the case, add the current
subject pointer to the chain of such remembered pointers, to be checked when we subject pointer to the chain of such remembered pointers, to be checked when we
hit the closing ket, in order to break infinite loops that match no characters. hit the closing ket, in order to break infinite loops that match no characters.
When match() is called in other circumstances, don't add to the chain. If this When match() is called in other circumstances, don't add to the chain. The
is a tail recursion, use a block from the workspace, as the one on the stack is match_cbegroup flag must NOT be used with tail recursion, because the memory
already used. */ block that is used is on the stack, so a new one may be required for each
match(). */
if ((flags & match_cbegroup) != 0) if ((flags & match_cbegroup) != 0)
{ {
eptrblock *p; newptrb.epb_saved_eptr = eptr;
if ((flags & match_tail_recursed) != 0) newptrb.epb_prev = eptrb;
{ eptrb = &newptrb;
if (md->eptrn >= EPTR_WORK_SIZE) RRETURN(PCRE_ERROR_NULLWSLIMIT);
p = md->eptrchain + md->eptrn++;
}
else p = &newptrb;
p->epb_saved_eptr = eptr;
p->epb_prev = eptrb;
eptrb = p;
} }
/* Now start processing the opcodes. */ /* Now start processing the opcodes. */
@@ -621,6 +622,34 @@ for (;;)
switch(op) switch(op)
{ {
case OP_FAIL:
RRETURN(MATCH_NOMATCH);
case OP_PRUNE:
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
ims, eptrb, flags, RM51);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
RRETURN(MATCH_PRUNE);
case OP_COMMIT:
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
ims, eptrb, flags, RM52);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
RRETURN(MATCH_COMMIT);
case OP_SKIP:
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
ims, eptrb, flags, RM53);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
md->start_match_ptr = eptr; /* Pass back current position */
RRETURN(MATCH_SKIP);
case OP_THEN:
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
ims, eptrb, flags, RM54);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
RRETURN(MATCH_THEN);
/* Handle a capturing bracket. If there is space in the offset vector, save /* Handle a capturing bracket. If there is space in the offset vector, save
the current subject position in the working slot at the top of the vector. the current subject position in the working slot at the top of the vector.
We mustn't change the current values of the data slot, because they may be We mustn't change the current values of the data slot, because they may be
@@ -662,7 +691,7 @@ for (;;)
{ {
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
ims, eptrb, flags, RM1); ims, eptrb, flags, RM1);
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
md->capture_last = save_capture_last; md->capture_last = save_capture_last;
ecode += GET(ecode, 1); ecode += GET(ecode, 1);
} }
@@ -677,15 +706,22 @@ for (;;)
RRETURN(MATCH_NOMATCH); RRETURN(MATCH_NOMATCH);
} }
/* Insufficient room for saving captured contents. Treat as a non-capturing /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
bracket. */ as a non-capturing bracket. */
/* VVVVVVVVVVVVVVVVVVVVVVVVV */
/* VVVVVVVVVVVVVVVVVVVVVVVVV */
DPRINTF(("insufficient capture room: treat as non-capturing\n")); DPRINTF(("insufficient capture room: treat as non-capturing\n"));
/* VVVVVVVVVVVVVVVVVVVVVVVVV */
/* VVVVVVVVVVVVVVVVVVVVVVVVV */
/* Non-capturing bracket. Loop for all the alternatives. When we get to the /* Non-capturing bracket. Loop for all the alternatives. When we get to the
final alternative within the brackets, we would return the result of a final alternative within the brackets, we would return the result of a
recursive call to match() whatever happened. We can reduce stack usage by recursive call to match() whatever happened. We can reduce stack usage by
turning this into a tail recursion. */ turning this into a tail recursion, except in the case when match_cbegroup
is set.*/
case OP_BRA: case OP_BRA:
case OP_SBRA: case OP_SBRA:
@@ -693,20 +729,28 @@ for (;;)
flags = (op >= OP_SBRA)? match_cbegroup : 0; flags = (op >= OP_SBRA)? match_cbegroup : 0;
for (;;) for (;;)
{ {
if (ecode[GET(ecode, 1)] != OP_ALT) if (ecode[GET(ecode, 1)] != OP_ALT) /* Final alternative */
{
if (flags == 0) /* Not a possibly empty group */
{ {
ecode += _pcre_OP_lengths[*ecode]; ecode += _pcre_OP_lengths[*ecode];
flags |= match_tail_recursed;
DPRINTF(("bracket 0 tail recursion\n")); DPRINTF(("bracket 0 tail recursion\n"));
goto TAIL_RECURSE; goto TAIL_RECURSE;
} }
/* Possibly empty group; can't use tail recursion. */
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
eptrb, flags, RM48);
RRETURN(rrc);
}
/* For non-final alternatives, continue the loop for a NOMATCH result; /* For non-final alternatives, continue the loop for a NOMATCH result;
otherwise return. */ otherwise return. */
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
eptrb, flags, RM2); eptrb, flags, RM2);
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
ecode += GET(ecode, 1); ecode += GET(ecode, 1);
} }
/* Control never reaches here. */ /* Control never reaches here. */
@@ -754,7 +798,7 @@ for (;;)
ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
while (*ecode == OP_ALT) ecode += GET(ecode, 1); while (*ecode == OP_ALT) ecode += GET(ecode, 1);
} }
else if (rrc != MATCH_NOMATCH) else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
{ {
RRETURN(rrc); /* Need braces because of following else */ RRETURN(rrc); /* Need braces because of following else */
} }
@@ -766,25 +810,36 @@ for (;;)
} }
/* We are now at the branch that is to be obeyed. As there is only one, /* We are now at the branch that is to be obeyed. As there is only one,
we can use tail recursion to avoid using another stack frame. If the second we can use tail recursion to avoid using another stack frame, except when
alternative doesn't exist, we can just plough on. */ match_cbegroup is required for an unlimited repeat of a possibly empty
group. If the second alternative doesn't exist, we can just plough on. */
if (condition || *ecode == OP_ALT) if (condition || *ecode == OP_ALT)
{ {
ecode += 1 + LINK_SIZE; ecode += 1 + LINK_SIZE;
flags = match_tail_recursed | ((op == OP_SCOND)? match_cbegroup : 0); if (op == OP_SCOND) /* Possibly empty group */
{
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49);
RRETURN(rrc);
}
else /* Group must match something */
{
flags = 0;
goto TAIL_RECURSE; goto TAIL_RECURSE;
} }
else }
else /* Condition false & no 2nd alternative */
{ {
ecode += 1 + LINK_SIZE; ecode += 1 + LINK_SIZE;
} }
break; break;
/* End of the pattern. If we are in a top-level recursion, we should /* End of the pattern, either real or forced. If we are in a top-level
restore the offsets appropriately and continue from after the call. */ recursion, we should restore the offsets appropriately and continue from
after the call. */
case OP_ACCEPT:
case OP_END: case OP_END:
if (md->recursive != NULL && md->recursive->group_num == 0) if (md->recursive != NULL && md->recursive->group_num == 0)
{ {
@@ -829,7 +884,7 @@ for (;;)
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
RM4); RM4);
if (rrc == MATCH_MATCH) break; if (rrc == MATCH_MATCH) break;
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
ecode += GET(ecode, 1); ecode += GET(ecode, 1);
} }
while (*ecode == OP_ALT); while (*ecode == OP_ALT);
@@ -856,7 +911,7 @@ for (;;)
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
RM5); RM5);
if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH);
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
ecode += GET(ecode,1); ecode += GET(ecode,1);
} }
while (*ecode == OP_ALT); while (*ecode == OP_ALT);
@@ -880,7 +935,7 @@ for (;;)
{ {
eptr--; eptr--;
if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
BACKCHAR(eptr) BACKCHAR(eptr);
} }
} }
else else
@@ -993,7 +1048,7 @@ for (;;)
(pcre_free)(new_recursive.offset_save); (pcre_free)(new_recursive.offset_save);
RRETURN(MATCH_MATCH); RRETURN(MATCH_MATCH);
} }
else if (rrc != MATCH_NOMATCH) else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
{ {
DPRINTF(("Recursion gave error %d\n", rrc)); DPRINTF(("Recursion gave error %d\n", rrc));
RRETURN(rrc); RRETURN(rrc);
@@ -1027,10 +1082,9 @@ for (;;)
do do
{ {
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7);
eptrb, 0, RM7);
if (rrc == MATCH_MATCH) break; if (rrc == MATCH_MATCH) break;
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
ecode += GET(ecode,1); ecode += GET(ecode,1);
} }
while (*ecode == OP_ALT); while (*ecode == OP_ALT);
@@ -1073,11 +1127,10 @@ for (;;)
if (*ecode == OP_KETRMIN) if (*ecode == OP_KETRMIN)
{ {
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM8);
RM8);
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode = prev; ecode = prev;
flags = match_tail_recursed; flags = 0;
goto TAIL_RECURSE; goto TAIL_RECURSE;
} }
else /* OP_KETRMAX */ else /* OP_KETRMAX */
@@ -1085,7 +1138,7 @@ for (;;)
RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9); RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9);
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode += 1 + LINK_SIZE; ecode += 1 + LINK_SIZE;
flags = match_tail_recursed; flags = 0;
goto TAIL_RECURSE; goto TAIL_RECURSE;
} }
/* Control never gets here */ /* Control never gets here */
@@ -1216,17 +1269,21 @@ for (;;)
/* The repeating kets try the rest of the pattern or restart from the /* The repeating kets try the rest of the pattern or restart from the
preceding bracket, in the appropriate order. In the second case, we can use preceding bracket, in the appropriate order. In the second case, we can use
tail recursion to avoid using another stack frame. */ tail recursion to avoid using another stack frame, unless we have an
unlimited repeat of a group that can match an empty string. */
flags = (*prev >= OP_SBRA)? match_cbegroup : 0; flags = (*prev >= OP_SBRA)? match_cbegroup : 0;
if (*ecode == OP_KETRMIN) if (*ecode == OP_KETRMIN)
{ {
RMATCH(eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM12);
RM12);
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (flags != 0) /* Could match an empty string */
{
RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50);
RRETURN(rrc);
}
ecode = prev; ecode = prev;
flags |= match_tail_recursed;
goto TAIL_RECURSE; goto TAIL_RECURSE;
} }
else /* OP_KETRMAX */ else /* OP_KETRMAX */
@@ -1234,7 +1291,7 @@ for (;;)
RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13); RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13);
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode += 1 + LINK_SIZE; ecode += 1 + LINK_SIZE;
flags = match_tail_recursed; flags = 0;
goto TAIL_RECURSE; goto TAIL_RECURSE;
} }
/* Control never gets here */ /* Control never gets here */
@@ -1471,12 +1528,16 @@ for (;;)
case 0x000d: case 0x000d:
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
break; break;
case 0x000a: case 0x000a:
break;
case 0x000b: case 0x000b:
case 0x000c: case 0x000c:
case 0x0085: case 0x0085:
case 0x2028: case 0x2028:
case 0x2029: case 0x2029:
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
break; break;
} }
ecode++; ecode++;
@@ -2033,7 +2094,7 @@ for (;;)
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21); RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */ if (eptr-- == pp) break; /* Stop if tried at original pos */
BACKCHAR(eptr) if (utf8) BACKCHAR(eptr);
} }
RRETURN(MATCH_NOMATCH); RRETURN(MATCH_NOMATCH);
} }
@@ -2899,12 +2960,16 @@ for (;;)
case 0x000d: case 0x000d:
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
break; break;
case 0x000a: case 0x000a:
break;
case 0x000b: case 0x000b:
case 0x000c: case 0x000c:
case 0x0085: case 0x0085:
case 0x2028: case 0x2028:
case 0x2029: case 0x2029:
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
break; break;
} }
} }
@@ -3038,9 +3103,9 @@ for (;;)
for (i = 1; i <= min; i++) for (i = 1; i <= min; i++)
{ {
if (eptr >= md->end_subject || if (eptr >= md->end_subject ||
(*eptr < 128 && (md->ctypes[*eptr++] & ctype_space) != 0)) (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0))
RRETURN(MATCH_NOMATCH); RRETURN(MATCH_NOMATCH);
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
} }
break; break;
@@ -3058,9 +3123,9 @@ for (;;)
for (i = 1; i <= min; i++) for (i = 1; i <= min; i++)
{ {
if (eptr >= md->end_subject || if (eptr >= md->end_subject ||
(*eptr < 128 && (md->ctypes[*eptr++] & ctype_word) != 0)) (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0))
RRETURN(MATCH_NOMATCH); RRETURN(MATCH_NOMATCH);
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
} }
break; break;
@@ -3117,9 +3182,12 @@ for (;;)
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
break; break;
case 0x000a: case 0x000a:
break;
case 0x000b: case 0x000b:
case 0x000c: case 0x000c:
case 0x0085: case 0x0085:
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
break; break;
} }
} }
@@ -3371,11 +3439,14 @@ for (;;)
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
break; break;
case 0x000a: case 0x000a:
break;
case 0x000b: case 0x000b:
case 0x000c: case 0x000c:
case 0x0085: case 0x0085:
case 0x2028: case 0x2028:
case 0x2029: case 0x2029:
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
break; break;
} }
break; break;
@@ -3527,10 +3598,14 @@ for (;;)
case 0x000d: case 0x000d:
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
break; break;
case 0x000a: case 0x000a:
break;
case 0x000b: case 0x000b:
case 0x000c: case 0x000c:
case 0x0085: case 0x0085:
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
break; break;
} }
break; break;
@@ -3702,7 +3777,7 @@ for (;;)
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44); RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44);
if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */ if (eptr-- == pp) break; /* Stop if tried at original pos */
BACKCHAR(eptr); if (utf8) BACKCHAR(eptr);
} }
} }
@@ -3741,9 +3816,9 @@ for (;;)
for (;;) /* Move back over one extended */ for (;;) /* Move back over one extended */
{ {
int len = 1; int len = 1;
BACKCHAR(eptr);
if (!utf8) c = *eptr; else if (!utf8) c = *eptr; else
{ {
BACKCHAR(eptr);
GETCHARLEN(c, eptr, len); GETCHARLEN(c, eptr, len);
} }
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);
@@ -3764,11 +3839,6 @@ for (;;)
switch(ctype) switch(ctype)
{ {
case OP_ANY: case OP_ANY:
/* Special code is required for UTF8, but when the maximum is
unlimited we don't need it, so we repeat the non-UTF8 code. This is
probably worth it, because .* is quite a common idiom. */
if (max < INT_MAX) if (max < INT_MAX)
{ {
if ((ims & PCRE_DOTALL) == 0) if ((ims & PCRE_DOTALL) == 0)
@@ -3801,15 +3871,12 @@ for (;;)
{ {
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
eptr++; eptr++;
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
} }
break;
} }
else else
{ {
c = max - min; eptr = md->end_subject;
if (c > (unsigned int)(md->end_subject - eptr))
c = md->end_subject - eptr;
eptr += c;
} }
} }
break; break;
@@ -3836,8 +3903,10 @@ for (;;)
} }
else else
{ {
if (c != 0x000a && c != 0x000b && c != 0x000c && if (c != 0x000a &&
c != 0x0085 && c != 0x2028 && c != 0x2029) (md->bsr_anycrlf ||
(c != 0x000b && c != 0x000c &&
c != 0x0085 && c != 0x2028 && c != 0x2029)))
break; break;
eptr += len; eptr += len;
} }
@@ -3990,7 +4059,7 @@ for (;;)
} }
} }
else else
#endif #endif /* SUPPORT_UTF8 */
/* Not UTF-8 mode */ /* Not UTF-8 mode */
{ {
@@ -4027,7 +4096,9 @@ for (;;)
} }
else else
{ {
if (c != 0x000a && c != 0x000b && c != 0x000c && c != 0x0085) if (c != 0x000a &&
(md->bsr_anycrlf ||
(c != 0x000b && c != 0x000c && c != 0x0085)))
break; break;
eptr++; eptr++;
} }
@@ -4177,11 +4248,17 @@ HEAP_RETURN:
switch (frame->Xwhere) switch (frame->Xwhere)
{ {
LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8) LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8)
LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(16) LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17)
LBL(17) LBL(18) LBL(19) LBL(20) LBL(21) LBL(22) LBL(23) LBL(24) LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33)
LBL(25) LBL(26) LBL(27) LBL(28) LBL(29) LBL(30) LBL(31) LBL(32) LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52)
LBL(33) LBL(34) LBL(35) LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(53) LBL(54)
LBL(41) LBL(42) LBL(43) LBL(44) LBL(45) LBL(46) LBL(47) #ifdef SUPPORT_UTF8
LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30)
LBL(32) LBL(34) LBL(42) LBL(46)
#ifdef SUPPORT_UCP
LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)
#endif /* SUPPORT_UCP */
#endif /* SUPPORT_UTF8 */
default: default:
DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere)); DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));
return PCRE_ERROR_INTERNAL; return PCRE_ERROR_INTERNAL;
@@ -4298,7 +4375,6 @@ const uschar *start_bits = NULL;
USPTR start_match = (USPTR)subject + start_offset; USPTR start_match = (USPTR)subject + start_offset;
USPTR end_subject; USPTR end_subject;
USPTR req_byte_ptr = start_match - 1; USPTR req_byte_ptr = start_match - 1;
eptrblock eptrchain[EPTR_WORK_SIZE];
pcre_study_data internal_study; pcre_study_data internal_study;
const pcre_study_data *study; const pcre_study_data *study;
@@ -4361,7 +4437,7 @@ if (re->magic_number != MAGIC_NUMBER)
/* Set up other data */ /* Set up other data */
anchored = ((re->options | options) & PCRE_ANCHORED) != 0; anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
startline = (re->options & PCRE_STARTLINE) != 0; startline = (re->flags & PCRE_STARTLINE) != 0;
firstline = (re->options & PCRE_FIRSTLINE) != 0; firstline = (re->options & PCRE_FIRSTLINE) != 0;
/* The code starts after the real_pcre block and the capture name table. */ /* The code starts after the real_pcre block and the capture name table. */
@@ -4384,16 +4460,41 @@ md->partial = (options & PCRE_PARTIAL) != 0;
md->hitend = FALSE; md->hitend = FALSE;
md->recursive = NULL; /* No recursion at top level */ md->recursive = NULL; /* No recursion at top level */
md->eptrchain = eptrchain; /* Make workspace generally available */
md->lcc = tables + lcc_offset; md->lcc = tables + lcc_offset;
md->ctypes = tables + ctypes_offset; md->ctypes = tables + ctypes_offset;
/* Handle different \R options. */
switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE))
{
case 0:
if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0)
md->bsr_anycrlf = (re->options & PCRE_BSR_ANYCRLF) != 0;
else
#ifdef BSR_ANYCRLF
md->bsr_anycrlf = TRUE;
#else
md->bsr_anycrlf = FALSE;
#endif
break;
case PCRE_BSR_ANYCRLF:
md->bsr_anycrlf = TRUE;
break;
case PCRE_BSR_UNICODE:
md->bsr_anycrlf = FALSE;
break;
default: return PCRE_ERROR_BADNEWLINE;
}
/* Handle different types of newline. The three bits give eight cases. If /* 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. */ nothing is set at run time, whatever was used at compile time applies. */
switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)options) & switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options :
PCRE_NEWLINE_BITS) (pcre_uint32)options) & PCRE_NEWLINE_BITS)
{ {
case 0: newline = NEWLINE; break; /* Compile-time default */ case 0: newline = NEWLINE; break; /* Compile-time default */
case PCRE_NEWLINE_CR: newline = '\r'; break; case PCRE_NEWLINE_CR: newline = '\r'; break;
@@ -4432,7 +4533,7 @@ else
/* Partial matching is supported only for a restricted set of regexes at the /* Partial matching is supported only for a restricted set of regexes at the
moment. */ moment. */
if (md->partial && (re->options & PCRE_NOPARTIAL) != 0) if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0)
return PCRE_ERROR_BADPARTIAL; return PCRE_ERROR_BADPARTIAL;
/* Check a UTF-8 string if required. Unfortunately there's no way of passing /* Check a UTF-8 string if required. Unfortunately there's no way of passing
@@ -4509,7 +4610,7 @@ studied, there may be a bitmap of possible first characters. */
if (!anchored) if (!anchored)
{ {
if ((re->options & PCRE_FIRSTSET) != 0) if ((re->flags & PCRE_FIRSTSET) != 0)
{ {
first_byte = re->first_byte & 255; first_byte = re->first_byte & 255;
if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE) if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
@@ -4524,7 +4625,7 @@ if (!anchored)
/* For anchored or unanchored matches, there may be a "last known required /* For anchored or unanchored matches, there may be a "last known required
character" set. */ character" set. */
if ((re->options & PCRE_REQCHSET) != 0) if ((re->flags & PCRE_REQCHSET) != 0)
{ {
req_byte = re->req_byte & 255; req_byte = re->req_byte & 255;
req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0; req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
@@ -4540,6 +4641,7 @@ the loop runs just once. */
for(;;) for(;;)
{ {
USPTR save_end_subject = end_subject; USPTR save_end_subject = end_subject;
USPTR new_start_match;
/* Reset the maximum number of extractions we might see. */ /* Reset the maximum number of extractions we might see. */
@@ -4680,15 +4782,48 @@ for(;;)
/* OK, we can now run the match. */ /* OK, we can now run the match. */
md->start_match_ptr = start_match; /* Insurance */ md->start_match_ptr = start_match;
md->match_call_count = 0; md->match_call_count = 0;
md->eptrn = 0; /* Next free eptrchain slot */ rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0);
rc = match(start_match, md->start_code, start_match, 2, md,
ims, NULL, 0, 0);
/* Any return other than MATCH_NOMATCH breaks the loop. */ switch(rc)
{
/* NOMATCH and PRUNE advance by one character. THEN at this level acts
exactly like PRUNE. */
if (rc != MATCH_NOMATCH) break; case MATCH_NOMATCH:
case MATCH_PRUNE:
case MATCH_THEN:
new_start_match = start_match + 1;
#ifdef SUPPORT_UTF8
if (utf8)
while(new_start_match < end_subject && (*new_start_match & 0xc0) == 0x80)
new_start_match++;
#endif
break;
/* SKIP passes back the next starting point explicitly. */
case MATCH_SKIP:
new_start_match = md->start_match_ptr;
break;
/* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */
case MATCH_COMMIT:
rc = MATCH_NOMATCH;
goto ENDLOOP;
/* Any other return is some kind of error. */
default:
goto ENDLOOP;
}
/* Control reaches here for the various types of "no match at this point"
result. Reset the code to MATCH_NOMATCH for subsequent checking. */
rc = MATCH_NOMATCH;
/* If PCRE_FIRSTLINE is set, the match must happen before or at the first /* If PCRE_FIRSTLINE is set, the match must happen before or at the first
newline in the subject (though it may continue over the newline). Therefore, newline in the subject (though it may continue over the newline). Therefore,
@@ -4696,30 +4831,26 @@ for(;;)
if (firstline && IS_NEWLINE(start_match)) break; if (firstline && IS_NEWLINE(start_match)) break;
/* Advance the match position by one character. */ /* Advance to new matching position */
start_match++; start_match = new_start_match;
#ifdef SUPPORT_UTF8
if (utf8)
while(start_match < end_subject && (*start_match & 0xc0) == 0x80)
start_match++;
#endif
/* Break the loop if the pattern is anchored or if we have passed the end of /* Break the loop if the pattern is anchored or if we have passed the end of
the subject. */ the subject. */
if (anchored || start_match > end_subject) break; if (anchored || start_match > end_subject) break;
/* If we have just passed a CR and the newline option is CRLF or ANY or /* If we have just passed a CR and we are now at a LF, and the pattern does
ANYCRLF, and we are now at a LF, advance the match position by one more not contain any explicit matches for \r or \n, and the newline option is CRLF
character. */ or ANY or ANYCRLF, advance the match position by one more character. */
if (start_match[-1] == '\r' && if (start_match[-1] == '\r' &&
start_match < end_subject &&
*start_match == '\n' &&
(re->flags & PCRE_HASCRORLF) == 0 &&
(md->nltype == NLTYPE_ANY || (md->nltype == NLTYPE_ANY ||
md->nltype == NLTYPE_ANYCRLF || md->nltype == NLTYPE_ANYCRLF ||
md->nllen == 2) && md->nllen == 2))
start_match < end_subject &&
*start_match == '\n')
start_match++; start_match++;
} /* End of for(;;) "bumpalong" loop */ } /* End of for(;;) "bumpalong" loop */
@@ -4729,7 +4860,7 @@ for(;;)
/* We reach here when rc is not MATCH_NOMATCH, or if one of the stopping /* We reach here when rc is not MATCH_NOMATCH, or if one of the stopping
conditions is true: conditions is true:
(1) The pattern is anchored; (1) The pattern is anchored or the match was failed by (*COMMIT);
(2) We are past the end of the subject; (2) We are past the end of the subject;
@@ -4744,6 +4875,8 @@ processing, copy those that we can. In this case there need not be overflow if
certain parts of the pattern were not used, even though there are more certain parts of the pattern were not used, even though there are more
capturing parentheses than vector slots. */ capturing parentheses than vector slots. */
ENDLOOP:
if (rc == MATCH_MATCH) if (rc == MATCH_MATCH)
{ {
if (using_temporary_offsets) if (using_temporary_offsets)

View File

@@ -42,6 +42,12 @@ POSSIBILITY OF SUCH DAMAGE.
information about a compiled pattern. */ information about a compiled pattern. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
@@ -106,8 +112,8 @@ switch (what)
case PCRE_INFO_FIRSTBYTE: case PCRE_INFO_FIRSTBYTE:
*((int *)where) = *((int *)where) =
((re->options & PCRE_FIRSTSET) != 0)? re->first_byte : ((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte :
((re->options & PCRE_STARTLINE) != 0)? -1 : -2; ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
break; break;
/* Make sure we pass back the pointer to the bit vector in the external /* Make sure we pass back the pointer to the bit vector in the external
@@ -121,7 +127,7 @@ switch (what)
case PCRE_INFO_LASTLITERAL: case PCRE_INFO_LASTLITERAL:
*((int *)where) = *((int *)where) =
((re->options & PCRE_REQCHSET) != 0)? re->req_byte : -1; ((re->flags & PCRE_REQCHSET) != 0)? re->req_byte : -1;
break; break;
case PCRE_INFO_NAMEENTRYSIZE: case PCRE_INFO_NAMEENTRYSIZE:
@@ -141,11 +147,15 @@ switch (what)
break; break;
case PCRE_INFO_OKPARTIAL: case PCRE_INFO_OKPARTIAL:
*((int *)where) = (re->options & PCRE_NOPARTIAL) == 0; *((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0;
break; break;
case PCRE_INFO_JCHANGED: case PCRE_INFO_JCHANGED:
*((int *)where) = (re->options & PCRE_JCHANGED) != 0; *((int *)where) = (re->flags & PCRE_JCHANGED) != 0;
break;
case PCRE_INFO_HASCRORLF:
*((int *)where) = (re->flags & PCRE_HASCRORLF) != 0;
break; break;
default: return PCRE_ERROR_BADOPTION; default: return PCRE_ERROR_BADOPTION;

View File

@@ -43,6 +43,12 @@ from the subject string after a regex match has succeeded. The original idea
for these functions came from Scott Wimer. */ for these functions came from Scott Wimer. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
@@ -185,7 +191,7 @@ const real_pcre *re = (const real_pcre *)code;
int entrysize; int entrysize;
char *first, *last; char *first, *last;
uschar *entry; uschar *entry;
if ((re->options & (PCRE_DUPNAMES | PCRE_JCHANGED)) == 0) if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
return pcre_get_stringnumber(code, stringname); return pcre_get_stringnumber(code, stringname);
entrysize = pcre_get_stringtable_entries(code, stringname, &first, &last); entrysize = pcre_get_stringtable_entries(code, stringname, &first, &last);
if (entrysize <= 0) return entrysize; if (entrysize <= 0) return entrysize;

View File

@@ -46,6 +46,12 @@ indirection. These values can be changed by the caller, but are shared between
all threads. However, when compiling for Virtual Pascal, things are done all threads. However, when compiling for Virtual Pascal, things are done
differently, and global variables are not used (see pcre.in). */ differently, and global variables are not used (see pcre.in). */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
#ifndef VPCOMPAT #ifndef VPCOMPAT

View File

@@ -43,6 +43,12 @@ information about a compiled pattern. However, use of this function is now
deprecated, as it has been superseded by pcre_fullinfo(). */ deprecated, as it has been superseded by pcre_fullinfo(). */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
@@ -81,8 +87,8 @@ if (re->magic_number != MAGIC_NUMBER)
} }
if (optptr != NULL) *optptr = (int)(re->options & PUBLIC_OPTIONS); if (optptr != NULL) *optptr = (int)(re->options & PUBLIC_OPTIONS);
if (first_byte != NULL) if (first_byte != NULL)
*first_byte = ((re->options & PCRE_FIRSTSET) != 0)? re->first_byte : *first_byte = ((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte :
((re->options & PCRE_STARTLINE) != 0)? -1 : -2; ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
return re->top_bracket; return re->top_bracket;
} }

View File

@@ -67,14 +67,6 @@ be absolutely sure we get our version. */
#endif #endif
/* Get the definitions provided by running "configure" */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
/* Standard C headers plus the external interface definition. The only time /* Standard C headers plus the external interface definition. The only time
setjmp and stdarg are used is when NO_RECURSE is set. */ setjmp and stdarg are used is when NO_RECURSE is set. */
@@ -117,7 +109,7 @@ PCRE_EXP_DATA_DEFN only if they are not already set. */
#ifndef PCRE_EXP_DECL #ifndef PCRE_EXP_DECL
# ifdef _WIN32 # ifdef _WIN32
/* COMMENTED OUT AS IT'S COMPILED STATICALLY /* COMMENTED OUT AS IT'S COMPILED STATICALLY
# ifdef DLL_EXPORT # ifndef PCRE_STATIC
# define PCRE_EXP_DECL extern __declspec(dllexport) # define PCRE_EXP_DECL extern __declspec(dllexport)
# define PCRE_EXP_DEFN __declspec(dllexport) # define PCRE_EXP_DEFN __declspec(dllexport)
# define PCRE_EXP_DATA_DEFN __declspec(dllexport) # define PCRE_EXP_DATA_DEFN __declspec(dllexport)
@@ -129,7 +121,6 @@ PCRE_EXP_DATA_DEFN only if they are not already set. */
/* /*
# endif # endif
*/ */
#
# else # else
# ifdef __cplusplus # ifdef __cplusplus
# define PCRE_EXP_DECL extern "C" # define PCRE_EXP_DECL extern "C"
@@ -371,7 +362,9 @@ capturing parenthesis numbers in back references. */
/* When UTF-8 encoding is being used, a character is no longer just a single /* When UTF-8 encoding is being used, a character is no longer just a single
byte. The macros for character handling generate simple sequences when used in byte. The macros for character handling generate simple sequences when used in
byte-mode, and more complicated ones for UTF-8 characters. */ byte-mode, and more complicated ones for UTF-8 characters. BACKCHAR should
never be called in byte mode. To make sure it can never even appear when UTF-8
support is omitted, we don't even define it. */
#ifndef SUPPORT_UTF8 #ifndef SUPPORT_UTF8
#define GETCHAR(c, eptr) c = *eptr; #define GETCHAR(c, eptr) c = *eptr;
@@ -379,7 +372,7 @@ byte-mode, and more complicated ones for UTF-8 characters. */
#define GETCHARINC(c, eptr) c = *eptr++; #define GETCHARINC(c, eptr) c = *eptr++;
#define GETCHARINCTEST(c, eptr) c = *eptr++; #define GETCHARINCTEST(c, eptr) c = *eptr++;
#define GETCHARLEN(c, eptr, len) c = *eptr; #define GETCHARLEN(c, eptr, len) c = *eptr;
#define BACKCHAR(eptr) /* #define BACKCHAR(eptr) */
#else /* SUPPORT_UTF8 */ #else /* SUPPORT_UTF8 */
@@ -472,9 +465,10 @@ if there are extra bytes. This is called when we know we are in UTF-8 mode. */
} }
/* If the pointer is not at the start of a character, move it back until /* If the pointer is not at the start of a character, move it back until
it is. Called only in UTF-8 mode. */ it is. This is called only in UTF-8 mode - we don't put a test within the macro
because almost all calls are already within a block of UTF-8 only code. */
#define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--; #define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--
#endif #endif
@@ -491,17 +485,16 @@ Standard C system should have one. */
#define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL) #define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
/* Private options flags start at the most significant end of the four bytes. /* Private flags containing information about the compiled regex. They used to
The public options defined in pcre.h start at the least significant end. Make live at the top end of the options word, but that got almost full, so now they
sure they don't overlap! The bits are getting a bit scarce now -- when we run are in a 16-bit flags word. */
out, there is a dummy word in the structure that could be used for the private
bits. */
#define PCRE_NOPARTIAL 0x80000000 /* can't use partial with this regex */ #define PCRE_NOPARTIAL 0x0001 /* can't use partial with this regex */
#define PCRE_FIRSTSET 0x40000000 /* first_byte is set */ #define PCRE_FIRSTSET 0x0002 /* first_byte is set */
#define PCRE_REQCHSET 0x20000000 /* req_byte is set */ #define PCRE_REQCHSET 0x0004 /* req_byte is set */
#define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */ #define PCRE_STARTLINE 0x0008 /* start after \n for multiline */
#define PCRE_JCHANGED 0x08000000 /* j option changes within regex */ #define PCRE_JCHANGED 0x0010 /* j option used in regex */
#define PCRE_HASCRORLF 0x0020 /* explicit \r or \n in pattern */
/* Options for the "extra" block produced by pcre_study(). */ /* Options for the "extra" block produced by pcre_study(). */
@@ -517,15 +510,16 @@ time, run time, or study time, respectively. */
(PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \ (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \ PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE| \ PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE| \
PCRE_DUPNAMES|PCRE_NEWLINE_BITS) PCRE_DUPNAMES|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)
#define PUBLIC_EXEC_OPTIONS \ #define PUBLIC_EXEC_OPTIONS \
(PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \ (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
PCRE_PARTIAL|PCRE_NEWLINE_BITS) PCRE_PARTIAL|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)
#define PUBLIC_DFA_EXEC_OPTIONS \ #define PUBLIC_DFA_EXEC_OPTIONS \
(PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \ (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
PCRE_PARTIAL|PCRE_DFA_SHORTEST|PCRE_DFA_RESTART|PCRE_NEWLINE_BITS) PCRE_PARTIAL|PCRE_DFA_SHORTEST|PCRE_DFA_RESTART|PCRE_NEWLINE_BITS| \
PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)
#define PUBLIC_STUDY_OPTIONS 0 /* None defined */ #define PUBLIC_STUDY_OPTIONS 0 /* None defined */
@@ -618,14 +612,9 @@ enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_k, ESC_REF }; ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_k, ESC_REF };
/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets /* Opcode table: Starting from 1 (i.e. after OP_END), the values up to
that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
OP_EOD must correspond in order to the list of escapes immediately above. OP_EOD must correspond in order to the list of escapes immediately above.
To keep stored, compiled patterns compatible, new opcodes should be added
immediately before OP_BRA, where (since release 7.0) a gap is left for this
purpose.
*** NOTE NOTE NOTE *** Whenever this list is updated, the two macro definitions *** NOTE NOTE NOTE *** Whenever this list is updated, the two macro definitions
that follow must also be updated to match. There is also a table called that follow must also be updated to match. There is also a table called
"coptable" in pcre_dfa_exec.c that must be updated. */ "coptable" in pcre_dfa_exec.c that must be updated. */
@@ -752,7 +741,7 @@ enum {
as there's a test for >= ONCE for a subpattern that isn't an assertion. */ as there's a test for >= ONCE for a subpattern that isn't an assertion. */
OP_ONCE, /* 92 Atomic group */ OP_ONCE, /* 92 Atomic group */
OP_BRA, /* 83 Start of non-capturing bracket */ OP_BRA, /* 93 Start of non-capturing bracket */
OP_CBRA, /* 94 Start of capturing bracket */ OP_CBRA, /* 94 Start of capturing bracket */
OP_COND, /* 95 Conditional group */ OP_COND, /* 95 Conditional group */
@@ -768,7 +757,19 @@ enum {
OP_DEF, /* 101 The DEFINE condition */ OP_DEF, /* 101 The DEFINE condition */
OP_BRAZERO, /* 102 These two must remain together and in this */ OP_BRAZERO, /* 102 These two must remain together and in this */
OP_BRAMINZERO /* 103 order. */ OP_BRAMINZERO, /* 103 order. */
/* These are backtracking control verbs */
OP_PRUNE, /* 104 */
OP_SKIP, /* 105 */
OP_THEN, /* 106 */
OP_COMMIT, /* 107 */
/* These are forced failure and success verbs */
OP_FAIL, /* 108 */
OP_ACCEPT /* 109 */
}; };
@@ -791,8 +792,9 @@ for debugging. The macro is referenced only in pcre_printint.c. */
"class", "nclass", "xclass", "Ref", "Recurse", "Callout", \ "class", "nclass", "xclass", "Ref", "Recurse", "Callout", \
"Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not", \ "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not", \
"AssertB", "AssertB not", "Reverse", \ "AssertB", "AssertB not", "Reverse", \
"Once", "Bra 0", "Bra", "Cond", "SBra 0", "SBra", "SCond", \ "Once", "Bra", "CBra", "Cond", "SBra", "SCBra", "SCond", \
"Cond ref", "Cond rec", "Cond def", "Brazero", "Braminzero" "Cond ref", "Cond rec", "Cond def", "Brazero", "Braminzero", \
"*PRUNE", "*SKIP", "*THEN", "*COMMIT", "*FAIL", "*ACCEPT"
/* This macro defines the length of fixed length operations in the compiled /* This macro defines the length of fixed length operations in the compiled
@@ -856,6 +858,8 @@ in UTF-8 mode. The code that uses this table must know about such things. */
3, /* RREF */ \ 3, /* RREF */ \
1, /* DEF */ \ 1, /* DEF */ \
1, 1, /* BRAZERO, BRAMINZERO */ \ 1, 1, /* BRAZERO, BRAMINZERO */ \
1, 1, 1, 1, /* PRUNE, SKIP, THEN, COMMIT, */ \
1, 1 /* FAIL, ACCEPT */
/* A magic value for OP_RREF to indicate the "any recursion" condition. */ /* A magic value for OP_RREF to indicate the "any recursion" condition. */
@@ -870,7 +874,8 @@ enum { ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9,
ERR20, ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29, ERR20, ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29,
ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39, ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,
ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49, ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58 }; ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
ERR60, ERR61 };
/* The real format of the start of the pcre block; the index of names and the /* The real format of the start of the pcre block; the index of names and the
code vector run on as long as necessary after the end. We store an explicit code vector run on as long as necessary after the end. We store an explicit
@@ -892,9 +897,9 @@ NOTE NOTE NOTE:
typedef struct real_pcre { typedef struct real_pcre {
pcre_uint32 magic_number; pcre_uint32 magic_number;
pcre_uint32 size; /* Total that was malloced */ pcre_uint32 size; /* Total that was malloced */
pcre_uint32 options; pcre_uint32 options; /* Public options */
pcre_uint32 dummy1; /* For future use, maybe */ pcre_uint16 flags; /* Private flags */
pcre_uint16 dummy1; /* For future use */
pcre_uint16 top_bracket; pcre_uint16 top_bracket;
pcre_uint16 top_backref; pcre_uint16 top_backref;
pcre_uint16 first_byte; pcre_uint16 first_byte;
@@ -937,8 +942,9 @@ typedef struct compile_data {
int top_backref; /* Maximum back reference */ int top_backref; /* Maximum back reference */
unsigned int backref_map; /* Bitmap of low back refs */ unsigned int backref_map; /* Bitmap of low back refs */
int external_options; /* External (initial) options */ int external_options; /* External (initial) options */
int external_flags; /* External flag bits to be set */
int req_varyopt; /* "After variable item" flag for reqbyte */ int req_varyopt; /* "After variable item" flag for reqbyte */
BOOL nopartial; /* Set TRUE if partial won't work */ BOOL had_accept; /* (*ACCEPT) encountered */
int nltype; /* Newline type */ int nltype; /* Newline type */
int nllen; /* Newline string length */ int nllen; /* Newline string length */
uschar nl[4]; /* Newline string when fixed length */ uschar nl[4]; /* Newline string when fixed length */
@@ -997,6 +1003,7 @@ typedef struct match_data {
BOOL notempty; /* Empty string match not wanted */ BOOL notempty; /* Empty string match not wanted */
BOOL partial; /* PARTIAL flag */ BOOL partial; /* PARTIAL flag */
BOOL hitend; /* Hit the end of the subject at some point */ BOOL hitend; /* Hit the end of the subject at some point */
BOOL bsr_anycrlf; /* \R is just any CRLF, not full Unicode */
const uschar *start_code; /* For use when recursing */ const uschar *start_code; /* For use when recursing */
USPTR start_subject; /* Start of the subject string */ USPTR start_subject; /* Start of the subject string */
USPTR end_subject; /* End of the subject string */ USPTR end_subject; /* End of the subject string */
@@ -1061,10 +1068,12 @@ total length. */
#define tables_length (ctypes_offset + 256) #define tables_length (ctypes_offset + 256)
/* Layout of the UCP type table that translates property names into types and /* Layout of the UCP type table that translates property names into types and
codes. */ codes. Each entry used to point directly to a name, but to reduce the number of
relocations in shared libraries, it now has an offset into a single string
instead. */
typedef struct { typedef struct {
const char *name; pcre_uint16 name_offset;
pcre_uint16 type; pcre_uint16 type;
pcre_uint16 value; pcre_uint16 value;
} ucp_type_table; } ucp_type_table;
@@ -1082,6 +1091,7 @@ extern const uschar _pcre_utf8_table4[];
extern const int _pcre_utf8_table1_size; extern const int _pcre_utf8_table1_size;
extern const char _pcre_utt_names[];
extern const ucp_type_table _pcre_utt[]; extern const ucp_type_table _pcre_utt[];
extern const int _pcre_utt_size; extern const int _pcre_utt_size;

View File

@@ -45,6 +45,11 @@ compilation of dftables.c, in which case the macro DFTABLES is defined. */
#ifndef DFTABLES #ifndef DFTABLES
# ifdef WIN32
# include "pcre_winconfig.h"
# else
# include "config.h"
# endif
# include "pcre_internal.h" # include "pcre_internal.h"
#endif #endif

View File

@@ -47,6 +47,12 @@ and NLTYPE_ANY. The full list of Unicode newline characters is taken from
http://unicode.org/unicode/reports/tr18/. */ http://unicode.org/unicode/reports/tr18/. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
@@ -124,12 +130,16 @@ _pcre_was_newline(const uschar *ptr, int type, const uschar *startptr,
{ {
int c; int c;
ptr--; ptr--;
#ifdef SUPPORT_UTF8
if (utf8) if (utf8)
{ {
BACKCHAR(ptr); BACKCHAR(ptr);
GETCHAR(c, ptr); GETCHAR(c, ptr);
} }
else c = *ptr; else c = *ptr;
#else /* no UTF-8 support */
c = *ptr;
#endif /* SUPPORT_UTF8 */
if (type == NLTYPE_ANYCRLF) switch(c) if (type == NLTYPE_ANYCRLF) switch(c)
{ {

View File

@@ -41,6 +41,11 @@ POSSIBILITY OF SUCH DAMAGE.
/* This file contains a private PCRE function that converts an ordinal /* This file contains a private PCRE function that converts an ordinal
character value into a UTF8 string. */ character value into a UTF8 string. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"

View File

@@ -43,6 +43,13 @@ auxiliary function that can be used to maintain a reference count in a compiled
pattern data block. This might be helpful in applications where the block is pattern data block. This might be helpful in applications where the block is
shared by different users. */ shared by different users. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"

View File

@@ -42,6 +42,12 @@ POSSIBILITY OF SUCH DAMAGE.
supporting functions. */ supporting functions. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
@@ -523,7 +529,8 @@ code = (uschar *)re + re->name_table_offset +
a multiline pattern that matches only at "line starts", no further processing a multiline pattern that matches only at "line starts", no further processing
at present. */ at present. */
if ((re->options & (PCRE_ANCHORED|PCRE_FIRSTSET|PCRE_STARTLINE)) != 0) if ((re->options & PCRE_ANCHORED) != 0 ||
(re->flags & (PCRE_FIRSTSET|PCRE_STARTLINE)) != 0)
return NULL; return NULL;
/* Set the character tables in the block that is passed around */ /* Set the character tables in the block that is passed around */

View File

@@ -44,6 +44,12 @@ uses macros to change their names from _pcre_xxx to xxxx, thereby avoiding name
clashes with the library. */ clashes with the library. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
@@ -83,115 +89,228 @@ const uschar _pcre_utf8_table4[] = {
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 }; 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
/* This table translates Unicode property names into type and code values. It /* The pcre_utt[] table below translates Unicode property names into type and
is searched by binary chop, so must be in collating sequence of name. */ code values. It is searched by binary chop, so must be in collating sequence of
name. Originally, the table contained pointers to the name strings in the first
field of each entry. However, that leads to a large number of relocations when
a shared library is dynamically loaded. A significant reduction is made by
putting all the names into a single, large string and then using offsets in the
table itself. Maintenance is more error-prone, but frequent changes to this
data is unlikely. */
const char _pcre_utt_names[] =
"Any\0"
"Arabic\0"
"Armenian\0"
"Balinese\0"
"Bengali\0"
"Bopomofo\0"
"Braille\0"
"Buginese\0"
"Buhid\0"
"C\0"
"Canadian_Aboriginal\0"
"Cc\0"
"Cf\0"
"Cherokee\0"
"Cn\0"
"Co\0"
"Common\0"
"Coptic\0"
"Cs\0"
"Cuneiform\0"
"Cypriot\0"
"Cyrillic\0"
"Deseret\0"
"Devanagari\0"
"Ethiopic\0"
"Georgian\0"
"Glagolitic\0"
"Gothic\0"
"Greek\0"
"Gujarati\0"
"Gurmukhi\0"
"Han\0"
"Hangul\0"
"Hanunoo\0"
"Hebrew\0"
"Hiragana\0"
"Inherited\0"
"Kannada\0"
"Katakana\0"
"Kharoshthi\0"
"Khmer\0"
"L\0"
"L&\0"
"Lao\0"
"Latin\0"
"Limbu\0"
"Linear_B\0"
"Ll\0"
"Lm\0"
"Lo\0"
"Lt\0"
"Lu\0"
"M\0"
"Malayalam\0"
"Mc\0"
"Me\0"
"Mn\0"
"Mongolian\0"
"Myanmar\0"
"N\0"
"Nd\0"
"New_Tai_Lue\0"
"Nko\0"
"Nl\0"
"No\0"
"Ogham\0"
"Old_Italic\0"
"Old_Persian\0"
"Oriya\0"
"Osmanya\0"
"P\0"
"Pc\0"
"Pd\0"
"Pe\0"
"Pf\0"
"Phags_Pa\0"
"Phoenician\0"
"Pi\0"
"Po\0"
"Ps\0"
"Runic\0"
"S\0"
"Sc\0"
"Shavian\0"
"Sinhala\0"
"Sk\0"
"Sm\0"
"So\0"
"Syloti_Nagri\0"
"Syriac\0"
"Tagalog\0"
"Tagbanwa\0"
"Tai_Le\0"
"Tamil\0"
"Telugu\0"
"Thaana\0"
"Thai\0"
"Tibetan\0"
"Tifinagh\0"
"Ugaritic\0"
"Yi\0"
"Z\0"
"Zl\0"
"Zp\0"
"Zs\0";
const ucp_type_table _pcre_utt[] = { const ucp_type_table _pcre_utt[] = {
{ "Any", PT_ANY, 0 }, { 0, PT_ANY, 0 },
{ "Arabic", PT_SC, ucp_Arabic }, { 4, PT_SC, ucp_Arabic },
{ "Armenian", PT_SC, ucp_Armenian }, { 11, PT_SC, ucp_Armenian },
{ "Balinese", PT_SC, ucp_Balinese }, { 20, PT_SC, ucp_Balinese },
{ "Bengali", PT_SC, ucp_Bengali }, { 29, PT_SC, ucp_Bengali },
{ "Bopomofo", PT_SC, ucp_Bopomofo }, { 37, PT_SC, ucp_Bopomofo },
{ "Braille", PT_SC, ucp_Braille }, { 46, PT_SC, ucp_Braille },
{ "Buginese", PT_SC, ucp_Buginese }, { 54, PT_SC, ucp_Buginese },
{ "Buhid", PT_SC, ucp_Buhid }, { 63, PT_SC, ucp_Buhid },
{ "C", PT_GC, ucp_C }, { 69, PT_GC, ucp_C },
{ "Canadian_Aboriginal", PT_SC, ucp_Canadian_Aboriginal }, { 71, PT_SC, ucp_Canadian_Aboriginal },
{ "Cc", PT_PC, ucp_Cc }, { 91, PT_PC, ucp_Cc },
{ "Cf", PT_PC, ucp_Cf }, { 94, PT_PC, ucp_Cf },
{ "Cherokee", PT_SC, ucp_Cherokee }, { 97, PT_SC, ucp_Cherokee },
{ "Cn", PT_PC, ucp_Cn }, { 106, PT_PC, ucp_Cn },
{ "Co", PT_PC, ucp_Co }, { 109, PT_PC, ucp_Co },
{ "Common", PT_SC, ucp_Common }, { 112, PT_SC, ucp_Common },
{ "Coptic", PT_SC, ucp_Coptic }, { 119, PT_SC, ucp_Coptic },
{ "Cs", PT_PC, ucp_Cs }, { 126, PT_PC, ucp_Cs },
{ "Cuneiform", PT_SC, ucp_Cuneiform }, { 129, PT_SC, ucp_Cuneiform },
{ "Cypriot", PT_SC, ucp_Cypriot }, { 139, PT_SC, ucp_Cypriot },
{ "Cyrillic", PT_SC, ucp_Cyrillic }, { 147, PT_SC, ucp_Cyrillic },
{ "Deseret", PT_SC, ucp_Deseret }, { 156, PT_SC, ucp_Deseret },
{ "Devanagari", PT_SC, ucp_Devanagari }, { 164, PT_SC, ucp_Devanagari },
{ "Ethiopic", PT_SC, ucp_Ethiopic }, { 175, PT_SC, ucp_Ethiopic },
{ "Georgian", PT_SC, ucp_Georgian }, { 184, PT_SC, ucp_Georgian },
{ "Glagolitic", PT_SC, ucp_Glagolitic }, { 193, PT_SC, ucp_Glagolitic },
{ "Gothic", PT_SC, ucp_Gothic }, { 204, PT_SC, ucp_Gothic },
{ "Greek", PT_SC, ucp_Greek }, { 211, PT_SC, ucp_Greek },
{ "Gujarati", PT_SC, ucp_Gujarati }, { 217, PT_SC, ucp_Gujarati },
{ "Gurmukhi", PT_SC, ucp_Gurmukhi }, { 226, PT_SC, ucp_Gurmukhi },
{ "Han", PT_SC, ucp_Han }, { 235, PT_SC, ucp_Han },
{ "Hangul", PT_SC, ucp_Hangul }, { 239, PT_SC, ucp_Hangul },
{ "Hanunoo", PT_SC, ucp_Hanunoo }, { 246, PT_SC, ucp_Hanunoo },
{ "Hebrew", PT_SC, ucp_Hebrew }, { 254, PT_SC, ucp_Hebrew },
{ "Hiragana", PT_SC, ucp_Hiragana }, { 261, PT_SC, ucp_Hiragana },
{ "Inherited", PT_SC, ucp_Inherited }, { 270, PT_SC, ucp_Inherited },
{ "Kannada", PT_SC, ucp_Kannada }, { 280, PT_SC, ucp_Kannada },
{ "Katakana", PT_SC, ucp_Katakana }, { 288, PT_SC, ucp_Katakana },
{ "Kharoshthi", PT_SC, ucp_Kharoshthi }, { 297, PT_SC, ucp_Kharoshthi },
{ "Khmer", PT_SC, ucp_Khmer }, { 308, PT_SC, ucp_Khmer },
{ "L", PT_GC, ucp_L }, { 314, PT_GC, ucp_L },
{ "L&", PT_LAMP, 0 }, { 316, PT_LAMP, 0 },
{ "Lao", PT_SC, ucp_Lao }, { 319, PT_SC, ucp_Lao },
{ "Latin", PT_SC, ucp_Latin }, { 323, PT_SC, ucp_Latin },
{ "Limbu", PT_SC, ucp_Limbu }, { 329, PT_SC, ucp_Limbu },
{ "Linear_B", PT_SC, ucp_Linear_B }, { 335, PT_SC, ucp_Linear_B },
{ "Ll", PT_PC, ucp_Ll }, { 344, PT_PC, ucp_Ll },
{ "Lm", PT_PC, ucp_Lm }, { 347, PT_PC, ucp_Lm },
{ "Lo", PT_PC, ucp_Lo }, { 350, PT_PC, ucp_Lo },
{ "Lt", PT_PC, ucp_Lt }, { 353, PT_PC, ucp_Lt },
{ "Lu", PT_PC, ucp_Lu }, { 356, PT_PC, ucp_Lu },
{ "M", PT_GC, ucp_M }, { 359, PT_GC, ucp_M },
{ "Malayalam", PT_SC, ucp_Malayalam }, { 361, PT_SC, ucp_Malayalam },
{ "Mc", PT_PC, ucp_Mc }, { 371, PT_PC, ucp_Mc },
{ "Me", PT_PC, ucp_Me }, { 374, PT_PC, ucp_Me },
{ "Mn", PT_PC, ucp_Mn }, { 377, PT_PC, ucp_Mn },
{ "Mongolian", PT_SC, ucp_Mongolian }, { 380, PT_SC, ucp_Mongolian },
{ "Myanmar", PT_SC, ucp_Myanmar }, { 390, PT_SC, ucp_Myanmar },
{ "N", PT_GC, ucp_N }, { 398, PT_GC, ucp_N },
{ "Nd", PT_PC, ucp_Nd }, { 400, PT_PC, ucp_Nd },
{ "New_Tai_Lue", PT_SC, ucp_New_Tai_Lue }, { 403, PT_SC, ucp_New_Tai_Lue },
{ "Nko", PT_SC, ucp_Nko }, { 415, PT_SC, ucp_Nko },
{ "Nl", PT_PC, ucp_Nl }, { 419, PT_PC, ucp_Nl },
{ "No", PT_PC, ucp_No }, { 422, PT_PC, ucp_No },
{ "Ogham", PT_SC, ucp_Ogham }, { 425, PT_SC, ucp_Ogham },
{ "Old_Italic", PT_SC, ucp_Old_Italic }, { 431, PT_SC, ucp_Old_Italic },
{ "Old_Persian", PT_SC, ucp_Old_Persian }, { 442, PT_SC, ucp_Old_Persian },
{ "Oriya", PT_SC, ucp_Oriya }, { 454, PT_SC, ucp_Oriya },
{ "Osmanya", PT_SC, ucp_Osmanya }, { 460, PT_SC, ucp_Osmanya },
{ "P", PT_GC, ucp_P }, { 468, PT_GC, ucp_P },
{ "Pc", PT_PC, ucp_Pc }, { 470, PT_PC, ucp_Pc },
{ "Pd", PT_PC, ucp_Pd }, { 473, PT_PC, ucp_Pd },
{ "Pe", PT_PC, ucp_Pe }, { 476, PT_PC, ucp_Pe },
{ "Pf", PT_PC, ucp_Pf }, { 479, PT_PC, ucp_Pf },
{ "Phags_Pa", PT_SC, ucp_Phags_Pa }, { 482, PT_SC, ucp_Phags_Pa },
{ "Phoenician", PT_SC, ucp_Phoenician }, { 491, PT_SC, ucp_Phoenician },
{ "Pi", PT_PC, ucp_Pi }, { 502, PT_PC, ucp_Pi },
{ "Po", PT_PC, ucp_Po }, { 505, PT_PC, ucp_Po },
{ "Ps", PT_PC, ucp_Ps }, { 508, PT_PC, ucp_Ps },
{ "Runic", PT_SC, ucp_Runic }, { 511, PT_SC, ucp_Runic },
{ "S", PT_GC, ucp_S }, { 517, PT_GC, ucp_S },
{ "Sc", PT_PC, ucp_Sc }, { 519, PT_PC, ucp_Sc },
{ "Shavian", PT_SC, ucp_Shavian }, { 522, PT_SC, ucp_Shavian },
{ "Sinhala", PT_SC, ucp_Sinhala }, { 530, PT_SC, ucp_Sinhala },
{ "Sk", PT_PC, ucp_Sk }, { 538, PT_PC, ucp_Sk },
{ "Sm", PT_PC, ucp_Sm }, { 541, PT_PC, ucp_Sm },
{ "So", PT_PC, ucp_So }, { 544, PT_PC, ucp_So },
{ "Syloti_Nagri", PT_SC, ucp_Syloti_Nagri }, { 547, PT_SC, ucp_Syloti_Nagri },
{ "Syriac", PT_SC, ucp_Syriac }, { 560, PT_SC, ucp_Syriac },
{ "Tagalog", PT_SC, ucp_Tagalog }, { 567, PT_SC, ucp_Tagalog },
{ "Tagbanwa", PT_SC, ucp_Tagbanwa }, { 575, PT_SC, ucp_Tagbanwa },
{ "Tai_Le", PT_SC, ucp_Tai_Le }, { 584, PT_SC, ucp_Tai_Le },
{ "Tamil", PT_SC, ucp_Tamil }, { 591, PT_SC, ucp_Tamil },
{ "Telugu", PT_SC, ucp_Telugu }, { 597, PT_SC, ucp_Telugu },
{ "Thaana", PT_SC, ucp_Thaana }, { 604, PT_SC, ucp_Thaana },
{ "Thai", PT_SC, ucp_Thai }, { 611, PT_SC, ucp_Thai },
{ "Tibetan", PT_SC, ucp_Tibetan }, { 616, PT_SC, ucp_Tibetan },
{ "Tifinagh", PT_SC, ucp_Tifinagh }, { 624, PT_SC, ucp_Tifinagh },
{ "Ugaritic", PT_SC, ucp_Ugaritic }, { 633, PT_SC, ucp_Ugaritic },
{ "Yi", PT_SC, ucp_Yi }, { 642, PT_SC, ucp_Yi },
{ "Z", PT_GC, ucp_Z }, { 645, PT_GC, ucp_Z },
{ "Zl", PT_PC, ucp_Zl }, { 647, PT_PC, ucp_Zl },
{ "Zp", PT_PC, ucp_Zp }, { 650, PT_PC, ucp_Zp },
{ "Zs", PT_PC, ucp_Zs } { 653, PT_PC, ucp_Zs }
}; };
const int _pcre_utt_size = sizeof(_pcre_utt)/sizeof(ucp_type_table); const int _pcre_utt_size = sizeof(_pcre_utt)/sizeof(ucp_type_table);

View File

@@ -43,6 +43,12 @@ see if it was compiled with the opposite endianness. If so, it uses an
auxiliary local function to flip the appropriate bytes. */ auxiliary local function to flip the appropriate bytes. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
@@ -104,6 +110,7 @@ if (byteflip(re->magic_number, sizeof(re->magic_number)) != MAGIC_NUMBER)
*internal_re = *re; /* To copy other fields */ *internal_re = *re; /* To copy other fields */
internal_re->size = byteflip(re->size, sizeof(re->size)); internal_re->size = byteflip(re->size, sizeof(re->size));
internal_re->options = byteflip(re->options, sizeof(re->options)); internal_re->options = byteflip(re->options, sizeof(re->options));
internal_re->flags = (pcre_uint16)byteflip(re->flags, sizeof(re->flags));
internal_re->top_bracket = internal_re->top_bracket =
(pcre_uint16)byteflip(re->top_bracket, sizeof(re->top_bracket)); (pcre_uint16)byteflip(re->top_bracket, sizeof(re->top_bracket));
internal_re->top_backref = internal_re->top_backref =

View File

@@ -41,6 +41,12 @@ POSSIBILITY OF SUCH DAMAGE.
/* This module contains code for searching the table of Unicode character /* This module contains code for searching the table of Unicode character
properties. */ properties. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
#include "ucp.h" /* Category definitions */ #include "ucp.h" /* Category definitions */

View File

@@ -42,6 +42,12 @@ POSSIBILITY OF SUCH DAMAGE.
strings. */ strings. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"
@@ -55,6 +61,13 @@ that subsequent code can assume it is dealing with a valid string. The check
can be turned off for maximum performance, but the consequences of supplying can be turned off for maximum performance, but the consequences of supplying
an invalid string are then undefined. an invalid string are then undefined.
Originally, this function checked according to RFC 2279, allowing for values in
the range 0 to 0x7fffffff, up to 6 bytes long, but ensuring that they were in
the canonical format. Once somebody had pointed out RFC 3629 to me (it
obsoletes 2279), additional restrictions were applies. The values are now
limited to be between 0 and 0x0010ffff, no more than 4 bytes long, and the
subrange 0xd000 to 0xdfff is excluded.
Arguments: Arguments:
string points to the string string points to the string
length length of string, or -1 if the string is zero-terminated length length of string, or -1 if the string is zero-terminated
@@ -82,30 +95,47 @@ for (p = string; length-- > 0; p++)
if (c < 128) continue; if (c < 128) continue;
if (c < 0xc0) return p - string; if (c < 0xc0) return p - string;
ab = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */ ab = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */
if (length < ab) return p - string; if (length < ab || ab > 3) return p - string;
length -= ab; length -= ab;
/* Check top bits in the second byte */ /* Check top bits in the second byte */
if ((*(++p) & 0xc0) != 0x80) return p - string; if ((*(++p) & 0xc0) != 0x80) return p - string;
/* Check for overlong sequences for each different length */ /* Check for overlong sequences for each different length, and for the
excluded range 0xd000 to 0xdfff. */
switch (ab) switch (ab)
{ {
/* Check for xx00 000x */ /* Check for xx00 000x (overlong sequence) */
case 1: case 1:
if ((c & 0x3e) == 0) return p - string; if ((c & 0x3e) == 0) return p - string;
continue; /* We know there aren't any more bytes to check */ continue; /* We know there aren't any more bytes to check */
/* Check for 1110 0000, xx0x xxxx */ /* Check for 1110 0000, xx0x xxxx (overlong sequence) or
1110 1101, 1010 xxxx (0xd000 - 0xdfff) */
case 2: case 2:
if (c == 0xe0 && (*p & 0x20) == 0) return p - string; if ((c == 0xe0 && (*p & 0x20) == 0) ||
(c == 0xed && *p >= 0xa0))
return p - string;
break; break;
/* Check for 1111 0000, xx00 xxxx */ /* Check for 1111 0000, xx00 xxxx (overlong sequence) or
greater than 0x0010ffff (f4 8f bf bf) */
case 3: case 3:
if (c == 0xf0 && (*p & 0x30) == 0) return p - string; if ((c == 0xf0 && (*p & 0x30) == 0) ||
(c > 0xf4 ) ||
(c == 0xf4 && *p > 0x8f))
return p - string;
break; break;
#if 0
/* These cases can no longer occur, as we restrict to a maximum of four
bytes nowadays. Leave the code here in case we ever want to add an option
for longer sequences. */
/* Check for 1111 1000, xx00 0xxx */ /* Check for 1111 1000, xx00 0xxx */
case 4: case 4:
if (c == 0xf8 && (*p & 0x38) == 0) return p - string; if (c == 0xf8 && (*p & 0x38) == 0) return p - string;
@@ -116,6 +146,8 @@ for (p = string; length-- > 0; p++)
if (c == 0xfe || c == 0xff || if (c == 0xfe || c == 0xff ||
(c == 0xfc && (*p & 0x3c) == 0)) return p - string; (c == 0xfc && (*p & 0x3c) == 0)) return p - string;
break; break;
#endif
} }
/* Check for valid bytes after the 2nd, if any; all must start 10 */ /* Check for valid bytes after the 2nd, if any; all must start 10 */

View File

@@ -42,6 +42,12 @@ POSSIBILITY OF SUCH DAMAGE.
string that identifies the PCRE version that is in use. */ string that identifies the PCRE version that is in use. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"

View File

@@ -43,6 +43,12 @@ class (one that contains characters whose values are > 255). It is used by both
pcre_exec() and pcre_def_exec(). */ pcre_exec() and pcre_def_exec(). */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#include "config.h"
#endif
#include "pcre_internal.h" #include "pcre_internal.h"

View File

@@ -42,10 +42,26 @@ POSSIBILITY OF SUCH DAMAGE.
functions. */ functions. */
#ifdef WIN32
#include "pcre_winconfig.h"
#else
#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
#include "pcre.h"
#include "pcre_internal.h" #include "pcre_internal.h"
#include "pcreposix.h" #include "pcreposix.h"
#include "stdlib.h"
/* Table to translate PCRE compile time error codes into POSIX error codes. */ /* Table to translate PCRE compile time error codes into POSIX error codes. */
@@ -109,7 +125,8 @@ static const int eint[] = {
REG_BADPAT, /* repeating a DEFINE group is not allowed */ REG_BADPAT, /* repeating a DEFINE group is not allowed */
REG_INVARG, /* inconsistent NEWLINE options */ REG_INVARG, /* inconsistent NEWLINE options */
REG_BADPAT, /* \g is not followed followed by an (optionally braced) non-zero number */ REG_BADPAT, /* \g is not followed followed by an (optionally braced) non-zero number */
REG_BADPAT /* (?+ or (?- must be followed by a non-zero number */ REG_BADPAT, /* (?+ or (?- must be followed by a non-zero number */
REG_BADPAT /* number is too big */
}; };
/* Table of texts corresponding to POSIX error codes */ /* Table of texts corresponding to POSIX error codes */

View File

@@ -107,15 +107,14 @@ typedef struct {
/* When an application links to a PCRE DLL in Windows, the symbols that are /* 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 imported have to be identified as such. When building PCRE, the appropriate
export settings are needed. */ export settings are needed, and are set in pcreposix.c before including this
file. */
/* /*
#ifdef _WIN32 #if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL)
# ifndef PCREPOSIX_STATIC
# define PCREPOSIX_EXP_DECL extern __declspec(dllimport) # define PCREPOSIX_EXP_DECL extern __declspec(dllimport)
# define PCREPOSIX_EXP_DEFN __declspec(dllimport) # define PCREPOSIX_EXP_DEFN __declspec(dllimport)
#endif #endif
#endif
*/ */
/* By default, we use the standard "extern" declarations. */ /* By default, we use the standard "extern" declarations. */