summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--ext/pcre/config.w322
-rw-r--r--ext/pcre/config0.m44
-rw-r--r--ext/pcre/pcrelib/AUTHORS6
-rw-r--r--ext/pcre/pcrelib/COPYING65
-rw-r--r--ext/pcre/pcrelib/ChangeLog220
-rw-r--r--ext/pcre/pcrelib/HACKING (renamed from ext/pcre/pcrelib/doc/Tech.Notes)7
-rw-r--r--ext/pcre/pcrelib/LICENCE6
-rw-r--r--ext/pcre/pcrelib/NEWS63
-rw-r--r--ext/pcre/pcrelib/NON-UNIX-USE361
-rw-r--r--ext/pcre/pcrelib/README640
-rw-r--r--ext/pcre/pcrelib/config.h282
-rw-r--r--ext/pcre/pcrelib/dftables.c47
-rw-r--r--ext/pcre/pcrelib/doc/pcre.txt1538
-rw-r--r--ext/pcre/pcrelib/libpcre.def20
-rw-r--r--ext/pcre/pcrelib/libpcreposix.def25
-rw-r--r--ext/pcre/pcrelib/pcre.def29
-rw-r--r--ext/pcre/pcrelib/pcre.h108
-rw-r--r--ext/pcre/pcrelib/pcre_chartables.c39
-rw-r--r--ext/pcre/pcrelib/pcre_compile.c544
-rw-r--r--ext/pcre/pcrelib/pcre_config.c4
-rw-r--r--ext/pcre/pcrelib/pcre_exec.c850
-rw-r--r--ext/pcre/pcrelib/pcre_fullinfo.c12
-rw-r--r--ext/pcre/pcrelib/pcre_get.c2
-rw-r--r--ext/pcre/pcrelib/pcre_globals.c35
-rw-r--r--ext/pcre/pcrelib/pcre_info.c4
-rw-r--r--ext/pcre/pcrelib/pcre_internal.h384
-rw-r--r--ext/pcre/pcrelib/pcre_maketables.c2
-rw-r--r--ext/pcre/pcrelib/pcre_newline.c41
-rw-r--r--ext/pcre/pcrelib/pcre_ord2utf8.c6
-rw-r--r--ext/pcre/pcrelib/pcre_printint.src34
-rw-r--r--ext/pcre/pcrelib/pcre_refcount.c4
-rw-r--r--ext/pcre/pcrelib/pcre_scanner.cc194
-rw-r--r--ext/pcre/pcrelib/pcre_scanner.h171
-rw-r--r--ext/pcre/pcrelib/pcre_scanner_unittest.cc152
-rw-r--r--ext/pcre/pcrelib/pcre_stringpiece.cc39
-rw-r--r--ext/pcre/pcrelib/pcre_stringpiece.h172
-rw-r--r--ext/pcre/pcrelib/pcre_stringpiece_unittest.cc145
-rw-r--r--ext/pcre/pcrelib/pcre_study.c8
-rw-r--r--ext/pcre/pcrelib/pcre_tables.c6
-rw-r--r--ext/pcre/pcrelib/pcre_try_flipped.c2
-rw-r--r--ext/pcre/pcrelib/pcre_ucp_searchfuncs.c6
-rw-r--r--ext/pcre/pcrelib/pcre_valid_utf8.c4
-rw-r--r--ext/pcre/pcrelib/pcre_version.c4
-rw-r--r--ext/pcre/pcrelib/pcre_xclass.c2
-rw-r--r--ext/pcre/pcrelib/pcrecpp.cc857
-rw-r--r--ext/pcre/pcrelib/pcrecpp.h695
-rw-r--r--ext/pcre/pcrelib/pcrecpp_unittest.cc1227
-rw-r--r--ext/pcre/pcrelib/pcrecpparg.h171
-rw-r--r--ext/pcre/pcrelib/pcredemo.c4
-rw-r--r--ext/pcre/pcrelib/pcregrep.c163
-rw-r--r--ext/pcre/pcrelib/pcreposix.c17
-rw-r--r--ext/pcre/pcrelib/pcreposix.h40
-rw-r--r--ext/pcre/pcrelib/pcretest.c2305
-rw-r--r--ext/pcre/pcrelib/testdata/grepinputx7
-rw-r--r--ext/pcre/pcrelib/testdata/grepoutput56
-rw-r--r--ext/pcre/pcrelib/testdata/grepoutputN22
-rw-r--r--ext/pcre/pcrelib/testdata/testinput17
-rw-r--r--ext/pcre/pcrelib/testdata/testinput10104
-rw-r--r--ext/pcre/pcrelib/testdata/testinput21146
-rw-r--r--ext/pcre/pcrelib/testdata/testinput32
-rw-r--r--ext/pcre/pcrelib/testdata/testinput5186
-rw-r--r--ext/pcre/pcrelib/testdata/testinput638
-rw-r--r--ext/pcre/pcrelib/testdata/testinput773
-rw-r--r--ext/pcre/pcrelib/testdata/testinput838
-rw-r--r--ext/pcre/pcrelib/testdata/testinput96
-rw-r--r--ext/pcre/pcrelib/testdata/testoutput111
-rw-r--r--ext/pcre/pcrelib/testdata/testoutput10563
-rw-r--r--ext/pcre/pcrelib/testdata/testoutput23938
-rw-r--r--ext/pcre/pcrelib/testdata/testoutput314
-rw-r--r--ext/pcre/pcrelib/testdata/testoutput51061
-rw-r--r--ext/pcre/pcrelib/testdata/testoutput6156
-rw-r--r--ext/pcre/pcrelib/testdata/testoutput7126
-rw-r--r--ext/pcre/pcrelib/testdata/testoutput866
-rw-r--r--ext/pcre/pcrelib/testdata/testoutput98
-rw-r--r--ext/pcre/pcrelib/ucptable.h (renamed from ext/pcre/pcrelib/ucptable.c)2
-rw-r--r--ext/pcre/upgrade-pcre.php102
77 files changed, 8769 insertions, 10732 deletions
diff --git a/NEWS b/NEWS
index f9bb8671bd..882f22b791 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2007, PHP 5.2.4
+- Upgraded PCRE to version 7.2 (Nuno)
- HTTP 500 is sent to browser in case of PHP error instead of blank page.
(Dmitry, Andrei Nigmatulin)
- Improved fix for MOPB-03-2007. (Ilia)
diff --git a/ext/pcre/config.w32 b/ext/pcre/config.w32
index 110fb2a7f9..b52aa71236 100644
--- a/ext/pcre/config.w32
+++ b/ext/pcre/config.w32
@@ -5,7 +5,7 @@ ARG_WITH("pcre-regex", "Perl Compatible Regular Expressions", "yes");
if (PHP_PCRE_REGEX == "yes") {
EXTENSION("pcre", "php_pcre.c", PHP_PCRE_REGEX_SHARED,
- "-DEXPORT= -DNEWLINE=10 -DSUPPORT_UTF8 -DSUPPORT_UCP -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10 -DMATCH_LIMIT=10000000 -DMATCH_LIMIT_RECURSION=10000000 -DMAX_NAME_SIZE=32 -DMAX_NAME_COUNT=10000 -DMAX_DUPLENGTH=30000 -DEBCDIC=0 -DNO_RECURSE -Iext/pcre/pcrelib");
+ "-DNO_RECURSE -Iext/pcre/pcrelib");
ADD_SOURCES("ext/pcre/pcrelib", "pcre_chartables.c pcre_ucp_searchfuncs.c pcre_compile.c pcre_config.c pcre_exec.c pcre_fullinfo.c pcre_get.c pcre_globals.c pcre_info.c pcre_maketables.c pcre_newline.c pcre_ord2utf8.c pcre_refcount.c pcre_study.c pcre_tables.c pcre_try_flipped.c pcre_valid_utf8.c pcre_version.c pcre_xclass.c", "pcre");
ADD_DEF_FILE("ext\\pcre\\php_pcre.def");
diff --git a/ext/pcre/config0.m4 b/ext/pcre/config0.m4
index db864eb080..ea0184537d 100644
--- a/ext/pcre/config0.m4
+++ b/ext/pcre/config0.m4
@@ -13,7 +13,7 @@ PHP_ARG_WITH(pcre-regex,for PCRE support,
if test "$PHP_PCRE_REGEX" != "no"; then
if test "$PHP_PCRE_REGEX" = "yes"; then
- PHP_NEW_EXTENSION(pcre, pcrelib/pcre_chartables.c pcrelib/pcre_ucp_searchfuncs.c pcrelib/pcre_compile.c pcrelib/pcre_config.c pcrelib/pcre_exec.c pcrelib/pcre_fullinfo.c pcrelib/pcre_get.c pcrelib/pcre_globals.c pcrelib/pcre_info.c pcrelib/pcre_maketables.c pcrelib/pcre_newline.c pcrelib/pcre_ord2utf8.c pcrelib/pcre_refcount.c pcrelib/pcre_study.c pcrelib/pcre_tables.c pcrelib/pcre_try_flipped.c pcrelib/pcre_valid_utf8.c pcrelib/pcre_version.c pcrelib/pcre_xclass.c php_pcre.c, $ext_shared,,-DEXPORT= -DNEWLINE=10 -DSUPPORT_UTF8 -DSUPPORT_UCP -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10 -DMATCH_LIMIT=10000000 -DMATCH_LIMIT_RECURSION=10000000 -DMAX_NAME_SIZE=32 -DMAX_NAME_COUNT=10000 -DMAX_DUPLENGTH=30000 -DEBCDIC=0 -I@ext_srcdir@/pcrelib)
+ PHP_NEW_EXTENSION(pcre, pcrelib/pcre_chartables.c pcrelib/pcre_ucp_searchfuncs.c pcrelib/pcre_compile.c pcrelib/pcre_config.c pcrelib/pcre_exec.c pcrelib/pcre_fullinfo.c pcrelib/pcre_get.c pcrelib/pcre_globals.c pcrelib/pcre_info.c pcrelib/pcre_maketables.c pcrelib/pcre_newline.c pcrelib/pcre_ord2utf8.c pcrelib/pcre_refcount.c pcrelib/pcre_study.c pcrelib/pcre_tables.c pcrelib/pcre_try_flipped.c pcrelib/pcre_valid_utf8.c pcrelib/pcre_version.c pcrelib/pcre_xclass.c php_pcre.c, $ext_shared,,-I@ext_srcdir@/pcrelib)
PHP_ADD_BUILD_DIR($ext_builddir/pcrelib)
PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcrelib/])
AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
@@ -51,7 +51,7 @@ if test "$PHP_PCRE_REGEX" != "no"; then
AC_DEFINE(HAVE_PCRE, 1, [ ])
PHP_ADD_INCLUDE($PCRE_INCDIR)
- PHP_NEW_EXTENSION(pcre, php_pcre.c, $ext_shared,,-DEXPORT= -DNEWLINE=10 -DSUPPORT_UTF8 -DSUPPORT_UCP -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10 -DMATCH_LIMIT=10000000 -DMATCH_LIMIT_RECURSION=10000000 -DMAX_NAME_SIZE=32 -DMAX_NAME_COUNT=10000 -DMAX_DUPLENGTH=30000)
+ PHP_NEW_EXTENSION(pcre, php_pcre.c, $ext_shared)
PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h])
PHP_SUBST(PCRE_SHARED_LIBADD)
fi
diff --git a/ext/pcre/pcrelib/AUTHORS b/ext/pcre/pcrelib/AUTHORS
index adb4fc4019..36e4aafbd3 100644
--- a/ext/pcre/pcrelib/AUTHORS
+++ b/ext/pcre/pcrelib/AUTHORS
@@ -6,9 +6,9 @@ Email local part: ph10
Email domain: cam.ac.uk
University of Cambridge Computing Service,
-Cambridge, England. Phone: +44 1223 334714.
+Cambridge, England.
-Copyright (c) 1997-2006 University of Cambridge
+Copyright (c) 1997-2007 University of Cambridge
All rights reserved
@@ -17,7 +17,7 @@ THE C++ WRAPPER LIBRARY
Written by: Google Inc.
-Copyright (c) 2006 Google Inc
+Copyright (c) 2007 Google Inc
All rights reserved
####
diff --git a/ext/pcre/pcrelib/COPYING b/ext/pcre/pcrelib/COPYING
index 58241b2bda..58eed01b61 100644
--- a/ext/pcre/pcrelib/COPYING
+++ b/ext/pcre/pcrelib/COPYING
@@ -1,68 +1,5 @@
PCRE LICENCE
-------------
-PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
-Release 7 of PCRE is distributed under the terms of the "BSD" licence, as
-specified below. The documentation for PCRE, supplied in the "doc"
-directory, is distributed under the same terms as the software itself.
-
-The basic library functions are written in C and are freestanding. Also
-included in the distribution is a set of C++ wrapper functions.
-
-
-THE BASIC LIBRARY FUNCTIONS
----------------------------
-
-Written by: Philip Hazel
-Email local part: ph10
-Email domain: cam.ac.uk
-
-University of Cambridge Computing Service,
-Cambridge, England. Phone: +44 1223 334714.
-
-Copyright (c) 1997-2006 University of Cambridge
-All rights reserved.
-
-
-THE C++ WRAPPER FUNCTIONS
--------------------------
-
-Contributed by: Google Inc.
-
-Copyright (c) 2006, Google Inc.
-All rights reserved.
-
-
-THE "BSD" LICENCE
------------------
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the name of Google
- Inc. nor the names of their contributors may be used to endorse or
- promote products derived from this software without specific prior
- written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
+Please see the file LICENCE in the PCRE distribution for licensing details.
End
diff --git a/ext/pcre/pcrelib/ChangeLog b/ext/pcre/pcrelib/ChangeLog
index 7d32804d05..fb2747fd09 100644
--- a/ext/pcre/pcrelib/ChangeLog
+++ b/ext/pcre/pcrelib/ChangeLog
@@ -1,6 +1,226 @@
ChangeLog for PCRE
------------------
+Version 7.2 13-June-07
+---------------------
+
+ 1. If the fr_FR locale cannot be found for test 3, try the "french" locale,
+ which is apparently normally available under Windows.
+
+ 2. Re-jig the pcregrep tests with different newline settings in an attempt
+ to make them independent of the local environment's newline setting.
+
+ 3. Add code to configure.ac to remove -g from the CFLAGS default settings.
+
+ 4. Some of the "internals" tests were previously cut out when the link size
+ was not 2, because the output contained actual offsets. The recent new
+ "Z" feature of pcretest means that these can be cut out, making the tests
+ usable with all link sizes.
+
+ 5. Implemented Stan Switzer's goto replacement for longjmp() when not using
+ stack recursion. This gives a massive performance boost under BSD, but just
+ a small improvement under Linux. However, it saves one field in the frame
+ in all cases.
+
+ 6. Added more features from the forthcoming Perl 5.10:
+
+ (a) (?-n) (where n is a string of digits) is a relative subroutine or
+ recursion call. It refers to the nth most recently opened parentheses.
+
+ (b) (?+n) is also a relative subroutine call; it refers to the nth next
+ to be opened parentheses.
+
+ (c) Conditions that refer to capturing parentheses can be specified
+ relatively, for example, (?(-2)... or (?(+3)...
+
+ (d) \K resets the start of the current match so that everything before
+ is not part of it.
+
+ (e) \k{name} is synonymous with \k<name> and \k'name' (.NET compatible).
+
+ (f) \g{name} is another synonym - part of Perl 5.10's unification of
+ reference syntax.
+
+ (g) (?| introduces a group in which the numbering of parentheses in each
+ alternative starts with the same number.
+
+ (h) \h, \H, \v, and \V match horizontal and vertical whitespace.
+
+ 7. Added two new calls to pcre_fullinfo(): PCRE_INFO_OKPARTIAL and
+ PCRE_INFO_JCHANGED.
+
+ 8. A pattern such as (.*(.)?)* caused pcre_exec() to fail by either not
+ terminating or by crashing. Diagnosed by Viktor Griph; it was in the code
+ for detecting groups that can match an empty string.
+
+ 9. A pattern with a very large number of alternatives (more than several
+ hundred) was running out of internal workspace during the pre-compile
+ phase, where pcre_compile() figures out how much memory will be needed. A
+ bit of new cunning has reduced the workspace needed for groups with
+ alternatives. The 1000-alternative test pattern now uses 12 bytes of
+ workspace instead of running out of the 4096 that are available.
+
+10. Inserted some missing (unsigned int) casts to get rid of compiler warnings.
+
+11. Applied patch from Google to remove an optimization that didn't quite work.
+ The report of the bug said:
+
+ pcrecpp::RE("a*").FullMatch("aaa") matches, while
+ pcrecpp::RE("a*?").FullMatch("aaa") does not, and
+ pcrecpp::RE("a*?\\z").FullMatch("aaa") does again.
+
+
+Version 7.1 24-Apr-07
+---------------------
+
+ 1. Applied Bob Rossi and Daniel G's patches to convert the build system to one
+ that is more "standard", making use of automake and other Autotools. There
+ is some re-arrangement of the files and adjustment of comments consequent
+ on this.
+
+ 2. Part of the patch fixed a problem with the pcregrep tests. The test of -r
+ for recursive directory scanning broke on some systems because the files
+ are not scanned in any specific order and on different systems the order
+ was different. A call to "sort" has been inserted into RunGrepTest for the
+ approprate test as a short-term fix. In the longer term there may be an
+ alternative.
+
+ 3. I had an email from Eric Raymond about problems translating some of PCRE's
+ man pages to HTML (despite the fact that I distribute HTML pages, some
+ people do their own conversions for various reasons). The problems
+ concerned the use of low-level troff macros .br and .in. I have therefore
+ removed all such uses from the man pages (some were redundant, some could
+ be replaced by .nf/.fi pairs). The 132html script that I use to generate
+ HTML has been updated to handle .nf/.fi and to complain if it encounters
+ .br or .in.
+
+ 4. Updated comments in configure.ac that get placed in config.h.in and also
+ arranged for config.h to be included in the distribution, with the name
+ config.h.generic, for the benefit of those who have to compile without
+ Autotools (compare pcre.h, which is now distributed as pcre.h.generic).
+
+ 5. Updated the support (such as it is) for Virtual Pascal, thanks to Stefan
+ Weber: (1) pcre_internal.h was missing some function renames; (2) updated
+ makevp.bat for the current PCRE, using the additional files
+ makevp_c.txt, makevp_l.txt, and pcregexp.pas.
+
+ 6. A Windows user reported a minor discrepancy with test 2, which turned out
+ to be caused by a trailing space on an input line that had got lost in his
+ copy. The trailing space was an accident, so I've just removed it.
+
+ 7. Add -Wl,-R... flags in pcre-config.in for *BSD* systems, as I'm told
+ that is needed.
+
+ 8. Mark ucp_table (in ucptable.h) and ucp_gentype (in pcre_ucp_searchfuncs.c)
+ as "const" (a) because they are and (b) because it helps the PHP
+ maintainers who have recently made a script to detect big data structures
+ in the php code that should be moved to the .rodata section. I remembered
+ to update Builducptable as well, so it won't revert if ucptable.h is ever
+ re-created.
+
+ 9. Added some extra #ifdef SUPPORT_UTF8 conditionals into pcretest.c,
+ pcre_printint.src, pcre_compile.c, pcre_study.c, and pcre_tables.c, in
+ order to be able to cut out the UTF-8 tables in the latter when UTF-8
+ support is not required. This saves 1.5-2K of code, which is important in
+ some applications.
+
+ Later: more #ifdefs are needed in pcre_ord2utf8.c and pcre_valid_utf8.c
+ so as not to refer to the tables, even though these functions will never be
+ called when UTF-8 support is disabled. Otherwise there are problems with a
+ shared library.
+
+10. Fixed two bugs in the emulated memmove() function in pcre_internal.h:
+
+ (a) It was defining its arguments as char * instead of void *.
+
+ (b) It was assuming that all moves were upwards in memory; this was true
+ a long time ago when I wrote it, but is no longer the case.
+
+ The emulated memove() is provided for those environments that have neither
+ memmove() nor bcopy(). I didn't think anyone used it these days, but that
+ is clearly not the case, as these two bugs were recently reported.
+
+11. The script PrepareRelease is now distributed: it calls 132html, CleanTxt,
+ and Detrail to create the HTML documentation, the .txt form of the man
+ pages, and it removes trailing spaces from listed files. It also creates
+ pcre.h.generic and config.h.generic from pcre.h and config.h. In the latter
+ case, it wraps all the #defines with #ifndefs. This script should be run
+ before "make dist".
+
+12. Fixed two fairly obscure bugs concerned with quantified caseless matching
+ with Unicode property support.
+
+ (a) For a maximizing quantifier, if the two different cases of the
+ character were of different lengths in their UTF-8 codings (there are
+ some cases like this - I found 11), and the matching function had to
+ back up over a mixture of the two cases, it incorrectly assumed they
+ were both the same length.
+
+ (b) When PCRE was configured to use the heap rather than the stack for
+ recursion during matching, it was not correctly preserving the data for
+ the other case of a UTF-8 character when checking ahead for a match
+ while processing a minimizing repeat. If the check also involved
+ matching a wide character, but failed, corruption could cause an
+ erroneous result when trying to check for a repeat of the original
+ character.
+
+13. Some tidying changes to the testing mechanism:
+
+ (a) The RunTest script now detects the internal link size and whether there
+ is UTF-8 and UCP support by running ./pcretest -C instead of relying on
+ values substituted by "configure". (The RunGrepTest script already did
+ this for UTF-8.) The configure.ac script no longer substitutes the
+ relevant variables.
+
+ (b) The debugging options /B and /D in pcretest show the compiled bytecode
+ with length and offset values. This means that the output is different
+ for different internal link sizes. Test 2 is skipped for link sizes
+ other than 2 because of this, bypassing the problem. Unfortunately,
+ there was also a test in test 3 (the locale tests) that used /B and
+ failed for link sizes other than 2. Rather than cut the whole test out,
+ I have added a new /Z option to pcretest that replaces the length and
+ offset values with spaces. This is now used to make test 3 independent
+ of link size. (Test 2 will be tidied up later.)
+
+14. If erroroffset was passed as NULL to pcre_compile, it provoked a
+ segmentation fault instead of returning the appropriate error message.
+
+15. In multiline mode when the newline sequence was set to "any", the pattern
+ ^$ would give a match between the \r and \n of a subject such as "A\r\nB".
+ This doesn't seem right; it now treats the CRLF combination as the line
+ ending, and so does not match in that case. It's only a pattern such as ^$
+ that would hit this one: something like ^ABC$ would have failed after \r
+ and then tried again after \r\n.
+
+16. Changed the comparison command for RunGrepTest from "diff -u" to "diff -ub"
+ in an attempt to make files that differ only in their line terminators
+ compare equal. This works on Linux.
+
+17. Under certain error circumstances pcregrep might try to free random memory
+ as it exited. This is now fixed, thanks to valgrind.
+
+19. In pcretest, if the pattern /(?m)^$/g<any> was matched against the string
+ "abc\r\n\r\n", it found an unwanted second match after the second \r. This
+ was because its rules for how to advance for /g after matching an empty
+ string at the end of a line did not allow for this case. They now check for
+ it specially.
+
+20. pcretest is supposed to handle patterns and data of any length, by
+ extending its buffers when necessary. It was getting this wrong when the
+ buffer for a data line had to be extended.
+
+21. Added PCRE_NEWLINE_ANYCRLF which is like ANY, but matches only CR, LF, or
+ CRLF as a newline sequence.
+
+22. Code for handling Unicode properties in pcre_dfa_exec() wasn't being cut
+ out by #ifdef SUPPORT_UCP. This did no harm, as it could never be used, but
+ I have nevertheless tidied it up.
+
+23. Added some casts to kill warnings from HP-UX ia64 compiler.
+
+24. Added a man page for pcre-config.
+
+
Version 7.0 19-Dec-06
---------------------
diff --git a/ext/pcre/pcrelib/doc/Tech.Notes b/ext/pcre/pcrelib/HACKING
index c75b3e8a5d..49bba8a702 100644
--- a/ext/pcre/pcrelib/doc/Tech.Notes
+++ b/ext/pcre/pcrelib/HACKING
@@ -129,13 +129,18 @@ These items are all just one byte long
OP_ANYBYTE match any single byte, even in UTF-8 mode
OP_SOD match start of data: \A
OP_SOM, start of match (subject + offset): \G
+ OP_SET_SOM, set start of match (\K)
OP_CIRC ^ (start of data, or after \n in multiline)
OP_NOT_WORD_BOUNDARY \W
OP_WORD_BOUNDARY \w
OP_NOT_DIGIT \D
OP_DIGIT \d
+ OP_NOT_HSPACE \H
+ OP_HSPACE \h
OP_NOT_WHITESPACE \S
OP_WHITESPACE \s
+ OP_NOT_VSPACE \V
+ OP_VSPACE \v
OP_NOT_WORDCHAR \W
OP_WORDCHAR \w
OP_EODN match end of data or \n at end: \Z
@@ -399,4 +404,4 @@ at compile time, and so does not cause anything to be put into the compiled
data.
Philip Hazel
-November 2006
+June 2007
diff --git a/ext/pcre/pcrelib/LICENCE b/ext/pcre/pcrelib/LICENCE
index 58241b2bda..4baa7d83a1 100644
--- a/ext/pcre/pcrelib/LICENCE
+++ b/ext/pcre/pcrelib/LICENCE
@@ -20,9 +20,9 @@ Email local part: ph10
Email domain: cam.ac.uk
University of Cambridge Computing Service,
-Cambridge, England. Phone: +44 1223 334714.
+Cambridge, England.
-Copyright (c) 1997-2006 University of Cambridge
+Copyright (c) 1997-2007 University of Cambridge
All rights reserved.
@@ -31,7 +31,7 @@ THE C++ WRAPPER FUNCTIONS
Contributed by: Google Inc.
-Copyright (c) 2006, Google Inc.
+Copyright (c) 2007, Google Inc.
All rights reserved.
diff --git a/ext/pcre/pcrelib/NEWS b/ext/pcre/pcrelib/NEWS
index 92768eaa8c..26d0999d91 100644
--- a/ext/pcre/pcrelib/NEWS
+++ b/ext/pcre/pcrelib/NEWS
@@ -1,7 +1,68 @@
News about PCRE releases
------------------------
-Release 7.0 23-Nov-06
+
+Release 7.2 13-Jun-07
+---------------------
+
+WARNING: saved patterns that were compiled by earlier versions of PCRE must be
+recompiled for use with 7.2 (necessitated by the addition of \K, \h, \H, \v,
+and \V).
+
+Correction to the notes for 7.1: the note about shared libraries for Windows is
+wrong. Previously, three libraries were built, but each could function
+independently. For example, the pcreposix library also included all the
+functions from the basic pcre library. The change is that the three libraries
+are no longer independent. They are like the Unix libraries. To use the
+pcreposix functions, for example, you need to link with both the pcreposix and
+the basic pcre library.
+
+Some more features from Perl 5.10 have been added:
+
+ (?-n) and (?+n) relative references for recursion and subroutines.
+
+ (?(-n) and (?(+n) relative references as conditions.
+
+ \k{name} and \g{name} are synonyms for \k<name>.
+
+ \K to reset the start of the matched string; for example, (foo)\Kbar
+ matches bar preceded by foo, but only sets bar as the matched string.
+
+ (?| introduces a group where the capturing parentheses in each alternative
+ start from the same number; for example, (?|(abc)|(xyz)) sets capturing
+ parentheses number 1 in both cases.
+
+ \h, \H, \v, \V match horizontal and vertical whitespace, respectively.
+
+
+Release 7.1 24-Apr-07
+---------------------
+
+There is only one new feature in this release: a linebreak setting of
+PCRE_NEWLINE_ANYCRLF. It is a cut-down version of PCRE_NEWLINE_ANY, which
+recognizes only CRLF, CR, and LF as linebreaks.
+
+A few bugs are fixed (see ChangeLog for details), but the major change is a
+complete re-implementation of the build system. This now has full Autotools
+support and so is now "standard" in some sense. It should help with compiling
+PCRE in a wide variety of environments.
+
+NOTE: when building shared libraries for Windows, three dlls are now built,
+called libpcre, libpcreposix, and libpcrecpp. Previously, everything was
+included in a single dll.
+
+Another important change is that the dftables auxiliary program is no longer
+compiled and run at "make" time by default. Instead, a default set of character
+tables (assuming ASCII coding) is used. If you want to use dftables to generate
+the character tables as previously, add --enable-rebuild-chartables to the
+"configure" command. You must do this if you are compiling PCRE to run on a
+system that uses EBCDIC code.
+
+There is a discussion about character tables in the README file. The default is
+not to use dftables so that that there is no problem when cross-compiling.
+
+
+Release 7.0 19-Dec-06
---------------------
This release has a new major number because there have been some internal
diff --git a/ext/pcre/pcrelib/NON-UNIX-USE b/ext/pcre/pcrelib/NON-UNIX-USE
index bcc0dc9af2..a10c7041aa 100644
--- a/ext/pcre/pcrelib/NON-UNIX-USE
+++ b/ext/pcre/pcrelib/NON-UNIX-USE
@@ -1,128 +1,121 @@
Compiling PCRE on non-Unix systems
----------------------------------
-See below for comments on Cygwin or MinGW and OpenVMS usage. I (Philip Hazel)
-have no knowledge of Windows or VMS sytems and how their libraries work. The
-items in the PCRE Makefile that relate to anything other than Unix-like systems
-have been contributed by PCRE users. There are some other comments and files in
-the Contrib directory on the ftp site that you may find useful. See
+This document contains the following sections:
+
+ General
+ Generic instructions for the PCRE C library
+ The C++ wrapper functions
+ Building for virtual Pascal
+ Comments about Win32 builds
+ Building under Windows with BCC5.5
+ Building PCRE on OpenVMS
+
+
+GENERAL
+
+I (Philip Hazel) have no knowledge of Windows or VMS sytems and how their
+libraries work. The items in the PCRE distribution and Makefile that relate to
+anything other than Unix-like systems are untested by me.
+
+There are some other comments and files in the Contrib directory on the ftp
+site that you may find useful. See
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib
-If you want to compile PCRE for a non-Unix system (or perhaps, more strictly,
-for a system that does not support "configure" and "make" files), note that
-the basic PCRE library consists entirely of code written in Standard C, and so
-should compile successfully on any system that has a Standard C compiler and
-library. The C++ wrapper functions are a separate issue (see below).
-
-
-GENERIC INSTRUCTIONS FOR THE C LIBRARY
-
-The following are generic comments about building PCRE. The interspersed
-indented commands are suggestions from Mark Tetrode as to which commands you
-might use on a Windows system to build a static library.
-
-(1) Copy or rename the file config.h.in as config.h, and change the macros that
-define HAVE_STRERROR and HAVE_MEMMOVE to define them as 1 rather than 0.
-Unfortunately, because of the way Unix autoconf works, the default setting has
-to be 0. You may also want to make changes to other macros in config.h. In
-particular, if you want to force a specific value for newline, you can define
-the NEWLINE macro. The default is to use '\n', thereby using whatever value
-your compiler gives to '\n'.
-
- rem Mark Tetrode's commands
- copy config.h.in config.h
- rem Use write, because notepad cannot handle UNIX files. Change values.
- write config.h
-
-(2) Compile dftables.c as a stand-alone program, and then run it with
-the single argument "pcre_chartables.c". This generates a set of standard
-character tables and writes them to that file.
-
- rem Mark Tetrode's commands
- rem Compile & run
- cl -DSUPPORT_UTF8 -DSUPPORT_UCP dftables.c
- dftables.exe pcre_chartables.c
-
-(3) Compile the following source files:
-
- pcre_chartables.c
- pcre_compile.c
- pcre_config.c
- pcre_dfa_exec.c
- pcre_exec.c
- pcre_fullinfo.c
- pcre_get.c
- pcre_globals.c
- pcre_info.c
- pcre_maketables.c
- pcre_newline.c
- pcre_ord2utf8.c
- pcre_refcount.c
- pcre_study.c
- pcre_tables.c
- pcre_try_flipped.c
- pcre_ucp_searchfuncs.c
- pcre_valid_utf8.c
- pcre_version.c
- pcre_xclass.c
-
-and link them all together into an object library in whichever form your system
-keeps such libraries. This is the pcre C library. If your system has static and
-shared libraries, you may have to do this once for each type.
-
- rem These comments are out-of-date, referring to a previous release which
- rem had fewer source files. Replace with the file names from above.
- rem Mark Tetrode's commands, for a static library
- rem Compile & lib
- cl -DSUPPORT_UTF8 -DSUPPORT_UCP -DPOSIX_MALLOC_THRESHOLD=10 /c maketables.c get.c study.c pcre.c
- lib /OUT:pcre.lib maketables.obj get.obj study.obj pcre.obj
-
-(4) Similarly, compile pcreposix.c and link it (on its own) as the pcreposix
-library.
-
- rem Mark Tetrode's commands, for a static library
- rem Compile & lib
- cl -DSUPPORT_UTF8 -DSUPPORT_UCP -DPOSIX_MALLOC_THRESHOLD=10 /c pcreposix.c
- lib /OUT:pcreposix.lib pcreposix.obj
-
-(5) Compile the test program pcretest.c. This needs the functions in the
-pcre and pcreposix libraries when linking.
-
- rem Mark Tetrode's commands
- rem compile & link
- cl /F0x400000 pcretest.c pcre.lib pcreposix.lib
-
-(6) Run pcretest on the testinput files in the testdata directory, and check
-that the output matches the corresponding testoutput files. Note that the
-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 different
-convention.
-
- rem Mark Tetrode's commands
- pcretest testdata\testinput1 testdata\myoutput1
- windiff testdata\testoutput1 testdata\myoutput1
- pcretest -i testdata\testinput2 testdata\myoutput2
- windiff testdata\testoutput2 testdata\myoutput2
- pcretest testdata\testinput3 testdata\myoutput3
- windiff testdata\testoutput3 testdata\myoutput3
- pcretest testdata\testinput4 testdata\myoutput4
- windiff testdata\testoutput4 testdata\myoutput4
- pcretest testdata\testinput5 testdata\myoutput5
- windiff testdata\testoutput5 testdata\myoutput5
- pcretest testdata\testinput6 testdata\myoutput6
- windiff testdata\testoutput6 testdata\myoutput6
-
-Note that there are now three more tests (7, 8, 9) that did not exist when Mark
-wrote those comments. The test the new pcre_dfa_exec() function.
-
-(7) If you want to use the pcregrep command, compile and link pcregrep.c; it
-uses only the basic PCRE library.
+If you want to compile PCRE for a non-Unix system (especially for a system that
+does not support "configure" and "make" files), note that the basic PCRE
+library consists entirely of code written in Standard C, and so should compile
+successfully on any system that has a Standard C compiler and library. The C++
+wrapper functions are a separate issue (see below).
+
+The PCRE distribution contains some experimental support for "cmake", but this
+is incomplete and not documented. However if you are a "cmake" user you might
+like to try building with "cmake".
+
+
+GENERIC INSTRUCTIONS FOR THE PCRE C LIBRARY
+
+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
+ 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
+ define the NEWLINE macro.
+
+ 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.
+
+ NOTE: There have been occasions when the way in which certain parameters 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
+ are strongly advised to review config.h.generic before re-using what you
+ had previously.
+
+(2) Copy or rename the file pcre.h.generic as pcre.h.
+
+(3) EITHER:
+ Copy or rename file pcre_chartables.c.dist as pcre_chartables.c.
+
+ OR:
+ Compile dftables.c as a stand-alone program, and then run it with the
+ single argument "pcre_chartables.c". This generates a set of standard
+ character tables and writes them to that file. The tables are generated
+ using the default C locale for your system. If you want to use a locale
+ that is specified by LC_xxx environment variables, add the -L option to
+ the dftables 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
+ specify alternative tables at run time.
+
+(4) Compile the following source files:
+
+ pcre_chartables.c
+ pcre_compile.c
+ pcre_config.c
+ pcre_dfa_exec.c
+ pcre_exec.c
+ pcre_fullinfo.c
+ pcre_get.c
+ pcre_globals.c
+ pcre_info.c
+ pcre_maketables.c
+ pcre_newline.c
+ pcre_ord2utf8.c
+ pcre_refcount.c
+ pcre_study.c
+ pcre_tables.c
+ pcre_try_flipped.c
+ pcre_ucp_searchfuncs.c
+ pcre_valid_utf8.c
+ pcre_version.c
+ pcre_xclass.c
+
+ Now link them all together into an object library in whichever form 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.
+
+(5) Similarly, compile pcreposix.c and link it (on its own) as the pcreposix
+ library.
+
+(6) Compile the test program pcretest.c. This needs the functions in the
+ pcre and pcreposix libraries when linking.
+
+(7) Run pcretest on the testinput files in the testdata directory, and check
+ that the output matches the corresponding testoutput files. Note that the
+ 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
+ different convention.
+
+(8) 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).
THE C++ WRAPPER FUNCTIONS
-The PCRE distribution now contains some C++ wrapper functions and tests,
+The PCRE distribution also contains some C++ wrapper functions and tests,
contributed by Google Inc. On a system that can use "configure" and "make",
the functions are automatically built into a library called pcrecpp. It should
be straightforward to compile the .cc files manually on other systems. The
@@ -130,88 +123,101 @@ files called xxx_unittest.cc are test programs for each of the corresponding
xxx.cc files.
-FURTHER REMARKS
+BUILDING FOR VIRTUAL PASCAL
-If you have a system without "configure" but where you can use a Makefile, edit
-Makefile.in to create Makefile, substituting suitable values for the variables
-at the head of the file.
+A script for building PCRE using Borland's C++ compiler for use with VPASCAL
+was contributed by Alexander Tokarev. Stefan Weber updated the script and added
+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.
-Michael Roy sent these comments about building PCRE under Windows with BCC5.5:
- Some of the core BCC libraries have a version of PCRE from 1998 built in,
- which can lead to pcre_exec() giving an erroneous PCRE_ERROR_NULL from a
- version mismatch. I'm including an easy workaround below, if you'd like to
- include it in the non-unix instructions:
+COMMENTS ABOUT WIN32 BUILDS
- When linking a project with BCC5.5, pcre.lib must be included before any of
- the libraries cw32.lib, cw32i.lib, cw32mt.lib, and cw32mti.lib on the command
- line.
+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
+the same thing; they are completely different from each other. There is also
+some experimental, undocumented support for building using "cmake", which you
+might like to try if you are familiar with "cmake". However, at the present
+time, the "cmake" process builds only a static library (not a dll), and the
+tests are not automatically run.
-Some help in building a Win32 DLL of PCRE in GnuWin32 environments was
-contributed by Paul Sokolovsky. These environments are Mingw32
-(http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and CygWin
-(http://sourceware.cygnus.com/cygwin/). Paul comments:
+The MinGW home page (http://www.mingw.org/) says this:
- For CygWin, set CFLAGS=-mno-cygwin, and do 'make dll'. You'll get
- pcre.dll (containing pcreposix also), libpcre.dll.a, and dynamically
- linked pgrep and pcretest. If you have /bin/sh, run RunTest (three
- main test go ok, locale not supported).
+ MinGW: A collection of freely available and freely distributable Windows
+ specific header files and import libraries combined with GNU toolsets that
+ allow one to produce native Windows programs that do not rely on any
+ 3rd-party C runtime DLLs.
-Changes to do MinGW with autoconf 2.50 were supplied by Fred Cox
-<sailorFred@yahoo.com>, who comments as follows:
+The Cygwin home page (http://www.cygwin.com/) says this:
- If you are using the PCRE DLL, the normal Unix style configure && make &&
- make check && make install should just work[*]. If you want to statically
- link against the .a file, you must define PCRE_STATIC before including
- pcre.h, otherwise the pcre_malloc and pcre_free exported functions will be
- declared __declspec(dllimport), with hilarious results. See the configure.in
- and pcretest.c for how it is done for the static test.
+ Cygwin is a Linux-like environment for Windows. It consists of two parts:
- Also, there will only be a libpcre.la, not a libpcreposix.la, as you
- would expect from the Unix version. The single DLL includes the pcreposix
- interface.
+ . A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing
+ substantial Linux API functionality
-[*] But note that the supplied test files are in Unix format, with just LF
-characters as line terminators. You will have to edit them to change to CR LF
-terminators.
+ . A collection of tools which provide Linux look and feel.
-A script for building PCRE using Borland's C++ compiler for use with VPASCAL
-was contributed by Alexander Tokarev. It is called makevp.bat.
+ The Cygwin DLL currently works with all recent, commercially released x86 32
+ bit and 64 bit versions of Windows, with the exception of Windows CE.
-These are some further comments about Win32 builds from Mark Evans. They
-were contributed before Fred Cox's changes were made, so it is possible that
-they may no longer be relevant.
+On both MinGW and Cygwin, PCRE should build correctly using:
-"The documentation for Win32 builds is a bit shy. Under MSVC6 I
-followed their instructions to the letter, but there were still
-some things missing.
+ ./configure && make && make install
-(1) Must #define STATIC for entire project if linking statically.
- (I see no reason to use DLLs for code this compact.) This of
- course is a project setting in MSVC under Preprocessor.
+This should create two libraries called libpcre and libpcreposix, and, if you
+have enabled building the C++ wrapper, a third one called libpcrecpp. These are
+independent libraries: when you like with libpcreposix or libpcrecpp you must
+also link with libpcre, which contains the basic functions. (Some earlier
+releases of PCRE included the basic libpcre functions in libpcreposix. This no
+longer happens.)
-(2) Missing some #ifdefs relating to the function pointers
- pcre_malloc and pcre_free. See my solution below. (The stubs
- may not be mandatory but they made me feel better.)"
+If you want to statically link your program against a non-dll .a file, you must
+define PCRE_STATIC before including pcre.h, otherwise the pcre_malloc() and
+pcre_free() exported functions will be declared __declspec(dllimport), with
+unwanted results.
-=========================
-#ifdef _WIN32
-#include <malloc.h>
+Using Cygwin's compiler generates libraries and executables that depend on
+cygwin1.dll. If a library that is generated this way is distributed,
+cygwin1.dll has to be distributed as well. Since cygwin1.dll is under the GPL
+licence, this forces not only PCRE to be under the GPL, but also the entire
+application. A distributor who wants to keep their own code proprietary must
+purchase an appropriate Cygwin licence.
-void* malloc_stub(size_t N)
-{ return malloc(N); }
-void free_stub(void* p)
-{ free(p); }
-void *(*pcre_malloc)(size_t) = &malloc_stub;
-void (*pcre_free)(void *) = &free_stub;
+MinGW has no such restrictions. The MinGW compiler generates a library or
+executable that can run standalone on Windows without any third party dll or
+licensing issues.
-#else
+But there is more complication:
-void *(*pcre_malloc)(size_t) = malloc;
-void (*pcre_free)(void *) = free;
+If a Cygwin user uses the -mno-cygwin Cygwin gcc flag, what that really does is
+to tell Cygwin's gcc to use the MinGW gcc. Cygwin's gcc is only acting as a
+front end to MinGW's gcc (if you install Cygwin's gcc, you get both Cygwin's
+gcc and MinGW's gcc). So, a user can:
-#endif
-=========================
+. Build native binaries by using MinGW or by getting Cygwin and using
+ -mno-cygwin.
+
+. Build binaries that depend on cygwin1.dll by using Cygwin with the normal
+ compiler flags.
+
+The test files that are supplied with PCRE are in Unix format, with LF
+characters as line terminators. It may be necessary to change the line
+terminators in order to get some of the tests to work. We hope to improve
+things in this area in future.
+
+
+BUILDING UNDER WINDOWS WITH BCC5.5
+
+Michael Roy sent these comments about building PCRE under Windows with BCC5.5:
+
+ Some of the core BCC libraries have a version of PCRE from 1998 built in,
+ which can lead to pcre_exec() giving an erroneous PCRE_ERROR_NULL from a
+ version mismatch. I'm including an easy workaround below, if you'd like to
+ include it in the non-unix instructions:
+
+ When linking a project with BCC5.5, pcre.lib must be included before any of
+ the libraries cw32.lib, cw32i.lib, cw32mt.lib, and cw32mti.lib on the command
+ line.
BUILDING PCRE ON OPENVMS
@@ -278,4 +284,5 @@ $! Locale could not be set to fr
$!
=========================
+Last Updated: 13 June 2007
****
diff --git a/ext/pcre/pcrelib/README b/ext/pcre/pcrelib/README
index 55e8fd0940..2f4d3c5771 100644
--- a/ext/pcre/pcrelib/README
+++ b/ext/pcre/pcrelib/README
@@ -5,51 +5,82 @@ The latest release of PCRE is always available from
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-xxx.tar.gz
+There is a mailing list for discussion about the development of PCRE at
+
+ pcre-dev@exim.org
+
Please read the NEWS file if you are upgrading from a previous release.
+The contents of this README file are:
+
+ The PCRE APIs
+ Documentation for PCRE
+ Contributions by users of PCRE
+ Building PCRE on non-Unix systems
+ Building PCRE on Unix-like systems
+ Retrieving configuration information on Unix-like systems
+ Shared libraries on Unix-like systems
+ Cross-compiling on Unix-like systems
+ Using HP's ANSI C++ compiler (aCC)
+ Making new tarballs
+ Testing PCRE
+ Character tables
+ File manifest
The PCRE APIs
-------------
-PCRE is written in C, and it has its own API. The distribution now includes a
-set of C++ wrapper functions, courtesy of Google Inc. (see the pcrecpp man page
-for details).
+PCRE is written in C, and it has its own API. The distribution also includes a
+set of C++ wrapper functions (see the pcrecpp man page for details), courtesy
+of Google Inc.
-Also included are a set of C wrapper functions that are based on the POSIX
-API. These end up in the library called libpcreposix. Note that this just
-provides a POSIX calling interface to PCRE: the regular expressions themselves
-still follow Perl syntax and semantics. The header file for the POSIX-style
-functions is called pcreposix.h. The official POSIX name is regex.h, but I
-didn't want to risk possible problems with existing files of that name by
-distributing it that way. To use it with an existing program that uses the
-POSIX API, it will have to be renamed or pointed at by a link.
+In addition, there is a set of C wrapper functions that are based on the POSIX
+regular expression API (see the pcreposix man page). These end up in the
+library called libpcreposix. Note that this just provides a POSIX calling
+interface to PCRE; the regular expressions themselves still follow Perl syntax
+and semantics. The POSIX API is restricted, and does not give full access to
+all of PCRE's facilities.
+
+The header file for the POSIX-style functions is called pcreposix.h. The
+official POSIX name is regex.h, but I did not want to risk possible problems
+with existing files of that name by distributing it that way. To use PCRE with
+an existing program that uses the POSIX API, pcreposix.h will have to be
+renamed or pointed at by a link.
If you are using the POSIX interface to PCRE and there is already a POSIX regex
-library installed on your system, you must take care when linking programs to
+library installed on your system, as well as worrying about the regex.h header
+file (as mentioned above), you must also take care when linking programs to
ensure that they link with PCRE's libpcreposix library. Otherwise they may pick
-up the "real" POSIX functions of the same name.
+up the POSIX functions of the same name from the other library.
+
+One way of avoiding this confusion is to compile PCRE with the addition of
+-Dregcomp=PCREregcomp (and similarly for the other POSIX functions) to the
+compiler flags (CFLAGS if you are using "configure" -- see below). This has the
+effect of renaming the functions so that the names no longer clash. Of course,
+you have to do the same thing for your applications, or write them using the
+new names.
Documentation for PCRE
----------------------
-If you install PCRE in the normal way, you will end up with an installed set of
-man pages whose names all start with "pcre". The one that is just called "pcre"
-lists all the others. In addition to these man pages, the PCRE documentation is
-supplied in two other forms; however, as there is no standard place to install
-them, they are left in the doc directory of the unpacked source distribution.
-These forms are:
+If you install PCRE in the normal way on a Unix-like system, you will end up
+with a set of man pages whose names all start with "pcre". The one that is just
+called "pcre" lists all the others. In addition to these man pages, the PCRE
+documentation is supplied in two other forms:
- 1. Files called doc/pcre.txt, doc/pcregrep.txt, and doc/pcretest.txt. The
- first of these is a concatenation of the text forms of all the section 3
- man pages except those that summarize individual functions. The other two
- are the text forms of the section 1 man pages for the pcregrep and
- pcretest commands. Text forms are provided for ease of scanning with text
- editors or similar tools.
+ 1. There are files called doc/pcre.txt, doc/pcregrep.txt, and
+ doc/pcretest.txt in the source distribution. The first of these is a
+ concatenation of the text forms of all the section 3 man pages except
+ those that summarize individual functions. The other two are the text
+ forms of the section 1 man pages for the pcregrep and pcretest commands.
+ These text forms are provided for ease of scanning with text editors or
+ similar tools. They are installed in <prefix>/share/doc/pcre, where
+ <prefix> is the installation prefix (defaulting to /usr/local).
- 2. A subdirectory called doc/html contains all the documentation in HTML
- form, hyperlinked in various ways, and rooted in a file called
- doc/index.html.
+ 2. A set of files containing all the documentation in HTML form, hyperlinked
+ in various ways, and rooted in a file called index.html, is distributed in
+ doc/html and installed in <prefix>/share/doc/pcre/html.
Contributions by users of PCRE
@@ -59,27 +90,46 @@ You can find contributions from PCRE users in the directory
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib
-where there is also a README file giving brief descriptions of what they are.
-Several of them provide support for compiling PCRE on various flavours of
-Windows systems (I myself do not use Windows). Some are complete in themselves;
-others are pointers to URLs containing relevant files.
+There is a README file giving brief descriptions of what they are. Some are
+complete in themselves; others are pointers to URLs containing relevant files.
+Some of this material is likely to be well out-of-date. Several of the earlier
+contributions provided support for compiling PCRE on various flavours of
+Windows (I myself do not use Windows). Nowadays there is more Windows support
+in the standard distribution, so these contibutions have been archived.
+
+
+Building PCRE on non-Unix systems
+---------------------------------
+
+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
+able to build PCRE in the same way as for Unix-like systems.
+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
+library, because it uses only Standard C functions.
-Building PCRE on a Unix-like system
------------------------------------
+
+Building PCRE on Unix-like systems
+----------------------------------
If you are using HP's ANSI C++ compiler (aCC), please see the special note
in the section entitled "Using HP's ANSI C++ compiler (aCC)" below.
+The following instructions assume the use of the widely used "configure, make,
+make install" process. There is also some experimental support for "cmake" in
+the PCRE distribution, but it is incomplete and not documented. However, if you
+are a "cmake" user, you might want to try it.
+
To build PCRE on a Unix-like system, first run the "configure" command from the
PCRE distribution directory, with your current directory set to the directory
where you want the files to be created. This command is a standard GNU
"autoconf" configuration script, for which generic instructions are supplied in
-INSTALL.
+the file INSTALL.
Most commonly, people build PCRE within its own distribution directory, and in
-this case, on many systems, just running "./configure" is sufficient, but the
-usual methods of changing standard defaults are available. For example:
+this case, on many systems, just running "./configure" is sufficient. However,
+the usual methods of changing standard defaults are available. For example:
CFLAGS='-O2 -Wall' ./configure --prefix=/opt/local
@@ -103,8 +153,8 @@ library. You can read more about them in the pcrebuild man page.
. If you want to suppress the building of the C++ wrapper library, you can add
--disable-cpp to the "configure" command. Otherwise, when "configure" is run,
- will try to find a C++ compiler and C++ header files, and if it succeeds, it
- will try to build the C++ wrapper.
+ it will try to find a C++ compiler and C++ header files, and if it succeeds,
+ it will try to build the C++ wrapper.
. If you want to make use of the support for UTF-8 character strings in PCRE,
you must add --enable-utf8 to the "configure" command. Without it, the code
@@ -119,16 +169,24 @@ library. You can read more about them in the pcrebuild man page.
supported.
. You can build PCRE to recognize either CR or LF or the sequence CRLF or any
- of the Unicode newline sequences as indicating the end of a line. Whatever
- you specify at build time is the default; the caller of PCRE can change the
- selection at run time. The default newline indicator is a single LF character
- (the Unix standard). You can specify the default newline indicator by adding
- --newline-is-cr or --newline-is-lf or --newline-is-crlf or --newline-is-any
- to the "configure" command, respectively.
+ of the preceding, or any of the Unicode newline sequences as indicating the
+ end of a line. Whatever you specify at build time is the default; the caller
+ of PCRE can change the selection at run time. The default newline indicator
+ is a single LF character (the Unix standard). You can specify the default
+ newline indicator by adding --enable-newline-is-cr or --enable-newline-is-lf
+ or --enable-newline-is-crlf or --enable-newline-is-anycrlf or
+ --enable-newline-is-any to the "configure" command, respectively.
+
+ If you specify --enable-newline-is-cr or --enable-newline-is-crlf, some of
+ the standard tests will fail, because the lines in the test files end with
+ LF. Even if the files are edited to change the line endings, there are likely
+ to be some failures. With --enable-newline-is-anycrlf or
+ --enable-newline-is-any, many tests should succeed, but there may be some
+ failures.
. When called via the POSIX interface, PCRE uses malloc() to get additional
storage for processing capturing parentheses if there are more than 10 of
- them. You can increase this threshold by setting, for example,
+ them in a pattern. You can increase this threshold by setting, for example,
--with-posix-malloc-threshold=20
@@ -141,8 +199,8 @@ library. You can read more about them in the pcrebuild man page.
--with-match-limit=500000
on the "configure" command. This is just the default; individual calls to
- pcre_exec() can supply their own value. There is discussion on the pcreapi
- man page.
+ pcre_exec() can supply their own value. There is more discussion on the
+ pcreapi man page.
. There is a separate counter that limits the depth of recursive function calls
during a matching process. This also has a default of ten million, which is
@@ -157,37 +215,61 @@ library. You can read more about them in the pcrebuild man page.
. The default maximum compiled pattern size is around 64K. You can increase
this by adding --with-link-size=3 to the "configure" command. You can
increase it even more by setting --with-link-size=4, but this is unlikely
- ever to be necessary. If you build PCRE with an increased link size, test 2
- (and 5 if you are using UTF-8) will fail. Part of the output of these tests
- is a representation of the compiled pattern, and this changes with the link
- size.
+ ever to be necessary. Increasing the internal link size will reduce
+ performance.
. You can build PCRE so that its internal match() function that is called from
- pcre_exec() does not call itself recursively. Instead, it uses blocks of data
- from the heap via special functions pcre_stack_malloc() and pcre_stack_free()
- to save data that would otherwise be saved on the stack. To build PCRE like
- this, use
+ pcre_exec() does not call itself recursively. Instead, it uses memory blocks
+ obtained from the heap via the special functions pcre_stack_malloc() and
+ pcre_stack_free() to save data that would otherwise be saved on the stack. To
+ build PCRE like this, use
--disable-stack-for-recursion
on the "configure" command. PCRE runs more slowly in this mode, but it may be
necessary in environments with limited stack sizes. This applies only to the
pcre_exec() function; it does not apply to pcre_dfa_exec(), which does not
- use deeply nested recursion.
+ use deeply nested recursion. There is a discussion about stack sizes in the
+ pcrestack man page.
+
+. For speed, PCRE uses four tables for manipulating and identifying characters
+ whose code point values are less than 256. By default, it uses a set of
+ tables for ASCII encoding that is part of the distribution. If you specify
+
+ --enable-rebuild-chartables
+
+ a program called dftables is compiled and run in the default C locale when
+ you obey "make". It builds a source file called pcre_chartables.c. If you do
+ not specify this option, pcre_chartables.c is created as a copy of
+ pcre_chartables.c.dist. See "Character tables" below for further information.
+
+. It is possible to compile PCRE for use on systems that use EBCDIC as their
+ default character code (as opposed to ASCII) by specifying
-The "configure" script builds eight files for the basic C library:
+ --enable-ebcdic
+
+ This automatically implies --enable-rebuild-chartables (see above).
+
+The "configure" script builds the following files for the basic C library:
. Makefile is the makefile that builds the library
. config.h contains build-time configuration options for the library
+. pcre.h is the public PCRE header file
. pcre-config is a script that shows the settings of "configure" options
. libpcre.pc is data for the pkg-config command
. libtool is a script that builds shared and/or static libraries
-. RunTest is a script for running tests on the library
+. RunTest is a script for running tests on the basic C library
. RunGrepTest is a script for running tests on the pcregrep command
-In addition, if a C++ compiler is found, the following are also built:
+Versions of config.h and pcre.h are distributed in the PCRE tarballs under
+the names config.h.generic and pcre.h.generic. These are provided for the
+benefit of those who have to built PCRE without the benefit of "configure". If
+you use "configure", the .generic versions are not used.
-. pcrecpp.h is the header file for programs that call PCRE via the C++ wrapper
+If a C++ compiler is found, the following files are also built:
+
+. libpcrecpp.pc is data for the pkg-config command
+. pcrecpparg.h is a header file for programs that call PCRE via the C++ wrapper
. pcre_stringpiece.h is the header for the C++ "stringpiece" functions
The "configure" script also creates config.status, which is an executable
@@ -195,18 +277,65 @@ script that can be run to recreate the configuration, and config.log, which
contains compiler output from tests that "configure" runs.
Once "configure" has run, you can run "make". It builds two libraries, called
-libpcre and libpcreposix, a test program called pcretest, and the pcregrep
-command. If a C++ compiler was found on your system, it also builds the C++
-wrapper library, which is called libpcrecpp, and some test programs called
-pcrecpp_unittest, pcre_scanner_unittest, and pcre_stringpiece_unittest.
-
-The command "make test" runs all the appropriate tests. Details of the PCRE
-tests are given in a separate section of this document, below.
-
-You can use "make install" to copy the libraries, the public header files
-pcre.h, pcreposix.h, pcrecpp.h, and pcre_stringpiece.h (the last two only if
-the C++ wrapper was built), and the man pages to appropriate live directories
-on your system, in the normal way.
+libpcre and libpcreposix, a test program called pcretest, a demonstration
+program called pcredemo, and the pcregrep command. If a C++ compiler was found
+on your system, "make" also builds the C++ wrapper library, which is called
+libpcrecpp, and some test programs called pcrecpp_unittest,
+pcre_scanner_unittest, and pcre_stringpiece_unittest. Building the C++ wrapper
+can be disabled by adding --disable-cpp to the "configure" command.
+
+The command "make check" runs all the appropriate tests. Details of the PCRE
+tests are given below in a separate section of this document.
+
+You can use "make install" to install PCRE into live directories on your
+system. The following are installed (file names are all relative to the
+<prefix> that is set when "configure" is run):
+
+ Commands (bin):
+ pcretest
+ pcregrep
+ pcre-config
+
+ Libraries (lib):
+ libpcre
+ libpcreposix
+ libpcrecpp (if C++ support is enabled)
+
+ Configuration information (lib/pkgconfig):
+ libpcre.pc
+ libpcrecpp.pc (if C++ support is enabled)
+
+ Header files (include):
+ pcre.h
+ pcreposix.h
+ pcre_scanner.h )
+ pcre_stringpiece.h ) if C++ support is enabled
+ pcrecpp.h )
+ pcrecpparg.h )
+
+ Man pages (share/man/man{1,3}):
+ pcregrep.1
+ pcretest.1
+ pcre.3
+ pcre*.3 (lots more pages, all starting "pcre")
+
+ HTML documentation (share/doc/pcre/html):
+ index.html
+ *.html (lots more pages, hyperlinked from index.html)
+
+ Text file documentation (share/doc/pcre):
+ AUTHORS
+ COPYING
+ ChangeLog
+ LICENCE
+ NEWS
+ README
+ pcre.txt (a concatenation of the man(3) pages)
+ pcretest.txt the pcretest man page
+ pcregrep.txt the pcregrep man page
+
+Note that the pcredemo program that is built by "configure" is *not* installed
+anywhere. It is a demonstration for programmers wanting to use PCRE.
If you want to remove PCRE from your system, you can run "make uninstall".
This removes all the files that "make install" installed. However, it does not
@@ -216,9 +345,8 @@ remove any directories, because these are often shared with other programs.
Retrieving configuration information on Unix-like systems
---------------------------------------------------------
-Running "make install" also installs the command pcre-config, which can be used
-to recall information about the PCRE configuration and installation. For
-example:
+Running "make install" installs the command pcre-config, which can be used to
+recall information about the PCRE configuration and installation. For example:
pcre-config --version
@@ -237,7 +365,7 @@ single command is used. For example:
pkg-config --cflags pcre
The data is held in *.pc files that are installed in a directory called
-pkgconfig.
+<prefix>/lib/pkgconfig.
Shared libraries on Unix-like systems
@@ -254,7 +382,7 @@ built. The programs pcretest and pcregrep are built to use these uninstalled
libraries (by means of wrapper scripts in the case of shared libraries). When
you use "make install" to install shared libraries, pcregrep and pcretest are
automatically re-built to use the newly installed shared libraries before being
-installed themselves. However, the versions left in the source directory still
+installed themselves. However, the versions left in the build directory still
use the uninstalled libraries.
To build PCRE using static libraries only you must use --disable-shared when
@@ -266,25 +394,33 @@ Then run "make" in the usual way. Similarly, you can use --disable-static to
build only shared libraries.
-Cross-compiling on a Unix-like system
--------------------------------------
+Cross-compiling on Unix-like systems
+------------------------------------
You can specify CC and CFLAGS in the normal way to the "configure" command, in
-order to cross-compile PCRE for some other host. However, during the building
-process, the dftables.c source file is compiled *and run* on the local host, in
-order to generate the default character tables (the chartables.c file). It
-therefore needs to be compiled with the local compiler, not the cross compiler.
-You can do this by specifying CC_FOR_BUILD (and if necessary CFLAGS_FOR_BUILD;
-there are also CXX_FOR_BUILD and CXXFLAGS_FOR_BUILD for the C++ wrapper)
-when calling the "configure" command. If they are not specified, they default
-to the values of CC and CFLAGS.
+order to cross-compile PCRE for some other host. However, you should NOT
+specify --enable-rebuild-chartables, because if you do, the dftables.c source
+file is compiled and run on the local host, in order to generate the inbuilt
+character tables (the pcre_chartables.c file). This will probably not work,
+because dftables.c needs to be compiled with the local compiler, not the cross
+compiler.
+
+When --enable-rebuild-chartables is not specified, pcre_chartables.c is created
+by making a copy of pcre_chartables.c.dist, which is a default set of tables
+that assumes ASCII code. Cross-compiling with the default tables should not be
+a problem.
+
+If you need to modify the character tables when cross-compiling, you should
+move pcre_chartables.c.dist out of the way, then compile dftables.c by hand and
+run it on the local host to make a new version of pcre_chartables.c.dist.
+Then when you cross-compile PCRE this new version of the tables will be used.
Using HP's ANSI C++ compiler (aCC)
----------------------------------
Unless C++ support is disabled by specifying the "--disable-cpp" option of the
-"configure" script, you *must* include the "-AA" option in the CXXFLAGS
+"configure" script, you must include the "-AA" option in the CXXFLAGS
environment variable in order for the C++ components to compile correctly.
Also, note that the aCC compiler on PA-RISC platforms may have a defect whereby
@@ -296,34 +432,32 @@ running the "configure" script:
CXXLDFLAGS="-lstd_v2 -lCsup_v2"
-Building on non-Unix systems
-----------------------------
+Making new tarballs
+-------------------
-For a non-Unix system, read the comments in the file NON-UNIX-USE, though if
-the system supports the use of "configure" and "make" you may be able to build
-PCRE in the same way as for Unix systems.
+The command "make dist" creates three PCRE tarballs, in tar.gz, tar.bz2, and
+zip formats. The command "make distcheck" does the same, but then does a trial
+build of the new distribution to ensure that it works.
-PCRE has been compiled on Windows systems and on Macintoshes, but I don't know
-the details because I don't use those systems. It should be straightforward to
-build PCRE on any system that has a Standard C compiler and library, because it
-uses only Standard C functions.
+If you have modified any of the man page sources in the doc directory, you
+should first run the PrepareRelease script before making a distribution. This
+script creates the .txt and HTML forms of the documentation from the man pages.
Testing PCRE
------------
-To test PCRE on a Unix system, run the RunTest script that is created by the
-configuring process. There is also a script called RunGrepTest that tests the
-options of the pcregrep command. If the C++ wrapper library is build, three
-test programs called pcrecpp_unittest, pcre_scanner_unittest, and
-pcre_stringpiece_unittest are provided.
+To test the basic PCRE library on a Unix system, run the RunTest script that is
+created by the configuring process. There is also a script called RunGrepTest
+that tests the options of the pcregrep command. If the C++ wrapper library is
+built, three test programs called pcrecpp_unittest, pcre_scanner_unittest, and
+pcre_stringpiece_unittest are also built.
-Both the scripts and all the program tests are run if you obey "make runtest",
-"make check", or "make test". For other systems, see the instructions in
-NON-UNIX-USE.
+Both the scripts and all the program tests are run if you obey "make check" or
+"make test". For other systems, see the instructions in NON-UNIX-USE.
The RunTest script runs the pcretest test program (which is documented in its
-own man page) on each of the testinput files (in the testdata directory) in
+own man page) on each of the testinput files in the testdata directory in
turn, and compares the output with the contents of the corresponding testoutput
files. A file called testtry is used to hold the main output from pcretest
(testsavedregex is also used as a working file). To run pcretest on just one of
@@ -331,14 +465,15 @@ the test files, give its number as an argument to RunTest, for example:
RunTest 2
-The first test file can also be fed directly into the perltest script to check
-that Perl gives the same results. The only difference you should see is in the
-first few lines, where the Perl version is given instead of the PCRE version.
+The first test file can also be fed directly into the perltest.pl script to
+check that Perl gives the same results. The only difference you should see is
+in the first few lines, where the Perl version is given instead of the PCRE
+version.
The second set of tests check pcre_fullinfo(), pcre_info(), pcre_study(),
pcre_copy_substring(), pcre_get_substring(), pcre_get_substring_list(), error
detection, and run-time flags that are specific to PCRE, as well as the POSIX
-wrapper API. It also uses the debugging flag to check some of the internals of
+wrapper API. It also uses the debugging flags to check some of the internals of
pcre_compile().
If you build PCRE with a locale setting that is not the standard C locale, the
@@ -364,6 +499,9 @@ is output to say why. If running this test produces instances of the error
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.
+[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.]
+
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
running "configure". This file can be also fed directly to the perltest script,
@@ -373,8 +511,8 @@ commented in the script, can be be used.)
The fifth test checks error handling with UTF-8 encoding, and internal UTF-8
features of PCRE that are not relevant to Perl.
-The sixth and test checks the support for Unicode character properties. It it
-not run automatically unless PCRE is built with Unicode property support. To to
+The sixth test checks the support for Unicode character properties. It it not
+run automatically unless PCRE is built with Unicode property support. To to
this you must set --enable-unicode-properties when running "configure".
The seventh, eighth, and ninth tests check the pcre_dfa_exec() alternative
@@ -386,27 +524,42 @@ automatically unless PCRE is build with the relevant support.
Character tables
----------------
-PCRE uses four tables for manipulating and identifying characters whose values
-are less than 256. The final argument of the pcre_compile() function is a
-pointer to a block of memory containing the concatenated tables. A call to
-pcre_maketables() can be used to generate a set of tables in the current
-locale. If the final argument for pcre_compile() is passed as NULL, a set of
-default tables that is built into the binary is used.
-
-The source file called chartables.c contains the default set of tables. This is
-not supplied in the distribution, but is built by the program dftables
-(compiled from dftables.c), which uses the ANSI C character handling functions
-such as isalnum(), isalpha(), isupper(), islower(), etc. to build the table
-sources. This means that the default C locale which is set for your system will
-control the contents of these default tables. You can change the default tables
-by editing chartables.c and then re-building PCRE. If you do this, you should
-probably also edit Makefile to ensure that the file doesn't ever get
-re-generated.
+For speed, PCRE uses four tables for manipulating and identifying characters
+whose code point values are less than 256. The final argument of the
+pcre_compile() function is a pointer to a block of memory containing the
+concatenated tables. A call to pcre_maketables() can be used to generate a set
+of tables in the current locale. If the final argument for pcre_compile() is
+passed as NULL, a set of default tables that is built into the binary is used.
+
+The source file called pcre_chartables.c contains the default set of tables. By
+default, this is created as a copy of pcre_chartables.c.dist, which contains
+tables for ASCII coding. However, if --enable-rebuild-chartables is specified
+for ./configure, a different version of pcre_chartables.c is built by the
+program dftables (compiled from dftables.c), which uses the ANSI C character
+handling functions such as isalnum(), isalpha(), isupper(), islower(), etc. to
+build the table sources. This means that the default C locale which is set for
+your system will control the contents of these default tables. You can change
+the default tables by editing pcre_chartables.c and then re-building PCRE. If
+you do this, you should take care to ensure that the file does not get
+automatically re-generated. The best way to do this is to move
+pcre_chartables.c.dist out of the way and replace it with your customized
+tables.
+
+When the dftables program is run as a result of --enable-rebuild-chartables,
+it uses the default C locale that is set on your system. It does not pay
+attention to the LC_xxx environment variables. In other words, it uses the
+system's default locale rather than whatever the compiling user happens to have
+set. If you really do want to build a source set of character tables in a
+locale that is specified by the LC_xxx variables, you can run the dftables
+program by hand with the -L option. For example:
+
+ ./dftables -L pcre_chartables.c.special
The first two 256-byte tables provide lower casing and case flipping functions,
respectively. The next table consists of three 32-byte bit maps which identify
digits, "word" characters, and white space, respectively. These are used when
-building 32-byte bit maps that represent character classes.
+building 32-byte bit maps that represent character classes for code points less
+than 256.
The final 256-byte table has bits indicating various character types, as
follows:
@@ -422,108 +575,143 @@ You should not alter the set of characters that contain the 128 bit, as that
will cause PCRE to malfunction.
-Manifest
---------
+File manifest
+-------------
The distribution should contain the following files:
-(A) The actual source files of the PCRE library functions and their
- headers:
-
- dftables.c auxiliary program for building chartables.c
-
- pcreposix.c )
- pcre_compile.c )
- pcre_config.c )
- pcre_dfa_exec.c )
- pcre_exec.c )
- pcre_fullinfo.c )
- pcre_get.c ) sources for the functions in the library,
- pcre_globals.c ) and some internal functions that they use
- pcre_info.c )
- pcre_maketables.c )
- pcre_newline.c )
- pcre_ord2utf8.c )
- pcre_refcount.c )
- pcre_study.c )
- pcre_tables.c )
- pcre_try_flipped.c )
- pcre_ucp_searchfuncs.c)
- pcre_valid_utf8.c )
- pcre_version.c )
- pcre_xclass.c )
- ucptable.c )
-
- pcre_printint.src ) debugging function that is #included in pcretest, and
- ) can also be #included in pcre_compile()
-
- pcre.h the public PCRE header file
- pcreposix.h header for the external POSIX wrapper API
- pcre_internal.h header for internal use
- ucp.h ) headers concerned with
- ucpinternal.h ) Unicode property handling
- config.in template for config.h, which is built by configure
-
- pcrecpp.h the header file for the C++ wrapper
- pcrecpparg.h.in "source" for another C++ header file
- pcrecpp.cc )
- pcre_scanner.cc ) source for the C++ wrapper library
-
- pcre_stringpiece.h.in "source" for pcre_stringpiece.h, the header for the
- C++ stringpiece functions
- pcre_stringpiece.cc source for the C++ stringpiece functions
-
-(B) Auxiliary files:
-
- AUTHORS information about the author of PCRE
- ChangeLog log of changes to the code
- INSTALL generic installation instructions
- LICENCE conditions for the use of PCRE
- COPYING the same, using GNU's standard name
- Makefile.in template for Unix Makefile, which is built by configure
- NEWS important changes in this release
- NON-UNIX-USE notes on building PCRE on non-Unix systems
- README this file
- RunTest.in template for a Unix shell script for running tests
- RunGrepTest.in template for a Unix shell script for pcregrep tests
- config.guess ) files used by libtool,
- config.sub ) used only when building a shared library
- config.h.in "source" for the config.h header file
- configure a configuring shell script (built by autoconf)
- configure.ac the autoconf input used to build configure
- doc/Tech.Notes notes on the encoding
- doc/*.3 man page sources for the PCRE functions
- doc/*.1 man page sources for pcregrep and pcretest
- doc/html/* HTML documentation
- doc/pcre.txt plain text version of the man pages
- doc/pcretest.txt plain text documentation of test program
- doc/perltest.txt plain text documentation of Perl test program
- install-sh a shell script for installing files
- libpcre.pc.in "source" for libpcre.pc for pkg-config
- ltmain.sh file used to build a libtool script
- mkinstalldirs script for making install directories
- pcretest.c comprehensive test program
- pcredemo.c simple demonstration of coding calls to PCRE
- perltest Perl test program
- pcregrep.c source of a grep utility that uses PCRE
- pcre-config.in source of script which retains PCRE information
- pcrecpp_unittest.c )
- pcre_scanner_unittest.c ) test programs for the C++ wrapper
- pcre_stringpiece_unittest.c )
- testdata/testinput* test data for main library tests
- testdata/testoutput* expected test results
- testdata/grep* input and output for pcregrep tests
-
-(C) Auxiliary files for Win32 DLL
-
- libpcre.def
- libpcreposix.def
-
-(D) Auxiliary file for VPASCAL
+(A) Source files of the PCRE library functions and their headers:
+
+ dftables.c auxiliary program for building pcre_chartables.c
+ when --enable-rebuild-chartables is specified
+
+ pcre_chartables.c.dist a default set of character tables that assume ASCII
+ coding; used, unless --enable-rebuild-chartables is
+ specified, by copying to pcre_chartables.c
+
+ pcreposix.c )
+ pcre_compile.c )
+ pcre_config.c )
+ pcre_dfa_exec.c )
+ pcre_exec.c )
+ pcre_fullinfo.c )
+ pcre_get.c ) sources for the functions in the library,
+ pcre_globals.c ) and some internal functions that they use
+ pcre_info.c )
+ pcre_maketables.c )
+ pcre_newline.c )
+ pcre_ord2utf8.c )
+ pcre_refcount.c )
+ pcre_study.c )
+ pcre_tables.c )
+ pcre_try_flipped.c )
+ pcre_ucp_searchfuncs.c )
+ pcre_valid_utf8.c )
+ pcre_version.c )
+ pcre_xclass.c )
+ pcre_printint.src ) debugging function that is #included in pcretest,
+ ) and can also be #included in pcre_compile()
+ pcre.h.in template for pcre.h when built by "configure"
+ pcreposix.h header for the external POSIX wrapper API
+ pcre_internal.h header for internal use
+ ucp.h ) headers concerned with
+ ucpinternal.h ) Unicode property handling
+ ucptable.h ) (this one is the data table)
+
+ config.h.in template for config.h, which is built by "configure"
+
+ pcrecpp.h public header file for the C++ wrapper
+ pcrecpparg.h.in template for another C++ header file
+ pcre_scanner.h public header file for C++ scanner functions
+ pcrecpp.cc )
+ pcre_scanner.cc ) source for the C++ wrapper library
+
+ pcre_stringpiece.h.in template for pcre_stringpiece.h, the header for the
+ C++ stringpiece functions
+ pcre_stringpiece.cc source for the C++ stringpiece functions
+
+(B) Source files for programs that use PCRE:
+
+ pcredemo.c simple demonstration of coding calls to PCRE
+ pcregrep.c source of a grep utility that uses PCRE
+ pcretest.c comprehensive test program
+
+(C) Auxiliary files:
+
+ 132html script to turn "man" pages into HTML
+ AUTHORS information about the author of PCRE
+ ChangeLog log of changes to the code
+ CleanTxt script to clean nroff output for txt man pages
+ Detrail script to remove trailing spaces
+ HACKING some notes about the internals of PCRE
+ INSTALL generic installation instructions
+ LICENCE conditions for the use of PCRE
+ COPYING the same, using GNU's standard name
+ Makefile.in ) template for Unix Makefile, which is built by
+ ) "configure"
+ Makefile.am ) the automake input that was used to create
+ ) Makefile.in
+ NEWS important changes in this release
+ NON-UNIX-USE notes on building PCRE on non-Unix systems
+ PrepareRelease script to make preparations for "make dist"
+ README this file
+ RunTest a Unix shell script for running tests
+ RunGrepTest a Unix shell script for pcregrep tests
+ aclocal.m4 m4 macros (generated by "aclocal")
+ config.guess ) files used by libtool,
+ config.sub ) used only when building a shared library
+ configure a configuring shell script (built by autoconf)
+ configure.ac ) the autoconf input that was used to build
+ ) "configure" and config.h
+ depcomp ) script to find program dependencies, generated by
+ ) automake
+ doc/*.3 man page sources for the PCRE functions
+ doc/*.1 man page sources for pcregrep and pcretest
+ doc/index.html.src the base HTML page
+ doc/html/* HTML documentation
+ doc/pcre.txt plain text version of the man pages
+ doc/pcretest.txt plain text documentation of test program
+ doc/perltest.txt plain text documentation of Perl test program
+ install-sh a shell script for installing files
+ libpcre.pc.in template for libpcre.pc for pkg-config
+ libpcrecpp.pc.in template for libpcrecpp.pc for pkg-config
+ ltmain.sh file used to build a libtool script
+ missing ) common stub for a few missing GNU programs while
+ ) installing, generated by automake
+ mkinstalldirs script for making install directories
+ perltest.pl Perl test program
+ pcre-config.in source of script which retains PCRE information
+ pcrecpp_unittest.cc )
+ pcre_scanner_unittest.cc ) test programs for the C++ wrapper
+ pcre_stringpiece_unittest.cc )
+ testdata/testinput* test data for main library tests
+ testdata/testoutput* expected test results
+ testdata/grep* input and output for pcregrep tests
+
+(D) Auxiliary files for cmake support
+
+ CMakeLists.txt
+ config-cmake.h.in
+
+(E) Auxiliary files for VPASCAL
makevp.bat
+ makevp_c.txt
+ makevp_l.txt
+ pcregexp.pas
+
+(F) Auxiliary files for building PCRE "by hand"
+
+ pcre.h.generic ) a version of the public PCRE header file
+ ) for use in non-"configure" environments
+ config.h.generic ) a version of config.h for use in non-"configure"
+ ) environments
+
+(F) Miscellaneous
+
+ RunTest.bat a script for running tests under Windows
Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
-November 2006
+Last updated: 24 April 2007
diff --git a/ext/pcre/pcrelib/config.h b/ext/pcre/pcrelib/config.h
new file mode 100644
index 0000000000..2913989624
--- /dev/null
+++ b/ext/pcre/pcrelib/config.h
@@ -0,0 +1,282 @@
+
+#include <php_compat.h>
+#undef PACKAGE_NAME
+#undef PACKAGE_VERSION
+#undef PACKAGE_TARNAME
+#undef PACKAGE_STRING
+
+#define SUPPORT_UCP
+#define SUPPORT_UTF8
+
+
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+
+/* On Unix-like systems config.h.in is converted by "configure" into config.h.
+Some other environments also support the use of "configure". PCRE is written in
+Standard C, but there are a few non-standard things it can cope with, allowing
+it to run on SunOS4 and other "close to standard" systems.
+
+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
+macros the way you need them. Alternatively, you can avoid editing by using -D
+on the compiler command line to set the macro values.
+
+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
+them both to 0; an emulation function will be used. */
+
+/* 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
+ "configure", this can be done via --enable-ebcdic. */
+/* #undef EBCDIC */
+
+/* Define to 1 if you have the `bcopy' function. */
+#ifndef HAVE_BCOPY
+#define HAVE_BCOPY 1
+#endif
+
+/* 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. */
+#ifndef HAVE_DIRENT_H
+#define HAVE_DIRENT_H 1
+#endif
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#ifndef HAVE_DLFCN_H
+#define HAVE_DLFCN_H 1
+#endif
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#ifndef HAVE_INTTYPES_H
+#define HAVE_INTTYPES_H 1
+#endif
+
+/* Define to 1 if you have the <limits.h> header file. */
+#ifndef HAVE_LIMITS_H
+#define HAVE_LIMITS_H 1
+#endif
+
+/* Define to 1 if the system has the type `long long'. */
+#ifndef HAVE_LONG_LONG
+#define HAVE_LONG_LONG 1
+#endif
+
+/* Define to 1 if you have the `memmove' function. */
+#ifndef HAVE_MEMMOVE
+#define HAVE_MEMMOVE 1
+#endif
+
+/* Define to 1 if you have the <memory.h> header file. */
+#ifndef HAVE_MEMORY_H
+#define HAVE_MEMORY_H 1
+#endif
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H 1
+#endif
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#ifndef HAVE_STDLIB_H
+#define HAVE_STDLIB_H 1
+#endif
+
+/* Define to 1 if you have the `strerror' function. */
+#ifndef HAVE_STRERROR
+#define HAVE_STRERROR 1
+#endif
+
+/* Define to 1 if you have the <string> header file. */
+#ifndef HAVE_STRING
+#define HAVE_STRING 1
+#endif
+
+/* Define to 1 if you have the <strings.h> header file. */
+#ifndef HAVE_STRINGS_H
+#define HAVE_STRINGS_H 1
+#endif
+
+/* Define to 1 if you have the <string.h> header file. */
+#ifndef HAVE_STRING_H
+#define HAVE_STRING_H 1
+#endif
+
+/* Define to 1 if you have the `strtoll' function. */
+#ifndef HAVE_STRTOLL
+#define HAVE_STRTOLL 1
+#endif
+
+/* Define to 1 if you have the `strtoq' function. */
+#ifndef HAVE_STRTOQ
+#define HAVE_STRTOQ 1
+#endif
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#ifndef HAVE_SYS_STAT_H
+#define HAVE_SYS_STAT_H 1
+#endif
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#ifndef HAVE_SYS_TYPES_H
+#define HAVE_SYS_TYPES_H 1
+#endif
+
+/* 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. */
+#ifndef HAVE_UNISTD_H
+#define HAVE_UNISTD_H 1
+#endif
+
+/* Define to 1 if the system has the type `unsigned long long'. */
+#ifndef HAVE_UNSIGNED_LONG_LONG
+#define HAVE_UNSIGNED_LONG_LONG 1
+#endif
+
+/* Define to 1 if you have the <windows.h> header file. */
+/* #undef HAVE_WINDOWS_H */
+
+/* The value of LINK_SIZE determines the number of bytes used to store links
+ as offsets within the compiled regex. The default is 2, which allows for
+ compiled patterns up to 64K long. This covers the vast majority of cases.
+ However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows
+ for longer patterns in extreme cases. On systems that support it,
+ "configure" can be used to override this default. */
+#ifndef LINK_SIZE
+#define LINK_SIZE 2
+#endif
+
+/* The value of MATCH_LIMIT determines the default number of times the
+ internal match() function can be called during a single execution of
+ pcre_exec(). There is a runtime interface for setting a different limit.
+ The limit exists in order to catch runaway regular expressions that take
+ for ever to determine that they do not match. The default is set very large
+ so that it does not accidentally catch legitimate cases. On systems that
+ support it, "configure" can be used to override this default default. */
+#ifndef MATCH_LIMIT
+#define MATCH_LIMIT 10000000
+#endif
+
+/* The above limit applies to all calls of match(), whether or not they
+ increase the recursion depth. In some environments it is desirable to limit
+ the depth of recursive calls of match() more strictly, in order to restrict
+ the maximum amount of stack (or heap, if NO_RECURSE is defined) that is
+ used. The value of MATCH_LIMIT_RECURSION applies only to recursive calls of
+ match(). To have any useful effect, it must be less than the value of
+ MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT. There is
+ a runtime method for setting a different limit. On systems that support it,
+ "configure" can be used to override the default. */
+#ifndef MATCH_LIMIT_RECURSION
+#define MATCH_LIMIT_RECURSION MATCH_LIMIT
+#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.
+ Care must be taken if it is increased, because it guards against integer
+ overflow caused by enormously large patterns. */
+#ifndef MAX_NAME_COUNT
+#define MAX_NAME_COUNT 10000
+#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_NAME_SIZE
+#define MAX_NAME_SIZE 32
+#endif
+
+/* The value of NEWLINE determines the newline character sequence. On
+ Unix-like systems, "configure" can be used to override the default, which
+ is 10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), -1 (ANY), or
+ -2 (ANYCRLF). */
+#ifndef NEWLINE
+#define NEWLINE 10
+#endif
+
+/* PCRE uses recursive function calls to handle backtracking while matching.
+ This can sometimes be a problem on systems that have stacks of limited
+ size. Define NO_RECURSE to get a version that doesn't use recursion in the
+ match() function; instead it creates its own stack by steam using
+ pcre_recurse_malloc() to obtain memory from the heap. For more detail, see
+ the comments and other stuff just above the match() function. On systems
+ that support it, "configure" can be used to set this in the Makefile (use
+ --disable-stack-for-recursion). */
+/* #undef NO_RECURSE */
+
+/* Name of package */
+#define PACKAGE "pcre"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "PCRE"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "PCRE 7.2-RC3"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "pcre"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "7.2-RC3"
+
+
+/* If you are compiling for a system other than a Unix-like system or
+ Win32, and it needs some magic to be inserted before the definition
+ of a function that is exported by the library, define this macro to
+ contain the relevant magic. If you do not define this macro, it
+ defaults to "extern" for a C compiler and "extern C" for a C++
+ compiler on non-Win32 systems. This macro apears at the start of
+ every exported function that is part of the external API. It does
+ not appear on functions that are "external" in the C sense, but
+ which are internal to the library. */
+/* #undef PCRE_EXP_DEFN */
+
+/* Define if linking statically (TODO: make nice with Libtool) */
+/* #undef PCRE_STATIC */
+
+/* When calling PCRE via the POSIX interface, additional working storage is
+ required for holding the pointers to capturing substrings because PCRE
+ requires three integers per substring, whereas the POSIX interface provides
+ only two. If the number of expected substrings is small, the wrapper
+ function uses space on the stack, because this is faster than using
+ malloc() for each call. The threshold above which the stack is no longer
+ used is defined by POSIX_MALLOC_THRESHOLD. On systems that support it,
+ "configure" can be used to override this default. */
+#ifndef POSIX_MALLOC_THRESHOLD
+#define POSIX_MALLOC_THRESHOLD 10
+#endif
+
+/* Define to 1 if you have the ANSI C header files. */
+#ifndef STDC_HEADERS
+#define STDC_HEADERS 1
+#endif
+
+/* Define to enable support for Unicode properties */
+/* #undef SUPPORT_UCP */
+
+/* Define to enable support for the UTF-8 Unicode encoding. */
+/* #undef SUPPORT_UTF8 */
+
+/* Version number of package */
+#ifndef VERSION
+#define VERSION "7.2-RC3"
+#endif
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
diff --git a/ext/pcre/pcrelib/dftables.c b/ext/pcre/pcrelib/dftables.c
index a94b7a61d5..baa56a15c9 100644
--- a/ext/pcre/pcrelib/dftables.c
+++ b/ext/pcre/pcrelib/dftables.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -38,14 +38,15 @@ POSSIBILITY OF SUCH DAMAGE.
*/
-/* This is a freestanding support program to generate a file containing default
-character tables for PCRE. The tables are built according to the default C
+/* This is a freestanding support program to generate a file containing
+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
make use of its code from here in order to be consistent. */
#include <ctype.h>
#include <stdio.h>
#include <string.h>
+#include <locale.h>
#include "pcre_internal.h"
@@ -55,38 +56,48 @@ make use of its code from here in order to be consistent. */
int main(int argc, char **argv)
{
-int i;
FILE *f;
-const unsigned char *tables = pcre_maketables();
-const unsigned char *base_of_tables = tables;
+int i = 1;
+const unsigned char *tables;
+const unsigned char *base_of_tables;
-if (argc != 2)
+/* By default, the default C locale is used rather than what the building user
+happens to have set. However, if the -L option is given, set the locale from
+the LC_xxx environment variables. */
+
+if (argc > 1 && strcmp(argv[1], "-L") == 0)
+ {
+ setlocale(LC_ALL, ""); /* Set from environment variables */
+ i++;
+ }
+
+if (argc < i + 1)
{
fprintf(stderr, "dftables: one filename argument is required\n");
return 1;
}
-f = fopen(argv[1], "wb");
+tables = pcre_maketables();
+base_of_tables = tables;
+
+f = fopen(argv[i], "wb");
if (f == NULL)
{
fprintf(stderr, "dftables: failed to open %s for writing\n", argv[1]);
return 1;
}
-/* There are two fprintf() calls here, because gcc in pedantic mode complains
-about the very long string otherwise. */
+/* There are several fprintf() calls here, because gcc in pedantic mode
+complains about the very long string otherwise. */
fprintf(f,
"/*************************************************\n"
"* Perl-Compatible Regular Expressions *\n"
"*************************************************/\n\n"
- "/* This file is automatically written by the dftables auxiliary \n"
- "program. If you edit it by hand, you might like to edit the Makefile to \n"
- "prevent its ever being regenerated.\n\n");
-fprintf(f,
- "This file contains the default tables for characters with codes less than\n"
- "128 (ASCII characters). These tables are used when no external tables are\n"
- "passed to PCRE.\n\n");
+ "/* This file was automatically written by the dftables auxiliary\n"
+ "program. It contains character tables that are used when no external\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");
fprintf(f,
"The following #include is present because without it gcc 4.x may remove\n"
"the array definition from the final binary if PCRE is built into a static\n"
@@ -171,7 +182,7 @@ if (isprint(i-8)) fprintf(f, " %c -", i-8);
else fprintf(f, "%3d-", i-8);
if (isprint(i-1)) fprintf(f, " %c ", i-1);
else fprintf(f, "%3d", i-1);
-fprintf(f, " */\n\n/* End of chartables.c */\n");
+fprintf(f, " */\n\n/* End of pcre_chartables.c */\n");
fclose(f);
free((void *)base_of_tables);
diff --git a/ext/pcre/pcrelib/doc/pcre.txt b/ext/pcre/pcrelib/doc/pcre.txt
index 9c7884998c..e55cf01c3a 100644
--- a/ext/pcre/pcrelib/doc/pcre.txt
+++ b/ext/pcre/pcrelib/doc/pcre.txt
@@ -72,6 +72,7 @@ USER DOCUMENTATION
of searching. The sections are as follows:
pcre this document
+ pcre-config show PCRE installation configuration information
pcreapi details of PCRE's native C API
pcrebuild options for building PCRE
pcrecallout details of the callout feature
@@ -196,7 +197,11 @@ UTF-8 AND UNICODE PROPERTY SUPPORT
8. Similarly, characters that match the POSIX named character classes
are all low-valued characters.
- 9. Case-insensitive matching applies only to characters whose values
+ 9. However, the Perl 5.10 horizontal and vertical whitespace matching
+ escapes (\h, \H, \v, and \V) do match all the appropriate Unicode char-
+ acters.
+
+ 10. Case-insensitive matching applies only to characters whose values
are less than 128, unless PCRE is built with Unicode property support.
Even when Unicode property support is available, PCRE still uses its
own character tables when checking the case of low-valued characters,
@@ -211,15 +216,18 @@ UTF-8 AND UNICODE PROPERTY SUPPORT
AUTHOR
Philip Hazel
- University Computing Service,
+ University Computing Service
Cambridge CB2 3QH, England.
Putting an actual email address here seems to have been a spam magnet,
- so I've taken it away. If you want to email me, use my initial and sur-
- name, separated by a dot, at the domain ucs.cam.ac.uk.
+ so I've taken it away. If you want to email me, use my two initials,
+ followed by the two digits 10, at the domain cam.ac.uk.
+
+
+REVISION
-Last updated: 23 November 2006
-Copyright (c) 1997-2006 University of Cambridge.
+ Last updated: 13 June 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -241,12 +249,12 @@ PCRE BUILD-TIME OPTIONS
./configure --help
- The following sections describe certain options whose names begin with
- --enable or --disable. These settings specify changes to the defaults
- for the configure command. Because of the way that configure works,
- --enable and --disable always come in pairs, so the complementary
- option always exists as well, but as it specifies the default, it is
- not described.
+ The following sections include descriptions of options whose names
+ begin with --enable or --disable. These settings specify changes to the
+ defaults for the configure command. Because of the way that configure
+ works, --enable and --disable always come in pairs, so the complemen-
+ tary option always exists as well, but as it specifies the default, it
+ is not described.
C++ SUPPORT
@@ -285,22 +293,21 @@ UNICODE CHARACTER PROPERTY SUPPORT
to the configure command. This implies UTF-8 support, even if you have
not explicitly requested it.
- Including Unicode property support adds around 90K of tables to the
- PCRE library, approximately doubling its size. Only the general cate-
- gory properties such as Lu and Nd are supported. Details are given in
- the pcrepattern documentation.
+ Including Unicode property support adds around 30K of tables to the
+ PCRE library. Only the general category properties such as Lu and Nd
+ are supported. Details are given in the pcrepattern documentation.
CODE VALUE OF NEWLINE
- By default, PCRE interprets character 10 (linefeed, LF) as indicating
- the end of a line. This is the normal newline character on Unix-like
+ By default, PCRE interprets character 10 (linefeed, LF) as indicating
+ the end of a line. This is the normal newline character on Unix-like
systems. You can compile PCRE to use character 13 (carriage return, CR)
instead, by adding
--enable-newline-is-cr
- to the configure command. There is also a --enable-newline-is-lf
+ to the configure command. There is also a --enable-newline-is-lf
option, which explicitly specifies linefeed as the newline character.
Alternatively, you can specify that line endings are to be indicated by
@@ -310,19 +317,24 @@ CODE VALUE OF NEWLINE
to the configure command. There is a fourth option, specified by
+ --enable-newline-is-anycrlf
+
+ which causes PCRE to recognize any of the three sequences CR, LF, or
+ CRLF as indicating a line ending. Finally, a fifth option, specified by
+
--enable-newline-is-any
- which causes PCRE to recognize any Unicode newline sequence.
+ causes PCRE to recognize any Unicode newline sequence.
- Whatever line ending convention is selected when PCRE is built can be
- overridden when the library functions are called. At build time it is
+ Whatever line ending convention is selected when PCRE is built can be
+ overridden when the library functions are called. At build time it is
conventional to use the standard for your operating system.
BUILDING SHARED AND STATIC LIBRARIES
- The PCRE building process uses libtool to build both shared and static
- Unix libraries by default. You can suppress one of these by adding one
+ The PCRE building process uses libtool to build both shared and static
+ Unix libraries by default. You can suppress one of these by adding one
of
--disable-shared
@@ -334,9 +346,9 @@ BUILDING SHARED AND STATIC LIBRARIES
POSIX MALLOC USAGE
When PCRE is called through the POSIX interface (see the pcreposix doc-
- umentation), additional working storage is required for holding the
- pointers to capturing substrings, because PCRE requires three integers
- per substring, whereas the POSIX interface provides only two. If the
+ umentation), additional working storage is required for holding the
+ pointers to capturing substrings, because PCRE requires three integers
+ per substring, whereas the POSIX interface provides only two. If the
number of expected substrings is small, the wrapper function uses space
on the stack, because this is faster than using malloc() for each call.
The default threshold above which the stack is no longer used is 10; it
@@ -349,26 +361,21 @@ POSIX MALLOC USAGE
HANDLING VERY LARGE PATTERNS
- Within a compiled pattern, offset values are used to point from one
- part to another (for example, from an opening parenthesis to an alter-
- nation metacharacter). By default, two-byte values are used for these
- offsets, leading to a maximum size for a compiled pattern of around
- 64K. This is sufficient to handle all but the most gigantic patterns.
- Nevertheless, some people do want to process enormous patterns, so it
- is possible to compile PCRE to use three-byte or four-byte offsets by
+ Within a compiled pattern, offset values are used to point from one
+ part to another (for example, from an opening parenthesis to an alter-
+ nation metacharacter). By default, two-byte values are used for these
+ offsets, leading to a maximum size for a compiled pattern of around
+ 64K. This is sufficient to handle all but the most gigantic patterns.
+ Nevertheless, some people do want to process enormous patterns, so it
+ is possible to compile PCRE to use three-byte or four-byte offsets by
adding a setting such as
--with-link-size=3
- to the configure command. The value given must be 2, 3, or 4. Using
- longer offsets slows down the operation of PCRE because it has to load
+ to the configure command. The value given must be 2, 3, or 4. Using
+ longer offsets slows down the operation of PCRE because it has to load
additional bytes when handling them.
- If you build PCRE with an increased link size, test 2 (and test 5 if
- you are using UTF-8) will fail. Part of the output of these tests is a
- representation of the compiled pattern, and this changes with the link
- size.
-
AVOIDING EXCESSIVE STACK USAGE
@@ -387,13 +394,17 @@ AVOIDING EXCESSIVE STACK USAGE
to the configure command. With this configuration, PCRE will use the
pcre_stack_malloc and pcre_stack_free variables to call memory manage-
- ment functions. Separate functions are provided because the usage is
- very predictable: the block sizes requested are always the same, and
- the blocks are always freed in reverse order. A calling program might
- be able to implement optimized functions that perform better than the
- standard malloc() and free() functions. PCRE runs noticeably more
- slowly when built in this way. This option affects only the pcre_exec()
- function; it is not relevant for the the pcre_dfa_exec() function.
+ ment functions. By default these point to malloc() and free(), but you
+ can replace the pointers so that your own functions are used.
+
+ Separate functions are provided rather than using pcre_malloc and
+ pcre_free because the usage is very predictable: the block sizes
+ requested are always the same, and the blocks are always freed in
+ reverse order. A calling program might be able to implement optimized
+ functions that perform better than malloc() and free(). PCRE runs
+ noticeably more slowly when built in this way. This option affects only
+ the pcre_exec() function; it is not relevant for the the
+ pcre_dfa_exec() function.
LIMITING PCRE RESOURCE USAGE
@@ -426,24 +437,53 @@ LIMITING PCRE RESOURCE USAGE
time.
+CREATING CHARACTER TABLES AT BUILD TIME
+
+ PCRE uses fixed tables for processing characters whose code values are
+ less than 256. By default, PCRE is built with a set of tables that are
+ distributed in the file pcre_chartables.c.dist. These tables are for
+ ASCII codes only. If you add
+
+ --enable-rebuild-chartables
+
+ to the configure command, the distributed tables are no longer used.
+ Instead, a program called dftables is compiled and run. This outputs
+ the source for new set of tables, created in the default locale of your
+ C runtime system. (This method of replacing the tables does not work if
+ you are cross compiling, because dftables is run on the local host. If
+ you need to create alternative tables when cross compiling, you will
+ have to do so "by hand".)
+
+
USING EBCDIC CODE
- PCRE assumes by default that it will run in an environment where the
- character code is ASCII (or Unicode, which is a superset of ASCII).
- PCRE can, however, be compiled to run in an EBCDIC environment by
+ PCRE assumes by default that it will run in an environment where the
+ character code is ASCII (or Unicode, which is a superset of ASCII).
+ PCRE can, however, be compiled to run in an EBCDIC environment by
adding
--enable-ebcdic
- to the configure command.
+ to the configure command. This setting implies --enable-rebuild-charta-
+ bles.
SEE ALSO
pcreapi(3), pcre_config(3).
-Last updated: 30 November 2006
-Copyright (c) 1997-2006 University of Cambridge.
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 05 June 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -495,8 +535,8 @@ REGULAR EXPRESSIONS AS TREES
THE STANDARD MATCHING ALGORITHM
- In the terminology of Jeffrey Friedl's book Mastering Regular Expres-
- sions, the standard algorithm is an "NFA algorithm". It conducts a
+ In the terminology of Jeffrey Friedl's book "Mastering Regular Expres-
+ sions", the standard algorithm is an "NFA algorithm". It conducts a
depth-first search of the pattern tree. That is, it proceeds along a
single path through the tree, checking that the subject matches what is
required. When there is a mismatch, the algorithm tries any alterna-
@@ -578,34 +618,39 @@ THE ALTERNATIVE MATCHING ALGORITHM
ence as the condition or test for a specific group recursion are not
supported.
- 5. Callouts are supported, but the value of the capture_top field is
+ 5. Because many paths through the tree may be active, the \K escape
+ sequence, which resets the start of the match when encountered (but may
+ be on some paths and not on others), is not supported. It causes an
+ error if encountered.
+
+ 6. Callouts are supported, but the value of the capture_top field is
always 1, and the value of the capture_last field is always -1.
- 6. The \C escape sequence, which (in the standard algorithm) matches a
- single byte, even in UTF-8 mode, is not supported because the alterna-
- tive algorithm moves through the subject string one character at a
+ 7. The \C escape sequence, which (in the standard algorithm) matches a
+ single byte, even in UTF-8 mode, is not supported because the alterna-
+ tive algorithm moves through the subject string one character at a
time, for all active paths through the tree.
ADVANTAGES OF THE ALTERNATIVE ALGORITHM
- Using the alternative matching algorithm provides the following advan-
+ Using the alternative matching algorithm provides the following advan-
tages:
1. All possible matches (at a single point in the subject) are automat-
- ically found, and in particular, the longest match is found. To find
+ ically found, and in particular, the longest match is found. To find
more than one match using the standard algorithm, you have to do kludgy
things with callouts.
- 2. There is much better support for partial matching. The restrictions
- on the content of the pattern that apply when using the standard algo-
- rithm for partial matching do not apply to the alternative algorithm.
- For non-anchored patterns, the starting position of a partial match is
+ 2. There is much better support for partial matching. The restrictions
+ on the content of the pattern that apply when using the standard algo-
+ rithm for partial matching do not apply to the alternative algorithm.
+ For non-anchored patterns, the starting position of a partial match is
available.
- 3. Because the alternative algorithm scans the subject string just
- once, and never needs to backtrack, it is possible to pass very long
- subject strings to the matching function in several pieces, checking
+ 3. Because the alternative algorithm scans the subject string just
+ once, and never needs to backtrack, it is possible to pass very long
+ subject strings to the matching function in several pieces, checking
for partial matching each time.
@@ -613,8 +658,8 @@ DISADVANTAGES OF THE ALTERNATIVE ALGORITHM
The alternative algorithm suffers from a number of disadvantages:
- 1. It is substantially slower than the standard algorithm. This is
- partly because it has to search for all possible matches, but is also
+ 1. It is substantially slower than the standard algorithm. This is
+ partly because it has to search for all possible matches, but is also
because it is less susceptible to optimization.
2. Capturing parentheses and back references are not supported.
@@ -622,8 +667,18 @@ DISADVANTAGES OF THE ALTERNATIVE ALGORITHM
3. Although atomic groups are supported, their use does not provide the
performance advantage that it does for the standard algorithm.
-Last updated: 24 November 2006
-Copyright (c) 1997-2006 University of Cambridge.
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 29 May 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -805,13 +860,13 @@ PCRE API OVERVIEW
NEWLINES
- PCRE supports four different conventions for indicating line breaks in
+ PCRE supports five different conventions for indicating line breaks in
strings: a single CR (carriage return) character, a single LF (line-
- feed) character, the two-character sequence CRLF, or any Unicode new-
- line sequence. The Unicode newline sequences are the three just men-
- tioned, plus the single characters VT (vertical tab, U+000B), FF (form-
- feed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028),
- and PS (paragraph separator, U+2029).
+ feed) character, the two-character sequence CRLF, any of the three pre-
+ ceding, or any Unicode newline sequence. The Unicode newline sequences
+ are the three just mentioned, plus the single characters VT (vertical
+ tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS (line
+ separator, U+2028), and PS (paragraph separator, U+2029).
Each of the first three conventions is used by at least one operating
system as its standard newline sequence. When PCRE is built, a default
@@ -845,7 +900,9 @@ SAVING PRECOMPILED PATTERNS FOR LATER USE
The compiled form of a regular expression can be saved and re-used at a
later time, possibly by a different program, and even on a host other
than the one on which it was compiled. Details are given in the
- pcreprecompile documentation.
+ pcreprecompile documentation. However, compiling a regular expression
+ with one version of PCRE for use with a different version is not guar-
+ anteed to work and may cause crashes.
CHECKING BUILD-TIME OPTIONS
@@ -876,9 +933,9 @@ CHECKING BUILD-TIME OPTIONS
The output is an integer whose value specifies the default character
sequence that is recognized as meaning "newline". The four values that
- are supported are: 10 for LF, 13 for CR, 3338 for CRLF, and -1 for ANY.
- The default should normally be the standard sequence for your operating
- system.
+ are supported are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF,
+ and -1 for ANY. The default should normally be the standard sequence
+ for your operating system.
PCRE_CONFIG_LINK_SIZE
@@ -1102,26 +1159,29 @@ COMPILING A PATTERN
PCRE_NEWLINE_CR
PCRE_NEWLINE_LF
PCRE_NEWLINE_CRLF
+ PCRE_NEWLINE_ANYCRLF
PCRE_NEWLINE_ANY
These options override the default newline definition that was chosen
when PCRE was built. Setting the first or the second specifies that a
newline is indicated by a single character (CR or LF, respectively).
Setting PCRE_NEWLINE_CRLF specifies that a newline is indicated by the
- two-character CRLF sequence. Setting PCRE_NEWLINE_ANY specifies that
- any Unicode newline sequence should be recognized. The Unicode newline
- sequences are the three just mentioned, plus the single characters VT
- (vertical tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085),
- LS (line separator, U+2028), and PS (paragraph separator, U+2029). The
- last two are recognized only in UTF-8 mode.
+ two-character CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies
+ that any of the three preceding sequences should be recognized. Setting
+ PCRE_NEWLINE_ANY specifies that any Unicode newline sequence should be
+ recognized. The Unicode newline sequences are the three just mentioned,
+ plus the single characters VT (vertical tab, U+000B), FF (formfeed,
+ U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS
+ (paragraph separator, U+2029). The last two are recognized only in
+ UTF-8 mode.
The newline setting in the options word uses three bits that are
- treated as a number, giving eight possibilities. Currently only five
- are used (default plus the four values above). This means that if you
- set more than one newline option, the combination may or may not be
- sensible. For example, PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equiva-
- lent to PCRE_NEWLINE_CRLF, but other combinations yield unused numbers
- and cause an error.
+ treated as a number, giving eight possibilities. Currently only six are
+ used (default plus the five values above). This means that if you set
+ more than one newline option, the combination may or may not be sensi-
+ ble. For example, PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to
+ PCRE_NEWLINE_CRLF, but other combinations may yield unused numbers and
+ cause an error.
The only time that a line break is specially recognized when compiling
a pattern is if PCRE_EXTENDED is set, and an unescaped # outside a
@@ -1207,7 +1267,7 @@ COMPILATION ERROR CODES
26 malformed number or name after (?(
27 conditional group contains more than two branches
28 assertion expected after (?(
- 29 (?R or (?digits must be followed by )
+ 29 (?R or (?[+-]digits must be followed by )
30 unknown POSIX class name
31 POSIX collating elements are not supported
32 this version of PCRE is not compiled with PCRE_UTF8 support
@@ -1236,6 +1296,9 @@ COMPILATION ERROR CODES
54 DEFINE group contains more than one branch
55 repeating a DEFINE group is not allowed
56 inconsistent NEWLINE options"
+ 57 \g is not followed by a braced name or an optionally braced
+ non-zero number
+ 58 (?+ or (?- or (?(+ or (?(- must be followed by a non-zero number
STUDYING A PATTERN
@@ -1287,31 +1350,41 @@ STUDYING A PATTERN
LOCALE SUPPORT
PCRE handles caseless matching, and determines whether characters are
- letters digits, or whatever, by reference to a set of tables, indexed
+ letters, digits, or whatever, by reference to a set of tables, indexed
by character value. When running in UTF-8 mode, this applies only to
characters with codes less than 128. Higher-valued codes never match
escapes such as \w or \d, but can be tested with \p if PCRE is built
with Unicode character property support. The use of locales with Uni-
- code is discouraged.
-
- An internal set of tables is created in the default C locale when PCRE
- is built. This is used when the final argument of pcre_compile() is
- NULL, and is sufficient for many applications. An alternative set of
- tables can, however, be supplied. These may be created in a different
- locale from the default. As more and more applications change to using
- Unicode, the need for this locale support is expected to die away.
-
- External tables are built by calling the pcre_maketables() function,
- which has no arguments, in the relevant locale. The result can then be
- passed to pcre_compile() or pcre_exec() as often as necessary. For
- example, to build and use tables that are appropriate for the French
- locale (where accented characters with values greater than 128 are
+ code is discouraged. If you are handling characters with codes greater
+ than 128, you should either use UTF-8 and Unicode, or use locales, but
+ not try to mix the two.
+
+ PCRE contains an internal set of tables that are used when the final
+ argument of pcre_compile() is NULL. These are sufficient for many
+ applications. Normally, the internal tables recognize only ASCII char-
+ acters. However, when PCRE is built, it is possible to cause the inter-
+ nal tables to be rebuilt in the default "C" locale of the local system,
+ which may cause them to be different.
+
+ The internal tables can always be overridden by tables supplied by the
+ application that calls PCRE. These may be created in a different locale
+ from the default. As more and more applications change to using Uni-
+ code, the need for this locale support is expected to die away.
+
+ External tables are built by calling the pcre_maketables() function,
+ which has no arguments, in the relevant locale. The result can then be
+ passed to pcre_compile() or pcre_exec() as often as necessary. For
+ example, to build and use tables that are appropriate for the French
+ locale (where accented characters with values greater than 128 are
treated as letters), the following code could be used:
setlocale(LC_CTYPE, "fr_FR");
tables = pcre_maketables();
re = pcre_compile(..., tables);
+ The locale name "fr_FR" is used on Linux and other Unix-like systems;
+ if you are using Windows, the name for the French locale is "french".
+
When pcre_maketables() runs, the tables are built in memory that is
obtained via pcre_malloc. It is the caller's responsibility to ensure
that the memory containing the tables remains available for as long as
@@ -1414,6 +1487,12 @@ INFORMATION ABOUT A PATTERN
returned. The fourth argument should point to an unsigned char * vari-
able.
+ PCRE_INFO_JCHANGED
+
+ Return 1 if the (?J) option setting is used in the pattern, otherwise
+ 0. The fourth argument should point to an int variable. The (?J) inter-
+ nal option setting changes the local PCRE_DUPNAMES option.
+
PCRE_INFO_LASTLITERAL
Return the value of the rightmost literal byte that must exist in any
@@ -1468,14 +1547,21 @@ INFORMATION ABOUT A PATTERN
name-to-number map, remember that the length of the entries is likely
to be different for each compiled pattern.
+ PCRE_INFO_OKPARTIAL
+
+ Return 1 if the pattern can be used for partial matching, otherwise 0.
+ The fourth argument should point to an int variable. The pcrepartial
+ documentation lists the restrictions that apply to patterns when par-
+ tial matching is used.
+
PCRE_INFO_OPTIONS
- Return a copy of the options with which the pattern was compiled. The
- fourth argument should point to an unsigned long int variable. These
+ Return a copy of the options with which the pattern was compiled. The
+ fourth argument should point to an unsigned long int variable. These
option bits are those specified in the call to pcre_compile(), modified
by any top-level option settings within the pattern itself.
- A pattern is automatically anchored by PCRE if all of its top-level
+ A pattern is automatically anchored by PCRE if all of its top-level
alternatives begin with one of the following:
^ unless PCRE_MULTILINE is set
@@ -1489,7 +1575,7 @@ INFORMATION ABOUT A PATTERN
PCRE_INFO_SIZE
- Return the size of the compiled pattern, that is, the value that was
+ Return the size of the compiled pattern, that is, the value that was
passed as the argument to pcre_malloc() when PCRE was getting memory in
which to place the compiled data. The fourth argument should point to a
size_t variable.
@@ -1497,9 +1583,9 @@ INFORMATION ABOUT A PATTERN
PCRE_INFO_STUDYSIZE
Return the size of the data block pointed to by the study_data field in
- a pcre_extra block. That is, it is the value that was passed to
+ a pcre_extra block. That is, it is the value that was passed to
pcre_malloc() when PCRE was getting memory into which to place the data
- created by pcre_study(). The fourth argument should point to a size_t
+ created by pcre_study(). The fourth argument should point to a size_t
variable.
@@ -1507,21 +1593,21 @@ OBSOLETE INFO FUNCTION
int pcre_info(const pcre *code, int *optptr, int *firstcharptr);
- The pcre_info() function is now obsolete because its interface is too
- restrictive to return all the available data about a compiled pattern.
- New programs should use pcre_fullinfo() instead. The yield of
- pcre_info() is the number of capturing subpatterns, or one of the fol-
+ The pcre_info() function is now obsolete because its interface is too
+ restrictive to return all the available data about a compiled pattern.
+ New programs should use pcre_fullinfo() instead. The yield of
+ pcre_info() is the number of capturing subpatterns, or one of the fol-
lowing negative numbers:
PCRE_ERROR_NULL the argument code was NULL
PCRE_ERROR_BADMAGIC the "magic number" was not found
- If the optptr argument is not NULL, a copy of the options with which
- the pattern was compiled is placed in the integer it points to (see
+ If the optptr argument is not NULL, a copy of the options with which
+ the pattern was compiled is placed in the integer it points to (see
PCRE_INFO_OPTIONS above).
- If the pattern is not anchored and the firstcharptr argument is not
- NULL, it is used to pass back information about the first character of
+ If the pattern is not anchored and the firstcharptr argument is not
+ NULL, it is used to pass back information about the first character of
any matched string (see PCRE_INFO_FIRSTBYTE above).
@@ -1529,21 +1615,21 @@ REFERENCE COUNTS
int pcre_refcount(pcre *code, int adjust);
- The pcre_refcount() function is used to maintain a reference count in
+ The pcre_refcount() function is used to maintain a reference count in
the data block that contains a compiled pattern. It is provided for the
- benefit of applications that operate in an object-oriented manner,
+ benefit of applications that operate in an object-oriented manner,
where different parts of the application may be using the same compiled
pattern, but you want to free the block when they are all done.
When a pattern is compiled, the reference count field is initialized to
- zero. It is changed only by calling this function, whose action is to
- add the adjust value (which may be positive or negative) to it. The
+ zero. It is changed only by calling this function, whose action is to
+ add the adjust value (which may be positive or negative) to it. The
yield of the function is the new value. However, the value of the count
- is constrained to lie between 0 and 65535, inclusive. If the new value
+ is constrained to lie between 0 and 65535, inclusive. If the new value
is outside these limits, it is forced to the appropriate limit value.
- Except when it is zero, the reference count is not correctly preserved
- if a pattern is compiled on one host and then transferred to a host
+ Except when it is zero, the reference count is not correctly preserved
+ if a pattern is compiled on one host and then transferred to a host
whose byte-order is different. (This seems a highly unlikely scenario.)
@@ -1553,18 +1639,18 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize);
- The function pcre_exec() is called to match a subject string against a
- compiled pattern, which is passed in the code argument. If the pattern
+ The function pcre_exec() is called to match a subject string against a
+ compiled pattern, which is passed in the code argument. If the pattern
has been studied, the result of the study should be passed in the extra
- argument. This function is the main matching facility of the library,
+ argument. This function is the main matching facility of the library,
and it operates in a Perl-like manner. For specialist use there is also
- an alternative matching function, which is described below in the sec-
+ an alternative matching function, which is described below in the sec-
tion about the pcre_dfa_exec() function.
- In most applications, the pattern will have been compiled (and option-
- ally studied) in the same process that calls pcre_exec(). However, it
+ In most applications, the pattern will have been compiled (and option-
+ ally studied) in the same process that calls pcre_exec(). However, it
is possible to save compiled patterns and study data, and then use them
- later in different processes, possibly even on different hosts. For a
+ later in different processes, possibly even on different hosts. For a
discussion about this, see the pcreprecompile documentation.
Here is an example of a simple call to pcre_exec():
@@ -1583,10 +1669,10 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
Extra data for pcre_exec()
- If the extra argument is not NULL, it must point to a pcre_extra data
- block. The pcre_study() function returns such a block (when it doesn't
- return NULL), but you can also create one for yourself, and pass addi-
- tional information in it. The pcre_extra block contains the following
+ If the extra argument is not NULL, it must point to a pcre_extra data
+ block. The pcre_study() function returns such a block (when it doesn't
+ return NULL), but you can also create one for yourself, and pass addi-
+ tional information in it. The pcre_extra block contains the following
fields (not necessarily in this order):
unsigned long int flags;
@@ -1596,7 +1682,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
void *callout_data;
const unsigned char *tables;
- The flags field is a bitmap that specifies which of the other fields
+ The flags field is a bitmap that specifies which of the other fields
are set. The flag bits are:
PCRE_EXTRA_STUDY_DATA
@@ -1605,91 +1691,93 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
PCRE_EXTRA_CALLOUT_DATA
PCRE_EXTRA_TABLES
- Other flag bits should be set to zero. The study_data field is set in
- the pcre_extra block that is returned by pcre_study(), together with
+ Other flag bits should be set to zero. The study_data field is set in
+ the pcre_extra block that is returned by pcre_study(), together with
the appropriate flag bit. You should not set this yourself, but you may
- add to the block by setting the other fields and their corresponding
+ add to the block by setting the other fields and their corresponding
flag bits.
The match_limit field provides a means of preventing PCRE from using up
- a vast amount of resources when running patterns that are not going to
- match, but which have a very large number of possibilities in their
- search trees. The classic example is the use of nested unlimited
+ a vast amount of resources when running patterns that are not going to
+ match, but which have a very large number of possibilities in their
+ search trees. The classic example is the use of nested unlimited
repeats.
- Internally, PCRE uses a function called match() which it calls repeat-
- edly (sometimes recursively). The limit set by match_limit is imposed
- on the number of times this function is called during a match, which
- has the effect of limiting the amount of backtracking that can take
+ Internally, PCRE uses a function called match() which it calls repeat-
+ edly (sometimes recursively). The limit set by match_limit is imposed
+ on the number of times this function is called during a match, which
+ has the effect of limiting the amount of backtracking that can take
place. For patterns that are not anchored, the count restarts from zero
for each position in the subject string.
- The default value for the limit can be set when PCRE is built; the
- default default is 10 million, which handles all but the most extreme
- cases. You can override the default by suppling pcre_exec() with a
- pcre_extra block in which match_limit is set, and
- PCRE_EXTRA_MATCH_LIMIT is set in the flags field. If the limit is
+ The default value for the limit can be set when PCRE is built; the
+ default default is 10 million, which handles all but the most extreme
+ cases. You can override the default by suppling pcre_exec() with a
+ pcre_extra block in which match_limit is set, and
+ PCRE_EXTRA_MATCH_LIMIT is set in the flags field. If the limit is
exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.
- The match_limit_recursion field is similar to match_limit, but instead
+ The match_limit_recursion field is similar to match_limit, but instead
of limiting the total number of times that match() is called, it limits
- the depth of recursion. The recursion depth is a smaller number than
- the total number of calls, because not all calls to match() are recur-
+ the depth of recursion. The recursion depth is a smaller number than
+ the total number of calls, because not all calls to match() are recur-
sive. This limit is of use only if it is set smaller than match_limit.
- Limiting the recursion depth limits the amount of stack that can be
+ Limiting the recursion depth limits the amount of stack that can be
used, or, when PCRE has been compiled to use memory on the heap instead
of the stack, the amount of heap memory that can be used.
- The default value for match_limit_recursion can be set when PCRE is
- built; the default default is the same value as the default for
- match_limit. You can override the default by suppling pcre_exec() with
- a pcre_extra block in which match_limit_recursion is set, and
- PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in the flags field. If the
+ The default value for match_limit_recursion can be set when PCRE is
+ built; the default default is the same value as the default for
+ match_limit. You can override the default by suppling pcre_exec() with
+ a pcre_extra block in which match_limit_recursion is set, and
+ PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in the flags field. If the
limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT.
- The pcre_callout field is used in conjunction with the "callout" fea-
+ The pcre_callout field is used in conjunction with the "callout" fea-
ture, which is described in the pcrecallout documentation.
- The tables field is used to pass a character tables pointer to
- pcre_exec(); this overrides the value that is stored with the compiled
- pattern. A non-NULL value is stored with the compiled pattern only if
- custom tables were supplied to pcre_compile() via its tableptr argu-
+ The tables field is used to pass a character tables pointer to
+ pcre_exec(); this overrides the value that is stored with the compiled
+ pattern. A non-NULL value is stored with the compiled pattern only if
+ custom tables were supplied to pcre_compile() via its tableptr argu-
ment. If NULL is passed to pcre_exec() using this mechanism, it forces
- PCRE's internal tables to be used. This facility is helpful when re-
- using patterns that have been saved after compiling with an external
- set of tables, because the external tables might be at a different
- address when pcre_exec() is called. See the pcreprecompile documenta-
+ PCRE's internal tables to be used. This facility is helpful when re-
+ using patterns that have been saved after compiling with an external
+ set of tables, because the external tables might be at a different
+ address when pcre_exec() is called. See the pcreprecompile documenta-
tion for a discussion of saving compiled patterns for later use.
Option bits for pcre_exec()
- The unused bits of the options argument for pcre_exec() must be zero.
- The only bits that may be set are PCRE_ANCHORED, PCRE_NEWLINE_xxx,
+ The unused bits of the options argument for pcre_exec() must be zero.
+ The only bits that may be set are PCRE_ANCHORED, PCRE_NEWLINE_xxx,
PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK and
PCRE_PARTIAL.
PCRE_ANCHORED
- The PCRE_ANCHORED option limits pcre_exec() to matching at the first
- matching position. If a pattern was compiled with PCRE_ANCHORED, or
- turned out to be anchored by virtue of its contents, it cannot be made
+ The PCRE_ANCHORED option limits pcre_exec() to matching at the first
+ matching position. If a pattern was compiled with PCRE_ANCHORED, or
+ turned out to be anchored by virtue of its contents, it cannot be made
unachored at matching time.
PCRE_NEWLINE_CR
PCRE_NEWLINE_LF
PCRE_NEWLINE_CRLF
+ PCRE_NEWLINE_ANYCRLF
PCRE_NEWLINE_ANY
- These options override the newline definition that was chosen or
- defaulted when the pattern was compiled. For details, see the descrip-
- tion of pcre_compile() above. During matching, the newline choice
- affects the behaviour of the dot, circumflex, and dollar metacharac-
- ters. It may also alter the way the match position is advanced after a
- match failure for an unanchored pattern. When PCRE_NEWLINE_CRLF or
- PCRE_NEWLINE_ANY is set, and a match attempt fails when the current
- position is at a CRLF sequence, the match position is advanced by two
- characters instead of one, in other words, to after the CRLF.
+ These options override the newline definition that was chosen or
+ defaulted when the pattern was compiled. For details, see the descrip-
+ tion of pcre_compile() above. During matching, the newline choice
+ affects the behaviour of the dot, circumflex, and dollar metacharac-
+ ters. It may also alter the way the match position is advanced after a
+ match failure for an unanchored pattern. When PCRE_NEWLINE_CRLF,
+ PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is set, and a match attempt
+ fails when the current position is at a CRLF sequence, the match posi-
+ tion is advanced by two characters instead of one, in other words, to
+ after the CRLF.
PCRE_NOTBOL
@@ -2109,7 +2197,8 @@ EXTRACTING CAPTURED SUBSTRINGS BY NAME
These functions call pcre_get_stringnumber(), and if it succeeds, they
then call pcre_copy_substring() or pcre_get_substring(), as appropri-
- ate.
+ ate. NOTE: If PCRE_DUPNAMES is set and there are duplicate names, the
+ behaviour may not be what you want (see the next section).
DUPLICATE SUBPATTERN NAMES
@@ -2117,45 +2206,45 @@ DUPLICATE SUBPATTERN NAMES
int pcre_get_stringtable_entries(const pcre *code,
const char *name, char **first, char **last);
- When a pattern is compiled with the PCRE_DUPNAMES option, names for
- subpatterns are not required to be unique. Normally, patterns with
- duplicate names are such that in any one match, only one of the named
- subpatterns participates. An example is shown in the pcrepattern docu-
+ When a pattern is compiled with the PCRE_DUPNAMES option, names for
+ subpatterns are not required to be unique. Normally, patterns with
+ duplicate names are such that in any one match, only one of the named
+ subpatterns participates. An example is shown in the pcrepattern docu-
mentation. When duplicates are present, pcre_copy_named_substring() and
- pcre_get_named_substring() return the first substring corresponding to
- the given name that is set. If none are set, an empty string is
+ pcre_get_named_substring() return the first substring corresponding to
+ the given name that is set. If none are set, an empty string is
returned. The pcre_get_stringnumber() function returns one of the num-
- bers that are associated with the name, but it is not defined which it
+ bers that are associated with the name, but it is not defined which it
is.
- If you want to get full details of all captured substrings for a given
- name, you must use the pcre_get_stringtable_entries() function. The
+ If you want to get full details of all captured substrings for a given
+ name, you must use the pcre_get_stringtable_entries() function. The
first argument is the compiled pattern, and the second is the name. The
- third and fourth are pointers to variables which are updated by the
+ third and fourth are pointers to variables which are updated by the
function. After it has run, they point to the first and last entries in
- the name-to-number table for the given name. The function itself
- returns the length of each entry, or PCRE_ERROR_NOSUBSTRING (-7) if
- there are none. The format of the table is described above in the sec-
- tion entitled Information about a pattern. Given all the relevant
- entries for the name, you can extract each of their numbers, and hence
+ the name-to-number table for the given name. The function itself
+ returns the length of each entry, or PCRE_ERROR_NOSUBSTRING (-7) if
+ there are none. The format of the table is described above in the sec-
+ tion entitled Information about a pattern. Given all the relevant
+ entries for the name, you can extract each of their numbers, and hence
the captured data, if any.
FINDING ALL POSSIBLE MATCHES
- The traditional matching function uses a similar algorithm to Perl,
+ The traditional matching function uses a similar algorithm to Perl,
which stops when it finds the first match, starting at a given point in
- the subject. If you want to find all possible matches, or the longest
- possible match, consider using the alternative matching function (see
- below) instead. If you cannot use the alternative function, but still
- need to find all possible matches, you can kludge it up by making use
+ the subject. If you want to find all possible matches, or the longest
+ possible match, consider using the alternative matching function (see
+ below) instead. If you cannot use the alternative function, but still
+ need to find all possible matches, you can kludge it up by making use
of the callout facility, which is described in the pcrecallout documen-
tation.
What you have to do is to insert a callout right at the end of the pat-
- tern. When your callout function is called, extract and save the cur-
- rent matched substring. Then return 1, which forces pcre_exec() to
- backtrack and try other alternatives. Ultimately, when it runs out of
+ tern. When your callout function is called, extract and save the cur-
+ rent matched substring. Then return 1, which forces pcre_exec() to
+ backtrack and try other alternatives. Ultimately, when it runs out of
matches, pcre_exec() will yield PCRE_ERROR_NOMATCH.
@@ -2166,25 +2255,25 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
int options, int *ovector, int ovecsize,
int *workspace, int wscount);
- The function pcre_dfa_exec() is called to match a subject string
- against a compiled pattern, using a matching algorithm that scans the
- subject string just once, and does not backtrack. This has different
- characteristics to the normal algorithm, and is not compatible with
- Perl. Some of the features of PCRE patterns are not supported. Never-
- theless, there are times when this kind of matching can be useful. For
+ The function pcre_dfa_exec() is called to match a subject string
+ against a compiled pattern, using a matching algorithm that scans the
+ subject string just once, and does not backtrack. This has different
+ characteristics to the normal algorithm, and is not compatible with
+ Perl. Some of the features of PCRE patterns are not supported. Never-
+ theless, there are times when this kind of matching can be useful. For
a discussion of the two matching algorithms, see the pcrematching docu-
mentation.
- The arguments for the pcre_dfa_exec() function are the same as for
+ The arguments for the pcre_dfa_exec() function are the same as for
pcre_exec(), plus two extras. The ovector argument is used in a differ-
- ent way, and this is described below. The other common arguments are
- used in the same way as for pcre_exec(), so their description is not
+ ent way, and this is described below. The other common arguments are
+ used in the same way as for pcre_exec(), so their description is not
repeated here.
- The two additional arguments provide workspace for the function. The
- workspace vector should contain at least 20 elements. It is used for
+ The two additional arguments provide workspace for the function. The
+ workspace vector should contain at least 20 elements. It is used for
keeping track of multiple paths through the pattern tree. More
- workspace will be needed for patterns and subjects where there are a
+ workspace will be needed for patterns and subjects where there are a
lot of potential matches.
Here is an example of a simple call to pcre_dfa_exec():
@@ -2206,47 +2295,47 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
Option bits for pcre_dfa_exec()
- The unused bits of the options argument for pcre_dfa_exec() must be
- zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NEW-
- LINE_xxx, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK,
+ The unused bits of the options argument for pcre_dfa_exec() must be
+ zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NEW-
+ LINE_xxx, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK,
PCRE_PARTIAL, PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last
three of these are the same as for pcre_exec(), so their description is
not repeated here.
PCRE_PARTIAL
- This has the same general effect as it does for pcre_exec(), but the
- details are slightly different. When PCRE_PARTIAL is set for
- pcre_dfa_exec(), the return code PCRE_ERROR_NOMATCH is converted into
- PCRE_ERROR_PARTIAL if the end of the subject is reached, there have
+ This has the same general effect as it does for pcre_exec(), but the
+ details are slightly different. When PCRE_PARTIAL is set for
+ pcre_dfa_exec(), the return code PCRE_ERROR_NOMATCH is converted into
+ PCRE_ERROR_PARTIAL if the end of the subject is reached, there have
been no complete matches, but there is still at least one matching pos-
- sibility. The portion of the string that provided the partial match is
+ sibility. The portion of the string that provided the partial match is
set as the first matching string.
PCRE_DFA_SHORTEST
- Setting the PCRE_DFA_SHORTEST option causes the matching algorithm to
+ Setting the PCRE_DFA_SHORTEST option causes the matching algorithm to
stop as soon as it has found one match. Because of the way the alterna-
- tive algorithm works, this is necessarily the shortest possible match
+ tive algorithm works, this is necessarily the shortest possible match
at the first possible matching point in the subject string.
PCRE_DFA_RESTART
- When pcre_dfa_exec() is called with the PCRE_PARTIAL option, and
- returns a partial match, it is possible to call it again, with addi-
- tional subject characters, and have it continue with the same match.
- The PCRE_DFA_RESTART option requests this action; when it is set, the
- workspace and wscount options must reference the same vector as before
- because data about the match so far is left in them after a partial
- match. There is more discussion of this facility in the pcrepartial
+ When pcre_dfa_exec() is called with the PCRE_PARTIAL option, and
+ returns a partial match, it is possible to call it again, with addi-
+ tional subject characters, and have it continue with the same match.
+ The PCRE_DFA_RESTART option requests this action; when it is set, the
+ workspace and wscount options must reference the same vector as before
+ because data about the match so far is left in them after a partial
+ match. There is more discussion of this facility in the pcrepartial
documentation.
Successful returns from pcre_dfa_exec()
- When pcre_dfa_exec() succeeds, it may have matched more than one sub-
+ When pcre_dfa_exec() succeeds, it may have matched more than one sub-
string in the subject. Note, however, that all the matches from one run
- of the function start at the same point in the subject. The shorter
- matches are all initial substrings of the longer matches. For example,
+ of the function start at the same point in the subject. The shorter
+ matches are all initial substrings of the longer matches. For example,
if the pattern
<.*>
@@ -2261,65 +2350,75 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
<something> <something else>
<something> <something else> <something further>
- On success, the yield of the function is a number greater than zero,
- which is the number of matched substrings. The substrings themselves
- are returned in ovector. Each string uses two elements; the first is
- the offset to the start, and the second is the offset to the end. In
- fact, all the strings have the same start offset. (Space could have
- been saved by giving this only once, but it was decided to retain some
- compatibility with the way pcre_exec() returns data, even though the
+ On success, the yield of the function is a number greater than zero,
+ which is the number of matched substrings. The substrings themselves
+ are returned in ovector. Each string uses two elements; the first is
+ the offset to the start, and the second is the offset to the end. In
+ fact, all the strings have the same start offset. (Space could have
+ been saved by giving this only once, but it was decided to retain some
+ compatibility with the way pcre_exec() returns data, even though the
meaning of the strings is different.)
The strings are returned in reverse order of length; that is, the long-
- est matching string is given first. If there were too many matches to
- fit into ovector, the yield of the function is zero, and the vector is
+ est matching string is given first. If there were too many matches to
+ fit into ovector, the yield of the function is zero, and the vector is
filled with the longest matches.
Error returns from pcre_dfa_exec()
- The pcre_dfa_exec() function returns a negative number when it fails.
- Many of the errors are the same as for pcre_exec(), and these are
- described above. There are in addition the following errors that are
+ The pcre_dfa_exec() function returns a negative number when it fails.
+ Many of the errors are the same as for pcre_exec(), and these are
+ described above. There are in addition the following errors that are
specific to pcre_dfa_exec():
PCRE_ERROR_DFA_UITEM (-16)
- This return is given if pcre_dfa_exec() encounters an item in the pat-
- tern that it does not support, for instance, the use of \C or a back
+ This return is given if pcre_dfa_exec() encounters an item in the pat-
+ tern that it does not support, for instance, the use of \C or a back
reference.
PCRE_ERROR_DFA_UCOND (-17)
- This return is given if pcre_dfa_exec() encounters a condition item
- that uses a back reference for the condition, or a test for recursion
+ This return is given if pcre_dfa_exec() encounters a condition item
+ that uses a back reference for the condition, or a test for recursion
in a specific group. These are not supported.
PCRE_ERROR_DFA_UMLIMIT (-18)
- This return is given if pcre_dfa_exec() is called with an extra block
+ This return is given if pcre_dfa_exec() is called with an extra block
that contains a setting of the match_limit field. This is not supported
(it is meaningless).
PCRE_ERROR_DFA_WSSIZE (-19)
- This return is given if pcre_dfa_exec() runs out of space in the
+ This return is given if pcre_dfa_exec() runs out of space in the
workspace vector.
PCRE_ERROR_DFA_RECURSE (-20)
- When a recursive subpattern is processed, the matching function calls
- itself recursively, using private vectors for ovector and workspace.
- This error is given if the output vector is not large enough. This
+ When a recursive subpattern is processed, the matching function calls
+ itself recursively, using private vectors for ovector and workspace.
+ This error is given if the output vector is not large enough. This
should be extremely rare, as a vector of size 1000 is used.
SEE ALSO
- pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3), pcrepar-
- tial(3), pcreposix(3), pcreprecompile(3), pcresample(3), pcrestack(3).
+ pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3), pcrepar-
+ tial(3), pcreposix(3), pcreprecompile(3), pcresample(3), pcrestack(3).
+
-Last updated: 30 November 2006
-Copyright (c) 1997-2006 University of Cambridge.
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 13 June 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -2346,7 +2445,7 @@ PCRE CALLOUTS
default value is zero. For example, this pattern has two callout
points:
- (?C1)eabc(?C2)def
+ (?C1)abc(?C2)def
If the PCRE_AUTO_CALLOUT option bit is set when pcre_compile() is
called, PCRE automatically inserts callouts, all with number 255,
@@ -2421,10 +2520,12 @@ THE CALLOUT INTERFACE
The subject and subject_length fields contain copies of the values that
were passed to pcre_exec().
- The start_match field contains the offset within the subject at which
- the current match attempt started. If the pattern is not anchored, the
- callout function may be called several times from the same point in the
- pattern for different starting points in the subject.
+ The start_match field normally contains the offset within the subject
+ at which the current match attempt started. However, if the escape
+ sequence \K has been encountered, this value is changed to reflect the
+ modified starting point. If the pattern is not anchored, the callout
+ function may be called several times from the same point in the pattern
+ for different starting points in the subject.
The current_position field contains the offset within the subject of
the current match pointer.
@@ -2477,8 +2578,18 @@ RETURN VALUES
reserved for use by callout functions; it will never be used by PCRE
itself.
-Last updated: 28 February 2005
-Copyright (c) 1997-2005 University of Cambridge.
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 29 May 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -2493,8 +2604,8 @@ DIFFERENCES BETWEEN PCRE AND PERL
This document describes the differences in the ways that PCRE and Perl
handle regular expressions. The differences described here are mainly
- with respect to Perl 5.8, though PCRE version 7.0 contains some fea-
- tures that are expected to be in the forthcoming Perl 5.10.
+ with respect to Perl 5.8, though PCRE versions 7.0 and later contain
+ some features that are expected to be in the forthcoming Perl 5.10.
1. PCRE has only a subset of Perl's UTF-8 and Unicode support. Details
of what it does have are given in the section on UTF-8 support in the
@@ -2572,8 +2683,8 @@ DIFFERENCES BETWEEN PCRE AND PERL
meta-character matches only at the very end of the string.
(c) If PCRE_EXTRA is set, a backslash followed by a letter with no spe-
- cial meaning is faulted. Otherwise, like Perl, the backslash is
- ignored. (Perl can be made to issue a warning.)
+ cial meaning is faulted. Otherwise, like Perl, the backslash is quietly
+ ignored. (Perl can be made to issue a warning.)
(d) If PCRE_UNGREEDY is set, the greediness of the repetition quanti-
fiers is inverted, that is, by default they are not greedy, but if fol-
@@ -2595,8 +2706,18 @@ DIFFERENCES BETWEEN PCRE AND PERL
(j) The alternative matching function (pcre_dfa_exec()) matches in a
different way and is not Perl-compatible.
-Last updated: 28 November 2006
-Copyright (c) 1997-2006 University of Cambridge.
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 13 June 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -2628,38 +2749,39 @@ PCRE REGULAR EXPRESSION DETAILS
ported by PCRE when its main matching function, pcre_exec(), is used.
From release 6.0, PCRE offers a second matching function,
pcre_dfa_exec(), which matches using a different algorithm that is not
- Perl-compatible. The advantages and disadvantages of the alternative
- function, and how it differs from the normal function, are discussed in
- the pcrematching page.
+ Perl-compatible. Some of the features discussed below are not available
+ when pcre_dfa_exec() is used. The advantages and disadvantages of the
+ alternative function, and how it differs from the normal function, are
+ discussed in the pcrematching page.
CHARACTERS AND METACHARACTERS
- A regular expression is a pattern that is matched against a subject
- string from left to right. Most characters stand for themselves in a
- pattern, and match the corresponding characters in the subject. As a
+ A regular expression is a pattern that is matched against a subject
+ string from left to right. Most characters stand for themselves in a
+ pattern, and match the corresponding characters in the subject. As a
trivial example, the pattern
The quick brown fox
matches a portion of a subject string that is identical to itself. When
- caseless matching is specified (the PCRE_CASELESS option), letters are
- matched independently of case. In UTF-8 mode, PCRE always understands
- the concept of case for characters whose values are less than 128, so
- caseless matching is always possible. For characters with higher val-
- ues, the concept of case is supported if PCRE is compiled with Unicode
- property support, but not otherwise. If you want to use caseless
- matching for characters 128 and above, you must ensure that PCRE is
+ caseless matching is specified (the PCRE_CASELESS option), letters are
+ matched independently of case. In UTF-8 mode, PCRE always understands
+ the concept of case for characters whose values are less than 128, so
+ caseless matching is always possible. For characters with higher val-
+ ues, the concept of case is supported if PCRE is compiled with Unicode
+ property support, but not otherwise. If you want to use caseless
+ matching for characters 128 and above, you must ensure that PCRE is
compiled with Unicode property support as well as with UTF-8 support.
- The power of regular expressions comes from the ability to include
- alternatives and repetitions in the pattern. These are encoded in the
+ The power of regular expressions comes from the ability to include
+ alternatives and repetitions in the pattern. These are encoded in the
pattern by the use of metacharacters, which do not stand for themselves
but instead are interpreted in some special way.
- There are two different sets of metacharacters: those that are recog-
- nized anywhere in the pattern except within square brackets, and those
- that are recognized within square brackets. Outside square brackets,
+ There are two different sets of metacharacters: those that are recog-
+ nized anywhere in the pattern except within square brackets, and those
+ that are recognized within square brackets. Outside square brackets,
the metacharacters are as follows:
\ general escape character with several uses
@@ -2678,7 +2800,7 @@ CHARACTERS AND METACHARACTERS
also "possessive quantifier"
{ start min/max quantifier
- Part of a pattern that is in square brackets is called a "character
+ Part of a pattern that is in square brackets is called a "character
class". In a character class the only metacharacters are:
\ general escape character
@@ -2688,33 +2810,33 @@ CHARACTERS AND METACHARACTERS
syntax)
] terminates the character class
- The following sections describe the use of each of the metacharacters.
+ The following sections describe the use of each of the metacharacters.
BACKSLASH
The backslash character has several uses. Firstly, if it is followed by
- a non-alphanumeric character, it takes away any special meaning that
- character may have. This use of backslash as an escape character
+ a non-alphanumeric character, it takes away any special meaning that
+ character may have. This use of backslash as an escape character
applies both inside and outside character classes.
- For example, if you want to match a * character, you write \* in the
- pattern. This escaping action applies whether or not the following
- character would otherwise be interpreted as a metacharacter, so it is
- always safe to precede a non-alphanumeric with backslash to specify
- that it stands for itself. In particular, if you want to match a back-
+ For example, if you want to match a * character, you write \* in the
+ pattern. This escaping action applies whether or not the following
+ character would otherwise be interpreted as a metacharacter, so it is
+ always safe to precede a non-alphanumeric with backslash to specify
+ that it stands for itself. In particular, if you want to match a back-
slash, you write \\.
- If a pattern is compiled with the PCRE_EXTENDED option, whitespace in
- the pattern (other than in a character class) and characters between a
+ If a pattern is compiled with the PCRE_EXTENDED option, whitespace in
+ the pattern (other than in a character class) and characters between a
# outside a character class and the next newline are ignored. An escap-
- ing backslash can be used to include a whitespace or # character as
+ ing backslash can be used to include a whitespace or # character as
part of the pattern.
- If you want to remove the special meaning from a sequence of charac-
- ters, you can do so by putting them between \Q and \E. This is differ-
- ent from Perl in that $ and @ are handled as literals in \Q...\E
- sequences in PCRE, whereas in Perl, $ and @ cause variable interpola-
+ If you want to remove the special meaning from a sequence of charac-
+ ters, you can do so by putting them between \Q and \E. This is differ-
+ ent from Perl in that $ and @ are handled as literals in \Q...\E
+ sequences in PCRE, whereas in Perl, $ and @ cause variable interpola-
tion. Note the following examples:
Pattern PCRE matches Perl matches
@@ -2724,16 +2846,16 @@ BACKSLASH
\Qabc\$xyz\E abc\$xyz abc\$xyz
\Qabc\E\$\Qxyz\E abc$xyz abc$xyz
- The \Q...\E sequence is recognized both inside and outside character
+ The \Q...\E sequence is recognized both inside and outside character
classes.
Non-printing characters
A second use of backslash provides a way of encoding non-printing char-
- acters in patterns in a visible manner. There is no restriction on the
- appearance of non-printing characters, apart from the binary zero that
- terminates a pattern, but when a pattern is being prepared by text
- editing, it is usually easier to use one of the following escape
+ acters in patterns in a visible manner. There is no restriction on the
+ appearance of non-printing characters, apart from the binary zero that
+ terminates a pattern, but when a pattern is being prepared by text
+ editing, it is usually easier to use one of the following escape
sequences than the binary character it represents:
\a alarm, that is, the BEL character (hex 07)
@@ -2747,45 +2869,45 @@ BACKSLASH
\xhh character with hex code hh
\x{hhh..} character with hex code hhh..
- The precise effect of \cx is as follows: if x is a lower case letter,
- it is converted to upper case. Then bit 6 of the character (hex 40) is
- inverted. Thus \cz becomes hex 1A, but \c{ becomes hex 3B, while \c;
+ The precise effect of \cx is as follows: if x is a lower case letter,
+ it is converted to upper case. Then bit 6 of the character (hex 40) is
+ inverted. Thus \cz becomes hex 1A, but \c{ becomes hex 3B, while \c;
becomes hex 7B.
- After \x, from zero to two hexadecimal digits are read (letters can be
- in upper or lower case). Any number of hexadecimal digits may appear
- between \x{ and }, but the value of the character code must be less
+ After \x, from zero to two hexadecimal digits are read (letters can be
+ in upper or lower case). Any number of hexadecimal digits may appear
+ between \x{ and }, but the value of the character code must be less
than 256 in non-UTF-8 mode, and less than 2**31 in UTF-8 mode (that is,
- the maximum hexadecimal value is 7FFFFFFF). If characters other than
- hexadecimal digits appear between \x{ and }, or if there is no termi-
- nating }, this form of escape is not recognized. Instead, the initial
+ the maximum hexadecimal value is 7FFFFFFF). If characters other than
+ hexadecimal digits appear between \x{ and }, or if there is no termi-
+ nating }, this form of escape is not recognized. Instead, the initial
\x will be interpreted as a basic hexadecimal escape, with no following
digits, giving a character whose value is zero.
Characters whose value is less than 256 can be defined by either of the
- two syntaxes for \x. There is no difference in the way they are han-
+ two syntaxes for \x. There is no difference in the way they are han-
dled. For example, \xdc is exactly the same as \x{dc}.
- After \0 up to two further octal digits are read. If there are fewer
- than two digits, just those that are present are used. Thus the
+ After \0 up to two further octal digits are read. If there are fewer
+ than two digits, just those that are present are used. Thus the
sequence \0\x\07 specifies two binary zeros followed by a BEL character
- (code value 7). Make sure you supply two digits after the initial zero
+ (code value 7). Make sure you supply two digits after the initial zero
if the pattern character that follows is itself an octal digit.
The handling of a backslash followed by a digit other than 0 is compli-
cated. Outside a character class, PCRE reads it and any following dig-
- its as a decimal number. If the number is less than 10, or if there
+ its as a decimal number. If the number is less than 10, or if there
have been at least that many previous capturing left parentheses in the
- expression, the entire sequence is taken as a back reference. A
- description of how this works is given later, following the discussion
+ expression, the entire sequence is taken as a back reference. A
+ description of how this works is given later, following the discussion
of parenthesized subpatterns.
- Inside a character class, or if the decimal number is greater than 9
- and there have not been that many capturing subpatterns, PCRE re-reads
+ Inside a character class, or if the decimal number is greater than 9
+ and there have not been that many capturing subpatterns, PCRE re-reads
up to three octal digits following the backslash, and uses them to gen-
- erate a data character. Any subsequent digits stand for themselves. In
- non-UTF-8 mode, the value of a character specified in octal must be
- less than \400. In UTF-8 mode, values up to \777 are permitted. For
+ erate a data character. Any subsequent digits stand for themselves. In
+ non-UTF-8 mode, the value of a character specified in octal must be
+ less than \400. In UTF-8 mode, values up to \777 are permitted. For
example:
\040 is another way of writing a space
@@ -2803,22 +2925,22 @@ BACKSLASH
\81 is either a back reference, or a binary zero
followed by the two characters "8" and "1"
- Note that octal values of 100 or greater must not be introduced by a
+ Note that octal values of 100 or greater must not be introduced by a
leading zero, because no more than three octal digits are ever read.
All the sequences that define a single character value can be used both
- inside and outside character classes. In addition, inside a character
- class, the sequence \b is interpreted as the backspace character (hex
- 08), and the sequences \R and \X are interpreted as the characters "R"
- and "X", respectively. Outside a character class, these sequences have
+ inside and outside character classes. In addition, inside a character
+ class, the sequence \b is interpreted as the backspace character (hex
+ 08), and the sequences \R and \X are interpreted as the characters "R"
+ and "X", respectively. Outside a character class, these sequences have
different meanings (see below).
Absolute and relative back references
- The sequence \g followed by a positive or negative number, optionally
- enclosed in braces, is an absolute or relative back reference. Back
- references are discussed later, following the discussion of parenthe-
- sized subpatterns.
+ The sequence \g followed by a positive or negative number, optionally
+ enclosed in braces, is an absolute or relative back reference. A named
+ back reference can be coded as \g{name}. Back references are discussed
+ later, following the discussion of parenthesized subpatterns.
Generic character types
@@ -2827,57 +2949,97 @@ BACKSLASH
\d any decimal digit
\D any character that is not a decimal digit
+ \h any horizontal whitespace character
+ \H any character that is not a horizontal whitespace character
\s any whitespace character
\S any character that is not a whitespace character
+ \v any vertical whitespace character
+ \V any character that is not a vertical whitespace character
\w any "word" character
\W any "non-word" character
Each pair of escape sequences partitions the complete set of characters
- into two disjoint sets. Any given character matches one, and only one,
+ into two disjoint sets. Any given character matches one, and only one,
of each pair.
These character type sequences can appear both inside and outside char-
- acter classes. They each match one character of the appropriate type.
- If the current matching point is at the end of the subject string, all
+ acter classes. They each match one character of the appropriate type.
+ If the current matching point is at the end of the subject string, all
of them fail, since there is no character to match.
- For compatibility with Perl, \s does not match the VT character (code
- 11). This makes it different from the the POSIX "space" class. The \s
- characters are HT (9), LF (10), FF (12), CR (13), and space (32). (If
+ For compatibility with Perl, \s does not match the VT character (code
+ 11). This makes it different from the the POSIX "space" class. The \s
+ characters are HT (9), LF (10), FF (12), CR (13), and space (32). If
"use locale;" is included in a Perl script, \s may match the VT charac-
- ter. In PCRE, it never does.)
+ ter. In PCRE, it never does.
- A "word" character is an underscore or any character less than 256 that
- is a letter or digit. The definition of letters and digits is con-
- trolled by PCRE's low-valued character tables, and may vary if locale-
- specific matching is taking place (see "Locale support" in the pcreapi
- page). For example, in the "fr_FR" (French) locale, some character
- codes greater than 128 are used for accented letters, and these are
- matched by \w.
-
- In UTF-8 mode, characters with values greater than 128 never match \d,
+ In UTF-8 mode, characters with values greater than 128 never match \d,
\s, or \w, and always match \D, \S, and \W. This is true even when Uni-
- code character property support is available. The use of locales with
- Unicode is discouraged.
+ code character property support is available. These sequences retain
+ their original meanings from before UTF-8 support was available, mainly
+ for efficiency reasons.
+
+ The sequences \h, \H, \v, and \V are Perl 5.10 features. In contrast to
+ the other sequences, these do match certain high-valued codepoints in
+ UTF-8 mode. The horizontal space characters are:
+
+ U+0009 Horizontal tab
+ U+0020 Space
+ U+00A0 Non-break space
+ U+1680 Ogham space mark
+ U+180E Mongolian vowel separator
+ U+2000 En quad
+ U+2001 Em quad
+ U+2002 En space
+ U+2003 Em space
+ U+2004 Three-per-em space
+ U+2005 Four-per-em space
+ U+2006 Six-per-em space
+ U+2007 Figure space
+ U+2008 Punctuation space
+ U+2009 Thin space
+ U+200A Hair space
+ U+202F Narrow no-break space
+ U+205F Medium mathematical space
+ U+3000 Ideographic space
+
+ The vertical space characters are:
+
+ U+000A Linefeed
+ U+000B Vertical tab
+ U+000C Formfeed
+ U+000D Carriage return
+ U+0085 Next line
+ U+2028 Line separator
+ U+2029 Paragraph separator
+
+ A "word" character is an underscore or any character less than 256 that
+ is a letter or digit. The definition of letters and digits is con-
+ trolled by PCRE's low-valued character tables, and may vary if locale-
+ specific matching is taking place (see "Locale support" in the pcreapi
+ page). For example, in a French locale such as "fr_FR" in Unix-like
+ systems, or "french" in Windows, some character codes greater than 128
+ are used for accented letters, and these are matched by \w. The use of
+ locales with Unicode is discouraged.
Newline sequences
- Outside a character class, the escape sequence \R matches any Unicode
- newline sequence. This is an extension to Perl. In non-UTF-8 mode \R is
+ Outside a character class, the escape sequence \R matches any Unicode
+ newline sequence. This is a Perl 5.10 feature. In non-UTF-8 mode \R is
equivalent to the following:
(?>\r\n|\n|\x0b|\f|\r|\x85)
- This is an example of an "atomic group", details of which are given
+ This is an example of an "atomic group", details of which are given
below. This particular group matches either the two-character sequence
- CR followed by LF, or one of the single characters LF (linefeed,
+ CR followed by LF, or one of the single characters LF (linefeed,
U+000A), VT (vertical tab, U+000B), FF (formfeed, U+000C), CR (carriage
return, U+000D), or NEL (next line, U+0085). The two-character sequence
is treated as a single unit that cannot be split.
- In UTF-8 mode, two additional characters whose codepoints are greater
+ In UTF-8 mode, two additional characters whose codepoints are greater
than 255 are added: LS (line separator, U+2028) and PS (paragraph sepa-
- rator, U+2029). Unicode character property support is not needed for
+ rator, U+2029). Unicode character property support is not needed for
these characters to be recognized.
Inside a character class, \R matches the letter "R".
@@ -2885,47 +3047,47 @@ BACKSLASH
Unicode character properties
When PCRE is built with Unicode character property support, three addi-
- tional escape sequences to match character properties are available
+ tional escape sequences to match character properties are available
when UTF-8 mode is selected. They are:
\p{xx} a character with the xx property
\P{xx} a character without the xx property
\X an extended Unicode sequence
- The property names represented by xx above are limited to the Unicode
+ The property names represented by xx above are limited to the Unicode
script names, the general category properties, and "Any", which matches
any character (including newline). Other properties such as "InMusical-
- Symbols" are not currently supported by PCRE. Note that \P{Any} does
+ Symbols" are not currently supported by PCRE. Note that \P{Any} does
not match any characters, so always causes a match failure.
Sets of Unicode characters are defined as belonging to certain scripts.
- A character from one of these sets can be matched using a script name.
+ A character from one of these sets can be matched using a script name.
For example:
\p{Greek}
\P{Han}
- Those that are not part of an identified script are lumped together as
+ Those that are not part of an identified script are lumped together as
"Common". The current list of scripts is:
Arabic, Armenian, Balinese, Bengali, Bopomofo, Braille, Buginese,
- Buhid, Canadian_Aboriginal, Cherokee, Common, Coptic, Cuneiform,
+ Buhid, Canadian_Aboriginal, Cherokee, Common, Coptic, Cuneiform,
Cypriot, Cyrillic, Deseret, Devanagari, Ethiopic, Georgian, Glagolitic,
- Gothic, Greek, Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hebrew, Hira-
- gana, Inherited, Kannada, Katakana, Kharoshthi, Khmer, Lao, Latin,
+ Gothic, Greek, Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hebrew, Hira-
+ gana, Inherited, Kannada, Katakana, Kharoshthi, Khmer, Lao, Latin,
Limbu, Linear_B, Malayalam, Mongolian, Myanmar, New_Tai_Lue, Nko,
- Ogham, Old_Italic, Old_Persian, Oriya, Osmanya, Phags_Pa, Phoenician,
+ Ogham, Old_Italic, Old_Persian, Oriya, Osmanya, Phags_Pa, Phoenician,
Runic, Shavian, Sinhala, Syloti_Nagri, Syriac, Tagalog, Tagbanwa,
Tai_Le, Tamil, Telugu, Thaana, Thai, Tibetan, Tifinagh, Ugaritic, Yi.
- Each character has exactly one general category property, specified by
+ Each character has exactly one general category property, specified by
a two-letter abbreviation. For compatibility with Perl, negation can be
- specified by including a circumflex between the opening brace and the
+ specified by including a circumflex between the opening brace and the
property name. For example, \p{^Lu} is the same as \P{Lu}.
If only one letter is specified with \p or \P, it includes all the gen-
- eral category properties that start with that letter. In this case, in
- the absence of negation, the curly brackets in the escape sequence are
+ eral category properties that start with that letter. In this case, in
+ the absence of negation, the curly brackets in the escape sequence are
optional; these two examples have the same effect:
\p{L}
@@ -2977,36 +3139,55 @@ BACKSLASH
Zp Paragraph separator
Zs Space separator
- The special property L& is also supported: it matches a character that
- has the Lu, Ll, or Lt property, in other words, a letter that is not
+ The special property L& is also supported: it matches a character that
+ has the Lu, Ll, or Lt property, in other words, a letter that is not
classified as a modifier or "other".
- The long synonyms for these properties that Perl supports (such as
- \p{Letter}) are not supported by PCRE, nor is it permitted to prefix
+ The long synonyms for these properties that Perl supports (such as
+ \p{Letter}) are not supported by PCRE, nor is it permitted to prefix
any of these properties with "Is".
No character that is in the Unicode table has the Cn (unassigned) prop-
erty. Instead, this property is assumed for any code point that is not
in the Unicode table.
- Specifying caseless matching does not affect these escape sequences.
+ Specifying caseless matching does not affect these escape sequences.
For example, \p{Lu} always matches only upper case letters.
- The \X escape matches any number of Unicode characters that form an
+ The \X escape matches any number of Unicode characters that form an
extended Unicode sequence. \X is equivalent to
(?>\PM\pM*)
- That is, it matches a character without the "mark" property, followed
- by zero or more characters with the "mark" property, and treats the
- sequence as an atomic group (see below). Characters with the "mark"
+ That is, it matches a character without the "mark" property, followed
+ by zero or more characters with the "mark" property, and treats the
+ sequence as an atomic group (see below). Characters with the "mark"
property are typically accents that affect the preceding character.
- Matching characters by Unicode property is not fast, because PCRE has
- to search a structure that contains data for over fifteen thousand
+ Matching characters by Unicode property is not fast, because PCRE has
+ to search a structure that contains data for over fifteen thousand
characters. That is why the traditional escape sequences such as \d and
\w do not use Unicode properties in PCRE.
+ Resetting the match start
+
+ The escape sequence \K, which is a Perl 5.10 feature, causes any previ-
+ ously matched characters not to be included in the final matched
+ sequence. For example, the pattern:
+
+ foo\Kbar
+
+ matches "foobar", but reports that it has matched "bar". This feature
+ is similar to a lookbehind assertion (described below). However, in
+ this case, the part of the subject before the real match does not have
+ to be of fixed length, as lookbehind assertions do. The use of \K does
+ not interfere with the setting of captured substrings. For example,
+ when the pattern
+
+ (foo)\Kbar
+
+ matches "foobar", the first substring is still set to "foo".
+
Simple assertions
The final use of backslash is for certain simple assertions. An asser-
@@ -3222,7 +3403,7 @@ SQUARE BRACKETS AND CHARACTER CLASSES
If a range that includes letters is used when caseless matching is set,
it matches the letters in either case. For example, [W-c] is equivalent
to [][\\^_`wxyzabc], matched caselessly, and in non-UTF-8 mode, if
- character tables for the "fr_FR" locale are in use, [\xc8-\xcb] matches
+ character tables for a French locale are in use, [\xc8-\xcb] matches
accented E characters in both cases. In UTF-8 mode, PCRE supports the
concept of case for characters with values greater than 128 only when
it is compiled with Unicode property support.
@@ -3407,6 +3588,37 @@ SUBPATTERNS
"Saturday".
+DUPLICATE SUBPATTERN NUMBERS
+
+ Perl 5.10 introduced a feature whereby each alternative in a subpattern
+ uses the same numbers for its capturing parentheses. Such a subpattern
+ starts with (?| and is itself a non-capturing subpattern. For example,
+ consider this pattern:
+
+ (?|(Sat)ur|(Sun))day
+
+ Because the two alternatives are inside a (?| group, both sets of cap-
+ turing parentheses are numbered one. Thus, when the pattern matches,
+ you can look at captured substring number one, whichever alternative
+ matched. This construct is useful when you want to capture part, but
+ not all, of one of a number of alternatives. Inside a (?| group, paren-
+ theses are numbered as usual, but the number is reset at the start of
+ each branch. The numbers of any capturing buffers that follow the sub-
+ pattern start after the highest number used in any branch. The follow-
+ ing example is taken from the Perl documentation. The numbers under-
+ neath show in which buffer the captured content will be stored.
+
+ # before ---------------branch-reset----------- after
+ / ( a ) (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
+ # 1 2 2 3 2 3 4
+
+ A backreference or a recursive call to a numbered subpattern always
+ refers to the first one in the pattern with the given number.
+
+ An alternative approach to using this "branch reset" feature is to use
+ duplicate named subpatterns, as described in the next section.
+
+
NAMED SUBPATTERNS
Identifying capturing parentheses by number is simple, but it can be
@@ -3446,14 +3658,16 @@ NAMED SUBPATTERNS
(?<DN>Sat)(?:urday)?
There are five capturing substrings, but only one is ever set after a
- match. The convenience function for extracting the data by name
- returns the substring for the first (and in this example, the only)
- subpattern of that name that matched. This saves searching to find
- which numbered subpattern it was. If you make a reference to a non-
- unique named subpattern from elsewhere in the pattern, the one that
- corresponds to the lowest number is used. For further details of the
- interfaces for handling named subpatterns, see the pcreapi documenta-
- tion.
+ match. (An alternative way of solving this problem is to use a "branch
+ reset" subpattern, as described in the previous section.)
+
+ The convenience function for extracting the data by name returns the
+ substring for the first (and in this example, the only) subpattern of
+ that name that matched. This saves searching to find which numbered
+ subpattern it was. If you make a reference to a non-unique named sub-
+ pattern from elsewhere in the pattern, the one that corresponds to the
+ lowest number is used. For further details of the interfaces for han-
+ dling named subpatterns, see the pcreapi documentation.
REPETITION
@@ -3768,64 +3982,69 @@ BACK REFERENCES
matches "rah rah" and "RAH RAH", but not "RAH rah", even though the
original capturing subpattern is matched caselessly.
- Back references to named subpatterns use the Perl syntax \k<name> or
- \k'name' or the Python syntax (?P=name). We could rewrite the above
- example in either of the following ways:
+ There are several different ways of writing back references to named
+ subpatterns. The .NET syntax \k{name} and the Perl syntax \k<name> or
+ \k'name' are supported, as is the Python syntax (?P=name). Perl 5.10's
+ unified back reference syntax, in which \g can be used for both numeric
+ and named references, is also supported. We could rewrite the above
+ example in any of the following ways:
(?<p1>(?i)rah)\s+\k<p1>
+ (?'p1'(?i)rah)\s+\k{p1}
(?P<p1>(?i)rah)\s+(?P=p1)
+ (?<p1>(?i)rah)\s+\g{p1}
- A subpattern that is referenced by name may appear in the pattern
+ A subpattern that is referenced by name may appear in the pattern
before or after the reference.
- There may be more than one back reference to the same subpattern. If a
- subpattern has not actually been used in a particular match, any back
+ There may be more than one back reference to the same subpattern. If a
+ subpattern has not actually been used in a particular match, any back
references to it always fail. For example, the pattern
(a|(bc))\2
- always fails if it starts to match "a" rather than "bc". Because there
- may be many capturing parentheses in a pattern, all digits following
- the backslash are taken as part of a potential back reference number.
+ always fails if it starts to match "a" rather than "bc". Because there
+ may be many capturing parentheses in a pattern, all digits following
+ the backslash are taken as part of a potential back reference number.
If the pattern continues with a digit character, some delimiter must be
- used to terminate the back reference. If the PCRE_EXTENDED option is
- set, this can be whitespace. Otherwise an empty comment (see "Com-
+ used to terminate the back reference. If the PCRE_EXTENDED option is
+ set, this can be whitespace. Otherwise an empty comment (see "Com-
ments" below) can be used.
- A back reference that occurs inside the parentheses to which it refers
- fails when the subpattern is first used, so, for example, (a\1) never
- matches. However, such references can be useful inside repeated sub-
+ A back reference that occurs inside the parentheses to which it refers
+ fails when the subpattern is first used, so, for example, (a\1) never
+ matches. However, such references can be useful inside repeated sub-
patterns. For example, the pattern
(a|b\1)+
matches any number of "a"s and also "aba", "ababbaa" etc. At each iter-
- ation of the subpattern, the back reference matches the character
- string corresponding to the previous iteration. In order for this to
- work, the pattern must be such that the first iteration does not need
- to match the back reference. This can be done using alternation, as in
+ ation of the subpattern, the back reference matches the character
+ string corresponding to the previous iteration. In order for this to
+ work, the pattern must be such that the first iteration does not need
+ to match the back reference. This can be done using alternation, as in
the example above, or by a quantifier with a minimum of zero.
ASSERTIONS
- An assertion is a test on the characters following or preceding the
- current matching point that does not actually consume any characters.
- The simple assertions coded as \b, \B, \A, \G, \Z, \z, ^ and $ are
+ An assertion is a test on the characters following or preceding the
+ current matching point that does not actually consume any characters.
+ The simple assertions coded as \b, \B, \A, \G, \Z, \z, ^ and $ are
described above.
- More complicated assertions are coded as subpatterns. There are two
- kinds: those that look ahead of the current position in the subject
- string, and those that look behind it. An assertion subpattern is
- matched in the normal way, except that it does not cause the current
+ More complicated assertions are coded as subpatterns. There are two
+ kinds: those that look ahead of the current position in the subject
+ string, and those that look behind it. An assertion subpattern is
+ matched in the normal way, except that it does not cause the current
matching position to be changed.
- Assertion subpatterns are not capturing subpatterns, and may not be
- repeated, because it makes no sense to assert the same thing several
- times. If any kind of assertion contains capturing subpatterns within
- it, these are counted for the purposes of numbering the capturing sub-
+ Assertion subpatterns are not capturing subpatterns, and may not be
+ repeated, because it makes no sense to assert the same thing several
+ times. If any kind of assertion contains capturing subpatterns within
+ it, these are counted for the purposes of numbering the capturing sub-
patterns in the whole pattern. However, substring capturing is carried
- out only for positive assertions, because it does not make sense for
+ out only for positive assertions, because it does not make sense for
negative assertions.
Lookahead assertions
@@ -3835,37 +4054,37 @@ ASSERTIONS
\w+(?=;)
- matches a word followed by a semicolon, but does not include the semi-
+ matches a word followed by a semicolon, but does not include the semi-
colon in the match, and
foo(?!bar)
- matches any occurrence of "foo" that is not followed by "bar". Note
+ matches any occurrence of "foo" that is not followed by "bar". Note
that the apparently similar pattern
(?!foo)bar
- does not find an occurrence of "bar" that is preceded by something
- other than "foo"; it finds any occurrence of "bar" whatsoever, because
+ does not find an occurrence of "bar" that is preceded by something
+ other than "foo"; it finds any occurrence of "bar" whatsoever, because
the assertion (?!foo) is always true when the next three characters are
"bar". A lookbehind assertion is needed to achieve the other effect.
If you want to force a matching failure at some point in a pattern, the
- most convenient way to do it is with (?!) because an empty string
- always matches, so an assertion that requires there not to be an empty
+ most convenient way to do it is with (?!) because an empty string
+ always matches, so an assertion that requires there not to be an empty
string must always fail.
Lookbehind assertions
- Lookbehind assertions start with (?<= for positive assertions and (?<!
+ Lookbehind assertions start with (?<= for positive assertions and (?<!
for negative assertions. For example,
(?<!foo)bar
- does find an occurrence of "bar" that is not preceded by "foo". The
- contents of a lookbehind assertion are restricted such that all the
+ does find an occurrence of "bar" that is not preceded by "foo". The
+ contents of a lookbehind assertion are restricted such that all the
strings it matches must have a fixed length. However, if there are sev-
- eral top-level alternatives, they do not all have to have the same
+ eral top-level alternatives, they do not all have to have the same
fixed length. Thus
(?<=bullock|donkey)
@@ -3874,55 +4093,59 @@ ASSERTIONS
(?<!dogs?|cats?)
- causes an error at compile time. Branches that match different length
- strings are permitted only at the top level of a lookbehind assertion.
- This is an extension compared with Perl (at least for 5.8), which
- requires all branches to match the same length of string. An assertion
+ causes an error at compile time. Branches that match different length
+ strings are permitted only at the top level of a lookbehind assertion.
+ This is an extension compared with Perl (at least for 5.8), which
+ requires all branches to match the same length of string. An assertion
such as
(?<=ab(c|de))
- is not permitted, because its single top-level branch can match two
- different lengths, but it is acceptable if rewritten to use two top-
+ is not permitted, because its single top-level branch can match two
+ different lengths, but it is acceptable if rewritten to use two top-
level branches:
(?<=abc|abde)
- The implementation of lookbehind assertions is, for each alternative,
- to temporarily move the current position back by the fixed length and
+ In some cases, the Perl 5.10 escape sequence \K (see above) can be used
+ instead of a lookbehind assertion; this is not restricted to a fixed-
+ length.
+
+ The implementation of lookbehind assertions is, for each alternative,
+ to temporarily move the current position back by the fixed length and
then try to match. If there are insufficient characters before the cur-
rent position, the assertion fails.
PCRE does not allow the \C escape (which matches a single byte in UTF-8
- mode) to appear in lookbehind assertions, because it makes it impossi-
- ble to calculate the length of the lookbehind. The \X and \R escapes,
+ mode) to appear in lookbehind assertions, because it makes it impossi-
+ ble to calculate the length of the lookbehind. The \X and \R escapes,
which can match different numbers of bytes, are also not permitted.
- Possessive quantifiers can be used in conjunction with lookbehind
- assertions to specify efficient matching at the end of the subject
+ Possessive quantifiers can be used in conjunction with lookbehind
+ assertions to specify efficient matching at the end of the subject
string. Consider a simple pattern such as
abcd$
- when applied to a long string that does not match. Because matching
+ when applied to a long string that does not match. Because matching
proceeds from left to right, PCRE will look for each "a" in the subject
- and then see if what follows matches the rest of the pattern. If the
+ and then see if what follows matches the rest of the pattern. If the
pattern is specified as
^.*abcd$
- the initial .* matches the entire string at first, but when this fails
+ the initial .* matches the entire string at first, but when this fails
(because there is no following "a"), it backtracks to match all but the
- last character, then all but the last two characters, and so on. Once
- again the search for "a" covers the entire string, from right to left,
+ last character, then all but the last two characters, and so on. Once
+ again the search for "a" covers the entire string, from right to left,
so we are no better off. However, if the pattern is written as
^.*+(?<=abcd)
- there can be no backtracking for the .*+ item; it can match only the
- entire string. The subsequent lookbehind assertion does a single test
- on the last four characters. If it fails, the match fails immediately.
- For long strings, this approach makes a significant difference to the
+ there can be no backtracking for the .*+ item; it can match only the
+ entire string. The subsequent lookbehind assertion does a single test
+ on the last four characters. If it fails, the match fails immediately.
+ For long strings, this approach makes a significant difference to the
processing time.
Using multiple assertions
@@ -3931,18 +4154,18 @@ ASSERTIONS
(?<=\d{3})(?<!999)foo
- matches "foo" preceded by three digits that are not "999". Notice that
- each of the assertions is applied independently at the same point in
- the subject string. First there is a check that the previous three
- characters are all digits, and then there is a check that the same
+ matches "foo" preceded by three digits that are not "999". Notice that
+ each of the assertions is applied independently at the same point in
+ the subject string. First there is a check that the previous three
+ characters are all digits, and then there is a check that the same
three characters are not "999". This pattern does not match "foo" pre-
- ceded by six characters, the first of which are digits and the last
- three of which are not "999". For example, it doesn't match "123abc-
+ ceded by six characters, the first of which are digits and the last
+ three of which are not "999". For example, it doesn't match "123abc-
foo". A pattern to do that is
(?<=\d{3}...)(?<!999)foo
- This time the first assertion looks at the preceding six characters,
+ This time the first assertion looks at the preceding six characters,
checking that the first three are digits, and then the second assertion
checks that the preceding three characters are not "999".
@@ -3950,38 +4173,43 @@ ASSERTIONS
(?<=(?<!foo)bar)baz
- matches an occurrence of "baz" that is preceded by "bar" which in turn
+ matches an occurrence of "baz" that is preceded by "bar" which in turn
is not preceded by "foo", while
(?<=\d{3}(?!999)...)foo
- is another pattern that matches "foo" preceded by three digits and any
+ is another pattern that matches "foo" preceded by three digits and any
three characters that are not "999".
CONDITIONAL SUBPATTERNS
- It is possible to cause the matching process to obey a subpattern con-
- ditionally or to choose between two alternative subpatterns, depending
- on the result of an assertion, or whether a previous capturing subpat-
- tern matched or not. The two possible forms of conditional subpattern
+ It is possible to cause the matching process to obey a subpattern con-
+ ditionally or to choose between two alternative subpatterns, depending
+ on the result of an assertion, or whether a previous capturing subpat-
+ tern matched or not. The two possible forms of conditional subpattern
are
(?(condition)yes-pattern)
(?(condition)yes-pattern|no-pattern)
- If the condition is satisfied, the yes-pattern is used; otherwise the
- no-pattern (if present) is used. If there are more than two alterna-
+ If the condition is satisfied, the yes-pattern is used; otherwise the
+ no-pattern (if present) is used. If there are more than two alterna-
tives in the subpattern, a compile-time error occurs.
- There are four kinds of condition: references to subpatterns, refer-
+ There are four kinds of condition: references to subpatterns, refer-
ences to recursion, a pseudo-condition called DEFINE, and assertions.
Checking for a used subpattern by number
- If the text between the parentheses consists of a sequence of digits,
- the condition is true if the capturing subpattern of that number has
- previously matched.
+ If the text between the parentheses consists of a sequence of digits,
+ the condition is true if the capturing subpattern of that number has
+ previously matched. An alternative notation is to precede the digits
+ with a plus or minus sign. In this case, the subpattern number is rela-
+ tive rather than absolute. The most recently opened parentheses can be
+ referenced by (?(-1), the next most recent by (?(-2), and so on. In
+ looping constructs it can also make sense to refer to subsequent groups
+ with constructs such as (?(+2).
Consider the following pattern, which contains non-significant white
space to make it more readable (assume the PCRE_EXTENDED option) and to
@@ -4000,6 +4228,14 @@ CONDITIONAL SUBPATTERNS
other words, this pattern matches a sequence of non-parentheses,
optionally enclosed in parentheses.
+ If you were embedding this pattern in a larger one, you could use a
+ relative reference:
+
+ ...other stuff... ( \( )? [^()]+ (?(-1) \) ) ...
+
+ This makes the fragment independent of the parentheses in the larger
+ pattern.
+
Checking for a used subpattern by name
Perl uses the syntax (?(<name>)...) or (?('name')...) to test for a
@@ -4141,19 +4377,35 @@ RECURSIVE PATTERNS
( \( ( (?>[^()]+) | (?1) )* \) )
We have put the pattern into parentheses, and caused the recursion to
- refer to them instead of the whole pattern. In a larger pattern, keep-
- ing track of parenthesis numbers can be tricky. It may be more conve-
- nient to use named parentheses instead. The Perl syntax for this is
- (?&name); PCRE's earlier syntax (?P>name) is also supported. We could
- rewrite the above example as follows:
+ refer to them instead of the whole pattern.
+
+ In a larger pattern, keeping track of parenthesis numbers can be
+ tricky. This is made easier by the use of relative references. (A Perl
+ 5.10 feature.) Instead of (?1) in the pattern above you can write
+ (?-2) to refer to the second most recently opened parentheses preceding
+ the recursion. In other words, a negative number counts capturing
+ parentheses leftwards from the point at which it is encountered.
+
+ It is also possible to refer to subsequently opened parentheses, by
+ writing references such as (?+2). However, these cannot be recursive
+ because the reference is not inside the parentheses that are refer-
+ enced. They are always "subroutine" calls, as described in the next
+ section.
+
+ An alternative approach is to use named parentheses instead. The Perl
+ syntax for this is (?&name); PCRE's earlier syntax (?P>name) is also
+ supported. We could rewrite the above example as follows:
(?<pn> \( ( (?>[^()]+) | (?&pn) )* \) )
- If there is more than one subpattern with the same name, the earliest
- one is used. This particular example pattern contains nested unlimited
- repeats, and so the use of atomic grouping for matching strings of non-
- parentheses is important when applying the pattern to strings that do
- not match. For example, when this pattern is applied to
+ If there is more than one subpattern with the same name, the earliest
+ one is used.
+
+ This particular example pattern that we have been looking at contains
+ nested unlimited repeats, and so the use of atomic grouping for match-
+ ing strings of non-parentheses is important when applying the pattern
+ to strings that do not match. For example, when this pattern is applied
+ to
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
@@ -4203,8 +4455,14 @@ SUBPATTERNS AS SUBROUTINES
If the syntax for a recursive subpattern reference (either by number or
by name) is used outside the parentheses to which it refers, it oper-
ates like a subroutine in a programming language. The "called" subpat-
- tern may be defined before or after the reference. An earlier example
- pointed out that the pattern
+ tern may be defined before or after the reference. A numbered reference
+ can be absolute or relative, as in these examples:
+
+ (...(absolute)...)...(?2)...
+ (...(relative)...)...(?-1)...
+ (...(?+1)...(relative)...
+
+ An earlier example pointed out that the pattern
(sens|respons)e and \1ibility
@@ -4226,7 +4484,7 @@ SUBPATTERNS AS SUBROUTINES
case-independence are fixed when the subpattern is defined. They cannot
be changed for different calls. For example, consider this pattern:
- (abc)(?i:(?1))
+ (abc)(?i:(?-1))
It matches "abcabc". It does not match "abcABC" because the change of
processing option does not affect the called subpattern.
@@ -4271,8 +4529,18 @@ SEE ALSO
pcreapi(3), pcrecallout(3), pcrematching(3), pcre(3).
-Last updated: 06 December 2006
-Copyright (c) 1997-2006 University of Cambridge.
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 13 June 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -4352,12 +4620,13 @@ RESTRICTED PATTERNS FOR PCRE_PARTIAL
If PCRE_PARTIAL is set for a pattern that does not conform to the
restrictions, pcre_exec() returns the error code PCRE_ERROR_BADPARTIAL
- (-13).
+ (-13). You can use the PCRE_INFO_OKPARTIAL call to pcre_fullinfo() to
+ find out if a compiled pattern can be used for partial matching.
EXAMPLE OF PARTIAL MATCHING USING PCRETEST
- If the escape sequence \P is present in a pcretest data line, the
+ If the escape sequence \P is present in a pcretest data line, the
PCRE_PARTIAL flag is used for the match. Here is a run of pcretest that
uses the date example quoted above:
@@ -4374,13 +4643,13 @@ EXAMPLE OF PARTIAL MATCHING USING PCRETEST
data> j\P
No match
- The first data string is matched completely, so pcretest shows the
- matched substrings. The remaining four strings do not match the com-
- plete pattern, but the first two are partial matches. The same test,
- using pcre_dfa_exec() matching (by means of the \D escape sequence),
+ The first data string is matched completely, so pcretest shows the
+ matched substrings. The remaining four strings do not match the com-
+ plete pattern, but the first two are partial matches. The same test,
+ using pcre_dfa_exec() matching (by means of the \D escape sequence),
produces the following output:
- re> /^?(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)$/
+ re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
data> 25jun04\P\D
0: 25jun04
data> 23dec3\P\D
@@ -4392,58 +4661,57 @@ EXAMPLE OF PARTIAL MATCHING USING PCRETEST
data> j\P\D
No match
- Notice that in this case the portion of the string that was matched is
+ Notice that in this case the portion of the string that was matched is
made available.
MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
When a partial match has been found using pcre_dfa_exec(), it is possi-
- ble to continue the match by providing additional subject data and
- calling pcre_dfa_exec() again with the same compiled regular expres-
+ ble to continue the match by providing additional subject data and
+ calling pcre_dfa_exec() again with the same compiled regular expres-
sion, this time setting the PCRE_DFA_RESTART option. You must also pass
- the same working space as before, because this is where details of the
- previous partial match are stored. Here is an example using pcretest,
+ the same working space as before, because this is where details of the
+ previous partial match are stored. Here is an example using pcretest,
using the \R escape sequence to set the PCRE_DFA_RESTART option (\P and
\D are as above):
- re> /^?(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)$/
+ re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
data> 23ja\P\D
Partial match: 23ja
data> n05\R\D
0: n05
- The first call has "23ja" as the subject, and requests partial match-
- ing; the second call has "n05" as the subject for the continued
- (restarted) match. Notice that when the match is complete, only the
- last part is shown; PCRE does not retain the previously partially-
- matched string. It is up to the calling program to do that if it needs
+ The first call has "23ja" as the subject, and requests partial match-
+ ing; the second call has "n05" as the subject for the continued
+ (restarted) match. Notice that when the match is complete, only the
+ last part is shown; PCRE does not retain the previously partially-
+ matched string. It is up to the calling program to do that if it needs
to.
- You can set PCRE_PARTIAL with PCRE_DFA_RESTART to continue partial
+ You can set PCRE_PARTIAL with PCRE_DFA_RESTART to continue partial
matching over multiple segments. This facility can be used to pass very
- long subject strings to pcre_dfa_exec(). However, some care is needed
+ long subject strings to pcre_dfa_exec(). However, some care is needed
for certain types of pattern.
- 1. If the pattern contains tests for the beginning or end of a line,
- you need to pass the PCRE_NOTBOL or PCRE_NOTEOL options, as appropri-
- ate, when the subject string for any call does not contain the begin-
+ 1. If the pattern contains tests for the beginning or end of a line,
+ you need to pass the PCRE_NOTBOL or PCRE_NOTEOL options, as appropri-
+ ate, when the subject string for any call does not contain the begin-
ning or end of a line.
- 2. If the pattern contains backward assertions (including \b or \B),
- you need to arrange for some overlap in the subject strings to allow
- for this. For example, you could pass the subject in chunks that are
- 500 bytes long, but in a buffer of 700 bytes, with the starting offset
+ 2. If the pattern contains backward assertions (including \b or \B),
+ you need to arrange for some overlap in the subject strings to allow
+ for this. For example, you could pass the subject in chunks that are
+ 500 bytes long, but in a buffer of 700 bytes, with the starting offset
set to 200 and the previous 200 bytes at the start of the buffer.
- 3. Matching a subject string that is split into multiple segments does
- not always produce exactly the same result as matching over one single
- long string. The difference arises when there are multiple matching
- possibilities, because a partial match result is given only when there
- are no completed matches in a call to fBpcre_dfa_exec(). This means
- that as soon as the shortest match has been found, continuation to a
- new subject segment is no longer possible. Consider this pcretest
- example:
+ 3. Matching a subject string that is split into multiple segments does
+ not always produce exactly the same result as matching over one single
+ long string. The difference arises when there are multiple matching
+ possibilities, because a partial match result is given only when there
+ are no completed matches in a call to pcre_dfa_exec(). This means that
+ as soon as the shortest match has been found, continuation to a new
+ subject segment is no longer possible. Consider this pcretest example:
re> /dog(sbody)?/
data> do\P\D
@@ -4454,13 +4722,13 @@ MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
0: dogsbody
1: dog
- The pattern matches the words "dog" or "dogsbody". When the subject is
- presented in several parts ("do" and "gsb" being the first two) the
- match stops when "dog" has been found, and it is not possible to con-
- tinue. On the other hand, if "dogsbody" is presented as a single
+ The pattern matches the words "dog" or "dogsbody". When the subject is
+ presented in several parts ("do" and "gsb" being the first two) the
+ match stops when "dog" has been found, and it is not possible to con-
+ tinue. On the other hand, if "dogsbody" is presented as a single
string, both matches are found.
- Because of this phenomenon, it does not usually make sense to end a
+ Because of this phenomenon, it does not usually make sense to end a
pattern that is going to be matched in this way with a variable repeat.
4. Patterns that contain alternatives at the top level which do not all
@@ -4469,21 +4737,31 @@ MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
1234|3789
- If the first part of the subject is "ABC123", a partial match of the
- first alternative is found at offset 3. There is no partial match for
+ If the first part of the subject is "ABC123", a partial match of the
+ first alternative is found at offset 3. There is no partial match for
the second alternative, because such a match does not start at the same
- point in the subject string. Attempting to continue with the string
+ point in the subject string. Attempting to continue with the string
"789" does not yield a match because only those alternatives that match
- at one point in the subject are remembered. The problem arises because
- the start of the second alternative matches within the first alterna-
+ at one point in the subject are remembered. The problem arises because
+ the start of the second alternative matches within the first alterna-
tive. There is no problem with anchored patterns or patterns such as:
1234|ABCD
where no string can be a partial match for both alternatives.
-Last updated: 30 November 2006
-Copyright (c) 1997-2006 University of Cambridge.
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 04 June 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -4507,7 +4785,9 @@ SAVING AND RE-USING PRECOMPILED PCRE PATTERNS
ent host and run them there. This works even if the new host has the
opposite endianness to the one on which the patterns were compiled.
There may be a small performance penalty, but it should be insignifi-
- cant.
+ cant. However, compiling regular expressions with one version of PCRE
+ for use with a different version is not guaranteed to work and may
+ cause crashes.
SAVING A COMPILED PATTERN
@@ -4590,22 +4870,22 @@ RE-USING A PRECOMPILED PATTERN
COMPATIBILITY WITH DIFFERENT PCRE RELEASES
- The layout of the control block that is at the start of the data that
- makes up a compiled pattern was changed for release 5.0. If you have
- any saved patterns that were compiled with previous releases (not a
- facility that was previously advertised), you will have to recompile
- them for release 5.0 and above.
+ In general, it is safest to recompile all saved patterns when you
+ update to a new PCRE release, though not all updates actually require
+ this. Recompiling is definitely needed for release 7.2.
+
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
- If you have any saved patterns in UTF-8 mode that use \p or \P that
- were compiled with any release up to and including 6.4, you will have
- to recompile them for release 6.5 and above.
- All saved patterns from earlier releases must be recompiled for release
- 7.0 or higher, because there was an internal reorganization at that
- release.
+REVISION
-Last updated: 28 November 2006
-Copyright (c) 1997-2006 University of Cambridge.
+ Last updated: 13 June 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -4744,8 +5024,18 @@ PROCESSING TIME
In many cases, the solution to this kind of performance issue is to use
an atomic group or a possessive quantifier.
-Last updated: 20 September 2006
-Copyright (c) 1997-2006 University of Cambridge.
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 06 March 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -4958,11 +5248,14 @@ MEMORY USAGE
AUTHOR
Philip Hazel
- University Computing Service,
+ University Computing Service
Cambridge CB2 3QH, England.
-Last updated: 16 January 2006
-Copyright (c) 1997-2006 University of Cambridge.
+
+REVISION
+
+ Last updated: 06 March 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -5059,7 +5352,7 @@ MATCHING INTERFACE
return false (because the empty string is not a valid number):
int number;
- pcrecpp::RE::FullMatch("abc", "[a-z]+(\d+)?", &number);
+ pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
The matching interface supports at most 16 arguments per call. If you
need more, consider using the more general interface
@@ -5293,7 +5586,12 @@ REPLACING PARTS OF STRINGS
AUTHOR
The C++ wrapper was contributed by Google Inc.
- Copyright (c) 2006 Google Inc.
+ Copyright (c) 2007 Google Inc.
+
+
+REVISION
+
+ Last updated: 06 March 2007
------------------------------------------------------------------------------
@@ -5321,28 +5619,29 @@ PCRE SAMPLE PROGRAM
bility of matching an empty string. Comments in the code explain what
is going on.
- If PCRE is installed in the standard include and library directories
- for your system, you should be able to compile the demonstration pro-
- gram using this command:
+ The demonstration program is automatically built if you use "./config-
+ ure;make" to build PCRE. Otherwise, if PCRE is installed in the stan-
+ dard include and library directories for your system, you should be
+ able to compile the demonstration program using this command:
gcc -o pcredemo pcredemo.c -lpcre
- If PCRE is installed elsewhere, you may need to add additional options
- to the command line. For example, on a Unix-like system that has PCRE
- installed in /usr/local, you can compile the demonstration program
+ If PCRE is installed elsewhere, you may need to add additional options
+ to the command line. For example, on a Unix-like system that has PCRE
+ installed in /usr/local, you can compile the demonstration program
using a command like this:
gcc -o pcredemo -I/usr/local/include pcredemo.c \
-L/usr/local/lib -lpcre
- Once you have compiled the demonstration program, you can run simple
+ Once you have compiled the demonstration program, you can run simple
tests like this:
./pcredemo 'cat|dog' 'the cat sat on the mat'
./pcredemo -g 'cat|dog' 'the dog sat on the cat'
- Note that there is a much more comprehensive test program, called
- pcretest, which supports many more facilities for testing regular
+ Note that there is a much more comprehensive test program, called
+ pcretest, which supports many more facilities for testing regular
expressions and the PCRE library. The pcredemo program is provided as a
simple coding example.
@@ -5350,18 +5649,28 @@ PCRE SAMPLE PROGRAM
the standard library directory, you may get an error like this when you
try to run pcredemo:
- ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or
+ ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or
directory
- This is caused by the way shared library support works on those sys-
+ This is caused by the way shared library support works on those sys-
tems. You need to add
-R/usr/local/lib
(for example) to the compile command to get round this problem.
-Last updated: 09 September 2004
-Copyright (c) 1997-2004 University of Cambridge.
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 13 June 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
PCRESTACK(3) PCRESTACK(3)
@@ -5414,7 +5723,7 @@ PCRE DISCUSSION OF STACK USAGE
ter. For a long string, a lot of stack is required. Consider now this
rewritten pattern, which matches exactly the same strings:
- ([^<]++|<(?!inet))
+ ([^<]++|<(?!inet))+
This uses very much less stack, because runs of characters that do not
contain "<" are "swallowed" in one item inside the parentheses. Recur-
@@ -5430,17 +5739,24 @@ PCRE DISCUSSION OF STACK USAGE
In environments where stack memory is constrained, you might want to
compile PCRE to use heap memory instead of stack for remembering back-
up points. This makes it run a lot more slowly, however. Details of how
- to do this are given in the pcrebuild documentation.
-
- In Unix-like environments, there is not often a problem with the stack
- unless very long strings are involved, though the default limit on
- stack size varies from system to system. Values from 8Mb to 64Mb are
+ to do this are given in the pcrebuild documentation. When built in this
+ way, instead of using the stack, PCRE obtains and frees memory by call-
+ ing the functions that are pointed to by the pcre_stack_malloc and
+ pcre_stack_free variables. By default, these point to malloc() and
+ free(), but you can replace the pointers to cause PCRE to use your own
+ functions. Since the block sizes are always the same, and are always
+ freed in reverse order, it may be possible to implement customized mem-
+ ory handlers that are more efficient than the standard functions.
+
+ In Unix-like environments, there is not often a problem with the stack
+ unless very long strings are involved, though the default limit on
+ stack size varies from system to system. Values from 8Mb to 64Mb are
common. You can find your default limit by running the command:
ulimit -s
- Unfortunately, the effect of running out of stack is often SIGSEGV,
- though sometimes a more explicit error message is given. You can nor-
+ Unfortunately, the effect of running out of stack is often SIGSEGV,
+ though sometimes a more explicit error message is given. You can nor-
mally increase the limit on stack size by code such as this:
struct rlimit rlim;
@@ -5448,26 +5764,36 @@ PCRE DISCUSSION OF STACK USAGE
rlim.rlim_cur = 100*1024*1024;
setrlimit(RLIMIT_STACK, &rlim);
- This reads the current limits (soft and hard) using getrlimit(), then
- attempts to increase the soft limit to 100Mb using setrlimit(). You
+ This reads the current limits (soft and hard) using getrlimit(), then
+ attempts to increase the soft limit to 100Mb using setrlimit(). You
must do this before calling pcre_exec().
- PCRE has an internal counter that can be used to limit the depth of
- recursion, and thus cause pcre_exec() to give an error code before it
- runs out of stack. By default, the limit is very large, and unlikely
- ever to operate. It can be changed when PCRE is built, and it can also
+ PCRE has an internal counter that can be used to limit the depth of
+ recursion, and thus cause pcre_exec() to give an error code before it
+ runs out of stack. By default, the limit is very large, and unlikely
+ ever to operate. It can be changed when PCRE is built, and it can also
be set when pcre_exec() is called. For details of these interfaces, see
the pcrebuild and pcreapi documentation.
As a very rough rule of thumb, you should reckon on about 500 bytes per
- recursion. Thus, if you want to limit your stack usage to 8Mb, you
- should set the limit at 16000 recursions. A 64Mb stack, on the other
- hand, can support around 128000 recursions. The pcretest test program
+ recursion. Thus, if you want to limit your stack usage to 8Mb, you
+ should set the limit at 16000 recursions. A 64Mb stack, on the other
+ hand, can support around 128000 recursions. The pcretest test program
has a command line option (-S) that can be used to increase the size of
its stack.
-Last updated: 14 September 2006
-Copyright (c) 1997-2006 University of Cambridge.
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 05 June 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
diff --git a/ext/pcre/pcrelib/libpcre.def b/ext/pcre/pcrelib/libpcre.def
deleted file mode 100644
index 01db4bd22c..0000000000
--- a/ext/pcre/pcrelib/libpcre.def
+++ /dev/null
@@ -1,20 +0,0 @@
-LIBRARY libpcre
-EXPORTS
-pcre_malloc
-pcre_free
-pcre_config
-pcre_callout
-pcre_compile
-pcre_copy_substring
-pcre_dfa_exec
-pcre_exec
-pcre_get_substring
-pcre_get_stringnumber
-pcre_get_substring_list
-pcre_free_substring
-pcre_free_substring_list
-pcre_info
-pcre_fullinfo
-pcre_maketables
-pcre_study
-pcre_version
diff --git a/ext/pcre/pcrelib/libpcreposix.def b/ext/pcre/pcrelib/libpcreposix.def
deleted file mode 100644
index 5f30247969..0000000000
--- a/ext/pcre/pcrelib/libpcreposix.def
+++ /dev/null
@@ -1,25 +0,0 @@
-LIBRARY libpcreposix
-EXPORTS
-pcre_malloc
-pcre_free
-pcre_config
-pcre_callout
-pcre_compile
-pcre_copy_substring
-pcre_dfa_exec
-pcre_exec
-pcre_get_substring
-pcre_get_stringnumber
-pcre_get_substring_list
-pcre_free_substring
-pcre_free_substring_list
-pcre_info
-pcre_fullinfo
-pcre_maketables
-pcre_study
-pcre_version
-
-regcomp
-regexec
-regerror
-regfree
diff --git a/ext/pcre/pcrelib/pcre.def b/ext/pcre/pcrelib/pcre.def
deleted file mode 100644
index ec2c7b395b..0000000000
--- a/ext/pcre/pcrelib/pcre.def
+++ /dev/null
@@ -1,29 +0,0 @@
-EXPORTS
-
-pcre_malloc DATA
-pcre_free DATA
-
-pcre_compile
-pcre_compile2
-pcre_config
-pcre_copy_named_substring
-pcre_copy_substring
-pcre_dfa_exec
-pcre_exec
-pcre_free_substring
-pcre_free_substring_list
-pcre_fullinfo
-pcre_get_named_substring
-pcre_get_stringnumber
-pcre_get_substring
-pcre_get_substring_list
-pcre_info
-pcre_maketables
-pcre_refcount
-pcre_study
-pcre_version
-
-regcomp
-regexec
-regerror
-regfree
diff --git a/ext/pcre/pcrelib/pcre.h b/ext/pcre/pcrelib/pcre.h
index c1961e597c..924a817bbf 100644
--- a/ext/pcre/pcrelib/pcre.h
+++ b/ext/pcre/pcrelib/pcre.h
@@ -5,7 +5,7 @@
/* This is the public header file for the PCRE library, to be #included by
applications that call the PCRE functions.
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -39,48 +39,33 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef _PCRE_H
#define _PCRE_H
-#include "php_compat.h"
-
/* The current PCRE version information. */
-/* NOTES FOR FUTURE MAINTAINERS: Do not use numbers with leading zeros, because
-they may be treated as octal constants. The PCRE_PRERELEASE feature is for
-identifying release candidates. It might be defined as -RC2, for example. In
-real releases, it should be defined empty. Do not change the alignment of these
-statments. The code in ./configure greps out the version numbers by using "cut"
-to get values from column 29 onwards. These are substituted into pcre-config
-and libpcre.pc. The values are not put into configure.ac and substituted here
-(which would simplify this issue) because that makes life harder for those who
-cannot run ./configure. As it now stands, this file need not be edited in that
-circumstance. */
-
#define PCRE_MAJOR 7
-#define PCRE_MINOR 0
-#define PCRE_PRERELEASE
-#define PCRE_DATE 18-Dec-2006
+#define PCRE_MINOR 2
+#define PCRE_PRERELEASE -RC3
+#define PCRE_DATE 2007-06-13
-/* Win32 uses DLL by default; it needs special stuff for exported functions
-when building PCRE. */
+/* When an application links to a PCRE DLL in Windows, the symbols that are
+imported have to be identified as such. When building PCRE, the appropriate
+export setting is defined in pcre_internal.h, which includes this file. So we
+don't change an existing definition of PCRE_EXP_DECL. */
-#ifdef _WIN32
-# ifdef PCRE_DEFINITION
-# ifdef DLL_EXPORT
-# define PCRE_DATA_SCOPE __declspec(dllexport)
-# endif
-# else
+#ifndef PCRE_EXP_DECL
+# ifdef _WIN32
# ifndef PCRE_STATIC
-# define PCRE_DATA_SCOPE extern __declspec(dllimport)
+# define PCRE_EXP_DECL extern __declspec(dllimport)
# endif
# endif
#endif
-/* Otherwise, we use the standard "extern". */
+/* By default, we use the standard "extern" declarations. */
-#ifndef PCRE_DATA_SCOPE
+#ifndef PCRE_EXP_DECL
# ifdef __cplusplus
-# define PCRE_DATA_SCOPE extern "C"
+# define PCRE_EXP_DECL extern "C"
# else
-# define PCRE_DATA_SCOPE extern
+# define PCRE_EXP_DECL extern
# endif
#endif
@@ -121,6 +106,7 @@ extern "C" {
#define PCRE_NEWLINE_LF 0x00200000
#define PCRE_NEWLINE_CRLF 0x00300000
#define PCRE_NEWLINE_ANY 0x00400000
+#define PCRE_NEWLINE_ANYCRLF 0x00500000
/* Exec-time and get/set-time error codes */
@@ -164,6 +150,8 @@ extern "C" {
#define PCRE_INFO_NAMETABLE 9
#define PCRE_INFO_STUDYSIZE 10
#define PCRE_INFO_DEFAULT_TABLES 11
+#define PCRE_INFO_OKPARTIAL 12
+#define PCRE_INFO_JCHANGED 13
/* Request types for pcre_config(). Do not re-arrange, in order to remain
compatible. */
@@ -242,52 +230,52 @@ that is triggered by the (?) regex item. For Virtual Pascal, these definitions
have to take another form. */
#ifndef VPCOMPAT
-PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);
-PCRE_DATA_SCOPE void (*pcre_free)(void *);
-PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t);
-PCRE_DATA_SCOPE void (*pcre_stack_free)(void *);
-PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *);
+PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
+PCRE_EXP_DECL void (*pcre_free)(void *);
+PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
+PCRE_EXP_DECL void (*pcre_stack_free)(void *);
+PCRE_EXP_DECL int (*pcre_callout)(pcre_callout_block *);
#else /* VPCOMPAT */
-PCRE_DATA_SCOPE void *pcre_malloc(size_t);
-PCRE_DATA_SCOPE void pcre_free(void *);
-PCRE_DATA_SCOPE void *pcre_stack_malloc(size_t);
-PCRE_DATA_SCOPE void pcre_stack_free(void *);
-PCRE_DATA_SCOPE int pcre_callout(pcre_callout_block *);
+PCRE_EXP_DECL void *pcre_malloc(size_t);
+PCRE_EXP_DECL void pcre_free(void *);
+PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
+PCRE_EXP_DECL void pcre_stack_free(void *);
+PCRE_EXP_DECL int pcre_callout(pcre_callout_block *);
#endif /* VPCOMPAT */
/* Exported PCRE functions */
-PCRE_DATA_SCOPE pcre *pcre_compile(const char *, int, const char **, int *,
+PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
const unsigned char *);
-PCRE_DATA_SCOPE pcre *pcre_compile2(const char *, int, int *, const char **,
+PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
int *, const unsigned char *);
-PCRE_DATA_SCOPE int pcre_config(int, void *);
-PCRE_DATA_SCOPE int pcre_copy_named_substring(const pcre *, const char *,
+PCRE_EXP_DECL int pcre_config(int, void *);
+PCRE_EXP_DECL int pcre_copy_named_substring(const pcre *, const char *,
int *, int, const char *, char *, int);
-PCRE_DATA_SCOPE int pcre_copy_substring(const char *, int *, int, int, char *,
+PCRE_EXP_DECL int pcre_copy_substring(const char *, int *, int, int, char *,
int);
-PCRE_DATA_SCOPE int pcre_dfa_exec(const pcre *, const pcre_extra *,
+PCRE_EXP_DECL int pcre_dfa_exec(const pcre *, const pcre_extra *,
const char *, int, int, int, int *, int , int *, int);
-PCRE_DATA_SCOPE int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
+PCRE_EXP_DECL int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
int, int, int, int *, int);
-PCRE_DATA_SCOPE void pcre_free_substring(const char *);
-PCRE_DATA_SCOPE void pcre_free_substring_list(const char **);
-PCRE_DATA_SCOPE int pcre_fullinfo(const pcre *, const pcre_extra *, int,
+PCRE_EXP_DECL void pcre_free_substring(const char *);
+PCRE_EXP_DECL void pcre_free_substring_list(const char **);
+PCRE_EXP_DECL int pcre_fullinfo(const pcre *, const pcre_extra *, int,
void *);
-PCRE_DATA_SCOPE int pcre_get_named_substring(const pcre *, const char *,
+PCRE_EXP_DECL int pcre_get_named_substring(const pcre *, const char *,
int *, int, const char *, const char **);
-PCRE_DATA_SCOPE int pcre_get_stringnumber(const pcre *, const char *);
-PCRE_DATA_SCOPE int pcre_get_stringtable_entries(const pcre *, const char *,
+PCRE_EXP_DECL int pcre_get_stringnumber(const pcre *, const char *);
+PCRE_EXP_DECL int pcre_get_stringtable_entries(const pcre *, const char *,
char **, char **);
-PCRE_DATA_SCOPE int pcre_get_substring(const char *, int *, int, int,
+PCRE_EXP_DECL int pcre_get_substring(const char *, int *, int, int,
const char **);
-PCRE_DATA_SCOPE int pcre_get_substring_list(const char *, int *, int,
+PCRE_EXP_DECL int pcre_get_substring_list(const char *, int *, int,
const char ***);
-PCRE_DATA_SCOPE int pcre_info(const pcre *, int *, int *);
-PCRE_DATA_SCOPE const unsigned char *pcre_maketables(void);
-PCRE_DATA_SCOPE int pcre_refcount(pcre *, int);
-PCRE_DATA_SCOPE pcre_extra *pcre_study(const pcre *, int, const char **);
-PCRE_DATA_SCOPE const char *pcre_version(void);
+PCRE_EXP_DECL int pcre_info(const pcre *, int *, int *);
+PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
+PCRE_EXP_DECL int pcre_refcount(pcre *, int);
+PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
+PCRE_EXP_DECL const char *pcre_version(void);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/ext/pcre/pcrelib/pcre_chartables.c b/ext/pcre/pcrelib/pcre_chartables.c
index d491433e25..6494d8e98c 100644
--- a/ext/pcre/pcrelib/pcre_chartables.c
+++ b/ext/pcre/pcrelib/pcre_chartables.c
@@ -2,13 +2,25 @@
* Perl-Compatible Regular Expressions *
*************************************************/
-/* This file is automatically written by the dftables auxiliary
-program. If you edit it by hand, you might like to edit the Makefile to
-prevent its ever being regenerated.
-
-This file contains the default tables for characters with codes less than
-128 (ASCII characters). These tables are used when no external tables are
-passed to PCRE. */
+/* This file contains character tables that are used when no external tables
+are passed to PCRE by the application that calls it. The tables are used only
+for characters whose code values are less than 256.
+
+This is a default version of the tables that assumes ASCII encoding. A program
+called dftables (which is distributed with PCRE) can be used to build
+alternative versions of this file. This is necessary if you are running in an
+EBCDIC environment, or if you want to default to a different encoding, for
+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
+happens automatically.
+
+The following #include is present because without it gcc 4.x may remove the
+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
+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. */
+
+#include "pcre_internal.h"
const unsigned char _pcre_default_tables[] = {
@@ -82,11 +94,10 @@ const unsigned char _pcre_default_tables[] = {
240,241,242,243,244,245,246,247,
248,249,250,251,252,253,254,255,
-/* This table contains bit maps for various character classes.
-Each map is 32 bytes long and the bits run from the least
-significant end of each byte. The classes that have their own
-maps are: space, xdigit, digit, upper, lower, word, graph
-print, punct, and cntrl. Other classes are built from combinations. */
+/* This table contains bit maps for various character classes. Each map is 32
+bytes long and the bits run from the least significant end of each byte. The
+classes that have their own maps are: space, xdigit, digit, upper, lower, word,
+graph, print, punct, and cntrl. Other classes are built from combinations. */
0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@@ -158,7 +169,7 @@ print, punct, and cntrl. Other classes are built from combinations. */
0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* @ - G */
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* H - O */
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* P - W */
- 0x12,0x12,0x12,0x80,0x00,0x00,0x80,0x10, /* X - _ */
+ 0x12,0x12,0x12,0x80,0x80,0x00,0x80,0x10, /* X - _ */
0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* ` - g */
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* h - o */
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* p - w */
@@ -180,4 +191,4 @@ print, punct, and cntrl. Other classes are built from combinations. */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
-/* End of chartables.c */
+/* End of pcre_chartables.c */
diff --git a/ext/pcre/pcrelib/pcre_compile.c b/ext/pcre/pcrelib/pcre_compile.c
index 34721c8863..c191539c8b 100644
--- a/ext/pcre/pcrelib/pcre_compile.c
+++ b/ext/pcre/pcrelib/pcre_compile.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -58,6 +58,11 @@ used by pcretest. DEBUG is not defined when building a production library. */
#endif
+/* Macro for setting individual bits in class bitmaps. */
+
+#define SETBIT(a,b) a[b/8] |= (1 << (b%8))
+
+
/*************************************************
* Code parameters and static tables *
*************************************************/
@@ -82,21 +87,21 @@ are simple data values; negative values are for special things like \d and so
on. Zero means further processing is needed (for things like \x), or the escape
is invalid. */
-#if !EBCDIC /* This is the "normal" table for ASCII systems */
+#ifndef EBCDIC /* This is the "normal" table for ASCII systems */
static const short int escapes[] = {
0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 7 */
0, 0, ':', ';', '<', '=', '>', '?', /* 8 - ? */
'@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E, 0, -ESC_G, /* @ - G */
- 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
--ESC_P, -ESC_Q, -ESC_R, -ESC_S, 0, 0, 0, -ESC_W, /* P - W */
+-ESC_H, 0, 0, -ESC_K, 0, 0, 0, 0, /* H - O */
+-ESC_P, -ESC_Q, -ESC_R, -ESC_S, 0, 0, -ESC_V, -ESC_W, /* P - W */
-ESC_X, 0, -ESC_Z, '[', '\\', ']', '^', '_', /* X - _ */
'`', 7, -ESC_b, 0, -ESC_d, ESC_e, ESC_f, 0, /* ` - g */
- 0, 0, 0, -ESC_k, 0, 0, ESC_n, 0, /* h - o */
--ESC_p, 0, ESC_r, -ESC_s, ESC_tee, 0, 0, -ESC_w, /* p - w */
+-ESC_h, 0, 0, -ESC_k, 0, 0, ESC_n, 0, /* h - o */
+-ESC_p, 0, ESC_r, -ESC_s, ESC_tee, 0, -ESC_v, -ESC_w, /* p - w */
0, 0, -ESC_z /* x - z */
};
-#else /* This is the "abnormal" table for EBCDIC systems */
+#else /* This is the "abnormal" table for EBCDIC systems */
static const short int escapes[] = {
/* 48 */ 0, 0, 0, '.', '<', '(', '+', '|',
/* 50 */ '&', 0, 0, 0, 0, 0, 0, 0,
@@ -106,18 +111,18 @@ static const short int escapes[] = {
/* 70 */ 0, 0, 0, 0, 0, 0, 0, 0,
/* 78 */ 0, '`', ':', '#', '@', '\'', '=', '"',
/* 80 */ 0, 7, -ESC_b, 0, -ESC_d, ESC_e, ESC_f, 0,
-/* 88 */ 0, 0, 0, '{', 0, 0, 0, 0,
+/* 88 */-ESC_h, 0, 0, '{', 0, 0, 0, 0,
/* 90 */ 0, 0, -ESC_k, 'l', 0, ESC_n, 0, -ESC_p,
/* 98 */ 0, ESC_r, 0, '}', 0, 0, 0, 0,
-/* A0 */ 0, '~', -ESC_s, ESC_tee, 0, 0, -ESC_w, 0,
+/* A0 */ 0, '~', -ESC_s, ESC_tee, 0,-ESC_v, -ESC_w, 0,
/* A8 */ 0,-ESC_z, 0, 0, 0, '[', 0, 0,
/* B0 */ 0, 0, 0, 0, 0, 0, 0, 0,
/* B8 */ 0, 0, 0, 0, 0, ']', '=', '-',
/* C0 */ '{',-ESC_A, -ESC_B, -ESC_C, -ESC_D,-ESC_E, 0, -ESC_G,
-/* C8 */ 0, 0, 0, 0, 0, 0, 0, 0,
+/* C8 */-ESC_H, 0, 0, 0, 0, 0, 0, 0,
/* D0 */ '}', 0, 0, 0, 0, 0, 0, -ESC_P,
/* D8 */-ESC_Q,-ESC_R, 0, 0, 0, 0, 0, 0,
-/* E0 */ '\\', 0, -ESC_S, 0, 0, 0, -ESC_W, -ESC_X,
+/* E0 */ '\\', 0, -ESC_S, 0, 0,-ESC_V, -ESC_W, -ESC_X,
/* E8 */ 0,-ESC_Z, 0, 0, 0, 0, 0, 0,
/* F0 */ 0, 0, 0, 0, 0, 0, 0, 0,
/* F8 */ 0, 0, 0, 0, 0, 0, 0, 0
@@ -208,7 +213,7 @@ static const char *error_texts[] = {
"malformed number or name after (?(",
"conditional group contains more than two branches",
"assertion expected after (?(",
- "(?R or (?digits must be followed by )",
+ "(?R or (?[+-]digits must be followed by )",
/* 30 */
"unknown POSIX class name",
"POSIX collating elements are not supported",
@@ -242,7 +247,8 @@ static const char *error_texts[] = {
/* 55 */
"repeating a DEFINE group is not allowed",
"inconsistent NEWLINE options",
- "\\g is not followed by an (optionally braced) non-zero number"
+ "\\g is not followed by a braced name or an optionally braced non-zero number",
+ "(?+ or (?- or (?(+ or (?(- must be followed by a non-zero number"
};
@@ -262,7 +268,7 @@ For convenience, we use the same bit definitions as in chartables:
Then we can use ctype_digit and ctype_xdigit in the code. */
-#if !EBCDIC /* This is the "normal" case, for ASCII systems */
+#ifndef EBCDIC /* This is the "normal" case, for ASCII systems */
static const unsigned char digitab[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */
@@ -298,7 +304,7 @@ static const unsigned char digitab[] =
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
-#else /* This is the "abnormal" case, for EBCDIC systems */
+#else /* This is the "abnormal" case, for EBCDIC systems */
static const unsigned char digitab[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 0 */
@@ -312,7 +318,7 @@ static const unsigned char digitab[] =
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - 71 40 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 72- | */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* & - 87 50 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 88- */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 88- 95 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - -103 60 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 104- ? */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 70 */
@@ -346,7 +352,7 @@ static const unsigned char ebcdic_chartab[] = { /* chartable partial dup */
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - 71 */
0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80, /* 72- | */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* & - 87 */
- 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00, /* 88- */
+ 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00, /* 88- 95 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - -103 */
0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x80, /* 104- ? */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 */
@@ -373,8 +379,8 @@ static const unsigned char ebcdic_chartab[] = { /* chartable partial dup */
/* Definition to allow mutual recursion */
static BOOL
- compile_regex(int, int, uschar **, const uschar **, int *, BOOL, int, int *,
- int *, branch_chain *, compile_data *, int *);
+ compile_regex(int, int, uschar **, const uschar **, int *, BOOL, BOOL, int,
+ int *, int *, branch_chain *, compile_data *, int *);
@@ -421,11 +427,11 @@ if (c == 0) *errorcodeptr = ERR1;
a table. A non-zero result is something that can be returned immediately.
Otherwise further processing may be required. */
-#if !EBCDIC /* ASCII coding */
+#ifndef EBCDIC /* ASCII coding */
else if (c < '0' || c > 'z') {} /* Not alphameric */
else if ((i = escapes[c - '0']) != 0) c = i;
-#else /* EBCDIC coding */
+#else /* EBCDIC coding */
else if (c < 'a' || (ebcdic_chartab[c] & 0x0E) == 0) {} /* Not alphameric */
else if ((i = escapes[c - 0x48]) != 0) c = i;
#endif
@@ -452,11 +458,22 @@ else
/* \g must be followed by a number, either plain or braced. If positive, it
is an absolute backreference. If negative, it is a relative backreference.
- This is a Perl 5.10 feature. */
+ This is a Perl 5.10 feature. Perl 5.10 also supports \g{name} as a
+ reference to a named group. This is part of Perl's movement towards a
+ unified syntax for back references. As this is synonymous with \k{name}, we
+ fudge it up by pretending it really was \k. */
case 'g':
if (ptr[1] == '{')
{
+ const uschar *p;
+ for (p = ptr+2; *p != 0 && *p != '}'; p++)
+ if (*p != '-' && (digitab[*p] & ctype_digit) == 0) break;
+ if (*p != 0 && *p != '}')
+ {
+ c = -ESC_k;
+ break;
+ }
braced = TRUE;
ptr++;
}
@@ -562,10 +579,10 @@ else
if (c == 0 && cc == '0') continue; /* Leading zeroes */
count++;
-#if !EBCDIC /* ASCII coding */
+#ifndef EBCDIC /* ASCII coding */
if (cc >= 'a') cc -= 32; /* Convert to upper case */
c = (c << 4) + cc - ((cc < 'A')? '0' : ('A' - 10));
-#else /* EBCDIC coding */
+#else /* EBCDIC coding */
if (cc >= 'a' && cc <= 'z') cc += 64; /* Convert to upper case */
c = (c << 4) + cc - ((cc >= '0')? '0' : ('A' - 10));
#endif
@@ -589,10 +606,10 @@ else
{
int cc; /* Some compilers don't like ++ */
cc = *(++ptr); /* in initializers */
-#if !EBCDIC /* ASCII coding */
+#ifndef EBCDIC /* ASCII coding */
if (cc >= 'a') cc -= 32; /* Convert to upper case */
c = c * 16 + cc - ((cc < 'A')? '0' : ('A' - 10));
-#else /* EBCDIC coding */
+#else /* EBCDIC coding */
if (cc <= 'z') cc += 64; /* Convert to upper case */
c = c * 16 + cc - ((cc >= '0')? '0' : ('A' - 10));
#endif
@@ -611,10 +628,10 @@ else
return 0;
}
-#if !EBCDIC /* ASCII coding */
+#ifndef EBCDIC /* ASCII coding */
if (c >= 'a' && c <= 'z') c -= 32;
c ^= 0x40;
-#else /* EBCDIC coding */
+#else /* EBCDIC coding */
if (c >= 'a' && c <= 'z') c += 64;
c ^= 0xC0;
#endif
@@ -1246,6 +1263,7 @@ for (;;)
else
{
code += _pcre_OP_lengths[c];
+#ifdef SUPPORT_UTF8
if (utf8) switch(c)
{
case OP_CHAR:
@@ -1266,6 +1284,7 @@ for (;;)
if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f];
break;
}
+#endif
}
}
}
@@ -1309,6 +1328,7 @@ for (;;)
else
{
code += _pcre_OP_lengths[c];
+#ifdef SUPPORT_UTF8
if (utf8) switch(c)
{
case OP_CHAR:
@@ -1329,6 +1349,7 @@ for (;;)
if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f];
break;
}
+#endif
}
}
}
@@ -1366,6 +1387,18 @@ for (code = first_significant_code(code + _pcre_OP_lengths[*code], NULL, 0, TRUE
c = *code;
+ /* Groups with zero repeats can of course be empty; skip them. */
+
+ if (c == OP_BRAZERO || c == OP_BRAMINZERO)
+ {
+ code += _pcre_OP_lengths[c];
+ do code += GET(code, 1); while (*code == OP_ALT);
+ c = *code;
+ continue;
+ }
+
+ /* For other groups, scan the branches. */
+
if (c == OP_BRA || c == OP_CBRA || c == OP_ONCE)
{
BOOL empty_branch;
@@ -1382,12 +1415,7 @@ for (code = first_significant_code(code + _pcre_OP_lengths[*code], NULL, 0, TRUE
}
while (*code == OP_ALT);
if (!empty_branch) return FALSE; /* All branches are non-empty */
-
- /* Move past the KET and fudge things so that the increment in the "for"
- above has no effect. */
-
- c = OP_END;
- code += 1 + LINK_SIZE - _pcre_OP_lengths[c];
+ c = *code;
continue;
}
@@ -1921,6 +1949,50 @@ if (next >= 0) switch(op_code)
case OP_NOT_WORDCHAR:
return next <= 127 && (cd->ctypes[next] & ctype_word) != 0;
+ case OP_HSPACE:
+ case OP_NOT_HSPACE:
+ switch(next)
+ {
+ case 0x09:
+ case 0x20:
+ case 0xa0:
+ case 0x1680:
+ case 0x180e:
+ case 0x2000:
+ case 0x2001:
+ case 0x2002:
+ case 0x2003:
+ case 0x2004:
+ case 0x2005:
+ case 0x2006:
+ case 0x2007:
+ case 0x2008:
+ case 0x2009:
+ case 0x200A:
+ case 0x202f:
+ case 0x205f:
+ case 0x3000:
+ return op_code != OP_HSPACE;
+ default:
+ return op_code == OP_HSPACE;
+ }
+
+ case OP_VSPACE:
+ case OP_NOT_VSPACE:
+ switch(next)
+ {
+ case 0x0a:
+ case 0x0b:
+ case 0x0c:
+ case 0x0d:
+ case 0x85:
+ case 0x2028:
+ case 0x2029:
+ return op_code != OP_VSPACE;
+ default:
+ return op_code == OP_VSPACE;
+ }
+
default:
return FALSE;
}
@@ -1955,12 +2027,57 @@ switch(op_code)
case ESC_W:
return item <= 127 && (cd->ctypes[item] & ctype_word) != 0;
+ case ESC_h:
+ case ESC_H:
+ switch(item)
+ {
+ case 0x09:
+ case 0x20:
+ case 0xa0:
+ case 0x1680:
+ case 0x180e:
+ case 0x2000:
+ case 0x2001:
+ case 0x2002:
+ case 0x2003:
+ case 0x2004:
+ case 0x2005:
+ case 0x2006:
+ case 0x2007:
+ case 0x2008:
+ case 0x2009:
+ case 0x200A:
+ case 0x202f:
+ case 0x205f:
+ case 0x3000:
+ return -next != ESC_h;
+ default:
+ return -next == ESC_h;
+ }
+
+ case ESC_v:
+ case ESC_V:
+ switch(item)
+ {
+ case 0x0a:
+ case 0x0b:
+ case 0x0c:
+ case 0x0d:
+ case 0x85:
+ case 0x2028:
+ case 0x2029:
+ return -next != ESC_v;
+ default:
+ return -next == ESC_v;
+ }
+
default:
return FALSE;
}
case OP_DIGIT:
- return next == -ESC_D || next == -ESC_s || next == -ESC_W;
+ return next == -ESC_D || next == -ESC_s || next == -ESC_W ||
+ next == -ESC_h || next == -ESC_v;
case OP_NOT_DIGIT:
return next == -ESC_d;
@@ -1969,10 +2086,23 @@ switch(op_code)
return next == -ESC_S || next == -ESC_d || next == -ESC_w;
case OP_NOT_WHITESPACE:
- return next == -ESC_s;
+ return next == -ESC_s || next == -ESC_h || next == -ESC_v;
+
+ case OP_HSPACE:
+ return next == -ESC_S || next == -ESC_H || next == -ESC_d || next == -ESC_w;
+
+ case OP_NOT_HSPACE:
+ return next == -ESC_h;
+
+ /* Can't have \S in here because VT matches \S (Perl anomaly) */
+ case OP_VSPACE:
+ return next == -ESC_V || next == -ESC_d || next == -ESC_w;
+
+ case OP_NOT_VSPACE:
+ return next == -ESC_v;
case OP_WORDCHAR:
- return next == -ESC_W || next == -ESC_s;
+ return next == -ESC_W || next == -ESC_s || next == -ESC_h || next == -ESC_v;
case OP_NOT_WORDCHAR:
return next == -ESC_w || next == -ESC_d;
@@ -2087,10 +2217,12 @@ for (;; ptr++)
BOOL possessive_quantifier;
BOOL is_quantifier;
BOOL is_recurse;
+ BOOL reset_bracount;
int class_charcount;
int class_lastchar;
int newoptions;
int recno;
+ int refsign;
int skipbytes;
int subreqbyte;
int subfirstbyte;
@@ -2515,6 +2647,133 @@ for (;; ptr++)
else if (c == -ESC_d || c == -ESC_D || c == -ESC_w ||
c == -ESC_W || c == -ESC_s || c == -ESC_S) continue;
+ /* We need to deal with \H, \h, \V, and \v in both phases because
+ they use extra memory. */
+
+ if (-c == ESC_h)
+ {
+ SETBIT(classbits, 0x09); /* VT */
+ SETBIT(classbits, 0x20); /* SPACE */
+ SETBIT(classbits, 0xa0); /* NSBP */
+#ifdef SUPPORT_UTF8
+ if (utf8)
+ {
+ class_utf8 = TRUE;
+ *class_utf8data++ = XCL_SINGLE;
+ class_utf8data += _pcre_ord2utf8(0x1680, class_utf8data);
+ *class_utf8data++ = XCL_SINGLE;
+ class_utf8data += _pcre_ord2utf8(0x180e, class_utf8data);
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x2000, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x200A, class_utf8data);
+ *class_utf8data++ = XCL_SINGLE;
+ class_utf8data += _pcre_ord2utf8(0x202f, class_utf8data);
+ *class_utf8data++ = XCL_SINGLE;
+ class_utf8data += _pcre_ord2utf8(0x205f, class_utf8data);
+ *class_utf8data++ = XCL_SINGLE;
+ class_utf8data += _pcre_ord2utf8(0x3000, class_utf8data);
+ }
+#endif
+ continue;
+ }
+
+ if (-c == ESC_H)
+ {
+ for (c = 0; c < 32; c++)
+ {
+ int x = 0xff;
+ switch (c)
+ {
+ case 0x09/8: x ^= 1 << (0x09%8); break;
+ case 0x20/8: x ^= 1 << (0x20%8); break;
+ case 0xa0/8: x ^= 1 << (0xa0%8); break;
+ default: break;
+ }
+ classbits[c] |= x;
+ }
+
+#ifdef SUPPORT_UTF8
+ if (utf8)
+ {
+ class_utf8 = TRUE;
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x0100, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x167f, class_utf8data);
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x1681, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x180d, class_utf8data);
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x180f, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x1fff, class_utf8data);
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x200B, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x202e, class_utf8data);
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x2030, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x205e, class_utf8data);
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x2060, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x2fff, class_utf8data);
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x3001, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x7fffffff, class_utf8data);
+ }
+#endif
+ continue;
+ }
+
+ if (-c == ESC_v)
+ {
+ SETBIT(classbits, 0x0a); /* LF */
+ SETBIT(classbits, 0x0b); /* VT */
+ SETBIT(classbits, 0x0c); /* FF */
+ SETBIT(classbits, 0x0d); /* CR */
+ SETBIT(classbits, 0x85); /* NEL */
+#ifdef SUPPORT_UTF8
+ if (utf8)
+ {
+ class_utf8 = TRUE;
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x2028, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x2029, class_utf8data);
+ }
+#endif
+ continue;
+ }
+
+ if (-c == ESC_V)
+ {
+ for (c = 0; c < 32; c++)
+ {
+ int x = 0xff;
+ switch (c)
+ {
+ case 0x0a/8: x ^= 1 << (0x0a%8);
+ x ^= 1 << (0x0b%8);
+ x ^= 1 << (0x0c%8);
+ x ^= 1 << (0x0d%8);
+ break;
+ case 0x85/8: x ^= 1 << (0x85%8); break;
+ default: break;
+ }
+ classbits[c] |= x;
+ }
+
+#ifdef SUPPORT_UTF8
+ if (utf8)
+ {
+ class_utf8 = TRUE;
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x0100, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x2027, class_utf8data);
+ *class_utf8data++ = XCL_RANGE;
+ class_utf8data += _pcre_ord2utf8(0x2029, class_utf8data);
+ class_utf8data += _pcre_ord2utf8(0x7fffffff, class_utf8data);
+ }
+#endif
+ continue;
+ }
+
/* We need to deal with \P and \p in both phases. */
#ifdef SUPPORT_UCP
@@ -2655,14 +2914,18 @@ for (;; ptr++)
unsigned int origd = d;
while (get_othercase_range(&cc, origd, &occ, &ocd))
{
- if (occ >= c && ocd <= d) continue; /* Skip embedded ranges */
+ if (occ >= (unsigned int)c &&
+ ocd <= (unsigned int)d)
+ continue; /* Skip embedded ranges */
- if (occ < c && ocd >= c - 1) /* Extend the basic range */
+ if (occ < (unsigned int)c &&
+ ocd >= (unsigned int)c - 1) /* Extend the basic range */
{ /* if there is overlap, */
c = occ; /* noting that if occ < c */
continue; /* we can't have ocd > d */
} /* because a subrange is */
- if (ocd > d && occ <= d + 1) /* always shorter than */
+ if (ocd > (unsigned int)d &&
+ occ <= (unsigned int)d + 1) /* always shorter than */
{ /* the basic range. */
d = ocd;
continue;
@@ -3560,6 +3823,7 @@ for (;; ptr++)
skipbytes = 0;
bravalue = OP_CBRA;
save_hwm = cd->hwm;
+ reset_bracount = FALSE;
if (*(++ptr) == '?')
{
@@ -3582,6 +3846,11 @@ for (;; ptr++)
/* ------------------------------------------------------------ */
+ case '|': /* Reset capture count for each branch */
+ reset_bracount = TRUE;
+ /* Fall through */
+
+ /* ------------------------------------------------------------ */
case ':': /* Non-capturing bracket */
bravalue = OP_BRA;
ptr++;
@@ -3617,6 +3886,7 @@ for (;; ptr++)
code[1+LINK_SIZE] = OP_CREF;
skipbytes = 3;
+ refsign = -1;
/* Check for a test for recursion in a named group. */
@@ -3640,7 +3910,11 @@ for (;; ptr++)
terminator = '\'';
ptr++;
}
- else terminator = 0;
+ else
+ {
+ terminator = 0;
+ if (ptr[1] == '-' || ptr[1] == '+') refsign = *(++ptr);
+ }
/* We now expect to read a name; any thing else is an error */
@@ -3676,7 +3950,32 @@ for (;; ptr++)
if (lengthptr != NULL) break;
/* In the real compile we do the work of looking for the actual
- reference. */
+ reference. If the string started with "+" or "-" we require the rest to
+ be digits, in which case recno will be set. */
+
+ if (refsign > 0)
+ {
+ if (recno <= 0)
+ {
+ *errorcodeptr = ERR58;
+ goto FAILED;
+ }
+ if (refsign == '-')
+ {
+ recno = cd->bracount - recno + 1;
+ if (recno <= 0)
+ {
+ *errorcodeptr = ERR15;
+ goto FAILED;
+ }
+ }
+ else recno += cd->bracount;
+ PUT2(code, 2+LINK_SIZE, recno);
+ break;
+ }
+
+ /* Otherwise (did not start with "+" or "-"), start by looking for the
+ name. */
slot = cd->name_table;
for (i = 0; i < cd->names_found; i++)
@@ -3995,19 +4294,54 @@ for (;; ptr++)
/* ------------------------------------------------------------ */
+ case '-': case '+':
case '0': case '1': case '2': case '3': case '4': /* Recursion or */
case '5': case '6': case '7': case '8': case '9': /* subroutine */
{
const uschar *called;
+
+ if ((refsign = *ptr) == '+') ptr++;
+ else if (refsign == '-')
+ {
+ if ((digitab[ptr[1]] & ctype_digit) == 0)
+ goto OTHER_CHAR_AFTER_QUERY;
+ ptr++;
+ }
+
recno = 0;
while((digitab[*ptr] & ctype_digit) != 0)
recno = recno * 10 + *ptr++ - '0';
+
if (*ptr != ')')
{
*errorcodeptr = ERR29;
goto FAILED;
}
+ if (refsign == '-')
+ {
+ if (recno == 0)
+ {
+ *errorcodeptr = ERR58;
+ goto FAILED;
+ }
+ recno = cd->bracount - recno + 1;
+ if (recno <= 0)
+ {
+ *errorcodeptr = ERR15;
+ goto FAILED;
+ }
+ }
+ else if (refsign == '+')
+ {
+ if (recno == 0)
+ {
+ *errorcodeptr = ERR58;
+ goto FAILED;
+ }
+ recno += cd->bracount;
+ }
+
/* Come here from code above that handles a named recursion */
HANDLE_RECURSION:
@@ -4080,6 +4414,7 @@ for (;; ptr++)
/* ------------------------------------------------------------ */
default: /* Other characters: check option setting */
+ OTHER_CHAR_AFTER_QUERY:
set = unset = 0;
optset = &set;
@@ -4214,6 +4549,7 @@ for (;; ptr++)
errorcodeptr, /* Where to put an error message */
(bravalue == OP_ASSERTBACK ||
bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */
+ reset_bracount, /* True if (?| group */
skipbytes, /* Skip over bracket number */
&subfirstbyte, /* For possible first char */
&subreqbyte, /* For possible last char */
@@ -4230,9 +4566,11 @@ for (;; ptr++)
is on the bracket. */
/* If this is a conditional bracket, check that there are no more than
- two branches in the group, or just one if it's a DEFINE group. */
+ two branches in the group, or just one if it's a DEFINE group. We do this
+ in the real compile phase, not in the pre-pass, where the whole group may
+ not be available. */
- if (bravalue == OP_COND)
+ if (bravalue == OP_COND && lengthptr == NULL)
{
uschar *tc = code;
int condcount = 0;
@@ -4392,12 +4730,13 @@ for (;; ptr++)
zerofirstbyte = firstbyte;
zeroreqbyte = reqbyte;
- /* \k<name> or \k'name' is a back reference by name (Perl syntax) */
+ /* \k<name> or \k'name' is a back reference by name (Perl syntax).
+ We also support \k{name} (.NET syntax) */
- if (-c == ESC_k && (ptr[1] == '<' || ptr[1] == '\''))
+ if (-c == ESC_k && (ptr[1] == '<' || ptr[1] == '\'' || ptr[1] == '{'))
{
is_recurse = FALSE;
- terminator = (*(++ptr) == '<')? '>' : '\'';
+ terminator = (*(++ptr) == '<')? '>' : (*ptr == '\'')? '\'' : '}';
goto NAMED_REF_OR_RECURSE;
}
@@ -4563,13 +4902,14 @@ This function is used during the pre-compile phase when we are trying to find
out the amount of memory needed, as well as during the real compile phase. The
value of lengthptr distinguishes the two phases.
-Argument:
+Arguments:
options option bits, including any changes for this subpattern
oldims previous settings of ims option bits
codeptr -> the address of the current code pointer
ptrptr -> the address of the current pattern pointer
errorcodeptr -> pointer to error code variable
lookbehind TRUE if this is a lookbehind assertion
+ reset_bracount TRUE to reset the count for each branch
skipbytes skip this many bytes at start (for brackets and OP_COND)
firstbyteptr place to put the first required character, or a negative number
reqbyteptr place to put the last required character, or a negative number
@@ -4583,8 +4923,9 @@ Returns: TRUE on success
static BOOL
compile_regex(int options, int oldims, uschar **codeptr, const uschar **ptrptr,
- int *errorcodeptr, BOOL lookbehind, int skipbytes, int *firstbyteptr,
- int *reqbyteptr, branch_chain *bcptr, compile_data *cd, int *lengthptr)
+ int *errorcodeptr, BOOL lookbehind, BOOL reset_bracount, int skipbytes,
+ int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr, compile_data *cd,
+ int *lengthptr)
{
const uschar *ptr = *ptrptr;
uschar *code = *codeptr;
@@ -4594,6 +4935,8 @@ uschar *reverse_count = NULL;
int firstbyte, reqbyte;
int branchfirstbyte, branchreqbyte;
int length;
+int orig_bracount;
+int max_bracount;
branch_chain bc;
bc.outer = bcptr;
@@ -4622,8 +4965,14 @@ code += 1 + LINK_SIZE + skipbytes;
/* Loop for each alternative branch */
+orig_bracount = max_bracount = cd->bracount;
for (;;)
{
+ /* For a (?| group, reset the capturing bracket count so that each branch
+ uses the same numbers. */
+
+ if (reset_bracount) cd->bracount = orig_bracount;
+
/* Handle a change of ims options at the start of the branch */
if ((options & PCRE_IMS) != oldims)
@@ -4653,6 +5002,11 @@ for (;;)
return FALSE;
}
+ /* Keep the highest bracket count in case (?| was used and some branch
+ has fewer than the rest. */
+
+ if (cd->bracount > max_bracount) max_bracount = cd->bracount;
+
/* In the real compile phase, there is some post-processing to be done. */
if (lengthptr == NULL)
@@ -4716,26 +5070,29 @@ for (;;)
}
}
- /* Reached end of expression, either ')' or end of pattern. Go back through
- the alternative branches and reverse the chain of offsets, with the field in
- the BRA item now becoming an offset to the first alternative. If there are
- no alternatives, it points to the end of the group. The length in the
- terminating ket is always the length of the whole bracketed item. If any of
- the ims options were changed inside the group, compile a resetting op-code
- following, except at the very end of the pattern. Return leaving the pointer
- at the terminating char. */
+ /* Reached end of expression, either ')' or end of pattern. In the real
+ compile phase, go back through the alternative branches and reverse the chain
+ of offsets, with the field in the BRA item now becoming an offset to the
+ first alternative. If there are no alternatives, it points to the end of the
+ group. The length in the terminating ket is always the length of the whole
+ bracketed item. If any of the ims options were changed inside the group,
+ compile a resetting op-code following, except at the very end of the pattern.
+ Return leaving the pointer at the terminating char. */
if (*ptr != '|')
{
- int branch_length = code - last_branch;
- do
+ if (lengthptr == NULL)
{
- int prev_length = GET(last_branch, 1);
- PUT(last_branch, 1, branch_length);
- branch_length = prev_length;
- last_branch -= branch_length;
+ int branch_length = code - last_branch;
+ do
+ {
+ int prev_length = GET(last_branch, 1);
+ PUT(last_branch, 1, branch_length);
+ branch_length = prev_length;
+ last_branch -= branch_length;
+ }
+ while (branch_length > 0);
}
- while (branch_length > 0);
/* Fill in the ket */
@@ -4752,6 +5109,10 @@ for (;;)
length += 2;
}
+ /* Retain the highest bracket number, in case resetting was used. */
+
+ cd->bracount = max_bracount;
+
/* Set values to pass back */
*codeptr = code;
@@ -4762,17 +5123,29 @@ for (;;)
return TRUE;
}
- /* Another branch follows; insert an "or" node. Its length field points back
+ /* Another branch follows. In the pre-compile phase, we can move the code
+ pointer back to where it was for the start of the first branch. (That is,
+ pretend that each branch is the only one.)
+
+ In the real compile phase, insert an ALT node. Its length field points back
to the previous branch while the bracket remains open. At the end the chain
is reversed. It's done like this so that the start of the bracket has a
zero offset until it is closed, making it possible to detect recursion. */
- *code = OP_ALT;
- PUT(code, 1, code - last_branch);
- bc.current = last_branch = code;
- code += 1 + LINK_SIZE;
+ if (lengthptr != NULL)
+ {
+ code = *codeptr + 1 + LINK_SIZE + skipbytes;
+ length += 1 + LINK_SIZE;
+ }
+ else
+ {
+ *code = OP_ALT;
+ PUT(code, 1, code - last_branch);
+ bc.current = last_branch = code;
+ code += 1 + LINK_SIZE;
+ }
+
ptr++;
- length += 1 + LINK_SIZE;
}
/* Control never reaches here */
}
@@ -5039,7 +5412,7 @@ Returns: pointer to compiled data block, or NULL on error,
with errorptr and erroroffset set
*/
-PCRE_DATA_SCOPE pcre *
+PCRE_EXP_DEFN pcre *
pcre_compile(const char *pattern, int options, const char **errorptr,
int *erroroffset, const unsigned char *tables)
{
@@ -5047,7 +5420,7 @@ return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
}
-PCRE_DATA_SCOPE pcre *
+PCRE_EXP_DEFN pcre *
pcre_compile2(const char *pattern, int options, int *errorcodeptr,
const char **errorptr, int *erroroffset, const unsigned char *tables)
{
@@ -5096,7 +5469,7 @@ if (errorcodeptr != NULL) *errorcodeptr = ERR0;
if (erroroffset == NULL)
{
errorcode = ERR16;
- goto PCRE_EARLY_ERROR_RETURN;
+ goto PCRE_EARLY_ERROR_RETURN2;
}
*erroroffset = 0;
@@ -5109,7 +5482,7 @@ if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0 &&
(*erroroffset = _pcre_valid_utf8((uschar *)pattern, -1)) >= 0)
{
errorcode = ERR44;
- goto PCRE_UTF8_ERROR_RETURN;
+ goto PCRE_EARLY_ERROR_RETURN2;
}
#else
if ((options & PCRE_UTF8) != 0)
@@ -5134,7 +5507,8 @@ cd->cbits = tables + cbits_offset;
cd->ctypes = tables + ctypes_offset;
/* Handle different types of newline. The three bits give seven cases. The
-current code allows for fixed one- or two-byte sequences, plus "any". */
+current code allows for fixed one- or two-byte sequences, plus "any" and
+"anycrlf". */
switch (options & (PCRE_NEWLINE_CRLF | PCRE_NEWLINE_ANY))
{
@@ -5144,10 +5518,15 @@ switch (options & (PCRE_NEWLINE_CRLF | PCRE_NEWLINE_ANY))
case PCRE_NEWLINE_CR+
PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
case PCRE_NEWLINE_ANY: newline = -1; break;
+ case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN;
}
-if (newline < 0)
+if (newline == -2)
+ {
+ cd->nltype = NLTYPE_ANYCRLF;
+ }
+else if (newline < 0)
{
cd->nltype = NLTYPE_ANY;
}
@@ -5208,7 +5587,8 @@ outside can help speed up starting point checks. */
code = cworkspace;
*code = OP_BRA;
(void)compile_regex(cd->external_options, cd->external_options & PCRE_IMS,
- &code, &ptr, &errorcode, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, &length);
+ &code, &ptr, &errorcode, FALSE, FALSE, 0, &firstbyte, &reqbyte, NULL, cd,
+ &length);
if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN;
DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,
@@ -5276,7 +5656,7 @@ ptr = (const uschar *)pattern;
code = (uschar *)codestart;
*code = OP_BRA;
(void)compile_regex(re->options, re->options & PCRE_IMS, &code, &ptr,
- &errorcode, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, NULL);
+ &errorcode, FALSE, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, NULL);
re->top_bracket = cd->bracount;
re->top_backref = cd->top_backref;
@@ -5321,9 +5701,7 @@ if (errorcode != 0)
(pcre_free)(re);
PCRE_EARLY_ERROR_RETURN:
*erroroffset = ptr - (const uschar *)pattern;
-#ifdef SUPPORT_UTF8
- PCRE_UTF8_ERROR_RETURN:
-#endif
+ PCRE_EARLY_ERROR_RETURN2:
*errorptr = error_texts[errorcode];
if (errorcodeptr != NULL) *errorcodeptr = errorcode;
return NULL;
@@ -5413,7 +5791,7 @@ if ((re->options & PCRE_REQCHSET) != 0)
else printf("Req char = \\x%02x%s\n", ch, caseless);
}
-pcre_printint(re, stdout);
+pcre_printint(re, stdout, TRUE);
/* This check is done here in the debugging case so that the code that
was compiled can be seen. */
diff --git a/ext/pcre/pcrelib/pcre_config.c b/ext/pcre/pcrelib/pcre_config.c
index 29e6c1a358..52d2594661 100644
--- a/ext/pcre/pcrelib/pcre_config.c
+++ b/ext/pcre/pcrelib/pcre_config.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -58,7 +58,7 @@ Arguments:
Returns: 0 if data returned, negative on error
*/
-PCRE_DATA_SCOPE int
+PCRE_EXP_DEFN int
pcre_config(int what, void *where)
{
switch (what)
diff --git a/ext/pcre/pcrelib/pcre_exec.c b/ext/pcre/pcrelib/pcre_exec.c
index 890e0f731a..f62b5fc18e 100644
--- a/ext/pcre/pcrelib/pcre_exec.c
+++ b/ext/pcre/pcrelib/pcre_exec.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -48,6 +48,11 @@ possible. There are also some static supporting functions. */
#include "pcre_internal.h"
+/* Undefine some potentially clashing cpp symbols */
+
+#undef min
+#undef max
+
/* The chain of eptrblocks for tail recursions uses memory in stack workspace,
obtained at top level, the size of which is defined by EPTR_WORK_SIZE. */
@@ -183,20 +188,45 @@ calls by keeping local variables that need to be preserved in blocks of memory
obtained from malloc() instead instead of on the stack. Macros are used to
achieve this so that the actual code doesn't look very different to what it
always used to.
+
+The original heap-recursive code used longjmp(). However, it seems that this
+can be very slow on some operating systems. Following a suggestion from Stan
+Switzer, the use of longjmp() has been abolished, at the cost of having to
+provide a unique number for each call to RMATCH. There is no way of generating
+a sequence of numbers at compile time in C. I have given them names, to make
+them stand out more clearly.
+
+Crude tests on x86 Linux show a small speedup of around 5-8%. However, on
+FreeBSD, avoiding longjmp() more than halves the time taken to run the standard
+tests. Furthermore, not using longjmp() means that local dynamic variables
+don't have indeterminate values; this has meant that the frame size can be
+reduced because the result can be "passed back" by straight setting of the
+variable instead of being passed in the frame.
****************************************************************************
***************************************************************************/
+/* Numbers for RMATCH calls */
+
+enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10,
+ RM11, RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20,
+ RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,
+ RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
+ RM41, RM42, RM43, RM44, RM45, RM46, RM47 };
+
+
/* These versions of the macros use the stack, as normal. There are debugging
-versions and production versions. */
+versions and production versions. Note that the "rw" argument of RMATCH isn't
+actuall used in this definition. */
#ifndef NO_RECURSE
#define REGISTER register
+
#ifdef DEBUG
-#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg) \
+#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
{ \
printf("match() called in line %d\n", __LINE__); \
- rx = match(ra,rb,rc,rd,re,rf,rg,rdepth+1); \
+ rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1); \
printf("to line %d\n", __LINE__); \
}
#define RRETURN(ra) \
@@ -205,43 +235,38 @@ versions and production versions. */
return ra; \
}
#else
-#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg) \
- rx = match(ra,rb,rc,rd,re,rf,rg,rdepth+1)
+#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
+ rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1)
#define RRETURN(ra) return ra
#endif
#else
-/* These versions of the macros manage a private stack on the heap. Note
-that the rd argument of RMATCH isn't actually used. It's the md argument of
-match(), which never changes. */
+/* These versions of the macros manage a private stack on the heap. Note that
+the "rd" argument of RMATCH isn't actually used in this definition. It's the md
+argument of match(), which never changes. */
#define REGISTER
-#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg)\
+#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\
{\
heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\
- if (setjmp(frame->Xwhere) == 0)\
- {\
- newframe->Xeptr = ra;\
- newframe->Xecode = rb;\
- newframe->Xoffset_top = rc;\
- newframe->Xims = re;\
- newframe->Xeptrb = rf;\
- newframe->Xflags = rg;\
- newframe->Xrdepth = frame->Xrdepth + 1;\
- newframe->Xprevframe = frame;\
- frame = newframe;\
- DPRINTF(("restarting from line %d\n", __LINE__));\
- goto HEAP_RECURSE;\
- }\
- else\
- {\
- DPRINTF(("longjumped back to line %d\n", __LINE__));\
- frame = md->thisframe;\
- rx = frame->Xresult;\
- }\
+ frame->Xwhere = rw; \
+ newframe->Xeptr = ra;\
+ newframe->Xecode = rb;\
+ newframe->Xmstart = mstart;\
+ newframe->Xoffset_top = rc;\
+ newframe->Xims = re;\
+ newframe->Xeptrb = rf;\
+ newframe->Xflags = rg;\
+ newframe->Xrdepth = frame->Xrdepth + 1;\
+ newframe->Xprevframe = frame;\
+ frame = newframe;\
+ DPRINTF(("restarting from line %d\n", __LINE__));\
+ goto HEAP_RECURSE;\
+ L_##rw:\
+ DPRINTF(("jumped back to line %d\n", __LINE__));\
}
#define RRETURN(ra)\
@@ -251,9 +276,8 @@ match(), which never changes. */
(pcre_stack_free)(newframe);\
if (frame != NULL)\
{\
- frame->Xresult = ra;\
- md->thisframe = frame;\
- longjmp(frame->Xwhere, 1);\
+ rrc = ra;\
+ goto HEAP_RETURN;\
}\
return ra;\
}
@@ -268,6 +292,7 @@ typedef struct heapframe {
const uschar *Xeptr;
const uschar *Xecode;
+ const uschar *Xmstart;
int Xoffset_top;
long int Xims;
eptrblock *Xeptrb;
@@ -299,6 +324,8 @@ typedef struct heapframe {
int Xprop_category;
int Xprop_chartype;
int Xprop_script;
+ int Xoclength;
+ uschar Xocchars[8];
#endif
int Xctype;
@@ -316,10 +343,9 @@ typedef struct heapframe {
eptrblock Xnewptrb;
- /* Place to pass back result, and where to jump back to */
+ /* Where to jump back to */
- int Xresult;
- jmp_buf Xwhere;
+ int Xwhere;
} heapframe;
@@ -347,6 +373,8 @@ made performance worse.
Arguments:
eptr pointer to current character in subject
ecode pointer to current position in compiled code
+ mstart pointer to the current match start position (can be modified
+ by encountering \K)
offset_top current top pointer
md pointer to "static" info for the match
ims current /i, /m, and /s options
@@ -366,7 +394,7 @@ Returns: MATCH_MATCH if matched ) these values are >= 0
*/
static int
-match(REGISTER USPTR eptr, REGISTER const uschar *ecode,
+match(REGISTER USPTR eptr, REGISTER const uschar *ecode, const uschar *mstart,
int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,
int flags, unsigned int rdepth)
{
@@ -394,6 +422,7 @@ frame->Xprevframe = NULL; /* Marks the top level */
frame->Xeptr = eptr;
frame->Xecode = ecode;
+frame->Xmstart = mstart;
frame->Xoffset_top = offset_top;
frame->Xims = ims;
frame->Xeptrb = eptrb;
@@ -408,6 +437,7 @@ HEAP_RECURSE:
#define eptr frame->Xeptr
#define ecode frame->Xecode
+#define mstart frame->Xmstart
#define offset_top frame->Xoffset_top
#define ims frame->Xims
#define eptrb frame->Xeptrb
@@ -441,6 +471,8 @@ HEAP_RECURSE:
#define prop_category frame->Xprop_category
#define prop_chartype frame->Xprop_chartype
#define prop_script frame->Xprop_script
+#define oclength frame->Xoclength
+#define occhars frame->Xocchars
#endif
#define ctype frame->Xctype
@@ -494,6 +526,8 @@ int prop_fail_result;
int prop_category;
int prop_chartype;
int prop_script;
+int oclength;
+uschar occhars[8];
#endif
int ctype;
@@ -534,6 +568,12 @@ defined). However, RMATCH isn't like a function call because it's quite a
complicated macro. It has to be used in one particular way. This shouldn't,
however, impact performance when true recursion is being used. */
+#ifdef SUPPORT_UTF8
+utf8 = md->utf8; /* Local copy of the flag */
+#else
+utf8 = FALSE;
+#endif
+
/* First check that we haven't called match() too many times, or that we
haven't exceeded the recursive call limit. */
@@ -542,12 +582,6 @@ if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT);
original_ims = ims; /* Save for resetting on ')' */
-#ifdef SUPPORT_UTF8
-utf8 = md->utf8; /* Local copy of the flag */
-#else
-utf8 = FALSE;
-#endif
-
/* At the start of a group with an unlimited repeat that may match an empty
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
@@ -582,7 +616,7 @@ for (;;)
if (md->partial &&
eptr >= md->end_subject &&
- eptr > md->start_match)
+ eptr > mstart)
md->hitend = TRUE;
switch(op)
@@ -626,8 +660,8 @@ for (;;)
flags = (op == OP_SCBRA)? match_cbegroup : 0;
do
{
- RMATCH(rrc, eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
- ims, eptrb, flags);
+ RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
+ ims, eptrb, flags, RM1);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
md->capture_last = save_capture_last;
ecode += GET(ecode, 1);
@@ -670,8 +704,8 @@ for (;;)
/* For non-final alternatives, continue the loop for a NOMATCH result;
otherwise return. */
- RMATCH(rrc, eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
- eptrb, flags);
+ RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
+ eptrb, flags, RM2);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode += GET(ecode, 1);
}
@@ -712,8 +746,8 @@ for (;;)
else
{
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
- match_condassert);
+ RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
+ match_condassert, RM3);
if (rrc == MATCH_MATCH)
{
condition = TRUE;
@@ -759,7 +793,7 @@ for (;;)
md->recursive = rec->prevrec;
memmove(md->offset_vector, rec->offset_save,
rec->saved_max * sizeof(int));
- md->start_match = rec->save_start;
+ mstart = rec->save_start;
ims = original_ims;
ecode = rec->after_call;
break;
@@ -768,9 +802,10 @@ for (;;)
/* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty
string - backtracking will then try other alternatives, if any. */
- if (md->notempty && eptr == md->start_match) RRETURN(MATCH_NOMATCH);
- md->end_match_ptr = eptr; /* Record where we ended */
- md->end_offset_top = offset_top; /* and how many extracts were taken */
+ if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH);
+ md->end_match_ptr = eptr; /* Record where we ended */
+ md->end_offset_top = offset_top; /* and how many extracts were taken */
+ md->start_match_ptr = mstart; /* and the start (\K can modify) */
RRETURN(MATCH_MATCH);
/* Change option settings */
@@ -791,7 +826,8 @@ for (;;)
case OP_ASSERTBACK:
do
{
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0);
+ RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
+ RM4);
if (rrc == MATCH_MATCH) break;
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode += GET(ecode, 1);
@@ -817,7 +853,8 @@ for (;;)
case OP_ASSERTBACK_NOT:
do
{
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0);
+ RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
+ RM5);
if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode += GET(ecode,1);
@@ -874,7 +911,7 @@ for (;;)
cb.offset_vector = md->offset_vector;
cb.subject = (PCRE_SPTR)md->start_subject;
cb.subject_length = md->end_subject - md->start_subject;
- cb.start_match = md->start_match - md->start_subject;
+ cb.start_match = mstart - md->start_subject;
cb.current_position = eptr - md->start_subject;
cb.pattern_position = GET(ecode, 2);
cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
@@ -936,8 +973,8 @@ for (;;)
memcpy(new_recursive.offset_save, md->offset_vector,
new_recursive.saved_max * sizeof(int));
- new_recursive.save_start = md->start_match;
- md->start_match = eptr;
+ new_recursive.save_start = mstart;
+ mstart = eptr;
/* OK, now we can do the recursion. For each top-level alternative we
restore the offset and recursion data. */
@@ -946,8 +983,8 @@ for (;;)
flags = (*callpat >= OP_SBRA)? match_cbegroup : 0;
do
{
- RMATCH(rrc, eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,
- md, ims, eptrb, flags);
+ RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,
+ md, ims, eptrb, flags, RM6);
if (rrc == MATCH_MATCH)
{
DPRINTF(("Recursion matched\n"));
@@ -990,8 +1027,8 @@ for (;;)
do
{
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims,
- eptrb, 0);
+ RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims,
+ eptrb, 0, RM7);
if (rrc == MATCH_MATCH) break;
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode += GET(ecode,1);
@@ -1036,7 +1073,8 @@ for (;;)
if (*ecode == OP_KETRMIN)
{
- RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0,
+ RM8);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode = prev;
flags = match_tail_recursed;
@@ -1044,7 +1082,7 @@ for (;;)
}
else /* OP_KETRMAX */
{
- RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_cbegroup);
+ RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode += 1 + LINK_SIZE;
flags = match_tail_recursed;
@@ -1068,7 +1106,7 @@ for (;;)
case OP_BRAZERO:
{
next = ecode+1;
- RMATCH(rrc, eptr, next, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, next, offset_top, md, ims, eptrb, 0, RM10);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
do next += GET(next,1); while (*next == OP_ALT);
ecode = next + 1 + LINK_SIZE;
@@ -1079,7 +1117,7 @@ for (;;)
{
next = ecode+1;
do next += GET(next, 1); while (*next == OP_ALT);
- RMATCH(rrc, eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, RM11);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode++;
}
@@ -1149,7 +1187,7 @@ for (;;)
recursion_info *rec = md->recursive;
DPRINTF(("Recursion (%d) succeeded - continuing\n", number));
md->recursive = rec->prevrec;
- md->start_match = rec->save_start;
+ mstart = rec->save_start;
memcpy(md->offset_vector, rec->offset_save,
rec->saved_max * sizeof(int));
ecode = rec->after_call;
@@ -1184,7 +1222,8 @@ for (;;)
if (*ecode == OP_KETRMIN)
{
- RMATCH(rrc, eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0,
+ RM12);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode = prev;
flags |= match_tail_recursed;
@@ -1192,7 +1231,7 @@ for (;;)
}
else /* OP_KETRMAX */
{
- RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, flags);
+ RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode += 1 + LINK_SIZE;
flags = match_tail_recursed;
@@ -1228,6 +1267,13 @@ for (;;)
ecode++;
break;
+ /* Reset the start of match point */
+
+ case OP_SET_SOM:
+ mstart = eptr;
+ ecode++;
+ break;
+
/* Assert before internal newline if multiline, or before a terminating
newline unless endonly is set, else end of subject unless noteol is set. */
@@ -1436,6 +1482,102 @@ for (;;)
ecode++;
break;
+ case OP_NOT_HSPACE:
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ GETCHARINCTEST(c, eptr);
+ switch(c)
+ {
+ default: break;
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ case 0x1680: /* OGHAM SPACE MARK */
+ case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
+ case 0x2000: /* EN QUAD */
+ case 0x2001: /* EM QUAD */
+ case 0x2002: /* EN SPACE */
+ case 0x2003: /* EM SPACE */
+ case 0x2004: /* THREE-PER-EM SPACE */
+ case 0x2005: /* FOUR-PER-EM SPACE */
+ case 0x2006: /* SIX-PER-EM SPACE */
+ case 0x2007: /* FIGURE SPACE */
+ case 0x2008: /* PUNCTUATION SPACE */
+ case 0x2009: /* THIN SPACE */
+ case 0x200A: /* HAIR SPACE */
+ case 0x202f: /* NARROW NO-BREAK SPACE */
+ case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
+ case 0x3000: /* IDEOGRAPHIC SPACE */
+ RRETURN(MATCH_NOMATCH);
+ }
+ ecode++;
+ break;
+
+ case OP_HSPACE:
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ GETCHARINCTEST(c, eptr);
+ switch(c)
+ {
+ default: RRETURN(MATCH_NOMATCH);
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ case 0x1680: /* OGHAM SPACE MARK */
+ case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
+ case 0x2000: /* EN QUAD */
+ case 0x2001: /* EM QUAD */
+ case 0x2002: /* EN SPACE */
+ case 0x2003: /* EM SPACE */
+ case 0x2004: /* THREE-PER-EM SPACE */
+ case 0x2005: /* FOUR-PER-EM SPACE */
+ case 0x2006: /* SIX-PER-EM SPACE */
+ case 0x2007: /* FIGURE SPACE */
+ case 0x2008: /* PUNCTUATION SPACE */
+ case 0x2009: /* THIN SPACE */
+ case 0x200A: /* HAIR SPACE */
+ case 0x202f: /* NARROW NO-BREAK SPACE */
+ case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
+ case 0x3000: /* IDEOGRAPHIC SPACE */
+ break;
+ }
+ ecode++;
+ break;
+
+ case OP_NOT_VSPACE:
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ GETCHARINCTEST(c, eptr);
+ switch(c)
+ {
+ default: break;
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ case 0x2028: /* LINE SEPARATOR */
+ case 0x2029: /* PARAGRAPH SEPARATOR */
+ RRETURN(MATCH_NOMATCH);
+ }
+ ecode++;
+ break;
+
+ case OP_VSPACE:
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ GETCHARINCTEST(c, eptr);
+ switch(c)
+ {
+ default: RRETURN(MATCH_NOMATCH);
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ case 0x2028: /* LINE SEPARATOR */
+ case 0x2029: /* PARAGRAPH SEPARATOR */
+ break;
+ }
+ ecode++;
+ break;
+
#ifdef SUPPORT_UCP
/* Check the next character by Unicode property. We will get here only
if the support is in the binary; otherwise a compile-time error occurs. */
@@ -1591,7 +1733,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || !match_ref(offset, eptr, length, md, ims))
RRETURN(MATCH_NOMATCH);
@@ -1612,7 +1754,7 @@ for (;;)
}
while (eptr >= pp)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
eptr -= length;
}
@@ -1717,7 +1859,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
GETCHARINC(c, eptr);
@@ -1737,7 +1879,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
c = *eptr++;
@@ -1774,7 +1916,7 @@ for (;;)
}
for (;;)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */
BACKCHAR(eptr);
@@ -1793,7 +1935,7 @@ for (;;)
}
while (eptr >= pp)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
eptr--;
}
@@ -1864,7 +2006,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
GETCHARINC(c, eptr);
@@ -1888,7 +2030,7 @@ for (;;)
}
for(;;)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */
BACKCHAR(eptr)
@@ -2045,19 +2187,18 @@ for (;;)
if (length > 1)
{
- int oclength = 0;
- uschar occhars[8];
-
#ifdef SUPPORT_UCP
unsigned int othercase;
if ((ims & PCRE_CASELESS) != 0 &&
(othercase = _pcre_ucp_othercase(fc)) != NOTACHAR)
oclength = _pcre_ord2utf8(othercase, occhars);
+ else oclength = 0;
#endif /* SUPPORT_UCP */
for (i = 1; i <= min; i++)
{
if (memcmp(eptr, charptr, length) == 0) eptr += length;
+#ifdef SUPPORT_UCP
/* Need braces because of following else */
else if (oclength == 0) { RRETURN(MATCH_NOMATCH); }
else
@@ -2065,6 +2206,9 @@ for (;;)
if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH);
eptr += oclength;
}
+#else /* without SUPPORT_UCP */
+ else { RRETURN(MATCH_NOMATCH); }
+#endif /* SUPPORT_UCP */
}
if (min == max) continue;
@@ -2073,10 +2217,11 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
if (memcmp(eptr, charptr, length) == 0) eptr += length;
+#ifdef SUPPORT_UCP
/* Need braces because of following else */
else if (oclength == 0) { RRETURN(MATCH_NOMATCH); }
else
@@ -2084,6 +2229,9 @@ for (;;)
if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH);
eptr += oclength;
}
+#else /* without SUPPORT_UCP */
+ else { RRETURN (MATCH_NOMATCH); }
+#endif /* SUPPORT_UCP */
}
/* Control never gets here */
}
@@ -2095,22 +2243,31 @@ for (;;)
{
if (eptr > md->end_subject - length) break;
if (memcmp(eptr, charptr, length) == 0) eptr += length;
+#ifdef SUPPORT_UCP
else if (oclength == 0) break;
else
{
if (memcmp(eptr, occhars, oclength) != 0) break;
eptr += oclength;
}
+#else /* without SUPPORT_UCP */
+ else break;
+#endif /* SUPPORT_UCP */
}
if (possessive) continue;
- while (eptr >= pp)
+ for(;;)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+ if (eptr == pp) RRETURN(MATCH_NOMATCH);
+#ifdef SUPPORT_UCP
+ eptr--;
+ BACKCHAR(eptr);
+#else /* without SUPPORT_UCP */
eptr -= length;
+#endif /* SUPPORT_UCP */
}
- RRETURN(MATCH_NOMATCH);
}
/* Control never gets here */
}
@@ -2150,7 +2307,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject ||
fc != md->lcc[*eptr++])
@@ -2169,7 +2326,7 @@ for (;;)
if (possessive) continue;
while (eptr >= pp)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25);
eptr--;
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
}
@@ -2188,7 +2345,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject || fc != *eptr++)
RRETURN(MATCH_NOMATCH);
@@ -2206,7 +2363,7 @@ for (;;)
if (possessive) continue;
while (eptr >= pp)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27);
eptr--;
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
}
@@ -2351,7 +2508,7 @@ for (;;)
register unsigned int d;
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
GETCHARINC(d, eptr);
if (d < 256) d = md->lcc[d];
@@ -2365,7 +2522,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++])
RRETURN(MATCH_NOMATCH);
@@ -2397,7 +2554,7 @@ for (;;)
if (possessive) continue;
for(;;)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM30);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */
BACKCHAR(eptr);
@@ -2415,7 +2572,7 @@ for (;;)
if (possessive) continue;
while (eptr >= pp)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM31);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
eptr--;
}
@@ -2460,7 +2617,7 @@ for (;;)
register unsigned int d;
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
GETCHARINC(d, eptr);
if (fi >= max || eptr >= md->end_subject || fc == d)
@@ -2473,7 +2630,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject || fc == *eptr++)
RRETURN(MATCH_NOMATCH);
@@ -2504,7 +2661,7 @@ for (;;)
if (possessive) continue;
for(;;)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM34);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */
BACKCHAR(eptr);
@@ -2522,7 +2679,7 @@ for (;;)
if (possessive) continue;
while (eptr >= pp)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM35);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
eptr--;
}
@@ -2753,6 +2910,110 @@ for (;;)
}
break;
+ case OP_NOT_HSPACE:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ GETCHARINC(c, eptr);
+ switch(c)
+ {
+ default: break;
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ case 0x1680: /* OGHAM SPACE MARK */
+ case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
+ case 0x2000: /* EN QUAD */
+ case 0x2001: /* EM QUAD */
+ case 0x2002: /* EN SPACE */
+ case 0x2003: /* EM SPACE */
+ case 0x2004: /* THREE-PER-EM SPACE */
+ case 0x2005: /* FOUR-PER-EM SPACE */
+ case 0x2006: /* SIX-PER-EM SPACE */
+ case 0x2007: /* FIGURE SPACE */
+ case 0x2008: /* PUNCTUATION SPACE */
+ case 0x2009: /* THIN SPACE */
+ case 0x200A: /* HAIR SPACE */
+ case 0x202f: /* NARROW NO-BREAK SPACE */
+ case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
+ case 0x3000: /* IDEOGRAPHIC SPACE */
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
+ break;
+
+ case OP_HSPACE:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ GETCHARINC(c, eptr);
+ switch(c)
+ {
+ default: RRETURN(MATCH_NOMATCH);
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ case 0x1680: /* OGHAM SPACE MARK */
+ case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
+ case 0x2000: /* EN QUAD */
+ case 0x2001: /* EM QUAD */
+ case 0x2002: /* EN SPACE */
+ case 0x2003: /* EM SPACE */
+ case 0x2004: /* THREE-PER-EM SPACE */
+ case 0x2005: /* FOUR-PER-EM SPACE */
+ case 0x2006: /* SIX-PER-EM SPACE */
+ case 0x2007: /* FIGURE SPACE */
+ case 0x2008: /* PUNCTUATION SPACE */
+ case 0x2009: /* THIN SPACE */
+ case 0x200A: /* HAIR SPACE */
+ case 0x202f: /* NARROW NO-BREAK SPACE */
+ case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
+ case 0x3000: /* IDEOGRAPHIC SPACE */
+ break;
+ }
+ }
+ break;
+
+ case OP_NOT_VSPACE:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ GETCHARINC(c, eptr);
+ switch(c)
+ {
+ default: break;
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ case 0x2028: /* LINE SEPARATOR */
+ case 0x2029: /* PARAGRAPH SEPARATOR */
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
+ break;
+
+ case OP_VSPACE:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ GETCHARINC(c, eptr);
+ switch(c)
+ {
+ default: RRETURN(MATCH_NOMATCH);
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ case 0x2028: /* LINE SEPARATOR */
+ case 0x2029: /* PARAGRAPH SEPARATOR */
+ break;
+ }
+ }
+ break;
+
case OP_NOT_DIGIT:
for (i = 1; i <= min; i++)
{
@@ -2864,6 +3125,70 @@ for (;;)
}
break;
+ case OP_NOT_HSPACE:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ switch(*eptr++)
+ {
+ default: break;
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
+ break;
+
+ case OP_HSPACE:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ switch(*eptr++)
+ {
+ default: RRETURN(MATCH_NOMATCH);
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ break;
+ }
+ }
+ break;
+
+ case OP_NOT_VSPACE:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ switch(*eptr++)
+ {
+ default: break;
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
+ break;
+
+ case OP_VSPACE:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+ switch(*eptr++)
+ {
+ default: RRETURN(MATCH_NOMATCH);
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ break;
+ }
+ }
+ break;
+
case OP_NOT_DIGIT:
for (i = 1; i <= min; i++)
if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
@@ -2919,7 +3244,7 @@ for (;;)
case PT_ANY:
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
GETCHARINC(c, eptr);
@@ -2930,7 +3255,7 @@ for (;;)
case PT_LAMP:
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
GETCHARINC(c, eptr);
@@ -2945,7 +3270,7 @@ for (;;)
case PT_GC:
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
GETCHARINC(c, eptr);
@@ -2958,7 +3283,7 @@ for (;;)
case PT_PC:
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
GETCHARINC(c, eptr);
@@ -2971,7 +3296,7 @@ for (;;)
case PT_SC:
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
GETCHARINC(c, eptr);
@@ -2993,7 +3318,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
GETCHARINCTEST(c, eptr);
@@ -3022,7 +3347,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject ||
(ctype == OP_ANY && (ims & PCRE_DOTALL) == 0 &&
@@ -3055,6 +3380,90 @@ for (;;)
}
break;
+ case OP_NOT_HSPACE:
+ switch(c)
+ {
+ default: break;
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ case 0x1680: /* OGHAM SPACE MARK */
+ case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
+ case 0x2000: /* EN QUAD */
+ case 0x2001: /* EM QUAD */
+ case 0x2002: /* EN SPACE */
+ case 0x2003: /* EM SPACE */
+ case 0x2004: /* THREE-PER-EM SPACE */
+ case 0x2005: /* FOUR-PER-EM SPACE */
+ case 0x2006: /* SIX-PER-EM SPACE */
+ case 0x2007: /* FIGURE SPACE */
+ case 0x2008: /* PUNCTUATION SPACE */
+ case 0x2009: /* THIN SPACE */
+ case 0x200A: /* HAIR SPACE */
+ case 0x202f: /* NARROW NO-BREAK SPACE */
+ case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
+ case 0x3000: /* IDEOGRAPHIC SPACE */
+ RRETURN(MATCH_NOMATCH);
+ }
+ break;
+
+ case OP_HSPACE:
+ switch(c)
+ {
+ default: RRETURN(MATCH_NOMATCH);
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ case 0x1680: /* OGHAM SPACE MARK */
+ case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
+ case 0x2000: /* EN QUAD */
+ case 0x2001: /* EM QUAD */
+ case 0x2002: /* EN SPACE */
+ case 0x2003: /* EM SPACE */
+ case 0x2004: /* THREE-PER-EM SPACE */
+ case 0x2005: /* FOUR-PER-EM SPACE */
+ case 0x2006: /* SIX-PER-EM SPACE */
+ case 0x2007: /* FIGURE SPACE */
+ case 0x2008: /* PUNCTUATION SPACE */
+ case 0x2009: /* THIN SPACE */
+ case 0x200A: /* HAIR SPACE */
+ case 0x202f: /* NARROW NO-BREAK SPACE */
+ case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
+ case 0x3000: /* IDEOGRAPHIC SPACE */
+ break;
+ }
+ break;
+
+ case OP_NOT_VSPACE:
+ switch(c)
+ {
+ default: break;
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ case 0x2028: /* LINE SEPARATOR */
+ case 0x2029: /* PARAGRAPH SEPARATOR */
+ RRETURN(MATCH_NOMATCH);
+ }
+ break;
+
+ case OP_VSPACE:
+ switch(c)
+ {
+ default: RRETURN(MATCH_NOMATCH);
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ case 0x2028: /* LINE SEPARATOR */
+ case 0x2029: /* PARAGRAPH SEPARATOR */
+ break;
+ }
+ break;
+
case OP_NOT_DIGIT:
if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
RRETURN(MATCH_NOMATCH);
@@ -3096,7 +3505,7 @@ for (;;)
{
for (fi = min;; fi++)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max || eptr >= md->end_subject ||
((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr)))
@@ -3126,6 +3535,54 @@ for (;;)
}
break;
+ case OP_NOT_HSPACE:
+ switch(c)
+ {
+ default: break;
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ RRETURN(MATCH_NOMATCH);
+ }
+ break;
+
+ case OP_HSPACE:
+ switch(c)
+ {
+ default: RRETURN(MATCH_NOMATCH);
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ break;
+ }
+ break;
+
+ case OP_NOT_VSPACE:
+ switch(c)
+ {
+ default: break;
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ RRETURN(MATCH_NOMATCH);
+ }
+ break;
+
+ case OP_VSPACE:
+ switch(c)
+ {
+ default: RRETURN(MATCH_NOMATCH);
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ break;
+ }
+ break;
+
case OP_NOT_DIGIT:
if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
break;
@@ -3242,7 +3699,7 @@ for (;;)
if (possessive) continue;
for(;;)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */
BACKCHAR(eptr);
@@ -3278,7 +3735,7 @@ for (;;)
if (possessive) continue;
for(;;)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */
for (;;) /* Move back over one extended */
@@ -3387,6 +3844,70 @@ for (;;)
}
break;
+ case OP_NOT_HSPACE:
+ case OP_HSPACE:
+ for (i = min; i < max; i++)
+ {
+ BOOL gotspace;
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(c, eptr, len);
+ switch(c)
+ {
+ default: gotspace = FALSE; break;
+ case 0x09: /* HT */
+ case 0x20: /* SPACE */
+ case 0xa0: /* NBSP */
+ case 0x1680: /* OGHAM SPACE MARK */
+ case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
+ case 0x2000: /* EN QUAD */
+ case 0x2001: /* EM QUAD */
+ case 0x2002: /* EN SPACE */
+ case 0x2003: /* EM SPACE */
+ case 0x2004: /* THREE-PER-EM SPACE */
+ case 0x2005: /* FOUR-PER-EM SPACE */
+ case 0x2006: /* SIX-PER-EM SPACE */
+ case 0x2007: /* FIGURE SPACE */
+ case 0x2008: /* PUNCTUATION SPACE */
+ case 0x2009: /* THIN SPACE */
+ case 0x200A: /* HAIR SPACE */
+ case 0x202f: /* NARROW NO-BREAK SPACE */
+ case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
+ case 0x3000: /* IDEOGRAPHIC SPACE */
+ gotspace = TRUE;
+ break;
+ }
+ if (gotspace == (ctype == OP_NOT_HSPACE)) break;
+ eptr += len;
+ }
+ break;
+
+ case OP_NOT_VSPACE:
+ case OP_VSPACE:
+ for (i = min; i < max; i++)
+ {
+ BOOL gotspace;
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(c, eptr, len);
+ switch(c)
+ {
+ default: gotspace = FALSE; break;
+ case 0x0a: /* LF */
+ case 0x0b: /* VT */
+ case 0x0c: /* FF */
+ case 0x0d: /* CR */
+ case 0x85: /* NEL */
+ case 0x2028: /* LINE SEPARATOR */
+ case 0x2029: /* PARAGRAPH SEPARATOR */
+ gotspace = TRUE;
+ break;
+ }
+ if (gotspace == (ctype == OP_NOT_VSPACE)) break;
+ eptr += len;
+ }
+ break;
+
case OP_NOT_DIGIT:
for (i = min; i < max; i++)
{
@@ -3462,7 +3983,7 @@ for (;;)
if (possessive) continue;
for(;;)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM46);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */
BACKCHAR(eptr);
@@ -3513,6 +4034,48 @@ for (;;)
}
break;
+ case OP_NOT_HSPACE:
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject) break;
+ c = *eptr;
+ if (c == 0x09 || c == 0x20 || c == 0xa0) break;
+ eptr++;
+ }
+ break;
+
+ case OP_HSPACE:
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject) break;
+ c = *eptr;
+ if (c != 0x09 && c != 0x20 && c != 0xa0) break;
+ eptr++;
+ }
+ break;
+
+ case OP_NOT_VSPACE:
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject) break;
+ c = *eptr;
+ if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85)
+ break;
+ eptr++;
+ }
+ break;
+
+ case OP_VSPACE:
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject) break;
+ c = *eptr;
+ if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85)
+ break;
+ eptr++;
+ }
+ break;
+
case OP_NOT_DIGIT:
for (i = min; i < max; i++)
{
@@ -3576,7 +4139,7 @@ for (;;)
if (possessive) continue;
while (eptr >= pp)
{
- RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);
+ RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM47);
eptr--;
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
}
@@ -3602,6 +4165,29 @@ for (;;)
} /* End of main loop */
/* Control never reaches here */
+
+
+/* When compiling to use the heap rather than the stack for recursive calls to
+match(), the RRETURN() macro jumps here. The number that is saved in
+frame->Xwhere indicates which label we actually want to return to. */
+
+#ifdef NO_RECURSE
+#define LBL(val) case val: goto L_RM##val;
+HEAP_RETURN:
+switch (frame->Xwhere)
+ {
+ 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(17) LBL(18) LBL(19) LBL(20) LBL(21) LBL(22) LBL(23) LBL(24)
+ LBL(25) LBL(26) LBL(27) LBL(28) LBL(29) LBL(30) LBL(31) LBL(32)
+ LBL(33) LBL(34) LBL(35) LBL(36) LBL(37) LBL(38) LBL(39) LBL(40)
+ LBL(41) LBL(42) LBL(43) LBL(44) LBL(45) LBL(46) LBL(47)
+ default:
+ DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));
+ return PCRE_ERROR_INTERNAL;
+ }
+#undef LBL
+#endif /* NO_RECURSE */
}
@@ -3614,6 +4200,7 @@ Undefine all the macros that were defined above to handle this. */
#ifdef NO_RECURSE
#undef eptr
#undef ecode
+#undef mstart
#undef offset_top
#undef ims
#undef eptrb
@@ -3686,7 +4273,7 @@ Returns: > 0 => success; value is the number of elements filled in
< -1 => some kind of unexpected problem
*/
-PCRE_DATA_SCOPE int
+PCRE_EXP_DEFN int
pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,
int offsetcount)
@@ -3802,10 +4389,10 @@ md->eptrchain = eptrchain; /* Make workspace generally available */
md->lcc = tables + lcc_offset;
md->ctypes = tables + ctypes_offset;
-/* Handle different types of newline. The two bits give four cases. If nothing
-is set at run time, whatever was used at compile time applies. */
+/* Handle different types of newline. The three bits give eight cases. If
+nothing is set at run time, whatever was used at compile time applies. */
-switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : options) &
+switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)options) &
PCRE_NEWLINE_BITS)
{
case 0: newline = NEWLINE; break; /* Compile-time default */
@@ -3814,10 +4401,15 @@ switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : options) &
case PCRE_NEWLINE_CR+
PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
case PCRE_NEWLINE_ANY: newline = -1; break;
+ case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
default: return PCRE_ERROR_BADNEWLINE;
}
-if (newline < 0)
+if (newline == -2)
+ {
+ md->nltype = NLTYPE_ANYCRLF;
+ }
+else if (newline < 0)
{
md->nltype = NLTYPE_ANY;
}
@@ -3992,6 +4584,16 @@ for(;;)
{
while (start_match <= end_subject && !WAS_NEWLINE(start_match))
start_match++;
+
+ /* If we have just passed a CR and the newline option is ANY or ANYCRLF,
+ and we are now at a LF, advance the match position by one more character.
+ */
+
+ if (start_match[-1] == '\r' &&
+ (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
+ start_match < end_subject &&
+ *start_match == '\n')
+ start_match++;
}
}
@@ -4078,10 +4680,11 @@ for(;;)
/* OK, we can now run the match. */
- md->start_match = start_match;
+ md->start_match_ptr = start_match; /* Insurance */
md->match_call_count = 0;
md->eptrn = 0; /* Next free eptrchain slot */
- rc = match(start_match, md->start_code, 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. */
@@ -4107,11 +4710,14 @@ for(;;)
if (anchored || start_match > end_subject) break;
- /* If we have just passed a CR and the newline option is CRLF or ANY, and we
- are now at a LF, advance the match position by one more character. */
+ /* If we have just passed a CR and the newline option is CRLF or ANY or
+ ANYCRLF, and we are now at a LF, advance the match position by one more
+ character. */
if (start_match[-1] == '\r' &&
- (md->nltype == NLTYPE_ANY || md->nllen == 2) &&
+ (md->nltype == NLTYPE_ANY ||
+ md->nltype == NLTYPE_ANYCRLF ||
+ md->nllen == 2) &&
start_match < end_subject &&
*start_match == '\n')
start_match++;
@@ -4158,11 +4764,13 @@ if (rc == MATCH_MATCH)
rc = md->offset_overflow? 0 : md->end_offset_top/2;
- /* If there is space, set up the whole thing as substring 0. */
+ /* If there is space, set up the whole thing as substring 0. The value of
+ md->start_match_ptr might be modified if \K was encountered on the success
+ matching path. */
if (offsetcount < 2) rc = 0; else
{
- offsets[0] = start_match - md->start_subject;
+ offsets[0] = md->start_match_ptr - md->start_subject;
offsets[1] = md->end_match_ptr - md->start_subject;
}
diff --git a/ext/pcre/pcrelib/pcre_fullinfo.c b/ext/pcre/pcrelib/pcre_fullinfo.c
index 4a8edc6f47..797eddecf2 100644
--- a/ext/pcre/pcrelib/pcre_fullinfo.c
+++ b/ext/pcre/pcrelib/pcre_fullinfo.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -61,7 +61,7 @@ Arguments:
Returns: 0 if data returned, negative on error
*/
-PCRE_DATA_SCOPE int
+PCRE_EXP_DEFN int
pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,
void *where)
{
@@ -140,6 +140,14 @@ switch (what)
*((const uschar **)where) = (const uschar *)(_pcre_default_tables);
break;
+ case PCRE_INFO_OKPARTIAL:
+ *((int *)where) = (re->options & PCRE_NOPARTIAL) == 0;
+ break;
+
+ case PCRE_INFO_JCHANGED:
+ *((int *)where) = (re->options & PCRE_JCHANGED) != 0;
+ break;
+
default: return PCRE_ERROR_BADOPTION;
}
diff --git a/ext/pcre/pcrelib/pcre_get.c b/ext/pcre/pcrelib/pcre_get.c
index 856e955a5c..ba0c8cb21f 100644
--- a/ext/pcre/pcrelib/pcre_get.c
+++ b/ext/pcre/pcrelib/pcre_get.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
diff --git a/ext/pcre/pcrelib/pcre_globals.c b/ext/pcre/pcrelib/pcre_globals.c
index f29983e53b..dbde57e023 100644
--- a/ext/pcre/pcrelib/pcre_globals.c
+++ b/ext/pcre/pcrelib/pcre_globals.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -46,37 +46,14 @@ indirection. These values can be changed by the caller, but are shared between
all threads. However, when compiling for Virtual Pascal, things are done
differently, and global variables are not used (see pcre.in). */
-
#include "pcre_internal.h"
-
#ifndef VPCOMPAT
-
-/**************************************************************************
-This code used to be here for use when compiling as a C++ library. However,
-according to Dair Grant it is not needed: "
-
- Including 'extern "C"' in the declaration generates an "initialized and
- declared `extern'" warning from gcc 4.0.1. Since we include pcre_internal.h,
- which includes pcre.h, which declares these prototypes within an extern "C" {}
- block, we shouldn't need the prefix here.
-
-So, from Release 7.0 I have cut this out.
-
-#ifdef __cplusplus
-extern "C" void *(*pcre_malloc)(size_t) = malloc;
-extern "C" void (*pcre_free)(void *) = free;
-extern "C" void *(*pcre_stack_malloc)(size_t) = malloc;
-extern "C" void (*pcre_stack_free)(void *) = free;
-extern "C" int (*pcre_callout)(pcre_callout_block *) = NULL;
-#else
-**************************************************************************/
-
-void *(*pcre_malloc)(size_t) = malloc;
-void (*pcre_free)(void *) = free;
-void *(*pcre_stack_malloc)(size_t) = malloc;
-void (*pcre_stack_free)(void *) = free;
-int (*pcre_callout)(pcre_callout_block *) = NULL;
+PCRE_EXP_DATA_DEFN void *(*pcre_malloc)(size_t) = malloc;
+PCRE_EXP_DATA_DEFN void (*pcre_free)(void *) = free;
+PCRE_EXP_DATA_DEFN void *(*pcre_stack_malloc)(size_t) = malloc;
+PCRE_EXP_DATA_DEFN void (*pcre_stack_free)(void *) = free;
+PCRE_EXP_DATA_DEFN int (*pcre_callout)(pcre_callout_block *) = NULL;
#endif
/* End of pcre_globals.c */
diff --git a/ext/pcre/pcrelib/pcre_info.c b/ext/pcre/pcrelib/pcre_info.c
index b318b93eaa..52ac23f708 100644
--- a/ext/pcre/pcrelib/pcre_info.c
+++ b/ext/pcre/pcrelib/pcre_info.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,7 @@ Returns: number of capturing subpatterns
or negative values on error
*/
-PCRE_DATA_SCOPE int
+PCRE_EXP_DEFN int
pcre_info(const pcre *argument_re, int *optptr, int *first_byte)
{
real_pcre internal_re;
diff --git a/ext/pcre/pcrelib/pcre_internal.h b/ext/pcre/pcrelib/pcre_internal.h
index 4034cf4574..d87b95cb27 100644
--- a/ext/pcre/pcrelib/pcre_internal.h
+++ b/ext/pcre/pcrelib/pcre_internal.h
@@ -7,7 +7,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -69,11 +69,7 @@ be absolutely sure we get our version. */
/* Get the definitions provided by running "configure" */
-#ifdef PHP_WIN32
-# include "config.w32.h"
-#else
-# include <php_config.h>
-#endif
+#include "config.h"
/* Standard C headers plus the external interface definition. The only time
setjmp and stdarg are used is when NO_RECURSE is set. */
@@ -87,8 +83,58 @@ setjmp and stdarg are used is when NO_RECURSE is set. */
#include <stdlib.h>
#include <string.h>
-#ifndef PCRE_SPY
-#define PCRE_DEFINITION /* Win32 __declspec(export) trigger for .dll */
+/* When compiling a DLL for Windows, the exported symbols have to be declared
+using some MS magic. I found some useful information on this web page:
+http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the
+information there, using __declspec(dllexport) without "extern" we have a
+definition; with "extern" we have a declaration. The settings here override the
+setting in pcre.h (which is included below); it defines only PCRE_EXP_DECL,
+which is all that is needed for applications (they just import the symbols). We
+use:
+
+ PCRE_EXP_DECL for declarations
+ PCRE_EXP_DEFN for definitions of exported functions
+ PCRE_EXP_DATA_DEFN for definitions of exported variables
+
+The reason for the two DEFN macros is that in non-Windows environments, one
+does not want to have "extern" before variable definitions because it leads to
+compiler warnings. So we distinguish between functions and variables. In
+Windows, the two should always be the same.
+
+The reason for wrapping this in #ifndef PCRE_EXP_DECL is so that pcretest,
+which is an application, but needs to import this file in order to "peek" at
+internals, can #include pcre.h first to get an application's-eye view.
+
+In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,
+special-purpose environments) might want to stick other stuff in front of
+exported symbols. That's why, in the non-Windows case, we set PCRE_EXP_DEFN and
+PCRE_EXP_DATA_DEFN only if they are not already set. */
+
+#ifndef PCRE_EXP_DECL
+# ifdef _WIN32
+# ifdef DLL_EXPORT
+# define PCRE_EXP_DECL extern __declspec(dllexport)
+# define PCRE_EXP_DEFN __declspec(dllexport)
+# define PCRE_EXP_DATA_DEFN __declspec(dllexport)
+# else
+# define PCRE_EXP_DECL extern
+# define PCRE_EXP_DEFN
+# define PCRE_EXP_DATA_DEFN
+# endif
+#
+# else
+# ifdef __cplusplus
+# define PCRE_EXP_DECL extern "C"
+# else
+# define PCRE_EXP_DECL extern
+# endif
+# ifndef PCRE_EXP_DEFN
+# define PCRE_EXP_DEFN PCRE_EXP_DECL
+# endif
+# ifndef PCRE_EXP_DATA_DEFN
+# define PCRE_EXP_DATA_DEFN
+# endif
+# endif
#endif
/* We need to have types that specify unsigned 16-bit and 32-bit integers. We
@@ -129,21 +175,22 @@ characters only go up to 0x7fffffff (though Unicode doesn't go beyond
#define NOTACHAR 0xffffffff
/* PCRE is able to support several different kinds of newline (CR, LF, CRLF,
-and "all" at present). The following macros are used to package up testing for
-newlines. NLBLOCK, PSSTART, and PSEND are defined in the various modules to
-indicate in which datablock the parameters exist, and what the start/end of
-string field names are. */
+"any" and "anycrlf" at present). The following macros are used to package up
+testing for newlines. NLBLOCK, PSSTART, and PSEND are defined in the various
+modules to indicate in which datablock the parameters exist, and what the
+start/end of string field names are. */
-#define NLTYPE_FIXED 0 /* Newline is a fixed length string */
-#define NLTYPE_ANY 1 /* Newline is any Unicode line ending */
+#define NLTYPE_FIXED 0 /* Newline is a fixed length string */
+#define NLTYPE_ANY 1 /* Newline is any Unicode line ending */
+#define NLTYPE_ANYCRLF 2 /* Newline is CR, LF, or CRLF */
/* This macro checks for a newline at the given position */
#define IS_NEWLINE(p) \
((NLBLOCK->nltype != NLTYPE_FIXED)? \
((p) < NLBLOCK->PSEND && \
- _pcre_is_newline((p), NLBLOCK->PSEND, &(NLBLOCK->nllen), utf8) \
- ) \
+ _pcre_is_newline((p), NLBLOCK->nltype, NLBLOCK->PSEND, &(NLBLOCK->nllen),\
+ utf8)) \
: \
((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \
(p)[0] == NLBLOCK->nl[0] && \
@@ -156,8 +203,8 @@ string field names are. */
#define WAS_NEWLINE(p) \
((NLBLOCK->nltype != NLTYPE_FIXED)? \
((p) > NLBLOCK->PSSTART && \
- _pcre_was_newline((p), NLBLOCK->PSSTART, &(NLBLOCK->nllen), utf8) \
- ) \
+ _pcre_was_newline((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \
+ &(NLBLOCK->nllen), utf8)) \
: \
((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \
(p)[-NLBLOCK->nllen] == NLBLOCK->nl[0] && \
@@ -182,10 +229,12 @@ must begin with PCRE_. */
#define USPTR const unsigned char *
#endif
+
+
/* Include the public PCRE header and the definitions of UCP character property
values. */
-#include "pcre.h"
+#include <pcre.h>
#include "ucp.h"
/* When compiling for use with the Virtual Pascal compiler, these functions
@@ -193,7 +242,9 @@ need to have their names changed. PCRE must be compiled with the -DVPCOMPAT
option on the command line. */
#ifdef VPCOMPAT
+#define strlen(s) _strlen(s)
#define strncmp(s1,s2,m) _strncmp(s1,s2,m)
+#define memcmp(s,c,n) _memcmp(s,c,n)
#define memcpy(d,s,n) _memcpy(d,s,n)
#define memmove(d,s,n) _memmove(d,s,n)
#define memset(s,c,n) _memset(s,c,n)
@@ -202,23 +253,31 @@ option on the command line. */
/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),
define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY
is set. Otherwise, include an emulating function for those systems that have
-neither (there some non-Unix environments where this is the case). This assumes
-that all calls to memmove are moving strings upwards in store, which is the
-case in PCRE. */
+neither (there some non-Unix environments where this is the case). */
-#if ! HAVE_MEMMOVE
+#ifndef HAVE_MEMMOVE
#undef memmove /* some systems may have a macro */
-#if HAVE_BCOPY
+#ifdef HAVE_BCOPY
#define memmove(a, b, c) bcopy(b, a, c)
#else /* HAVE_BCOPY */
static void *
-pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n)
+pcre_memmove(void *d, const void *s, size_t n)
{
size_t i;
-dest += n;
-src += n;
-for (i = 0; i < n; ++i) *(--dest) = *(--src);
-return dest;
+unsigned char *dest = (unsigned char *)d;
+const unsigned char *src = (const unsigned char *)s;
+if (dest > src)
+ {
+ dest += n;
+ src += n;
+ for (i = 0; i < n; ++i) *(--dest) = *(--src);
+ return (void *)dest;
+ }
+else
+ {
+ for (i = 0; i < n; ++i) *dest++ = *src++;
+ return (void *)(dest - n);
+ }
}
#define memmove(a, b, c) pcre_memmove(a, b, c)
#endif /* not HAVE_BCOPY */
@@ -443,7 +502,8 @@ bits. */
/* Masks for identifying the public options that are permitted at compile
time, run time, or study time, respectively. */
-#define PCRE_NEWLINE_BITS (PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|PCRE_NEWLINE_ANY)
+#define PCRE_NEWLINE_BITS (PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|PCRE_NEWLINE_ANY| \
+ PCRE_NEWLINE_ANYCRLF)
#define PUBLIC_OPTIONS \
(PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
@@ -545,9 +605,9 @@ ESC_Z to detect the types that may be repeated. These are the types that
consume characters. If any new escapes are put in between that don't consume a
character, that code will have to change. */
-enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,
- ESC_w, ESC_dum1, ESC_C, ESC_P, ESC_p, ESC_R, ESC_X, ESC_Z, ESC_z,
- ESC_E, ESC_Q, ESC_k, ESC_REF };
+enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
+ ESC_W, ESC_w, ESC_dum1, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H, ESC_h,
+ 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
@@ -569,133 +629,138 @@ enum {
OP_SOD, /* 1 Start of data: \A */
OP_SOM, /* 2 Start of match (subject + offset): \G */
- OP_NOT_WORD_BOUNDARY, /* 3 \B */
- OP_WORD_BOUNDARY, /* 4 \b */
- OP_NOT_DIGIT, /* 5 \D */
- OP_DIGIT, /* 6 \d */
- OP_NOT_WHITESPACE, /* 7 \S */
- OP_WHITESPACE, /* 8 \s */
- OP_NOT_WORDCHAR, /* 9 \W */
- OP_WORDCHAR, /* 10 \w */
- OP_ANY, /* 11 Match any character */
- OP_ANYBYTE, /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */
- OP_NOTPROP, /* 13 \P (not Unicode property) */
- OP_PROP, /* 14 \p (Unicode property) */
- OP_ANYNL, /* 15 \R (any newline sequence) */
- OP_EXTUNI, /* 16 \X (extended Unicode sequence */
- OP_EODN, /* 17 End of data or \n at end of data: \Z. */
- OP_EOD, /* 18 End of data: \z */
-
- OP_OPT, /* 19 Set runtime options */
- OP_CIRC, /* 20 Start of line - varies with multiline switch */
- OP_DOLL, /* 21 End of line - varies with multiline switch */
- OP_CHAR, /* 22 Match one character, casefully */
- OP_CHARNC, /* 23 Match one character, caselessly */
- OP_NOT, /* 24 Match one character, not the following one */
-
- OP_STAR, /* 25 The maximizing and minimizing versions of */
- OP_MINSTAR, /* 26 these six opcodes must come in pairs, with */
- OP_PLUS, /* 27 the minimizing one second. */
- OP_MINPLUS, /* 28 This first set applies to single characters.*/
- OP_QUERY, /* 29 */
- OP_MINQUERY, /* 30 */
-
- OP_UPTO, /* 31 From 0 to n matches */
- OP_MINUPTO, /* 32 */
- OP_EXACT, /* 33 Exactly n matches */
-
- OP_POSSTAR, /* 34 Possessified star */
- OP_POSPLUS, /* 35 Possessified plus */
- OP_POSQUERY, /* 36 Posesssified query */
- OP_POSUPTO, /* 37 Possessified upto */
-
- OP_NOTSTAR, /* 38 The maximizing and minimizing versions of */
- OP_NOTMINSTAR, /* 39 these six opcodes must come in pairs, with */
- OP_NOTPLUS, /* 40 the minimizing one second. They must be in */
- OP_NOTMINPLUS, /* 41 exactly the same order as those above. */
- OP_NOTQUERY, /* 42 This set applies to "not" single characters. */
- OP_NOTMINQUERY, /* 43 */
-
- OP_NOTUPTO, /* 44 From 0 to n matches */
- OP_NOTMINUPTO, /* 45 */
- OP_NOTEXACT, /* 46 Exactly n matches */
-
- OP_NOTPOSSTAR, /* 47 Possessified versions */
- OP_NOTPOSPLUS, /* 48 */
- OP_NOTPOSQUERY, /* 49 */
- OP_NOTPOSUPTO, /* 50 */
-
- OP_TYPESTAR, /* 51 The maximizing and minimizing versions of */
- OP_TYPEMINSTAR, /* 52 these six opcodes must come in pairs, with */
- OP_TYPEPLUS, /* 53 the minimizing one second. These codes must */
- OP_TYPEMINPLUS, /* 54 be in exactly the same order as those above. */
- OP_TYPEQUERY, /* 55 This set applies to character types such as \d */
- OP_TYPEMINQUERY, /* 56 */
-
- OP_TYPEUPTO, /* 57 From 0 to n matches */
- OP_TYPEMINUPTO, /* 58 */
- OP_TYPEEXACT, /* 59 Exactly n matches */
-
- OP_TYPEPOSSTAR, /* 60 Possessified versions */
- OP_TYPEPOSPLUS, /* 61 */
- OP_TYPEPOSQUERY, /* 62 */
- OP_TYPEPOSUPTO, /* 63 */
-
- OP_CRSTAR, /* 64 The maximizing and minimizing versions of */
- OP_CRMINSTAR, /* 65 all these opcodes must come in pairs, with */
- OP_CRPLUS, /* 66 the minimizing one second. These codes must */
- OP_CRMINPLUS, /* 67 be in exactly the same order as those above. */
- OP_CRQUERY, /* 68 These are for character classes and back refs */
- OP_CRMINQUERY, /* 69 */
- OP_CRRANGE, /* 70 These are different to the three sets above. */
- OP_CRMINRANGE, /* 71 */
-
- OP_CLASS, /* 72 Match a character class, chars < 256 only */
- OP_NCLASS, /* 73 Same, but the bitmap was created from a negative
+ OP_SET_SOM, /* 3 Set start of match (\K) */
+ OP_NOT_WORD_BOUNDARY, /* 4 \B */
+ OP_WORD_BOUNDARY, /* 5 \b */
+ OP_NOT_DIGIT, /* 6 \D */
+ OP_DIGIT, /* 7 \d */
+ OP_NOT_WHITESPACE, /* 8 \S */
+ OP_WHITESPACE, /* 9 \s */
+ OP_NOT_WORDCHAR, /* 10 \W */
+ OP_WORDCHAR, /* 11 \w */
+ OP_ANY, /* 12 Match any character */
+ OP_ANYBYTE, /* 13 Match any byte (\C); different to OP_ANY for UTF-8 */
+ OP_NOTPROP, /* 14 \P (not Unicode property) */
+ OP_PROP, /* 15 \p (Unicode property) */
+ OP_ANYNL, /* 16 \R (any newline sequence) */
+ OP_NOT_HSPACE, /* 17 \H (not horizontal whitespace) */
+ OP_HSPACE, /* 18 \h (horizontal whitespace) */
+ OP_NOT_VSPACE, /* 19 \V (not vertical whitespace) */
+ OP_VSPACE, /* 20 \v (vertical whitespace) */
+ OP_EXTUNI, /* 21 \X (extended Unicode sequence */
+ OP_EODN, /* 22 End of data or \n at end of data: \Z. */
+ OP_EOD, /* 23 End of data: \z */
+
+ OP_OPT, /* 24 Set runtime options */
+ OP_CIRC, /* 25 Start of line - varies with multiline switch */
+ OP_DOLL, /* 26 End of line - varies with multiline switch */
+ OP_CHAR, /* 27 Match one character, casefully */
+ OP_CHARNC, /* 28 Match one character, caselessly */
+ OP_NOT, /* 29 Match one character, not the following one */
+
+ OP_STAR, /* 30 The maximizing and minimizing versions of */
+ OP_MINSTAR, /* 31 these six opcodes must come in pairs, with */
+ OP_PLUS, /* 32 the minimizing one second. */
+ OP_MINPLUS, /* 33 This first set applies to single characters.*/
+ OP_QUERY, /* 34 */
+ OP_MINQUERY, /* 35 */
+
+ OP_UPTO, /* 36 From 0 to n matches */
+ OP_MINUPTO, /* 37 */
+ OP_EXACT, /* 38 Exactly n matches */
+
+ OP_POSSTAR, /* 39 Possessified star */
+ OP_POSPLUS, /* 40 Possessified plus */
+ OP_POSQUERY, /* 41 Posesssified query */
+ OP_POSUPTO, /* 42 Possessified upto */
+
+ OP_NOTSTAR, /* 43 The maximizing and minimizing versions of */
+ OP_NOTMINSTAR, /* 44 these six opcodes must come in pairs, with */
+ OP_NOTPLUS, /* 45 the minimizing one second. They must be in */
+ OP_NOTMINPLUS, /* 46 exactly the same order as those above. */
+ OP_NOTQUERY, /* 47 This set applies to "not" single characters. */
+ OP_NOTMINQUERY, /* 48 */
+
+ OP_NOTUPTO, /* 49 From 0 to n matches */
+ OP_NOTMINUPTO, /* 50 */
+ OP_NOTEXACT, /* 51 Exactly n matches */
+
+ OP_NOTPOSSTAR, /* 52 Possessified versions */
+ OP_NOTPOSPLUS, /* 53 */
+ OP_NOTPOSQUERY, /* 54 */
+ OP_NOTPOSUPTO, /* 55 */
+
+ OP_TYPESTAR, /* 56 The maximizing and minimizing versions of */
+ OP_TYPEMINSTAR, /* 57 these six opcodes must come in pairs, with */
+ OP_TYPEPLUS, /* 58 the minimizing one second. These codes must */
+ OP_TYPEMINPLUS, /* 59 be in exactly the same order as those above. */
+ OP_TYPEQUERY, /* 60 This set applies to character types such as \d */
+ OP_TYPEMINQUERY, /* 61 */
+
+ OP_TYPEUPTO, /* 62 From 0 to n matches */
+ OP_TYPEMINUPTO, /* 63 */
+ OP_TYPEEXACT, /* 64 Exactly n matches */
+
+ OP_TYPEPOSSTAR, /* 65 Possessified versions */
+ OP_TYPEPOSPLUS, /* 66 */
+ OP_TYPEPOSQUERY, /* 67 */
+ OP_TYPEPOSUPTO, /* 68 */
+
+ OP_CRSTAR, /* 69 The maximizing and minimizing versions of */
+ OP_CRMINSTAR, /* 70 all these opcodes must come in pairs, with */
+ OP_CRPLUS, /* 71 the minimizing one second. These codes must */
+ OP_CRMINPLUS, /* 72 be in exactly the same order as those above. */
+ OP_CRQUERY, /* 73 These are for character classes and back refs */
+ OP_CRMINQUERY, /* 74 */
+ OP_CRRANGE, /* 75 These are different to the three sets above. */
+ OP_CRMINRANGE, /* 76 */
+
+ OP_CLASS, /* 77 Match a character class, chars < 256 only */
+ OP_NCLASS, /* 78 Same, but the bitmap was created from a negative
class - the difference is relevant only when a UTF-8
character > 255 is encountered. */
- OP_XCLASS, /* 74 Extended class for handling UTF-8 chars within the
+ OP_XCLASS, /* 79 Extended class for handling UTF-8 chars within the
class. This does both positive and negative. */
- OP_REF, /* 75 Match a back reference */
- OP_RECURSE, /* 76 Match a numbered subpattern (possibly recursive) */
- OP_CALLOUT, /* 77 Call out to external function if provided */
+ OP_REF, /* 80 Match a back reference */
+ OP_RECURSE, /* 81 Match a numbered subpattern (possibly recursive) */
+ OP_CALLOUT, /* 82 Call out to external function if provided */
- OP_ALT, /* 78 Start of alternation */
- OP_KET, /* 79 End of group that doesn't have an unbounded repeat */
- OP_KETRMAX, /* 80 These two must remain together and in this */
- OP_KETRMIN, /* 81 order. They are for groups the repeat for ever. */
+ OP_ALT, /* 83 Start of alternation */
+ OP_KET, /* 84 End of group that doesn't have an unbounded repeat */
+ OP_KETRMAX, /* 85 These two must remain together and in this */
+ OP_KETRMIN, /* 86 order. They are for groups the repeat for ever. */
/* The assertions must come before BRA, CBRA, ONCE, and COND.*/
- OP_ASSERT, /* 82 Positive lookahead */
- OP_ASSERT_NOT, /* 83 Negative lookahead */
- OP_ASSERTBACK, /* 84 Positive lookbehind */
- OP_ASSERTBACK_NOT, /* 85 Negative lookbehind */
- OP_REVERSE, /* 86 Move pointer back - used in lookbehind assertions */
+ OP_ASSERT, /* 87 Positive lookahead */
+ OP_ASSERT_NOT, /* 88 Negative lookahead */
+ OP_ASSERTBACK, /* 89 Positive lookbehind */
+ OP_ASSERTBACK_NOT, /* 90 Negative lookbehind */
+ OP_REVERSE, /* 91 Move pointer back - used in lookbehind assertions */
/* ONCE, BRA, CBRA, and COND must come after the assertions, with ONCE first,
as there's a test for >= ONCE for a subpattern that isn't an assertion. */
- OP_ONCE, /* 87 Atomic group */
- OP_BRA, /* 88 Start of non-capturing bracket */
- OP_CBRA, /* 89 Start of capturing bracket */
- OP_COND, /* 90 Conditional group */
+ OP_ONCE, /* 92 Atomic group */
+ OP_BRA, /* 83 Start of non-capturing bracket */
+ OP_CBRA, /* 94 Start of capturing bracket */
+ OP_COND, /* 95 Conditional group */
/* These three must follow the previous three, in the same order. There's a
check for >= SBRA to distinguish the two sets. */
- OP_SBRA, /* 91 Start of non-capturing bracket, check empty */
- OP_SCBRA, /* 92 Start of capturing bracket, check empty */
- OP_SCOND, /* 93 Conditional group, check empty */
+ OP_SBRA, /* 96 Start of non-capturing bracket, check empty */
+ OP_SCBRA, /* 97 Start of capturing bracket, check empty */
+ OP_SCOND, /* 98 Conditional group, check empty */
- OP_CREF, /* 94 Used to hold a capture number as condition */
- OP_RREF, /* 95 Used to hold a recursion number as condition */
- OP_DEF, /* 96 The DEFINE condition */
+ OP_CREF, /* 99 Used to hold a capture number as condition */
+ OP_RREF, /* 100 Used to hold a recursion number as condition */
+ OP_DEF, /* 101 The DEFINE condition */
- OP_BRAZERO, /* 97 These two must remain together and in this */
- OP_BRAMINZERO /* 98 order. */
+ OP_BRAZERO, /* 102 These two must remain together and in this */
+ OP_BRAMINZERO /* 103 order. */
};
@@ -703,10 +768,10 @@ enum {
for debugging. The macro is referenced only in pcre_printint.c. */
#define OP_NAME_LIST \
- "End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d", \
+ "End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d", \
"\\S", "\\s", "\\W", "\\w", "Any", "Anybyte", \
- "notprop", "prop", "anynl", "extuni", \
- "\\Z", "\\z", \
+ "notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v", \
+ "extuni", "\\Z", "\\z", \
"Opt", "^", "$", "char", "charnc", "not", \
"*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
"*+","++", "?+", "{", \
@@ -733,9 +798,11 @@ in UTF-8 mode. The code that uses this table must know about such things. */
#define OP_LENGTHS \
1, /* End */ \
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* \A, \G, \B, \B, \D, \d, \S, \s, \W, \w */ \
+ 1, 1, 1, 1, 1, /* \A, \G, \K, \B, \b */ \
+ 1, 1, 1, 1, 1, 1, /* \D, \d, \S, \s, \W, \w */ \
1, 1, /* Any, Anybyte */ \
- 3, 3, 1, 1, /* NOTPROP, PROP, EXTUNI, ANYNL */ \
+ 3, 3, 1, /* NOTPROP, PROP, EXTUNI */ \
+ 1, 1, 1, 1, 1, /* \R, \H, \h, \V, \v */ \
1, 1, 2, 1, 1, /* \Z, \z, Opt, ^, $ */ \
2, /* Char - the minimum length */ \
2, /* Charnc - the minimum length */ \
@@ -795,7 +862,7 @@ enum { ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9,
ERR20, ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29,
ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,
ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
- ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57 };
+ ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58 };
/* 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
@@ -884,21 +951,11 @@ typedef struct recursion_info {
struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
int group_num; /* Number of group that was called */
const uschar *after_call; /* "Return value": points after the call in the expr */
- USPTR save_start; /* Old value of md->start_match */
+ USPTR save_start; /* Old value of mstart */
int *offset_save; /* Pointer to start of saved offsets */
int saved_max; /* Number of saved offsets */
} recursion_info;
-/* When compiling in a mode that doesn't use recursive calls to match(),
-a structure is used to remember local variables on the heap. It is defined in
-pcre_exec.c, close to the match() function, so that it is easy to keep it in
-step with any changes of local variable. However, the pointer to the current
-frame must be saved in some "static" place over a longjmp(). We declare the
-structure here so that we can put a pointer in the match_data structure. NOTE:
-This isn't used for a "normal" compilation of pcre. */
-
-struct heapframe;
-
/* Structure for building a chain of data for holding the values of the subject
pointer at the start of each subpattern, so as to detect when an empty string
has been matched by a subpattern - to break infinite loops. */
@@ -935,7 +992,7 @@ typedef struct match_data {
const uschar *start_code; /* For use when recursing */
USPTR start_subject; /* Start of the subject string */
USPTR end_subject; /* End of the subject string */
- USPTR start_match; /* Start of this match attempt */
+ USPTR start_match_ptr; /* Start of matched string */
USPTR end_match_ptr; /* Subject position at end match */
int end_offset_top; /* Highwater mark at end of match */
int capture_last; /* Most recent capture number */
@@ -944,7 +1001,6 @@ typedef struct match_data {
int eptrn; /* Next free eptrblock */
recursion_info *recursive; /* Linked list of recursion data */
void *callout_data; /* To pass back to callouts */
- struct heapframe *thisframe; /* Used only when compiling for no recursion */
} match_data;
/* A similar structure is used for the same purpose by the DFA matching
@@ -1030,16 +1086,16 @@ extern const uschar _pcre_OP_lengths[];
one of the exported public functions. They have to be "external" in the C
sense, but are not part of the PCRE public API. */
-extern BOOL _pcre_is_newline(const uschar *, const uschar *, int *,
- BOOL);
+extern BOOL _pcre_is_newline(const uschar *, int, const uschar *,
+ int *, BOOL);
extern int _pcre_ord2utf8(int, uschar *);
extern real_pcre *_pcre_try_flipped(const real_pcre *, real_pcre *,
const pcre_study_data *, pcre_study_data *);
extern int _pcre_ucp_findprop(const unsigned int, int *, int *);
extern unsigned int _pcre_ucp_othercase(const unsigned int);
extern int _pcre_valid_utf8(const uschar *, int);
-extern BOOL _pcre_was_newline(const uschar *, const uschar *, int *,
- BOOL);
+extern BOOL _pcre_was_newline(const uschar *, int, const uschar *,
+ int *, BOOL);
extern BOOL _pcre_xclass(int, const uschar *);
#endif
diff --git a/ext/pcre/pcrelib/pcre_maketables.c b/ext/pcre/pcrelib/pcre_maketables.c
index 29e40989bf..9963e13fb0 100644
--- a/ext/pcre/pcrelib/pcre_maketables.c
+++ b/ext/pcre/pcrelib/pcre_maketables.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
diff --git a/ext/pcre/pcrelib/pcre_newline.c b/ext/pcre/pcrelib/pcre_newline.c
index 348791b1ed..ae66c730f6 100644
--- a/ext/pcre/pcrelib/pcre_newline.c
+++ b/ext/pcre/pcrelib/pcre_newline.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -42,9 +42,8 @@ POSSIBILITY OF SUCH DAMAGE.
one kind of newline is to be recognized. When a newline is found, its length is
returned. In principle, we could implement several newline "types", each
referring to a different set of newline characters. At present, PCRE supports
-only NLTYPE_FIXED, which gets handled without these functions, and NLTYPE_ALL,
-so for now the type isn't passed into the functions. It can easily be added
-later if required. The full list of Unicode newline characters is taken from
+only NLTYPE_FIXED, which gets handled without these functions, NLTYPE_ANYCRLF,
+and NLTYPE_ANY. The full list of Unicode newline characters is taken from
http://unicode.org/unicode/reports/tr18/. */
@@ -61,6 +60,7 @@ string that is being processed.
Arguments:
ptr pointer to possible newline
+ type the newline type
endptr pointer to the end of the string
lenptr where to return the length
utf8 TRUE if in utf8 mode
@@ -69,12 +69,23 @@ Returns: TRUE or FALSE
*/
BOOL
-_pcre_is_newline(const uschar *ptr, const uschar *endptr, int *lenptr,
- BOOL utf8)
+_pcre_is_newline(const uschar *ptr, int type, const uschar *endptr,
+ int *lenptr, BOOL utf8)
{
int c;
if (utf8) { GETCHAR(c, ptr); } else c = *ptr;
-switch(c)
+
+if (type == NLTYPE_ANYCRLF) switch(c)
+ {
+ case 0x000a: *lenptr = 1; return TRUE; /* LF */
+ case 0x000d: *lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a)? 2 : 1;
+ return TRUE; /* CR */
+ default: return FALSE;
+ }
+
+/* NLTYPE_ANY */
+
+else switch(c)
{
case 0x000a: /* LF */
case 0x000b: /* VT */
@@ -99,6 +110,7 @@ the string that is being processed.
Arguments:
ptr pointer to possible newline
+ type the newline type
startptr pointer to the start of the string
lenptr where to return the length
utf8 TRUE if in utf8 mode
@@ -107,8 +119,8 @@ Returns: TRUE or FALSE
*/
BOOL
-_pcre_was_newline(const uschar *ptr, const uschar *startptr, int *lenptr,
- BOOL utf8)
+_pcre_was_newline(const uschar *ptr, int type, const uschar *startptr,
+ int *lenptr, BOOL utf8)
{
int c;
ptr--;
@@ -118,7 +130,16 @@ if (utf8)
GETCHAR(c, ptr);
}
else c = *ptr;
-switch(c)
+
+if (type == NLTYPE_ANYCRLF) switch(c)
+ {
+ case 0x000a: *lenptr = (ptr > startptr && ptr[-1] == 0x0d)? 2 : 1;
+ return TRUE; /* LF */
+ case 0x000d: *lenptr = 1; return TRUE; /* CR */
+ default: return FALSE;
+ }
+
+else switch(c)
{
case 0x000a: *lenptr = (ptr > startptr && ptr[-1] == 0x0d)? 2 : 1;
return TRUE; /* LF */
diff --git a/ext/pcre/pcrelib/pcre_ord2utf8.c b/ext/pcre/pcrelib/pcre_ord2utf8.c
index fc4d6de812..a72761285e 100644
--- a/ext/pcre/pcrelib/pcre_ord2utf8.c
+++ b/ext/pcre/pcrelib/pcre_ord2utf8.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -62,6 +62,7 @@ Returns: number of characters placed in the buffer
int
_pcre_ord2utf8(int cvalue, uschar *buffer)
{
+#ifdef SUPPORT_UTF8
register int i, j;
for (i = 0; i < _pcre_utf8_table1_size; i++)
if (cvalue <= _pcre_utf8_table1[i]) break;
@@ -73,6 +74,9 @@ for (j = i; j > 0; j--)
}
*buffer = _pcre_utf8_table2[i] | cvalue;
return i + 1;
+#else
+return 0; /* Keep compiler happy; this function won't ever be */
+#endif /* called when SUPPORT_UTF8 is not defined. */
}
/* End of pcre_ord2utf8.c */
diff --git a/ext/pcre/pcrelib/pcre_printint.src b/ext/pcre/pcrelib/pcre_printint.src
index a6f433368a..79299f7e68 100644
--- a/ext/pcre/pcrelib/pcre_printint.src
+++ b/ext/pcre/pcrelib/pcre_printint.src
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2005 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -71,6 +71,12 @@ print_char(FILE *f, uschar *ptr, BOOL utf8)
{
int c = *ptr;
+#ifndef SUPPORT_UTF8
+utf8 = utf8; /* Avoid compiler warning */
+if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
+return 0;
+
+#else
if (!utf8 || (c & 0xc0) != 0xc0)
{
if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
@@ -102,6 +108,7 @@ else
if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c);
return a;
}
+#endif
}
@@ -134,10 +141,13 @@ return (ptype == pvalue)? "??" : "??";
*************************************************/
/* Make this function work for a regex with integers either byte order.
-However, we assume that what we are passed is a compiled regex. */
+However, we assume that what we are passed is a compiled regex. The
+print_lengths flag controls whether offsets and lengths of items are printed.
+They can be turned off from pcretest so that automatic tests on bytecode can be
+written that do not depend on the value of LINK_SIZE. */
static void
-pcre_printint(pcre *external_re, FILE *f)
+pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
{
real_pcre *re = (real_pcre *)external_re;
uschar *codestart, *code;
@@ -168,7 +178,10 @@ for(;;)
int c;
int extra = 0;
- fprintf(f, "%3d ", (int)(code - codestart));
+ if (print_lengths)
+ fprintf(f, "%3d ", (int)(code - codestart));
+ else
+ fprintf(f, " ");
switch(*code)
{
@@ -205,8 +218,9 @@ for(;;)
case OP_CBRA:
case OP_SCBRA:
- fprintf(f, "%3d %s %d", GET(code, 1), OP_names[*code],
- GET2(code, 1+LINK_SIZE));
+ if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
+ else fprintf(f, " ");
+ fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));
break;
case OP_BRA:
@@ -223,7 +237,9 @@ for(;;)
case OP_COND:
case OP_SCOND:
case OP_REVERSE:
- fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]);
+ if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
+ else fprintf(f, " ");
+ fprintf(f, "%s", OP_names[*code]);
break;
case OP_CREF:
@@ -339,7 +355,9 @@ for(;;)
break;
case OP_RECURSE:
- fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]);
+ if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
+ else fprintf(f, " ");
+ fprintf(f, "%s", OP_names[*code]);
break;
case OP_REF:
diff --git a/ext/pcre/pcrelib/pcre_refcount.c b/ext/pcre/pcrelib/pcre_refcount.c
index e6965812ef..8339019db5 100644
--- a/ext/pcre/pcrelib/pcre_refcount.c
+++ b/ext/pcre/pcrelib/pcre_refcount.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -63,7 +63,7 @@ Returns: the (possibly updated) count value (a non-negative number), or
a negative error number
*/
-PCRE_DATA_SCOPE int
+PCRE_EXP_DEFN int
pcre_refcount(pcre *argument_re, int adjust)
{
real_pcre *re = (real_pcre *)argument_re;
diff --git a/ext/pcre/pcrelib/pcre_scanner.cc b/ext/pcre/pcrelib/pcre_scanner.cc
deleted file mode 100644
index bdc8d4df56..0000000000
--- a/ext/pcre/pcrelib/pcre_scanner.cc
+++ /dev/null
@@ -1,194 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sanjay Ghemawat
-
-#include <vector>
-#include <assert.h>
-#include "config.h"
-#include "pcre_scanner.h"
-
-using std::vector;
-
-namespace pcrecpp {
-
-Scanner::Scanner()
- : data_(),
- input_(data_),
- skip_(NULL),
- should_skip_(false),
- skip_repeat_(false),
- save_comments_(false),
- comments_(NULL),
- comments_offset_(0) {
-}
-
-Scanner::Scanner(const string& in)
- : data_(in),
- input_(data_),
- skip_(NULL),
- should_skip_(false),
- skip_repeat_(false),
- save_comments_(false),
- comments_(NULL),
- comments_offset_(0) {
-}
-
-Scanner::~Scanner() {
- delete skip_;
- delete comments_;
-}
-
-void Scanner::SetSkipExpression(const char* re) {
- delete skip_;
- if (re != NULL) {
- skip_ = new RE(re);
- should_skip_ = true;
- skip_repeat_ = true;
- ConsumeSkip();
- } else {
- skip_ = NULL;
- should_skip_ = false;
- skip_repeat_ = false;
- }
-}
-
-void Scanner::Skip(const char* re) {
- delete skip_;
- if (re != NULL) {
- skip_ = new RE(re);
- should_skip_ = true;
- skip_repeat_ = false;
- ConsumeSkip();
- } else {
- skip_ = NULL;
- should_skip_ = false;
- skip_repeat_ = false;
- }
-}
-
-void Scanner::DisableSkip() {
- assert(skip_ != NULL);
- should_skip_ = false;
-}
-
-void Scanner::EnableSkip() {
- assert(skip_ != NULL);
- should_skip_ = true;
- ConsumeSkip();
-}
-
-int Scanner::LineNumber() const {
- // TODO: Make it more efficient by keeping track of the last point
- // where we computed line numbers and counting newlines since then.
- // We could use std:count, but not all systems have it. :-(
- int count = 1;
- for (const char* p = data_.data(); p < input_.data(); ++p)
- if (*p == '\n')
- ++count;
- return count;
-}
-
-int Scanner::Offset() const {
- return input_.data() - data_.c_str();
-}
-
-bool Scanner::LookingAt(const RE& re) const {
- int consumed;
- return re.DoMatch(input_, RE::ANCHOR_START, &consumed, 0, 0);
-}
-
-
-bool Scanner::Consume(const RE& re,
- const Arg& arg0,
- const Arg& arg1,
- const Arg& arg2) {
- const bool result = re.Consume(&input_, arg0, arg1, arg2);
- if (result && should_skip_) ConsumeSkip();
- return result;
-}
-
-// helper function to consume *skip_ and honour save_comments_
-void Scanner::ConsumeSkip() {
- const char* start_data = input_.data();
- while (skip_->Consume(&input_)) {
- if (!skip_repeat_) {
- // Only one skip allowed.
- break;
- }
- }
- if (save_comments_) {
- if (comments_ == NULL) {
- comments_ = new vector<StringPiece>;
- }
- // already pointing one past end, so no need to +1
- int length = input_.data() - start_data;
- if (length > 0) {
- comments_->push_back(StringPiece(start_data, length));
- }
- }
-}
-
-
-void Scanner::GetComments(int start, int end, vector<StringPiece> *ranges) {
- // short circuit out if we've not yet initialized comments_
- // (e.g., when save_comments is false)
- if (!comments_) {
- return;
- }
- // TODO: if we guarantee that comments_ will contain StringPieces
- // that are ordered by their start, then we can do a binary search
- // for the first StringPiece at or past start and then scan for the
- // ones contained in the range, quit early (use equal_range or
- // lower_bound)
- for (vector<StringPiece>::const_iterator it = comments_->begin();
- it != comments_->end(); ++it) {
- if ((it->data() >= data_.c_str() + start &&
- it->data() + it->size() <= data_.c_str() + end)) {
- ranges->push_back(*it);
- }
- }
-}
-
-
-void Scanner::GetNextComments(vector<StringPiece> *ranges) {
- // short circuit out if we've not yet initialized comments_
- // (e.g., when save_comments is false)
- if (!comments_) {
- return;
- }
- for (vector<StringPiece>::const_iterator it =
- comments_->begin() + comments_offset_;
- it != comments_->end(); ++it) {
- ranges->push_back(*it);
- ++comments_offset_;
- }
-}
-
-} // namespace pcrecpp
diff --git a/ext/pcre/pcrelib/pcre_scanner.h b/ext/pcre/pcrelib/pcre_scanner.h
deleted file mode 100644
index ab4583ee41..0000000000
--- a/ext/pcre/pcrelib/pcre_scanner.h
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sanjay Ghemawat
-//
-// Regular-expression based scanner for parsing an input stream.
-//
-// Example 1: parse a sequence of "var = number" entries from input:
-//
-// Scanner scanner(input);
-// string var;
-// int number;
-// scanner.SetSkipExpression("\\s+"); // Skip any white space we encounter
-// while (scanner.Consume("(\\w+) = (\\d+)", &var, &number)) {
-// ...;
-// }
-
-#ifndef _PCRE_SCANNER_H
-#define _PCRE_SCANNER_H
-
-#include <assert.h>
-#include <string>
-#include <vector>
-#include <pcrecpp.h>
-#include <pcre_stringpiece.h>
-
-namespace pcrecpp {
-
-class Scanner {
- public:
- Scanner();
- explicit Scanner(const std::string& input);
- ~Scanner();
-
- // Return current line number. The returned line-number is
- // one-based. I.e. it returns 1 + the number of consumed newlines.
- //
- // Note: this method may be slow. It may take time proportional to
- // the size of the input.
- int LineNumber() const;
-
- // Return the byte-offset that the scanner is looking in the
- // input data;
- int Offset() const;
-
- // Return true iff the start of the remaining input matches "re"
- bool LookingAt(const RE& re) const;
-
- // Return true iff all of the following are true
- // a. the start of the remaining input matches "re",
- // b. if any arguments are supplied, matched sub-patterns can be
- // parsed and stored into the arguments.
- // If it returns true, it skips over the matched input and any
- // following input that matches the "skip" regular expression.
- bool Consume(const RE& re,
- const Arg& arg0 = no_arg,
- const Arg& arg1 = no_arg,
- const Arg& arg2 = no_arg
- // TODO: Allow more arguments?
- );
-
- // Set the "skip" regular expression. If after consuming some data,
- // a prefix of the input matches this RE, it is automatically
- // skipped. For example, a programming language scanner would use
- // a skip RE that matches white space and comments.
- //
- // scanner.SetSkipExpression("\\s+|//.*|/[*](.|\n)*?[*]/");
- //
- // Skipping repeats as long as it succeeds. We used to let people do
- // this by writing "(...)*" in the regular expression, but that added
- // up to lots of recursive calls within the pcre library, so now we
- // control repetition explicitly via the function call API.
- //
- // You can pass NULL for "re" if you do not want any data to be skipped.
- void Skip(const char* re); // DEPRECATED; does *not* repeat
- void SetSkipExpression(const char* re);
-
- // Temporarily pause "skip"ing. This
- // Skip("Foo"); code ; DisableSkip(); code; EnableSkip()
- // is similar to
- // Skip("Foo"); code ; Skip(NULL); code ; Skip("Foo");
- // but avoids creating/deleting new RE objects.
- void DisableSkip();
-
- // Reenable previously paused skipping. Any prefix of the input
- // that matches the skip pattern is immediately dropped.
- void EnableSkip();
-
- /***** Special wrappers around SetSkip() for some common idioms *****/
-
- // Arranges to skip whitespace, C comments, C++ comments.
- // The overall RE is a disjunction of the following REs:
- // \\s whitespace
- // //.*\n C++ comment
- // /[*](.|\n)*?[*]/ C comment (x*? means minimal repetitions of x)
- // We get repetition via the semantics of SetSkipExpression, not by using *
- void SkipCXXComments() {
- SetSkipExpression("\\s|//.*\n|/[*](?:\n|.)*?[*]/");
- }
-
- void set_save_comments(bool comments) {
- save_comments_ = comments;
- }
-
- bool save_comments() {
- return save_comments_;
- }
-
- // Append to vector ranges the comments found in the
- // byte range [start,end] (inclusive) of the input data.
- // Only comments that were extracted entirely within that
- // range are returned: no range splitting of atomically-extracted
- // comments is performed.
- void GetComments(int start, int end, std::vector<StringPiece> *ranges);
-
- // Append to vector ranges the comments added
- // since the last time this was called. This
- // functionality is provided for efficiency when
- // interleaving scanning with parsing.
- void GetNextComments(std::vector<StringPiece> *ranges);
-
- private:
- std::string data_; // All the input data
- StringPiece input_; // Unprocessed input
- RE* skip_; // If non-NULL, RE for skipping input
- bool should_skip_; // If true, use skip_
- bool skip_repeat_; // If true, repeat skip_ as long as it works
- bool save_comments_; // If true, aggregate the skip expression
-
- // the skipped comments
- // TODO: later consider requiring that the StringPieces be added
- // in order by their start position
- std::vector<StringPiece> *comments_;
-
- // the offset into comments_ that has been returned by GetNextComments
- int comments_offset_;
-
- // helper function to consume *skip_ and honour
- // save_comments_
- void ConsumeSkip();
-};
-
-} // namespace pcrecpp
-
-#endif /* _PCRE_SCANNER_H */
diff --git a/ext/pcre/pcrelib/pcre_scanner_unittest.cc b/ext/pcre/pcrelib/pcre_scanner_unittest.cc
deleted file mode 100644
index d939fedeca..0000000000
--- a/ext/pcre/pcrelib/pcre_scanner_unittest.cc
+++ /dev/null
@@ -1,152 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Greg J. Badros
-//
-// Unittest for scanner, especially GetNextComments and GetComments()
-// functionality.
-
-#include <stdio.h>
-#include <string>
-#include <vector>
-#include <pcre_stringpiece.h>
-#include <pcre_scanner.h>
-
-#define FLAGS_unittest_stack_size 49152
-
-// Dies with a fatal error if the two values are not equal.
-#define CHECK_EQ(a, b) do { \
- if ( (a) != (b) ) { \
- fprintf(stderr, "%s:%d: Check failed because %s != %s\n", \
- __FILE__, __LINE__, #a, #b); \
- exit(1); \
- } \
-} while (0)
-
-using std::vector;
-using pcrecpp::StringPiece;
-using pcrecpp::Scanner;
-
-static void TestScanner() {
- const char input[] = "\n"
- "alpha = 1; // this sets alpha\n"
- "bravo = 2; // bravo is set here\n"
- "gamma = 33; /* and here is gamma */\n";
-
- const char *re = "(\\w+) = (\\d+);";
-
- Scanner s(input);
- string var;
- int number;
- s.SkipCXXComments();
- s.set_save_comments(true);
- vector<StringPiece> comments;
-
- s.Consume(re, &var, &number);
- CHECK_EQ(var, "alpha");
- CHECK_EQ(number, 1);
- CHECK_EQ(s.LineNumber(), 3);
- s.GetNextComments(&comments);
- CHECK_EQ(comments.size(), 1);
- CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
- comments.resize(0);
-
- s.Consume(re, &var, &number);
- CHECK_EQ(var, "bravo");
- CHECK_EQ(number, 2);
- s.GetNextComments(&comments);
- CHECK_EQ(comments.size(), 1);
- CHECK_EQ(comments[0].as_string(), " // bravo is set here\n");
- comments.resize(0);
-
- s.Consume(re, &var, &number);
- CHECK_EQ(var, "gamma");
- CHECK_EQ(number, 33);
- s.GetNextComments(&comments);
- CHECK_EQ(comments.size(), 1);
- CHECK_EQ(comments[0].as_string(), " /* and here is gamma */\n");
- comments.resize(0);
-
- s.GetComments(0, sizeof(input), &comments);
- CHECK_EQ(comments.size(), 3);
- CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
- CHECK_EQ(comments[1].as_string(), " // bravo is set here\n");
- CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");
- comments.resize(0);
-
- s.GetComments(0, strchr(input, '/') - input, &comments);
- CHECK_EQ(comments.size(), 0);
- comments.resize(0);
-
- s.GetComments(strchr(input, '/') - input - 1, sizeof(input),
- &comments);
- CHECK_EQ(comments.size(), 3);
- CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
- CHECK_EQ(comments[1].as_string(), " // bravo is set here\n");
- CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");
- comments.resize(0);
-
- s.GetComments(strchr(input, '/') - input - 1,
- strchr(input + 1, '\n') - input + 1, &comments);
- CHECK_EQ(comments.size(), 1);
- CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
- comments.resize(0);
-}
-
-static void TestBigComment() {
- string input;
- for (int i = 0; i < 1024; ++i) {
- char buf[1024];
- snprintf(buf, sizeof(buf), " # Comment %d\n", i);
- input += buf;
- }
- input += "name = value;\n";
-
- Scanner s(input.c_str());
- s.SetSkipExpression("\\s+|#.*\n");
-
- string name;
- string value;
- s.Consume("(\\w+) = (\\w+);", &name, &value);
- CHECK_EQ(name, "name");
- CHECK_EQ(value, "value");
-}
-
-// TODO: also test scanner and big-comment in a thread with a
-// small stack size
-
-int main(int argc, char** argv) {
- TestScanner();
- TestBigComment();
-
- // Done
- printf("OK\n");
-
- return 0;
-}
diff --git a/ext/pcre/pcrelib/pcre_stringpiece.cc b/ext/pcre/pcrelib/pcre_stringpiece.cc
deleted file mode 100644
index dbdb509b3b..0000000000
--- a/ext/pcre/pcrelib/pcre_stringpiece.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wilsonh@google.com (Wilson Hsieh)
-//
-
-#include <iostream>
-#include "config.h"
-#include "pcre_stringpiece.h"
-
-std::ostream& operator<<(std::ostream& o, const pcrecpp::StringPiece& piece) {
- return (o << piece.as_string());
-}
diff --git a/ext/pcre/pcrelib/pcre_stringpiece.h b/ext/pcre/pcrelib/pcre_stringpiece.h
deleted file mode 100644
index 89d5449651..0000000000
--- a/ext/pcre/pcrelib/pcre_stringpiece.h
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sanjay Ghemawat
-//
-// A string like object that points into another piece of memory.
-// Useful for providing an interface that allows clients to easily
-// pass in either a "const char*" or a "string".
-//
-// Arghh! I wish C++ literals were automatically of type "string".
-
-#ifndef _PCRE_STRINGPIECE_H
-#define _PCRE_STRINGPIECE_H
-
-#include <string.h>
-#include <string>
-#include <iosfwd> // for ostream forward-declaration
-
-#if 1
-#define HAVE_TYPE_TRAITS
-#include <type_traits.h>
-#elif 0
-#define HAVE_TYPE_TRAITS
-#include <bits/type_traits.h>
-#endif
-
-using std::string;
-
-namespace pcrecpp {
-
-class StringPiece {
- private:
- const char* ptr_;
- int length_;
-
- public:
- // We provide non-explicit singleton constructors so users can pass
- // in a "const char*" or a "string" wherever a "StringPiece" is
- // expected.
- StringPiece()
- : ptr_(NULL), length_(0) { }
- StringPiece(const char* str)
- : ptr_(str), length_(static_cast<int>(strlen(str))) { }
- StringPiece(const string& str)
- : ptr_(str.data()), length_(static_cast<int>(str.size())) { }
- StringPiece(const char* offset, int len)
- : ptr_(offset), length_(len) { }
-
- // data() may return a pointer to a buffer with embedded NULs, and the
- // returned buffer may or may not be null terminated. Therefore it is
- // typically a mistake to pass data() to a routine that expects a NUL
- // terminated string. Use "as_string().c_str()" if you really need to do
- // this. Or better yet, change your routine so it does not rely on NUL
- // termination.
- const char* data() const { return ptr_; }
- int size() const { return length_; }
- bool empty() const { return length_ == 0; }
-
- void clear() { ptr_ = NULL; length_ = 0; }
- void set(const char* buffer, int len) { ptr_ = buffer; length_ = len; }
- void set(const char* str) {
- ptr_ = str;
- length_ = static_cast<int>(strlen(str));
- }
- void set(const void* buffer, int len) {
- ptr_ = reinterpret_cast<const char*>(buffer);
- length_ = len;
- }
-
- char operator[](int i) const { return ptr_[i]; }
-
- void remove_prefix(int n) {
- ptr_ += n;
- length_ -= n;
- }
-
- void remove_suffix(int n) {
- length_ -= n;
- }
-
- bool operator==(const StringPiece& x) const {
- return ((length_ == x.length_) &&
- (memcmp(ptr_, x.ptr_, length_) == 0));
- }
- bool operator!=(const StringPiece& x) const {
- return !(*this == x);
- }
-
-#define STRINGPIECE_BINARY_PREDICATE(cmp,auxcmp) \
- bool operator cmp (const StringPiece& x) const { \
- int r = memcmp(ptr_, x.ptr_, length_ < x.length_ ? length_ : x.length_); \
- return ((r auxcmp 0) || ((r == 0) && (length_ cmp x.length_))); \
- }
- STRINGPIECE_BINARY_PREDICATE(<, <);
- STRINGPIECE_BINARY_PREDICATE(<=, <);
- STRINGPIECE_BINARY_PREDICATE(>=, >);
- STRINGPIECE_BINARY_PREDICATE(>, >);
-#undef STRINGPIECE_BINARY_PREDICATE
-
- int compare(const StringPiece& x) const {
- int r = memcmp(ptr_, x.ptr_, length_ < x.length_ ? length_ : x.length_);
- if (r == 0) {
- if (length_ < x.length_) r = -1;
- else if (length_ > x.length_) r = +1;
- }
- return r;
- }
-
- string as_string() const {
- return string(data(), size());
- }
-
- void CopyToString(string* target) const {
- target->assign(ptr_, length_);
- }
-
- // Does "this" start with "x"
- bool starts_with(const StringPiece& x) const {
- return ((length_ >= x.length_) && (memcmp(ptr_, x.ptr_, x.length_) == 0));
- }
-};
-
-} // namespace pcrecpp
-
-// ------------------------------------------------------------------
-// Functions used to create STL containers that use StringPiece
-// Remember that a StringPiece's lifetime had better be less than
-// that of the underlying string or char*. If it is not, then you
-// cannot safely store a StringPiece into an STL container
-// ------------------------------------------------------------------
-
-#ifdef HAVE_TYPE_TRAITS
-// This makes vector<StringPiece> really fast for some STL implementations
-template<> struct __type_traits<pcrecpp::StringPiece> {
- typedef __true_type has_trivial_default_constructor;
- typedef __true_type has_trivial_copy_constructor;
- typedef __true_type has_trivial_assignment_operator;
- typedef __true_type has_trivial_destructor;
- typedef __true_type is_POD_type;
-};
-#endif
-
-// allow StringPiece to be logged
-std::ostream& operator<<(std::ostream& o, const pcrecpp::StringPiece& piece);
-
-#endif /* _PCRE_STRINGPIECE_H */
diff --git a/ext/pcre/pcrelib/pcre_stringpiece_unittest.cc b/ext/pcre/pcrelib/pcre_stringpiece_unittest.cc
deleted file mode 100644
index d6a89e8c7a..0000000000
--- a/ext/pcre/pcrelib/pcre_stringpiece_unittest.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright 2003 and onwards Google Inc.
-// Author: Sanjay Ghemawat
-
-#include <stdio.h>
-#include <map>
-#include <algorithm> // for make_pair
-#include <pcre_stringpiece.h>
-
-// CHECK dies with a fatal error if condition is not true. It is *not*
-// controlled by NDEBUG, so the check will be executed regardless of
-// compilation mode. Therefore, it is safe to do things like:
-// CHECK(fp->Write(x) == 4)
-#define CHECK(condition) do { \
- if (!(condition)) { \
- fprintf(stderr, "%s:%d: Check failed: %s\n", \
- __FILE__, __LINE__, #condition); \
- exit(1); \
- } \
-} while (0)
-
-using std::map;
-using std::make_pair;
-using pcrecpp::StringPiece;
-
-static void CheckSTLComparator() {
- string s1("foo");
- string s2("bar");
- string s3("baz");
-
- StringPiece p1(s1);
- StringPiece p2(s2);
- StringPiece p3(s3);
-
- typedef map<StringPiece, int> TestMap;
- TestMap map;
-
- map.insert(make_pair(p1, 0));
- map.insert(make_pair(p2, 1));
- map.insert(make_pair(p3, 2));
- CHECK(map.size() == 3);
-
- TestMap::const_iterator iter = map.begin();
- CHECK(iter->second == 1);
- ++iter;
- CHECK(iter->second == 2);
- ++iter;
- CHECK(iter->second == 0);
- ++iter;
- CHECK(iter == map.end());
-
- TestMap::iterator new_iter = map.find("zot");
- CHECK(new_iter == map.end());
-
- new_iter = map.find("bar");
- CHECK(new_iter != map.end());
-
- map.erase(new_iter);
- CHECK(map.size() == 2);
-
- iter = map.begin();
- CHECK(iter->second == 2);
- ++iter;
- CHECK(iter->second == 0);
- ++iter;
- CHECK(iter == map.end());
-}
-
-static void CheckComparisonOperators() {
-#define CMP_Y(op, x, y) \
- CHECK( (StringPiece((x)) op StringPiece((y)))); \
- CHECK( (StringPiece((x)).compare(StringPiece((y))) op 0))
-
-#define CMP_N(op, x, y) \
- CHECK(!(StringPiece((x)) op StringPiece((y)))); \
- CHECK(!(StringPiece((x)).compare(StringPiece((y))) op 0))
-
- CMP_Y(==, "", "");
- CMP_Y(==, "a", "a");
- CMP_Y(==, "aa", "aa");
- CMP_N(==, "a", "");
- CMP_N(==, "", "a");
- CMP_N(==, "a", "b");
- CMP_N(==, "a", "aa");
- CMP_N(==, "aa", "a");
-
- CMP_N(!=, "", "");
- CMP_N(!=, "a", "a");
- CMP_N(!=, "aa", "aa");
- CMP_Y(!=, "a", "");
- CMP_Y(!=, "", "a");
- CMP_Y(!=, "a", "b");
- CMP_Y(!=, "a", "aa");
- CMP_Y(!=, "aa", "a");
-
- CMP_Y(<, "a", "b");
- CMP_Y(<, "a", "aa");
- CMP_Y(<, "aa", "b");
- CMP_Y(<, "aa", "bb");
- CMP_N(<, "a", "a");
- CMP_N(<, "b", "a");
- CMP_N(<, "aa", "a");
- CMP_N(<, "b", "aa");
- CMP_N(<, "bb", "aa");
-
- CMP_Y(<=, "a", "a");
- CMP_Y(<=, "a", "b");
- CMP_Y(<=, "a", "aa");
- CMP_Y(<=, "aa", "b");
- CMP_Y(<=, "aa", "bb");
- CMP_N(<=, "b", "a");
- CMP_N(<=, "aa", "a");
- CMP_N(<=, "b", "aa");
- CMP_N(<=, "bb", "aa");
-
- CMP_N(>=, "a", "b");
- CMP_N(>=, "a", "aa");
- CMP_N(>=, "aa", "b");
- CMP_N(>=, "aa", "bb");
- CMP_Y(>=, "a", "a");
- CMP_Y(>=, "b", "a");
- CMP_Y(>=, "aa", "a");
- CMP_Y(>=, "b", "aa");
- CMP_Y(>=, "bb", "aa");
-
- CMP_N(>, "a", "a");
- CMP_N(>, "a", "b");
- CMP_N(>, "a", "aa");
- CMP_N(>, "aa", "b");
- CMP_N(>, "aa", "bb");
- CMP_Y(>, "b", "a");
- CMP_Y(>, "aa", "a");
- CMP_Y(>, "b", "aa");
- CMP_Y(>, "bb", "aa");
-
-#undef CMP_Y
-#undef CMP_N
-}
-
-int main(int argc, char** argv) {
- CheckComparisonOperators();
- CheckSTLComparator();
-
- printf("OK\n");
- return 0;
-}
diff --git a/ext/pcre/pcrelib/pcre_study.c b/ext/pcre/pcrelib/pcre_study.c
index 87f8c6fb51..3cf5b5954d 100644
--- a/ext/pcre/pcrelib/pcre_study.c
+++ b/ext/pcre/pcrelib/pcre_study.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -394,11 +394,13 @@ do
character with a value > 255. */
case OP_NCLASS:
+#ifdef SUPPORT_UTF8
if (utf8)
{
start_bits[24] |= 0xf0; /* Bits for 0xc4 - 0xc8 */
memset(start_bits+25, 0xff, 7); /* Bits for 0xc9 - 0xff */
}
+#endif
/* Fall through */
case OP_CLASS:
@@ -411,6 +413,7 @@ do
value is > 127. In fact, there are only two possible starting bytes for
characters in the range 128 - 255. */
+#ifdef SUPPORT_UTF8
if (utf8)
{
for (c = 0; c < 16; c++) start_bits[c] |= tcode[c];
@@ -428,6 +431,7 @@ do
/* In non-UTF-8 mode, the two bit maps are completely compatible. */
else
+#endif
{
for (c = 0; c < 32; c++) start_bits[c] |= tcode[c];
}
@@ -487,7 +491,7 @@ Returns: pointer to a pcre_extra block, with study_data filled in and the
NULL on error or if no optimization possible
*/
-PCRE_DATA_SCOPE pcre_extra *
+PCRE_EXP_DEFN pcre_extra *
pcre_study(const pcre *external_re, int options, const char **errorptr)
{
uschar start_bits[32];
diff --git a/ext/pcre/pcrelib/pcre_tables.c b/ext/pcre/pcrelib/pcre_tables.c
index 53690d7c9b..3e36c931a0 100644
--- a/ext/pcre/pcrelib/pcre_tables.c
+++ b/ext/pcre/pcrelib/pcre_tables.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,8 @@ const uschar _pcre_OP_lengths[] = { OP_LENGTHS };
/* These are the breakpoints for different numbers of bytes in a UTF-8
character. */
+#ifdef SUPPORT_UTF8
+
const int _pcre_utf8_table1[] =
{ 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
@@ -194,4 +196,6 @@ const ucp_type_table _pcre_utt[] = {
const int _pcre_utt_size = sizeof(_pcre_utt)/sizeof(ucp_type_table);
+#endif /* SUPPORT_UTF8 */
+
/* End of pcre_tables.c */
diff --git a/ext/pcre/pcrelib/pcre_try_flipped.c b/ext/pcre/pcrelib/pcre_try_flipped.c
index 00c94fccf5..cd45968a4a 100644
--- a/ext/pcre/pcrelib/pcre_try_flipped.c
+++ b/ext/pcre/pcrelib/pcre_try_flipped.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
diff --git a/ext/pcre/pcrelib/pcre_ucp_searchfuncs.c b/ext/pcre/pcrelib/pcre_ucp_searchfuncs.c
index 20bb7be832..5ecba6b1f8 100644
--- a/ext/pcre/pcrelib/pcre_ucp_searchfuncs.c
+++ b/ext/pcre/pcrelib/pcre_ucp_searchfuncs.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -45,12 +45,12 @@ properties. */
#include "ucp.h" /* Category definitions */
#include "ucpinternal.h" /* Internal table details */
-#include "ucptable.c" /* The table itself */
+#include "ucptable.h" /* The table itself */
/* Table to translate from particular type value to the general value. */
-static int ucp_gentype[] = {
+static const int ucp_gentype[] = {
ucp_C, ucp_C, ucp_C, ucp_C, ucp_C, /* Cc, Cf, Cn, Co, Cs */
ucp_L, ucp_L, ucp_L, ucp_L, ucp_L, /* Ll, Lu, Lm, Lo, Lt */
ucp_M, ucp_M, ucp_M, /* Mc, Me, Mn */
diff --git a/ext/pcre/pcrelib/pcre_valid_utf8.c b/ext/pcre/pcrelib/pcre_valid_utf8.c
index 727fbe8d0a..9a35a202e4 100644
--- a/ext/pcre/pcrelib/pcre_valid_utf8.c
+++ b/ext/pcre/pcrelib/pcre_valid_utf8.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -66,6 +66,7 @@ Returns: < 0 if the string is a valid UTF-8 string
int
_pcre_valid_utf8(const uschar *string, int length)
{
+#ifdef SUPPORT_UTF8
register const uschar *p;
if (length < 0)
@@ -123,6 +124,7 @@ for (p = string; length-- > 0; p++)
if ((*(++p) & 0xc0) != 0x80) return p - string;
}
}
+#endif
return -1;
}
diff --git a/ext/pcre/pcrelib/pcre_version.c b/ext/pcre/pcrelib/pcre_version.c
index 9edf3e013e..1a9ecb2c50 100644
--- a/ext/pcre/pcrelib/pcre_version.c
+++ b/ext/pcre/pcrelib/pcre_version.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -75,7 +75,7 @@ I could find no way of detecting that a macro is defined as an empty string at
pre-processor time. This hack uses a standard trick for avoiding calling
the STRING macro with an empty argument when doing the test. */
-PCRE_DATA_SCOPE const char *
+PCRE_EXP_DEFN const char *
pcre_version(void)
{
return (XSTRING(Z PCRE_PRERELEASE)[1] == 0)?
diff --git a/ext/pcre/pcrelib/pcre_xclass.c b/ext/pcre/pcrelib/pcre_xclass.c
index 57c514b78a..0b333515f2 100644
--- a/ext/pcre/pcrelib/pcre_xclass.c
+++ b/ext/pcre/pcrelib/pcre_xclass.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
diff --git a/ext/pcre/pcrelib/pcrecpp.cc b/ext/pcre/pcrelib/pcrecpp.cc
deleted file mode 100644
index b75738b36c..0000000000
--- a/ext/pcre/pcrelib/pcrecpp.cc
+++ /dev/null
@@ -1,857 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sanjay Ghemawat
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <limits.h> /* for SHRT_MIN, USHRT_MAX, etc */
-#include <assert.h>
-#include <errno.h>
-#include <string>
-#include <algorithm>
-#include "config.h"
-// We need this to compile the proper dll on windows/msys. This is copied
-// from pcre_internal.h. It would probably be better just to include that.
-#define PCRE_DEFINITION /* Win32 __declspec(export) trigger for .dll */
-#include "pcre.h"
-#include "pcre_stringpiece.h"
-#include "pcrecpp.h"
-
-
-namespace pcrecpp {
-
-// Maximum number of args we can set
-static const int kMaxArgs = 16;
-static const int kVecSize = (1 + kMaxArgs) * 3; // results + PCRE workspace
-
-// Special object that stands-in for no argument
-Arg no_arg((void*)NULL);
-
-// If a regular expression has no error, its error_ field points here
-static const string empty_string;
-
-// If the user doesn't ask for any options, we just use this one
-static RE_Options default_options;
-
-void RE::Init(const string& pat, const RE_Options* options) {
- pattern_ = pat;
- if (options == NULL) {
- options_ = default_options;
- } else {
- options_ = *options;
- }
- error_ = &empty_string;
- re_full_ = NULL;
- re_partial_ = NULL;
-
- re_partial_ = Compile(UNANCHORED);
- if (re_partial_ != NULL) {
- // Check for complicated patterns. The following change is
- // conservative in that it may treat some "simple" patterns
- // as "complex" (e.g., if the vertical bar is in a character
- // class or is escaped). But it seems good enough.
- if (strchr(pat.c_str(), '|') == NULL) {
- // Simple pattern: we can use position-based checks to perform
- // fully anchored matches
- re_full_ = re_partial_;
- } else {
- // We need a special pattern for anchored matches
- re_full_ = Compile(ANCHOR_BOTH);
- }
- }
-}
-
-void RE::Cleanup() {
- if (re_full_ != NULL && re_full_ != re_partial_) (*pcre_free)(re_full_);
- if (re_partial_ != NULL) (*pcre_free)(re_partial_);
- if (error_ != &empty_string) delete error_;
-}
-
-
-RE::~RE() {
- Cleanup();
-}
-
-
-pcre* RE::Compile(Anchor anchor) {
- // First, convert RE_Options into pcre options
- int pcre_options = 0;
- pcre_options = options_.all_options();
-
- // Special treatment for anchoring. This is needed because at
- // runtime pcre only provides an option for anchoring at the
- // beginning of a string (unless you use offset).
- //
- // There are three types of anchoring we want:
- // UNANCHORED Compile the original pattern, and use
- // a pcre unanchored match.
- // ANCHOR_START Compile the original pattern, and use
- // a pcre anchored match.
- // ANCHOR_BOTH Tack a "\z" to the end of the original pattern
- // and use a pcre anchored match.
-
- const char* compile_error;
- int eoffset;
- pcre* re;
- if (anchor != ANCHOR_BOTH) {
- re = pcre_compile(pattern_.c_str(), pcre_options,
- &compile_error, &eoffset, NULL);
- } else {
- // Tack a '\z' at the end of RE. Parenthesize it first so that
- // the '\z' applies to all top-level alternatives in the regexp.
- string wrapped = "(?:"; // A non-counting grouping operator
- wrapped += pattern_;
- wrapped += ")\\z";
- re = pcre_compile(wrapped.c_str(), pcre_options,
- &compile_error, &eoffset, NULL);
- }
- if (re == NULL) {
- if (error_ == &empty_string) error_ = new string(compile_error);
- }
- return re;
-}
-
-/***** Matching interfaces *****/
-
-bool RE::FullMatch(const StringPiece& text,
- const Arg& ptr1,
- const Arg& ptr2,
- const Arg& ptr3,
- const Arg& ptr4,
- const Arg& ptr5,
- const Arg& ptr6,
- const Arg& ptr7,
- const Arg& ptr8,
- const Arg& ptr9,
- const Arg& ptr10,
- const Arg& ptr11,
- const Arg& ptr12,
- const Arg& ptr13,
- const Arg& ptr14,
- const Arg& ptr15,
- const Arg& ptr16) const {
- const Arg* args[kMaxArgs];
- int n = 0;
- if (&ptr1 == &no_arg) goto done; args[n++] = &ptr1;
- if (&ptr2 == &no_arg) goto done; args[n++] = &ptr2;
- if (&ptr3 == &no_arg) goto done; args[n++] = &ptr3;
- if (&ptr4 == &no_arg) goto done; args[n++] = &ptr4;
- if (&ptr5 == &no_arg) goto done; args[n++] = &ptr5;
- if (&ptr6 == &no_arg) goto done; args[n++] = &ptr6;
- if (&ptr7 == &no_arg) goto done; args[n++] = &ptr7;
- if (&ptr8 == &no_arg) goto done; args[n++] = &ptr8;
- if (&ptr9 == &no_arg) goto done; args[n++] = &ptr9;
- if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10;
- if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11;
- if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12;
- if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13;
- if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14;
- if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15;
- if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16;
- done:
-
- int consumed;
- int vec[kVecSize];
- return DoMatchImpl(text, ANCHOR_BOTH, &consumed, args, n, vec, kVecSize);
-}
-
-bool RE::PartialMatch(const StringPiece& text,
- const Arg& ptr1,
- const Arg& ptr2,
- const Arg& ptr3,
- const Arg& ptr4,
- const Arg& ptr5,
- const Arg& ptr6,
- const Arg& ptr7,
- const Arg& ptr8,
- const Arg& ptr9,
- const Arg& ptr10,
- const Arg& ptr11,
- const Arg& ptr12,
- const Arg& ptr13,
- const Arg& ptr14,
- const Arg& ptr15,
- const Arg& ptr16) const {
- const Arg* args[kMaxArgs];
- int n = 0;
- if (&ptr1 == &no_arg) goto done; args[n++] = &ptr1;
- if (&ptr2 == &no_arg) goto done; args[n++] = &ptr2;
- if (&ptr3 == &no_arg) goto done; args[n++] = &ptr3;
- if (&ptr4 == &no_arg) goto done; args[n++] = &ptr4;
- if (&ptr5 == &no_arg) goto done; args[n++] = &ptr5;
- if (&ptr6 == &no_arg) goto done; args[n++] = &ptr6;
- if (&ptr7 == &no_arg) goto done; args[n++] = &ptr7;
- if (&ptr8 == &no_arg) goto done; args[n++] = &ptr8;
- if (&ptr9 == &no_arg) goto done; args[n++] = &ptr9;
- if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10;
- if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11;
- if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12;
- if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13;
- if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14;
- if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15;
- if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16;
- done:
-
- int consumed;
- int vec[kVecSize];
- return DoMatchImpl(text, UNANCHORED, &consumed, args, n, vec, kVecSize);
-}
-
-bool RE::Consume(StringPiece* input,
- const Arg& ptr1,
- const Arg& ptr2,
- const Arg& ptr3,
- const Arg& ptr4,
- const Arg& ptr5,
- const Arg& ptr6,
- const Arg& ptr7,
- const Arg& ptr8,
- const Arg& ptr9,
- const Arg& ptr10,
- const Arg& ptr11,
- const Arg& ptr12,
- const Arg& ptr13,
- const Arg& ptr14,
- const Arg& ptr15,
- const Arg& ptr16) const {
- const Arg* args[kMaxArgs];
- int n = 0;
- if (&ptr1 == &no_arg) goto done; args[n++] = &ptr1;
- if (&ptr2 == &no_arg) goto done; args[n++] = &ptr2;
- if (&ptr3 == &no_arg) goto done; args[n++] = &ptr3;
- if (&ptr4 == &no_arg) goto done; args[n++] = &ptr4;
- if (&ptr5 == &no_arg) goto done; args[n++] = &ptr5;
- if (&ptr6 == &no_arg) goto done; args[n++] = &ptr6;
- if (&ptr7 == &no_arg) goto done; args[n++] = &ptr7;
- if (&ptr8 == &no_arg) goto done; args[n++] = &ptr8;
- if (&ptr9 == &no_arg) goto done; args[n++] = &ptr9;
- if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10;
- if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11;
- if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12;
- if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13;
- if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14;
- if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15;
- if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16;
- done:
-
- int consumed;
- int vec[kVecSize];
- if (DoMatchImpl(*input, ANCHOR_START, &consumed,
- args, n, vec, kVecSize)) {
- input->remove_prefix(consumed);
- return true;
- } else {
- return false;
- }
-}
-
-bool RE::FindAndConsume(StringPiece* input,
- const Arg& ptr1,
- const Arg& ptr2,
- const Arg& ptr3,
- const Arg& ptr4,
- const Arg& ptr5,
- const Arg& ptr6,
- const Arg& ptr7,
- const Arg& ptr8,
- const Arg& ptr9,
- const Arg& ptr10,
- const Arg& ptr11,
- const Arg& ptr12,
- const Arg& ptr13,
- const Arg& ptr14,
- const Arg& ptr15,
- const Arg& ptr16) const {
- const Arg* args[kMaxArgs];
- int n = 0;
- if (&ptr1 == &no_arg) goto done; args[n++] = &ptr1;
- if (&ptr2 == &no_arg) goto done; args[n++] = &ptr2;
- if (&ptr3 == &no_arg) goto done; args[n++] = &ptr3;
- if (&ptr4 == &no_arg) goto done; args[n++] = &ptr4;
- if (&ptr5 == &no_arg) goto done; args[n++] = &ptr5;
- if (&ptr6 == &no_arg) goto done; args[n++] = &ptr6;
- if (&ptr7 == &no_arg) goto done; args[n++] = &ptr7;
- if (&ptr8 == &no_arg) goto done; args[n++] = &ptr8;
- if (&ptr9 == &no_arg) goto done; args[n++] = &ptr9;
- if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10;
- if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11;
- if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12;
- if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13;
- if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14;
- if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15;
- if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16;
- done:
-
- int consumed;
- int vec[kVecSize];
- if (DoMatchImpl(*input, UNANCHORED, &consumed,
- args, n, vec, kVecSize)) {
- input->remove_prefix(consumed);
- return true;
- } else {
- return false;
- }
-}
-
-bool RE::Replace(const StringPiece& rewrite,
- string *str) const {
- int vec[kVecSize];
- int matches = TryMatch(*str, 0, UNANCHORED, vec, kVecSize);
- if (matches == 0)
- return false;
-
- string s;
- if (!Rewrite(&s, rewrite, *str, vec, matches))
- return false;
-
- assert(vec[0] >= 0);
- assert(vec[1] >= 0);
- str->replace(vec[0], vec[1] - vec[0], s);
- return true;
-}
-
-// Returns PCRE_NEWLINE_CRLF, PCRE_NEWLINE_CR, or PCRE_NEWLINE_LF.
-// Note that PCRE_NEWLINE_CRLF is defined to be P_N_CR | P_N_LF.
-static int NewlineMode(int pcre_options) {
- // TODO: if we can make it threadsafe, cache this var
- int newline_mode = 0;
- /* if (newline_mode) return newline_mode; */ // do this once it's cached
- if (pcre_options & (PCRE_NEWLINE_CRLF|PCRE_NEWLINE_CR|PCRE_NEWLINE_LF)) {
- newline_mode = (pcre_options &
- (PCRE_NEWLINE_CRLF|PCRE_NEWLINE_CR|PCRE_NEWLINE_LF));
- } else {
- int newline;
- pcre_config(PCRE_CONFIG_NEWLINE, &newline);
- if (newline == 10)
- newline_mode = PCRE_NEWLINE_LF;
- else if (newline == 13)
- newline_mode = PCRE_NEWLINE_CR;
- else if (newline == 3338)
- newline_mode = PCRE_NEWLINE_CRLF;
- else
- assert("" == "Unexpected return value from pcre_config(NEWLINE)");
- }
- return newline_mode;
-}
-
-int RE::GlobalReplace(const StringPiece& rewrite,
- string *str) const {
- int count = 0;
- int vec[kVecSize];
- string out;
- int start = 0;
- int lastend = -1;
-
- for (; start <= static_cast<int>(str->length()); count++) {
- int matches = TryMatch(*str, start, UNANCHORED, vec, kVecSize);
- if (matches <= 0)
- break;
- int matchstart = vec[0], matchend = vec[1];
- assert(matchstart >= start);
- assert(matchend >= matchstart);
- if (matchstart == matchend && matchstart == lastend) {
- // advance one character if we matched an empty string at the same
- // place as the last match occurred
- matchend = start + 1;
- // If the current char is CR and we're in CRLF mode, skip LF too.
- // Note it's better to call pcre_fullinfo() than to examine
- // all_options(), since options_ could have changed bewteen
- // compile-time and now, but this is simpler and safe enough.
- if (start+1 < static_cast<int>(str->length()) &&
- (*str)[start] == '\r' && (*str)[start+1] == '\n' &&
- NewlineMode(options_.all_options()) == PCRE_NEWLINE_CRLF) {
- matchend++;
- }
- // We also need to advance more than one char if we're in utf8 mode.
-#ifdef SUPPORT_UTF8
- if (options_.utf8()) {
- while (matchend < static_cast<int>(str->length()) &&
- ((*str)[matchend] & 0xc0) == 0x80)
- matchend++;
- }
-#endif
- if (matchend <= static_cast<int>(str->length()))
- out.append(*str, start, matchend - start);
- start = matchend;
- } else {
- out.append(*str, start, matchstart - start);
- Rewrite(&out, rewrite, *str, vec, matches);
- start = matchend;
- lastend = matchend;
- count++;
- }
- }
-
- if (count == 0)
- return 0;
-
- if (start < static_cast<int>(str->length()))
- out.append(*str, start, str->length() - start);
- swap(out, *str);
- return count;
-}
-
-bool RE::Extract(const StringPiece& rewrite,
- const StringPiece& text,
- string *out) const {
- int vec[kVecSize];
- int matches = TryMatch(text, 0, UNANCHORED, vec, kVecSize);
- if (matches == 0)
- return false;
- out->erase();
- return Rewrite(out, rewrite, text, vec, matches);
-}
-
-/*static*/ string RE::QuoteMeta(const StringPiece& unquoted) {
- string result;
-
- // Escape any ascii character not in [A-Za-z_0-9].
- //
- // Note that it's legal to escape a character even if it has no
- // special meaning in a regular expression -- so this function does
- // that. (This also makes it identical to the perl function of the
- // same name; see `perldoc -f quotemeta`.)
- for (int ii = 0; ii < unquoted.size(); ++ii) {
- // Note that using 'isalnum' here raises the benchmark time from
- // 32ns to 58ns:
- if ((unquoted[ii] < 'a' || unquoted[ii] > 'z') &&
- (unquoted[ii] < 'A' || unquoted[ii] > 'Z') &&
- (unquoted[ii] < '0' || unquoted[ii] > '9') &&
- unquoted[ii] != '_' &&
- // If this is the part of a UTF8 or Latin1 character, we need
- // to copy this byte without escaping. Experimentally this is
- // what works correctly with the regexp library.
- !(unquoted[ii] & 128)) {
- result += '\\';
- }
- result += unquoted[ii];
- }
-
- return result;
-}
-
-/***** Actual matching and rewriting code *****/
-
-int RE::TryMatch(const StringPiece& text,
- int startpos,
- Anchor anchor,
- int *vec,
- int vecsize) const {
- pcre* re = (anchor == ANCHOR_BOTH) ? re_full_ : re_partial_;
- if (re == NULL) {
- //fprintf(stderr, "Matching against invalid re: %s\n", error_->c_str());
- return 0;
- }
-
- pcre_extra extra = { 0 };
- if (options_.match_limit() > 0) {
- extra.flags |= PCRE_EXTRA_MATCH_LIMIT;
- extra.match_limit = options_.match_limit();
- }
- if (options_.match_limit_recursion() > 0) {
- extra.flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
- extra.match_limit_recursion = options_.match_limit_recursion();
- }
- int rc = pcre_exec(re, // The regular expression object
- &extra,
- (text.data() == NULL) ? "" : text.data(),
- text.size(),
- startpos,
- (anchor == UNANCHORED) ? 0 : PCRE_ANCHORED,
- vec,
- vecsize);
-
- // Handle errors
- if (rc == PCRE_ERROR_NOMATCH) {
- return 0;
- } else if (rc < 0) {
- //fprintf(stderr, "Unexpected return code: %d when matching '%s'\n",
- // re, pattern_.c_str());
- return 0;
- } else if (rc == 0) {
- // pcre_exec() returns 0 as a special case when the number of
- // capturing subpatterns exceeds the size of the vector.
- // When this happens, there is a match and the output vector
- // is filled, but we miss out on the positions of the extra subpatterns.
- rc = vecsize / 2;
- }
-
- if ((anchor == ANCHOR_BOTH) && (re_full_ == re_partial_)) {
- // We need an extra check to make sure that the match extended
- // to the end of the input string
- assert(vec[0] == 0); // PCRE_ANCHORED forces starting match
- if (vec[1] != text.size()) return 0; // Did not get ending match
- }
-
- return rc;
-}
-
-bool RE::DoMatchImpl(const StringPiece& text,
- Anchor anchor,
- int* consumed,
- const Arg* const* args,
- int n,
- int* vec,
- int vecsize) const {
- assert((1 + n) * 3 <= vecsize); // results + PCRE workspace
- int matches = TryMatch(text, 0, anchor, vec, vecsize);
- assert(matches >= 0); // TryMatch never returns negatives
- if (matches == 0)
- return false;
-
- *consumed = vec[1];
-
- if (n == 0 || args == NULL) {
- // We are not interested in results
- return true;
- }
-
- if (NumberOfCapturingGroups() < n) {
- // RE has fewer capturing groups than number of arg pointers passed in
- return false;
- }
-
- // If we got here, we must have matched the whole pattern.
- // We do not need (can not do) any more checks on the value of 'matches' here
- // -- see the comment for TryMatch.
- for (int i = 0; i < n; i++) {
- const int start = vec[2*(i+1)];
- const int limit = vec[2*(i+1)+1];
- if (!args[i]->Parse(text.data() + start, limit-start)) {
- // TODO: Should we indicate what the error was?
- return false;
- }
- }
-
- return true;
-}
-
-bool RE::DoMatch(const StringPiece& text,
- Anchor anchor,
- int* consumed,
- const Arg* const args[],
- int n) const {
- assert(n >= 0);
- size_t const vecsize = (1 + n) * 3; // results + PCRE workspace
- // (as for kVecSize)
- int space[21]; // use stack allocation for small vecsize (common case)
- int* vec = vecsize <= 21 ? space : new int[vecsize];
- bool retval = DoMatchImpl(text, anchor, consumed, args, n, vec, vecsize);
- if (vec != space) delete [] vec;
- return retval;
-}
-
-bool RE::Rewrite(string *out, const StringPiece &rewrite,
- const StringPiece &text, int *vec, int veclen) const {
- for (const char *s = rewrite.data(), *end = s + rewrite.size();
- s < end; s++) {
- int c = *s;
- if (c == '\\') {
- c = *++s;
- if (isdigit(c)) {
- int n = (c - '0');
- if (n >= veclen) {
- //fprintf(stderr, requested group %d in regexp %.*s\n",
- // n, rewrite.size(), rewrite.data());
- return false;
- }
- int start = vec[2 * n];
- if (start >= 0)
- out->append(text.data() + start, vec[2 * n + 1] - start);
- } else if (c == '\\') {
- out->push_back('\\');
- } else {
- //fprintf(stderr, "invalid rewrite pattern: %.*s\n",
- // rewrite.size(), rewrite.data());
- return false;
- }
- } else {
- out->push_back(c);
- }
- }
- return true;
-}
-
-// Return the number of capturing subpatterns, or -1 if the
-// regexp wasn't valid on construction.
-int RE::NumberOfCapturingGroups() const {
- if (re_partial_ == NULL) return -1;
-
- int result;
- int pcre_retval = pcre_fullinfo(re_partial_, // The regular expression object
- NULL, // We did not study the pattern
- PCRE_INFO_CAPTURECOUNT,
- &result);
- assert(pcre_retval == 0);
- return result;
-}
-
-/***** Parsers for various types *****/
-
-bool Arg::parse_null(const char* str, int n, void* dest) {
- // We fail if somebody asked us to store into a non-NULL void* pointer
- return (dest == NULL);
-}
-
-bool Arg::parse_string(const char* str, int n, void* dest) {
- reinterpret_cast<string*>(dest)->assign(str, n);
- return true;
-}
-
-bool Arg::parse_stringpiece(const char* str, int n, void* dest) {
- reinterpret_cast<StringPiece*>(dest)->set(str, n);
- return true;
-}
-
-bool Arg::parse_char(const char* str, int n, void* dest) {
- if (n != 1) return false;
- *(reinterpret_cast<char*>(dest)) = str[0];
- return true;
-}
-
-bool Arg::parse_uchar(const char* str, int n, void* dest) {
- if (n != 1) return false;
- *(reinterpret_cast<unsigned char*>(dest)) = str[0];
- return true;
-}
-
-// Largest number spec that we are willing to parse
-static const int kMaxNumberLength = 32;
-
-// REQUIRES "buf" must have length at least kMaxNumberLength+1
-// REQUIRES "n > 0"
-// Copies "str" into "buf" and null-terminates if necessary.
-// Returns one of:
-// a. "str" if no termination is needed
-// b. "buf" if the string was copied and null-terminated
-// c. "" if the input was invalid and has no hope of being parsed
-static const char* TerminateNumber(char* buf, const char* str, int n) {
- if ((n > 0) && isspace(*str)) {
- // We are less forgiving than the strtoxxx() routines and do not
- // allow leading spaces.
- return "";
- }
-
- // See if the character right after the input text may potentially
- // look like a digit.
- if (isdigit(str[n]) ||
- ((str[n] >= 'a') && (str[n] <= 'f')) ||
- ((str[n] >= 'A') && (str[n] <= 'F'))) {
- if (n > kMaxNumberLength) return ""; // Input too big to be a valid number
- memcpy(buf, str, n);
- buf[n] = '\0';
- return buf;
- } else {
- // We can parse right out of the supplied string, so return it.
- return str;
- }
-}
-
-bool Arg::parse_long_radix(const char* str,
- int n,
- void* dest,
- int radix) {
- if (n == 0) return false;
- char buf[kMaxNumberLength+1];
- str = TerminateNumber(buf, str, n);
- char* end;
- errno = 0;
- long r = strtol(str, &end, radix);
- if (end != str + n) return false; // Leftover junk
- if (errno) return false;
- *(reinterpret_cast<long*>(dest)) = r;
- return true;
-}
-
-bool Arg::parse_ulong_radix(const char* str,
- int n,
- void* dest,
- int radix) {
- if (n == 0) return false;
- char buf[kMaxNumberLength+1];
- str = TerminateNumber(buf, str, n);
- if (str[0] == '-') return false; // strtoul() on a negative number?!
- char* end;
- errno = 0;
- unsigned long r = strtoul(str, &end, radix);
- if (end != str + n) return false; // Leftover junk
- if (errno) return false;
- *(reinterpret_cast<unsigned long*>(dest)) = r;
- return true;
-}
-
-bool Arg::parse_short_radix(const char* str,
- int n,
- void* dest,
- int radix) {
- long r;
- if (!parse_long_radix(str, n, &r, radix)) return false; // Could not parse
- if (r < SHRT_MIN || r > SHRT_MAX) return false; // Out of range
- *(reinterpret_cast<short*>(dest)) = r;
- return true;
-}
-
-bool Arg::parse_ushort_radix(const char* str,
- int n,
- void* dest,
- int radix) {
- unsigned long r;
- if (!parse_ulong_radix(str, n, &r, radix)) return false; // Could not parse
- if (r > USHRT_MAX) return false; // Out of range
- *(reinterpret_cast<unsigned short*>(dest)) = r;
- return true;
-}
-
-bool Arg::parse_int_radix(const char* str,
- int n,
- void* dest,
- int radix) {
- long r;
- if (!parse_long_radix(str, n, &r, radix)) return false; // Could not parse
- if (r < INT_MIN || r > INT_MAX) return false; // Out of range
- *(reinterpret_cast<int*>(dest)) = r;
- return true;
-}
-
-bool Arg::parse_uint_radix(const char* str,
- int n,
- void* dest,
- int radix) {
- unsigned long r;
- if (!parse_ulong_radix(str, n, &r, radix)) return false; // Could not parse
- if (r > UINT_MAX) return false; // Out of range
- *(reinterpret_cast<unsigned int*>(dest)) = r;
- return true;
-}
-
-bool Arg::parse_longlong_radix(const char* str,
- int n,
- void* dest,
- int radix) {
-#ifndef HAVE_LONG_LONG
- return false;
-#else
- if (n == 0) return false;
- char buf[kMaxNumberLength+1];
- str = TerminateNumber(buf, str, n);
- char* end;
- errno = 0;
-#if defined HAVE_STRTOQ
- long long r = strtoq(str, &end, radix);
-#elif defined HAVE_STRTOLL
- long long r = strtoll(str, &end, radix);
-#else
-#error parse_longlong_radix: cannot convert input to a long-long
-#endif
- if (end != str + n) return false; // Leftover junk
- if (errno) return false;
- *(reinterpret_cast<long long*>(dest)) = r;
- return true;
-#endif /* HAVE_LONG_LONG */
-}
-
-bool Arg::parse_ulonglong_radix(const char* str,
- int n,
- void* dest,
- int radix) {
-#ifndef HAVE_UNSIGNED_LONG_LONG
- return false;
-#else
- if (n == 0) return false;
- char buf[kMaxNumberLength+1];
- str = TerminateNumber(buf, str, n);
- if (str[0] == '-') return false; // strtoull() on a negative number?!
- char* end;
- errno = 0;
-#if defined HAVE_STRTOQ
- unsigned long long r = strtouq(str, &end, radix);
-#elif defined HAVE_STRTOLL
- unsigned long long r = strtoull(str, &end, radix);
-#else
-#error parse_ulonglong_radix: cannot convert input to a long-long
-#endif
- if (end != str + n) return false; // Leftover junk
- if (errno) return false;
- *(reinterpret_cast<unsigned long long*>(dest)) = r;
- return true;
-#endif /* HAVE_UNSIGNED_LONG_LONG */
-}
-
-bool Arg::parse_double(const char* str, int n, void* dest) {
- if (n == 0) return false;
- static const int kMaxLength = 200;
- char buf[kMaxLength];
- if (n >= kMaxLength) return false;
- memcpy(buf, str, n);
- buf[n] = '\0';
- errno = 0;
- char* end;
- double r = strtod(buf, &end);
- if (end != buf + n) return false; // Leftover junk
- if (errno) return false;
- *(reinterpret_cast<double*>(dest)) = r;
- return true;
-}
-
-bool Arg::parse_float(const char* str, int n, void* dest) {
- double r;
- if (!parse_double(str, n, &r)) return false;
- *(reinterpret_cast<float*>(dest)) = static_cast<float>(r);
- return true;
-}
-
-
-#define DEFINE_INTEGER_PARSERS(name) \
- bool Arg::parse_##name(const char* str, int n, void* dest) { \
- return parse_##name##_radix(str, n, dest, 10); \
- } \
- bool Arg::parse_##name##_hex(const char* str, int n, void* dest) { \
- return parse_##name##_radix(str, n, dest, 16); \
- } \
- bool Arg::parse_##name##_octal(const char* str, int n, void* dest) { \
- return parse_##name##_radix(str, n, dest, 8); \
- } \
- bool Arg::parse_##name##_cradix(const char* str, int n, void* dest) { \
- return parse_##name##_radix(str, n, dest, 0); \
- }
-
-DEFINE_INTEGER_PARSERS(short) /* */
-DEFINE_INTEGER_PARSERS(ushort) /* */
-DEFINE_INTEGER_PARSERS(int) /* Don't use semicolons after these */
-DEFINE_INTEGER_PARSERS(uint) /* statements because they can cause */
-DEFINE_INTEGER_PARSERS(long) /* compiler warnings if the checking */
-DEFINE_INTEGER_PARSERS(ulong) /* level is turned up high enough. */
-DEFINE_INTEGER_PARSERS(longlong) /* */
-DEFINE_INTEGER_PARSERS(ulonglong) /* */
-
-#undef DEFINE_INTEGER_PARSERS
-
-} // namespace pcrecpp
diff --git a/ext/pcre/pcrelib/pcrecpp.h b/ext/pcre/pcrelib/pcrecpp.h
deleted file mode 100644
index e3f1b716c2..0000000000
--- a/ext/pcre/pcrelib/pcrecpp.h
+++ /dev/null
@@ -1,695 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sanjay Ghemawat
-// Support for PCRE_XXX modifiers added by Giuseppe Maxia, July 2005
-
-#ifndef _PCRECPP_H
-#define _PCRECPP_H
-
-// C++ interface to the pcre regular-expression library. RE supports
-// Perl-style regular expressions (with extensions like \d, \w, \s,
-// ...).
-//
-// -----------------------------------------------------------------------
-// REGEXP SYNTAX:
-//
-// This module is part of the pcre library and hence supports its syntax
-// for regular expressions.
-//
-// The syntax is pretty similar to Perl's. For those not familiar
-// with Perl's regular expressions, here are some examples of the most
-// commonly used extensions:
-//
-// "hello (\\w+) world" -- \w matches a "word" character
-// "version (\\d+)" -- \d matches a digit
-// "hello\\s+world" -- \s matches any whitespace character
-// "\\b(\\w+)\\b" -- \b matches empty string at a word boundary
-// "(?i)hello" -- (?i) turns on case-insensitive matching
-// "/\\*(.*?)\\*/" -- .*? matches . minimum no. of times possible
-//
-// -----------------------------------------------------------------------
-// MATCHING INTERFACE:
-//
-// The "FullMatch" operation checks that supplied text matches a
-// supplied pattern exactly.
-//
-// Example: successful match
-// pcrecpp::RE re("h.*o");
-// re.FullMatch("hello");
-//
-// Example: unsuccessful match (requires full match):
-// pcrecpp::RE re("e");
-// !re.FullMatch("hello");
-//
-// Example: creating a temporary RE object:
-// pcrecpp::RE("h.*o").FullMatch("hello");
-//
-// You can pass in a "const char*" or a "string" for "text". The
-// examples below tend to use a const char*.
-//
-// You can, as in the different examples above, store the RE object
-// explicitly in a variable or use a temporary RE object. The
-// examples below use one mode or the other arbitrarily. Either
-// could correctly be used for any of these examples.
-//
-// -----------------------------------------------------------------------
-// MATCHING WITH SUB-STRING EXTRACTION:
-//
-// You can supply extra pointer arguments to extract matched subpieces.
-//
-// Example: extracts "ruby" into "s" and 1234 into "i"
-// int i;
-// string s;
-// pcrecpp::RE re("(\\w+):(\\d+)");
-// re.FullMatch("ruby:1234", &s, &i);
-//
-// Example: does not try to extract any extra sub-patterns
-// re.FullMatch("ruby:1234", &s);
-//
-// Example: does not try to extract into NULL
-// re.FullMatch("ruby:1234", NULL, &i);
-//
-// Example: integer overflow causes failure
-// !re.FullMatch("ruby:1234567891234", NULL, &i);
-//
-// Example: fails because there aren't enough sub-patterns:
-// !pcrecpp::RE("\\w+:\\d+").FullMatch("ruby:1234", &s);
-//
-// Example: fails because string cannot be stored in integer
-// !pcrecpp::RE("(.*)").FullMatch("ruby", &i);
-//
-// The provided pointer arguments can be pointers to any scalar numeric
-// type, or one of
-// string (matched piece is copied to string)
-// StringPiece (StringPiece is mutated to point to matched piece)
-// T (where "bool T::ParseFrom(const char*, int)" exists)
-// NULL (the corresponding matched sub-pattern is not copied)
-//
-// CAVEAT: An optional sub-pattern that does not exist in the matched
-// string is assigned the empty string. Therefore, the following will
-// return false (because the empty string is not a valid number):
-// int number;
-// pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
-//
-// -----------------------------------------------------------------------
-// DO_MATCH
-//
-// The matching interface supports at most 16 arguments per call.
-// If you need more, consider using the more general interface
-// pcrecpp::RE::DoMatch(). See pcrecpp.h for the signature for DoMatch.
-//
-// -----------------------------------------------------------------------
-// PARTIAL MATCHES
-//
-// You can use the "PartialMatch" operation when you want the pattern
-// to match any substring of the text.
-//
-// Example: simple search for a string:
-// pcrecpp::RE("ell").PartialMatch("hello");
-//
-// Example: find first number in a string:
-// int number;
-// pcrecpp::RE re("(\\d+)");
-// re.PartialMatch("x*100 + 20", &number);
-// assert(number == 100);
-//
-// -----------------------------------------------------------------------
-// UTF-8 AND THE MATCHING INTERFACE:
-//
-// By default, pattern and text are plain text, one byte per character.
-// The UTF8 flag, passed to the constructor, causes both pattern
-// and string to be treated as UTF-8 text, still a byte stream but
-// potentially multiple bytes per character. In practice, the text
-// is likelier to be UTF-8 than the pattern, but the match returned
-// may depend on the UTF8 flag, so always use it when matching
-// UTF8 text. E.g., "." will match one byte normally but with UTF8
-// set may match up to three bytes of a multi-byte character.
-//
-// Example:
-// pcrecpp::RE_Options options;
-// options.set_utf8();
-// pcrecpp::RE re(utf8_pattern, options);
-// re.FullMatch(utf8_string);
-//
-// Example: using the convenience function UTF8():
-// pcrecpp::RE re(utf8_pattern, pcrecpp::UTF8());
-// re.FullMatch(utf8_string);
-//
-// NOTE: The UTF8 option is ignored if pcre was not configured with the
-// --enable-utf8 flag.
-//
-// -----------------------------------------------------------------------
-// PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
-//
-// PCRE defines some modifiers to change the behavior of the regular
-// expression engine.
-// The C++ wrapper defines an auxiliary class, RE_Options, as a vehicle
-// to pass such modifiers to a RE class.
-//
-// Currently, the following modifiers are supported
-//
-// modifier description Perl corresponding
-//
-// PCRE_CASELESS case insensitive match /i
-// PCRE_MULTILINE multiple lines match /m
-// PCRE_DOTALL dot matches newlines /s
-// PCRE_DOLLAR_ENDONLY $ matches only at end N/A
-// PCRE_EXTRA strict escape parsing N/A
-// PCRE_EXTENDED ignore whitespaces /x
-// PCRE_UTF8 handles UTF8 chars built-in
-// PCRE_UNGREEDY reverses * and *? N/A
-// PCRE_NO_AUTO_CAPTURE disables matching parens N/A (*)
-//
-// (For a full account on how each modifier works, please check the
-// PCRE API reference manual).
-//
-// (*) Both Perl and PCRE allow non matching parentheses by means of the
-// "?:" modifier within the pattern itself. e.g. (?:ab|cd) does not
-// capture, while (ab|cd) does.
-//
-// For each modifier, there are two member functions whose name is made
-// out of the modifier in lowercase, without the "PCRE_" prefix. For
-// instance, PCRE_CASELESS is handled by
-// bool caseless(),
-// which returns true if the modifier is set, and
-// RE_Options & set_caseless(bool),
-// which sets or unsets the modifier.
-//
-// Moreover, PCRE_EXTRA_MATCH_LIMIT can be accessed through the
-// set_match_limit() and match_limit() member functions.
-// Setting match_limit to a non-zero value will limit the executation of
-// pcre to keep it from doing bad things like blowing the stack or taking
-// an eternity to return a result. A value of 5000 is good enough to stop
-// stack blowup in a 2MB thread stack. Setting match_limit to zero will
-// disable match limiting. Alternately, you can set match_limit_recursion()
-// which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to limit how much pcre
-// recurses. match_limit() caps the number of matches pcre does;
-// match_limit_recrusion() caps the depth of recursion.
-//
-// Normally, to pass one or more modifiers to a RE class, you declare
-// a RE_Options object, set the appropriate options, and pass this
-// object to a RE constructor. Example:
-//
-// RE_options opt;
-// opt.set_caseless(true);
-//
-// if (RE("HELLO", opt).PartialMatch("hello world")) ...
-//
-// RE_options has two constructors. The default constructor takes no
-// arguments and creates a set of flags that are off by default.
-//
-// The optional parameter 'option_flags' is to facilitate transfer
-// of legacy code from C programs. This lets you do
-// RE(pattern, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
-//
-// But new code is better off doing
-// RE(pattern,
-// RE_Options().set_caseless(true).set_multiline(true)).PartialMatch(str);
-// (See below)
-//
-// If you are going to pass one of the most used modifiers, there are some
-// convenience functions that return a RE_Options class with the
-// appropriate modifier already set:
-// CASELESS(), UTF8(), MULTILINE(), DOTALL(), EXTENDED()
-//
-// If you need to set several options at once, and you don't want to go
-// through the pains of declaring a RE_Options object and setting several
-// options, there is a parallel method that give you such ability on the
-// fly. You can concatenate several set_xxxxx member functions, since each
-// of them returns a reference to its class object. e.g.: to pass
-// PCRE_CASELESS, PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one
-// statement, you may write
-//
-// RE(" ^ xyz \\s+ .* blah$", RE_Options()
-// .set_caseless(true)
-// .set_extended(true)
-// .set_multiline(true)).PartialMatch(sometext);
-//
-// -----------------------------------------------------------------------
-// SCANNING TEXT INCREMENTALLY
-//
-// The "Consume" operation may be useful if you want to repeatedly
-// match regular expressions at the front of a string and skip over
-// them as they match. This requires use of the "StringPiece" type,
-// which represents a sub-range of a real string. Like RE, StringPiece
-// is defined in the pcrecpp namespace.
-//
-// Example: read lines of the form "var = value" from a string.
-// string contents = ...; // Fill string somehow
-// pcrecpp::StringPiece input(contents); // Wrap in a StringPiece
-//
-// string var;
-// int value;
-// pcrecpp::RE re("(\\w+) = (\\d+)\n");
-// while (re.Consume(&input, &var, &value)) {
-// ...;
-// }
-//
-// Each successful call to "Consume" will set "var/value", and also
-// advance "input" so it points past the matched text.
-//
-// The "FindAndConsume" operation is similar to "Consume" but does not
-// anchor your match at the beginning of the string. For example, you
-// could extract all words from a string by repeatedly calling
-// pcrecpp::RE("(\\w+)").FindAndConsume(&input, &word)
-//
-// -----------------------------------------------------------------------
-// PARSING HEX/OCTAL/C-RADIX NUMBERS
-//
-// By default, if you pass a pointer to a numeric value, the
-// corresponding text is interpreted as a base-10 number. You can
-// instead wrap the pointer with a call to one of the operators Hex(),
-// Octal(), or CRadix() to interpret the text in another base. The
-// CRadix operator interprets C-style "0" (base-8) and "0x" (base-16)
-// prefixes, but defaults to base-10.
-//
-// Example:
-// int a, b, c, d;
-// pcrecpp::RE re("(.*) (.*) (.*) (.*)");
-// re.FullMatch("100 40 0100 0x40",
-// pcrecpp::Octal(&a), pcrecpp::Hex(&b),
-// pcrecpp::CRadix(&c), pcrecpp::CRadix(&d));
-// will leave 64 in a, b, c, and d.
-//
-// -----------------------------------------------------------------------
-// REPLACING PARTS OF STRINGS
-//
-// You can replace the first match of "pattern" in "str" with
-// "rewrite". Within "rewrite", backslash-escaped digits (\1 to \9)
-// can be used to insert text matching corresponding parenthesized
-// group from the pattern. \0 in "rewrite" refers to the entire
-// matching text. E.g.,
-//
-// string s = "yabba dabba doo";
-// pcrecpp::RE("b+").Replace("d", &s);
-//
-// will leave "s" containing "yada dabba doo". The result is true if
-// the pattern matches and a replacement occurs, or false otherwise.
-//
-// GlobalReplace() is like Replace(), except that it replaces all
-// occurrences of the pattern in the string with the rewrite.
-// Replacements are not subject to re-matching. E.g.,
-//
-// string s = "yabba dabba doo";
-// pcrecpp::RE("b+").GlobalReplace("d", &s);
-//
-// will leave "s" containing "yada dada doo". It returns the number
-// of replacements made.
-//
-// Extract() is like Replace(), except that if the pattern matches,
-// "rewrite" is copied into "out" (an additional argument) with
-// substitutions. The non-matching portions of "text" are ignored.
-// Returns true iff a match occurred and the extraction happened
-// successfully. If no match occurs, the string is left unaffected.
-
-
-#include <string>
-#include <pcrecpparg.h> // defines the Arg class
-// These aren't technically needed here, but we include them
-// anyway so folks who include pcrecpp.h don't have to include
-// all these other header files as well.
-#include <pcre.h>
-#include <pcre_stringpiece.h>
-
-namespace pcrecpp {
-
-#define PCRE_SET_OR_CLEAR(b, o) \
- if (b) all_options_ |= (o); else all_options_ &= ~(o); \
- return *this
-
-#define PCRE_IS_SET(o) \
- (all_options_ & o) == o
-
-// We convert user-passed pointers into special Arg objects
-extern Arg no_arg;
-
-/***** Compiling regular expressions: the RE class *****/
-
-// RE_Options allow you to set options to be passed along to pcre,
-// along with other options we put on top of pcre.
-// Only 9 modifiers, plus match_limit and match_limit_recursion,
-// are supported now.
-class RE_Options {
- public:
- // constructor
- RE_Options() : match_limit_(0), match_limit_recursion_(0), all_options_(0) {}
-
- // alternative constructor.
- // To facilitate transfer of legacy code from C programs
- //
- // This lets you do
- // RE(pattern, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
- // But new code is better off doing
- // RE(pattern,
- // RE_Options().set_caseless(true).set_multiline(true)).PartialMatch(str);
- RE_Options(int option_flags) : match_limit_(0), match_limit_recursion_(0),
- all_options_(option_flags) {}
- // we're fine with the default destructor, copy constructor, etc.
-
- // accessors and mutators
- int match_limit() const { return match_limit_; };
- RE_Options &set_match_limit(int limit) {
- match_limit_ = limit;
- return *this;
- }
-
- int match_limit_recursion() const { return match_limit_recursion_; };
- RE_Options &set_match_limit_recursion(int limit) {
- match_limit_recursion_ = limit;
- return *this;
- }
-
- bool caseless() const {
- return PCRE_IS_SET(PCRE_CASELESS);
- }
- RE_Options &set_caseless(bool x) {
- PCRE_SET_OR_CLEAR(x, PCRE_CASELESS);
- }
-
- bool multiline() const {
- return PCRE_IS_SET(PCRE_MULTILINE);
- }
- RE_Options &set_multiline(bool x) {
- PCRE_SET_OR_CLEAR(x, PCRE_MULTILINE);
- }
-
- bool dotall() const {
- return PCRE_IS_SET(PCRE_DOTALL);
- }
- RE_Options &set_dotall(bool x) {
- PCRE_SET_OR_CLEAR(x,PCRE_DOTALL);
- }
-
- bool extended() const {
- return PCRE_IS_SET(PCRE_EXTENDED);
- }
- RE_Options &set_extended(bool x) {
- PCRE_SET_OR_CLEAR(x,PCRE_EXTENDED);
- }
-
- bool dollar_endonly() const {
- return PCRE_IS_SET(PCRE_DOLLAR_ENDONLY);
- }
- RE_Options &set_dollar_endonly(bool x) {
- PCRE_SET_OR_CLEAR(x,PCRE_DOLLAR_ENDONLY);
- }
-
- bool extra() const {
- return PCRE_IS_SET( PCRE_EXTRA);
- }
- RE_Options &set_extra(bool x) {
- PCRE_SET_OR_CLEAR(x, PCRE_EXTRA);
- }
-
- bool ungreedy() const {
- return PCRE_IS_SET(PCRE_UNGREEDY);
- }
- RE_Options &set_ungreedy(bool x) {
- PCRE_SET_OR_CLEAR(x, PCRE_UNGREEDY);
- }
-
- bool utf8() const {
- return PCRE_IS_SET(PCRE_UTF8);
- }
- RE_Options &set_utf8(bool x) {
- PCRE_SET_OR_CLEAR(x, PCRE_UTF8);
- }
-
- bool no_auto_capture() const {
- return PCRE_IS_SET(PCRE_NO_AUTO_CAPTURE);
- }
- RE_Options &set_no_auto_capture(bool x) {
- PCRE_SET_OR_CLEAR(x, PCRE_NO_AUTO_CAPTURE);
- }
-
- RE_Options &set_all_options(int opt) {
- all_options_ = opt;
- return *this;
- }
- int all_options() const {
- return all_options_ ;
- }
-
- // TODO: add other pcre flags
-
- private:
- int match_limit_;
- int match_limit_recursion_;
- int all_options_;
-};
-
-// These functions return some common RE_Options
-static inline RE_Options UTF8() {
- return RE_Options().set_utf8(true);
-}
-
-static inline RE_Options CASELESS() {
- return RE_Options().set_caseless(true);
-}
-static inline RE_Options MULTILINE() {
- return RE_Options().set_multiline(true);
-}
-
-static inline RE_Options DOTALL() {
- return RE_Options().set_dotall(true);
-}
-
-static inline RE_Options EXTENDED() {
- return RE_Options().set_extended(true);
-}
-
-// Interface for regular expression matching. Also corresponds to a
-// pre-compiled regular expression. An "RE" object is safe for
-// concurrent use by multiple threads.
-class RE {
- public:
- // We provide implicit conversions from strings so that users can
- // pass in a string or a "const char*" wherever an "RE" is expected.
- RE(const char* pat) { Init(pat, NULL); }
- RE(const char *pat, const RE_Options& option) { Init(pat, &option); }
- RE(const string& pat) { Init(pat, NULL); }
- RE(const string& pat, const RE_Options& option) { Init(pat, &option); }
-
- // Copy constructor & assignment - note that these are expensive
- // because they recompile the expression.
- RE(const RE& re) { Init(re.pattern_, &re.options_); }
- const RE& operator=(const RE& re) {
- if (this != &re) {
- Cleanup();
-
- // This is the code that originally came from Google
- // Init(re.pattern_.c_str(), &re.options_);
-
- // This is the replacement from Ari Pollak
- Init(re.pattern_, &re.options_);
- }
- return *this;
- }
-
-
- ~RE();
-
- // The string specification for this RE. E.g.
- // RE re("ab*c?d+");
- // re.pattern(); // "ab*c?d+"
- const string& pattern() const { return pattern_; }
-
- // If RE could not be created properly, returns an error string.
- // Else returns the empty string.
- const string& error() const { return *error_; }
-
- /***** The useful part: the matching interface *****/
-
- // This is provided so one can do pattern.ReplaceAll() just as
- // easily as ReplaceAll(pattern-text, ....)
-
- bool FullMatch(const StringPiece& text,
- const Arg& ptr1 = no_arg,
- const Arg& ptr2 = no_arg,
- const Arg& ptr3 = no_arg,
- const Arg& ptr4 = no_arg,
- const Arg& ptr5 = no_arg,
- const Arg& ptr6 = no_arg,
- const Arg& ptr7 = no_arg,
- const Arg& ptr8 = no_arg,
- const Arg& ptr9 = no_arg,
- const Arg& ptr10 = no_arg,
- const Arg& ptr11 = no_arg,
- const Arg& ptr12 = no_arg,
- const Arg& ptr13 = no_arg,
- const Arg& ptr14 = no_arg,
- const Arg& ptr15 = no_arg,
- const Arg& ptr16 = no_arg) const;
-
- bool PartialMatch(const StringPiece& text,
- const Arg& ptr1 = no_arg,
- const Arg& ptr2 = no_arg,
- const Arg& ptr3 = no_arg,
- const Arg& ptr4 = no_arg,
- const Arg& ptr5 = no_arg,
- const Arg& ptr6 = no_arg,
- const Arg& ptr7 = no_arg,
- const Arg& ptr8 = no_arg,
- const Arg& ptr9 = no_arg,
- const Arg& ptr10 = no_arg,
- const Arg& ptr11 = no_arg,
- const Arg& ptr12 = no_arg,
- const Arg& ptr13 = no_arg,
- const Arg& ptr14 = no_arg,
- const Arg& ptr15 = no_arg,
- const Arg& ptr16 = no_arg) const;
-
- bool Consume(StringPiece* input,
- const Arg& ptr1 = no_arg,
- const Arg& ptr2 = no_arg,
- const Arg& ptr3 = no_arg,
- const Arg& ptr4 = no_arg,
- const Arg& ptr5 = no_arg,
- const Arg& ptr6 = no_arg,
- const Arg& ptr7 = no_arg,
- const Arg& ptr8 = no_arg,
- const Arg& ptr9 = no_arg,
- const Arg& ptr10 = no_arg,
- const Arg& ptr11 = no_arg,
- const Arg& ptr12 = no_arg,
- const Arg& ptr13 = no_arg,
- const Arg& ptr14 = no_arg,
- const Arg& ptr15 = no_arg,
- const Arg& ptr16 = no_arg) const;
-
- bool FindAndConsume(StringPiece* input,
- const Arg& ptr1 = no_arg,
- const Arg& ptr2 = no_arg,
- const Arg& ptr3 = no_arg,
- const Arg& ptr4 = no_arg,
- const Arg& ptr5 = no_arg,
- const Arg& ptr6 = no_arg,
- const Arg& ptr7 = no_arg,
- const Arg& ptr8 = no_arg,
- const Arg& ptr9 = no_arg,
- const Arg& ptr10 = no_arg,
- const Arg& ptr11 = no_arg,
- const Arg& ptr12 = no_arg,
- const Arg& ptr13 = no_arg,
- const Arg& ptr14 = no_arg,
- const Arg& ptr15 = no_arg,
- const Arg& ptr16 = no_arg) const;
-
- bool Replace(const StringPiece& rewrite,
- string *str) const;
-
- int GlobalReplace(const StringPiece& rewrite,
- string *str) const;
-
- bool Extract(const StringPiece &rewrite,
- const StringPiece &text,
- string *out) const;
-
- // Escapes all potentially meaningful regexp characters in
- // 'unquoted'. The returned string, used as a regular expression,
- // will exactly match the original string. For example,
- // 1.5-2.0?
- // may become:
- // 1\.5\-2\.0\?
- static string QuoteMeta(const StringPiece& unquoted);
-
-
- /***** Generic matching interface *****/
-
- // Type of match (TODO: Should be restructured as part of RE_Options)
- enum Anchor {
- UNANCHORED, // No anchoring
- ANCHOR_START, // Anchor at start only
- ANCHOR_BOTH // Anchor at start and end
- };
-
- // General matching routine. Stores the length of the match in
- // "*consumed" if successful.
- bool DoMatch(const StringPiece& text,
- Anchor anchor,
- int* consumed,
- const Arg* const* args, int n) const;
-
- // Return the number of capturing subpatterns, or -1 if the
- // regexp wasn't valid on construction.
- int NumberOfCapturingGroups() const;
-
- private:
-
- void Init(const string& pattern, const RE_Options* options);
- void Cleanup();
-
- // Match against "text", filling in "vec" (up to "vecsize" * 2/3) with
- // pairs of integers for the beginning and end positions of matched
- // text. The first pair corresponds to the entire matched text;
- // subsequent pairs correspond, in order, to parentheses-captured
- // matches. Returns the number of pairs (one more than the number of
- // the last subpattern with a match) if matching was successful
- // and zero if the match failed.
- // I.e. for RE("(foo)|(bar)|(baz)") it will return 2, 3, and 4 when matching
- // against "foo", "bar", and "baz" respectively.
- // When matching RE("(foo)|hello") against "hello", it will return 1.
- // But the values for all subpattern are filled in into "vec".
- int TryMatch(const StringPiece& text,
- int startpos,
- Anchor anchor,
- int *vec,
- int vecsize) const;
-
- // Append the "rewrite" string, with backslash subsitutions from "text"
- // and "vec", to string "out".
- bool Rewrite(string *out,
- const StringPiece& rewrite,
- const StringPiece& text,
- int *vec,
- int veclen) const;
-
- // internal implementation for DoMatch
- bool DoMatchImpl(const StringPiece& text,
- Anchor anchor,
- int* consumed,
- const Arg* const args[],
- int n,
- int* vec,
- int vecsize) const;
-
- // Compile the regexp for the specified anchoring mode
- pcre* Compile(Anchor anchor);
-
- string pattern_;
- RE_Options options_;
- pcre* re_full_; // For full matches
- pcre* re_partial_; // For partial matches
- const string* error_; // Error indicator (or points to empty string)
-};
-
-} // namespace pcrecpp
-
-#endif /* _PCRECPP_H */
diff --git a/ext/pcre/pcrelib/pcrecpp_unittest.cc b/ext/pcre/pcrelib/pcrecpp_unittest.cc
deleted file mode 100644
index 858728cd4e..0000000000
--- a/ext/pcre/pcrelib/pcrecpp_unittest.cc
+++ /dev/null
@@ -1,1227 +0,0 @@
-// -*- coding: utf-8 -*-
-//
-// Copyright (c) 2005 - 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sanjay Ghemawat
-//
-// TODO: Test extractions for PartialMatch/Consume
-
-#include <stdio.h>
-#include <cassert>
-#include <vector>
-#include "config.h"
-#include "pcrecpp.h"
-
-using pcrecpp::StringPiece;
-using pcrecpp::RE;
-using pcrecpp::RE_Options;
-using pcrecpp::Hex;
-using pcrecpp::Octal;
-using pcrecpp::CRadix;
-
-static bool VERBOSE_TEST = false;
-
-// CHECK dies with a fatal error if condition is not true. It is *not*
-// controlled by NDEBUG, so the check will be executed regardless of
-// compilation mode. Therefore, it is safe to do things like:
-// CHECK_EQ(fp->Write(x), 4)
-#define CHECK(condition) do { \
- if (!(condition)) { \
- fprintf(stderr, "%s:%d: Check failed: %s\n", \
- __FILE__, __LINE__, #condition); \
- exit(1); \
- } \
-} while (0)
-
-#define CHECK_EQ(a, b) CHECK(a == b)
-
-static void Timing1(int num_iters) {
- // Same pattern lots of times
- RE pattern("ruby:\\d+");
- StringPiece p("ruby:1234");
- for (int j = num_iters; j > 0; j--) {
- CHECK(pattern.FullMatch(p));
- }
-}
-
-static void Timing2(int num_iters) {
- // Same pattern lots of times
- RE pattern("ruby:(\\d+)");
- int i;
- for (int j = num_iters; j > 0; j--) {
- CHECK(pattern.FullMatch("ruby:1234", &i));
- CHECK_EQ(i, 1234);
- }
-}
-
-static void Timing3(int num_iters) {
- string text_string;
- for (int j = num_iters; j > 0; j--) {
- text_string += "this is another line\n";
- }
-
- RE line_matcher(".*\n");
- string line;
- StringPiece text(text_string);
- int counter = 0;
- while (line_matcher.Consume(&text)) {
- counter++;
- }
- printf("Matched %d lines\n", counter);
-}
-
-#if 0 // uncomment this if you have a way of defining VirtualProcessSize()
-
-static void LeakTest() {
- // Check for memory leaks
- unsigned long long initial_size = 0;
- for (int i = 0; i < 100000; i++) {
- if (i == 50000) {
- initial_size = VirtualProcessSize();
- printf("Size after 50000: %llu\n", initial_size);
- }
- char buf[100];
- snprintf(buf, sizeof(buf), "pat%09d", i);
- RE newre(buf);
- }
- uint64 final_size = VirtualProcessSize();
- printf("Size after 100000: %llu\n", final_size);
- const double growth = double(final_size - initial_size) / final_size;
- printf("Growth: %0.2f%%", growth * 100);
- CHECK(growth < 0.02); // Allow < 2% growth
-}
-
-#endif
-
-static void RadixTests() {
- printf("Testing hex\n");
-
-#define CHECK_HEX(type, value) \
- do { \
- type v; \
- CHECK(RE("([0-9a-fA-F]+)[uUlL]*").FullMatch(#value, Hex(&v))); \
- CHECK_EQ(v, 0x ## value); \
- CHECK(RE("([0-9a-fA-FxX]+)[uUlL]*").FullMatch("0x" #value, CRadix(&v))); \
- CHECK_EQ(v, 0x ## value); \
- } while(0)
-
- CHECK_HEX(short, 2bad);
- CHECK_HEX(unsigned short, 2badU);
- CHECK_HEX(int, dead);
- CHECK_HEX(unsigned int, deadU);
- CHECK_HEX(long, 7eadbeefL);
- CHECK_HEX(unsigned long, deadbeefUL);
-#ifdef HAVE_LONG_LONG
- CHECK_HEX(long long, 12345678deadbeefLL);
-#endif
-#ifdef HAVE_UNSIGNED_LONG_LONG
- CHECK_HEX(unsigned long long, cafebabedeadbeefULL);
-#endif
-
-#undef CHECK_HEX
-
- printf("Testing octal\n");
-
-#define CHECK_OCTAL(type, value) \
- do { \
- type v; \
- CHECK(RE("([0-7]+)[uUlL]*").FullMatch(#value, Octal(&v))); \
- CHECK_EQ(v, 0 ## value); \
- CHECK(RE("([0-9a-fA-FxX]+)[uUlL]*").FullMatch("0" #value, CRadix(&v))); \
- CHECK_EQ(v, 0 ## value); \
- } while(0)
-
- CHECK_OCTAL(short, 77777);
- CHECK_OCTAL(unsigned short, 177777U);
- CHECK_OCTAL(int, 17777777777);
- CHECK_OCTAL(unsigned int, 37777777777U);
- CHECK_OCTAL(long, 17777777777L);
- CHECK_OCTAL(unsigned long, 37777777777UL);
-#ifdef HAVE_LONG_LONG
- CHECK_OCTAL(long long, 777777777777777777777LL);
-#endif
-#ifdef HAVE_UNSIGNED_LONG_LONG
- CHECK_OCTAL(unsigned long long, 1777777777777777777777ULL);
-#endif
-
-#undef CHECK_OCTAL
-
- printf("Testing decimal\n");
-
-#define CHECK_DECIMAL(type, value) \
- do { \
- type v; \
- CHECK(RE("(-?[0-9]+)[uUlL]*").FullMatch(#value, &v)); \
- CHECK_EQ(v, value); \
- CHECK(RE("(-?[0-9a-fA-FxX]+)[uUlL]*").FullMatch(#value, CRadix(&v))); \
- CHECK_EQ(v, value); \
- } while(0)
-
- CHECK_DECIMAL(short, -1);
- CHECK_DECIMAL(unsigned short, 9999);
- CHECK_DECIMAL(int, -1000);
- CHECK_DECIMAL(unsigned int, 12345U);
- CHECK_DECIMAL(long, -10000000L);
- CHECK_DECIMAL(unsigned long, 3083324652U);
-#ifdef HAVE_LONG_LONG
- CHECK_DECIMAL(long long, -100000000000000LL);
-#endif
-#ifdef HAVE_UNSIGNED_LONG_LONG
- CHECK_DECIMAL(unsigned long long, 1234567890987654321ULL);
-#endif
-
-#undef CHECK_DECIMAL
-
-}
-
-static void TestReplace() {
- printf("Testing Replace\n");
-
- struct ReplaceTest {
- const char *regexp;
- const char *rewrite;
- const char *original;
- const char *single;
- const char *global;
- };
- static const ReplaceTest tests[] = {
- { "(qu|[b-df-hj-np-tv-z]*)([a-z]+)",
- "\\2\\1ay",
- "the quick brown fox jumps over the lazy dogs.",
- "ethay quick brown fox jumps over the lazy dogs.",
- "ethay ickquay ownbray oxfay umpsjay overay ethay azylay ogsday." },
- { "\\w+",
- "\\0-NOSPAM",
- "paul.haahr@google.com",
- "paul-NOSPAM.haahr@google.com",
- "paul-NOSPAM.haahr-NOSPAM@google-NOSPAM.com-NOSPAM" },
- { "^",
- "(START)",
- "foo",
- "(START)foo",
- "(START)foo" },
- { "^",
- "(START)",
- "",
- "(START)",
- "(START)" },
- { "$",
- "(END)",
- "",
- "(END)",
- "(END)" },
- { "b",
- "bb",
- "ababababab",
- "abbabababab",
- "abbabbabbabbabb" },
- { "b",
- "bb",
- "bbbbbb",
- "bbbbbbb",
- "bbbbbbbbbbbb" },
- { "b+",
- "bb",
- "bbbbbb",
- "bb",
- "bb" },
- { "b*",
- "bb",
- "bbbbbb",
- "bb",
- "bb" },
- { "b*",
- "bb",
- "aaaaa",
- "bbaaaaa",
- "bbabbabbabbabbabb" },
- { "b*",
- "bb",
- "aa\naa\n",
- "bbaa\naa\n",
- "bbabbabb\nbbabbabb\nbb" },
- { "b*",
- "bb",
- "aa\raa\r",
- "bbaa\raa\r",
- "bbabbabb\rbbabbabb\rbb" },
- { "b*",
- "bb",
- "aa\r\naa\r\n",
- "bbaa\r\naa\r\n",
- "bbabbabb\r\nbbabbabb\r\nbb" },
-#ifdef SUPPORT_UTF8
- { "b*",
- "bb",
- "\xE3\x83\x9B\xE3\x83\xBC\xE3\x83\xA0\xE3\x81\xB8", // utf8
- "bb\xE3\x83\x9B\xE3\x83\xBC\xE3\x83\xA0\xE3\x81\xB8",
- "bb\xE3\x83\x9B""bb""\xE3\x83\xBC""bb""\xE3\x83\xA0""bb""\xE3\x81\xB8""bb" },
- { "b*",
- "bb",
- "\xE3\x83\x9B\r\n\xE3\x83\xBC\r\xE3\x83\xA0\n\xE3\x81\xB8\r\n", // utf8
- "bb\xE3\x83\x9B\r\n\xE3\x83\xBC\r\xE3\x83\xA0\n\xE3\x81\xB8\r\n",
- ("bb\xE3\x83\x9B""bb\r\nbb""\xE3\x83\xBC""bb\rbb""\xE3\x83\xA0"
- "bb\nbb""\xE3\x81\xB8""bb\r\nbb") },
-#endif
- { "", NULL, NULL, NULL, NULL }
- };
-
-#ifdef SUPPORT_UTF8
- const bool support_utf8 = true;
-#else
- const bool support_utf8 = false;
-#endif
-
- for (const ReplaceTest *t = tests; t->original != NULL; ++t) {
- RE re(t->regexp, RE_Options(PCRE_NEWLINE_CRLF).set_utf8(support_utf8));
- assert(re.error().empty());
- string one(t->original);
- CHECK(re.Replace(t->rewrite, &one));
- CHECK_EQ(one, t->single);
- string all(t->original);
- CHECK(re.GlobalReplace(t->rewrite, &all) > 0);
- CHECK_EQ(all, t->global);
- }
-
- // One final test: test \r\n replacement when we're not in CRLF mode
- {
- RE re("b*", RE_Options(PCRE_NEWLINE_CR).set_utf8(support_utf8));
- assert(re.error().empty());
- string all("aa\r\naa\r\n");
- CHECK(re.GlobalReplace("bb", &all) > 0);
- CHECK_EQ(all, string("bbabbabb\rbb\nbbabbabb\rbb\nbb"));
- }
- {
- RE re("b*", RE_Options(PCRE_NEWLINE_LF).set_utf8(support_utf8));
- assert(re.error().empty());
- string all("aa\r\naa\r\n");
- CHECK(re.GlobalReplace("bb", &all) > 0);
- CHECK_EQ(all, string("bbabbabb\rbb\nbbabbabb\rbb\nbb"));
- }
- // TODO: test what happens when no PCRE_NEWLINE_* flag is set.
- // Alas, the answer depends on how pcre was compiled.
-}
-
-static void TestExtract() {
- printf("Testing Extract\n");
-
- string s;
-
- CHECK(RE("(.*)@([^.]*)").Extract("\\2!\\1", "boris@kremvax.ru", &s));
- CHECK_EQ(s, "kremvax!boris");
-
- // check the RE interface as well
- CHECK(RE(".*").Extract("'\\0'", "foo", &s));
- CHECK_EQ(s, "'foo'");
- CHECK(!RE("bar").Extract("'\\0'", "baz", &s));
- CHECK_EQ(s, "'foo'");
-}
-
-static void TestConsume() {
- printf("Testing Consume\n");
-
- string word;
-
- string s(" aaa b!@#$@#$cccc");
- StringPiece input(s);
-
- RE r("\\s*(\\w+)"); // matches a word, possibly proceeded by whitespace
- CHECK(r.Consume(&input, &word));
- CHECK_EQ(word, "aaa");
- CHECK(r.Consume(&input, &word));
- CHECK_EQ(word, "b");
- CHECK(! r.Consume(&input, &word));
-}
-
-static void TestFindAndConsume() {
- printf("Testing FindAndConsume\n");
-
- string word;
-
- string s(" aaa b!@#$@#$cccc");
- StringPiece input(s);
-
- RE r("(\\w+)"); // matches a word
- CHECK(r.FindAndConsume(&input, &word));
- CHECK_EQ(word, "aaa");
- CHECK(r.FindAndConsume(&input, &word));
- CHECK_EQ(word, "b");
- CHECK(r.FindAndConsume(&input, &word));
- CHECK_EQ(word, "cccc");
- CHECK(! r.FindAndConsume(&input, &word));
-}
-
-static void TestMatchNumberPeculiarity() {
- printf("Testing match-number peculiaraity\n");
-
- string word1;
- string word2;
- string word3;
-
- RE r("(foo)|(bar)|(baz)");
- CHECK(r.PartialMatch("foo", &word1, &word2, &word3));
- CHECK_EQ(word1, "foo");
- CHECK_EQ(word2, "");
- CHECK_EQ(word3, "");
- CHECK(r.PartialMatch("bar", &word1, &word2, &word3));
- CHECK_EQ(word1, "");
- CHECK_EQ(word2, "bar");
- CHECK_EQ(word3, "");
- CHECK(r.PartialMatch("baz", &word1, &word2, &word3));
- CHECK_EQ(word1, "");
- CHECK_EQ(word2, "");
- CHECK_EQ(word3, "baz");
- CHECK(!r.PartialMatch("f", &word1, &word2, &word3));
-
- string a;
- CHECK(RE("(foo)|hello").FullMatch("hello", &a));
- CHECK_EQ(a, "");
-}
-
-static void TestRecursion() {
- printf("Testing recursion\n");
-
- // Get one string that passes (sometimes), one that never does.
- string text_good("abcdefghijk");
- string text_bad("acdefghijkl");
-
- // According to pcretest, matching text_good against (\w+)*b
- // requires match_limit of at least 8192, and match_recursion_limit
- // of at least 37.
-
- RE_Options options_ml;
- options_ml.set_match_limit(8192);
- RE re("(\\w+)*b", options_ml);
- CHECK(re.PartialMatch(text_good) == true);
- CHECK(re.PartialMatch(text_bad) == false);
- CHECK(re.FullMatch(text_good) == false);
- CHECK(re.FullMatch(text_bad) == false);
-
- options_ml.set_match_limit(1024);
- RE re2("(\\w+)*b", options_ml);
- CHECK(re2.PartialMatch(text_good) == false); // because of match_limit
- CHECK(re2.PartialMatch(text_bad) == false);
- CHECK(re2.FullMatch(text_good) == false);
- CHECK(re2.FullMatch(text_bad) == false);
-
- RE_Options options_mlr;
- options_mlr.set_match_limit_recursion(50);
- RE re3("(\\w+)*b", options_mlr);
- CHECK(re3.PartialMatch(text_good) == true);
- CHECK(re3.PartialMatch(text_bad) == false);
- CHECK(re3.FullMatch(text_good) == false);
- CHECK(re3.FullMatch(text_bad) == false);
-
- options_mlr.set_match_limit_recursion(10);
- RE re4("(\\w+)*b", options_mlr);
- CHECK(re4.PartialMatch(text_good) == false);
- CHECK(re4.PartialMatch(text_bad) == false);
- CHECK(re4.FullMatch(text_good) == false);
- CHECK(re4.FullMatch(text_bad) == false);
-}
-
-// A meta-quoted string, interpreted as a pattern, should always match
-// the original unquoted string.
-static void TestQuoteMeta(string unquoted, RE_Options options = RE_Options()) {
- string quoted = RE::QuoteMeta(unquoted);
- RE re(quoted, options);
- CHECK(re.FullMatch(unquoted));
-}
-
-// A string containing meaningful regexp characters, which is then meta-
-// quoted, should not generally match a string the unquoted string does.
-static void NegativeTestQuoteMeta(string unquoted, string should_not_match,
- RE_Options options = RE_Options()) {
- string quoted = RE::QuoteMeta(unquoted);
- RE re(quoted, options);
- CHECK(!re.FullMatch(should_not_match));
-}
-
-// Tests that quoted meta characters match their original strings,
-// and that a few things that shouldn't match indeed do not.
-static void TestQuotaMetaSimple() {
- TestQuoteMeta("foo");
- TestQuoteMeta("foo.bar");
- TestQuoteMeta("foo\\.bar");
- TestQuoteMeta("[1-9]");
- TestQuoteMeta("1.5-2.0?");
- TestQuoteMeta("\\d");
- TestQuoteMeta("Who doesn't like ice cream?");
- TestQuoteMeta("((a|b)c?d*e+[f-h]i)");
- TestQuoteMeta("((?!)xxx).*yyy");
- TestQuoteMeta("([");
-}
-
-static void TestQuoteMetaSimpleNegative() {
- NegativeTestQuoteMeta("foo", "bar");
- NegativeTestQuoteMeta("...", "bar");
- NegativeTestQuoteMeta("\\.", ".");
- NegativeTestQuoteMeta("\\.", "..");
- NegativeTestQuoteMeta("(a)", "a");
- NegativeTestQuoteMeta("(a|b)", "a");
- NegativeTestQuoteMeta("(a|b)", "(a)");
- NegativeTestQuoteMeta("(a|b)", "a|b");
- NegativeTestQuoteMeta("[0-9]", "0");
- NegativeTestQuoteMeta("[0-9]", "0-9");
- NegativeTestQuoteMeta("[0-9]", "[9]");
- NegativeTestQuoteMeta("((?!)xxx)", "xxx");
-}
-
-static void TestQuoteMetaLatin1() {
- TestQuoteMeta("3\xb2 = 9");
-}
-
-static void TestQuoteMetaUtf8() {
-#ifdef SUPPORT_UTF8
- TestQuoteMeta("Pl\xc3\xa1\x63ido Domingo", pcrecpp::UTF8());
- TestQuoteMeta("xyz", pcrecpp::UTF8()); // No fancy utf8
- TestQuoteMeta("\xc2\xb0", pcrecpp::UTF8()); // 2-byte utf8 (degree symbol)
- TestQuoteMeta("27\xc2\xb0 degrees", pcrecpp::UTF8()); // As a middle character
- TestQuoteMeta("\xe2\x80\xb3", pcrecpp::UTF8()); // 3-byte utf8 (double prime)
- TestQuoteMeta("\xf0\x9d\x85\x9f", pcrecpp::UTF8()); // 4-byte utf8 (music note)
- TestQuoteMeta("27\xc2\xb0"); // Interpreted as Latin-1, but should still work
- NegativeTestQuoteMeta("27\xc2\xb0", // 2-byte utf (degree symbol)
- "27\\\xc2\\\xb0",
- pcrecpp::UTF8());
-#endif
-}
-
-static void TestQuoteMetaAll() {
- printf("Testing QuoteMeta\n");
- TestQuotaMetaSimple();
- TestQuoteMetaSimpleNegative();
- TestQuoteMetaLatin1();
- TestQuoteMetaUtf8();
-}
-
-//
-// Options tests contributed by
-// Giuseppe Maxia, CTO, Stardata s.r.l.
-// July 2005
-//
-static void GetOneOptionResult(
- const char *option_name,
- const char *regex,
- const char *str,
- RE_Options options,
- bool full,
- string expected) {
-
- printf("Testing Option <%s>\n", option_name);
- if(VERBOSE_TEST)
- printf("/%s/ finds \"%s\" within \"%s\" \n",
- regex,
- expected.c_str(),
- str);
- string captured("");
- if (full)
- RE(regex,options).FullMatch(str, &captured);
- else
- RE(regex,options).PartialMatch(str, &captured);
- CHECK_EQ(captured, expected);
-}
-
-static void TestOneOption(
- const char *option_name,
- const char *regex,
- const char *str,
- RE_Options options,
- bool full,
- bool assertive = true) {
-
- printf("Testing Option <%s>\n", option_name);
- if (VERBOSE_TEST)
- printf("'%s' %s /%s/ \n",
- str,
- (assertive? "matches" : "doesn't match"),
- regex);
- if (assertive) {
- if (full)
- CHECK(RE(regex,options).FullMatch(str));
- else
- CHECK(RE(regex,options).PartialMatch(str));
- } else {
- if (full)
- CHECK(!RE(regex,options).FullMatch(str));
- else
- CHECK(!RE(regex,options).PartialMatch(str));
- }
-}
-
-static void Test_CASELESS() {
- RE_Options options;
- RE_Options options2;
-
- options.set_caseless(true);
- TestOneOption("CASELESS (class)", "HELLO", "hello", options, false);
- TestOneOption("CASELESS (class2)", "HELLO", "hello", options2.set_caseless(true), false);
- TestOneOption("CASELESS (class)", "^[A-Z]+$", "Hello", options, false);
-
- TestOneOption("CASELESS (function)", "HELLO", "hello", pcrecpp::CASELESS(), false);
- TestOneOption("CASELESS (function)", "^[A-Z]+$", "Hello", pcrecpp::CASELESS(), false);
- options.set_caseless(false);
- TestOneOption("no CASELESS", "HELLO", "hello", options, false, false);
-}
-
-static void Test_MULTILINE() {
- RE_Options options;
- RE_Options options2;
- const char *str = "HELLO\n" "cruel\n" "world\n";
-
- options.set_multiline(true);
- TestOneOption("MULTILINE (class)", "^cruel$", str, options, false);
- TestOneOption("MULTILINE (class2)", "^cruel$", str, options2.set_multiline(true), false);
- TestOneOption("MULTILINE (function)", "^cruel$", str, pcrecpp::MULTILINE(), false);
- options.set_multiline(false);
- TestOneOption("no MULTILINE", "^cruel$", str, options, false, false);
-}
-
-static void Test_DOTALL() {
- RE_Options options;
- RE_Options options2;
- const char *str = "HELLO\n" "cruel\n" "world";
-
- options.set_dotall(true);
- TestOneOption("DOTALL (class)", "HELLO.*world", str, options, true);
- TestOneOption("DOTALL (class2)", "HELLO.*world", str, options2.set_dotall(true), true);
- TestOneOption("DOTALL (function)", "HELLO.*world", str, pcrecpp::DOTALL(), true);
- options.set_dotall(false);
- TestOneOption("no DOTALL", "HELLO.*world", str, options, true, false);
-}
-
-static void Test_DOLLAR_ENDONLY() {
- RE_Options options;
- RE_Options options2;
- const char *str = "HELLO world\n";
-
- TestOneOption("no DOLLAR_ENDONLY", "world$", str, options, false);
- options.set_dollar_endonly(true);
- TestOneOption("DOLLAR_ENDONLY 1", "world$", str, options, false, false);
- TestOneOption("DOLLAR_ENDONLY 2", "world$", str, options2.set_dollar_endonly(true), false, false);
-}
-
-static void Test_EXTRA() {
- RE_Options options;
- const char *str = "HELLO";
-
- options.set_extra(true);
- TestOneOption("EXTRA 1", "\\HELL\\O", str, options, true, false );
- TestOneOption("EXTRA 2", "\\HELL\\O", str, RE_Options().set_extra(true), true, false );
- options.set_extra(false);
- TestOneOption("no EXTRA", "\\HELL\\O", str, options, true );
-}
-
-static void Test_EXTENDED() {
- RE_Options options;
- RE_Options options2;
- const char *str = "HELLO world";
-
- options.set_extended(true);
- TestOneOption("EXTENDED (class)", "HELLO world", str, options, false, false);
- TestOneOption("EXTENDED (class2)", "HELLO world", str, options2.set_extended(true), false, false);
- TestOneOption("EXTENDED (class)",
- "^ HE L{2} O "
- "\\s+ "
- "\\w+ $ ",
- str,
- options,
- false);
-
- TestOneOption("EXTENDED (function)", "HELLO world", str, pcrecpp::EXTENDED(), false, false);
- TestOneOption("EXTENDED (function)",
- "^ HE L{2} O "
- "\\s+ "
- "\\w+ $ ",
- str,
- pcrecpp::EXTENDED(),
- false);
-
- options.set_extended(false);
- TestOneOption("no EXTENDED", "HELLO world", str, options, false);
-}
-
-static void Test_NO_AUTO_CAPTURE() {
- RE_Options options;
- const char *str = "HELLO world";
- string captured;
-
- printf("Testing Option <no NO_AUTO_CAPTURE>\n");
- if (VERBOSE_TEST)
- printf("parentheses capture text\n");
- RE re("(world|universe)$", options);
- CHECK(re.Extract("\\1", str , &captured));
- CHECK_EQ(captured, "world");
- options.set_no_auto_capture(true);
- printf("testing Option <NO_AUTO_CAPTURE>\n");
- if (VERBOSE_TEST)
- printf("parentheses do not capture text\n");
- re.Extract("\\1",str, &captured );
- CHECK_EQ(captured, "world");
-}
-
-static void Test_UNGREEDY() {
- RE_Options options;
- const char *str = "HELLO, 'this' is the 'world'";
-
- options.set_ungreedy(true);
- GetOneOptionResult("UNGREEDY 1", "('.*')", str, options, false, "'this'" );
- GetOneOptionResult("UNGREEDY 2", "('.*')", str, RE_Options().set_ungreedy(true), false, "'this'" );
- GetOneOptionResult("UNGREEDY", "('.*?')", str, options, false, "'this' is the 'world'" );
-
- options.set_ungreedy(false);
- GetOneOptionResult("no UNGREEDY", "('.*')", str, options, false, "'this' is the 'world'" );
- GetOneOptionResult("no UNGREEDY", "('.*?')", str, options, false, "'this'" );
-}
-
-static void Test_all_options() {
- const char *str = "HELLO\n" "cruel\n" "world";
- RE_Options options;
- options.set_all_options(PCRE_CASELESS | PCRE_DOTALL);
-
- TestOneOption("all_options (CASELESS|DOTALL)", "^hello.*WORLD", str , options, false);
- options.set_all_options(0);
- TestOneOption("all_options (0)", "^hello.*WORLD", str , options, false, false);
- options.set_all_options(PCRE_MULTILINE | PCRE_EXTENDED);
-
- TestOneOption("all_options (MULTILINE|EXTENDED)", " ^ c r u e l $ ", str, options, false);
- TestOneOption("all_options (MULTILINE|EXTENDED) with constructor",
- " ^ c r u e l $ ",
- str,
- RE_Options(PCRE_MULTILINE | PCRE_EXTENDED),
- false);
-
- TestOneOption("all_options (MULTILINE|EXTENDED) with concatenation",
- " ^ c r u e l $ ",
- str,
- RE_Options()
- .set_multiline(true)
- .set_extended(true),
- false);
-
- options.set_all_options(0);
- TestOneOption("all_options (0)", "^ c r u e l $", str, options, false, false);
-
-}
-
-static void TestOptions() {
- printf("Testing Options\n");
- Test_CASELESS();
- Test_MULTILINE();
- Test_DOTALL();
- Test_DOLLAR_ENDONLY();
- Test_EXTENDED();
- Test_NO_AUTO_CAPTURE();
- Test_UNGREEDY();
- Test_EXTRA();
- Test_all_options();
-}
-
-static void TestConstructors() {
- printf("Testing constructors\n");
-
- RE_Options options;
- options.set_dotall(true);
- const char *str = "HELLO\n" "cruel\n" "world";
-
- RE orig("HELLO.*world", options);
- CHECK(orig.FullMatch(str));
-
- RE copy1(orig);
- CHECK(copy1.FullMatch(str));
-
- RE copy2("not a match");
- CHECK(!copy2.FullMatch(str));
- copy2 = copy1;
- CHECK(copy2.FullMatch(str));
- copy2 = orig;
- CHECK(copy2.FullMatch(str));
-
- // Make sure when we assign to ourselves, nothing bad happens
- orig = orig;
- copy1 = copy1;
- copy2 = copy2;
- CHECK(orig.FullMatch(str));
- CHECK(copy1.FullMatch(str));
- CHECK(copy2.FullMatch(str));
-}
-
-int main(int argc, char** argv) {
- // Treat any flag as --help
- if (argc > 1 && argv[1][0] == '-') {
- printf("Usage: %s [timing1|timing2|timing3 num-iters]\n"
- " If 'timingX ###' is specified, run the given timing test\n"
- " with the given number of iterations, rather than running\n"
- " the default corectness test.\n", argv[0]);
- return 0;
- }
-
- if (argc > 1) {
- if ( argc == 2 || atoi(argv[2]) == 0) {
- printf("timing mode needs a num-iters argument\n");
- return 1;
- }
- if (!strcmp(argv[1], "timing1"))
- Timing1(atoi(argv[2]));
- else if (!strcmp(argv[1], "timing2"))
- Timing2(atoi(argv[2]));
- else if (!strcmp(argv[1], "timing3"))
- Timing3(atoi(argv[2]));
- else
- printf("Unknown argument '%s'\n", argv[1]);
- return 0;
- }
-
- printf("Testing FullMatch\n");
-
- int i;
- string s;
-
- /***** FullMatch with no args *****/
-
- CHECK(RE("h.*o").FullMatch("hello"));
- CHECK(!RE("h.*o").FullMatch("othello"));
- CHECK(!RE("h.*o").FullMatch("hello!"));
-
- /***** FullMatch with args *****/
-
- // Zero-arg
- CHECK(RE("\\d+").FullMatch("1001"));
-
- // Single-arg
- CHECK(RE("(\\d+)").FullMatch("1001", &i));
- CHECK_EQ(i, 1001);
- CHECK(RE("(-?\\d+)").FullMatch("-123", &i));
- CHECK_EQ(i, -123);
- CHECK(!RE("()\\d+").FullMatch("10", &i));
- CHECK(!RE("(\\d+)").FullMatch("1234567890123456789012345678901234567890",
- &i));
-
- // Digits surrounding integer-arg
- CHECK(RE("1(\\d*)4").FullMatch("1234", &i));
- CHECK_EQ(i, 23);
- CHECK(RE("(\\d)\\d+").FullMatch("1234", &i));
- CHECK_EQ(i, 1);
- CHECK(RE("(-\\d)\\d+").FullMatch("-1234", &i));
- CHECK_EQ(i, -1);
- CHECK(RE("(\\d)").PartialMatch("1234", &i));
- CHECK_EQ(i, 1);
- CHECK(RE("(-\\d)").PartialMatch("-1234", &i));
- CHECK_EQ(i, -1);
-
- // String-arg
- CHECK(RE("h(.*)o").FullMatch("hello", &s));
- CHECK_EQ(s, string("ell"));
-
- // StringPiece-arg
- StringPiece sp;
- CHECK(RE("(\\w+):(\\d+)").FullMatch("ruby:1234", &sp, &i));
- CHECK_EQ(sp.size(), 4);
- CHECK(memcmp(sp.data(), "ruby", 4) == 0);
- CHECK_EQ(i, 1234);
-
- // Multi-arg
- CHECK(RE("(\\w+):(\\d+)").FullMatch("ruby:1234", &s, &i));
- CHECK_EQ(s, string("ruby"));
- CHECK_EQ(i, 1234);
-
- // Ignored arg
- CHECK(RE("(\\w+)(:)(\\d+)").FullMatch("ruby:1234", &s, (void*)NULL, &i));
- CHECK_EQ(s, string("ruby"));
- CHECK_EQ(i, 1234);
-
- // Type tests
- {
- char c;
- CHECK(RE("(H)ello").FullMatch("Hello", &c));
- CHECK_EQ(c, 'H');
- }
- {
- unsigned char c;
- CHECK(RE("(H)ello").FullMatch("Hello", &c));
- CHECK_EQ(c, static_cast<unsigned char>('H'));
- }
- {
- short v;
- CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
- CHECK(RE("(-?\\d+)").FullMatch("-100", &v)); CHECK_EQ(v, -100);
- CHECK(RE("(-?\\d+)").FullMatch("32767", &v)); CHECK_EQ(v, 32767);
- CHECK(RE("(-?\\d+)").FullMatch("-32768", &v)); CHECK_EQ(v, -32768);
- CHECK(!RE("(-?\\d+)").FullMatch("-32769", &v));
- CHECK(!RE("(-?\\d+)").FullMatch("32768", &v));
- }
- {
- unsigned short v;
- CHECK(RE("(\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
- CHECK(RE("(\\d+)").FullMatch("32767", &v)); CHECK_EQ(v, 32767);
- CHECK(RE("(\\d+)").FullMatch("65535", &v)); CHECK_EQ(v, 65535);
- CHECK(!RE("(\\d+)").FullMatch("65536", &v));
- }
- {
- int v;
- static const int max_value = 0x7fffffff;
- static const int min_value = -max_value - 1;
- CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
- CHECK(RE("(-?\\d+)").FullMatch("-100", &v)); CHECK_EQ(v, -100);
- CHECK(RE("(-?\\d+)").FullMatch("2147483647", &v)); CHECK_EQ(v, max_value);
- CHECK(RE("(-?\\d+)").FullMatch("-2147483648", &v)); CHECK_EQ(v, min_value);
- CHECK(!RE("(-?\\d+)").FullMatch("-2147483649", &v));
- CHECK(!RE("(-?\\d+)").FullMatch("2147483648", &v));
- }
- {
- unsigned int v;
- static const unsigned int max_value = 0xfffffffful;
- CHECK(RE("(\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
- CHECK(RE("(\\d+)").FullMatch("4294967295", &v)); CHECK_EQ(v, max_value);
- CHECK(!RE("(\\d+)").FullMatch("4294967296", &v));
- }
-#ifdef HAVE_LONG_LONG
- {
- long long v;
- static const long long max_value = 0x7fffffffffffffffLL;
- static const long long min_value = -max_value - 1;
- char buf[32];
-
- CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
- CHECK(RE("(-?\\d+)").FullMatch("-100",&v)); CHECK_EQ(v, -100);
-
- snprintf(buf, sizeof(buf), "%lld", max_value);
- CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);
-
- snprintf(buf, sizeof(buf), "%lld", min_value);
- CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, min_value);
-
- snprintf(buf, sizeof(buf), "%lld", max_value);
- assert(buf[strlen(buf)-1] != '9');
- buf[strlen(buf)-1]++;
- CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
-
- snprintf(buf, sizeof(buf), "%lld", min_value);
- assert(buf[strlen(buf)-1] != '9');
- buf[strlen(buf)-1]++;
- CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
- }
-#endif
-#if defined HAVE_UNSIGNED_LONG_LONG && defined HAVE_LONG_LONG
- {
- unsigned long long v;
- long long v2;
- static const unsigned long long max_value = 0xffffffffffffffffULL;
- char buf[32];
-
- CHECK(RE("(-?\\d+)").FullMatch("100",&v)); CHECK_EQ(v, 100);
- CHECK(RE("(-?\\d+)").FullMatch("-100",&v2)); CHECK_EQ(v2, -100);
-
- snprintf(buf, sizeof(buf), "%llu", max_value);
- CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);
-
- assert(buf[strlen(buf)-1] != '9');
- buf[strlen(buf)-1]++;
- CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
- }
-#endif
- {
- float v;
- CHECK(RE("(.*)").FullMatch("100", &v));
- CHECK(RE("(.*)").FullMatch("-100.", &v));
- CHECK(RE("(.*)").FullMatch("1e23", &v));
- }
- {
- double v;
- CHECK(RE("(.*)").FullMatch("100", &v));
- CHECK(RE("(.*)").FullMatch("-100.", &v));
- CHECK(RE("(.*)").FullMatch("1e23", &v));
- }
-
- // Check that matching is fully anchored
- CHECK(!RE("(\\d+)").FullMatch("x1001", &i));
- CHECK(!RE("(\\d+)").FullMatch("1001x", &i));
- CHECK(RE("x(\\d+)").FullMatch("x1001", &i)); CHECK_EQ(i, 1001);
- CHECK(RE("(\\d+)x").FullMatch("1001x", &i)); CHECK_EQ(i, 1001);
-
- // Braces
- CHECK(RE("[0-9a-f+.-]{5,}").FullMatch("0abcd"));
- CHECK(RE("[0-9a-f+.-]{5,}").FullMatch("0abcde"));
- CHECK(!RE("[0-9a-f+.-]{5,}").FullMatch("0abc"));
-
- // Complicated RE
- CHECK(RE("foo|bar|[A-Z]").FullMatch("foo"));
- CHECK(RE("foo|bar|[A-Z]").FullMatch("bar"));
- CHECK(RE("foo|bar|[A-Z]").FullMatch("X"));
- CHECK(!RE("foo|bar|[A-Z]").FullMatch("XY"));
-
- // Check full-match handling (needs '$' tacked on internally)
- CHECK(RE("fo|foo").FullMatch("fo"));
- CHECK(RE("fo|foo").FullMatch("foo"));
- CHECK(RE("fo|foo$").FullMatch("fo"));
- CHECK(RE("fo|foo$").FullMatch("foo"));
- CHECK(RE("foo$").FullMatch("foo"));
- CHECK(!RE("foo\\$").FullMatch("foo$bar"));
- CHECK(!RE("fo|bar").FullMatch("fox"));
-
- // Uncomment the following if we change the handling of '$' to
- // prevent it from matching a trailing newline
- if (false) {
- // Check that we don't get bitten by pcre's special handling of a
- // '\n' at the end of the string matching '$'
- CHECK(!RE("foo$").PartialMatch("foo\n"));
- }
-
- // Number of args
- int a[16];
- CHECK(RE("").FullMatch(""));
-
- memset(a, 0, sizeof(0));
- CHECK(RE("(\\d){1}").FullMatch("1",
- &a[0]));
- CHECK_EQ(a[0], 1);
-
- memset(a, 0, sizeof(0));
- CHECK(RE("(\\d)(\\d)").FullMatch("12",
- &a[0], &a[1]));
- CHECK_EQ(a[0], 1);
- CHECK_EQ(a[1], 2);
-
- memset(a, 0, sizeof(0));
- CHECK(RE("(\\d)(\\d)(\\d)").FullMatch("123",
- &a[0], &a[1], &a[2]));
- CHECK_EQ(a[0], 1);
- CHECK_EQ(a[1], 2);
- CHECK_EQ(a[2], 3);
-
- memset(a, 0, sizeof(0));
- CHECK(RE("(\\d)(\\d)(\\d)(\\d)").FullMatch("1234",
- &a[0], &a[1], &a[2], &a[3]));
- CHECK_EQ(a[0], 1);
- CHECK_EQ(a[1], 2);
- CHECK_EQ(a[2], 3);
- CHECK_EQ(a[3], 4);
-
- memset(a, 0, sizeof(0));
- CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch("12345",
- &a[0], &a[1], &a[2],
- &a[3], &a[4]));
- CHECK_EQ(a[0], 1);
- CHECK_EQ(a[1], 2);
- CHECK_EQ(a[2], 3);
- CHECK_EQ(a[3], 4);
- CHECK_EQ(a[4], 5);
-
- memset(a, 0, sizeof(0));
- CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch("123456",
- &a[0], &a[1], &a[2],
- &a[3], &a[4], &a[5]));
- CHECK_EQ(a[0], 1);
- CHECK_EQ(a[1], 2);
- CHECK_EQ(a[2], 3);
- CHECK_EQ(a[3], 4);
- CHECK_EQ(a[4], 5);
- CHECK_EQ(a[5], 6);
-
- memset(a, 0, sizeof(0));
- CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch("1234567",
- &a[0], &a[1], &a[2], &a[3],
- &a[4], &a[5], &a[6]));
- CHECK_EQ(a[0], 1);
- CHECK_EQ(a[1], 2);
- CHECK_EQ(a[2], 3);
- CHECK_EQ(a[3], 4);
- CHECK_EQ(a[4], 5);
- CHECK_EQ(a[5], 6);
- CHECK_EQ(a[6], 7);
-
- memset(a, 0, sizeof(0));
- CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)"
- "(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch(
- "1234567890123456",
- &a[0], &a[1], &a[2], &a[3],
- &a[4], &a[5], &a[6], &a[7],
- &a[8], &a[9], &a[10], &a[11],
- &a[12], &a[13], &a[14], &a[15]));
- CHECK_EQ(a[0], 1);
- CHECK_EQ(a[1], 2);
- CHECK_EQ(a[2], 3);
- CHECK_EQ(a[3], 4);
- CHECK_EQ(a[4], 5);
- CHECK_EQ(a[5], 6);
- CHECK_EQ(a[6], 7);
- CHECK_EQ(a[7], 8);
- CHECK_EQ(a[8], 9);
- CHECK_EQ(a[9], 0);
- CHECK_EQ(a[10], 1);
- CHECK_EQ(a[11], 2);
- CHECK_EQ(a[12], 3);
- CHECK_EQ(a[13], 4);
- CHECK_EQ(a[14], 5);
- CHECK_EQ(a[15], 6);
-
- /***** PartialMatch *****/
-
- printf("Testing PartialMatch\n");
-
- CHECK(RE("h.*o").PartialMatch("hello"));
- CHECK(RE("h.*o").PartialMatch("othello"));
- CHECK(RE("h.*o").PartialMatch("hello!"));
- CHECK(RE("((((((((((((((((((((x))))))))))))))))))))").PartialMatch("x"));
-
- /***** other tests *****/
-
- RadixTests();
- TestReplace();
- TestExtract();
- TestConsume();
- TestFindAndConsume();
- TestQuoteMetaAll();
- TestMatchNumberPeculiarity();
-
- // Check the pattern() accessor
- {
- const string kPattern = "http://([^/]+)/.*";
- const RE re(kPattern);
- CHECK_EQ(kPattern, re.pattern());
- }
-
- // Check RE error field.
- {
- RE re("foo");
- CHECK(re.error().empty()); // Must have no error
- }
-
-#ifdef SUPPORT_UTF8
- // Check UTF-8 handling
- {
- printf("Testing UTF-8 handling\n");
-
- // Three Japanese characters (nihongo)
- const char utf8_string[] = {
- 0xe6, 0x97, 0xa5, // 65e5
- 0xe6, 0x9c, 0xac, // 627c
- 0xe8, 0xaa, 0x9e, // 8a9e
- 0
- };
- const char utf8_pattern[] = {
- '.',
- 0xe6, 0x9c, 0xac, // 627c
- '.',
- 0
- };
-
- // Both should match in either mode, bytes or UTF-8
- RE re_test1(".........");
- CHECK(re_test1.FullMatch(utf8_string));
- RE re_test2("...", pcrecpp::UTF8());
- CHECK(re_test2.FullMatch(utf8_string));
-
- // Check that '.' matches one byte or UTF-8 character
- // according to the mode.
- string ss;
- RE re_test3("(.)");
- CHECK(re_test3.PartialMatch(utf8_string, &ss));
- CHECK_EQ(ss, string("\xe6"));
- RE re_test4("(.)", pcrecpp::UTF8());
- CHECK(re_test4.PartialMatch(utf8_string, &ss));
- CHECK_EQ(ss, string("\xe6\x97\xa5"));
-
- // Check that string matches itself in either mode
- RE re_test5(utf8_string);
- CHECK(re_test5.FullMatch(utf8_string));
- RE re_test6(utf8_string, pcrecpp::UTF8());
- CHECK(re_test6.FullMatch(utf8_string));
-
- // Check that pattern matches string only in UTF8 mode
- RE re_test7(utf8_pattern);
- CHECK(!re_test7.FullMatch(utf8_string));
- RE re_test8(utf8_pattern, pcrecpp::UTF8());
- CHECK(re_test8.FullMatch(utf8_string));
- }
-
- // Check that ungreedy, UTF8 regular expressions don't match when they
- // oughtn't -- see bug 82246.
- {
- // This code always worked.
- const char* pattern = "\\w+X";
- const string target = "a aX";
- RE match_sentence(pattern);
- RE match_sentence_re(pattern, pcrecpp::UTF8());
-
- CHECK(!match_sentence.FullMatch(target));
- CHECK(!match_sentence_re.FullMatch(target));
- }
-
- {
- const char* pattern = "(?U)\\w+X";
- const string target = "a aX";
- RE match_sentence(pattern);
- RE match_sentence_re(pattern, pcrecpp::UTF8());
-
- CHECK(!match_sentence.FullMatch(target));
- CHECK(!match_sentence_re.FullMatch(target));
- }
-#endif /* def SUPPORT_UTF8 */
-
- printf("Testing error reporting\n");
-
- { RE re("a\\1"); CHECK(!re.error().empty()); }
- {
- RE re("a[x");
- CHECK(!re.error().empty());
- }
- {
- RE re("a[z-a]");
- CHECK(!re.error().empty());
- }
- {
- RE re("a[[:foobar:]]");
- CHECK(!re.error().empty());
- }
- {
- RE re("a(b");
- CHECK(!re.error().empty());
- }
- {
- RE re("a\\");
- CHECK(!re.error().empty());
- }
-
- // Test that recursion is stopped
- TestRecursion();
-
- // Test Options
- if (getenv("VERBOSE_TEST") != NULL)
- VERBOSE_TEST = true;
- TestOptions();
-
- // Test the constructors
- TestConstructors();
-
- // Done
- printf("OK\n");
-
- return 0;
-}
diff --git a/ext/pcre/pcrelib/pcrecpparg.h b/ext/pcre/pcrelib/pcrecpparg.h
deleted file mode 100644
index 323dde58e5..0000000000
--- a/ext/pcre/pcrelib/pcrecpparg.h
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright (c) 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sanjay Ghemawat
-
-#ifndef _PCRECPPARG_H
-#define _PCRECPPARG_H
-
-#include <stdlib.h> // for NULL
-#include <string>
-
-namespace pcrecpp {
-
-class StringPiece;
-
-// Hex/Octal/Binary?
-
-// Special class for parsing into objects that define a ParseFrom() method
-template <class T>
-class _RE_MatchObject {
- public:
- static inline bool Parse(const char* str, int n, void* dest) {
- T* object = reinterpret_cast<T*>(dest);
- return object->ParseFrom(str, n);
- }
-};
-
-class Arg {
- public:
- // Empty constructor so we can declare arrays of Arg
- Arg();
-
- // Constructor specially designed for NULL arguments
- Arg(void*);
-
- typedef bool (*Parser)(const char* str, int n, void* dest);
-
-// Type-specific parsers
-#define PCRE_MAKE_PARSER(type,name) \
- Arg(type* p) : arg_(p), parser_(name) { } \
- Arg(type* p, Parser parser) : arg_(p), parser_(parser) { }
-
-
- PCRE_MAKE_PARSER(char, parse_char);
- PCRE_MAKE_PARSER(unsigned char, parse_uchar);
- PCRE_MAKE_PARSER(short, parse_short);
- PCRE_MAKE_PARSER(unsigned short, parse_ushort);
- PCRE_MAKE_PARSER(int, parse_int);
- PCRE_MAKE_PARSER(unsigned int, parse_uint);
- PCRE_MAKE_PARSER(long, parse_long);
- PCRE_MAKE_PARSER(unsigned long, parse_ulong);
-#if 1
- PCRE_MAKE_PARSER(long long, parse_longlong);
-#endif
-#if 1
- PCRE_MAKE_PARSER(unsigned long long, parse_ulonglong);
-#endif
- PCRE_MAKE_PARSER(float, parse_float);
- PCRE_MAKE_PARSER(double, parse_double);
- PCRE_MAKE_PARSER(std::string, parse_string);
- PCRE_MAKE_PARSER(StringPiece, parse_stringpiece);
-
-#undef PCRE_MAKE_PARSER
-
- // Generic constructor
- template <class T> Arg(T*, Parser parser);
- // Generic constructor template
- template <class T> Arg(T* p)
- : arg_(p), parser_(_RE_MatchObject<T>::Parse) {
- }
-
- // Parse the data
- bool Parse(const char* str, int n) const;
-
- private:
- void* arg_;
- Parser parser_;
-
- static bool parse_null (const char* str, int n, void* dest);
- static bool parse_char (const char* str, int n, void* dest);
- static bool parse_uchar (const char* str, int n, void* dest);
- static bool parse_float (const char* str, int n, void* dest);
- static bool parse_double (const char* str, int n, void* dest);
- static bool parse_string (const char* str, int n, void* dest);
- static bool parse_stringpiece (const char* str, int n, void* dest);
-
-#define PCRE_DECLARE_INTEGER_PARSER(name) \
- private: \
- static bool parse_ ## name(const char* str, int n, void* dest); \
- static bool parse_ ## name ## _radix( \
- const char* str, int n, void* dest, int radix); \
- public: \
- static bool parse_ ## name ## _hex(const char* str, int n, void* dest); \
- static bool parse_ ## name ## _octal(const char* str, int n, void* dest); \
- static bool parse_ ## name ## _cradix(const char* str, int n, void* dest)
-
- PCRE_DECLARE_INTEGER_PARSER(short);
- PCRE_DECLARE_INTEGER_PARSER(ushort);
- PCRE_DECLARE_INTEGER_PARSER(int);
- PCRE_DECLARE_INTEGER_PARSER(uint);
- PCRE_DECLARE_INTEGER_PARSER(long);
- PCRE_DECLARE_INTEGER_PARSER(ulong);
- PCRE_DECLARE_INTEGER_PARSER(longlong);
- PCRE_DECLARE_INTEGER_PARSER(ulonglong);
-
-#undef PCRE_DECLARE_INTEGER_PARSER
-};
-
-inline Arg::Arg() : arg_(NULL), parser_(parse_null) { }
-inline Arg::Arg(void* p) : arg_(p), parser_(parse_null) { }
-
-inline bool Arg::Parse(const char* str, int n) const {
- return (*parser_)(str, n, arg_);
-}
-
-// This part of the parser, appropriate only for ints, deals with bases
-#define MAKE_INTEGER_PARSER(type, name) \
- inline Arg Hex(type* ptr) { \
- return Arg(ptr, Arg::parse_ ## name ## _hex); } \
- inline Arg Octal(type* ptr) { \
- return Arg(ptr, Arg::parse_ ## name ## _octal); } \
- inline Arg CRadix(type* ptr) { \
- return Arg(ptr, Arg::parse_ ## name ## _cradix); }
-
-MAKE_INTEGER_PARSER(short, short);
-MAKE_INTEGER_PARSER(unsigned short, ushort);
-MAKE_INTEGER_PARSER(int, int);
-MAKE_INTEGER_PARSER(unsigned int, uint);
-MAKE_INTEGER_PARSER(long, long);
-MAKE_INTEGER_PARSER(unsigned long, ulong);
-#if 1
-MAKE_INTEGER_PARSER(long long, longlong);
-#endif
-#if 1
-MAKE_INTEGER_PARSER(unsigned long long, ulonglong);
-#endif
-
-#undef PCRE_IS_SET
-#undef PCRE_SET_OR_CLEAR
-#undef MAKE_INTEGER_PARSER
-
-} // namespace pcrecpp
-
-
-#endif /* _PCRECPPARG_H */
diff --git a/ext/pcre/pcrelib/pcredemo.c b/ext/pcre/pcrelib/pcredemo.c
index 8b06a9ce63..80aba0e19d 100644
--- a/ext/pcre/pcrelib/pcredemo.c
+++ b/ext/pcre/pcrelib/pcredemo.c
@@ -16,6 +16,10 @@ systems (e.g. Solaris) use the -R option.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <stdio.h>
#include <string.h>
#include <pcre.h>
diff --git a/ext/pcre/pcrelib/pcregrep.c b/ext/pcre/pcrelib/pcregrep.c
index e5ceec3ace..f14c973cb3 100644
--- a/ext/pcre/pcrelib/pcregrep.c
+++ b/ext/pcre/pcrelib/pcregrep.c
@@ -6,7 +6,7 @@
its pattern matching. On a Unix or Win32 system it can recurse into
directories.
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,10 @@ POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <ctype.h>
#include <locale.h>
#include <stdio.h>
@@ -46,17 +50,17 @@ POSSIBILITY OF SUCH DAMAGE.
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
-#include "config.h"
-#include "pcre.h"
+#include <pcre.h>
#define FALSE 0
#define TRUE 1
typedef int BOOL;
-#define VERSION "4.4 29-Nov-2006"
#define MAX_PATTERN_COUNT 100
#if BUFSIZ > 8192
@@ -84,7 +88,7 @@ enum { DEE_READ, DEE_SKIP };
/* Line ending types */
-enum { EL_LF, EL_CR, EL_CRLF, EL_ANY };
+enum { EL_LF, EL_CR, EL_CRLF, EL_ANY, EL_ANYCRLF };
@@ -117,8 +121,8 @@ static char *locale = NULL;
static const unsigned char *pcretables = NULL;
static int pattern_count = 0;
-static pcre **pattern_list;
-static pcre_extra **hints_list;
+static pcre **pattern_list = NULL;
+static pcre_extra **hints_list = NULL;
static char *include_pattern = NULL;
static char *exclude_pattern = NULL;
@@ -192,7 +196,7 @@ static option_item optionlist[] = {
{ OP_STRING, N_LABEL, &stdin_name, "label=name", "set name for standard input" },
{ OP_STRING, N_LOCALE, &locale, "locale=locale", "use the named locale" },
{ OP_NODATA, 'M', NULL, "multiline", "run in multiline mode" },
- { OP_STRING, 'N', &newline, "newline=type", "specify newline type (CR, LR, CRLF)" },
+ { OP_STRING, 'N', &newline, "newline=type", "specify newline type (CR, LF, CRLF, ANYCRLF or ANY)" },
{ OP_NODATA, 'n', NULL, "line-number", "print line number with output lines" },
{ OP_NODATA, 'o', NULL, "only-matching", "show only the part of the line that matched" },
{ OP_NODATA, 'q', NULL, "quiet", "suppress output, just set return code" },
@@ -222,7 +226,7 @@ static const char *prefix[] = {
static const char *suffix[] = {
"", "\\b", ")$", ")$", "\\E", "\\E\\b", "\\E)$", "\\E)$" };
-/* UTF-8 tables - used only when the newline setting is "all". */
+/* UTF-8 tables - used only when the newline setting is "any". */
const int utf8_table3[] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
@@ -244,7 +248,7 @@ although at present the only ones are for Unix, Win32, and for "no support". */
/************* Directory scanning in Unix ***********/
-#if IS_UNIX
+#if defined HAVE_SYS_STAT_H && defined HAVE_DIRENT_H && defined HAVE_SYS_TYPES_H
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
@@ -276,7 +280,7 @@ for (;;)
if (strcmp(dent->d_name, ".") != 0 && strcmp(dent->d_name, "..") != 0)
return dent->d_name;
}
-return NULL; /* Keep compiler happy; never executed */
+/* Control never reaches here */
}
static void
@@ -314,7 +318,7 @@ Lionel Fourquaux. David Burgess added a patch to define INVALID_FILE_ATTRIBUTES
when it did not exist. */
-#elif HAVE_WIN32API
+#elif HAVE_WINDOWS_H
#ifndef STRICT
# define STRICT
@@ -436,8 +440,8 @@ FALSE;
typedef void directory_type;
int isdirectory(char *filename) { return 0; }
-directory_type * opendirectory(char *filename) {}
-char *readdirectory(directory_type *dir) {}
+directory_type * opendirectory(char *filename) { return (directory_type*)0;}
+char *readdirectory(directory_type *dir) { return (char*)0;}
void closedirectory(directory_type *dir) {}
@@ -461,7 +465,7 @@ return FALSE;
-#if ! HAVE_STRERROR
+#ifndef HAVE_STRERROR
/*************************************************
* Provide strerror() for non-ANSI libraries *
*************************************************/
@@ -541,6 +545,50 @@ switch(endlinetype)
}
break;
+ case EL_ANYCRLF:
+ while (p < endptr)
+ {
+ int extra = 0;
+ register int c = *((unsigned char *)p);
+
+ if (utf8 && c >= 0xc0)
+ {
+ int gcii, gcss;
+ extra = utf8_table4[c & 0x3f]; /* Number of additional bytes */
+ gcss = 6*extra;
+ c = (c & utf8_table3[extra]) << gcss;
+ for (gcii = 1; gcii <= extra; gcii++)
+ {
+ gcss -= 6;
+ c |= (p[gcii] & 0x3f) << gcss;
+ }
+ }
+
+ p += 1 + extra;
+
+ switch (c)
+ {
+ case 0x0a: /* LF */
+ *lenptr = 1;
+ return p;
+
+ case 0x0d: /* CR */
+ if (p < endptr && *p == 0x0a)
+ {
+ *lenptr = 2;
+ p++;
+ }
+ else *lenptr = 1;
+ return p;
+
+ default:
+ break;
+ }
+ } /* End of loop for ANYCRLF case */
+
+ *lenptr = 0; /* Must have hit the end */
+ return endptr;
+
case EL_ANY:
while (p < endptr)
{
@@ -639,6 +687,7 @@ switch(endlinetype)
return p; /* But control should never get here */
case EL_ANY:
+ case EL_ANYCRLF:
if (*(--p) == '\n' && p > startptr && p[-1] == '\r') p--;
if (utf8) while ((*p & 0xc0) == 0x80) p--;
@@ -667,7 +716,17 @@ switch(endlinetype)
}
else c = *((unsigned char *)pp);
- switch (c)
+ if (endlinetype == EL_ANYCRLF) switch (c)
+ {
+ case 0x0a: /* LF */
+ case 0x0d: /* CR */
+ return p;
+
+ default:
+ break;
+ }
+
+ else switch (c)
{
case 0x0a: /* LF */
case 0x0b: /* VT */
@@ -1188,7 +1247,8 @@ if ((sep = isdirectory(pathname)) != 0)
while ((nextfile = readdirectory(dir)) != NULL)
{
int frc, blen;
- blen = slprintf(buffer, sizeof(buffer), "%.512s%c%.128s", pathname, sep, nextfile);
+ sprintf(buffer, "%.512s%c%.128s", pathname, sep, nextfile);
+ blen = strlen(buffer);
if (exclude_compiled != NULL &&
pcre_exec(exclude_compiled, NULL, buffer, blen, 0, 0, NULL, 0) >= 0)
@@ -1280,7 +1340,7 @@ for (op = optionlist; op->one_char != 0; op++)
{
int n;
char s[4];
- if (op->one_char > 0) snprintf(s, sizeof(s), "-%c,", op->one_char); else strcpy(s, " ");
+ if (op->one_char > 0) sprintf(s, "-%c,", op->one_char); else strcpy(s, " ");
printf(" %s --%s%n", s, op->long_name, &n);
n = 30 - n;
if (n < 1) n = 1;
@@ -1327,8 +1387,7 @@ switch(letter)
case 'x': process_options |= PO_LINE_MATCH; break;
case 'V':
- fprintf(stderr, "pcregrep version %s using ", VERSION);
- fprintf(stderr, "PCRE version %s\n", pcre_version());
+ fprintf(stderr, "pcregrep version %s\n", pcre_version());
exit(0);
break;
@@ -1354,7 +1413,7 @@ ordin(int n)
{
static char buffer[8];
char *p = buffer;
-snprintf(p, sizeof(buffer), "%d", n);
+sprintf(p, "%d", n);
while (*p != 0) p++;
switch (n%10)
{
@@ -1400,11 +1459,15 @@ if (pattern_count >= MAX_PATTERN_COUNT)
return FALSE;
}
-snprintf(buffer, sizeof(buffer), "%s%.*s%s", prefix[process_options], MBUFTHIRD, pattern,
+sprintf(buffer, "%s%.*s%s", prefix[process_options], MBUFTHIRD, pattern,
suffix[process_options]);
pattern_list[pattern_count] =
pcre_compile(buffer, options, &error, &errptr, pcretables);
-if (pattern_list[pattern_count++] != NULL) return TRUE;
+if (pattern_list[pattern_count] != NULL)
+ {
+ pattern_count++;
+ return TRUE;
+ }
/* Handle compile errors */
@@ -1462,7 +1525,7 @@ if ((process_options & PO_FIXED_STRINGS) != 0)
char *p = end_of_line(pattern, eop, &ellength);
if (ellength == 0)
return compile_single_pattern(pattern, options, filename, count);
- snprintf(buffer, sizeof(buffer), "%.*s", p - pattern - ellength, pattern);
+ sprintf(buffer, "%.*s", (int)(p - pattern - ellength), pattern);
pattern = p;
if (!compile_single_pattern(buffer, options, filename, count))
return FALSE;
@@ -1486,6 +1549,7 @@ int i, j;
int rc = 1;
int pcre_options = 0;
int cmd_pattern_count = 0;
+int hint_count = 0;
int errptr;
BOOL only_one_at_top;
char *patterns[MAX_PATTERN_COUNT];
@@ -1503,6 +1567,7 @@ switch(i)
case '\r': newline = (char *)"cr"; break;
case ('\r' << 8) | '\n': newline = (char *)"crlf"; break;
case -1: newline = (char *)"any"; break;
+ case -2: newline = (char *)"anycrlf"; break;
}
/* Process the options */
@@ -1578,9 +1643,9 @@ for (i = 1; i < argc; i++)
char buff1[24];
char buff2[24];
int baselen = opbra - op->long_name;
- snprintf(buff1, sizeof(buff1), "%.*s", baselen, op->long_name);
- snprintf(buff2, sizeof(buff2), "%s%.*s", buff1, strlen(op->long_name) - baselen - 2,
- opbra + 1);
+ sprintf(buff1, "%.*s", baselen, op->long_name);
+ sprintf(buff2, "%s%.*s", buff1,
+ (int)strlen(op->long_name) - baselen - 2, opbra + 1);
if (strcmp(arg, buff1) == 0 || strcmp(arg, buff2) == 0)
break;
}
@@ -1810,6 +1875,11 @@ else if (strcmp(newline, "any") == 0 || strcmp(newline, "ANY") == 0)
pcre_options |= PCRE_NEWLINE_ANY;
endlinetype = EL_ANY;
}
+else if (strcmp(newline, "anycrlf") == 0 || strcmp(newline, "ANYCRLF") == 0)
+ {
+ pcre_options |= PCRE_NEWLINE_ANYCRLF;
+ endlinetype = EL_ANYCRLF;
+ }
else
{
fprintf(stderr, "pcregrep: Invalid newline specifier \"%s\"\n", newline);
@@ -1864,7 +1934,7 @@ hints_list = (pcre_extra **)malloc(MAX_PATTERN_COUNT * sizeof(pcre_extra *));
if (pattern_list == NULL || hints_list == NULL)
{
fprintf(stderr, "pcregrep: malloc failed\n");
- return 2;
+ goto EXIT2;
}
/* If no patterns were provided by -e, and there is no file provided by -f,
@@ -1883,7 +1953,7 @@ for (j = 0; j < cmd_pattern_count; j++)
{
if (!compile_pattern(patterns[j], pcre_options, NULL,
(j == 0 && cmd_pattern_count == 1)? 0 : j + 1))
- return 2;
+ goto EXIT2;
}
/* Compile the regular expressions that are provided in a file. */
@@ -1907,7 +1977,7 @@ if (pattern_filename != NULL)
{
fprintf(stderr, "pcregrep: Failed to open %s: %s\n", pattern_filename,
strerror(errno));
- return 2;
+ goto EXIT2;
}
filename = pattern_filename;
}
@@ -1920,7 +1990,7 @@ if (pattern_filename != NULL)
linenumber++;
if (buffer[0] == 0) continue; /* Skip blank lines */
if (!compile_pattern(buffer, pcre_options, filename, linenumber))
- return 2;
+ goto EXIT2;
}
if (f != stdin) fclose(f);
@@ -1934,10 +2004,11 @@ for (j = 0; j < pattern_count; j++)
if (error != NULL)
{
char s[16];
- if (pattern_count == 1) s[0] = 0; else snprintf(s, sizeof(s), " number %d", j);
+ if (pattern_count == 1) s[0] = 0; else sprintf(s, " number %d", j);
fprintf(stderr, "pcregrep: Error while studying regex%s: %s\n", s, error);
- return 2;
+ goto EXIT2;
}
+ hint_count++;
}
/* If there are include or exclude patterns, compile them. */
@@ -1950,7 +2021,7 @@ if (exclude_pattern != NULL)
{
fprintf(stderr, "pcregrep: Error in 'exclude' regex at offset %d: %s\n",
errptr, error);
- return 2;
+ goto EXIT2;
}
}
@@ -1962,14 +2033,17 @@ if (include_pattern != NULL)
{
fprintf(stderr, "pcregrep: Error in 'include' regex at offset %d: %s\n",
errptr, error);
- return 2;
+ goto EXIT2;
}
}
/* If there are no further arguments, do the business on stdin and exit. */
if (i >= argc)
- return pcregrep(stdin, (filenames > FN_DEFAULT)? stdin_name : NULL);
+ {
+ rc = pcregrep(stdin, (filenames > FN_DEFAULT)? stdin_name : NULL);
+ goto EXIT;
+ }
/* Otherwise, work through the remaining arguments as files or directories.
Pass in the fact that there is only one argument at top level - this suppresses
@@ -1986,7 +2060,22 @@ for (; i < argc; i++)
else if (frc == 0 && rc == 1) rc = 0;
}
+EXIT:
+if (pattern_list != NULL)
+ {
+ for (i = 0; i < pattern_count; i++) free(pattern_list[i]);
+ free(pattern_list);
+ }
+if (hints_list != NULL)
+ {
+ for (i = 0; i < hint_count; i++) free(hints_list[i]);
+ free(hints_list);
+ }
return rc;
+
+EXIT2:
+rc = 2;
+goto EXIT;
}
/* End of pcregrep */
diff --git a/ext/pcre/pcrelib/pcreposix.c b/ext/pcre/pcrelib/pcreposix.c
index 3cee2aa33f..8582fba097 100644
--- a/ext/pcre/pcrelib/pcreposix.c
+++ b/ext/pcre/pcrelib/pcreposix.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -80,7 +80,7 @@ static const int eint[] = {
REG_BADPAT, /* malformed number or name after (?( */
REG_BADPAT, /* conditional group contains more than two branches */
REG_BADPAT, /* assertion expected after (?( */
- REG_BADPAT, /* (?R or (?digits must be followed by ) */
+ REG_BADPAT, /* (?R or (?[+-]digits must be followed by ) */
REG_ECTYPE, /* unknown POSIX class name */
REG_BADPAT, /* POSIX collating elements are not supported */
REG_INVARG, /* this version of PCRE is not compiled with PCRE_UTF8 support */
@@ -108,7 +108,8 @@ static const int eint[] = {
REG_BADPAT, /* DEFINE group contains more than one branch */
REG_BADPAT, /* repeating a DEFINE group is not allowed */
REG_INVARG, /* inconsistent NEWLINE options */
- REG_BADPAT /* \g is not followed followed by an (optionally braced) non-zero number */
+ REG_BADPAT, /* \g is not followed followed by an (optionally braced) non-zero number */
+ REG_BADPAT /* (?+ or (?- must be followed by a non-zero number */
};
/* Table of texts corresponding to POSIX error codes */
@@ -141,7 +142,7 @@ static const char *const pstring[] = {
* Translate error code to string *
*************************************************/
-PCRE_DATA_SCOPE size_t
+PCREPOSIX_EXP_DEFN size_t
regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
{
const char *message, *addmessage;
@@ -158,7 +159,7 @@ addlength = (preg != NULL && (int)preg->re_erroffset != -1)?
if (errbuf_size > 0)
{
if (addlength > 0 && errbuf_size >= length + addlength)
- snprintf(errbuf, errbuf_size, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
+ sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
else
{
strncpy(errbuf, message, errbuf_size - 1);
@@ -176,7 +177,7 @@ return length + addlength;
* Free store held by a regex *
*************************************************/
-PCRE_DATA_SCOPE void
+PCREPOSIX_EXP_DEFN void
regfree(regex_t *preg)
{
(pcre_free)(preg->re_pcre);
@@ -199,7 +200,7 @@ Returns: 0 on success
various non-zero codes on failure
*/
-PCRE_DATA_SCOPE int
+PCREPOSIX_EXP_DEFN int
regcomp(regex_t *preg, const char *pattern, int cflags)
{
const char *errorptr;
@@ -241,7 +242,7 @@ If REG_NOSUB was specified at compile time, the PCRE_NO_AUTO_CAPTURE flag will
be set. When this is the case, the nmatch and pmatch arguments are ignored, and
the only result is yes/no/error. */
-PCRE_DATA_SCOPE int
+PCREPOSIX_EXP_DEFN int
regexec(const regex_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags)
{
diff --git a/ext/pcre/pcrelib/pcreposix.h b/ext/pcre/pcrelib/pcreposix.h
index 31ee03749c..cca559b3b2 100644
--- a/ext/pcre/pcrelib/pcreposix.h
+++ b/ext/pcre/pcrelib/pcreposix.h
@@ -9,7 +9,7 @@
Compatible Regular Expression library. It defines the things POSIX says should
be there. I hope.
- Copyright (c) 1997-2006 University of Cambridge
+ Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -105,40 +105,36 @@ typedef struct {
regoff_t rm_eo;
} regmatch_t;
-/* Win32 uses DLL by default; it needs special stuff for exported functions
-when building PCRE. */
+/* When an application links to a PCRE DLL in Windows, the symbols that are
+imported have to be identified as such. When building PCRE, the appropriate
+export settings are needed. */
-#ifndef PCRE_DATA_SCOPE
#ifdef _WIN32
-# ifdef PCRE_DEFINITION
-# ifdef DLL_EXPORT
-# define PCRE_DATA_SCOPE __declspec(dllexport)
-# endif
-# else
-# ifndef PCRE_STATIC
-# define PCRE_DATA_SCOPE extern __declspec(dllimport)
-# endif
+# ifndef PCREPOSIX_STATIC
+# define PCREPOSIX_EXP_DECL extern __declspec(dllimport)
+# define PCREPOSIX_EXP_DEFN __declspec(dllimport)
# endif
#endif
-#endif
-/* Otherwise, we use the standard "extern". */
+/* By default, we use the standard "extern" declarations. */
-#ifndef PCRE_DATA_SCOPE
+#ifndef PCREPOSIX_EXP_DECL
# ifdef __cplusplus
-# define PCRE_DATA_SCOPE extern "C"
+# define PCREPOSIX_EXP_DECL extern "C"
+# define PCREPOSIX_EXP_DEFN extern "C"
# else
-# define PCRE_DATA_SCOPE extern
+# define PCREPOSIX_EXP_DECL extern
+# define PCREPOSIX_EXP_DEFN extern
# endif
#endif
/* The functions */
-PCRE_DATA_SCOPE int regcomp(regex_t *, const char *, int);
-PCRE_DATA_SCOPE int regexec(const regex_t *, const char *, size_t,
- regmatch_t *, int);
-PCRE_DATA_SCOPE size_t regerror(int, const regex_t *, char *, size_t);
-PCRE_DATA_SCOPE void regfree(regex_t *);
+PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int);
+PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t,
+ regmatch_t *, int);
+PCREPOSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t);
+PCREPOSIX_EXP_DECL void regfree(regex_t *);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/ext/pcre/pcrelib/pcretest.c b/ext/pcre/pcrelib/pcretest.c
deleted file mode 100644
index d5249fa18f..0000000000
--- a/ext/pcre/pcrelib/pcretest.c
+++ /dev/null
@@ -1,2305 +0,0 @@
-/*************************************************
-* PCRE testing program *
-*************************************************/
-
-/* This program was hacked up as a tester for PCRE. I really should have
-written it more tidily in the first place. Will I ever learn? It has grown and
-been extended and consequently is now rather, er, *very* untidy in places.
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <time.h>
-#include <locale.h>
-#include <errno.h>
-
-
-/* A number of things vary for Windows builds. Originally, pcretest opened its
-input and output without "b"; then I was told that "b" was needed in some
-environments, so it was added for release 5.0 to both the input and output. (It
-makes no difference on Unix-like systems.) Later I was told that it is wrong
-for the input on Windows. I've now abstracted the modes into two macros that
-are set here, to make it easier to fiddle with them, and removed "b" from the
-input mode under Windows. */
-
-#if defined(_WIN32) || defined(WIN32)
-#include <io.h> /* For _setmode() */
-#include <fcntl.h> /* For _O_BINARY */
-#define INPUT_MODE "r"
-#define OUTPUT_MODE "wb"
-
-#else
-#include <sys/time.h> /* These two includes are needed */
-#include <sys/resource.h> /* for setrlimit(). */
-#define INPUT_MODE "rb"
-#define OUTPUT_MODE "wb"
-#endif
-
-
-#define PCRE_SPY /* For Win32 build, import data, not export */
-
-/* We include pcre_internal.h because we need the internal info for displaying
-the results of pcre_study() and we also need to know about the internal
-macros, structures, and other internal data values; pcretest has "inside
-information" compared to a program that strictly follows the PCRE API. */
-
-#include "pcre_internal.h"
-
-/* We need access to the data tables that PCRE uses. So as not to have to keep
-two copies, we include the source file here, changing the names of the external
-symbols to prevent clashes. */
-
-#define _pcre_utf8_table1 utf8_table1
-#define _pcre_utf8_table1_size utf8_table1_size
-#define _pcre_utf8_table2 utf8_table2
-#define _pcre_utf8_table3 utf8_table3
-#define _pcre_utf8_table4 utf8_table4
-#define _pcre_utt utt
-#define _pcre_utt_size utt_size
-#define _pcre_OP_lengths OP_lengths
-
-#include "pcre_tables.c"
-
-/* We also need the pcre_printint() function for printing out compiled
-patterns. This function is in a separate file so that it can be included in
-pcre_compile.c when that module is compiled with debugging enabled.
-
-The definition of the macro PRINTABLE, which determines whether to print an
-output character as-is or as a hex value when showing compiled patterns, is
-contained in this file. We uses it here also, in cases when the locale has not
-been explicitly changed, so as to get consistent output from systems that
-differ in their output from isprint() even in the "C" locale. */
-
-#include "pcre_printint.src"
-
-#define PRINTHEX(c) (locale_set? isprint(c) : PRINTABLE(c))
-
-
-/* It is possible to compile this test program without including support for
-testing the POSIX interface, though this is not available via the standard
-Makefile. */
-
-#if !defined NOPOSIX
-#include "pcreposix.h"
-#endif
-
-/* It is also possible, for the benefit of the version imported into Exim, to
-build pcretest without support for UTF8 (define NOUTF8), without the interface
-to the DFA matcher (NODFA), and without the doublecheck of the old "info"
-function (define NOINFOCHECK). */
-
-
-/* Other parameters */
-
-#ifndef CLOCKS_PER_SEC
-#ifdef CLK_TCK
-#define CLOCKS_PER_SEC CLK_TCK
-#else
-#define CLOCKS_PER_SEC 100
-#endif
-#endif
-
-/* This is the default loop count for timing. */
-
-#define LOOPREPEAT 500000
-
-/* Static variables */
-
-static FILE *outfile;
-static int log_store = 0;
-static int callout_count;
-static int callout_extra;
-static int callout_fail_count;
-static int callout_fail_id;
-static int first_callout;
-static int locale_set = 0;
-static int show_malloc;
-static int use_utf8;
-static size_t gotten_store;
-
-/* The buffers grow automatically if very long input lines are encountered. */
-
-static int buffer_size = 50000;
-static uschar *buffer = NULL;
-static uschar *dbuffer = NULL;
-static uschar *pbuffer = NULL;
-
-
-
-/*************************************************
-* Read or extend an input line *
-*************************************************/
-
-/* Input lines are read into buffer, but both patterns and data lines can be
-continued over multiple input lines. In addition, if the buffer fills up, we
-want to automatically expand it so as to be able to handle extremely large
-lines that are needed for certain stress tests. When the input buffer is
-expanded, the other two buffers must also be expanded likewise, and the
-contents of pbuffer, which are a copy of the input for callouts, must be
-preserved (for when expansion happens for a data line). This is not the most
-optimal way of handling this, but hey, this is just a test program!
-
-Arguments:
- f the file to read
- start where in buffer to start (this *must* be within buffer)
-
-Returns: pointer to the start of new data
- could be a copy of start, or could be moved
- NULL if no data read and EOF reached
-*/
-
-static uschar *
-extend_inputline(FILE *f, uschar *start)
-{
-uschar *here = start;
-
-for (;;)
- {
- int rlen = buffer_size - (here - buffer);
-
- if (rlen > 1000)
- {
- int dlen;
- if (fgets((char *)here, rlen, f) == NULL)
- return (here == start)? NULL : start;
- dlen = (int)strlen((char *)here);
- if (dlen > 0 && here[dlen - 1] == '\n') return start;
- here += dlen;
- }
-
- else
- {
- int new_buffer_size = 2*buffer_size;
- uschar *new_buffer = (unsigned char *)malloc(new_buffer_size);
- uschar *new_dbuffer = (unsigned char *)malloc(new_buffer_size);
- uschar *new_pbuffer = (unsigned char *)malloc(new_buffer_size);
-
- if (new_buffer == NULL || new_dbuffer == NULL || new_pbuffer == NULL)
- {
- fprintf(stderr, "pcretest: malloc(%d) failed\n", new_buffer_size);
- exit(1);
- }
-
- memcpy(new_buffer, buffer, buffer_size);
- memcpy(new_pbuffer, pbuffer, buffer_size);
-
- buffer_size = new_buffer_size;
-
- start = new_buffer + (start - buffer);
- here = new_buffer + (here - buffer);
-
- free(buffer);
- free(dbuffer);
- free(pbuffer);
-
- buffer = new_buffer;
- dbuffer = new_dbuffer;
- pbuffer = new_pbuffer;
- }
- }
-
-return NULL; /* Control never gets here */
-}
-
-
-
-
-
-
-
-/*************************************************
-* Read number from string *
-*************************************************/
-
-/* We don't use strtoul() because SunOS4 doesn't have it. Rather than mess
-around with conditional compilation, just do the job by hand. It is only used
-for unpicking arguments, so just keep it simple.
-
-Arguments:
- str string to be converted
- endptr where to put the end pointer
-
-Returns: the unsigned long
-*/
-
-static int
-get_value(unsigned char *str, unsigned char **endptr)
-{
-int result = 0;
-while(*str != 0 && isspace(*str)) str++;
-while (isdigit(*str)) result = result * 10 + (int)(*str++ - '0');
-*endptr = str;
-return(result);
-}
-
-
-
-
-/*************************************************
-* Convert UTF-8 string to value *
-*************************************************/
-
-/* This function takes one or more bytes that represents a UTF-8 character,
-and returns the value of the character.
-
-Argument:
- utf8bytes a pointer to the byte vector
- vptr a pointer to an int to receive the value
-
-Returns: > 0 => the number of bytes consumed
- -6 to 0 => malformed UTF-8 character at offset = (-return)
-*/
-
-#if !defined NOUTF8
-
-static int
-utf82ord(unsigned char *utf8bytes, int *vptr)
-{
-int c = *utf8bytes++;
-int d = c;
-int i, j, s;
-
-for (i = -1; i < 6; i++) /* i is number of additional bytes */
- {
- if ((d & 0x80) == 0) break;
- d <<= 1;
- }
-
-if (i == -1) { *vptr = c; return 1; } /* ascii character */
-if (i == 0 || i == 6) return 0; /* invalid UTF-8 */
-
-/* i now has a value in the range 1-5 */
-
-s = 6*i;
-d = (c & utf8_table3[i]) << s;
-
-for (j = 0; j < i; j++)
- {
- c = *utf8bytes++;
- if ((c & 0xc0) != 0x80) return -(j+1);
- s -= 6;
- d |= (c & 0x3f) << s;
- }
-
-/* Check that encoding was the correct unique one */
-
-for (j = 0; j < utf8_table1_size; j++)
- if (d <= utf8_table1[j]) break;
-if (j != i) return -(i+1);
-
-/* Valid value */
-
-*vptr = d;
-return i+1;
-}
-
-#endif
-
-
-
-/*************************************************
-* Convert character value to UTF-8 *
-*************************************************/
-
-/* This function takes an integer value in the range 0 - 0x7fffffff
-and encodes it as a UTF-8 character in 0 to 6 bytes.
-
-Arguments:
- cvalue the character value
- utf8bytes pointer to buffer for result - at least 6 bytes long
-
-Returns: number of characters placed in the buffer
-*/
-
-#if !defined NOUTF8
-
-static int
-ord2utf8(int cvalue, uschar *utf8bytes)
-{
-register int i, j;
-for (i = 0; i < utf8_table1_size; i++)
- if (cvalue <= utf8_table1[i]) break;
-utf8bytes += i;
-for (j = i; j > 0; j--)
- {
- *utf8bytes-- = 0x80 | (cvalue & 0x3f);
- cvalue >>= 6;
- }
-*utf8bytes = utf8_table2[i] | cvalue;
-return i + 1;
-}
-
-#endif
-
-
-
-/*************************************************
-* Print character string *
-*************************************************/
-
-/* Character string printing function. Must handle UTF-8 strings in utf8
-mode. Yields number of characters printed. If handed a NULL file, just counts
-chars without printing. */
-
-static int pchars(unsigned char *p, int length, FILE *f)
-{
-int c = 0;
-int yield = 0;
-
-while (length-- > 0)
- {
-#if !defined NOUTF8
- if (use_utf8)
- {
- int rc = utf82ord(p, &c);
-
- if (rc > 0 && rc <= length + 1) /* Mustn't run over the end */
- {
- length -= rc - 1;
- p += rc;
- if (PRINTHEX(c))
- {
- if (f != NULL) fprintf(f, "%c", c);
- yield++;
- }
- else
- {
- int n = 4;
- if (f != NULL) fprintf(f, "\\x{%02x}", c);
- yield += (n <= 0x000000ff)? 2 :
- (n <= 0x00000fff)? 3 :
- (n <= 0x0000ffff)? 4 :
- (n <= 0x000fffff)? 5 : 6;
- }
- continue;
- }
- }
-#endif
-
- /* Not UTF-8, or malformed UTF-8 */
-
- c = *p++;
- if (PRINTHEX(c))
- {
- if (f != NULL) fprintf(f, "%c", c);
- yield++;
- }
- else
- {
- if (f != NULL) fprintf(f, "\\x%02x", c);
- yield += 4;
- }
- }
-
-return yield;
-}
-
-
-
-/*************************************************
-* Callout function *
-*************************************************/
-
-/* Called from PCRE as a result of the (?C) item. We print out where we are in
-the match. Yield zero unless more callouts than the fail count, or the callout
-data is not zero. */
-
-static int callout(pcre_callout_block *cb)
-{
-FILE *f = (first_callout | callout_extra)? outfile : NULL;
-int i, pre_start, post_start, subject_length;
-
-if (callout_extra)
- {
- fprintf(f, "Callout %d: last capture = %d\n",
- cb->callout_number, cb->capture_last);
-
- for (i = 0; i < cb->capture_top * 2; i += 2)
- {
- if (cb->offset_vector[i] < 0)
- fprintf(f, "%2d: <unset>\n", i/2);
- else
- {
- fprintf(f, "%2d: ", i/2);
- (void)pchars((unsigned char *)cb->subject + cb->offset_vector[i],
- cb->offset_vector[i+1] - cb->offset_vector[i], f);
- fprintf(f, "\n");
- }
- }
- }
-
-/* Re-print the subject in canonical form, the first time or if giving full
-datails. On subsequent calls in the same match, we use pchars just to find the
-printed lengths of the substrings. */
-
-if (f != NULL) fprintf(f, "--->");
-
-pre_start = pchars((unsigned char *)cb->subject, cb->start_match, f);
-post_start = pchars((unsigned char *)(cb->subject + cb->start_match),
- cb->current_position - cb->start_match, f);
-
-subject_length = pchars((unsigned char *)cb->subject, cb->subject_length, NULL);
-
-(void)pchars((unsigned char *)(cb->subject + cb->current_position),
- cb->subject_length - cb->current_position, f);
-
-if (f != NULL) fprintf(f, "\n");
-
-/* Always print appropriate indicators, with callout number if not already
-shown. For automatic callouts, show the pattern offset. */
-
-if (cb->callout_number == 255)
- {
- fprintf(outfile, "%+3d ", cb->pattern_position);
- if (cb->pattern_position > 99) fprintf(outfile, "\n ");
- }
-else
- {
- if (callout_extra) fprintf(outfile, " ");
- else fprintf(outfile, "%3d ", cb->callout_number);
- }
-
-for (i = 0; i < pre_start; i++) fprintf(outfile, " ");
-fprintf(outfile, "^");
-
-if (post_start > 0)
- {
- for (i = 0; i < post_start - 1; i++) fprintf(outfile, " ");
- fprintf(outfile, "^");
- }
-
-for (i = 0; i < subject_length - pre_start - post_start + 4; i++)
- fprintf(outfile, " ");
-
-fprintf(outfile, "%.*s", (cb->next_item_length == 0)? 1 : cb->next_item_length,
- pbuffer + cb->pattern_position);
-
-fprintf(outfile, "\n");
-first_callout = 0;
-
-if (cb->callout_data != NULL)
- {
- int callout_data = *((int *)(cb->callout_data));
- if (callout_data != 0)
- {
- fprintf(outfile, "Callout data = %d\n", callout_data);
- return callout_data;
- }
- }
-
-return (cb->callout_number != callout_fail_id)? 0 :
- (++callout_count >= callout_fail_count)? 1 : 0;
-}
-
-
-/*************************************************
-* Local malloc functions *
-*************************************************/
-
-/* Alternative malloc function, to test functionality and show the size of the
-compiled re. */
-
-static void *new_malloc(size_t size)
-{
-void *block = malloc(size);
-gotten_store = size;
-if (show_malloc)
- fprintf(outfile, "malloc %3d %p\n", (int)size, block);
-return block;
-}
-
-static void new_free(void *block)
-{
-if (show_malloc)
- fprintf(outfile, "free %p\n", block);
-free(block);
-}
-
-
-/* For recursion malloc/free, to test stacking calls */
-
-static void *stack_malloc(size_t size)
-{
-void *block = malloc(size);
-if (show_malloc)
- fprintf(outfile, "stack_malloc %3d %p\n", (int)size, block);
-return block;
-}
-
-static void stack_free(void *block)
-{
-if (show_malloc)
- fprintf(outfile, "stack_free %p\n", block);
-free(block);
-}
-
-
-/*************************************************
-* Call pcre_fullinfo() *
-*************************************************/
-
-/* Get one piece of information from the pcre_fullinfo() function */
-
-static void new_info(pcre *re, pcre_extra *study, int option, void *ptr)
-{
-int rc;
-if ((rc = pcre_fullinfo(re, study, option, ptr)) < 0)
- fprintf(outfile, "Error %d from pcre_fullinfo(%d)\n", rc, option);
-}
-
-
-
-/*************************************************
-* Byte flipping function *
-*************************************************/
-
-static unsigned long int
-byteflip(unsigned long int value, int n)
-{
-if (n == 2) return ((value & 0x00ff) << 8) | ((value & 0xff00) >> 8);
-return ((value & 0x000000ff) << 24) |
- ((value & 0x0000ff00) << 8) |
- ((value & 0x00ff0000) >> 8) |
- ((value & 0xff000000) >> 24);
-}
-
-
-
-
-/*************************************************
-* Check match or recursion limit *
-*************************************************/
-
-static int
-check_match_limit(pcre *re, pcre_extra *extra, uschar *bptr, int len,
- int start_offset, int options, int *use_offsets, int use_size_offsets,
- int flag, unsigned long int *limit, int errnumber, const char *msg)
-{
-int count;
-int min = 0;
-int mid = 64;
-int max = -1;
-
-extra->flags |= flag;
-
-for (;;)
- {
- *limit = mid;
-
- count = pcre_exec(re, extra, (char *)bptr, len, start_offset, options,
- use_offsets, use_size_offsets);
-
- if (count == errnumber)
- {
- /* fprintf(outfile, "Testing %s limit = %d\n", msg, mid); */
- min = mid;
- mid = (mid == max - 1)? max : (max > 0)? (min + max)/2 : mid*2;
- }
-
- else if (count >= 0 || count == PCRE_ERROR_NOMATCH ||
- count == PCRE_ERROR_PARTIAL)
- {
- if (mid == min + 1)
- {
- fprintf(outfile, "Minimum %s limit = %d\n", msg, mid);
- break;
- }
- /* fprintf(outfile, "Testing %s limit = %d\n", msg, mid); */
- max = mid;
- mid = (min + mid)/2;
- }
- else break; /* Some other error */
- }
-
-extra->flags &= ~flag;
-return count;
-}
-
-
-
-/*************************************************
-* Check newline indicator *
-*************************************************/
-
-/* This is used both at compile and run-time to check for <xxx> escapes, where
-xxx is LF, CR, CRLF, or ANY. Print a message and return 0 if there is no match.
-
-Arguments:
- p points after the leading '<'
- f file for error message
-
-Returns: appropriate PCRE_NEWLINE_xxx flags, or 0
-*/
-
-static int
-check_newline(uschar *p, FILE *f)
-{
-if (strncmp((char *)p, "cr>", 3) == 0) return PCRE_NEWLINE_CR;
-if (strncmp((char *)p, "lf>", 3) == 0) return PCRE_NEWLINE_LF;
-if (strncmp((char *)p, "crlf>", 5) == 0) return PCRE_NEWLINE_CRLF;
-if (strncmp((char *)p, "any>", 4) == 0) return PCRE_NEWLINE_ANY;
-fprintf(f, "Unknown newline type at: <%s\n", p);
-return 0;
-}
-
-
-
-/*************************************************
-* Usage function *
-*************************************************/
-
-static void
-usage(void)
-{
-printf("Usage: pcretest [options] [<input> [<output>]]\n");
-printf(" -b show compiled code (bytecode)\n");
-printf(" -C show PCRE compile-time options and exit\n");
-printf(" -d debug: show compiled code and information (-b and -i)\n");
-#if !defined NODFA
-printf(" -dfa force DFA matching for all subjects\n");
-#endif
-printf(" -help show usage information\n");
-printf(" -i show information about compiled patterns\n"
- " -m output memory used information\n"
- " -o <n> set size of offsets vector to <n>\n");
-#if !defined NOPOSIX
-printf(" -p use POSIX interface\n");
-#endif
-printf(" -q quiet: do not output PCRE version number at start\n");
-printf(" -S <n> set stack size to <n> megabytes\n");
-printf(" -s output store (memory) used information\n"
- " -t time compilation and execution\n");
-printf(" -t <n> time compilation and execution, repeating <n> times\n");
-printf(" -tm time execution (matching) only\n");
-printf(" -tm <n> time execution (matching) only, repeating <n> times\n");
-}
-
-
-
-/*************************************************
-* Main Program *
-*************************************************/
-
-/* Read lines from named file or stdin and write to named file or stdout; lines
-consist of a regular expression, in delimiters and optionally followed by
-options, followed by a set of test data, terminated by an empty line. */
-
-int main(int argc, char **argv)
-{
-FILE *infile = stdin;
-int options = 0;
-int study_options = 0;
-int op = 1;
-int timeit = 0;
-int timeitm = 0;
-int showinfo = 0;
-int showstore = 0;
-int quiet = 0;
-int size_offsets = 45;
-int size_offsets_max;
-int *offsets = NULL;
-#if !defined NOPOSIX
-int posix = 0;
-#endif
-int debug = 0;
-int done = 0;
-int all_use_dfa = 0;
-int yield = 0;
-int stack_size;
-
-/* These vectors store, end-to-end, a list of captured substring names. Assume
-that 1024 is plenty long enough for the few names we'll be testing. */
-
-uschar copynames[1024];
-uschar getnames[1024];
-
-uschar *copynamesptr;
-uschar *getnamesptr;
-
-/* Get buffers from malloc() so that Electric Fence will check their misuse
-when I am debugging. They grow automatically when very long lines are read. */
-
-buffer = (unsigned char *)malloc(buffer_size);
-dbuffer = (unsigned char *)malloc(buffer_size);
-pbuffer = (unsigned char *)malloc(buffer_size);
-
-/* The outfile variable is static so that new_malloc can use it. */
-
-outfile = stdout;
-
-/* The following _setmode() stuff is some Windows magic that tells its runtime
-library to translate CRLF into a single LF character. At least, that's what
-I've been told: never having used Windows I take this all on trust. Originally
-it set 0x8000, but then I was advised that _O_BINARY was better. */
-
-#if defined(_WIN32) || defined(WIN32)
-_setmode( _fileno( stdout ), _O_BINARY );
-#endif
-
-/* Scan options */
-
-while (argc > 1 && argv[op][0] == '-')
- {
- unsigned char *endptr;
-
- if (strcmp(argv[op], "-s") == 0 || strcmp(argv[op], "-m") == 0)
- showstore = 1;
- else if (strcmp(argv[op], "-q") == 0) quiet = 1;
- else if (strcmp(argv[op], "-b") == 0) debug = 1;
- else if (strcmp(argv[op], "-i") == 0) showinfo = 1;
- else if (strcmp(argv[op], "-d") == 0) showinfo = debug = 1;
-#if !defined NODFA
- else if (strcmp(argv[op], "-dfa") == 0) all_use_dfa = 1;
-#endif
- else if (strcmp(argv[op], "-o") == 0 && argc > 2 &&
- ((size_offsets = get_value((unsigned char *)argv[op+1], &endptr)),
- *endptr == 0))
- {
- op++;
- argc--;
- }
- else if (strcmp(argv[op], "-t") == 0 || strcmp(argv[op], "-tm") == 0)
- {
- int both = argv[op][2] == 0;
- int temp;
- if (argc > 2 && (temp = get_value((unsigned char *)argv[op+1], &endptr),
- *endptr == 0))
- {
- timeitm = temp;
- op++;
- argc--;
- }
- else timeitm = LOOPREPEAT;
- if (both) timeit = timeitm;
- }
- else if (strcmp(argv[op], "-S") == 0 && argc > 2 &&
- ((stack_size = get_value((unsigned char *)argv[op+1], &endptr)),
- *endptr == 0))
- {
-#if defined(_WIN32) || defined(WIN32)
- printf("PCRE: -S not supported on this OS\n");
- exit(1);
-#else
- int rc;
- struct rlimit rlim;
- getrlimit(RLIMIT_STACK, &rlim);
- rlim.rlim_cur = stack_size * 1024 * 1024;
- rc = setrlimit(RLIMIT_STACK, &rlim);
- if (rc != 0)
- {
- printf("PCRE: setrlimit() failed with error %d\n", rc);
- exit(1);
- }
- op++;
- argc--;
-#endif
- }
-#if !defined NOPOSIX
- else if (strcmp(argv[op], "-p") == 0) posix = 1;
-#endif
- else if (strcmp(argv[op], "-C") == 0)
- {
- int rc;
- printf("PCRE version %s\n", pcre_version());
- printf("Compiled with\n");
- (void)pcre_config(PCRE_CONFIG_UTF8, &rc);
- printf(" %sUTF-8 support\n", rc? "" : "No ");
- (void)pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &rc);
- printf(" %sUnicode properties support\n", rc? "" : "No ");
- (void)pcre_config(PCRE_CONFIG_NEWLINE, &rc);
- printf(" Newline sequence is %s\n", (rc == '\r')? "CR" :
- (rc == '\n')? "LF" : (rc == ('\r'<<8 | '\n'))? "CRLF" :
- (rc == -1)? "ANY" : "???");
- (void)pcre_config(PCRE_CONFIG_LINK_SIZE, &rc);
- printf(" Internal link size = %d\n", rc);
- (void)pcre_config(PCRE_CONFIG_POSIX_MALLOC_THRESHOLD, &rc);
- printf(" POSIX malloc threshold = %d\n", rc);
- (void)pcre_config(PCRE_CONFIG_MATCH_LIMIT, &rc);
- printf(" Default match limit = %d\n", rc);
- (void)pcre_config(PCRE_CONFIG_MATCH_LIMIT_RECURSION, &rc);
- printf(" Default recursion depth limit = %d\n", rc);
- (void)pcre_config(PCRE_CONFIG_STACKRECURSE, &rc);
- printf(" Match recursion uses %s\n", rc? "stack" : "heap");
- exit(0);
- }
- else if (strcmp(argv[op], "-help") == 0 ||
- strcmp(argv[op], "--help") == 0)
- {
- usage();
- goto EXIT;
- }
- else
- {
- printf("** Unknown or malformed option %s\n", argv[op]);
- usage();
- yield = 1;
- goto EXIT;
- }
- op++;
- argc--;
- }
-
-/* Get the store for the offsets vector, and remember what it was */
-
-size_offsets_max = size_offsets;
-offsets = (int *)malloc(size_offsets_max * sizeof(int));
-if (offsets == NULL)
- {
- printf("** Failed to get %d bytes of memory for offsets vector\n",
- size_offsets_max * sizeof(int));
- yield = 1;
- goto EXIT;
- }
-
-/* Sort out the input and output files */
-
-if (argc > 1)
- {
- infile = fopen(argv[op], INPUT_MODE);
- if (infile == NULL)
- {
- printf("** Failed to open %s\n", argv[op]);
- yield = 1;
- goto EXIT;
- }
- }
-
-if (argc > 2)
- {
- outfile = fopen(argv[op+1], OUTPUT_MODE);
- if (outfile == NULL)
- {
- printf("** Failed to open %s\n", argv[op+1]);
- yield = 1;
- goto EXIT;
- }
- }
-
-/* Set alternative malloc function */
-
-pcre_malloc = new_malloc;
-pcre_free = new_free;
-pcre_stack_malloc = stack_malloc;
-pcre_stack_free = stack_free;
-
-/* Heading line unless quiet, then prompt for first regex if stdin */
-
-if (!quiet) fprintf(outfile, "PCRE version %s\n\n", pcre_version());
-
-/* Main loop */
-
-while (!done)
- {
- pcre *re = NULL;
- pcre_extra *extra = NULL;
-
-#if !defined NOPOSIX /* There are still compilers that require no indent */
- regex_t preg;
- int do_posix = 0;
-#endif
-
- const char *error;
- unsigned char *p, *pp, *ppp;
- unsigned char *to_file = NULL;
- const unsigned char *tables = NULL;
- unsigned long int true_size, true_study_size = 0;
- size_t size, regex_gotten_store;
- int do_study = 0;
- int do_debug = debug;
- int do_G = 0;
- int do_g = 0;
- int do_showinfo = showinfo;
- int do_showrest = 0;
- int do_flip = 0;
- int erroroffset, len, delimiter, poffset;
-
- use_utf8 = 0;
-
- if (infile == stdin) printf(" re> ");
- if (extend_inputline(infile, buffer) == NULL) break;
- if (infile != stdin) fprintf(outfile, "%s", (char *)buffer);
- fflush(outfile);
-
- p = buffer;
- while (isspace(*p)) p++;
- if (*p == 0) continue;
-
- /* See if the pattern is to be loaded pre-compiled from a file. */
-
- if (*p == '<' && strchr((char *)(p+1), '<') == NULL)
- {
- unsigned long int magic, get_options;
- uschar sbuf[8];
- FILE *f;
-
- p++;
- pp = p + (int)strlen((char *)p);
- while (isspace(pp[-1])) pp--;
- *pp = 0;
-
- f = fopen((char *)p, "rb");
- if (f == NULL)
- {
- fprintf(outfile, "Failed to open %s: %s\n", p, strerror(errno));
- continue;
- }
-
- if (fread(sbuf, 1, 8, f) != 8) goto FAIL_READ;
-
- true_size =
- (sbuf[0] << 24) | (sbuf[1] << 16) | (sbuf[2] << 8) | sbuf[3];
- true_study_size =
- (sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];
-
- re = (real_pcre *)new_malloc(true_size);
- regex_gotten_store = gotten_store;
-
- if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ;
-
- magic = ((real_pcre *)re)->magic_number;
- if (magic != MAGIC_NUMBER)
- {
- if (byteflip(magic, sizeof(magic)) == MAGIC_NUMBER)
- {
- do_flip = 1;
- }
- else
- {
- fprintf(outfile, "Data in %s is not a compiled PCRE regex\n", p);
- fclose(f);
- continue;
- }
- }
-
- fprintf(outfile, "Compiled regex%s loaded from %s\n",
- do_flip? " (byte-inverted)" : "", p);
-
- /* Need to know if UTF-8 for printing data strings */
-
- new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options);
- use_utf8 = (get_options & PCRE_UTF8) != 0;
-
- /* Now see if there is any following study data */
-
- if (true_study_size != 0)
- {
- pcre_study_data *psd;
-
- extra = (pcre_extra *)new_malloc(sizeof(pcre_extra) + true_study_size);
- extra->flags = PCRE_EXTRA_STUDY_DATA;
-
- psd = (pcre_study_data *)(((char *)extra) + sizeof(pcre_extra));
- extra->study_data = psd;
-
- if (fread(psd, 1, true_study_size, f) != true_study_size)
- {
- FAIL_READ:
- fprintf(outfile, "Failed to read data from %s\n", p);
- if (extra != NULL) new_free(extra);
- if (re != NULL) new_free(re);
- fclose(f);
- continue;
- }
- fprintf(outfile, "Study data loaded from %s\n", p);
- do_study = 1; /* To get the data output if requested */
- }
- else fprintf(outfile, "No study data\n");
-
- fclose(f);
- goto SHOW_INFO;
- }
-
- /* In-line pattern (the usual case). Get the delimiter and seek the end of
- the pattern; if is isn't complete, read more. */
-
- delimiter = *p++;
-
- if (isalnum(delimiter) || delimiter == '\\')
- {
- fprintf(outfile, "** Delimiter must not be alphameric or \\\n");
- goto SKIP_DATA;
- }
-
- pp = p;
- poffset = p - buffer;
-
- for(;;)
- {
- while (*pp != 0)
- {
- if (*pp == '\\' && pp[1] != 0) pp++;
- else if (*pp == delimiter) break;
- pp++;
- }
- if (*pp != 0) break;
- if (infile == stdin) printf(" > ");
- if ((pp = extend_inputline(infile, pp)) == NULL)
- {
- fprintf(outfile, "** Unexpected EOF\n");
- done = 1;
- goto CONTINUE;
- }
- if (infile != stdin) fprintf(outfile, "%s", (char *)pp);
- }
-
- /* The buffer may have moved while being extended; reset the start of data
- pointer to the correct relative point in the buffer. */
-
- p = buffer + poffset;
-
- /* If the first character after the delimiter is backslash, make
- the pattern end with backslash. This is purely to provide a way
- of testing for the error message when a pattern ends with backslash. */
-
- if (pp[1] == '\\') *pp++ = '\\';
-
- /* Terminate the pattern at the delimiter, and save a copy of the pattern
- for callouts. */
-
- *pp++ = 0;
- strcpy((char *)pbuffer, (char *)p);
-
- /* Look for options after final delimiter */
-
- options = 0;
- study_options = 0;
- log_store = showstore; /* default from command line */
-
- while (*pp != 0)
- {
- switch (*pp++)
- {
- case 'f': options |= PCRE_FIRSTLINE; break;
- case 'g': do_g = 1; break;
- case 'i': options |= PCRE_CASELESS; break;
- case 'm': options |= PCRE_MULTILINE; break;
- case 's': options |= PCRE_DOTALL; break;
- case 'x': options |= PCRE_EXTENDED; break;
-
- case '+': do_showrest = 1; break;
- case 'A': options |= PCRE_ANCHORED; break;
- case 'B': do_debug = 1; break;
- case 'C': options |= PCRE_AUTO_CALLOUT; break;
- case 'D': do_debug = do_showinfo = 1; break;
- case 'E': options |= PCRE_DOLLAR_ENDONLY; break;
- case 'F': do_flip = 1; break;
- case 'G': do_G = 1; break;
- case 'I': do_showinfo = 1; break;
- case 'J': options |= PCRE_DUPNAMES; break;
- case 'M': log_store = 1; break;
- case 'N': options |= PCRE_NO_AUTO_CAPTURE; break;
-
-#if !defined NOPOSIX
- case 'P': do_posix = 1; break;
-#endif
-
- case 'S': do_study = 1; break;
- case 'U': options |= PCRE_UNGREEDY; break;
- case 'X': options |= PCRE_EXTRA; break;
- case '8': options |= PCRE_UTF8; use_utf8 = 1; break;
- case '?': options |= PCRE_NO_UTF8_CHECK; break;
-
- case 'L':
- ppp = pp;
- /* The '\r' test here is so that it works on Windows. */
- /* The '0' test is just in case this is an unterminated line. */
- while (*ppp != 0 && *ppp != '\n' && *ppp != '\r' && *ppp != ' ') ppp++;
- *ppp = 0;
- if (setlocale(LC_CTYPE, (const char *)pp) == NULL)
- {
- fprintf(outfile, "** Failed to set locale \"%s\"\n", pp);
- goto SKIP_DATA;
- }
- locale_set = 1;
- tables = pcre_maketables();
- pp = ppp;
- break;
-
- case '>':
- to_file = pp;
- while (*pp != 0) pp++;
- while (isspace(pp[-1])) pp--;
- *pp = 0;
- break;
-
- case '<':
- {
- int x = check_newline(pp, outfile);
- if (x == 0) goto SKIP_DATA;
- options |= x;
- while (*pp++ != '>');
- }
- break;
-
- case '\r': /* So that it works in Windows */
- case '\n':
- case ' ':
- break;
-
- default:
- fprintf(outfile, "** Unknown option '%c'\n", pp[-1]);
- goto SKIP_DATA;
- }
- }
-
- /* Handle compiling via the POSIX interface, which doesn't support the
- timing, showing, or debugging options, nor the ability to pass over
- local character tables. */
-
-#if !defined NOPOSIX
- if (posix || do_posix)
- {
- int rc;
- int cflags = 0;
-
- if ((options & PCRE_CASELESS) != 0) cflags |= REG_ICASE;
- if ((options & PCRE_MULTILINE) != 0) cflags |= REG_NEWLINE;
- if ((options & PCRE_DOTALL) != 0) cflags |= REG_DOTALL;
- if ((options & PCRE_NO_AUTO_CAPTURE) != 0) cflags |= REG_NOSUB;
- if ((options & PCRE_UTF8) != 0) cflags |= REG_UTF8;
-
- rc = regcomp(&preg, (char *)p, cflags);
-
- /* Compilation failed; go back for another re, skipping to blank line
- if non-interactive. */
-
- if (rc != 0)
- {
- (void)regerror(rc, &preg, (char *)buffer, buffer_size);
- fprintf(outfile, "Failed: POSIX code %d: %s\n", rc, buffer);
- goto SKIP_DATA;
- }
- }
-
- /* Handle compiling via the native interface */
-
- else
-#endif /* !defined NOPOSIX */
-
- {
- if (timeit > 0)
- {
- register int i;
- clock_t time_taken;
- clock_t start_time = clock();
- for (i = 0; i < timeit; i++)
- {
- re = pcre_compile((char *)p, options, &error, &erroroffset, tables);
- if (re != NULL) free(re);
- }
- time_taken = clock() - start_time;
- fprintf(outfile, "Compile time %.4f milliseconds\n",
- (((double)time_taken * 1000.0) / (double)timeit) /
- (double)CLOCKS_PER_SEC);
- }
-
- re = pcre_compile((char *)p, options, &error, &erroroffset, tables);
-
- /* Compilation failed; go back for another re, skipping to blank line
- if non-interactive. */
-
- if (re == NULL)
- {
- fprintf(outfile, "Failed: %s at offset %d\n", error, erroroffset);
- SKIP_DATA:
- if (infile != stdin)
- {
- for (;;)
- {
- if (extend_inputline(infile, buffer) == NULL)
- {
- done = 1;
- goto CONTINUE;
- }
- len = (int)strlen((char *)buffer);
- while (len > 0 && isspace(buffer[len-1])) len--;
- if (len == 0) break;
- }
- fprintf(outfile, "\n");
- }
- goto CONTINUE;
- }
-
- /* Compilation succeeded; print data if required. There are now two
- info-returning functions. The old one has a limited interface and
- returns only limited data. Check that it agrees with the newer one. */
-
- if (log_store)
- fprintf(outfile, "Memory allocation (code space): %d\n",
- (int)(gotten_store -
- sizeof(real_pcre) -
- ((real_pcre *)re)->name_count * ((real_pcre *)re)->name_entry_size));
-
- /* Extract the size for possible writing before possibly flipping it,
- and remember the store that was got. */
-
- true_size = ((real_pcre *)re)->size;
- regex_gotten_store = gotten_store;
-
- /* If /S was present, study the regexp to generate additional info to
- help with the matching. */
-
- if (do_study)
- {
- if (timeit > 0)
- {
- register int i;
- clock_t time_taken;
- clock_t start_time = clock();
- for (i = 0; i < timeit; i++)
- extra = pcre_study(re, study_options, &error);
- time_taken = clock() - start_time;
- if (extra != NULL) free(extra);
- fprintf(outfile, " Study time %.4f milliseconds\n",
- (((double)time_taken * 1000.0) / (double)timeit) /
- (double)CLOCKS_PER_SEC);
- }
- extra = pcre_study(re, study_options, &error);
- if (error != NULL)
- fprintf(outfile, "Failed to study: %s\n", error);
- else if (extra != NULL)
- true_study_size = ((pcre_study_data *)(extra->study_data))->size;
- }
-
- /* If the 'F' option was present, we flip the bytes of all the integer
- fields in the regex data block and the study block. This is to make it
- possible to test PCRE's handling of byte-flipped patterns, e.g. those
- compiled on a different architecture. */
-
- if (do_flip)
- {
- real_pcre *rre = (real_pcre *)re;
- rre->magic_number = byteflip(rre->magic_number, sizeof(rre->magic_number));
- rre->size = byteflip(rre->size, sizeof(rre->size));
- rre->options = byteflip(rre->options, sizeof(rre->options));
- rre->top_bracket = byteflip(rre->top_bracket, sizeof(rre->top_bracket));
- rre->top_backref = byteflip(rre->top_backref, sizeof(rre->top_backref));
- rre->first_byte = byteflip(rre->first_byte, sizeof(rre->first_byte));
- rre->req_byte = byteflip(rre->req_byte, sizeof(rre->req_byte));
- rre->name_table_offset = byteflip(rre->name_table_offset,
- sizeof(rre->name_table_offset));
- rre->name_entry_size = byteflip(rre->name_entry_size,
- sizeof(rre->name_entry_size));
- rre->name_count = byteflip(rre->name_count, sizeof(rre->name_count));
-
- if (extra != NULL)
- {
- pcre_study_data *rsd = (pcre_study_data *)(extra->study_data);
- rsd->size = byteflip(rsd->size, sizeof(rsd->size));
- rsd->options = byteflip(rsd->options, sizeof(rsd->options));
- }
- }
-
- /* Extract information from the compiled data if required */
-
- SHOW_INFO:
-
- if (do_debug)
- {
- fprintf(outfile, "------------------------------------------------------------------\n");
- pcre_printint(re, outfile);
- }
-
- if (do_showinfo)
- {
- unsigned long int get_options, all_options;
-#if !defined NOINFOCHECK
- int old_first_char, old_options, old_count;
-#endif
- int count, backrefmax, first_char, need_char;
- int nameentrysize, namecount;
- const uschar *nametable;
-
- new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options);
- new_info(re, NULL, PCRE_INFO_SIZE, &size);
- new_info(re, NULL, PCRE_INFO_CAPTURECOUNT, &count);
- new_info(re, NULL, PCRE_INFO_BACKREFMAX, &backrefmax);
- new_info(re, NULL, PCRE_INFO_FIRSTBYTE, &first_char);
- new_info(re, NULL, PCRE_INFO_LASTLITERAL, &need_char);
- new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &nameentrysize);
- new_info(re, NULL, PCRE_INFO_NAMECOUNT, &namecount);
- new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable);
-
-#if !defined NOINFOCHECK
- old_count = pcre_info(re, &old_options, &old_first_char);
- if (count < 0) fprintf(outfile,
- "Error %d from pcre_info()\n", count);
- else
- {
- if (old_count != count) fprintf(outfile,
- "Count disagreement: pcre_fullinfo=%d pcre_info=%d\n", count,
- old_count);
-
- if (old_first_char != first_char) fprintf(outfile,
- "First char disagreement: pcre_fullinfo=%d pcre_info=%d\n",
- first_char, old_first_char);
-
- if (old_options != (int)get_options) fprintf(outfile,
- "Options disagreement: pcre_fullinfo=%ld pcre_info=%d\n",
- get_options, old_options);
- }
-#endif
-
- if (size != regex_gotten_store) fprintf(outfile,
- "Size disagreement: pcre_fullinfo=%d call to malloc for %d\n",
- (int)size, (int)regex_gotten_store);
-
- fprintf(outfile, "Capturing subpattern count = %d\n", count);
- if (backrefmax > 0)
- fprintf(outfile, "Max back reference = %d\n", backrefmax);
-
- if (namecount > 0)
- {
- fprintf(outfile, "Named capturing subpatterns:\n");
- while (namecount-- > 0)
- {
- fprintf(outfile, " %s %*s%3d\n", nametable + 2,
- nameentrysize - 3 - (int)strlen((char *)nametable + 2), "",
- GET2(nametable, 0));
- nametable += nameentrysize;
- }
- }
-
- /* The NOPARTIAL bit is a private bit in the options, so we have
- to fish it out via out back door */
-
- all_options = ((real_pcre *)re)->options;
- if (do_flip)
- {
- all_options = byteflip(all_options, sizeof(all_options));
- }
-
- if ((all_options & PCRE_NOPARTIAL) != 0)
- fprintf(outfile, "Partial matching not supported\n");
-
- if (get_options == 0) fprintf(outfile, "No options\n");
- else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
- ((get_options & PCRE_ANCHORED) != 0)? " anchored" : "",
- ((get_options & PCRE_CASELESS) != 0)? " caseless" : "",
- ((get_options & PCRE_EXTENDED) != 0)? " extended" : "",
- ((get_options & PCRE_MULTILINE) != 0)? " multiline" : "",
- ((get_options & PCRE_FIRSTLINE) != 0)? " firstline" : "",
- ((get_options & PCRE_DOTALL) != 0)? " dotall" : "",
- ((get_options & PCRE_DOLLAR_ENDONLY) != 0)? " dollar_endonly" : "",
- ((get_options & PCRE_EXTRA) != 0)? " extra" : "",
- ((get_options & PCRE_UNGREEDY) != 0)? " ungreedy" : "",
- ((get_options & PCRE_NO_AUTO_CAPTURE) != 0)? " no_auto_capture" : "",
- ((get_options & PCRE_UTF8) != 0)? " utf8" : "",
- ((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf8_check" : "",
- ((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : "");
-
- switch (get_options & PCRE_NEWLINE_BITS)
- {
- case PCRE_NEWLINE_CR:
- fprintf(outfile, "Forced newline sequence: CR\n");
- break;
-
- case PCRE_NEWLINE_LF:
- fprintf(outfile, "Forced newline sequence: LF\n");
- break;
-
- case PCRE_NEWLINE_CRLF:
- fprintf(outfile, "Forced newline sequence: CRLF\n");
- break;
-
- case PCRE_NEWLINE_ANY:
- fprintf(outfile, "Forced newline sequence: ANY\n");
- break;
-
- default:
- break;
- }
-
- if (first_char == -1)
- {
- fprintf(outfile, "First char at start or follows newline\n");
- }
- else if (first_char < 0)
- {
- fprintf(outfile, "No first char\n");
- }
- else
- {
- int ch = first_char & 255;
- const char *caseless = ((first_char & REQ_CASELESS) == 0)?
- "" : " (caseless)";
- if (PRINTHEX(ch))
- fprintf(outfile, "First char = \'%c\'%s\n", ch, caseless);
- else
- fprintf(outfile, "First char = %d%s\n", ch, caseless);
- }
-
- if (need_char < 0)
- {
- fprintf(outfile, "No need char\n");
- }
- else
- {
- int ch = need_char & 255;
- const char *caseless = ((need_char & REQ_CASELESS) == 0)?
- "" : " (caseless)";
- if (PRINTHEX(ch))
- fprintf(outfile, "Need char = \'%c\'%s\n", ch, caseless);
- else
- fprintf(outfile, "Need char = %d%s\n", ch, caseless);
- }
-
- /* Don't output study size; at present it is in any case a fixed
- value, but it varies, depending on the computer architecture, and
- so messes up the test suite. (And with the /F option, it might be
- flipped.) */
-
- if (do_study)
- {
- if (extra == NULL)
- fprintf(outfile, "Study returned NULL\n");
- else
- {
- uschar *start_bits = NULL;
- new_info(re, extra, PCRE_INFO_FIRSTTABLE, &start_bits);
-
- if (start_bits == NULL)
- fprintf(outfile, "No starting byte set\n");
- else
- {
- int i;
- int c = 24;
- fprintf(outfile, "Starting byte set: ");
- for (i = 0; i < 256; i++)
- {
- if ((start_bits[i/8] & (1<<(i&7))) != 0)
- {
- if (c > 75)
- {
- fprintf(outfile, "\n ");
- c = 2;
- }
- if (PRINTHEX(i) && i != ' ')
- {
- fprintf(outfile, "%c ", i);
- c += 2;
- }
- else
- {
- fprintf(outfile, "\\x%02x ", i);
- c += 5;
- }
- }
- }
- fprintf(outfile, "\n");
- }
- }
- }
- }
-
- /* If the '>' option was present, we write out the regex to a file, and
- that is all. The first 8 bytes of the file are the regex length and then
- the study length, in big-endian order. */
-
- if (to_file != NULL)
- {
- FILE *f = fopen((char *)to_file, "wb");
- if (f == NULL)
- {
- fprintf(outfile, "Unable to open %s: %s\n", to_file, strerror(errno));
- }
- else
- {
- uschar sbuf[8];
- sbuf[0] = (true_size >> 24) & 255;
- sbuf[1] = (true_size >> 16) & 255;
- sbuf[2] = (true_size >> 8) & 255;
- sbuf[3] = (true_size) & 255;
-
- sbuf[4] = (true_study_size >> 24) & 255;
- sbuf[5] = (true_study_size >> 16) & 255;
- sbuf[6] = (true_study_size >> 8) & 255;
- sbuf[7] = (true_study_size) & 255;
-
- if (fwrite(sbuf, 1, 8, f) < 8 ||
- fwrite(re, 1, true_size, f) < true_size)
- {
- fprintf(outfile, "Write error on %s: %s\n", to_file, strerror(errno));
- }
- else
- {
- fprintf(outfile, "Compiled regex written to %s\n", to_file);
- if (extra != NULL)
- {
- if (fwrite(extra->study_data, 1, true_study_size, f) <
- true_study_size)
- {
- fprintf(outfile, "Write error on %s: %s\n", to_file,
- strerror(errno));
- }
- else fprintf(outfile, "Study data written to %s\n", to_file);
-
- }
- }
- fclose(f);
- }
-
- new_free(re);
- if (extra != NULL) new_free(extra);
- if (tables != NULL) new_free((void *)tables);
- continue; /* With next regex */
- }
- } /* End of non-POSIX compile */
-
- /* Read data lines and test them */
-
- for (;;)
- {
- uschar *q;
- uschar *bptr = dbuffer;
- int *use_offsets = offsets;
- int use_size_offsets = size_offsets;
- int callout_data = 0;
- int callout_data_set = 0;
- int count, c;
- int copystrings = 0;
- int find_match_limit = 0;
- int getstrings = 0;
- int getlist = 0;
- int gmatched = 0;
- int start_offset = 0;
- int g_notempty = 0;
- int use_dfa = 0;
-
- options = 0;
-
- *copynames = 0;
- *getnames = 0;
-
- copynamesptr = copynames;
- getnamesptr = getnames;
-
- pcre_callout = callout;
- first_callout = 1;
- callout_extra = 0;
- callout_count = 0;
- callout_fail_count = 999999;
- callout_fail_id = -1;
- show_malloc = 0;
-
- if (extra != NULL) extra->flags &=
- ~(PCRE_EXTRA_MATCH_LIMIT|PCRE_EXTRA_MATCH_LIMIT_RECURSION);
-
- len = 0;
- for (;;)
- {
- if (infile == stdin) printf("data> ");
- if (extend_inputline(infile, buffer + len) == NULL)
- {
- if (len > 0) break;
- done = 1;
- goto CONTINUE;
- }
- if (infile != stdin) fprintf(outfile, "%s", (char *)buffer);
- len = (int)strlen((char *)buffer);
- if (buffer[len-1] == '\n') break;
- }
-
- while (len > 0 && isspace(buffer[len-1])) len--;
- buffer[len] = 0;
- if (len == 0) break;
-
- p = buffer;
- while (isspace(*p)) p++;
-
- q = dbuffer;
- while ((c = *p++) != 0)
- {
- int i = 0;
- int n = 0;
-
- if (c == '\\') switch ((c = *p++))
- {
- case 'a': c = 7; break;
- case 'b': c = '\b'; break;
- case 'e': c = 27; break;
- case 'f': c = '\f'; break;
- case 'n': c = '\n'; break;
- case 'r': c = '\r'; break;
- case 't': c = '\t'; break;
- case 'v': c = '\v'; break;
-
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- c -= '0';
- while (i++ < 2 && isdigit(*p) && *p != '8' && *p != '9')
- c = c * 8 + *p++ - '0';
-
-#if !defined NOUTF8
- if (use_utf8 && c > 255)
- {
- unsigned char buff8[8];
- int ii, utn;
- utn = ord2utf8(c, buff8);
- for (ii = 0; ii < utn - 1; ii++) *q++ = buff8[ii];
- c = buff8[ii]; /* Last byte */
- }
-#endif
- break;
-
- case 'x':
-
- /* Handle \x{..} specially - new Perl thing for utf8 */
-
-#if !defined NOUTF8
- if (*p == '{')
- {
- unsigned char *pt = p;
- c = 0;
- while (isxdigit(*(++pt)))
- c = c * 16 + tolower(*pt) - ((isdigit(*pt))? '0' : 'W');
- if (*pt == '}')
- {
- unsigned char buff8[8];
- int ii, utn;
- utn = ord2utf8(c, buff8);
- for (ii = 0; ii < utn - 1; ii++) *q++ = buff8[ii];
- c = buff8[ii]; /* Last byte */
- p = pt + 1;
- break;
- }
- /* Not correct form; fall through */
- }
-#endif
-
- /* Ordinary \x */
-
- c = 0;
- while (i++ < 2 && isxdigit(*p))
- {
- c = c * 16 + tolower(*p) - ((isdigit(*p))? '0' : 'W');
- p++;
- }
- break;
-
- case 0: /* \ followed by EOF allows for an empty line */
- p--;
- continue;
-
- case '>':
- while(isdigit(*p)) start_offset = start_offset * 10 + *p++ - '0';
- continue;
-
- case 'A': /* Option setting */
- options |= PCRE_ANCHORED;
- continue;
-
- case 'B':
- options |= PCRE_NOTBOL;
- continue;
-
- case 'C':
- if (isdigit(*p)) /* Set copy string */
- {
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
- copystrings |= 1 << n;
- }
- else if (isalnum(*p))
- {
- uschar *npp = copynamesptr;
- while (isalnum(*p)) *npp++ = *p++;
- *npp++ = 0;
- *npp = 0;
- n = pcre_get_stringnumber(re, (char *)copynamesptr);
- if (n < 0)
- fprintf(outfile, "no parentheses with name \"%s\"\n", copynamesptr);
- copynamesptr = npp;
- }
- else if (*p == '+')
- {
- callout_extra = 1;
- p++;
- }
- else if (*p == '-')
- {
- pcre_callout = NULL;
- p++;
- }
- else if (*p == '!')
- {
- callout_fail_id = 0;
- p++;
- while(isdigit(*p))
- callout_fail_id = callout_fail_id * 10 + *p++ - '0';
- callout_fail_count = 0;
- if (*p == '!')
- {
- p++;
- while(isdigit(*p))
- callout_fail_count = callout_fail_count * 10 + *p++ - '0';
- }
- }
- else if (*p == '*')
- {
- int sign = 1;
- callout_data = 0;
- if (*(++p) == '-') { sign = -1; p++; }
- while(isdigit(*p))
- callout_data = callout_data * 10 + *p++ - '0';
- callout_data *= sign;
- callout_data_set = 1;
- }
- continue;
-
-#if !defined NODFA
- case 'D':
-#if !defined NOPOSIX
- if (posix || do_posix)
- printf("** Can't use dfa matching in POSIX mode: \\D ignored\n");
- else
-#endif
- use_dfa = 1;
- continue;
-
- case 'F':
- options |= PCRE_DFA_SHORTEST;
- continue;
-#endif
-
- case 'G':
- if (isdigit(*p))
- {
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
- getstrings |= 1 << n;
- }
- else if (isalnum(*p))
- {
- uschar *npp = getnamesptr;
- while (isalnum(*p)) *npp++ = *p++;
- *npp++ = 0;
- *npp = 0;
- n = pcre_get_stringnumber(re, (char *)getnamesptr);
- if (n < 0)
- fprintf(outfile, "no parentheses with name \"%s\"\n", getnamesptr);
- getnamesptr = npp;
- }
- continue;
-
- case 'L':
- getlist = 1;
- continue;
-
- case 'M':
- find_match_limit = 1;
- continue;
-
- case 'N':
- options |= PCRE_NOTEMPTY;
- continue;
-
- case 'O':
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
- if (n > size_offsets_max)
- {
- size_offsets_max = n;
- free(offsets);
- use_offsets = offsets = (int *)malloc(size_offsets_max * sizeof(int));
- if (offsets == NULL)
- {
- printf("** Failed to get %d bytes of memory for offsets vector\n",
- size_offsets_max * sizeof(int));
- yield = 1;
- goto EXIT;
- }
- }
- use_size_offsets = n;
- if (n == 0) use_offsets = NULL; /* Ensures it can't write to it */
- continue;
-
- case 'P':
- options |= PCRE_PARTIAL;
- continue;
-
- case 'Q':
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
- if (extra == NULL)
- {
- extra = (pcre_extra *)malloc(sizeof(pcre_extra));
- extra->flags = 0;
- }
- extra->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
- extra->match_limit_recursion = n;
- continue;
-
- case 'q':
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
- if (extra == NULL)
- {
- extra = (pcre_extra *)malloc(sizeof(pcre_extra));
- extra->flags = 0;
- }
- extra->flags |= PCRE_EXTRA_MATCH_LIMIT;
- extra->match_limit = n;
- continue;
-
-#if !defined NODFA
- case 'R':
- options |= PCRE_DFA_RESTART;
- continue;
-#endif
-
- case 'S':
- show_malloc = 1;
- continue;
-
- case 'Z':
- options |= PCRE_NOTEOL;
- continue;
-
- case '?':
- options |= PCRE_NO_UTF8_CHECK;
- continue;
-
- case '<':
- {
- int x = check_newline(p, outfile);
- if (x == 0) goto NEXT_DATA;
- options |= x;
- while (*p++ != '>');
- }
- continue;
- }
- *q++ = c;
- }
- *q = 0;
- len = q - dbuffer;
-
- if ((all_use_dfa || use_dfa) && find_match_limit)
- {
- printf("**Match limit not relevant for DFA matching: ignored\n");
- find_match_limit = 0;
- }
-
- /* Handle matching via the POSIX interface, which does not
- support timing or playing with the match limit or callout data. */
-
-#if !defined NOPOSIX
- if (posix || do_posix)
- {
- int rc;
- int eflags = 0;
- regmatch_t *pmatch = NULL;
- if (use_size_offsets > 0)
- pmatch = (regmatch_t *)malloc(sizeof(regmatch_t) * use_size_offsets);
- if ((options & PCRE_NOTBOL) != 0) eflags |= REG_NOTBOL;
- if ((options & PCRE_NOTEOL) != 0) eflags |= REG_NOTEOL;
-
- rc = regexec(&preg, (const char *)bptr, use_size_offsets, pmatch, eflags);
-
- if (rc != 0)
- {
- (void)regerror(rc, &preg, (char *)buffer, buffer_size);
- fprintf(outfile, "No match: POSIX code %d: %s\n", rc, buffer);
- }
- else if ((((const pcre *)preg.re_pcre)->options & PCRE_NO_AUTO_CAPTURE)
- != 0)
- {
- fprintf(outfile, "Matched with REG_NOSUB\n");
- }
- else
- {
- size_t i;
- for (i = 0; i < (size_t)use_size_offsets; i++)
- {
- if (pmatch[i].rm_so >= 0)
- {
- fprintf(outfile, "%2d: ", (int)i);
- (void)pchars(dbuffer + pmatch[i].rm_so,
- pmatch[i].rm_eo - pmatch[i].rm_so, outfile);
- fprintf(outfile, "\n");
- if (i == 0 && do_showrest)
- {
- fprintf(outfile, " 0+ ");
- (void)pchars(dbuffer + pmatch[i].rm_eo, len - pmatch[i].rm_eo,
- outfile);
- fprintf(outfile, "\n");
- }
- }
- }
- }
- free(pmatch);
- }
-
- /* Handle matching via the native interface - repeats for /g and /G */
-
- else
-#endif /* !defined NOPOSIX */
-
- for (;; gmatched++) /* Loop for /g or /G */
- {
- if (timeitm > 0)
- {
- register int i;
- clock_t time_taken;
- clock_t start_time = clock();
-
-#if !defined NODFA
- if (all_use_dfa || use_dfa)
- {
- int workspace[1000];
- for (i = 0; i < timeitm; i++)
- count = pcre_dfa_exec(re, NULL, (char *)bptr, len, start_offset,
- options | g_notempty, use_offsets, use_size_offsets, workspace,
- sizeof(workspace)/sizeof(int));
- }
- else
-#endif
-
- for (i = 0; i < timeitm; i++)
- count = pcre_exec(re, extra, (char *)bptr, len,
- start_offset, options | g_notempty, use_offsets, use_size_offsets);
-
- time_taken = clock() - start_time;
- fprintf(outfile, "Execute time %.4f milliseconds\n",
- (((double)time_taken * 1000.0) / (double)timeitm) /
- (double)CLOCKS_PER_SEC);
- }
-
- /* If find_match_limit is set, we want to do repeated matches with
- varying limits in order to find the minimum value for the match limit and
- for the recursion limit. */
-
- if (find_match_limit)
- {
- if (extra == NULL)
- {
- extra = (pcre_extra *)malloc(sizeof(pcre_extra));
- extra->flags = 0;
- }
-
- (void)check_match_limit(re, extra, bptr, len, start_offset,
- options|g_notempty, use_offsets, use_size_offsets,
- PCRE_EXTRA_MATCH_LIMIT, &(extra->match_limit),
- PCRE_ERROR_MATCHLIMIT, "match()");
-
- count = check_match_limit(re, extra, bptr, len, start_offset,
- options|g_notempty, use_offsets, use_size_offsets,
- PCRE_EXTRA_MATCH_LIMIT_RECURSION, &(extra->match_limit_recursion),
- PCRE_ERROR_RECURSIONLIMIT, "match() recursion");
- }
-
- /* If callout_data is set, use the interface with additional data */
-
- else if (callout_data_set)
- {
- if (extra == NULL)
- {
- extra = (pcre_extra *)malloc(sizeof(pcre_extra));
- extra->flags = 0;
- }
- extra->flags |= PCRE_EXTRA_CALLOUT_DATA;
- extra->callout_data = &callout_data;
- count = pcre_exec(re, extra, (char *)bptr, len, start_offset,
- options | g_notempty, use_offsets, use_size_offsets);
- extra->flags &= ~PCRE_EXTRA_CALLOUT_DATA;
- }
-
- /* The normal case is just to do the match once, with the default
- value of match_limit. */
-
-#if !defined NODFA
- else if (all_use_dfa || use_dfa)
- {
- int workspace[1000];
- count = pcre_dfa_exec(re, NULL, (char *)bptr, len, start_offset,
- options | g_notempty, use_offsets, use_size_offsets, workspace,
- sizeof(workspace)/sizeof(int));
- if (count == 0)
- {
- fprintf(outfile, "Matched, but too many subsidiary matches\n");
- count = use_size_offsets/2;
- }
- }
-#endif
-
- else
- {
- count = pcre_exec(re, extra, (char *)bptr, len,
- start_offset, options | g_notempty, use_offsets, use_size_offsets);
- if (count == 0)
- {
- fprintf(outfile, "Matched, but too many substrings\n");
- count = use_size_offsets/3;
- }
- }
-
- /* Matched */
-
- if (count >= 0)
- {
- int i, maxcount;
-
-#if !defined NODFA
- if (all_use_dfa || use_dfa) maxcount = use_size_offsets/2; else
-#endif
- maxcount = use_size_offsets/3;
-
- /* This is a check against a lunatic return value. */
-
- if (count > maxcount)
- {
- fprintf(outfile,
- "** PCRE error: returned count %d is too big for offset size %d\n",
- count, use_size_offsets);
- count = use_size_offsets/3;
- if (do_g || do_G)
- {
- fprintf(outfile, "** /%c loop abandoned\n", do_g? 'g' : 'G');
- do_g = do_G = FALSE; /* Break g/G loop */
- }
- }
-
- for (i = 0; i < count * 2; i += 2)
- {
- if (use_offsets[i] < 0)
- fprintf(outfile, "%2d: <unset>\n", i/2);
- else
- {
- fprintf(outfile, "%2d: ", i/2);
- (void)pchars(bptr + use_offsets[i],
- use_offsets[i+1] - use_offsets[i], outfile);
- fprintf(outfile, "\n");
- if (i == 0)
- {
- if (do_showrest)
- {
- fprintf(outfile, " 0+ ");
- (void)pchars(bptr + use_offsets[i+1], len - use_offsets[i+1],
- outfile);
- fprintf(outfile, "\n");
- }
- }
- }
- }
-
- for (i = 0; i < 32; i++)
- {
- if ((copystrings & (1 << i)) != 0)
- {
- char copybuffer[256];
- int rc = pcre_copy_substring((char *)bptr, use_offsets, count,
- i, copybuffer, sizeof(copybuffer));
- if (rc < 0)
- fprintf(outfile, "copy substring %d failed %d\n", i, rc);
- else
- fprintf(outfile, "%2dC %s (%d)\n", i, copybuffer, rc);
- }
- }
-
- for (copynamesptr = copynames;
- *copynamesptr != 0;
- copynamesptr += (int)strlen((char*)copynamesptr) + 1)
- {
- char copybuffer[256];
- int rc = pcre_copy_named_substring(re, (char *)bptr, use_offsets,
- count, (char *)copynamesptr, copybuffer, sizeof(copybuffer));
- if (rc < 0)
- fprintf(outfile, "copy substring %s failed %d\n", copynamesptr, rc);
- else
- fprintf(outfile, " C %s (%d) %s\n", copybuffer, rc, copynamesptr);
- }
-
- for (i = 0; i < 32; i++)
- {
- if ((getstrings & (1 << i)) != 0)
- {
- const char *substring;
- int rc = pcre_get_substring((char *)bptr, use_offsets, count,
- i, &substring);
- if (rc < 0)
- fprintf(outfile, "get substring %d failed %d\n", i, rc);
- else
- {
- fprintf(outfile, "%2dG %s (%d)\n", i, substring, rc);
- pcre_free_substring(substring);
- }
- }
- }
-
- for (getnamesptr = getnames;
- *getnamesptr != 0;
- getnamesptr += (int)strlen((char*)getnamesptr) + 1)
- {
- const char *substring;
- int rc = pcre_get_named_substring(re, (char *)bptr, use_offsets,
- count, (char *)getnamesptr, &substring);
- if (rc < 0)
- fprintf(outfile, "copy substring %s failed %d\n", getnamesptr, rc);
- else
- {
- fprintf(outfile, " G %s (%d) %s\n", substring, rc, getnamesptr);
- pcre_free_substring(substring);
- }
- }
-
- if (getlist)
- {
- const char **stringlist;
- int rc = pcre_get_substring_list((char *)bptr, use_offsets, count,
- &stringlist);
- if (rc < 0)
- fprintf(outfile, "get substring list failed %d\n", rc);
- else
- {
- for (i = 0; i < count; i++)
- fprintf(outfile, "%2dL %s\n", i, stringlist[i]);
- if (stringlist[i] != NULL)
- fprintf(outfile, "string list not terminated by NULL\n");
- /* free((void *)stringlist); */
- pcre_free_substring_list(stringlist);
- }
- }
- }
-
- /* There was a partial match */
-
- else if (count == PCRE_ERROR_PARTIAL)
- {
- fprintf(outfile, "Partial match");
-#if !defined NODFA
- if ((all_use_dfa || use_dfa) && use_size_offsets > 2)
- fprintf(outfile, ": %.*s", use_offsets[1] - use_offsets[0],
- bptr + use_offsets[0]);
-#endif
- fprintf(outfile, "\n");
- break; /* Out of the /g loop */
- }
-
- /* Failed to match. If this is a /g or /G loop and we previously set
- g_notempty after a null match, this is not necessarily the end.
- We want to advance the start offset, and continue. In the case of UTF-8
- matching, the advance must be one character, not one byte. Fudge the
- offset values to achieve this. We won't be at the end of the string -
- that was checked before setting g_notempty. */
-
- else
- {
- if (g_notempty != 0)
- {
- int onechar = 1;
- use_offsets[0] = start_offset;
- if (use_utf8)
- {
- while (start_offset + onechar < len)
- {
- int tb = bptr[start_offset+onechar];
- if (tb <= 127) break;
- tb &= 0xc0;
- if (tb != 0 && tb != 0xc0) onechar++;
- }
- }
- use_offsets[1] = start_offset + onechar;
- }
- else
- {
- if (count == PCRE_ERROR_NOMATCH)
- {
- if (gmatched == 0) fprintf(outfile, "No match\n");
- }
- else fprintf(outfile, "Error %d\n", count);
- break; /* Out of the /g loop */
- }
- }
-
- /* If not /g or /G we are done */
-
- if (!do_g && !do_G) break;
-
- /* If we have matched an empty string, first check to see if we are at
- the end of the subject. If so, the /g loop is over. Otherwise, mimic
- what Perl's /g options does. This turns out to be rather cunning. First
- we set PCRE_NOTEMPTY and PCRE_ANCHORED and try the match again at the
- same point. If this fails (picked up above) we advance to the next
- character. */
-
- g_notempty = 0;
- if (use_offsets[0] == use_offsets[1])
- {
- if (use_offsets[0] == len) break;
- g_notempty = PCRE_NOTEMPTY | PCRE_ANCHORED;
- }
-
- /* For /g, update the start offset, leaving the rest alone */
-
- if (do_g) start_offset = use_offsets[1];
-
- /* For /G, update the pointer and length */
-
- else
- {
- bptr += use_offsets[1];
- len -= use_offsets[1];
- }
- } /* End of loop for /g and /G */
-
- NEXT_DATA: continue;
- } /* End of loop for data lines */
-
- CONTINUE:
-
-#if !defined NOPOSIX
- if (posix || do_posix) regfree(&preg);
-#endif
-
- if (re != NULL) new_free(re);
- if (extra != NULL) new_free(extra);
- if (tables != NULL)
- {
- new_free((void *)tables);
- setlocale(LC_CTYPE, "C");
- locale_set = 0;
- }
- }
-
-if (infile == stdin) fprintf(outfile, "\n");
-
-EXIT:
-
-if (infile != NULL && infile != stdin) fclose(infile);
-if (outfile != NULL && outfile != stdout) fclose(outfile);
-
-free(buffer);
-free(dbuffer);
-free(pbuffer);
-free(offsets);
-
-return yield;
-}
-
-/* End of pcretest.c */
diff --git a/ext/pcre/pcrelib/testdata/grepinputx b/ext/pcre/pcrelib/testdata/grepinputx
index 4c02567552..aebba02770 100644
--- a/ext/pcre/pcrelib/testdata/grepinputx
+++ b/ext/pcre/pcrelib/testdata/grepinputx
@@ -39,11 +39,4 @@ eighteen
nineteen
twenty
-Here follows some CR/LF/CRLF test data.
-
-abc
-def
-ghi
-jkl
-
This is the last line of this file.
diff --git a/ext/pcre/pcrelib/testdata/grepoutput b/ext/pcre/pcrelib/testdata/grepoutput
index 804c33fc3f..2e8cdc7d69 100644
--- a/ext/pcre/pcrelib/testdata/grepoutput
+++ b/ext/pcre/pcrelib/testdata/grepoutput
@@ -75,14 +75,7 @@ RC=1
39:nineteen
40:twenty
41:
-42:Here follows some CR/LF/CRLF test data.
-43:
-44:abc
-def
-45:ghi
-46:jkl
-47:
-48:This is the last line of this file.
+42:This is the last line of this file.
---------------------------- Test 12 -----------------------------
Pattern
---------------------------- Test 13 -----------------------------
@@ -164,8 +157,7 @@ eighteen
nineteen
twenty
-Here follows some CR/LF/CRLF test data.
-
+This is the last line of this file.
---------------------------- Test 25 -----------------------------
15-
16-complete pair
@@ -215,8 +207,7 @@ eighteen
nineteen
twenty
-Here follows some CR/LF/CRLF test data.
-
+This is the last line of this file.
---------------------------- Test 27 -----------------------------
four
five
@@ -236,10 +227,7 @@ eighteen
nineteen
twenty
-Here follows some CR/LF/CRLF test data.
-
-abc
-def
+This is the last line of this file.
---------------------------- Test 28 -----------------------------
14-of lines all by themselves.
15-
@@ -291,12 +279,7 @@ eighteen
nineteen
twenty
-Here follows some CR/LF/CRLF test data.
-
-abc
-def
-ghi
-jkl
+This is the last line of this file.
---------------------------- Test 30 -----------------------------
./testdata/grepinput-4-features should be added at the end, because some of the tests involve the
./testdata/grepinput-5-output of line numbers, and we don't want these to change.
@@ -345,8 +328,8 @@ RC=2
./testdata/grepinputx
RC=0
---------------------------- Test 36 -----------------------------
-./testdata/grepinputx
./testdata/grepinput8
+./testdata/grepinputx
RC=0
---------------------------- Test 37 -----------------------------
aaaaa0
@@ -400,30 +383,3 @@ AB.VE
AB.VE the turtle
PUT NEW DATA ABOVE THIS LINE.
---------------------------- Test 49 ------------------------------
-abc
-def
-ghi
-jkl
----------------------------- Test 50 ------------------------------
-def
----------------------------- Test 51 ------------------------------
-ghi
-jkl
-
-This is the last line of this file.
----------------------------- Test 52 ------------------------------
-def
-ghi
-jkl
-
-This is the last line of this file.
----------------------------- Test 53 ------------------------------
-ghi
-jkl
-
-This is the last line of this file.
----------------------------- Test 54 ------------------------------
-44:abc
-45:def
-46:ghi
-47:jkl
diff --git a/ext/pcre/pcrelib/testdata/grepoutputN b/ext/pcre/pcrelib/testdata/grepoutputN
new file mode 100644
index 0000000000..170a4321ee
--- /dev/null
+++ b/ext/pcre/pcrelib/testdata/grepoutputN
@@ -0,0 +1,22 @@
+---------------------------- Test N1 ------------------------------
+1:abc
+2:def
+---------------------------- Test N2 ------------------------------
+1:abc
+def
+2:ghi
+jkl---------------------------- Test N3 ------------------------------
+2:def
+3:
+ghi
+jkl---------------------------- Test N4 ------------------------------
+2:ghi
+jkl---------------------------- Test N5 ------------------------------
+1:abc
+2:def
+3:ghi
+4:jkl---------------------------- Test N6 ------------------------------
+1:abc
+2:def
+3:ghi
+4:jkl \ No newline at end of file
diff --git a/ext/pcre/pcrelib/testdata/testinput1 b/ext/pcre/pcrelib/testdata/testinput1
index d8ef12bc42..7e8e9f0c4d 100644
--- a/ext/pcre/pcrelib/testdata/testinput1
+++ b/ext/pcre/pcrelib/testdata/testinput1
@@ -1494,8 +1494,8 @@
/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
abcdefghijk\12S
-/ab\hdef/
- abhdef
+/ab\idef/
+ abidef
/a{0}bc/
bc
@@ -4018,4 +4018,7 @@
abc
abc\n
+/(.*(.)?)*/
+ abcd
+
/ End of testinput1 /
diff --git a/ext/pcre/pcrelib/testdata/testinput10 b/ext/pcre/pcrelib/testdata/testinput10
new file mode 100644
index 0000000000..369af4a3d3
--- /dev/null
+++ b/ext/pcre/pcrelib/testdata/testinput10
@@ -0,0 +1,104 @@
+/-- These are a few representative patterns whose lengths and offsets are to be
+shown when the link size is 2. This is just a doublecheck test to ensure the
+sizes don't go horribly wrong when something is changed. The pattern contents
+are all themselves checked in other tests. --/
+
+/((?i)b)/BM
+
+/(?s)(.*X|^B)/BM
+
+/(?s:.*X|^B)/BM
+
+/^[[:alnum:]]/BM
+
+/#/IxMD
+
+/a#/IxMD
+
+/x?+/BM
+
+/x++/BM
+
+/x{1,3}+/BM
+
+/(x)*+/BM
+
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/BM
+
+|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|BM
+
+|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|BM
+
+/(a(?1)b)/BM
+
+/(a(?1)+b)/BM
+
+/a(?P<name1>b|c)d(?P<longername2>e)/BM
+
+/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/BM
+
+/(?P<a>a)...(?P=a)bbb(?P>a)d/BM
+
+/abc(?C255)de(?C)f/BM
+
+/abcde/CBM
+
+/\x{100}/8BM
+
+/\x{1000}/8BM
+
+/\x{10000}/8BM
+
+/\x{100000}/8BM
+
+/\x{1000000}/8BM
+
+/\x{4000000}/8BM
+
+/\x{7fffFFFF}/8BM
+
+/[\x{ff}]/8BM
+
+/[\x{100}]/8BM
+
+/\x80/8BM
+
+/\xff/8BM
+
+/\x{0041}\x{2262}\x{0391}\x{002e}/D8M
+
+/\x{D55c}\x{ad6d}\x{C5B4}/D8M
+
+/\x{65e5}\x{672c}\x{8a9e}/D8M
+
+/[\x{100}]/8BM
+
+/[Z\x{100}]/8BM
+
+/^[\x{100}\E-\Q\E\x{150}]/B8M
+
+/^[\QĀ\E-\QŐ\E]/B8M
+
+/^[\QĀ\E-\QŐ\E/B8M
+
+/[\p{L}]/BM
+
+/[\p{^L}]/BM
+
+/[\P{L}]/BM
+
+/[\P{^L}]/BM
+
+/[abc\p{L}\x{0660}]/8BM
+
+/[\p{Nd}]/8BM
+
+/[\p{Nd}+-]+/8BM
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iBM
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8BM
+
+/[\x{105}-\x{109}]/8iBM
+
+/ End of testinput10 /
diff --git a/ext/pcre/pcrelib/testdata/testinput2 b/ext/pcre/pcrelib/testdata/testinput2
index bb21f4819b..2ce7ad0321 100644
--- a/ext/pcre/pcrelib/testdata/testinput2
+++ b/ext/pcre/pcrelib/testdata/testinput2
@@ -28,9 +28,9 @@
*** Failers
def\nabc
-/ab\hdef/X
+/ab\idef/X
-/(?X)ab\hdef/X
+/(?X)ab\idef/X
/x{5,4}/
@@ -82,7 +82,7 @@
\O3abcb
\O6abcb
\O9abcb
- \O12abcb
+ \O12abcb
/(a)bc|(a)(b)\2/I
abc
@@ -126,7 +126,7 @@
/abc/IP
abc
*** Failers
-
+
/^abc|def/IP
abcdef
abcdef\B
@@ -134,23 +134,23 @@
/.*((abc)$|(def))/IP
defabc
\Zdefabc
-
+
/the quick brown fox/IP
the quick brown fox
- *** Failers
- The Quick Brown Fox
+ *** Failers
+ The Quick Brown Fox
/the quick brown fox/IPi
the quick brown fox
- The Quick Brown Fox
+ The Quick Brown Fox
/abc.def/IP
*** Failers
abc\ndef
-
+
/abc$/IP
abc
- abc\n
+ abc\n
/(abc)\2/IP
@@ -162,8 +162,8 @@
/a[]b/
/[^aeiou ]{3,}/I
- co-processors, and for
-
+ co-processors, and for
+
/<.*>/I
abc<def>ghi<klm>nop
@@ -172,25 +172,25 @@
/<.*>/IU
abc<def>ghi<klm>nop
-
+
/(?U)<.*>/I
abc<def>ghi<klm>nop
/<.*?>/IU
abc<def>ghi<klm>nop
-
+
/={3,}/IU
abc========def
-
+
/(?U)={3,}?/I
abc========def
-
+
/(?<!bar|cattle)foo/I
foo
- catfoo
+ catfoo
*** Failers
the barfoo
- and cattlefoo
+ and cattlefoo
/(?<=a+)b/
@@ -236,27 +236,27 @@
/((?i)blah)\s+\1/I
-/((?i)b)/IDS
+/((?i)b)/IDZS
/(a*b|(?i:c*(?-i)d))/IS
/a$/I
a
a\n
- *** Failers
+ *** Failers
\Za
- \Za\n
+ \Za\n
/a$/Im
a
a\n
- \Za\n
- *** Failers
+ \Za\n
+ *** Failers
\Za
-
+
/\Aabc/Im
-/^abc/Im
+/^abc/Im
/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/I
aaaaabbbbbcccccdef
@@ -268,24 +268,24 @@
/(?!alphabet)[ab]/IS
/(?<=foo\n)^bar/Im
- foo\nbarbar
+ foo\nbarbar
***Failers
- rhubarb
+ rhubarb
barbell
- abc\nbarton
+ abc\nbarton
/^(?<=foo\n)bar/Im
- foo\nbarbar
+ foo\nbarbar
***Failers
- rhubarb
+ rhubarb
barbell
- abc\nbarton
+ abc\nbarton
/(?>^abc)/Im
abc
def\nabc
*** Failers
- defabc
+ defabc
/(?<=ab(c+)d)ef/
@@ -300,8 +300,8 @@
a donkey-cart race
*** Failers
cart
- horse-and-cart
-
+ horse-and-cart
+
/(?<=ab(?i)x|y|z)/I
/(?>.*)(?<=(abcd)|(xyz))/I
@@ -314,30 +314,30 @@
ZZZ
zZZ
bZZ
- BZZ
+ BZZ
*** Failers
- ZZ
- abXYZZ
+ ZZ
+ abXYZZ
zzz
- bzz
+ bzz
/(?<!(foo)a)bar/I
bar
- foobbar
+ foobbar
*** Failers
- fooabar
+ fooabar
/This one is here because Perl 5.005_02 doesn't fail it/I
/^(a)?(?(1)a|b)+$/I
*** Failers
- a
+ a
/This one is here because I think Perl 5.005_02 gets the setting of $1 wrong/I
/^(a\1?){4}$/I
aaaaaa
-
+
/These are syntax tests from Perl 5.005/I
/a[b-a]/
@@ -416,12 +416,12 @@
abcd
abcd\C2
abcd\C5
-
+
/(.{20})/I
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz\C1
abcdefghijklmnopqrstuvwxyz\G1
-
+
/(.{15})/I
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz\C1\G1
@@ -429,30 +429,30 @@
/(.{16})/I
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz\C1\G1\L
-
+
/^(a|(bc))de(f)/I
- adef\G1\G2\G3\G4\L
- bcdef\G1\G2\G3\G4\L
- adefghijk\C0
-
+ adef\G1\G2\G3\G4\L
+ bcdef\G1\G2\G3\G4\L
+ adefghijk\C0
+
/^abc\00def/I
- abc\00def\L\C0
-
-/word ((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
-)((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
-)?)?)?)?)?)?)?)?)?otherword/IM
+ abc\00def\L\C0
-/.*X/ID
+/word ((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
+)((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
+)?)?)?)?)?)?)?)?)?otherword/I
-/.*X/IDs
+/.*X/IDZ
-/(.*X|^B)/ID
+/.*X/IDZs
-/(.*X|^B)/IDs
-
-/(?s)(.*X|^B)/ID
+/(.*X|^B)/IDZ
+
+/(.*X|^B)/IDZs
-/(?s:.*X|^B)/ID
+/(?s)(.*X|^B)/IDZ
+
+/(?s:.*X|^B)/IDZ
/\Biss\B/I+
Mississippi
@@ -479,15 +479,15 @@
/^iss/Ig+
ississippi
-
+
/.*iss/Ig+
- abciss\nxyzisspqr
+ abciss\nxyzisspqr
/.i./I+g
Mississippi
Mississippi\A
Missouri river
- Missouri river\A
+ Missouri river\A
/^.is/I+g
Mississippi
@@ -586,14 +586,14 @@
ab
\
*** Failers
- \N
-
+ \N
+
/|-/I
abcd
-abc
\Nab-c
*** Failers
- \Nabc
+ \Nabc
/a*(b+)(z)(z)/IP
aaaabbbbzzzz
@@ -603,8 +603,8 @@
aaaabbbbzzzz\O3
aaaabbbbzzzz\O4
aaaabbbbzzzz\O5
-
-/^.?abcd/IS
+
+/^.?abcd/IS
/\( # ( at start
(?: # Non-capturing bracket
@@ -617,26 +617,26 @@
(abcd)
(abcd)xyz
xyz(abcd)
- (ab(xy)cd)pqr
- (ab(xycd)pqr
- () abc ()
+ (ab(xy)cd)pqr
+ (ab(xycd)pqr
+ () abc ()
12(abcde(fsh)xyz(foo(bar))lmno)89
*** Failers
- abcd
+ abcd
abcd)
- (abcd
+ (abcd
/\( ( (?>[^()]+) | (?R) )* \) /Ixg
- (ab(xy)cd)pqr
+ (ab(xy)cd)pqr
1(abcd)(x(y)z)pqr
/\( (?: (?>[^()]+) | (?R) ) \) /Ix
(abcd)
(ab(xy)cd)
- (a(b(c)d)e)
- ((ab))
+ (a(b(c)d)e)
+ ((ab))
*** Failers
- ()
+ ()
/\( (?: (?>[^()]+) | (?R) )? \) /Ix
()
@@ -666,53 +666,53 @@
(ab(cd)ef)
(ab(cd(ef)gh)ij)
-/^[[:alnum:]]/D
+/^[[:alnum:]]/DZ
+
+/^[[:^alnum:]]/DZ
-/^[[:^alnum:]]/D
+/^[[:alpha:]]/DZ
-/^[[:alpha:]]/D
+/^[[:^alpha:]]/DZ
-/^[[:^alpha:]]/D
-
/[_[:alpha:]]/IS
-/^[[:ascii:]]/D
+/^[[:ascii:]]/DZ
-/^[[:^ascii:]]/D
+/^[[:^ascii:]]/DZ
-/^[[:blank:]]/D
+/^[[:blank:]]/DZ
-/^[[:^blank:]]/D
+/^[[:^blank:]]/DZ
/[\n\x0b\x0c\x0d[:blank:]]/IS
-/^[[:cntrl:]]/D
+/^[[:cntrl:]]/DZ
-/^[[:digit:]]/D
+/^[[:digit:]]/DZ
-/^[[:graph:]]/D
+/^[[:graph:]]/DZ
-/^[[:lower:]]/D
+/^[[:lower:]]/DZ
-/^[[:print:]]/D
+/^[[:print:]]/DZ
-/^[[:punct:]]/D
+/^[[:punct:]]/DZ
-/^[[:space:]]/D
+/^[[:space:]]/DZ
-/^[[:upper:]]/D
+/^[[:upper:]]/DZ
-/^[[:xdigit:]]/D
+/^[[:xdigit:]]/DZ
-/^[[:word:]]/D
+/^[[:word:]]/DZ
-/^[[:^cntrl:]]/D
+/^[[:^cntrl:]]/DZ
-/^[12[:^digit:]]/D
+/^[12[:^digit:]]/DZ
-/^[[:^blank:]]/D
+/^[[:^blank:]]/DZ
-/[01[:alpha:]%]/D
+/[01[:alpha:]%]/DZ
/[[.ch.]]/I
@@ -722,18 +722,18 @@
/[[:upper:]]/Ii
A
- a
-
+ a
+
/[[:lower:]]/Ii
A
- a
+ a
/((?-i)[[:lower:]])[[:lower:]]/Ii
ab
aB
*** Failers
Ab
- AB
+ AB
/[\200-\110]/I
@@ -749,120 +749,120 @@
/(main(O)?)+/I
mainmain
mainOmain
-
+
/These are all cases where Perl does it differently (nested captures)/I
/^(a(b)?)+$/I
aba
-
+
/^(aa(bb)?)+$/I
- aabbaa
-
+ aabbaa
+
/^(aa|aa(bb))+$/I
- aabbaa
-
+ aabbaa
+
/^(aa(bb)??)+$/I
- aabbaa
-
+ aabbaa
+
/^(?:aa(bb)?)+$/I
- aabbaa
-
+ aabbaa
+
/^(aa(b(b))?)+$/I
- aabbaa
+ aabbaa
/^(?:aa(b(b))?)+$/I
- aabbaa
+ aabbaa
/^(?:aa(b(?:b))?)+$/I
- aabbaa
+ aabbaa
/^(?:aa(bb(?:b))?)+$/I
- aabbbaa
-
+ aabbbaa
+
/^(?:aa(b(?:bb))?)+$/I
- aabbbaa
+ aabbbaa
/^(?:aa(?:b(b))?)+$/I
- aabbaa
+ aabbaa
/^(?:aa(?:b(bb))?)+$/I
- aabbbaa
+ aabbbaa
/^(aa(b(bb))?)+$/I
- aabbbaa
+ aabbbaa
/^(aa(bb(bb))?)+$/I
- aabbbbaa
+ aabbbbaa
-/--------------------------------------------------------------------/I
-
-/#/IxMD
+/--------------------------------------------------------------------/I
-/a#/IxMD
+/#/IxDZ
-/[\s]/D
+/a#/IxDZ
-/[\S]/D
+/[\s]/DZ
-/a(?i)b/D
+/[\S]/DZ
+
+/a(?i)b/DZ
ab
aB
- *** Failers
- AB
+ *** Failers
+ AB
-/(a(?i)b)/D
+/(a(?i)b)/DZ
ab
aB
- *** Failers
- AB
-
-/ (?i)abc/IxD
+ *** Failers
+ AB
+
+/ (?i)abc/IxDZ
/#this is a comment
- (?i)abc/IxD
+ (?i)abc/IxDZ
-/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/D
+/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/DZ
-/\Q123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/D
+/\Q123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/DZ
-/\Q\E/D
+/\Q\E/DZ
\
-/\Q\Ex/D
+/\Q\Ex/DZ
-/ \Q\E/D
+/ \Q\E/DZ
-/a\Q\E/D
+/a\Q\E/DZ
abc
bca
- bac
+ bac
-/a\Q\Eb/D
+/a\Q\Eb/DZ
abc
-/\Q\Eabc/D
+/\Q\Eabc/DZ
-/x*+\w/D
+/x*+\w/DZ
*** Failers
xxxxx
-
-/x?+/D
-/x++/D
+/x?+/DZ
+
+/x++/DZ
-/x{1,3}+/D
+/x{1,3}+/DZ
-/(x)*+/D
+/(x)*+/DZ
/^(\w++|\s++)*$/I
now is the time for all good men to come to the aid of the party
*** Failers
this is not a line with only words and spaces!
-
+
/(\d++)(\w)/I
12345a
*** Failers
- 12345+
+ 12345+
/a++b/I
aaab
@@ -875,14 +875,14 @@
/([^()]++|\([^()]*\))+/I
((abc(ade)ufh()()x
-
-/\(([^()]++|\([^()]+\))+\)/I
+
+/\(([^()]++|\([^()]+\))+\)/I
(abc)
(abc(def)xyz)
*** Failers
- ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-/(abc){1,3}+/D
+/(abc){1,3}+/DZ
/a+?+/I
@@ -892,17 +892,17 @@
/a{2,3}?+b/IU
-/x(?U)a++b/D
+/x(?U)a++b/DZ
xaaaab
-/(?U)xa++b/D
+/(?U)xa++b/DZ
xaaaab
-/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/D
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/DZ
-/^x(?U)a+b/D
+/^x(?U)a+b/DZ
-/^x(?U)(a+)b/D
+/^x(?U)(a+)b/DZ
/[.x.]/I
@@ -926,30 +926,30 @@
/[[:space:]/I
-/[\s]/IDM
+/[\s]/IDZ
-/[[:space:]]/IDM
+/[[:space:]]/IDZ
-/[[:space:]abcde]/IDM
+/[[:space:]abcde]/IDZ
/< (?: (?(R) \d++ | [^<>]*+) | (?R)) * >/Ix
<>
<abcd>
<abc <123> hij>
<abc <def> hij>
- <abc<>def>
- <abc<>
+ <abc<>def>
+ <abc<>
*** Failers
<abc
-|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDM
+|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDZ
-|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDM
+|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDZ
/(.*)\d+\1/I
/(.*)\d+/I
-
+
/(.*)\d+\1/Is
/(.*)\d+/Is
@@ -958,7 +958,7 @@
/((.*))\d+\1/I
abc123bc
-
+
/a[b]/I
/(?=a).*/I
@@ -1007,9 +1007,9 @@
/^a/Im
abcde
- xy\nabc
- *** Failers
- xyabc
+ xy\nabc
+ *** Failers
+ xyabc
/c|abc/I
@@ -1019,24 +1019,24 @@
/abc(?C)def/I
abcdef
- 1234abcdef
+ 1234abcdef
*** Failers
abcxyz
- abcxyzf
+ abcxyzf
/abc(?C)de(?C1)f/I
123abcdef
-
-/(?C1)\dabc(?C2)def/I
+
+/(?C1)\dabc(?C2)def/I
1234abcdef
*** Failers
- abcdef
-
+ abcdef
+
/(?C255)ab/I
/(?C256)ab/I
-/(?Cab)xx/I
+/(?Cab)xx/I
/(?C12vr)x/I
@@ -1046,21 +1046,21 @@
/(abc)(?C)de(?C1)f/I
123abcdef
- 123abcdef\C+
- 123abcdef\C-
+ 123abcdef\C+
+ 123abcdef\C-
*** Failers
- 123abcdef\C!1
-
+ 123abcdef\C!1
+
/(?C0)(abc(?C1))*/I
abcabcabc
- abcabc\C!1!3
+ abcabc\C!1!3
*** Failers
- abcabcabc\C!1!3
+ abcabcabc\C!1!3
/(\d{3}(?C))*/I
123\C+
123456\C+
- 123456789\C+
+ 123456789\C+
/((xyz)(?C)p|(?C1)xyzabc)/I
xyzabc\C+
@@ -1070,20 +1070,20 @@
/(?=(abc))(?C)abcdef/I
abcdef\C+
-
+
/(?!(abc)(?C1)d)(?C2)abcxyz/I
- abcxyz\C+
+ abcxyz\C+
/(?<=(abc)(?C))xyz/I
abcxyz\C+
-
+
/a(b+)(c*)(?C1)/I
abbbbbccc\C*1
/a(b+?)(c*?)(?C1)/I
abbbbbccc\C*1
-
-/(?C)abc/I
+
+/(?C)abc/I
/(?C)^abc/I
@@ -1102,7 +1102,7 @@
xxab
xxxab
*** Failers
- xyab
+ xyab
/(ab|(bc|(de|(?1))))/I
@@ -1111,48 +1111,48 @@
/^([^()]|\((?1)*\))*$/I
abc
a(b)c
- a(b(c))d
+ a(b(c))d
*** Failers)
- a(b(c)d
+ a(b(c)d
/^>abc>([^()]|\((?1)*\))*<xyz<$/I
>abc>123<xyz<
>abc>1(2)3<xyz<
>abc>(1(2)3)<xyz<
-/(a(?1)b)/D
+/(a(?1)b)/DZ
-/(a(?1)+b)/D
+/(a(?1)+b)/DZ
/^\W*(?:((.)\W*(?1)\W*\2|)|((.)\W*(?3)\W*\4|\W*.\W*))\W*$/Ii
1221
Satan, oscillate my metallic sonatas!
A man, a plan, a canal: Panama!
- Able was I ere I saw Elba.
+ Able was I ere I saw Elba.
*** Failers
- The quick brown fox
-
+ The quick brown fox
+
/^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/I
12
(((2+2)*-3)-7)
-12
*** Failers
((2+2)*-3)-7)
-
+
/^(x(y|(?1){2})z)/I
xyz
- xxyzxyzz
+ xxyzxyzz
*** Failers
xxyzz
- xxyzxyzxyzz
+ xxyzxyzxyzz
/((< (?: (?(R) \d++ | [^<>]*+) | (?2)) * >))/Ix
<>
<abcd>
<abc <123> hij>
<abc <def> hij>
- <abc<>def>
- <abc<>
+ <abc<>def>
+ <abc<>
*** Failers
<abc
@@ -1166,32 +1166,32 @@
/^(a|b|c)=(?1)+/I
a=a
a=b
- a=bc
+ a=bc
/^(a|b|c)=((?1))+/I
a=a
a=b
- a=bc
+ a=bc
-/a(?P<name1>b|c)d(?P<longername2>e)/D
+/a(?P<name1>b|c)d(?P<longername2>e)/DZ
abde
- acde
+ acde
-/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/D
+/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/DZ
-/(?P<a>a)...(?P=a)bbb(?P>a)d/D
+/(?P<a>a)...(?P=a)bbb(?P>a)d/DZ
/^\W*(?:(?P<one>(?P<two>.)\W*(?P>one)\W*(?P=two)|)|(?P<three>(?P<four>.)\W*(?P>three)\W*(?P=four)|\W*.\W*))\W*$/Ii
1221
Satan, oscillate my metallic sonatas!
A man, a plan, a canal: Panama!
- Able was I ere I saw Elba.
+ Able was I ere I saw Elba.
*** Failers
- The quick brown fox
-
+ The quick brown fox
+
/((?(R)a|b))\1(?1)?/I
bb
- bbaa
+ bbaa
/(.*)a/Is
@@ -1215,13 +1215,13 @@
/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\32/Is
-/(a)(bc)/IND
+/(a)(bc)/INDZ
abc
-/(?P<one>a)(bc)/IND
+/(?P<one>a)(bc)/INDZ
abc
-/(a)(?P<named>bc)/IND
+/(a)(?P<named>bc)/INDZ
/(a+)*zz/I
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzbbbbbb\M
@@ -1237,11 +1237,11 @@
abcdefgh
abcdefgh\C1\Gtwo
abcdefgh\Cone\Ctwo
- abcdefgh\Cthree
+ abcdefgh\Cthree
-/(?P<Tes>)(?P<Test>)/D
+/(?P<Tes>)(?P<Test>)/DZ
-/(?P<Test>)(?P<Tes>)/D
+/(?P<Test>)(?P<Tes>)/DZ
/(?P<Z>zz)(?P<A>aa)/I
zzaa\CZ
@@ -1254,47 +1254,47 @@
"\[((?P<elem>\d+)(,(?P>elem))*)\]"I
[10,20,30,5,5,4,4,2,43,23,4234]
*** Failers
- []
+ []
"\[((?P<elem>\d+)(,(?P>elem))*)?\]"I
[10,20,30,5,5,4,4,2,43,23,4234]
- []
+ []
-/(a(b(?2)c))?/D
+/(a(b(?2)c))?/DZ
-/(a(b(?2)c))*/D
+/(a(b(?2)c))*/DZ
-/(a(b(?2)c)){0,2}/D
+/(a(b(?2)c)){0,2}/DZ
-/[ab]{1}+/D
+/[ab]{1}+/DZ
/((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)/Ii
Baby Bjorn Active Carrier - With free SHIPPING!!
/((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)/IiS
Baby Bjorn Active Carrier - With free SHIPPING!!
-
-/a*.*b/ISD
-/(a|b)*.?c/ISD
+/a*.*b/ISDZ
-/abc(?C255)de(?C)f/D
+/(a|b)*.?c/ISDZ
-/abcde/ICD
+/abc(?C255)de(?C)f/DZ
+
+/abcde/ICDZ
abcde
- abcdfe
-
-/a*b/ICD
+ abcdfe
+
+/a*b/ICDZ
ab
aaaab
- aaaacb
+ aaaacb
-/a+b/ICD
+/a+b/ICDZ
ab
aaaab
- aaaacb
+ aaaacb
-/(abc|def)x/ICD
+/(abc|def)x/ICDZ
abcx
defx
abcdefzx
@@ -1302,43 +1302,43 @@
/(ab|cd){3,4}/IC
ababab
abcdabcd
- abcdcdcdcdcd
+ abcdcdcdcdcd
-/([ab]{,4}c|xy)/ICD
+/([ab]{,4}c|xy)/ICDZ
Note: that { does NOT introduce a quantifier
-/([ab]{1,4}c|xy){4,5}?123/ICD
+/([ab]{1,4}c|xy){4,5}?123/ICDZ
aacaacaacaacaac123
/\b.*/I
ab cd\>1
-
-/\b.*/Is
+
+/\b.*/Is
ab cd\>1
-
+
/(?!.bcd).*/I
- Xbcd12345
+ Xbcd12345
/abcde/I
ab\P
abc\P
abcd\P
- abcde\P
+ abcde\P
the quick brown abc\P
** Failers\P
the quick brown abxyz fox\P
-
+
"^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/(20)?\d\d$"I
13/05/04\P
13/5/2004\P
- 02/05/09\P
+ 02/05/09\P
1\P
1/2\P
1/2/0\P
- 1/2/04\P
+ 1/2/04\P
0\P
02/\P
- 02/0\P
+ 02/0\P
02/1\P
** Failers\P
\P
@@ -1346,14 +1346,14 @@
33/4/04\P
3/13/04\P
0/1/2003\P
- 0/\P
- 02/0/\P
- 02/13\P
+ 0/\P
+ 02/0/\P
+ 02/13\P
/0{0,2}ABC/I
-
+
/\d{3,}ABC/I
-
+
/\d*ABC/I
/[abc]+DE/I
@@ -1364,7 +1364,7 @@
b\P
c\P
c12\P
- c123\P
+ c123\P
/^(?:\d){3,5}X/I
1\P
@@ -1373,17 +1373,17 @@
1234\P
1234X
12345\P
- 12345X
- *** Failers
- 1X
- 123456\P
+ 12345X
+ *** Failers
+ 1X
+ 123456\P
/abc/I>testsavedregex
<testsavedregex
abc
** Failers
bca
-
+
/abc/IF>testsavedregex
<testsavedregex
abc
@@ -1394,14 +1394,14 @@
<testsavedregex
abc
** Failers
- def
-
+ def
+
/(a|b)/ISF>testsavedregex
<testsavedregex
abc
** Failers
- def
-
+ def
+
~<(\w+)/?>(.)*</(\1)>~smgI
<!DOCTYPE seite SYSTEM "http://www.lco.lineas.de/xmlCms.dtd">\n<seite>\n<dokumenteninformation>\n<seitentitel>Partner der LCO</seitentitel>\n<sprache>de</sprache>\n<seitenbeschreibung>Partner der LINEAS Consulting\nGmbH</seitenbeschreibung>\n<schluesselworte>LINEAS Consulting GmbH Hamburg\nPartnerfirmen</schluesselworte>\n<revisit>30 days</revisit>\n<robots>index,follow</robots>\n<menueinformation>\n<aktiv>ja</aktiv>\n<menueposition>3</menueposition>\n<menuetext>Partner</menuetext>\n</menueinformation>\n<lastedited>\n<autor>LCO</autor>\n<firma>LINEAS Consulting</firma>\n<datum>15.10.2003</datum>\n</lastedited>\n</dokumenteninformation>\n<inhalt>\n\n<absatzueberschrift>Die Partnerfirmen der LINEAS Consulting\nGmbH</absatzueberschrift>\n\n<absatz><link ziel="http://www.ca.com/" zielfenster="_blank">\n<bild name="logo_ca.gif" rahmen="no"/></link> <link\nziel="http://www.ey.com/" zielfenster="_blank"><bild\nname="logo_euy.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><link ziel="http://www.cisco.de/" zielfenster="_blank">\n<bild name="logo_cisco.gif" rahmen="ja"/></link></absatz>\n\n<absatz><link ziel="http://www.atelion.de/"\nzielfenster="_blank"><bild\nname="logo_atelion.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><link ziel="http://www.line-information.de/"\nzielfenster="_blank">\n<bild name="logo_line_information.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><bild name="logo_aw.gif" rahmen="no"/></absatz>\n\n<absatz><link ziel="http://www.incognis.de/"\nzielfenster="_blank"><bild\nname="logo_incognis.gif" rahmen="no"/></link></absatz>\n\n<absatz><link ziel="http://www.addcraft.com/"\nzielfenster="_blank"><bild\nname="logo_addcraft.gif" rahmen="no"/></link></absatz>\n\n<absatz><link ziel="http://www.comendo.com/"\nzielfenster="_blank"><bild\nname="logo_comendo.gif" rahmen="no"/></link></absatz>\n\n</inhalt>\n</seite>
@@ -1409,34 +1409,34 @@
/line\nbreak/I
this is a line\nbreak
- line one\nthis is a line\nbreak in the second line
+ line one\nthis is a line\nbreak in the second line
/line\nbreak/If
this is a line\nbreak
- ** Failers
- line one\nthis is a line\nbreak in the second line
+ ** Failers
+ line one\nthis is a line\nbreak in the second line
/line\nbreak/Imf
this is a line\nbreak
- ** Failers
- line one\nthis is a line\nbreak in the second line
+ ** Failers
+ line one\nthis is a line\nbreak in the second line
/ab.cd/IP
ab-cd
- ab=cd
+ ab=cd
** Failers
ab\ncd
/ab.cd/IPs
ab-cd
- ab=cd
+ ab=cd
ab\ncd
/(?i)(?-i)AbCd/I
AbCd
** Failers
- abcd
-
+ abcd
+
/a{11111111111111111111}/I
/(){64294967295}/I
@@ -1460,35 +1460,35 @@
/[^()]*(?:\((?R)\)[^()]*)*/I
(this(and)that
- (this(and)that)
+ (this(and)that)
(this(and)that)stuff
/[^()]*(?:\((?>(?R))\)[^()]*)*/I
(this(and)that
- (this(and)that)
-
+ (this(and)that)
+
/[^()]*(?:\((?R)\))*[^()]*/I
(this(and)that
- (this(and)that)
+ (this(and)that)
/(?:\((?R)\))*[^()]*/I
(this(and)that
- (this(and)that)
- ((this))
+ (this(and)that)
+ ((this))
/(?:\((?R)\))|[^()]*/I
(this(and)that
- (this(and)that)
+ (this(and)that)
(this)
- ((this))
-
+ ((this))
+
/a(b)c/IPN
abc
-
+
/a(?P<name>b)c/IPN
- abc
-
-/\x{100}/I
+ abc
+
+/\x{100}/I
/\x{0000ff}/I
@@ -1496,44 +1496,44 @@
/^((?P<A>a1)|(?P<A>a2)b)/IJ
a1b\CA
- a2b\CA
+ a2b\CA
** Failers
- a1b\CZ\CA
-
+ a1b\CZ\CA
+
/^(?P<A>a)(?P<A>b)/IJ
ab\CA
-
+
/^(?P<A>a)(?P<A>b)|cd/IJ
ab\CA
- cd\CA
-
+ cd\CA
+
/^(?P<A>a)(?P<A>b)|cd(?P<A>ef)(?P<A>gh)/IJ
- cdefgh\CA
-
+ cdefgh\CA
+
/^((?P<A>a1)|(?P<A>a2)b)/IJ
a1b\GA
- a2b\GA
+ a2b\GA
** Failers
- a1b\GZ\GA
-
+ a1b\GZ\GA
+
/^(?P<A>a)(?P<A>b)/IJ
ab\GA
-
+
/^(?P<A>a)(?P<A>b)|cd/IJ
ab\GA
- cd\GA
-
+ cd\GA
+
/^(?P<A>a)(?P<A>b)|cd(?P<A>ef)(?P<A>gh)/IJ
- cdefgh\GA
-
+ cdefgh\GA
+
/(?J)^((?P<A>a1)|(?P<A>a2)b)/I
a1b\CA
- a2b\CA
-
+ a2b\CA
+
/^(?P<A>a) (?J:(?P<B>b)(?P<B>c)) (?P<A>d)/I
/ In this next test, J is not set at the outer level; consequently it isn't
-set in the pattern's options; consequently pcre_get_named_substring() produces
+set in the pattern's options; consequently pcre_get_named_substring() produces
a random value. /Ix
/^(?P<A>a) (?J:(?P<B>b)(?P<B>c)) (?P<C>d)/I
@@ -1543,7 +1543,7 @@ a random value. /Ix
aabc
bc
** Failers
- abc
+ abc
/(?:(?(ZZ)a|b)(?P<ZZ>X))+/I
bXaX
@@ -1562,7 +1562,7 @@ a random value. /Ix
/(?:(?(A)(?P=A)a|b)(?P<A>X|Y))+/I
bXXaYYaY
- bXYaXXaX
+ bXYaXXaX
/()()()()()()()()()(?:(?(A)(?P=A)a|b)(?P<A>X|Y))+/I
bXXaYYaY
@@ -1571,7 +1571,7 @@ a random value. /Ix
/\s*,\s*/IS
\x0b,\x0b
- \x0c,\x0d
+ \x0c,\x0d
/^abc/Im
xyz\nabc
@@ -1579,51 +1579,51 @@ a random value. /Ix
xyz\r\nabc\<lf>
xyz\rabc\<cr>
xyz\r\nabc\<crlf>
- ** Failers
+ ** Failers
xyz\nabc\<cr>
xyz\r\nabc\<cr>
xyz\nabc\<crlf>
xyz\rabc\<crlf>
xyz\rabc\<lf>
-
+
/abc$/Im<lf>
xyzabc
- xyzabc\n
- xyzabc\npqr
- xyzabc\r\<cr>
- xyzabc\rpqr\<cr>
- xyzabc\r\n\<crlf>
- xyzabc\r\npqr\<crlf>
+ xyzabc\n
+ xyzabc\npqr
+ xyzabc\r\<cr>
+ xyzabc\rpqr\<cr>
+ xyzabc\r\n\<crlf>
+ xyzabc\r\npqr\<crlf>
** Failers
- xyzabc\r
- xyzabc\rpqr
- xyzabc\r\n
- xyzabc\r\npqr
-
+ xyzabc\r
+ xyzabc\rpqr
+ xyzabc\r\n
+ xyzabc\r\npqr
+
/^abc/Im<cr>
xyz\rabcdef
xyz\nabcdef\<lf>
- ** Failers
+ ** Failers
xyz\nabcdef
-
+
/^abc/Im<lf>
xyz\nabcdef
xyz\rabcdef\<cr>
- ** Failers
+ ** Failers
xyz\rabcdef
-
+
/^abc/Im<crlf>
xyz\r\nabcdef
xyz\rabcdef\<cr>
- ** Failers
+ ** Failers
xyz\rabcdef
-
+
/^abc/Im<bad>
/abc/I
xyz\rabc\<bad>
- abc
-
+ abc
+
/.*/I<lf>
abc\ndef
abc\rdef
@@ -1651,7 +1651,7 @@ a random value. /Ix
()()()()()()()()()()()()()()()()()()()()
()()()()()()()()()()()()()()()()()()()()
(.(.))/Ix
- XY\O400
+ XY\O400
/(a*b|(?i:c*(?-i)d))/IS
@@ -1667,18 +1667,18 @@ a random value. /Ix
/(d?|c)[ab]xyz/IS
-/^a*b\d/D
+/^a*b\d/DZ
-/^a*+b\d/D
+/^a*+b\d/DZ
-/^a*?b\d/D
+/^a*?b\d/DZ
-/^a+A\d/D
+/^a+A\d/DZ
aaaA5
** Failers
- aaaa5
+ aaaa5
-/^a*A\d/IiD
+/^a*A\d/IiDZ
aaaA5
aaaa5
@@ -1696,141 +1696,141 @@ a random value. /Ix
a
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
- )))
-/Ix
+ )))
+/Ix
large nest
-/a*\d/B
+/a*\d/BZ
-/a*\D/B
+/a*\D/BZ
-/0*\d/B
+/0*\d/BZ
-/0*\D/B
+/0*\D/BZ
-/a*\s/B
+/a*\s/BZ
-/a*\S/B
+/a*\S/BZ
-/ *\s/B
+/ *\s/BZ
-/ *\S/B
+/ *\S/BZ
-/a*\w/B
+/a*\w/BZ
-/a*\W/B
+/a*\W/BZ
-/=*\w/B
+/=*\w/BZ
-/=*\W/B
+/=*\W/BZ
-/\d*a/B
+/\d*a/BZ
-/\d*2/B
+/\d*2/BZ
-/\d*\d/B
+/\d*\d/BZ
-/\d*\D/B
+/\d*\D/BZ
-/\d*\s/B
+/\d*\s/BZ
-/\d*\S/B
+/\d*\S/BZ
-/\d*\w/B
+/\d*\w/BZ
-/\d*\W/B
+/\d*\W/BZ
-/\D*a/B
+/\D*a/BZ
-/\D*2/B
+/\D*2/BZ
-/\D*\d/B
+/\D*\d/BZ
-/\D*\D/B
+/\D*\D/BZ
-/\D*\s/B
+/\D*\s/BZ
-/\D*\S/B
+/\D*\S/BZ
-/\D*\w/B
+/\D*\w/BZ
-/\D*\W/B
+/\D*\W/BZ
-/\s*a/B
+/\s*a/BZ
-/\s*2/B
+/\s*2/BZ
-/\s*\d/B
+/\s*\d/BZ
-/\s*\D/B
+/\s*\D/BZ
-/\s*\s/B
+/\s*\s/BZ
-/\s*\S/B
+/\s*\S/BZ
-/\s*\w/B
+/\s*\w/BZ
-/\s*\W/B
+/\s*\W/BZ
-/\S*a/B
+/\S*a/BZ
-/\S*2/B
+/\S*2/BZ
-/\S*\d/B
+/\S*\d/BZ
-/\S*\D/B
+/\S*\D/BZ
-/\S*\s/B
+/\S*\s/BZ
-/\S*\S/B
+/\S*\S/BZ
-/\S*\w/B
+/\S*\w/BZ
-/\S*\W/B
+/\S*\W/BZ
-/\w*a/B
+/\w*a/BZ
-/\w*2/B
+/\w*2/BZ
-/\w*\d/B
+/\w*\d/BZ
-/\w*\D/B
+/\w*\D/BZ
-/\w*\s/B
+/\w*\s/BZ
-/\w*\S/B
+/\w*\S/BZ
-/\w*\w/B
+/\w*\w/BZ
-/\w*\W/B
+/\w*\W/BZ
-/\W*a/B
+/\W*a/BZ
-/\W*2/B
+/\W*2/BZ
-/\W*\d/B
+/\W*\d/BZ
-/\W*\D/B
+/\W*\D/BZ
-/\W*\s/B
+/\W*\s/BZ
-/\W*\S/B
+/\W*\S/BZ
-/\W*\w/B
+/\W*\w/BZ
-/\W*\W/B
+/\W*\W/BZ
-/[^a]+a/B
+/[^a]+a/BZ
-/[^a]+a/Bi
+/[^a]+a/BZi
-/[^a]+A/Bi
+/[^a]+A/BZi
-/[^a]+b/B
+/[^a]+b/BZ
-/[^a]+\d/B
+/[^a]+\d/BZ
-/a*[^a]/B
+/a*[^a]/BZ
/(?P<abc>x)(?P<xyz>y)/I
xy\Cabc\Cxyz
@@ -1848,8 +1848,8 @@ a random value. /Ix
bXaX
bXbX
** Failers
- aXaX
- aXbX
+ aXaX
+ aXbX
/^(?P>abc)(?<abcd>xxx)/
@@ -1857,60 +1857,60 @@ a random value. /Ix
xx
xy
yy
- yx
+ yx
/^(?P>abc)(?P<abc>x|y)/
xx
xy
yy
- yx
+ yx
/^((?(abc)a|b)(?<abc>x|y))+/
bxay
- bxby
+ bxby
** Failers
- axby
+ axby
/^(((?P=abc)|X)(?<abc>x|y))+/
XxXxxx
XxXyyx
XxXyxx
** Failers
- x
+ x
/^(?1)(abc)/
abcabc
/^(?:(?:\1|X)(a|b))+/
Xaaa
- Xaba
+ Xaba
-/^[\E\Qa\E-\Qz\E]+/B
-
-/^[a\Q]bc\E]/B
-
-/^[a-\Q\E]/B
+/^[\E\Qa\E-\Qz\E]+/BZ
+
+/^[a\Q]bc\E]/BZ
-/^(?P>abc)[()](?<abc>)/B
+/^[a-\Q\E]/BZ
-/^((?(abc)y)[()](?P<abc>x))+/B
+/^(?P>abc)[()](?<abc>)/BZ
+
+/^((?(abc)y)[()](?P<abc>x))+/BZ
(xy)x
-
-/^(?P>abc)\Q()\E(?<abc>)/B
-/^(?P>abc)[a\Q(]\E(](?<abc>)/B
+/^(?P>abc)\Q()\E(?<abc>)/BZ
+
+/^(?P>abc)[a\Q(]\E(](?<abc>)/BZ
/^(?P>abc) # this is (a comment)
- (?<abc>)/Bx
+ (?<abc>)/BZx
/^\W*(?:(?<one>(?<two>.)\W*(?&one)\W*\k<two>|)|(?<three>(?<four>.)\W*(?&three)\W*\k'four'|\W*.\W*))\W*$/Ii
1221
Satan, oscillate my metallic sonatas!
A man, a plan, a canal: Panama!
- Able was I ere I saw Elba.
+ Able was I ere I saw Elba.
*** Failers
- The quick brown fox
-
+ The quick brown fox
+
/(?=(\w+))\1:/I
abcd:
@@ -1921,28 +1921,28 @@ a random value. /Ix
a:aaxyz
ab:ababxyz
** Failers
- a:axyz
- ab:abxyz
+ a:axyz
+ ab:abxyz
/(?'abc'a|b)(?<abc>d|e)\k<abc>{2}/J
adaa
** Failers
addd
- adbb
+ adbb
/(?'abc'a|b)(?<abc>d|e)(?&abc){2}/J
bdaa
bdab
** Failers
- bddd
+ bddd
/^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
abd
- ce
-
+ ce
+
/(?(<bc))/
-/(?(''))/
+/(?(''))/
/(?('R')stuff)/
@@ -1959,16 +1959,16 @@ a random value. /Ix
/^(?(DEFINE) (?<A> a) (?<B> b) ) (?&A) (?&B) /x
abcd
-
+
/(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
(?(DEFINE)
(?<NAME_PAT>[a-z]+)
(?<ADDRESS_PAT>\d+)
)/x
metcalfe 33
-
+
/^(?(DEFINE) abc | xyz ) /x
-
+
/(?(DEFINE) abc) xyz/xI
/(?(DEFINE) abc){3} xyz/x
@@ -1979,12 +1979,15 @@ a random value. /Ix
/^a.b/<lf>
a\rb
- a\nb\<cr>
+ a\nb\<cr>
+ a\x85b\<anycrlf>
** Failers
a\nb
a\nb\<any>
- a\rb\<cr>
- a\rb\<any>
+ a\rb\<cr>
+ a\rb\<any>
+ a\x85b\<any>
+ a\rb\<anycrlf>
/^abc./mgx<any>
abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x85abc7 \x{2028}abc8 \x{2029}abc9 JUNK
@@ -2002,9 +2005,9 @@ a random value. /Ix
a\r\nb
a\x0bb
a\x0cb
- a\x85b
+ a\x85b
** Failers
- a\n\rb
+ a\n\rb
/^a\R*b/
ab
@@ -2013,9 +2016,9 @@ a random value. /Ix
a\r\nb
a\x0bb
a\x0cb
- a\x85b
- a\n\rb
- a\n\r\x85\x0cb
+ a\x85b
+ a\n\rb
+ a\n\r\x85\x0cb
/^a\R+b/
a\nb
@@ -2023,20 +2026,20 @@ a random value. /Ix
a\r\nb
a\x0bb
a\x0cb
- a\x85b
- a\n\rb
- a\n\r\x85\x0cb
+ a\x85b
+ a\n\rb
+ a\n\r\x85\x0cb
** Failers
- ab
-
+ ab
+
/^a\R{1,3}b/
a\nb
a\n\rb
a\n\r\x85b
- a\r\n\r\nb
- a\r\n\r\n\r\nb
+ a\r\n\r\nb
+ a\r\n\r\n\r\nb
a\n\r\n\rb
- a\n\n\r\nb
+ a\n\n\r\nb
** Failers
a\n\n\n\rb
a\r
@@ -2044,7 +2047,7 @@ a random value. /Ix
/^a[\R]b/
aRb
** Failers
- a\nb
+ a\nb
/(?&abc)X(?<abc>P)/I
abcPXP123
@@ -2058,7 +2061,7 @@ a random value. /Ix
10.0.0.0
** Failers
10.6
- 455.3.4.5
+ 455.3.4.5
/\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
1.2.3.4
@@ -2066,12 +2069,12 @@ a random value. /Ix
10.0.0.0
** Failers
10.6
- 455.3.4.5
-
+ 455.3.4.5
+
/(?:a(?&abc)b)*(?<abc>x)/
123axbaxbaxbx456
123axbaxbaxb456
-
+
/(?:a(?&abc)b){1,5}(?<abc>x)/
123axbaxbaxbx456
@@ -2109,25 +2112,218 @@ a random value. /Ix
/.+foo/
afoo
- ** Failers
- \r\nfoo
- \nfoo
+ ** Failers
+ \r\nfoo
+ \nfoo
/.+foo/<crlf>
afoo
- \nfoo
- ** Failers
- \r\nfoo
+ \nfoo
+ ** Failers
+ \r\nfoo
/.+foo/<any>
afoo
- ** Failers
- \nfoo
- \r\nfoo
+ ** Failers
+ \nfoo
+ \r\nfoo
/.+foo/s
afoo
- \r\nfoo
- \nfoo
+ \r\nfoo
+ \nfoo
+
+/^$/mg<any>
+ abc\r\rxyz
+ abc\n\rxyz
+ ** Failers
+ abc\r\nxyz
+
+/(?m)^$/<any>g+
+ abc\r\n\r\n
+
+/(?m)^$|^\r\n/<any>g+
+ abc\r\n\r\n
+
+/(?m)$/<any>g+
+ abc\r\n\r\n
+
+/abc.$/mgx<anycrlf>
+ abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc7\x{2028} abc8\x{2029} abc9
+
+/^X/m
+ XABC
+ ** Failers
+ XABC\B
+
+/(ab|c)(?-1)/BZ
+ abc
+
+/xy(?+1)(abc)/BZ
+ xyabcabc
+ ** Failers
+ xyabc
+
+/x(?-0)y/
+
+/x(?-1)y/
+
+/x(?+0)y/
+
+/x(?+1)y/
+
+/^(abc)?(?(-1)X|Y)/BZ
+ abcX
+ Y
+ ** Failers
+ abcY
+
+/^((?(+1)X|Y)(abc))+/BZ
+ YabcXabc
+ YabcXabcXabc
+ ** Failers
+ XabcXabc
+
+/(?(-1)a)/BZ
+
+/((?(-1)a))/BZ
+
+/((?(-2)a))/BZ
+
+/^(?(+1)X|Y)/BZ
+ Y
+
+/(foo)\Kbar/
+ foobar
+
+/(foo)(\Kbar|baz)/
+ foobar
+ foobaz
+
+/(foo\Kbar)baz/
+ foobarbaz
+
+/(?<A>tom|bon)-\k{A}/
+ tom-tom
+ bon-bon
+ ** Failers
+ tom-bon
+
+/(?<A>tom|bon)-\g{A}/
+ tom-tom
+ bon-bon
+
+/\g{A/
+
+/(?|(abc)|(xyz))/BZ
+ >abc<
+ >xyz<
+
+/(x)(?|(abc)|(xyz))(x)/BZ
+ xabcx
+ xxyzx
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/BZ
+ xabcpqrx
+ xxyzx
+
+/(?|(abc)|(xyz))\1/
+ abcabc
+ xyzxyz
+ ** Failers
+ abcxyz
+ xyzabc
+
+/(?|(abc)|(xyz))(?1)/
+ abcabc
+ xyzabc
+ ** Failers
+ xyzxyz
+
+/\H\h\V\v/
+ X X\x0a
+ X\x09X\x0b
+ ** Failers
+ \xa0 X\x0a
+
+/\H*\h+\V?\v{3,4}/
+ \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+ \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+ \x09\x20\xa0\x0a\x0b\x0c
+ ** Failers
+ \x09\x20\xa0\x0a\x0b
+
+/\H{3,4}/
+ XY ABCDE
+ XY PQR ST
+
+/.\h{3,4}./
+ XY AB PQRS
+
+/\h*X\h?\H+Y\H?Z/
+ >XNNNYZ
+ > X NYQZ
+ ** Failers
+ >XYZ
+ > X NY Z
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+ >XY\x0aZ\x0aA\x0bNN\x0c
+ >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
+/[\h]/BZ
+ >\x09<
+
+/[\h]+/BZ
+ >\x09\x20\xa0<
+
+/[\v]/BZ
+
+/[\H]/BZ
+
+/[^\h]/BZ
+
+/[\V]/BZ
+
+/[\x0a\V]/BZ
+
+/\H++X/BZ
+ ** Failers
+ XXXX
+
+/\H+\hY/BZ
+ XXXX Y
+
+/\H+ Y/BZ
+
+/\h+A/BZ
+
+/\v*B/BZ
+
+/\V+\x0a/BZ
+
+/A+\h/BZ
+
+/ *\H/BZ
+
+/A*\v/BZ
+
+/\x0b*\V/BZ
+
+/\d+\h/BZ
+
+/\d*\v/BZ
+
+/S+\h\S+\v/BZ
+
+/\w{3,}\h\w+\v/BZ
+
+/\h+\d\h+\w\h+\S\h+\H/BZ
+
+/\v+\d\v+\w\v+\S\v+\V/BZ
+
+/\H+\h\H+\d/BZ
+
+/\V+\v\V+\w/BZ
/ End of testinput2 /
diff --git a/ext/pcre/pcrelib/testdata/testinput3 b/ext/pcre/pcrelib/testdata/testinput3
index e6ac826f77..1376c213b4 100644
--- a/ext/pcre/pcrelib/testdata/testinput3
+++ b/ext/pcre/pcrelib/testdata/testinput3
@@ -86,6 +86,6 @@
>>>\xaa<<<
>>>\xba<<<
-/[[:alpha:]][[:lower:]][[:upper:]]/DLfr_FR
+/[[:alpha:]][[:lower:]][[:upper:]]/DZLfr_FR
/ End of testinput3 /
diff --git a/ext/pcre/pcrelib/testdata/testinput5 b/ext/pcre/pcrelib/testdata/testinput5
index 85d3ce63db..e8e3cf799f 100644
--- a/ext/pcre/pcrelib/testdata/testinput5
+++ b/ext/pcre/pcrelib/testdata/testinput5
@@ -1,20 +1,20 @@
-/\x{100}/8DM
+/\x{100}/8DZ
-/\x{1000}/8DM
+/\x{1000}/8DZ
-/\x{10000}/8DM
+/\x{10000}/8DZ
-/\x{100000}/8DM
+/\x{100000}/8DZ
-/\x{1000000}/8DM
+/\x{1000000}/8DZ
-/\x{4000000}/8DM
+/\x{4000000}/8DZ
-/\x{7fffFFFF}/8DM
+/\x{7fffFFFF}/8DZ
-/[\x{ff}]/8DM
+/[\x{ff}]/8DZ
-/[\x{100}]/8DM
+/[\x{100}]/8DZ
/\x{ffffffff}/8
@@ -23,39 +23,39 @@
/^\x{100}a\x{1234}/8
\x{100}a\x{1234}bcd
-/\x80/8D
+/\x80/8DZ
-/\xff/8D
+/\xff/8DZ
-/\x{0041}\x{2262}\x{0391}\x{002e}/D8
+/\x{0041}\x{2262}\x{0391}\x{002e}/DZ8
\x{0041}\x{2262}\x{0391}\x{002e}
-/\x{D55c}\x{ad6d}\x{C5B4}/D8
+/\x{D55c}\x{ad6d}\x{C5B4}/DZ8
\x{D55c}\x{ad6d}\x{C5B4}
-/\x{65e5}\x{672c}\x{8a9e}/D8
+/\x{65e5}\x{672c}\x{8a9e}/DZ8
\x{65e5}\x{672c}\x{8a9e}
-/\x{80}/D8
+/\x{80}/DZ8
-/\x{084}/D8
+/\x{084}/DZ8
-/\x{104}/D8
+/\x{104}/DZ8
-/\x{861}/D8
+/\x{861}/DZ8
-/\x{212ab}/D8
+/\x{212ab}/DZ8
-/.{3,5}X/D8
+/.{3,5}X/DZ8
\x{212ab}\x{212ab}\x{212ab}\x{861}X
-/.{3,5}?/D8
+/.{3,5}?/DZ8
\x{212ab}\x{212ab}\x{212ab}\x{861}
-/-- These tests are here rather than in testinput4 because Perl 5.6 has --/
-/-- some problems with UTF-8 support, in the area of \x{..} where the --/
-/-- value is < 255. It grumbles about invalid UTF-8 strings. --/
+/-- These tests are here rather than in testinput4 because Perl 5.6 has some
+problems with UTF-8 support, in the area of \x{..} where the value is < 255.
+It grumbles about invalid UTF-8 strings. --/
/^[a\x{c0}]b/8
\x{c0}b
@@ -80,29 +80,29 @@
/(?<=\C)X/8
Should produce an error diagnostic
-/-- This one is here not because it's different to Perl, but because the --/
-/-- way the captured single-byte is displayed. (In Perl it becomes a --/
-/-- character, and you can't tell the difference.) --/
+/-- This one is here not because it's different to Perl, but because the way
+the captured single-byte is displayed. (In Perl it becomes a character, and you
+can't tell the difference.) --/
/X(\C)(.*)/8
X\x{1234}
X\nabc
-/^[ab]/8D
+/^[ab]/8DZ
bar
*** Failers
c
\x{ff}
\x{100}
-/^[^ab]/8D
+/^[^ab]/8DZ
c
\x{ff}
\x{100}
*** Failers
aaa
-/[^ab\xC0-\xF0]/8SD
+/[^ab\xC0-\xF0]/8SDZ
\x{f1}
\x{bf}
\x{100}
@@ -111,16 +111,16 @@
\x{c0}
\x{f0}
-/Ā{3,4}/8SD
+/Ā{3,4}/8SDZ
\x{100}\x{100}\x{100}\x{100\x{100}
-/(\x{100}+|x)/8SD
+/(\x{100}+|x)/8SDZ
-/(\x{100}*a|x)/8SD
+/(\x{100}*a|x)/8SDZ
-/(\x{100}{0,2}a|x)/8SD
+/(\x{100}{0,2}a|x)/8SDZ
-/(\x{100}{1,2}a|x)/8SD
+/(\x{100}{1,2}a|x)/8SDZ
/\x{100}*(\d+|"(?1)")/8
1234
@@ -132,34 +132,34 @@
*** Failers
\x{100}\x{100}abcd
-/\x{100}/8D
+/\x{100}/8DZ
-/\x{100}*/8D
+/\x{100}*/8DZ
-/a\x{100}*/8D
+/a\x{100}*/8DZ
-/ab\x{100}*/8D
+/ab\x{100}*/8DZ
-/a\x{100}\x{101}*/8D
+/a\x{100}\x{101}*/8DZ
-/a\x{100}\x{101}+/8D
+/a\x{100}\x{101}+/8DZ
-/\x{100}*A/8D
+/\x{100}*A/8DZ
A
-/\x{100}*\d(?R)/8D
+/\x{100}*\d(?R)/8DZ
-/[^\x{c4}]/D
+/[^\x{c4}]/DZ
-/[^\x{c4}]/8D
+/[^\x{c4}]/8DZ
-/[\x{100}]/8DM
+/[\x{100}]/8DZ
\x{100}
Z\x{100}
\x{100}Z
*** Failers
-/[Z\x{100}]/8DM
+/[Z\x{100}]/8DZ
Z\x{100}
\x{100}
\x{100}Z
@@ -174,21 +174,21 @@
\x{105}
\x{ff}
-/[z-\x{100}]/8D
+/[z-\x{100}]/8DZ
-/[z\Qa-d]Ā\E]/8D
+/[z\Qa-d]Ā\E]/8DZ
\x{100}
Ā
-/[\xFF]/D
+/[\xFF]/DZ
>\xff<
-/[\xff]/D8
+/[\xff]/DZ8
>\x{ff}<
-/[^\xFF]/D
+/[^\xFF]/DZ
-/[^\xff]/8D
+/[^\xff]/8DZ
/[Ä-Ü]/8
Ö # Matches without Study
@@ -212,7 +212,7 @@
/xxx/8
-/xxx/8?D
+/xxx/8?DZ
/abc/8
]
@@ -239,19 +239,19 @@
\xfc\x84\x80\x80\x80\x80
\xfd\x83\x80\x80\x80\x80
-/\x{100}abc(xyz(?1))/8D
+/\x{100}abc(xyz(?1))/8DZ
-/[^\x{100}]abc(xyz(?1))/8D
+/[^\x{100}]abc(xyz(?1))/8DZ
-/[ab\x{100}]abc(xyz(?1))/8D
+/[ab\x{100}]abc(xyz(?1))/8DZ
-/(\x{100}(b(?2)c))?/D8
+/(\x{100}(b(?2)c))?/DZ8
-/(\x{100}(b(?2)c)){0,2}/D8
+/(\x{100}(b(?2)c)){0,2}/DZ8
-/(\x{100}(b(?1)c))?/D8
+/(\x{100}(b(?1)c))?/DZ8
-/(\x{100}(b(?1)c)){0,2}/D8
+/(\x{100}(b(?1)c)){0,2}/DZ8
/\W/8
A.B
@@ -263,7 +263,7 @@
/a\x{1234}b/P8
a\x{1234}b
-/^\ሴ/8D
+/^\ሴ/8DZ
/\777/I
@@ -271,23 +271,23 @@
\x{1ff}
\777
-/\x{100}*\d/8D
+/\x{100}*\d/8DZ
-/\x{100}*\s/8D
+/\x{100}*\s/8DZ
-/\x{100}*\w/8D
+/\x{100}*\w/8DZ
-/\x{100}*\D/8D
+/\x{100}*\D/8DZ
-/\x{100}*\S/8D
+/\x{100}*\S/8DZ
-/\x{100}*\W/8D
+/\x{100}*\W/8DZ
-/\x{100}+\x{200}/8D
+/\x{100}+\x{200}/8DZ
-/\x{100}+X/8D
+/\x{100}+X/8DZ
-/X+\x{200}/8D
+/X+\x{200}/8DZ
/()()()()()()()()()()
()()()()()()()()()()
@@ -296,11 +296,11 @@
A (x) (?41) B/8x
AxxB
-/^[\x{100}\E-\Q\E\x{150}]/B8
+/^[\x{100}\E-\Q\E\x{150}]/BZ8
-/^[\QĀ\E-\QŐ\E]/B8
+/^[\QĀ\E-\QŐ\E]/BZ8
-/^[\QĀ\E-\QŐ\E/B8
+/^[\QĀ\E-\QŐ\E/BZ8
/^abc./mgx8<any>
abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x{0085}abc7 \x{2028}abc8 \x{2029}abc9 JUNK
@@ -355,4 +355,42 @@
a\n\n\n\rb
a\r
+/\H\h\V\v/8
+ X X\x0a
+ X\x09X\x0b
+ ** Failers
+ \x{a0} X\x0a
+
+/\H*\h+\V?\v{3,4}/8
+ \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+ \x09\x20\x{a0}\x0a\x0b\x0c
+ ** Failers
+ \x09\x20\x{a0}\x0a\x0b
+
+/\H\h\V\v/8
+ \x{3001}\x{3000}\x{2030}\x{2028}
+ X\x{180e}X\x{85}
+ ** Failers
+ \x{2009} X\x0a
+
+/\H*\h+\V?\v{3,4}/8
+ \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+ \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+ \x09\x20\x{202f}\x0a\x0b\x0c
+ ** Failers
+ \x09\x{200a}\x{a0}\x{2028}\x0b
+
+/[\h]/8BZ
+ >\x{1680}
+
+/[\h]{3,}/8BZ
+ >\x{1680}\x{180e}\x{2000}\x{2003}\x{200a}\x{202f}\x{205f}\x{3000}<
+
+/[\v]/8BZ
+
+/[\H]/8BZ
+
+/[\V]/8BZ
+
/ End of testinput5 /
diff --git a/ext/pcre/pcrelib/testdata/testinput6 b/ext/pcre/pcrelib/testdata/testinput6
index 5a541f362a..1028845b0b 100644
--- a/ext/pcre/pcrelib/testdata/testinput6
+++ b/ext/pcre/pcrelib/testdata/testinput6
@@ -323,20 +323,20 @@
** Failers
WXYZ
-/[\p{L}]/D
+/[\p{L}]/DZ
-/[\p{^L}]/D
+/[\p{^L}]/DZ
-/[\P{L}]/D
+/[\P{L}]/DZ
-/[\P{^L}]/D
+/[\P{^L}]/DZ
-/[abc\p{L}\x{0660}]/8D
+/[abc\p{L}\x{0660}]/8DZ
-/[\p{Nd}]/8DM
+/[\p{Nd}]/8DZ
1234
-/[\p{Nd}+-]+/8DM
+/[\p{Nd}+-]+/8DZ
1234
12-34
12+\x{661}-34
@@ -425,13 +425,13 @@
A\x{391}\x{10427}\x{ff5a}\x{1fb0}
A\x{391}\x{10427}\x{ff3a}\x{1fb8}
-/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iD
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iDZ
-/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8D
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8DZ
-/AB\x{1fb0}/8D
+/AB\x{1fb0}/8DZ
-/AB\x{1fb0}/8Di
+/AB\x{1fb0}/8DZi
/\x{391}+/8i
\x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
@@ -452,7 +452,7 @@
\x{c0}
\x{e0}
-/[\x{105}-\x{109}]/8iD
+/[\x{105}-\x{109}]/8iDZ
\x{104}
\x{105}
\x{109}
@@ -460,7 +460,7 @@
\x{100}
\x{10a}
-/[z-\x{100}]/8iD
+/[z-\x{100}]/8iDZ
Z
z
\x{39c}
@@ -475,7 +475,7 @@
Y
y
-/[z-\x{100}]/8Di
+/[z-\x{100}]/8DZi
/^\X/8
A
@@ -762,4 +762,14 @@ of case for anything other than the ASCII letters. /
/^\p{Balinese}\p{Cuneiform}\p{Nko}\p{Phags_Pa}\p{Phoenician}/8
\x{1b00}\x{12000}\x{7c0}\x{a840}\x{10900}
+/The next two are special cases where the lengths of the different cases of the
+same character differ. The first went wrong with heap fram storage; the 2nd
+was broken in all cases./
+
+/^\x{023a}+?(\x{0130}+)/8i
+ \x{023a}\x{2c65}\x{0130}
+
+/^\x{023a}+([^X])/8i
+ \x{023a}\x{2c65}X
+
/ End of testinput6 /
diff --git a/ext/pcre/pcrelib/testdata/testinput7 b/ext/pcre/pcrelib/testdata/testinput7
index 23b35f16d8..2722980ad6 100644
--- a/ext/pcre/pcrelib/testdata/testinput7
+++ b/ext/pcre/pcrelib/testdata/testinput7
@@ -1931,8 +1931,8 @@
/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
abcdefghijk\12S
-/ab\hdef/
- abhdef
+/ab\idef/
+ abidef
/a{0}bc/
bc
@@ -4229,4 +4229,73 @@
\r\nfoo
\nfoo
+/^$/mg<any>
+ abc\r\rxyz
+ abc\n\rxyz
+ ** Failers
+ abc\r\nxyz
+
+/^X/m
+ XABC
+ ** Failers
+ XABC\B
+
+/(?m)^$/<any>g+
+ abc\r\n\r\n
+
+/(?m)^$|^\r\n/<any>g+
+ abc\r\n\r\n
+
+/(?m)$/<any>g+
+ abc\r\n\r\n
+
+/(?|(abc)|(xyz))/
+ >abc<
+ >xyz<
+
+/(x)(?|(abc)|(xyz))(x)/
+ xabcx
+ xxyzx
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/
+ xabcpqrx
+ xxyzx
+
+/(?|(abc)|(xyz))(?1)/
+ abcabc
+ xyzabc
+ ** Failers
+ xyzxyz
+
+/\H\h\V\v/
+ X X\x0a
+ X\x09X\x0b
+ ** Failers
+ \xa0 X\x0a
+
+/\H*\h+\V?\v{3,4}/
+ \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+ \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+ \x09\x20\xa0\x0a\x0b\x0c
+ ** Failers
+ \x09\x20\xa0\x0a\x0b
+
+/\H{3,4}/
+ XY ABCDE
+ XY PQR ST
+
+/.\h{3,4}./
+ XY AB PQRS
+
+/\h*X\h?\H+Y\H?Z/
+ >XNNNYZ
+ > X NYQZ
+ ** Failers
+ >XYZ
+ > X NY Z
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+ >XY\x0aZ\x0aA\x0bNN\x0c
+ >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
/ End of testinput7 /
diff --git a/ext/pcre/pcrelib/testdata/testinput8 b/ext/pcre/pcrelib/testdata/testinput8
index a19493fe63..61e70e55ac 100644
--- a/ext/pcre/pcrelib/testdata/testinput8
+++ b/ext/pcre/pcrelib/testdata/testinput8
@@ -590,4 +590,42 @@
a\n\n\n\rb
a\r
+/\h+\V?\v{3,4}/8
+ \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+
+/\V?\v{3,4}/8
+ \x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+
+/\h+\V?\v{3,4}/8
+ >\x09\x20\x{a0}X\x0a\x0a\x0a<
+
+/\V?\v{3,4}/8
+ >\x09\x20\x{a0}X\x0a\x0a\x0a<
+
+/\H\h\V\v/8
+ X X\x0a
+ X\x09X\x0b
+ ** Failers
+ \x{a0} X\x0a
+
+/\H*\h+\V?\v{3,4}/8
+ \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+ \x09\x20\x{a0}\x0a\x0b\x0c
+ ** Failers
+ \x09\x20\x{a0}\x0a\x0b
+
+/\H\h\V\v/8
+ \x{3001}\x{3000}\x{2030}\x{2028}
+ X\x{180e}X\x{85}
+ ** Failers
+ \x{2009} X\x0a
+
+/\H*\h+\V?\v{3,4}/8
+ \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+ \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+ \x09\x20\x{202f}\x0a\x0b\x0c
+ ** Failers
+ \x09\x{200a}\x{a0}\x{2028}\x0b
+
/ End of testinput 8 /
diff --git a/ext/pcre/pcrelib/testdata/testinput9 b/ext/pcre/pcrelib/testdata/testinput9
index 23d3d3e434..e11dda1bf5 100644
--- a/ext/pcre/pcrelib/testdata/testinput9
+++ b/ext/pcre/pcrelib/testdata/testinput9
@@ -813,4 +813,10 @@
\x{1c5}XY
AXY
+/^\x{023a}+?(\x{0130}+)/8i
+ \x{023a}\x{2c65}\x{0130}
+
+/^\x{023a}+([^X])/8i
+ \x{023a}\x{2c65}X
+
/ End /
diff --git a/ext/pcre/pcrelib/testdata/testoutput1 b/ext/pcre/pcrelib/testdata/testoutput1
index b513dca417..209b0d3f4c 100644
--- a/ext/pcre/pcrelib/testdata/testoutput1
+++ b/ext/pcre/pcrelib/testdata/testoutput1
@@ -2189,9 +2189,9 @@ No match
10: j
11: k
-/ab\hdef/
- abhdef
- 0: abhdef
+/ab\idef/
+ abidef
+ 0: abidef
/a{0}bc/
bc
@@ -6571,4 +6571,9 @@ No match
abc\n
No match
+/(.*(.)?)*/
+ abcd
+ 0: abcd
+ 1:
+
/ End of testinput1 /
diff --git a/ext/pcre/pcrelib/testdata/testoutput10 b/ext/pcre/pcrelib/testdata/testoutput10
new file mode 100644
index 0000000000..bfda261bc8
--- /dev/null
+++ b/ext/pcre/pcrelib/testdata/testoutput10
@@ -0,0 +1,563 @@
+/-- These are a few representative patterns whose lengths and offsets are to be
+shown when the link size is 2. This is just a doublecheck test to ensure the
+sizes don't go horribly wrong when something is changed. The pattern contents
+are all themselves checked in other tests. --/
+
+/((?i)b)/BM
+Memory allocation (code space): 21
+------------------------------------------------------------------
+ 0 17 Bra 0
+ 3 9 Bra 1
+ 8 01 Opt
+ 10 NC b
+ 12 9 Ket
+ 15 00 Opt
+ 17 17 Ket
+ 20 End
+------------------------------------------------------------------
+
+/(?s)(.*X|^B)/BM
+Memory allocation (code space): 25
+------------------------------------------------------------------
+ 0 21 Bra 0
+ 3 9 Bra 1
+ 8 Any*
+ 10 X
+ 12 6 Alt
+ 15 ^
+ 16 B
+ 18 15 Ket
+ 21 21 Ket
+ 24 End
+------------------------------------------------------------------
+
+/(?s:.*X|^B)/BM
+Memory allocation (code space): 29
+------------------------------------------------------------------
+ 0 25 Bra 0
+ 3 9 Bra 0
+ 6 04 Opt
+ 8 Any*
+ 10 X
+ 12 8 Alt
+ 15 04 Opt
+ 17 ^
+ 18 B
+ 20 17 Ket
+ 23 00 Opt
+ 25 25 Ket
+ 28 End
+------------------------------------------------------------------
+
+/^[[:alnum:]]/BM
+Memory allocation (code space): 41
+------------------------------------------------------------------
+ 0 37 Bra 0
+ 3 ^
+ 4 [0-9A-Za-z]
+ 37 37 Ket
+ 40 End
+------------------------------------------------------------------
+
+/#/IxMD
+Memory allocation (code space): 7
+------------------------------------------------------------------
+ 0 3 Bra 0
+ 3 3 Ket
+ 6 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: extended
+No first char
+No need char
+
+/a#/IxMD
+Memory allocation (code space): 9
+------------------------------------------------------------------
+ 0 5 Bra 0
+ 3 a
+ 5 5 Ket
+ 8 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: extended
+First char = 'a'
+No need char
+
+/x?+/BM
+Memory allocation (code space): 9
+------------------------------------------------------------------
+ 0 5 Bra 0
+ 3 x?+
+ 5 5 Ket
+ 8 End
+------------------------------------------------------------------
+
+/x++/BM
+Memory allocation (code space): 9
+------------------------------------------------------------------
+ 0 5 Bra 0
+ 3 x++
+ 5 5 Ket
+ 8 End
+------------------------------------------------------------------
+
+/x{1,3}+/BM
+Memory allocation (code space): 19
+------------------------------------------------------------------
+ 0 15 Bra 0
+ 3 9 Once
+ 6 x
+ 8 x{0,2}
+ 12 9 Ket
+ 15 15 Ket
+ 18 End
+------------------------------------------------------------------
+
+/(x)*+/BM
+Memory allocation (code space): 24
+------------------------------------------------------------------
+ 0 20 Bra 0
+ 3 14 Once
+ 6 Brazero
+ 7 7 Bra 1
+ 12 x
+ 14 7 KetRmax
+ 17 14 Ket
+ 20 20 Ket
+ 23 End
+------------------------------------------------------------------
+
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/BM
+Memory allocation (code space): 120
+------------------------------------------------------------------
+ 0 116 Bra 0
+ 3 ^
+ 4 109 Bra 1
+ 9 7 Bra 2
+ 14 a+
+ 16 7 Ket
+ 19 39 Bra 3
+ 24 [ab]+?
+ 58 39 Ket
+ 61 39 Bra 4
+ 66 [bc]+
+100 39 Ket
+103 7 Bra 5
+108 \w*
+110 7 Ket
+113 109 Ket
+116 116 Ket
+119 End
+------------------------------------------------------------------
+
+|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|BM
+Memory allocation (code space): 826
+------------------------------------------------------------------
+ 0 822 Bra 0
+ 3 8J$WE<.rX+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
+821 \b
+822 822 Ket
+825 End
+------------------------------------------------------------------
+
+|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|BM
+Memory allocation (code space): 816
+------------------------------------------------------------------
+ 0 812 Bra 0
+ 3 $<.X+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
+811 \b
+812 812 Ket
+815 End
+------------------------------------------------------------------
+
+/(a(?1)b)/BM
+Memory allocation (code space): 28
+------------------------------------------------------------------
+ 0 24 Bra 0
+ 3 18 Bra 1
+ 8 a
+ 10 6 Once
+ 13 3 Recurse
+ 16 6 Ket
+ 19 b
+ 21 18 Ket
+ 24 24 Ket
+ 27 End
+------------------------------------------------------------------
+
+/(a(?1)+b)/BM
+Memory allocation (code space): 28
+------------------------------------------------------------------
+ 0 24 Bra 0
+ 3 18 Bra 1
+ 8 a
+ 10 6 Once
+ 13 3 Recurse
+ 16 6 KetRmax
+ 19 b
+ 21 18 Ket
+ 24 24 Ket
+ 27 End
+------------------------------------------------------------------
+
+/a(?P<name1>b|c)d(?P<longername2>e)/BM
+Memory allocation (code space): 42
+------------------------------------------------------------------
+ 0 32 Bra 0
+ 3 a
+ 5 7 Bra 1
+ 10 b
+ 12 5 Alt
+ 15 c
+ 17 12 Ket
+ 20 d
+ 22 7 Bra 2
+ 27 e
+ 29 7 Ket
+ 32 32 Ket
+ 35 End
+------------------------------------------------------------------
+
+/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/BM
+Memory allocation (code space): 54
+------------------------------------------------------------------
+ 0 41 Bra 0
+ 3 25 Bra 0
+ 6 a
+ 8 17 Bra 1
+ 13 c
+ 15 7 Bra 2
+ 20 d
+ 22 7 Ket
+ 25 17 Ket
+ 28 25 Ket
+ 31 7 Bra 3
+ 36 a
+ 38 7 Ket
+ 41 41 Ket
+ 44 End
+------------------------------------------------------------------
+
+/(?P<a>a)...(?P=a)bbb(?P>a)d/BM
+Memory allocation (code space): 43
+------------------------------------------------------------------
+ 0 36 Bra 0
+ 3 7 Bra 1
+ 8 a
+ 10 7 Ket
+ 13 Any
+ 14 Any
+ 15 Any
+ 16 \1
+ 19 bbb
+ 25 6 Once
+ 28 3 Recurse
+ 31 6 Ket
+ 34 d
+ 36 36 Ket
+ 39 End
+------------------------------------------------------------------
+
+/abc(?C255)de(?C)f/BM
+Memory allocation (code space): 31
+------------------------------------------------------------------
+ 0 27 Bra 0
+ 3 abc
+ 9 Callout 255 10 1
+ 15 de
+ 19 Callout 0 16 1
+ 25 f
+ 27 27 Ket
+ 30 End
+------------------------------------------------------------------
+
+/abcde/CBM
+Memory allocation (code space): 53
+------------------------------------------------------------------
+ 0 49 Bra 0
+ 3 Callout 255 0 1
+ 9 a
+ 11 Callout 255 1 1
+ 17 b
+ 19 Callout 255 2 1
+ 25 c
+ 27 Callout 255 3 1
+ 33 d
+ 35 Callout 255 4 1
+ 41 e
+ 43 Callout 255 5 0
+ 49 49 Ket
+ 52 End
+------------------------------------------------------------------
+
+/\x{100}/8BM
+Memory allocation (code space): 10
+------------------------------------------------------------------
+ 0 6 Bra 0
+ 3 \x{100}
+ 6 6 Ket
+ 9 End
+------------------------------------------------------------------
+
+/\x{1000}/8BM
+Memory allocation (code space): 11
+------------------------------------------------------------------
+ 0 7 Bra 0
+ 3 \x{1000}
+ 7 7 Ket
+ 10 End
+------------------------------------------------------------------
+
+/\x{10000}/8BM
+Memory allocation (code space): 12
+------------------------------------------------------------------
+ 0 8 Bra 0
+ 3 \x{10000}
+ 8 8 Ket
+ 11 End
+------------------------------------------------------------------
+
+/\x{100000}/8BM
+Memory allocation (code space): 12
+------------------------------------------------------------------
+ 0 8 Bra 0
+ 3 \x{100000}
+ 8 8 Ket
+ 11 End
+------------------------------------------------------------------
+
+/\x{1000000}/8BM
+Memory allocation (code space): 13
+------------------------------------------------------------------
+ 0 9 Bra 0
+ 3 \x{1000000}
+ 9 9 Ket
+ 12 End
+------------------------------------------------------------------
+
+/\x{4000000}/8BM
+Memory allocation (code space): 14
+------------------------------------------------------------------
+ 0 10 Bra 0
+ 3 \x{4000000}
+ 10 10 Ket
+ 13 End
+------------------------------------------------------------------
+
+/\x{7fffFFFF}/8BM
+Memory allocation (code space): 14
+------------------------------------------------------------------
+ 0 10 Bra 0
+ 3 \x{7fffffff}
+ 10 10 Ket
+ 13 End
+------------------------------------------------------------------
+
+/[\x{ff}]/8BM
+Memory allocation (code space): 10
+------------------------------------------------------------------
+ 0 6 Bra 0
+ 3 \x{ff}
+ 6 6 Ket
+ 9 End
+------------------------------------------------------------------
+
+/[\x{100}]/8BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 [\x{100}]
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+
+/\x80/8BM
+Memory allocation (code space): 10
+------------------------------------------------------------------
+ 0 6 Bra 0
+ 3 \x{80}
+ 6 6 Ket
+ 9 End
+------------------------------------------------------------------
+
+/\xff/8BM
+Memory allocation (code space): 10
+------------------------------------------------------------------
+ 0 6 Bra 0
+ 3 \x{ff}
+ 6 6 Ket
+ 9 End
+------------------------------------------------------------------
+
+/\x{0041}\x{2262}\x{0391}\x{002e}/D8M
+Memory allocation (code space): 18
+------------------------------------------------------------------
+ 0 14 Bra 0
+ 3 A\x{2262}\x{391}.
+ 14 14 Ket
+ 17 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 'A'
+Need char = '.'
+
+/\x{D55c}\x{ad6d}\x{C5B4}/D8M
+Memory allocation (code space): 19
+------------------------------------------------------------------
+ 0 15 Bra 0
+ 3 \x{d55c}\x{ad6d}\x{c5b4}
+ 15 15 Ket
+ 18 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 237
+Need char = 180
+
+/\x{65e5}\x{672c}\x{8a9e}/D8M
+Memory allocation (code space): 19
+------------------------------------------------------------------
+ 0 15 Bra 0
+ 3 \x{65e5}\x{672c}\x{8a9e}
+ 15 15 Ket
+ 18 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 230
+Need char = 158
+
+/[\x{100}]/8BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 [\x{100}]
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+
+/[Z\x{100}]/8BM
+Memory allocation (code space): 47
+------------------------------------------------------------------
+ 0 43 Bra 0
+ 3 [Z\x{100}]
+ 43 43 Ket
+ 46 End
+------------------------------------------------------------------
+
+/^[\x{100}\E-\Q\E\x{150}]/B8M
+Memory allocation (code space): 18
+------------------------------------------------------------------
+ 0 14 Bra 0
+ 3 ^
+ 4 [\x{100}-\x{150}]
+ 14 14 Ket
+ 17 End
+------------------------------------------------------------------
+
+/^[\QĀ\E-\QŐ\E]/B8M
+Memory allocation (code space): 18
+------------------------------------------------------------------
+ 0 14 Bra 0
+ 3 ^
+ 4 [\x{100}-\x{150}]
+ 14 14 Ket
+ 17 End
+------------------------------------------------------------------
+
+/^[\QĀ\E-\QŐ\E/B8M
+Failed: missing terminating ] for character class at offset 15
+
+/[\p{L}]/BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 [\p{L}]
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+
+/[\p{^L}]/BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 [\P{L}]
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+
+/[\P{L}]/BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 [\P{L}]
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+
+/[\P{^L}]/BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 [\p{L}]
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+
+/[abc\p{L}\x{0660}]/8BM
+Memory allocation (code space): 50
+------------------------------------------------------------------
+ 0 46 Bra 0
+ 3 [a-c\p{L}\x{660}]
+ 46 46 Ket
+ 49 End
+------------------------------------------------------------------
+
+/[\p{Nd}]/8BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 [\p{Nd}]
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+
+/[\p{Nd}+-]+/8BM
+Memory allocation (code space): 48
+------------------------------------------------------------------
+ 0 44 Bra 0
+ 3 [+\-\p{Nd}]+
+ 44 44 Ket
+ 47 End
+------------------------------------------------------------------
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iBM
+Memory allocation (code space): 25
+------------------------------------------------------------------
+ 0 21 Bra 0
+ 3 NC A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+ 21 21 Ket
+ 24 End
+------------------------------------------------------------------
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8BM
+Memory allocation (code space): 25
+------------------------------------------------------------------
+ 0 21 Bra 0
+ 3 A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+ 21 21 Ket
+ 24 End
+------------------------------------------------------------------
+
+/[\x{105}-\x{109}]/8iBM
+Memory allocation (code space): 17
+------------------------------------------------------------------
+ 0 13 Bra 0
+ 3 [\x{104}-\x{109}]
+ 13 13 Ket
+ 16 End
+------------------------------------------------------------------
+
+/ End of testinput10 /
diff --git a/ext/pcre/pcrelib/testdata/testoutput2 b/ext/pcre/pcrelib/testdata/testoutput2
index 45907492f9..cd8f82eb10 100644
--- a/ext/pcre/pcrelib/testdata/testoutput2
+++ b/ext/pcre/pcrelib/testdata/testoutput2
@@ -78,10 +78,10 @@ No match
def\nabc
No match
-/ab\hdef/X
+/ab\idef/X
Failed: unrecognized character follows \ at offset 3
-/(?X)ab\hdef/X
+/(?X)ab\idef/X
Failed: unrecognized character follows \ at offset 7
/x{5,4}/
@@ -222,7 +222,7 @@ Matched, but too many substrings
0: abcb
1: a
2: b
- \O12abcb
+ \O12abcb
0: abcb
1: a
2: b
@@ -343,7 +343,7 @@ No need char
0: abc
*** Failers
No match: POSIX code 17: match failed
-
+
/^abc|def/IP
abcdef
0: abc
@@ -359,19 +359,19 @@ No match: POSIX code 17: match failed
0: def
1: def
3: def
-
+
/the quick brown fox/IP
the quick brown fox
0: the quick brown fox
- *** Failers
+ *** Failers
No match: POSIX code 17: match failed
- The Quick Brown Fox
+ The Quick Brown Fox
No match: POSIX code 17: match failed
/the quick brown fox/IPi
the quick brown fox
0: the quick brown fox
- The Quick Brown Fox
+ The Quick Brown Fox
0: The Quick Brown Fox
/abc.def/IP
@@ -379,11 +379,11 @@ No match: POSIX code 17: match failed
No match: POSIX code 17: match failed
abc\ndef
No match: POSIX code 17: match failed
-
+
/abc$/IP
abc
0: abc
- abc\n
+ abc\n
0: abc
/(abc)\2/IP
@@ -405,9 +405,9 @@ Partial matching not supported
No options
No first char
No need char
- co-processors, and for
+ co-processors, and for
0: -pr
-
+
/<.*>/I
Capturing subpattern count = 0
Partial matching not supported
@@ -434,7 +434,7 @@ First char = '<'
Need char = '>'
abc<def>ghi<klm>nop
0: <def>
-
+
/(?U)<.*>/I
Capturing subpattern count = 0
Partial matching not supported
@@ -452,7 +452,7 @@ First char = '<'
Need char = '>'
abc<def>ghi<klm>nop
0: <def>ghi<klm>
-
+
/={3,}/IU
Capturing subpattern count = 0
Partial matching not supported
@@ -461,7 +461,7 @@ First char = '='
Need char = '='
abc========def
0: ===
-
+
/(?U)={3,}?/I
Capturing subpattern count = 0
Partial matching not supported
@@ -470,7 +470,7 @@ First char = '='
Need char = '='
abc========def
0: ========
-
+
/(?<!bar|cattle)foo/I
Capturing subpattern count = 0
No options
@@ -478,13 +478,13 @@ First char = 'f'
Need char = 'o'
foo
0: foo
- catfoo
+ catfoo
0: foo
*** Failers
No match
the barfoo
No match
- and cattlefoo
+ and cattlefoo
No match
/(?<=a+)b/
@@ -597,16 +597,16 @@ No options
First char = 'b' (caseless)
Need char = 'h' (caseless)
-/((?i)b)/IDS
+/((?i)b)/IDZS
------------------------------------------------------------------
- 0 17 Bra 0
- 3 9 Bra 1
- 8 01 Opt
- 10 NC b
- 12 9 Ket
- 15 00 Opt
- 17 17 Ket
- 20 End
+ Bra 0
+ Bra 1
+ 01 Opt
+ NC b
+ Ket
+ 00 Opt
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
No options
@@ -631,11 +631,11 @@ No need char
0: a
a\n
0: a
- *** Failers
+ *** Failers
No match
\Za
No match
- \Za\n
+ \Za\n
No match
/a$/Im
@@ -647,20 +647,20 @@ No need char
0: a
a\n
0: a
- \Za\n
+ \Za\n
0: a
- *** Failers
+ *** Failers
No match
\Za
No match
-
+
/\Aabc/Im
Capturing subpattern count = 0
Options: anchored multiline
No first char
No need char
-/^abc/Im
+/^abc/Im
Capturing subpattern count = 0
Options: multiline
First char at start or follows newline
@@ -706,15 +706,15 @@ Capturing subpattern count = 0
Options: multiline
No first char
Need char = 'r'
- foo\nbarbar
+ foo\nbarbar
0: bar
***Failers
No match
- rhubarb
+ rhubarb
No match
barbell
No match
- abc\nbarton
+ abc\nbarton
No match
/^(?<=foo\n)bar/Im
@@ -722,15 +722,15 @@ Capturing subpattern count = 0
Options: multiline
First char at start or follows newline
Need char = 'r'
- foo\nbarbar
+ foo\nbarbar
0: bar
***Failers
No match
- rhubarb
+ rhubarb
No match
barbell
No match
- abc\nbarton
+ abc\nbarton
No match
/(?>^abc)/Im
@@ -744,7 +744,7 @@ Need char = 'c'
0: abc
*** Failers
No match
- defabc
+ defabc
No match
/(?<=ab(c+)d)ef/
@@ -771,9 +771,9 @@ Need char = 't'
No match
cart
No match
- horse-and-cart
+ horse-and-cart
No match
-
+
/(?<=ab(?i)x|y|z)/I
Capturing subpattern count = 0
No options
@@ -809,17 +809,17 @@ Need char = 'Z'
0: ZZ
bZZ
0: ZZ
- BZZ
+ BZZ
0: ZZ
*** Failers
No match
- ZZ
+ ZZ
No match
- abXYZZ
+ abXYZZ
No match
zzz
No match
- bzz
+ bzz
No match
/(?<!(foo)a)bar/I
@@ -829,11 +829,11 @@ First char = 'b'
Need char = 'r'
bar
0: bar
- foobbar
+ foobbar
0: bar
*** Failers
No match
- fooabar
+ fooabar
No match
/This one is here because Perl 5.005_02 doesn't fail it/I
@@ -849,7 +849,7 @@ No first char
No need char
*** Failers
No match
- a
+ a
No match
/This one is here because I think Perl 5.005_02 gets the setting of $1 wrong/I
@@ -867,7 +867,7 @@ No need char
aaaaaa
0: aaaaaa
1: aa
-
+
/These are syntax tests from Perl 5.005/I
Capturing subpattern count = 0
No options
@@ -1001,7 +1001,7 @@ Need char = 'd'
1: a
2: d
copy substring 5 failed -7
-
+
/(.{20})/I
Capturing subpattern count = 1
Partial matching not supported
@@ -1019,7 +1019,7 @@ No need char
0: abcdefghijklmnopqrst
1: abcdefghijklmnopqrst
1G abcdefghijklmnopqrst (20)
-
+
/(.{15})/I
Capturing subpattern count = 1
Partial matching not supported
@@ -1051,13 +1051,13 @@ No need char
1G abcdefghijklmnop (16)
0L abcdefghijklmnop
1L abcdefghijklmnop
-
+
/^(a|(bc))de(f)/I
Capturing subpattern count = 3
Options: anchored
No first char
No need char
- adef\G1\G2\G3\G4\L
+ adef\G1\G2\G3\G4\L
0: adef
1: a
2: <unset>
@@ -1070,7 +1070,7 @@ get substring 4 failed -7
1L a
2L
3L f
- bcdef\G1\G2\G3\G4\L
+ bcdef\G1\G2\G3\G4\L
0: bcdef
1: bc
2: bc
@@ -1083,40 +1083,39 @@ get substring 4 failed -7
1L bc
2L bc
3L f
- adefghijk\C0
+ adefghijk\C0
0: adef
1: a
2: <unset>
3: f
0C adef (4)
-
+
/^abc\00def/I
Capturing subpattern count = 0
Options: anchored
No first char
No need char
- abc\00def\L\C0
+ abc\00def\L\C0
0: abc\x00def
0C abc (7)
0L abc
-
-/word ((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
-)((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
-)?)?)?)?)?)?)?)?)?otherword/IM
-Memory allocation (code space): 448
+
+/word ((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
+)((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
+)?)?)?)?)?)?)?)?)?otherword/I
Capturing subpattern count = 8
Partial matching not supported
No options
First char = 'w'
Need char = 'd'
-/.*X/ID
+/.*X/IDZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 Any*
- 5 X
- 7 7 Ket
- 10 End
+ Bra 0
+ Any*
+ X
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1124,13 +1123,13 @@ No options
First char at start or follows newline
Need char = 'X'
-/.*X/IDs
+/.*X/IDZs
------------------------------------------------------------------
- 0 7 Bra 0
- 3 Any*
- 5 X
- 7 7 Ket
- 10 End
+ Bra 0
+ Any*
+ X
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1138,18 +1137,18 @@ Options: anchored dotall
No first char
Need char = 'X'
-/(.*X|^B)/ID
+/(.*X|^B)/IDZ
------------------------------------------------------------------
- 0 21 Bra 0
- 3 9 Bra 1
- 8 Any*
- 10 X
- 12 6 Alt
- 15 ^
- 16 B
- 18 15 Ket
- 21 21 Ket
- 24 End
+ Bra 0
+ Bra 1
+ Any*
+ X
+ Alt
+ ^
+ B
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Partial matching not supported
@@ -1157,37 +1156,37 @@ No options
First char at start or follows newline
No need char
-/(.*X|^B)/IDs
+/(.*X|^B)/IDZs
------------------------------------------------------------------
- 0 21 Bra 0
- 3 9 Bra 1
- 8 Any*
- 10 X
- 12 6 Alt
- 15 ^
- 16 B
- 18 15 Ket
- 21 21 Ket
- 24 End
+ Bra 0
+ Bra 1
+ Any*
+ X
+ Alt
+ ^
+ B
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Partial matching not supported
Options: anchored dotall
No first char
No need char
-
-/(?s)(.*X|^B)/ID
-------------------------------------------------------------------
- 0 21 Bra 0
- 3 9 Bra 1
- 8 Any*
- 10 X
- 12 6 Alt
- 15 ^
- 16 B
- 18 15 Ket
- 21 21 Ket
- 24 End
+
+/(?s)(.*X|^B)/IDZ
+------------------------------------------------------------------
+ Bra 0
+ Bra 1
+ Any*
+ X
+ Alt
+ ^
+ B
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Partial matching not supported
@@ -1195,21 +1194,21 @@ Options: anchored dotall
No first char
No need char
-/(?s:.*X|^B)/ID
+/(?s:.*X|^B)/IDZ
------------------------------------------------------------------
- 0 25 Bra 0
- 3 9 Bra 0
- 6 04 Opt
- 8 Any*
- 10 X
- 12 8 Alt
- 15 04 Opt
- 17 ^
- 18 B
- 20 17 Ket
- 23 00 Opt
- 25 25 Ket
- 28 End
+ Bra 0
+ Bra 0
+ 04 Opt
+ Any*
+ X
+ Alt
+ 04 Opt
+ ^
+ B
+ Ket
+ 00 Opt
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1294,14 +1293,14 @@ No need char
ississippi
0: iss
0+ issippi
-
+
/.*iss/Ig+
Capturing subpattern count = 0
Partial matching not supported
No options
First char at start or follows newline
Need char = 's'
- abciss\nxyzisspqr
+ abciss\nxyzisspqr
0: abciss
0+ \x0axyzisspqr
0: xyziss
@@ -1333,7 +1332,7 @@ Need char = 'i'
0+ river
0: riv
0+ er
- Missouri river\A
+ Missouri river\A
0: Mis
0+ souri river
@@ -1646,9 +1645,9 @@ No need char
0:
*** Failers
0:
- \N
+ \N
No match
-
+
/|-/I
Capturing subpattern count = 0
No options
@@ -1662,7 +1661,7 @@ No need char
0: -
*** Failers
0:
- \Nabc
+ \Nabc
No match
/a*(b+)(z)(z)/IP
@@ -1691,8 +1690,8 @@ No match
1: bbbb
2: z
3: z
-
-/^.?abcd/IS
+
+/^.?abcd/IS
Capturing subpattern count = 0
Options: anchored
No first char
@@ -1718,21 +1717,21 @@ Need char = ')'
0: (abcd)
xyz(abcd)
0: (abcd)
- (ab(xy)cd)pqr
+ (ab(xy)cd)pqr
0: (ab(xy)cd)
- (ab(xycd)pqr
+ (ab(xycd)pqr
0: (xycd)
- () abc ()
+ () abc ()
0: ()
12(abcde(fsh)xyz(foo(bar))lmno)89
0: (abcde(fsh)xyz(foo(bar))lmno)
*** Failers
No match
- abcd
+ abcd
No match
abcd)
No match
- (abcd
+ (abcd
No match
/\( ( (?>[^()]+) | (?R) )* \) /Ixg
@@ -1741,7 +1740,7 @@ Partial matching not supported
Options: extended
First char = '('
Need char = ')'
- (ab(xy)cd)pqr
+ (ab(xy)cd)pqr
0: (ab(xy)cd)
1: cd
1(abcd)(x(y)z)pqr
@@ -1760,13 +1759,13 @@ Need char = ')'
0: (abcd)
(ab(xy)cd)
0: (xy)
- (a(b(c)d)e)
+ (a(b(c)d)e)
0: (c)
- ((ab))
+ ((ab))
0: ((ab))
*** Failers
No match
- ()
+ ()
No match
/\( (?: (?>[^()]+) | (?R) )? \) /Ix
@@ -1884,58 +1883,58 @@ Need char = ')'
2: ij
3: (cd(ef)gh)
-/^[[:alnum:]]/D
+/^[[:alnum:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [0-9A-Za-z]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [0-9A-Za-z]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:^alnum:]]/D
+/^[[:^alnum:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x00-/:-@[-`{-\xff]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x00-/:-@[-`{-\xff]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:alpha:]]/D
+/^[[:alpha:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [A-Za-z]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [A-Za-z]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:^alpha:]]/D
+/^[[:^alpha:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x00-@[-`{-\xff]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x00-@[-`{-\xff]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-
+
/[_[:alpha:]]/IS
Capturing subpattern count = 0
No options
@@ -1944,52 +1943,52 @@ No need char
Starting byte set: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
_ a b c d e f g h i j k l m n o p q r s t u v w x y z
-/^[[:ascii:]]/D
+/^[[:ascii:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x00-\x7f]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x00-\x7f]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:^ascii:]]/D
+/^[[:^ascii:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x80-\xff]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x80-\xff]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:blank:]]/D
+/^[[:blank:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x09 ]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x09 ]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:^blank:]]/D
+/^[[:^blank:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x00-\x08\x0a-\x1f!-\xff]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x00-\x08\x0a-\x1f!-\xff]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
@@ -2003,181 +2002,181 @@ No first char
No need char
Starting byte set: \x09 \x0a \x0b \x0c \x0d \x20
-/^[[:cntrl:]]/D
+/^[[:cntrl:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x00-\x1f\x7f]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x00-\x1f\x7f]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:digit:]]/D
+/^[[:digit:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [0-9]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [0-9]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:graph:]]/D
+/^[[:graph:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [!-~]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [!-~]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:lower:]]/D
+/^[[:lower:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [a-z]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [a-z]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:print:]]/D
+/^[[:print:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [ -~]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [ -~]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:punct:]]/D
+/^[[:punct:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [!-/:-@[-`{-~]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [!-/:-@[-`{-~]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:space:]]/D
+/^[[:space:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x09-\x0d ]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x09-\x0d ]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:upper:]]/D
+/^[[:upper:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [A-Z]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [A-Z]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:xdigit:]]/D
+/^[[:xdigit:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [0-9A-Fa-f]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [0-9A-Fa-f]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:word:]]/D
+/^[[:word:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [0-9A-Z_a-z]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [0-9A-Z_a-z]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:^cntrl:]]/D
+/^[[:^cntrl:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [ -~\x80-\xff]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [ -~\x80-\xff]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[12[:^digit:]]/D
+/^[12[:^digit:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x00-/12:-\xff]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x00-/12:-\xff]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/^[[:^blank:]]/D
+/^[[:^blank:]]/DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x00-\x08\x0a-\x1f!-\xff]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x00-\x08\x0a-\x1f!-\xff]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored
No first char
No need char
-/[01[:alpha:]%]/D
+/[01[:alpha:]%]/DZ
------------------------------------------------------------------
- 0 36 Bra 0
- 3 [%01A-Za-z]
- 36 36 Ket
- 39 End
+ Bra 0
+ [%01A-Za-z]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
@@ -2200,9 +2199,9 @@ No first char
No need char
A
0: A
- a
+ a
0: a
-
+
/[[:lower:]]/Ii
Capturing subpattern count = 0
Options: caseless
@@ -2210,7 +2209,7 @@ No first char
No need char
A
0: A
- a
+ a
0: a
/((?-i)[[:lower:]])[[:lower:]]/Ii
@@ -2229,7 +2228,7 @@ No need char
1: a
Ab
No match
- AB
+ AB
No match
/[\200-\110]/I
@@ -2543,7 +2542,7 @@ Need char = 'n'
0: mainOmain
1: main
2: O
-
+
/These are all cases where Perl does it differently (nested captures)/I
Capturing subpattern count = 1
No options
@@ -2559,52 +2558,52 @@ No need char
0: aba
1: a
2: b
-
+
/^(aa(bb)?)+$/I
Capturing subpattern count = 2
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: aa
2: bb
-
+
/^(aa|aa(bb))+$/I
Capturing subpattern count = 2
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: aa
2: bb
-
+
/^(aa(bb)??)+$/I
Capturing subpattern count = 2
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: aa
2: bb
-
+
/^(?:aa(bb)?)+$/I
Capturing subpattern count = 1
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: bb
-
+
/^(aa(b(b))?)+$/I
Capturing subpattern count = 3
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: aa
2: bb
@@ -2615,7 +2614,7 @@ Capturing subpattern count = 2
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: bb
2: b
@@ -2625,7 +2624,7 @@ Capturing subpattern count = 1
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: bb
@@ -2634,16 +2633,16 @@ Capturing subpattern count = 1
Options: anchored
No first char
No need char
- aabbbaa
+ aabbbaa
0: aabbbaa
1: bbb
-
+
/^(?:aa(b(?:bb))?)+$/I
Capturing subpattern count = 1
Options: anchored
No first char
No need char
- aabbbaa
+ aabbbaa
0: aabbbaa
1: bbb
@@ -2652,7 +2651,7 @@ Capturing subpattern count = 1
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: b
@@ -2661,7 +2660,7 @@ Capturing subpattern count = 1
Options: anchored
No first char
No need char
- aabbbaa
+ aabbbaa
0: aabbbaa
1: bb
@@ -2670,7 +2669,7 @@ Capturing subpattern count = 3
Options: anchored
No first char
No need char
- aabbbaa
+ aabbbaa
0: aabbbaa
1: aa
2: bbb
@@ -2681,75 +2680,73 @@ Capturing subpattern count = 3
Options: anchored
No first char
No need char
- aabbbbaa
+ aabbbbaa
0: aabbbbaa
1: aa
2: bbbb
3: bb
-/--------------------------------------------------------------------/I
+/--------------------------------------------------------------------/I
Capturing subpattern count = 0
No options
First char = '-'
Need char = '-'
-
-/#/IxMD
-Memory allocation (code space): 7
+
+/#/IxDZ
------------------------------------------------------------------
- 0 3 Bra 0
- 3 3 Ket
- 6 End
+ Bra 0
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: extended
No first char
No need char
-/a#/IxMD
-Memory allocation (code space): 9
+/a#/IxDZ
------------------------------------------------------------------
- 0 5 Bra 0
- 3 a
- 5 5 Ket
- 8 End
+ Bra 0
+ a
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: extended
First char = 'a'
No need char
-/[\s]/D
+/[\s]/DZ
------------------------------------------------------------------
- 0 36 Bra 0
- 3 [\x09\x0a\x0c\x0d ]
- 36 36 Ket
- 39 End
+ Bra 0
+ [\x09\x0a\x0c\x0d ]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/[\S]/D
+/[\S]/DZ
------------------------------------------------------------------
- 0 36 Bra 0
- 3 [\x00-\x08\x0b\x0e-\x1f!-\xff]
- 36 36 Ket
- 39 End
+ Bra 0
+ [\x00-\x08\x0b\x0e-\x1f!-\xff]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/a(?i)b/D
+/a(?i)b/DZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 a
- 5 01 Opt
- 7 NC b
- 9 9 Ket
- 12 End
+ Bra 0
+ a
+ 01 Opt
+ NC b
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
@@ -2759,22 +2756,22 @@ Need char = 'b' (caseless)
0: ab
aB
0: aB
- *** Failers
+ *** Failers
No match
- AB
+ AB
No match
-/(a(?i)b)/D
+/(a(?i)b)/DZ
------------------------------------------------------------------
- 0 19 Bra 0
- 3 11 Bra 1
- 8 a
- 10 01 Opt
- 12 NC b
- 14 11 Ket
- 17 00 Opt
- 19 19 Ket
- 22 End
+ Bra 0
+ Bra 1
+ a
+ 01 Opt
+ NC b
+ Ket
+ 00 Opt
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
No options
@@ -2786,17 +2783,17 @@ Need char = 'b' (caseless)
aB
0: aB
1: aB
- *** Failers
+ *** Failers
No match
- AB
+ AB
No match
-
-/ (?i)abc/IxD
+
+/ (?i)abc/IxDZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 NC abc
- 9 9 Ket
- 12 End
+ Bra 0
+ NC abc
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: caseless extended
@@ -2804,47 +2801,47 @@ First char = 'a' (caseless)
Need char = 'c' (caseless)
/#this is a comment
- (?i)abc/IxD
+ (?i)abc/IxDZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 NC abc
- 9 9 Ket
- 12 End
+ Bra 0
+ NC abc
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: caseless extended
First char = 'a' (caseless)
Need char = 'c' (caseless)
-/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/D
+/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/DZ
------------------------------------------------------------------
- 0 603 Bra 0
- 3 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
-603 603 Ket
-606 End
+ Bra 0
+ 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
First char = '1'
Need char = '0'
-/\Q123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/D
+/\Q123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/DZ
------------------------------------------------------------------
- 0 603 Bra 0
- 3 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
-603 603 Ket
-606 End
+ Bra 0
+ 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
First char = '1'
Need char = '0'
-/\Q\E/D
+/\Q\E/DZ
------------------------------------------------------------------
- 0 3 Bra 0
- 3 3 Ket
- 6 End
+ Bra 0
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
@@ -2853,36 +2850,36 @@ No need char
\
0:
-/\Q\Ex/D
+/\Q\Ex/DZ
------------------------------------------------------------------
- 0 5 Bra 0
- 3 x
- 5 5 Ket
- 8 End
+ Bra 0
+ x
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
First char = 'x'
No need char
-/ \Q\E/D
+/ \Q\E/DZ
------------------------------------------------------------------
- 0 5 Bra 0
- 3
- 5 5 Ket
- 8 End
+ Bra 0
+
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
First char = ' '
No need char
-/a\Q\E/D
+/a\Q\E/DZ
------------------------------------------------------------------
- 0 5 Bra 0
- 3 a
- 5 5 Ket
- 8 End
+ Bra 0
+ a
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
@@ -2892,15 +2889,15 @@ No need char
0: a
bca
0: a
- bac
+ bac
0: a
-/a\Q\Eb/D
+/a\Q\Eb/DZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 ab
- 7 7 Ket
- 10 End
+ Bra 0
+ ab
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
@@ -2909,25 +2906,25 @@ Need char = 'b'
abc
0: ab
-/\Q\Eabc/D
+/\Q\Eabc/DZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 abc
- 9 9 Ket
- 12 End
+ Bra 0
+ abc
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
First char = 'a'
Need char = 'c'
-/x*+\w/D
+/x*+\w/DZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 x*+
- 5 \w
- 6 6 Ket
- 9 End
+ Bra 0
+ x*+
+ \w
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -2938,25 +2935,25 @@ No need char
0: F
xxxxx
No match
-
-/x?+/D
+
+/x?+/DZ
------------------------------------------------------------------
- 0 5 Bra 0
- 3 x?+
- 5 5 Ket
- 8 End
+ Bra 0
+ x?+
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/x++/D
+/x++/DZ
------------------------------------------------------------------
- 0 5 Bra 0
- 3 x++
- 5 5 Ket
- 8 End
+ Bra 0
+ x++
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -2964,15 +2961,15 @@ No options
First char = 'x'
No need char
-/x{1,3}+/D
+/x{1,3}+/DZ
------------------------------------------------------------------
- 0 15 Bra 0
- 3 9 Once
- 6 x
- 8 x{0,2}
- 12 9 Ket
- 15 15 Ket
- 18 End
+ Bra 0
+ Once
+ x
+ x{0,2}
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -2980,17 +2977,17 @@ No options
First char = 'x'
No need char
-/(x)*+/D
+/(x)*+/DZ
------------------------------------------------------------------
- 0 20 Bra 0
- 3 14 Once
- 6 Brazero
- 7 7 Bra 1
- 12 x
- 14 7 KetRmax
- 17 14 Ket
- 20 20 Ket
- 23 End
+ Bra 0
+ Once
+ Brazero
+ Bra 1
+ x
+ KetRmax
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
No options
@@ -3010,7 +3007,7 @@ No need char
No match
this is not a line with only words and spaces!
No match
-
+
/(\d++)(\w)/I
Capturing subpattern count = 2
Partial matching not supported
@@ -3023,7 +3020,7 @@ No need char
2: a
*** Failers
No match
- 12345+
+ 12345+
No match
/a++b/I
@@ -3064,8 +3061,8 @@ No need char
((abc(ade)ufh()()x
0: abc(ade)ufh()()x
1: x
-
-/\(([^()]++|\([^()]+\))+\)/I
+
+/\(([^()]++|\([^()]+\))+\)/I
Capturing subpattern count = 1
Partial matching not supported
No options
@@ -3079,29 +3076,29 @@ Need char = ')'
1: xyz
*** Failers
No match
- ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-No match
-
-/(abc){1,3}+/D
-------------------------------------------------------------------
- 0 59 Bra 0
- 3 53 Once
- 6 11 Bra 1
- 11 abc
- 17 11 Ket
- 20 Brazero
- 21 32 Bra 0
- 24 11 Bra 1
- 29 abc
- 35 11 Ket
- 38 Brazero
- 39 11 Bra 1
- 44 abc
- 50 11 Ket
- 53 32 Ket
- 56 53 Ket
- 59 59 Ket
- 62 End
+ ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+
+/(abc){1,3}+/DZ
+------------------------------------------------------------------
+ Bra 0
+ Once
+ Bra 1
+ abc
+ Ket
+ Brazero
+ Bra 0
+ Bra 1
+ abc
+ Ket
+ Brazero
+ Bra 1
+ abc
+ Ket
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
No options
@@ -3120,14 +3117,14 @@ Failed: nothing to repeat at offset 7
/a{2,3}?+b/IU
Failed: nothing to repeat at offset 7
-/x(?U)a++b/D
+/x(?U)a++b/DZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 x
- 5 a++
- 7 b
- 9 9 Ket
- 12 End
+ Bra 0
+ x
+ a++
+ b
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -3137,14 +3134,14 @@ Need char = 'b'
xaaaab
0: xaaaab
-/(?U)xa++b/D
+/(?U)xa++b/DZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 x
- 5 a++
- 7 b
- 9 9 Ket
- 12 End
+ Bra 0
+ x
+ a++
+ b
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -3154,26 +3151,26 @@ Need char = 'b'
xaaaab
0: xaaaab
-/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/D
-------------------------------------------------------------------
- 0 116 Bra 0
- 3 ^
- 4 109 Bra 1
- 9 7 Bra 2
- 14 a+
- 16 7 Ket
- 19 39 Bra 3
- 24 [ab]+?
- 58 39 Ket
- 61 39 Bra 4
- 66 [bc]+
-100 39 Ket
-103 7 Bra 5
-108 \w*
-110 7 Ket
-113 109 Ket
-116 116 Ket
-119 End
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/DZ
+------------------------------------------------------------------
+ Bra 0
+ ^
+ Bra 1
+ Bra 2
+ a+
+ Ket
+ Bra 3
+ [ab]+?
+ Ket
+ Bra 4
+ [bc]+
+ Ket
+ Bra 5
+ \w*
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 5
Partial matching not supported
@@ -3181,15 +3178,15 @@ Options: anchored
No first char
No need char
-/^x(?U)a+b/D
+/^x(?U)a+b/DZ
------------------------------------------------------------------
- 0 10 Bra 0
- 3 ^
- 4 x
- 6 a++
- 8 b
- 10 10 Ket
- 13 End
+ Bra 0
+ ^
+ x
+ a++
+ b
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -3197,17 +3194,17 @@ Options: anchored
No first char
Need char = 'b'
-/^x(?U)(a+)b/D
+/^x(?U)(a+)b/DZ
------------------------------------------------------------------
- 0 18 Bra 0
- 3 ^
- 4 x
- 6 7 Bra 1
- 11 a+?
- 13 7 Ket
- 16 b
- 18 18 Ket
- 21 End
+ Bra 0
+ ^
+ x
+ Bra 1
+ a+?
+ Ket
+ b
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Partial matching not supported
@@ -3248,39 +3245,36 @@ Failed: missing terminating ] for character class at offset 3
/[[:space:]/I
Failed: missing terminating ] for character class at offset 10
-/[\s]/IDM
-Memory allocation (code space): 40
+/[\s]/IDZ
------------------------------------------------------------------
- 0 36 Bra 0
- 3 [\x09\x0a\x0c\x0d ]
- 36 36 Ket
- 39 End
+ Bra 0
+ [\x09\x0a\x0c\x0d ]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/[[:space:]]/IDM
-Memory allocation (code space): 40
+/[[:space:]]/IDZ
------------------------------------------------------------------
- 0 36 Bra 0
- 3 [\x09-\x0d ]
- 36 36 Ket
- 39 End
+ Bra 0
+ [\x09-\x0d ]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/[[:space:]abcde]/IDM
-Memory allocation (code space): 40
+/[[:space:]abcde]/IDZ
------------------------------------------------------------------
- 0 36 Bra 0
- 3 [\x09-\x0d a-e]
- 36 36 Ket
- 39 End
+ Bra 0
+ [\x09-\x0d a-e]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
@@ -3301,37 +3295,35 @@ Need char = '>'
0: <abc <123> hij>
<abc <def> hij>
0: <def>
- <abc<>def>
+ <abc<>def>
0: <abc<>def>
- <abc<>
+ <abc<>
0: <>
*** Failers
No match
<abc
No match
-|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDM
-Memory allocation (code space): 826
+|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDZ
------------------------------------------------------------------
- 0 822 Bra 0
- 3 8J$WE<.rX+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
-821 \b
-822 822 Ket
-825 End
+ Bra 0
+ 8J$WE<.rX+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
+ \b
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
First char = '8'
Need char = 'X'
-|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDM
-Memory allocation (code space): 816
+|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDZ
------------------------------------------------------------------
- 0 812 Bra 0
- 3 $<.X+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
-811 \b
-812 812 Ket
-815 End
+ Bra 0
+ $<.X+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
+ \b
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
@@ -3352,7 +3344,7 @@ Partial matching not supported
No options
First char at start or follows newline
No need char
-
+
/(.*)\d+\1/Is
Capturing subpattern count = 1
Max back reference = 1
@@ -3387,7 +3379,7 @@ No need char
0: bc123bc
1: bc
2: bc
-
+
/a[b]/I
Capturing subpattern count = 0
No options
@@ -3536,11 +3528,11 @@ First char at start or follows newline
Need char = 'a'
abcde
0: a
- xy\nabc
+ xy\nabc
0: a
- *** Failers
+ *** Failers
No match
- xyabc
+ xyabc
No match
/c|abc/I
@@ -3572,7 +3564,7 @@ Need char = 'f'
--->abcdef
0 ^ ^ d
0: abcdef
- 1234abcdef
+ 1234abcdef
--->1234abcdef
0 ^ ^ d
0: abcdef
@@ -3580,7 +3572,7 @@ Need char = 'f'
No match
abcxyz
No match
- abcxyzf
+ abcxyzf
--->abcxyzf
0 ^ ^ d
No match
@@ -3595,8 +3587,8 @@ Need char = 'f'
0 ^ ^ d
1 ^ ^ f
0: abcdef
-
-/(?C1)\dabc(?C2)def/I
+
+/(?C1)\dabc(?C2)def/I
Capturing subpattern count = 0
No options
No first char
@@ -3611,7 +3603,7 @@ Need char = 'f'
0: 4abcdef
*** Failers
No match
- abcdef
+ abcdef
--->abcdef
1 ^ \d
1 ^ \d
@@ -3620,7 +3612,7 @@ No match
1 ^ \d
1 ^ \d
No match
-
+
/(?C255)ab/I
Capturing subpattern count = 0
No options
@@ -3630,7 +3622,7 @@ Need char = 'b'
/(?C256)ab/I
Failed: number after (?C is > 255 at offset 6
-/(?Cab)xx/I
+/(?Cab)xx/I
Failed: closing ) for (?C expected at offset 3
/(?C12vr)x/I
@@ -3659,7 +3651,7 @@ Need char = 'f'
1 ^ ^ f
0: abcdef
1: abc
- 123abcdef\C+
+ 123abcdef\C+
Callout 0: last capture = 1
0: <unset>
1: abc
@@ -3672,17 +3664,17 @@ Callout 1: last capture = 1
^ ^ f
0: abcdef
1: abc
- 123abcdef\C-
+ 123abcdef\C-
0: abcdef
1: abc
*** Failers
No match
- 123abcdef\C!1
+ 123abcdef\C!1
--->123abcdef
0 ^ ^ d
1 ^ ^ f
No match
-
+
/(?C0)(abc(?C1))*/I
Capturing subpattern count = 1
No options
@@ -3696,7 +3688,7 @@ No need char
1 ^ ^ )
0: abcabcabc
1: abc
- abcabc\C!1!3
+ abcabc\C!1!3
--->abcabc
0 ^ (abc(?C1))*
1 ^ ^ )
@@ -3707,7 +3699,7 @@ No need char
--->*** Failers
0 ^ (abc(?C1))*
0:
- abcabcabc\C!1!3
+ abcabcabc\C!1!3
--->abcabcabc
0 ^ (abc(?C1))*
1 ^ ^ )
@@ -3741,7 +3733,7 @@ Callout 0: last capture = 1
^ ^ )
0: 123456
1: 456
- 123456789\C+
+ 123456789\C+
Callout 0: last capture = -1
0: <unset>
--->123456789
@@ -3813,13 +3805,13 @@ Callout 0: last capture = 1
^ a
0: abcdef
1: abc
-
+
/(?!(abc)(?C1)d)(?C2)abcxyz/I
Capturing subpattern count = 1
No options
First char = 'a'
Need char = 'z'
- abcxyz\C+
+ abcxyz\C+
Callout 1: last capture = 1
0: <unset>
1: abc
@@ -3844,7 +3836,7 @@ Callout 0: last capture = 1
^ )
0: xyz
1: abc
-
+
/a(b+)(c*)(?C1)/I
Capturing subpattern count = 2
Partial matching not supported
@@ -3896,8 +3888,8 @@ Callout data = 1
1 ^ ^
Callout data = 1
No match
-
-/(?C)abc/I
+
+/(?C)abc/I
Capturing subpattern count = 0
No options
First char = 'a'
@@ -3954,7 +3946,7 @@ No need char
3: xxab
*** Failers
No match
- xyab
+ xyab
No match
/(ab|(bc|(de|(?1))))/I
@@ -3974,12 +3966,12 @@ No need char
a(b)c
0: a(b)c
1: c
- a(b(c))d
+ a(b(c))d
0: a(b(c))d
1: d
*** Failers)
No match
- a(b(c)d
+ a(b(c)d
No match
/^>abc>([^()]|\((?1)*\))*<xyz<$/I
@@ -3997,36 +3989,36 @@ Need char = '<'
0: >abc>(1(2)3)<xyz<
1: (1(2)3)
-/(a(?1)b)/D
+/(a(?1)b)/DZ
------------------------------------------------------------------
- 0 24 Bra 0
- 3 18 Bra 1
- 8 a
- 10 6 Once
- 13 3 Recurse
- 16 6 Ket
- 19 b
- 21 18 Ket
- 24 24 Ket
- 27 End
+ Bra 0
+ Bra 1
+ a
+ Once
+ Recurse
+ Ket
+ b
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
No options
First char = 'a'
Need char = 'b'
-/(a(?1)+b)/D
+/(a(?1)+b)/DZ
------------------------------------------------------------------
- 0 24 Bra 0
- 3 18 Bra 1
- 8 a
- 10 6 Once
- 13 3 Recurse
- 16 6 KetRmax
- 19 b
- 21 18 Ket
- 24 24 Ket
- 27 End
+ Bra 0
+ Bra 1
+ a
+ Once
+ Recurse
+ KetRmax
+ b
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
No options
@@ -4056,7 +4048,7 @@ No need char
2: <unset>
3: A man, a plan, a canal: Panama
4: A
- Able was I ere I saw Elba.
+ Able was I ere I saw Elba.
0: Able was I ere I saw Elba.
1: <unset>
2: <unset>
@@ -4064,9 +4056,9 @@ No need char
4: A
*** Failers
No match
- The quick brown fox
+ The quick brown fox
No match
-
+
/^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/I
Capturing subpattern count = 2
Partial matching not supported
@@ -4087,7 +4079,7 @@ No need char
No match
((2+2)*-3)-7)
No match
-
+
/^(x(y|(?1){2})z)/I
Capturing subpattern count = 2
Options: anchored
@@ -4097,7 +4089,7 @@ No need char
0: xyz
1: xyz
2: y
- xxyzxyzz
+ xxyzxyzz
0: xxyzxyzz
1: xxyzxyzz
2: xyzxyz
@@ -4105,7 +4097,7 @@ No need char
No match
xxyzz
No match
- xxyzxyzxyzz
+ xxyzxyzxyzz
No match
/((< (?: (?(R) \d++ | [^<>]*+) | (?2)) * >))/Ix
@@ -4130,11 +4122,11 @@ Need char = '>'
0: <def>
1: <def>
2: <def>
- <abc<>def>
+ <abc<>def>
0: <abc<>def>
1: <abc<>def>
2: <abc<>def>
- <abc<>
+ <abc<>
0: <>
1: <>
2: <>
@@ -4169,7 +4161,7 @@ No need char
a=b
0: a=b
1: a
- a=bc
+ a=bc
0: a=bc
1: a
@@ -4186,26 +4178,26 @@ No need char
0: a=b
1: a
2: b
- a=bc
+ a=bc
0: a=bc
1: a
2: c
-/a(?P<name1>b|c)d(?P<longername2>e)/D
-------------------------------------------------------------------
- 0 32 Bra 0
- 3 a
- 5 7 Bra 1
- 10 b
- 12 5 Alt
- 15 c
- 17 12 Ket
- 20 d
- 22 7 Bra 2
- 27 e
- 29 7 Ket
- 32 32 Ket
- 35 End
+/a(?P<name1>b|c)d(?P<longername2>e)/DZ
+------------------------------------------------------------------
+ Bra 0
+ a
+ Bra 1
+ b
+ Alt
+ c
+ Ket
+ d
+ Bra 2
+ e
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 2
Named capturing subpatterns:
@@ -4218,28 +4210,28 @@ Need char = 'e'
0: abde
1: b
2: e
- acde
+ acde
0: acde
1: c
2: e
-/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/D
-------------------------------------------------------------------
- 0 41 Bra 0
- 3 25 Bra 0
- 6 a
- 8 17 Bra 1
- 13 c
- 15 7 Bra 2
- 20 d
- 22 7 Ket
- 25 17 Ket
- 28 25 Ket
- 31 7 Bra 3
- 36 a
- 38 7 Ket
- 41 41 Ket
- 44 End
+/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/DZ
+------------------------------------------------------------------
+ Bra 0
+ Bra 0
+ a
+ Bra 1
+ c
+ Bra 2
+ d
+ Ket
+ Ket
+ Ket
+ Bra 3
+ a
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 3
Named capturing subpatterns:
@@ -4250,23 +4242,23 @@ No options
First char = 'a'
Need char = 'a'
-/(?P<a>a)...(?P=a)bbb(?P>a)d/D
-------------------------------------------------------------------
- 0 36 Bra 0
- 3 7 Bra 1
- 8 a
- 10 7 Ket
- 13 Any
- 14 Any
- 15 Any
- 16 \1
- 19 bbb
- 25 6 Once
- 28 3 Recurse
- 31 6 Ket
- 34 d
- 36 36 Ket
- 39 End
+/(?P<a>a)...(?P=a)bbb(?P>a)d/DZ
+------------------------------------------------------------------
+ Bra 0
+ Bra 1
+ a
+ Ket
+ Any
+ Any
+ Any
+ \1
+ bbb
+ Once
+ Recurse
+ Ket
+ d
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Max back reference = 1
@@ -4304,7 +4296,7 @@ No need char
2: <unset>
3: A man, a plan, a canal: Panama
4: A
- Able was I ere I saw Elba.
+ Able was I ere I saw Elba.
0: Able was I ere I saw Elba.
1: <unset>
2: <unset>
@@ -4312,9 +4304,9 @@ No need char
4: A
*** Failers
No match
- The quick brown fox
+ The quick brown fox
No match
-
+
/((?(R)a|b))\1(?1)?/I
Capturing subpattern count = 1
Max back reference = 1
@@ -4324,7 +4316,7 @@ No need char
bb
0: bb
1: b
- bbaa
+ bbaa
0: bba
1: b
@@ -4413,17 +4405,17 @@ Options: dotall
No first char
No need char
-/(a)(bc)/IND
+/(a)(bc)/INDZ
------------------------------------------------------------------
- 0 21 Bra 0
- 3 5 Bra 0
- 6 a
- 8 5 Ket
- 11 7 Bra 0
- 14 bc
- 18 7 Ket
- 21 21 Ket
- 24 End
+ Bra 0
+ Bra 0
+ a
+ Ket
+ Bra 0
+ bc
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: no_auto_capture
@@ -4432,17 +4424,17 @@ Need char = 'c'
abc
0: abc
-/(?P<one>a)(bc)/IND
+/(?P<one>a)(bc)/INDZ
------------------------------------------------------------------
- 0 23 Bra 0
- 3 7 Bra 1
- 8 a
- 10 7 Ket
- 13 7 Bra 0
- 16 bc
- 20 7 Ket
- 23 23 Ket
- 26 End
+ Bra 0
+ Bra 1
+ a
+ Ket
+ Bra 0
+ bc
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Named capturing subpatterns:
@@ -4454,17 +4446,17 @@ Need char = 'c'
0: abc
1: a
-/(a)(?P<named>bc)/IND
+/(a)(?P<named>bc)/INDZ
------------------------------------------------------------------
- 0 23 Bra 0
- 3 5 Bra 0
- 6 a
- 8 5 Ket
- 11 9 Bra 1
- 16 bc
- 20 9 Ket
- 23 23 Ket
- 26 End
+ Bra 0
+ Bra 0
+ a
+ Ket
+ Bra 1
+ bc
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Named capturing subpatterns:
@@ -4540,22 +4532,22 @@ Need char = 'h'
2: gh
C cd (2) one
C gh (2) two
- abcdefgh\Cthree
+ abcdefgh\Cthree
no parentheses with name "three"
0: abcdefgh
1: cd
2: gh
copy substring three failed -7
-/(?P<Tes>)(?P<Test>)/D
+/(?P<Tes>)(?P<Test>)/DZ
------------------------------------------------------------------
- 0 19 Bra 0
- 3 5 Bra 1
- 8 5 Ket
- 11 5 Bra 2
- 16 5 Ket
- 19 19 Ket
- 22 End
+ Bra 0
+ Bra 1
+ Ket
+ Bra 2
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 2
Named capturing subpatterns:
@@ -4565,15 +4557,15 @@ No options
No first char
No need char
-/(?P<Test>)(?P<Tes>)/D
+/(?P<Test>)(?P<Tes>)/DZ
------------------------------------------------------------------
- 0 19 Bra 0
- 3 5 Bra 1
- 8 5 Ket
- 11 5 Bra 2
- 16 5 Ket
- 19 19 Ket
- 22 End
+ Bra 0
+ Bra 1
+ Ket
+ Bra 2
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 2
Named capturing subpatterns:
@@ -4623,7 +4615,7 @@ Need char = ']'
3: ,4234
*** Failers
No match
- []
+ []
No match
"\[((?P<elem>\d+)(,(?P>elem))*)?\]"I
@@ -4639,96 +4631,96 @@ Need char = ']'
1: 10,20,30,5,5,4,4,2,43,23,4234
2: 10
3: ,4234
- []
+ []
0: []
-/(a(b(?2)c))?/D
-------------------------------------------------------------------
- 0 35 Bra 0
- 3 Brazero
- 4 28 Bra 1
- 9 a
- 11 18 Bra 2
- 16 b
- 18 6 Once
- 21 11 Recurse
- 24 6 Ket
- 27 c
- 29 18 Ket
- 32 28 Ket
- 35 35 Ket
- 38 End
+/(a(b(?2)c))?/DZ
+------------------------------------------------------------------
+ Bra 0
+ Brazero
+ Bra 1
+ a
+ Bra 2
+ b
+ Once
+ Recurse
+ Ket
+ c
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 2
No options
No first char
No need char
-/(a(b(?2)c))*/D
+/(a(b(?2)c))*/DZ
------------------------------------------------------------------
- 0 35 Bra 0
- 3 Brazero
- 4 28 Bra 1
- 9 a
- 11 18 Bra 2
- 16 b
- 18 6 Once
- 21 11 Recurse
- 24 6 Ket
- 27 c
- 29 18 Ket
- 32 28 KetRmax
- 35 35 Ket
- 38 End
+ Bra 0
+ Brazero
+ Bra 1
+ a
+ Bra 2
+ b
+ Once
+ Recurse
+ Ket
+ c
+ Ket
+ KetRmax
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 2
No options
No first char
No need char
-/(a(b(?2)c)){0,2}/D
-------------------------------------------------------------------
- 0 73 Bra 0
- 3 Brazero
- 4 66 Bra 0
- 7 28 Bra 1
- 12 a
- 14 18 Bra 2
- 19 b
- 21 6 Once
- 24 14 Recurse
- 27 6 Ket
- 30 c
- 32 18 Ket
- 35 28 Ket
- 38 Brazero
- 39 28 Bra 1
- 44 a
- 46 18 Bra 2
- 51 b
- 53 6 Once
- 56 14 Recurse
- 59 6 Ket
- 62 c
- 64 18 Ket
- 67 28 Ket
- 70 66 Ket
- 73 73 Ket
- 76 End
+/(a(b(?2)c)){0,2}/DZ
+------------------------------------------------------------------
+ Bra 0
+ Brazero
+ Bra 0
+ Bra 1
+ a
+ Bra 2
+ b
+ Once
+ Recurse
+ Ket
+ c
+ Ket
+ Ket
+ Brazero
+ Bra 1
+ a
+ Bra 2
+ b
+ Once
+ Recurse
+ Ket
+ c
+ Ket
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 2
No options
No first char
No need char
-/[ab]{1}+/D
+/[ab]{1}+/DZ
------------------------------------------------------------------
- 0 47 Bra 0
- 3 41 Once
- 6 [ab]{1,1}
- 44 41 Ket
- 47 47 Ket
- 50 End
+ Bra 0
+ Once
+ [ab]{1,1}
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
@@ -4755,15 +4747,15 @@ Study returned NULL
Baby Bjorn Active Carrier - With free SHIPPING!!
0: Baby Bjorn Active Carrier - With free SHIPPING!!
1: Baby Bjorn Active Carrier - With free SHIPPING!!
-
-/a*.*b/ISD
+
+/a*.*b/ISDZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 a*
- 5 Any*
- 7 b
- 9 9 Ket
- 12 End
+ Bra 0
+ a*
+ Any*
+ b
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -4772,19 +4764,19 @@ No first char
Need char = 'b'
Study returned NULL
-/(a|b)*.?c/ISD
+/(a|b)*.?c/ISDZ
------------------------------------------------------------------
- 0 23 Bra 0
- 3 Brazero
- 4 7 Bra 1
- 9 a
- 11 5 Alt
- 14 b
- 16 12 KetRmax
- 19 Any?
- 21 c
- 23 23 Ket
- 26 End
+ Bra 0
+ Brazero
+ Bra 1
+ a
+ Alt
+ b
+ KetRmax
+ Any?
+ c
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
No options
@@ -4792,38 +4784,38 @@ No first char
Need char = 'c'
Study returned NULL
-/abc(?C255)de(?C)f/D
+/abc(?C255)de(?C)f/DZ
------------------------------------------------------------------
- 0 27 Bra 0
- 3 abc
- 9 Callout 255 10 1
- 15 de
- 19 Callout 0 16 1
- 25 f
- 27 27 Ket
- 30 End
+ Bra 0
+ abc
+ Callout 255 10 1
+ de
+ Callout 0 16 1
+ f
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
First char = 'a'
Need char = 'f'
-/abcde/ICD
+/abcde/ICDZ
------------------------------------------------------------------
- 0 49 Bra 0
- 3 Callout 255 0 1
- 9 a
- 11 Callout 255 1 1
- 17 b
- 19 Callout 255 2 1
- 25 c
- 27 Callout 255 3 1
- 33 d
- 35 Callout 255 4 1
- 41 e
- 43 Callout 255 5 0
- 49 49 Ket
- 52 End
+ Bra 0
+ Callout 255 0 1
+ a
+ Callout 255 1 1
+ b
+ Callout 255 2 1
+ c
+ Callout 255 3 1
+ d
+ Callout 255 4 1
+ e
+ Callout 255 5 0
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options:
@@ -4838,7 +4830,7 @@ Need char = 'e'
+4 ^ ^ e
+5 ^ ^
0: abcde
- abcdfe
+ abcdfe
--->abcdfe
+0 ^ a
+1 ^^ b
@@ -4846,17 +4838,17 @@ Need char = 'e'
+3 ^ ^ d
+4 ^ ^ e
No match
-
-/a*b/ICD
+
+/a*b/ICDZ
------------------------------------------------------------------
- 0 25 Bra 0
- 3 Callout 255 0 2
- 9 a*+
- 11 Callout 255 2 1
- 17 b
- 19 Callout 255 3 0
- 25 25 Ket
- 28 End
+ Bra 0
+ Callout 255 0 2
+ a*+
+ Callout 255 2 1
+ b
+ Callout 255 3 0
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -4875,7 +4867,7 @@ Need char = 'b'
+2 ^ ^ b
+3 ^ ^
0: aaaab
- aaaacb
+ aaaacb
--->aaaacb
+0 ^ a*
+2 ^ ^ b
@@ -4892,16 +4884,16 @@ Need char = 'b'
+3 ^^
0: b
-/a+b/ICD
+/a+b/ICDZ
------------------------------------------------------------------
- 0 25 Bra 0
- 3 Callout 255 0 2
- 9 a++
- 11 Callout 255 2 1
- 17 b
- 19 Callout 255 3 0
- 25 25 Ket
- 28 End
+ Bra 0
+ Callout 255 0 2
+ a++
+ Callout 255 2 1
+ b
+ Callout 255 3 0
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -4920,7 +4912,7 @@ Need char = 'b'
+2 ^ ^ b
+3 ^ ^
0: aaaab
- aaaacb
+ aaaacb
--->aaaacb
+0 ^ a+
+2 ^ ^ b
@@ -4932,32 +4924,32 @@ Need char = 'b'
+2 ^^ b
No match
-/(abc|def)x/ICD
-------------------------------------------------------------------
- 0 94 Bra 0
- 3 Callout 255 0 9
- 9 35 Bra 1
- 14 Callout 255 1 1
- 20 a
- 22 Callout 255 2 1
- 28 b
- 30 Callout 255 3 1
- 36 c
- 38 Callout 255 4 0
- 44 33 Alt
- 47 Callout 255 5 1
- 53 d
- 55 Callout 255 6 1
- 61 e
- 63 Callout 255 7 1
- 69 f
- 71 Callout 255 8 0
- 77 68 Ket
- 80 Callout 255 9 1
- 86 x
- 88 Callout 255 10 0
- 94 94 Ket
- 97 End
+/(abc|def)x/ICDZ
+------------------------------------------------------------------
+ Bra 0
+ Callout 255 0 9
+ Bra 1
+ Callout 255 1 1
+ a
+ Callout 255 2 1
+ b
+ Callout 255 3 1
+ c
+ Callout 255 4 0
+ Alt
+ Callout 255 5 1
+ d
+ Callout 255 6 1
+ e
+ Callout 255 7 1
+ f
+ Callout 255 8 0
+ Ket
+ Callout 255 9 1
+ x
+ Callout 255 10 0
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Options:
@@ -5064,7 +5056,7 @@ No need char
+12 ^ ^
0: abcdabcd
1: cd
- abcdcdcdcdcd
+ abcdcdcdcdcd
--->abcdcdcdcdcd
+0 ^ (ab|cd){3,4}
+1 ^ a
@@ -5086,34 +5078,34 @@ No need char
0: abcdcdcd
1: cd
-/([ab]{,4}c|xy)/ICD
-------------------------------------------------------------------
- 0 133 Bra 0
- 3 Callout 255 0 14
- 9 90 Bra 1
- 14 Callout 255 1 4
- 20 [ab]
- 53 Callout 255 5 1
- 59 {
- 61 Callout 255 6 1
- 67 ,
- 69 Callout 255 7 1
- 75 4
- 77 Callout 255 8 1
- 83 }
- 85 Callout 255 9 1
- 91 c
- 93 Callout 255 10 0
- 99 25 Alt
-102 Callout 255 11 1
-108 x
-110 Callout 255 12 1
-116 y
-118 Callout 255 13 0
-124 115 Ket
-127 Callout 255 14 0
-133 133 Ket
-136 End
+/([ab]{,4}c|xy)/ICDZ
+------------------------------------------------------------------
+ Bra 0
+ Callout 255 0 14
+ Bra 1
+ Callout 255 1 4
+ [ab]
+ Callout 255 5 1
+ {
+ Callout 255 6 1
+ ,
+ Callout 255 7 1
+ 4
+ Callout 255 8 1
+ }
+ Callout 255 9 1
+ c
+ Callout 255 10 0
+ Alt
+ Callout 255 11 1
+ x
+ Callout 255 12 1
+ y
+ Callout 255 13 0
+ Ket
+ Callout 255 14 0
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Options:
@@ -5261,85 +5253,85 @@ No need char
+11 ^ x
No match
-/([ab]{1,4}c|xy){4,5}?123/ICD
-------------------------------------------------------------------
- 0 495 Bra 0
- 3 Callout 255 0 21
- 9 63 Bra 1
- 14 Callout 255 1 9
- 20 [ab]{1,4}
- 58 Callout 255 10 1
- 64 c
- 66 Callout 255 11 0
- 72 25 Alt
- 75 Callout 255 12 1
- 81 x
- 83 Callout 255 13 1
- 89 y
- 91 Callout 255 14 0
- 97 88 Ket
-100 63 Bra 1
-105 Callout 255 1 9
-111 [ab]{1,4}
-149 Callout 255 10 1
-155 c
-157 Callout 255 11 0
-163 25 Alt
-166 Callout 255 12 1
-172 x
-174 Callout 255 13 1
-180 y
-182 Callout 255 14 0
-188 88 Ket
-191 63 Bra 1
-196 Callout 255 1 9
-202 [ab]{1,4}
-240 Callout 255 10 1
-246 c
-248 Callout 255 11 0
-254 25 Alt
-257 Callout 255 12 1
-263 x
-265 Callout 255 13 1
-271 y
-273 Callout 255 14 0
-279 88 Ket
-282 63 Bra 1
-287 Callout 255 1 9
-293 [ab]{1,4}
-331 Callout 255 10 1
-337 c
-339 Callout 255 11 0
-345 25 Alt
-348 Callout 255 12 1
-354 x
-356 Callout 255 13 1
-362 y
-364 Callout 255 14 0
-370 88 Ket
-373 Braminzero
-374 63 Bra 1
-379 Callout 255 1 9
-385 [ab]{1,4}
-423 Callout 255 10 1
-429 c
-431 Callout 255 11 0
-437 25 Alt
-440 Callout 255 12 1
-446 x
-448 Callout 255 13 1
-454 y
-456 Callout 255 14 0
-462 88 Ket
-465 Callout 255 21 1
-471 1
-473 Callout 255 22 1
-479 2
-481 Callout 255 23 1
-487 3
-489 Callout 255 24 0
-495 495 Ket
-498 End
+/([ab]{1,4}c|xy){4,5}?123/ICDZ
+------------------------------------------------------------------
+ Bra 0
+ Callout 255 0 21
+ Bra 1
+ Callout 255 1 9
+ [ab]{1,4}
+ Callout 255 10 1
+ c
+ Callout 255 11 0
+ Alt
+ Callout 255 12 1
+ x
+ Callout 255 13 1
+ y
+ Callout 255 14 0
+ Ket
+ Bra 1
+ Callout 255 1 9
+ [ab]{1,4}
+ Callout 255 10 1
+ c
+ Callout 255 11 0
+ Alt
+ Callout 255 12 1
+ x
+ Callout 255 13 1
+ y
+ Callout 255 14 0
+ Ket
+ Bra 1
+ Callout 255 1 9
+ [ab]{1,4}
+ Callout 255 10 1
+ c
+ Callout 255 11 0
+ Alt
+ Callout 255 12 1
+ x
+ Callout 255 13 1
+ y
+ Callout 255 14 0
+ Ket
+ Bra 1
+ Callout 255 1 9
+ [ab]{1,4}
+ Callout 255 10 1
+ c
+ Callout 255 11 0
+ Alt
+ Callout 255 12 1
+ x
+ Callout 255 13 1
+ y
+ Callout 255 14 0
+ Ket
+ Braminzero
+ Bra 1
+ Callout 255 1 9
+ [ab]{1,4}
+ Callout 255 10 1
+ c
+ Callout 255 11 0
+ Alt
+ Callout 255 12 1
+ x
+ Callout 255 13 1
+ y
+ Callout 255 14 0
+ Ket
+ Callout 255 21 1
+ 1
+ Callout 255 22 1
+ 2
+ Callout 255 23 1
+ 3
+ Callout 255 24 0
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Partial matching not supported
@@ -5380,8 +5372,8 @@ No first char
No need char
ab cd\>1
0: cd
-
-/\b.*/Is
+
+/\b.*/Is
Capturing subpattern count = 0
Partial matching not supported
Options: dotall
@@ -5389,14 +5381,14 @@ No first char
No need char
ab cd\>1
0: cd
-
+
/(?!.bcd).*/I
Capturing subpattern count = 0
Partial matching not supported
No options
No first char
No need char
- Xbcd12345
+ Xbcd12345
0: bcd12345
/abcde/I
@@ -5410,7 +5402,7 @@ Partial match
Partial match
abcd\P
Partial match
- abcde\P
+ abcde\P
0: abcde
the quick brown abc\P
Partial match
@@ -5418,7 +5410,7 @@ Partial match
No match
the quick brown abxyz fox\P
No match
-
+
"^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/(20)?\d\d$"I
Capturing subpattern count = 3
Options: anchored
@@ -5433,7 +5425,7 @@ Need char = '/'
1: 13
2: 5
3: 20
- 02/05/09\P
+ 02/05/09\P
0: 02/05/09
1: 02
2: 05
@@ -5443,7 +5435,7 @@ Partial match
Partial match
1/2/0\P
Partial match
- 1/2/04\P
+ 1/2/04\P
0: 1/2/04
1: 1
2: 2
@@ -5451,7 +5443,7 @@ Partial match
Partial match
02/\P
Partial match
- 02/0\P
+ 02/0\P
Partial match
02/1\P
Partial match
@@ -5467,11 +5459,11 @@ No match
No match
0/1/2003\P
No match
- 0/\P
+ 0/\P
No match
- 02/0/\P
+ 02/0/\P
No match
- 02/13\P
+ 02/13\P
No match
/0{0,2}ABC/I
@@ -5480,14 +5472,14 @@ Partial matching not supported
No options
No first char
Need char = 'C'
-
+
/\d{3,}ABC/I
Capturing subpattern count = 0
Partial matching not supported
No options
No first char
Need char = 'C'
-
+
/\d*ABC/I
Capturing subpattern count = 0
Partial matching not supported
@@ -5517,7 +5509,7 @@ Partial match
Partial match
c12\P
Partial match
- c123\P
+ c123\P
0: c123
/^(?:\d){3,5}X/I
@@ -5537,13 +5529,13 @@ Partial match
0: 1234X
12345\P
Partial match
- 12345X
+ 12345X
0: 12345X
- *** Failers
+ *** Failers
No match
- 1X
+ 1X
No match
- 123456\P
+ 123456\P
No match
/abc/I>testsavedregex
@@ -5561,7 +5553,7 @@ No study data
No match
bca
No match
-
+
/abc/IF>testsavedregex
Capturing subpattern count = 0
No options
@@ -5595,9 +5587,9 @@ Study data loaded from testsavedregex
** Failers
0: a
1: a
- def
+ def
No match
-
+
/(a|b)/ISF>testsavedregex
Capturing subpattern count = 1
No options
@@ -5615,9 +5607,9 @@ Study data loaded from testsavedregex
** Failers
0: a
1: a
- def
+ def
No match
-
+
~<(\w+)/?>(.)*</(\1)>~smgI
Capturing subpattern count = 3
Max back reference = 1
@@ -5644,7 +5636,7 @@ First char = 'l'
Need char = 'k'
this is a line\nbreak
0: line\x0abreak
- line one\nthis is a line\nbreak in the second line
+ line one\nthis is a line\nbreak in the second line
0: line\x0abreak
/line\nbreak/If
@@ -5654,9 +5646,9 @@ First char = 'l'
Need char = 'k'
this is a line\nbreak
0: line\x0abreak
- ** Failers
+ ** Failers
No match
- line one\nthis is a line\nbreak in the second line
+ line one\nthis is a line\nbreak in the second line
No match
/line\nbreak/Imf
@@ -5666,15 +5658,15 @@ First char = 'l'
Need char = 'k'
this is a line\nbreak
0: line\x0abreak
- ** Failers
+ ** Failers
No match
- line one\nthis is a line\nbreak in the second line
+ line one\nthis is a line\nbreak in the second line
No match
/ab.cd/IP
ab-cd
0: ab-cd
- ab=cd
+ ab=cd
0: ab=cd
** Failers
No match: POSIX code 17: match failed
@@ -5684,7 +5676,7 @@ No match: POSIX code 17: match failed
/ab.cd/IPs
ab-cd
0: ab-cd
- ab=cd
+ ab=cd
0: ab=cd
ab\ncd
0: ab\x0acd
@@ -5698,9 +5690,9 @@ Need char = 'd'
0: AbCd
** Failers
No match
- abcd
+ abcd
No match
-
+
/a{11111111111111111111}/I
Failed: number too big in {} quantifier at offset 22
@@ -5931,7 +5923,7 @@ No first char
No need char
(this(and)that
0:
- (this(and)that)
+ (this(and)that)
0: (this(and)that)
(this(and)that)stuff
0: (this(and)that)stuff
@@ -5944,9 +5936,9 @@ No first char
No need char
(this(and)that
0:
- (this(and)that)
+ (this(and)that)
0: (this(and)that)
-
+
/[^()]*(?:\((?R)\))*[^()]*/I
Capturing subpattern count = 0
Partial matching not supported
@@ -5955,7 +5947,7 @@ No first char
No need char
(this(and)that
0:
- (this(and)that)
+ (this(and)that)
0: (this(and)that)
/(?:\((?R)\))*[^()]*/I
@@ -5966,9 +5958,9 @@ No first char
No need char
(this(and)that
0:
- (this(and)that)
+ (this(and)that)
0:
- ((this))
+ ((this))
0: ((this))
/(?:\((?R)\))|[^()]*/I
@@ -5979,22 +5971,22 @@ No first char
No need char
(this(and)that
0:
- (this(and)that)
+ (this(and)that)
0:
(this)
0: (this)
- ((this))
+ ((this))
0: ((this))
-
+
/a(b)c/IPN
abc
Matched with REG_NOSUB
-
+
/a(?P<name>b)c/IPN
- abc
+ abc
Matched with REG_NOSUB
-
-/\x{100}/I
+
+/\x{100}/I
Failed: character value in \x{...} sequence is too large at offset 6
/\x{0000ff}/I
@@ -6019,7 +6011,7 @@ No need char
1: a1
2: a1
C a1 (2) A
- a2b\CA
+ a2b\CA
0: a2b
1: a2b
2: <unset>
@@ -6027,14 +6019,14 @@ No need char
C a2 (2) A
** Failers
No match
- a1b\CZ\CA
+ a1b\CZ\CA
no parentheses with name "Z"
0: a1
1: a1
2: a1
copy substring Z failed -7
C a1 (2) A
-
+
/^(?P<A>a)(?P<A>b)/IJ
Capturing subpattern count = 2
Named capturing subpatterns:
@@ -6048,7 +6040,7 @@ No need char
1: a
2: b
C a (1) A
-
+
/^(?P<A>a)(?P<A>b)|cd/IJ
Capturing subpattern count = 2
Named capturing subpatterns:
@@ -6062,10 +6054,10 @@ No need char
1: a
2: b
C a (1) A
- cd\CA
+ cd\CA
0: cd
copy substring A failed -7
-
+
/^(?P<A>a)(?P<A>b)|cd(?P<A>ef)(?P<A>gh)/IJ
Capturing subpattern count = 4
Named capturing subpatterns:
@@ -6076,14 +6068,14 @@ Named capturing subpatterns:
Options: dupnames
No first char
No need char
- cdefgh\CA
+ cdefgh\CA
0: cdefgh
1: <unset>
2: <unset>
3: ef
4: gh
C ef (2) A
-
+
/^((?P<A>a1)|(?P<A>a2)b)/IJ
Capturing subpattern count = 3
Named capturing subpatterns:
@@ -6097,7 +6089,7 @@ No need char
1: a1
2: a1
G a1 (2) A
- a2b\GA
+ a2b\GA
0: a2b
1: a2b
2: <unset>
@@ -6105,14 +6097,14 @@ No need char
G a2 (2) A
** Failers
No match
- a1b\GZ\GA
+ a1b\GZ\GA
no parentheses with name "Z"
0: a1
1: a1
2: a1
copy substring Z failed -7
G a1 (2) A
-
+
/^(?P<A>a)(?P<A>b)/IJ
Capturing subpattern count = 2
Named capturing subpatterns:
@@ -6126,7 +6118,7 @@ No need char
1: a
2: b
G a (1) A
-
+
/^(?P<A>a)(?P<A>b)|cd/IJ
Capturing subpattern count = 2
Named capturing subpatterns:
@@ -6140,10 +6132,10 @@ No need char
1: a
2: b
G a (1) A
- cd\GA
+ cd\GA
0: cd
copy substring A failed -7
-
+
/^(?P<A>a)(?P<A>b)|cd(?P<A>ef)(?P<A>gh)/IJ
Capturing subpattern count = 4
Named capturing subpatterns:
@@ -6154,14 +6146,14 @@ Named capturing subpatterns:
Options: dupnames
No first char
No need char
- cdefgh\GA
+ cdefgh\GA
0: cdefgh
1: <unset>
2: <unset>
3: ef
4: gh
G ef (2) A
-
+
/(?J)^((?P<A>a1)|(?P<A>a2)b)/I
Capturing subpattern count = 3
Named capturing subpatterns:
@@ -6175,18 +6167,18 @@ No need char
1: a1
2: a1
C a1 (2) A
- a2b\CA
+ a2b\CA
0: a2b
1: a2b
2: <unset>
3: a2
C a2 (2) A
-
+
/^(?P<A>a) (?J:(?P<B>b)(?P<B>c)) (?P<A>d)/I
Failed: two named subpatterns have the same name at offset 37
/ In this next test, J is not set at the outer level; consequently it isn't
-set in the pattern's options; consequently pcre_get_named_substring() produces
+set in the pattern's options; consequently pcre_get_named_substring() produces
a random value. /Ix
Capturing subpattern count = 1
Options: extended
@@ -6201,6 +6193,7 @@ Named capturing subpatterns:
B 3
C 4
Options: anchored
+Duplicate name status changes
No first char
No need char
a bc d\CA\CB\CC
@@ -6227,7 +6220,7 @@ No need char
0: b
** Failers
No match
- abc
+ abc
No match
/(?:(?(ZZ)a|b)(?P<ZZ>X))+/I
@@ -6283,7 +6276,7 @@ No need char
bXXaYYaY
0: bXXaYYaY
1: Y
- bXYaXXaX
+ bXYaXXaX
0: bX
1: X
@@ -6320,7 +6313,7 @@ Need char = ','
Starting byte set: \x09 \x0a \x0c \x0d \x20 ,
\x0b,\x0b
0: ,
- \x0c,\x0d
+ \x0c,\x0d
0: \x0c,\x0d
/^abc/Im
@@ -6338,7 +6331,7 @@ Need char = 'c'
0: abc
xyz\r\nabc\<crlf>
0: abc
- ** Failers
+ ** Failers
No match
xyz\nabc\<cr>
No match
@@ -6350,7 +6343,7 @@ No match
No match
xyz\rabc\<lf>
No match
-
+
/abc$/Im<lf>
Capturing subpattern count = 0
Options: multiline
@@ -6359,29 +6352,29 @@ First char = 'a'
Need char = 'c'
xyzabc
0: abc
- xyzabc\n
+ xyzabc\n
0: abc
- xyzabc\npqr
+ xyzabc\npqr
0: abc
- xyzabc\r\<cr>
+ xyzabc\r\<cr>
0: abc
- xyzabc\rpqr\<cr>
+ xyzabc\rpqr\<cr>
0: abc
- xyzabc\r\n\<crlf>
+ xyzabc\r\n\<crlf>
0: abc
- xyzabc\r\npqr\<crlf>
+ xyzabc\r\npqr\<crlf>
0: abc
** Failers
No match
- xyzabc\r
+ xyzabc\r
No match
- xyzabc\rpqr
+ xyzabc\rpqr
No match
- xyzabc\r\n
+ xyzabc\r\n
No match
- xyzabc\r\npqr
+ xyzabc\r\npqr
No match
-
+
/^abc/Im<cr>
Capturing subpattern count = 0
Options: multiline
@@ -6392,11 +6385,11 @@ Need char = 'c'
0: abc
xyz\nabcdef\<lf>
0: abc
- ** Failers
+ ** Failers
No match
xyz\nabcdef
No match
-
+
/^abc/Im<lf>
Capturing subpattern count = 0
Options: multiline
@@ -6407,11 +6400,11 @@ Need char = 'c'
0: abc
xyz\rabcdef\<cr>
0: abc
- ** Failers
+ ** Failers
No match
xyz\rabcdef
No match
-
+
/^abc/Im<crlf>
Capturing subpattern count = 0
Options: multiline
@@ -6422,11 +6415,11 @@ Need char = 'c'
0: abc
xyz\rabcdef\<cr>
0: abc
- ** Failers
+ ** Failers
No match
xyz\rabcdef
No match
-
+
/^abc/Im<bad>
Unknown newline type at: <bad>
@@ -6438,9 +6431,9 @@ First char = 'a'
Need char = 'c'
xyz\rabc\<bad>
Unknown newline type at: <bad>
- abc
+ abc
0: abc
-
+
/.*/I<lf>
Capturing subpattern count = 0
Partial matching not supported
@@ -6514,7 +6507,7 @@ Capturing subpattern count = 102
Options: extended
No first char
No need char
- XY\O400
+ XY\O400
0: XY
1:
2:
@@ -6669,15 +6662,15 @@ No first char
Need char = 'z'
Starting byte set: a b c d
-/^a*b\d/D
+/^a*b\d/DZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 ^
- 4 a*+
- 6 b
- 8 \d
- 9 9 Ket
- 12 End
+ Bra 0
+ ^
+ a*+
+ b
+ \d
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -6685,15 +6678,15 @@ Options: anchored
No first char
Need char = 'b'
-/^a*+b\d/D
+/^a*+b\d/DZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 ^
- 4 a*+
- 6 b
- 8 \d
- 9 9 Ket
- 12 End
+ Bra 0
+ ^
+ a*+
+ b
+ \d
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -6701,15 +6694,15 @@ Options: anchored
No first char
Need char = 'b'
-/^a*?b\d/D
+/^a*?b\d/DZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 ^
- 4 a*+
- 6 b
- 8 \d
- 9 9 Ket
- 12 End
+ Bra 0
+ ^
+ a*+
+ b
+ \d
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -6717,15 +6710,15 @@ Options: anchored
No first char
Need char = 'b'
-/^a+A\d/D
+/^a+A\d/DZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 ^
- 4 a++
- 6 A
- 8 \d
- 9 9 Ket
- 12 End
+ Bra 0
+ ^
+ a++
+ A
+ \d
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -6736,18 +6729,18 @@ Need char = 'A'
0: aaaA5
** Failers
No match
- aaaa5
+ aaaa5
No match
-/^a*A\d/IiD
+/^a*A\d/IiDZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 ^
- 4 a*
- 6 NC A
- 8 \d
- 9 9 Ket
- 12 End
+ Bra 0
+ ^
+ a*
+ NC A
+ \d
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -6797,8 +6790,8 @@ Starting byte set: a b
a
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
- )))
-/Ix
+ )))
+/Ix
Capturing subpattern count = 203
Options: extended
First char = 'a'
@@ -6821,598 +6814,598 @@ Matched, but too many substrings
13: a
14: a
-/a*\d/B
+/a*\d/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 a*+
- 5 \d
- 6 6 Ket
- 9 End
+ Bra 0
+ a*+
+ \d
+ Ket
+ End
------------------------------------------------------------------
-/a*\D/B
+/a*\D/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 a*
- 5 \D
- 6 6 Ket
- 9 End
+ Bra 0
+ a*
+ \D
+ Ket
+ End
------------------------------------------------------------------
-/0*\d/B
+/0*\d/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 0*
- 5 \d
- 6 6 Ket
- 9 End
+ Bra 0
+ 0*
+ \d
+ Ket
+ End
------------------------------------------------------------------
-/0*\D/B
+/0*\D/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 0*+
- 5 \D
- 6 6 Ket
- 9 End
+ Bra 0
+ 0*+
+ \D
+ Ket
+ End
------------------------------------------------------------------
-/a*\s/B
+/a*\s/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 a*+
- 5 \s
- 6 6 Ket
- 9 End
+ Bra 0
+ a*+
+ \s
+ Ket
+ End
------------------------------------------------------------------
-/a*\S/B
+/a*\S/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 a*
- 5 \S
- 6 6 Ket
- 9 End
+ Bra 0
+ a*
+ \S
+ Ket
+ End
------------------------------------------------------------------
-/ *\s/B
+/ *\s/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 *
- 5 \s
- 6 6 Ket
- 9 End
+ Bra 0
+ *
+ \s
+ Ket
+ End
------------------------------------------------------------------
-/ *\S/B
+/ *\S/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 *+
- 5 \S
- 6 6 Ket
- 9 End
+ Bra 0
+ *+
+ \S
+ Ket
+ End
------------------------------------------------------------------
-/a*\w/B
+/a*\w/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 a*
- 5 \w
- 6 6 Ket
- 9 End
+ Bra 0
+ a*
+ \w
+ Ket
+ End
------------------------------------------------------------------
-/a*\W/B
+/a*\W/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 a*+
- 5 \W
- 6 6 Ket
- 9 End
+ Bra 0
+ a*+
+ \W
+ Ket
+ End
------------------------------------------------------------------
-/=*\w/B
+/=*\w/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 =*+
- 5 \w
- 6 6 Ket
- 9 End
+ Bra 0
+ =*+
+ \w
+ Ket
+ End
------------------------------------------------------------------
-/=*\W/B
+/=*\W/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 =*
- 5 \W
- 6 6 Ket
- 9 End
+ Bra 0
+ =*
+ \W
+ Ket
+ End
------------------------------------------------------------------
-/\d*a/B
+/\d*a/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \d*+
- 5 a
- 7 7 Ket
- 10 End
+ Bra 0
+ \d*+
+ a
+ Ket
+ End
------------------------------------------------------------------
-/\d*2/B
+/\d*2/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \d*
- 5 2
- 7 7 Ket
- 10 End
+ Bra 0
+ \d*
+ 2
+ Ket
+ End
------------------------------------------------------------------
-/\d*\d/B
+/\d*\d/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \d*
- 5 \d
- 6 6 Ket
- 9 End
+ Bra 0
+ \d*
+ \d
+ Ket
+ End
------------------------------------------------------------------
-/\d*\D/B
+/\d*\D/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \d*+
- 5 \D
- 6 6 Ket
- 9 End
+ Bra 0
+ \d*+
+ \D
+ Ket
+ End
------------------------------------------------------------------
-/\d*\s/B
+/\d*\s/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \d*+
- 5 \s
- 6 6 Ket
- 9 End
+ Bra 0
+ \d*+
+ \s
+ Ket
+ End
------------------------------------------------------------------
-/\d*\S/B
+/\d*\S/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \d*
- 5 \S
- 6 6 Ket
- 9 End
+ Bra 0
+ \d*
+ \S
+ Ket
+ End
------------------------------------------------------------------
-/\d*\w/B
+/\d*\w/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \d*
- 5 \w
- 6 6 Ket
- 9 End
+ Bra 0
+ \d*
+ \w
+ Ket
+ End
------------------------------------------------------------------
-/\d*\W/B
+/\d*\W/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \d*+
- 5 \W
- 6 6 Ket
- 9 End
+ Bra 0
+ \d*+
+ \W
+ Ket
+ End
------------------------------------------------------------------
-/\D*a/B
+/\D*a/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \D*
- 5 a
- 7 7 Ket
- 10 End
+ Bra 0
+ \D*
+ a
+ Ket
+ End
------------------------------------------------------------------
-/\D*2/B
+/\D*2/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \D*+
- 5 2
- 7 7 Ket
- 10 End
+ Bra 0
+ \D*+
+ 2
+ Ket
+ End
------------------------------------------------------------------
-/\D*\d/B
+/\D*\d/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \D*+
- 5 \d
- 6 6 Ket
- 9 End
+ Bra 0
+ \D*+
+ \d
+ Ket
+ End
------------------------------------------------------------------
-/\D*\D/B
+/\D*\D/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \D*
- 5 \D
- 6 6 Ket
- 9 End
+ Bra 0
+ \D*
+ \D
+ Ket
+ End
------------------------------------------------------------------
-/\D*\s/B
+/\D*\s/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \D*
- 5 \s
- 6 6 Ket
- 9 End
+ Bra 0
+ \D*
+ \s
+ Ket
+ End
------------------------------------------------------------------
-/\D*\S/B
+/\D*\S/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \D*
- 5 \S
- 6 6 Ket
- 9 End
+ Bra 0
+ \D*
+ \S
+ Ket
+ End
------------------------------------------------------------------
-/\D*\w/B
+/\D*\w/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \D*
- 5 \w
- 6 6 Ket
- 9 End
+ Bra 0
+ \D*
+ \w
+ Ket
+ End
------------------------------------------------------------------
-/\D*\W/B
+/\D*\W/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \D*
- 5 \W
- 6 6 Ket
- 9 End
+ Bra 0
+ \D*
+ \W
+ Ket
+ End
------------------------------------------------------------------
-/\s*a/B
+/\s*a/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \s*+
- 5 a
- 7 7 Ket
- 10 End
+ Bra 0
+ \s*+
+ a
+ Ket
+ End
------------------------------------------------------------------
-/\s*2/B
+/\s*2/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \s*+
- 5 2
- 7 7 Ket
- 10 End
+ Bra 0
+ \s*+
+ 2
+ Ket
+ End
------------------------------------------------------------------
-/\s*\d/B
+/\s*\d/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \s*+
- 5 \d
- 6 6 Ket
- 9 End
+ Bra 0
+ \s*+
+ \d
+ Ket
+ End
------------------------------------------------------------------
-/\s*\D/B
+/\s*\D/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \s*
- 5 \D
- 6 6 Ket
- 9 End
+ Bra 0
+ \s*
+ \D
+ Ket
+ End
------------------------------------------------------------------
-/\s*\s/B
+/\s*\s/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \s*
- 5 \s
- 6 6 Ket
- 9 End
+ Bra 0
+ \s*
+ \s
+ Ket
+ End
------------------------------------------------------------------
-/\s*\S/B
+/\s*\S/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \s*+
- 5 \S
- 6 6 Ket
- 9 End
+ Bra 0
+ \s*+
+ \S
+ Ket
+ End
------------------------------------------------------------------
-/\s*\w/B
+/\s*\w/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \s*+
- 5 \w
- 6 6 Ket
- 9 End
+ Bra 0
+ \s*+
+ \w
+ Ket
+ End
------------------------------------------------------------------
-/\s*\W/B
+/\s*\W/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \s*
- 5 \W
- 6 6 Ket
- 9 End
+ Bra 0
+ \s*
+ \W
+ Ket
+ End
------------------------------------------------------------------
-/\S*a/B
+/\S*a/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \S*
- 5 a
- 7 7 Ket
- 10 End
+ Bra 0
+ \S*
+ a
+ Ket
+ End
------------------------------------------------------------------
-/\S*2/B
+/\S*2/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \S*
- 5 2
- 7 7 Ket
- 10 End
+ Bra 0
+ \S*
+ 2
+ Ket
+ End
------------------------------------------------------------------
-/\S*\d/B
+/\S*\d/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \S*
- 5 \d
- 6 6 Ket
- 9 End
+ Bra 0
+ \S*
+ \d
+ Ket
+ End
------------------------------------------------------------------
-/\S*\D/B
+/\S*\D/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \S*
- 5 \D
- 6 6 Ket
- 9 End
+ Bra 0
+ \S*
+ \D
+ Ket
+ End
------------------------------------------------------------------
-/\S*\s/B
+/\S*\s/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \S*+
- 5 \s
- 6 6 Ket
- 9 End
+ Bra 0
+ \S*+
+ \s
+ Ket
+ End
------------------------------------------------------------------
-/\S*\S/B
+/\S*\S/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \S*
- 5 \S
- 6 6 Ket
- 9 End
+ Bra 0
+ \S*
+ \S
+ Ket
+ End
------------------------------------------------------------------
-/\S*\w/B
+/\S*\w/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \S*
- 5 \w
- 6 6 Ket
- 9 End
+ Bra 0
+ \S*
+ \w
+ Ket
+ End
------------------------------------------------------------------
-/\S*\W/B
+/\S*\W/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \S*
- 5 \W
- 6 6 Ket
- 9 End
+ Bra 0
+ \S*
+ \W
+ Ket
+ End
------------------------------------------------------------------
-/\w*a/B
+/\w*a/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \w*
- 5 a
- 7 7 Ket
- 10 End
+ Bra 0
+ \w*
+ a
+ Ket
+ End
------------------------------------------------------------------
-/\w*2/B
+/\w*2/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \w*
- 5 2
- 7 7 Ket
- 10 End
+ Bra 0
+ \w*
+ 2
+ Ket
+ End
------------------------------------------------------------------
-/\w*\d/B
+/\w*\d/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \w*
- 5 \d
- 6 6 Ket
- 9 End
+ Bra 0
+ \w*
+ \d
+ Ket
+ End
------------------------------------------------------------------
-/\w*\D/B
+/\w*\D/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \w*
- 5 \D
- 6 6 Ket
- 9 End
+ Bra 0
+ \w*
+ \D
+ Ket
+ End
------------------------------------------------------------------
-/\w*\s/B
+/\w*\s/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \w*+
- 5 \s
- 6 6 Ket
- 9 End
+ Bra 0
+ \w*+
+ \s
+ Ket
+ End
------------------------------------------------------------------
-/\w*\S/B
+/\w*\S/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \w*
- 5 \S
- 6 6 Ket
- 9 End
+ Bra 0
+ \w*
+ \S
+ Ket
+ End
------------------------------------------------------------------
-/\w*\w/B
+/\w*\w/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \w*
- 5 \w
- 6 6 Ket
- 9 End
+ Bra 0
+ \w*
+ \w
+ Ket
+ End
------------------------------------------------------------------
-/\w*\W/B
+/\w*\W/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \w*+
- 5 \W
- 6 6 Ket
- 9 End
+ Bra 0
+ \w*+
+ \W
+ Ket
+ End
------------------------------------------------------------------
-/\W*a/B
+/\W*a/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \W*+
- 5 a
- 7 7 Ket
- 10 End
+ Bra 0
+ \W*+
+ a
+ Ket
+ End
------------------------------------------------------------------
-/\W*2/B
+/\W*2/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \W*+
- 5 2
- 7 7 Ket
- 10 End
+ Bra 0
+ \W*+
+ 2
+ Ket
+ End
------------------------------------------------------------------
-/\W*\d/B
+/\W*\d/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \W*+
- 5 \d
- 6 6 Ket
- 9 End
+ Bra 0
+ \W*+
+ \d
+ Ket
+ End
------------------------------------------------------------------
-/\W*\D/B
+/\W*\D/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \W*
- 5 \D
- 6 6 Ket
- 9 End
+ Bra 0
+ \W*
+ \D
+ Ket
+ End
------------------------------------------------------------------
-/\W*\s/B
+/\W*\s/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \W*
- 5 \s
- 6 6 Ket
- 9 End
+ Bra 0
+ \W*
+ \s
+ Ket
+ End
------------------------------------------------------------------
-/\W*\S/B
+/\W*\S/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \W*
- 5 \S
- 6 6 Ket
- 9 End
+ Bra 0
+ \W*
+ \S
+ Ket
+ End
------------------------------------------------------------------
-/\W*\w/B
+/\W*\w/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \W*+
- 5 \w
- 6 6 Ket
- 9 End
+ Bra 0
+ \W*+
+ \w
+ Ket
+ End
------------------------------------------------------------------
-/\W*\W/B
+/\W*\W/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \W*
- 5 \W
- 6 6 Ket
- 9 End
+ Bra 0
+ \W*
+ \W
+ Ket
+ End
------------------------------------------------------------------
-/[^a]+a/B
+/[^a]+a/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 [^a]++
- 5 a
- 7 7 Ket
- 10 End
+ Bra 0
+ [^a]++
+ a
+ Ket
+ End
------------------------------------------------------------------
-/[^a]+a/Bi
+/[^a]+a/BZi
------------------------------------------------------------------
- 0 7 Bra 0
- 3 [^A]++
- 5 NC a
- 7 7 Ket
- 10 End
+ Bra 0
+ [^A]++
+ NC a
+ Ket
+ End
------------------------------------------------------------------
-/[^a]+A/Bi
+/[^a]+A/BZi
------------------------------------------------------------------
- 0 7 Bra 0
- 3 [^A]++
- 5 NC A
- 7 7 Ket
- 10 End
+ Bra 0
+ [^A]++
+ NC A
+ Ket
+ End
------------------------------------------------------------------
-/[^a]+b/B
+/[^a]+b/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 [^a]+
- 5 b
- 7 7 Ket
- 10 End
+ Bra 0
+ [^a]+
+ b
+ Ket
+ End
------------------------------------------------------------------
-/[^a]+\d/B
+/[^a]+\d/BZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 [^a]+
- 5 \d
- 6 6 Ket
- 9 End
+ Bra 0
+ [^a]+
+ \d
+ Ket
+ End
------------------------------------------------------------------
-/a*[^a]/B
+/a*[^a]/BZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 a*
- 5 [^a]
- 7 7 Ket
- 10 End
+ Bra 0
+ a*
+ [^a]
+ Ket
+ End
------------------------------------------------------------------
/(?P<abc>x)(?P<xyz>y)/I
@@ -7463,9 +7456,9 @@ Failed: unrecognized character after (?P at offset 3
1: X
** Failers
No match
- aXaX
+ aXaX
No match
- aXbX
+ aXbX
No match
/^(?P>abc)(?<abcd>xxx)/
@@ -7481,7 +7474,7 @@ Failed: reference to non-existent subpattern at offset 8
yy
0: yy
1: y
- yx
+ yx
0: yx
1: x
@@ -7495,7 +7488,7 @@ Failed: reference to non-existent subpattern at offset 8
yy
0: yy
1: y
- yx
+ yx
0: yx
1: x
@@ -7504,13 +7497,13 @@ Failed: reference to non-existent subpattern at offset 8
0: bxay
1: ay
2: y
- bxby
+ bxby
0: bx
1: bx
2: x
** Failers
No match
- axby
+ axby
No match
/^(((?P=abc)|X)(?<abc>x|y))+/
@@ -7531,7 +7524,7 @@ No match
3: y
** Failers
No match
- x
+ x
No match
/^(?1)(abc)/
@@ -7543,113 +7536,113 @@ No match
Xaaa
0: Xaaa
1: a
- Xaba
+ Xaba
0: Xa
1: a
-/^[\E\Qa\E-\Qz\E]+/B
+/^[\E\Qa\E-\Qz\E]+/BZ
------------------------------------------------------------------
- 0 38 Bra 0
- 3 ^
- 4 [a-z]+
- 38 38 Ket
- 41 End
+ Bra 0
+ ^
+ [a-z]+
+ Ket
+ End
------------------------------------------------------------------
-
-/^[a\Q]bc\E]/B
+
+/^[a\Q]bc\E]/BZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\]a-c]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\]a-c]
+ Ket
+ End
------------------------------------------------------------------
-
-/^[a-\Q\E]/B
-------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\-a]
- 37 37 Ket
- 40 End
-------------------------------------------------------------------
-
-/^(?P>abc)[()](?<abc>)/B
-------------------------------------------------------------------
- 0 54 Bra 0
- 3 ^
- 4 6 Once
- 7 46 Recurse
- 10 6 Ket
- 13 [()]
- 46 5 Bra 1
- 51 5 Ket
- 54 54 Ket
- 57 End
-------------------------------------------------------------------
-
-/^((?(abc)y)[()](?P<abc>x))+/B
-------------------------------------------------------------------
- 0 66 Bra 0
- 3 ^
- 4 59 Bra 1
- 9 8 Cond
- 12 2 Cond ref
- 15 y
- 17 8 Ket
- 20 [()]
- 53 7 Bra 2
- 58 x
- 60 7 Ket
- 63 59 KetRmax
- 66 66 Ket
- 69 End
+
+/^[a-\Q\E]/BZ
+------------------------------------------------------------------
+ Bra 0
+ ^
+ [\-a]
+ Ket
+ End
+------------------------------------------------------------------
+
+/^(?P>abc)[()](?<abc>)/BZ
+------------------------------------------------------------------
+ Bra 0
+ ^
+ Once
+ Recurse
+ Ket
+ [()]
+ Bra 1
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+
+/^((?(abc)y)[()](?P<abc>x))+/BZ
+------------------------------------------------------------------
+ Bra 0
+ ^
+ Bra 1
+ Cond
+ 2 Cond ref
+ y
+ Ket
+ [()]
+ Bra 2
+ x
+ Ket
+ KetRmax
+ Ket
+ End
------------------------------------------------------------------
(xy)x
0: (xy)x
1: y)x
2: x
-
-/^(?P>abc)\Q()\E(?<abc>)/B
-------------------------------------------------------------------
- 0 25 Bra 0
- 3 ^
- 4 6 Once
- 7 17 Recurse
- 10 6 Ket
- 13 ()
- 17 5 Bra 1
- 22 5 Ket
- 25 25 Ket
- 28 End
-------------------------------------------------------------------
-
-/^(?P>abc)[a\Q(]\E(](?<abc>)/B
-------------------------------------------------------------------
- 0 54 Bra 0
- 3 ^
- 4 6 Once
- 7 46 Recurse
- 10 6 Ket
- 13 [(\]a]
- 46 5 Bra 1
- 51 5 Ket
- 54 54 Ket
- 57 End
+
+/^(?P>abc)\Q()\E(?<abc>)/BZ
+------------------------------------------------------------------
+ Bra 0
+ ^
+ Once
+ Recurse
+ Ket
+ ()
+ Bra 1
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+
+/^(?P>abc)[a\Q(]\E(](?<abc>)/BZ
+------------------------------------------------------------------
+ Bra 0
+ ^
+ Once
+ Recurse
+ Ket
+ [(\]a]
+ Bra 1
+ Ket
+ Ket
+ End
------------------------------------------------------------------
/^(?P>abc) # this is (a comment)
- (?<abc>)/Bx
+ (?<abc>)/BZx
------------------------------------------------------------------
- 0 21 Bra 0
- 3 ^
- 4 6 Once
- 7 13 Recurse
- 10 6 Ket
- 13 5 Bra 1
- 18 5 Ket
- 21 21 Ket
- 24 End
+ Bra 0
+ ^
+ Once
+ Recurse
+ Ket
+ Bra 1
+ Ket
+ Ket
+ End
------------------------------------------------------------------
/^\W*(?:(?<one>(?<two>.)\W*(?&one)\W*\k<two>|)|(?<three>(?<four>.)\W*(?&three)\W*\k'four'|\W*.\W*))\W*$/Ii
@@ -7680,7 +7673,7 @@ No need char
2: <unset>
3: A man, a plan, a canal: Panama
4: A
- Able was I ere I saw Elba.
+ Able was I ere I saw Elba.
0: Able was I ere I saw Elba.
1: <unset>
2: <unset>
@@ -7688,9 +7681,9 @@ No need char
4: A
*** Failers
No match
- The quick brown fox
+ The quick brown fox
No match
-
+
/(?=(\w+))\1:/I
Capturing subpattern count = 1
Max back reference = 1
@@ -7724,9 +7717,9 @@ Need char = ':'
1: ab
** Failers
No match
- a:axyz
+ a:axyz
No match
- ab:abxyz
+ ab:abxyz
No match
/(?'abc'a|b)(?<abc>d|e)\k<abc>{2}/J
@@ -7738,7 +7731,7 @@ No match
No match
addd
No match
- adbb
+ adbb
No match
/(?'abc'a|b)(?<abc>d|e)(?&abc){2}/J
@@ -7752,20 +7745,20 @@ No match
2: d
** Failers
No match
- bddd
+ bddd
No match
/^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
abd
0: abd
1: a
- ce
+ ce
0: ce
-
+
/(?(<bc))/
Failed: malformed number or name after (?( at offset 6
-/(?(''))/
+/(?(''))/
Failed: assertion expected after (?( at offset 4
/(?('R')stuff)/
@@ -7797,7 +7790,7 @@ Failed: reference to non-existent subpattern at offset 29
0: ab
1: <unset>
2: <unset>
-
+
/(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
(?(DEFINE)
(?<NAME_PAT>[a-z]+)
@@ -7809,7 +7802,7 @@ Failed: reference to non-existent subpattern at offset 29
2: 33
3: <unset>
4: <unset>
-
+
/^(?(DEFINE) abc | xyz ) /x
Failed: DEFINE group contains more than one branch at offset 22
@@ -7831,17 +7824,23 @@ Matched, but too many substrings
/^a.b/<lf>
a\rb
0: a\x0db
- a\nb\<cr>
+ a\nb\<cr>
0: a\x0ab
+ a\x85b\<anycrlf>
+ 0: a\x85b
** Failers
No match
a\nb
No match
a\nb\<any>
No match
- a\rb\<cr>
+ a\rb\<cr>
+No match
+ a\rb\<any>
No match
- a\rb\<any>
+ a\x85b\<any>
+No match
+ a\rb\<anycrlf>
No match
/^abc./mgx<any>
@@ -7865,7 +7864,6 @@ No match
0: abc9
/a/<cr><any>
-Failed: inconsistent NEWLINE options at offset 0
/a/<any><crlf>
Failed: inconsistent NEWLINE options at offset 0
@@ -7881,11 +7879,11 @@ Failed: inconsistent NEWLINE options at offset 0
0: a\x0bb
a\x0cb
0: a\x0cb
- a\x85b
+ a\x85b
0: a\x85b
** Failers
No match
- a\n\rb
+ a\n\rb
No match
/^a\R*b/
@@ -7901,11 +7899,11 @@ No match
0: a\x0bb
a\x0cb
0: a\x0cb
- a\x85b
+ a\x85b
0: a\x85b
- a\n\rb
+ a\n\rb
0: a\x0a\x0db
- a\n\r\x85\x0cb
+ a\n\r\x85\x0cb
0: a\x0a\x0d\x85\x0cb
/^a\R+b/
@@ -7919,17 +7917,17 @@ No match
0: a\x0bb
a\x0cb
0: a\x0cb
- a\x85b
+ a\x85b
0: a\x85b
- a\n\rb
+ a\n\rb
0: a\x0a\x0db
- a\n\r\x85\x0cb
+ a\n\r\x85\x0cb
0: a\x0a\x0d\x85\x0cb
** Failers
No match
- ab
+ ab
No match
-
+
/^a\R{1,3}b/
a\nb
0: a\x0ab
@@ -7937,13 +7935,13 @@ No match
0: a\x0a\x0db
a\n\r\x85b
0: a\x0a\x0d\x85b
- a\r\n\r\nb
+ a\r\n\r\nb
0: a\x0d\x0a\x0d\x0ab
- a\r\n\r\n\r\nb
+ a\r\n\r\n\r\nb
0: a\x0d\x0a\x0d\x0a\x0d\x0ab
a\n\r\n\rb
0: a\x0a\x0d\x0a\x0db
- a\n\n\r\nb
+ a\n\n\r\nb
0: a\x0a\x0a\x0d\x0ab
** Failers
No match
@@ -7957,7 +7955,7 @@ No match
0: aRb
** Failers
No match
- a\nb
+ a\nb
No match
/(?&abc)X(?<abc>P)/I
@@ -7999,7 +7997,7 @@ Need char = 'P'
No match
10.6
No match
- 455.3.4.5
+ 455.3.4.5
No match
/\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
@@ -8019,9 +8017,9 @@ No match
No match
10.6
No match
- 455.3.4.5
+ 455.3.4.5
No match
-
+
/(?:a(?&abc)b)*(?<abc>x)/
123axbaxbaxbx456
0: axbaxbaxbx
@@ -8029,7 +8027,7 @@ No match
123axbaxbaxb456
0: x
1: x
-
+
/(?:a(?&abc)b){1,5}(?<abc>x)/
123axbaxbaxbx456
0: axbaxbaxbx
@@ -8069,16 +8067,16 @@ No match
Failed: reference to non-existent subpattern at offset 4
/^(a)\g/
-Failed: \g is not followed by an (optionally braced) non-zero number at offset 4
+Failed: \g is not followed by a braced name or an optionally braced non-zero number at offset 4
/^(a)\g{0}/
-Failed: \g is not followed by an (optionally braced) non-zero number at offset 4
+Failed: \g is not followed by a braced name or an optionally braced non-zero number at offset 4
/^(a)\g{3/
-Failed: \g is not followed by an (optionally braced) non-zero number at offset 4
+Failed: \g is not followed by a braced name or an optionally braced non-zero number at offset 4
/^(a)\g{4a}/
-Failed: \g is not followed by an (optionally braced) non-zero number at offset 4
+Failed: reference to non-existent subpattern at offset 9
/^a.b/<lf>
a\rb
@@ -8091,39 +8089,689 @@ No match
/.+foo/
afoo
0: afoo
- ** Failers
+ ** Failers
No match
- \r\nfoo
+ \r\nfoo
No match
- \nfoo
+ \nfoo
No match
/.+foo/<crlf>
afoo
0: afoo
- \nfoo
+ \nfoo
0: \x0afoo
- ** Failers
+ ** Failers
No match
- \r\nfoo
+ \r\nfoo
No match
/.+foo/<any>
afoo
0: afoo
- ** Failers
+ ** Failers
No match
- \nfoo
+ \nfoo
No match
- \r\nfoo
+ \r\nfoo
No match
/.+foo/s
afoo
0: afoo
- \r\nfoo
+ \r\nfoo
0: \x0d\x0afoo
- \nfoo
+ \nfoo
0: \x0afoo
+
+/^$/mg<any>
+ abc\r\rxyz
+ 0:
+ abc\n\rxyz
+ 0:
+ ** Failers
+No match
+ abc\r\nxyz
+No match
+
+/(?m)^$/<any>g+
+ abc\r\n\r\n
+ 0:
+ 0+ \x0d\x0a
+
+/(?m)^$|^\r\n/<any>g+
+ abc\r\n\r\n
+ 0:
+ 0+ \x0d\x0a
+ 0: \x0d\x0a
+ 0+
+
+/(?m)$/<any>g+
+ abc\r\n\r\n
+ 0:
+ 0+ \x0d\x0a\x0d\x0a
+ 0:
+ 0+ \x0d\x0a
+ 0:
+ 0+
+
+/abc.$/mgx<anycrlf>
+ abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc7\x{2028} abc8\x{2029} abc9
+ 0: abc1
+ 0: abc4
+ 0: abc5
+ 0: abc9
+
+/^X/m
+ XABC
+ 0: X
+ ** Failers
+No match
+ XABC\B
+No match
+
+/(ab|c)(?-1)/BZ
+------------------------------------------------------------------
+ Bra 0
+ Bra 1
+ ab
+ Alt
+ c
+ Ket
+ Once
+ Recurse
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+ abc
+ 0: abc
+ 1: ab
+
+/xy(?+1)(abc)/BZ
+------------------------------------------------------------------
+ Bra 0
+ xy
+ Once
+ Recurse
+ Ket
+ Bra 1
+ abc
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+ xyabcabc
+ 0: xyabcabc
+ 1: abc
+ ** Failers
+No match
+ xyabc
+No match
+
+/x(?-0)y/
+Failed: (?+ or (?- or (?(+ or (?(- must be followed by a non-zero number at offset 5
+
+/x(?-1)y/
+Failed: reference to non-existent subpattern at offset 5
+
+/x(?+0)y/
+Failed: (?+ or (?- or (?(+ or (?(- must be followed by a non-zero number at offset 5
+
+/x(?+1)y/
+Failed: reference to non-existent subpattern at offset 5
+
+/^(abc)?(?(-1)X|Y)/BZ
+------------------------------------------------------------------
+ Bra 0
+ ^
+ Brazero
+ Bra 1
+ abc
+ Ket
+ Cond
+ 1 Cond ref
+ X
+ Alt
+ Y
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+ abcX
+ 0: abcX
+ 1: abc
+ Y
+ 0: Y
+ ** Failers
+No match
+ abcY
+No match
+
+/^((?(+1)X|Y)(abc))+/BZ
+------------------------------------------------------------------
+ Bra 0
+ ^
+ Bra 1
+ Cond
+ 2 Cond ref
+ X
+ Alt
+ Y
+ Ket
+ Bra 2
+ abc
+ Ket
+ KetRmax
+ Ket
+ End
+------------------------------------------------------------------
+ YabcXabc
+ 0: YabcXabc
+ 1: Xabc
+ 2: abc
+ YabcXabcXabc
+ 0: YabcXabcXabc
+ 1: Xabc
+ 2: abc
+ ** Failers
+No match
+ XabcXabc
+No match
+
+/(?(-1)a)/BZ
+Failed: reference to non-existent subpattern at offset 6
+
+/((?(-1)a))/BZ
+------------------------------------------------------------------
+ Bra 0
+ Bra 1
+ Cond
+ 1 Cond ref
+ a
+ Ket
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+
+/((?(-2)a))/BZ
+Failed: reference to non-existent subpattern at offset 7
+
+/^(?(+1)X|Y)/BZ
+------------------------------------------------------------------
+ Bra 0
+ ^
+ Cond
+ 1 Cond ref
+ X
+ Alt
+ Y
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+ Y
+ 0: Y
+
+/(foo)\Kbar/
+ foobar
+ 0: bar
+ 1: foo
+
+/(foo)(\Kbar|baz)/
+ foobar
+ 0: bar
+ 1: foo
+ 2: bar
+ foobaz
+ 0: foobaz
+ 1: foo
+ 2: baz
+
+/(foo\Kbar)baz/
+ foobarbaz
+ 0: barbaz
+ 1: foobar
+
+/(?<A>tom|bon)-\k{A}/
+ tom-tom
+ 0: tom-tom
+ 1: tom
+ bon-bon
+ 0: bon-bon
+ 1: bon
+ ** Failers
+No match
+ tom-bon
+No match
+
+/(?<A>tom|bon)-\g{A}/
+ tom-tom
+ 0: tom-tom
+ 1: tom
+ bon-bon
+ 0: bon-bon
+ 1: bon
+
+/\g{A/
+Failed: syntax error in subpattern name (missing terminator) at offset 4
+
+/(?|(abc)|(xyz))/BZ
+------------------------------------------------------------------
+ Bra 0
+ Bra 0
+ Bra 1
+ abc
+ Ket
+ Alt
+ Bra 1
+ xyz
+ Ket
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+ >abc<
+ 0: abc
+ 1: abc
+ >xyz<
+ 0: xyz
+ 1: xyz
+
+/(x)(?|(abc)|(xyz))(x)/BZ
+------------------------------------------------------------------
+ Bra 0
+ Bra 1
+ x
+ Ket
+ Bra 0
+ Bra 2
+ abc
+ Ket
+ Alt
+ Bra 2
+ xyz
+ Ket
+ Ket
+ Bra 3
+ x
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+ xabcx
+ 0: xabcx
+ 1: x
+ 2: abc
+ 3: x
+ xxyzx
+ 0: xxyzx
+ 1: x
+ 2: xyz
+ 3: x
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/BZ
+------------------------------------------------------------------
+ Bra 0
+ Bra 1
+ x
+ Ket
+ Bra 0
+ Bra 2
+ abc
+ Ket
+ Bra 3
+ pqr
+ Ket
+ Alt
+ Bra 2
+ xyz
+ Ket
+ Ket
+ Bra 4
+ x
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+ xabcpqrx
+ 0: xabcpqrx
+ 1: x
+ 2: abc
+ 3: pqr
+ 4: x
+ xxyzx
+ 0: xxyzx
+ 1: x
+ 2: xyz
+ 3: <unset>
+ 4: x
+
+/(?|(abc)|(xyz))\1/
+ abcabc
+ 0: abcabc
+ 1: abc
+ xyzxyz
+ 0: xyzxyz
+ 1: xyz
+ ** Failers
+No match
+ abcxyz
+No match
+ xyzabc
+No match
+
+/(?|(abc)|(xyz))(?1)/
+ abcabc
+ 0: abcabc
+ 1: abc
+ xyzabc
+ 0: xyzabc
+ 1: xyz
+ ** Failers
+No match
+ xyzxyz
+No match
+
+/\H\h\V\v/
+ X X\x0a
+ 0: X X\x0a
+ X\x09X\x0b
+ 0: X\x09X\x0b
+ ** Failers
+No match
+ \xa0 X\x0a
+No match
+
+/\H*\h+\V?\v{3,4}/
+ \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0X\x0a\x0b\x0c\x0d
+ \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0\x0a\x0b\x0c\x0d
+ \x09\x20\xa0\x0a\x0b\x0c
+ 0: \x09 \xa0\x0a\x0b\x0c
+ ** Failers
+No match
+ \x09\x20\xa0\x0a\x0b
+No match
+
+/\H{3,4}/
+ XY ABCDE
+ 0: ABCD
+ XY PQR ST
+ 0: PQR
+
+/.\h{3,4}./
+ XY AB PQRS
+ 0: B P
+
+/\h*X\h?\H+Y\H?Z/
+ >XNNNYZ
+ 0: XNNNYZ
+ > X NYQZ
+ 0: X NYQZ
+ ** Failers
+No match
+ >XYZ
+No match
+ > X NY Z
+No match
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+ >XY\x0aZ\x0aA\x0bNN\x0c
+ 0: XY\x0aZ\x0aA\x0bNN\x0c
+ >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+ 0: \x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
+/[\h]/BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x09 \xa0]
+ Ket
+ End
+------------------------------------------------------------------
+ >\x09<
+ 0: \x09
+
+/[\h]+/BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x09 \xa0]+
+ Ket
+ End
+------------------------------------------------------------------
+ >\x09\x20\xa0<
+ 0: \x09 \xa0
+
+/[\v]/BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x0a-\x0d\x85]
+ Ket
+ End
+------------------------------------------------------------------
+
+/[\H]/BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x00-\x08\x0a-\x1f!-\x9f\xa1-\xff]
+ Ket
+ End
+------------------------------------------------------------------
+
+/[^\h]/BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x00-\x08\x0a-\x1f!-\x9f\xa1-\xff] (neg)
+ Ket
+ End
+------------------------------------------------------------------
+
+/[\V]/BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x00-\x09\x0e-\x84\x86-\xff]
+ Ket
+ End
+------------------------------------------------------------------
+
+/[\x0a\V]/BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x00-\x0a\x0e-\x84\x86-\xff]
+ Ket
+ End
+------------------------------------------------------------------
+
+/\H++X/BZ
+------------------------------------------------------------------
+ Bra 0
+ \H++
+ X
+ Ket
+ End
+------------------------------------------------------------------
+ ** Failers
+No match
+ XXXX
+No match
+
+/\H+\hY/BZ
+------------------------------------------------------------------
+ Bra 0
+ \H++
+ \h
+ Y
+ Ket
+ End
+------------------------------------------------------------------
+ XXXX Y
+ 0: XXXX Y
+
+/\H+ Y/BZ
+------------------------------------------------------------------
+ Bra 0
+ \H++
+ Y
+ Ket
+ End
+------------------------------------------------------------------
+
+/\h+A/BZ
+------------------------------------------------------------------
+ Bra 0
+ \h++
+ A
+ Ket
+ End
+------------------------------------------------------------------
+
+/\v*B/BZ
+------------------------------------------------------------------
+ Bra 0
+ \v*+
+ B
+ Ket
+ End
+------------------------------------------------------------------
+
+/\V+\x0a/BZ
+------------------------------------------------------------------
+ Bra 0
+ \V++
+ \x0a
+ Ket
+ End
+------------------------------------------------------------------
+
+/A+\h/BZ
+------------------------------------------------------------------
+ Bra 0
+ A++
+ \h
+ Ket
+ End
+------------------------------------------------------------------
+
+/ *\H/BZ
+------------------------------------------------------------------
+ Bra 0
+ *+
+ \H
+ Ket
+ End
+------------------------------------------------------------------
+
+/A*\v/BZ
+------------------------------------------------------------------
+ Bra 0
+ A*+
+ \v
+ Ket
+ End
+------------------------------------------------------------------
+
+/\x0b*\V/BZ
+------------------------------------------------------------------
+ Bra 0
+ \x0b*+
+ \V
+ Ket
+ End
+------------------------------------------------------------------
+
+/\d+\h/BZ
+------------------------------------------------------------------
+ Bra 0
+ \d++
+ \h
+ Ket
+ End
+------------------------------------------------------------------
+
+/\d*\v/BZ
+------------------------------------------------------------------
+ Bra 0
+ \d*+
+ \v
+ Ket
+ End
+------------------------------------------------------------------
+
+/S+\h\S+\v/BZ
+------------------------------------------------------------------
+ Bra 0
+ S++
+ \h
+ \S++
+ \v
+ Ket
+ End
+------------------------------------------------------------------
+
+/\w{3,}\h\w+\v/BZ
+------------------------------------------------------------------
+ Bra 0
+ \w{3}
+ \w*+
+ \h
+ \w++
+ \v
+ Ket
+ End
+------------------------------------------------------------------
+
+/\h+\d\h+\w\h+\S\h+\H/BZ
+------------------------------------------------------------------
+ Bra 0
+ \h++
+ \d
+ \h++
+ \w
+ \h++
+ \S
+ \h++
+ \H
+ Ket
+ End
+------------------------------------------------------------------
+
+/\v+\d\v+\w\v+\S\v+\V/BZ
+------------------------------------------------------------------
+ Bra 0
+ \v++
+ \d
+ \v++
+ \w
+ \v+
+ \S
+ \v++
+ \V
+ Ket
+ End
+------------------------------------------------------------------
+
+/\H+\h\H+\d/BZ
+------------------------------------------------------------------
+ Bra 0
+ \H++
+ \h
+ \H+
+ \d
+ Ket
+ End
+------------------------------------------------------------------
+
+/\V+\v\V+\w/BZ
+------------------------------------------------------------------
+ Bra 0
+ \V++
+ \v
+ \V+
+ \w
+ Ket
+ End
+------------------------------------------------------------------
/ End of testinput2 /
diff --git a/ext/pcre/pcrelib/testdata/testoutput3 b/ext/pcre/pcrelib/testdata/testoutput3
index c539579832..839ae8a0dc 100644
--- a/ext/pcre/pcrelib/testdata/testoutput3
+++ b/ext/pcre/pcrelib/testdata/testoutput3
@@ -146,14 +146,14 @@ No match
>>>\xba<<<
0:
-/[[:alpha:]][[:lower:]][[:upper:]]/DLfr_FR
+/[[:alpha:]][[:lower:]][[:upper:]]/DZLfr_FR
------------------------------------------------------------------
- 0 102 Bra 0
- 3 [A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\xff]
- 36 [a-z\xb5\xdf-\xf6\xf8-\xff]
- 69 [A-Z\xc0-\xd6\xd8-\xde]
-102 102 Ket
-105 End
+ Bra 0
+ [A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\xff]
+ [a-z\xb5\xdf-\xf6\xf8-\xff]
+ [A-Z\xc0-\xd6\xd8-\xde]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
diff --git a/ext/pcre/pcrelib/testdata/testoutput5 b/ext/pcre/pcrelib/testdata/testoutput5
index 61c6842d77..1f0b2b1243 100644
--- a/ext/pcre/pcrelib/testdata/testoutput5
+++ b/ext/pcre/pcrelib/testdata/testoutput5
@@ -1,114 +1,105 @@
-/\x{100}/8DM
-Memory allocation (code space): 10
+/\x{100}/8DZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \x{100}
- 6 6 Ket
- 9 End
+ Bra 0
+ \x{100}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 196
Need char = 128
-/\x{1000}/8DM
-Memory allocation (code space): 11
+/\x{1000}/8DZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \x{1000}
- 7 7 Ket
- 10 End
+ Bra 0
+ \x{1000}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 225
Need char = 128
-/\x{10000}/8DM
-Memory allocation (code space): 12
+/\x{10000}/8DZ
------------------------------------------------------------------
- 0 8 Bra 0
- 3 \x{10000}
- 8 8 Ket
- 11 End
+ Bra 0
+ \x{10000}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 240
Need char = 128
-/\x{100000}/8DM
-Memory allocation (code space): 12
+/\x{100000}/8DZ
------------------------------------------------------------------
- 0 8 Bra 0
- 3 \x{100000}
- 8 8 Ket
- 11 End
+ Bra 0
+ \x{100000}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 244
Need char = 128
-/\x{1000000}/8DM
-Memory allocation (code space): 13
+/\x{1000000}/8DZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 \x{1000000}
- 9 9 Ket
- 12 End
+ Bra 0
+ \x{1000000}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 249
Need char = 128
-/\x{4000000}/8DM
-Memory allocation (code space): 14
+/\x{4000000}/8DZ
------------------------------------------------------------------
- 0 10 Bra 0
- 3 \x{4000000}
- 10 10 Ket
- 13 End
+ Bra 0
+ \x{4000000}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 252
Need char = 128
-/\x{7fffFFFF}/8DM
-Memory allocation (code space): 14
+/\x{7fffFFFF}/8DZ
------------------------------------------------------------------
- 0 10 Bra 0
- 3 \x{7fffffff}
- 10 10 Ket
- 13 End
+ Bra 0
+ \x{7fffffff}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 253
Need char = 191
-/[\x{ff}]/8DM
-Memory allocation (code space): 10
+/[\x{ff}]/8DZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \x{ff}
- 6 6 Ket
- 9 End
+ Bra 0
+ \x{ff}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 195
Need char = 191
-/[\x{100}]/8DM
-Memory allocation (code space): 15
+/[\x{100}]/8DZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 [\x{100}]
- 11 11 Ket
- 14 End
+ Bra 0
+ [\x{100}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -125,36 +116,36 @@ Failed: character value in \x{...} sequence is too large at offset 12
\x{100}a\x{1234}bcd
0: \x{100}a\x{1234}
-/\x80/8D
+/\x80/8DZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \x{80}
- 6 6 Ket
- 9 End
+ Bra 0
+ \x{80}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 194
Need char = 128
-/\xff/8D
+/\xff/8DZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \x{ff}
- 6 6 Ket
- 9 End
+ Bra 0
+ \x{ff}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 195
Need char = 191
-/\x{0041}\x{2262}\x{0391}\x{002e}/D8
+/\x{0041}\x{2262}\x{0391}\x{002e}/DZ8
------------------------------------------------------------------
- 0 14 Bra 0
- 3 A\x{2262}\x{391}.
- 14 14 Ket
- 17 End
+ Bra 0
+ A\x{2262}\x{391}.
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -163,12 +154,12 @@ Need char = '.'
\x{0041}\x{2262}\x{0391}\x{002e}
0: A\x{2262}\x{391}.
-/\x{D55c}\x{ad6d}\x{C5B4}/D8
+/\x{D55c}\x{ad6d}\x{C5B4}/DZ8
------------------------------------------------------------------
- 0 15 Bra 0
- 3 \x{d55c}\x{ad6d}\x{c5b4}
- 15 15 Ket
- 18 End
+ Bra 0
+ \x{d55c}\x{ad6d}\x{c5b4}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -177,12 +168,12 @@ Need char = 180
\x{D55c}\x{ad6d}\x{C5B4}
0: \x{d55c}\x{ad6d}\x{c5b4}
-/\x{65e5}\x{672c}\x{8a9e}/D8
+/\x{65e5}\x{672c}\x{8a9e}/DZ8
------------------------------------------------------------------
- 0 15 Bra 0
- 3 \x{65e5}\x{672c}\x{8a9e}
- 15 15 Ket
- 18 End
+ Bra 0
+ \x{65e5}\x{672c}\x{8a9e}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -191,74 +182,74 @@ Need char = 158
\x{65e5}\x{672c}\x{8a9e}
0: \x{65e5}\x{672c}\x{8a9e}
-/\x{80}/D8
+/\x{80}/DZ8
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \x{80}
- 6 6 Ket
- 9 End
+ Bra 0
+ \x{80}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 194
Need char = 128
-/\x{084}/D8
+/\x{084}/DZ8
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \x{84}
- 6 6 Ket
- 9 End
+ Bra 0
+ \x{84}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 194
Need char = 132
-/\x{104}/D8
+/\x{104}/DZ8
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \x{104}
- 6 6 Ket
- 9 End
+ Bra 0
+ \x{104}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 196
Need char = 132
-/\x{861}/D8
+/\x{861}/DZ8
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \x{861}
- 7 7 Ket
- 10 End
+ Bra 0
+ \x{861}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 224
Need char = 161
-/\x{212ab}/D8
+/\x{212ab}/DZ8
------------------------------------------------------------------
- 0 8 Bra 0
- 3 \x{212ab}
- 8 8 Ket
- 11 End
+ Bra 0
+ \x{212ab}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 240
Need char = 171
-/.{3,5}X/D8
+/.{3,5}X/DZ8
------------------------------------------------------------------
- 0 13 Bra 0
- 3 Any{3}
- 7 Any{0,2}
- 11 X
- 13 13 Ket
- 16 End
+ Bra 0
+ Any{3}
+ Any{0,2}
+ X
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -269,13 +260,13 @@ Need char = 'X'
0: \x{212ab}\x{212ab}\x{212ab}\x{861}X
-/.{3,5}?/D8
+/.{3,5}?/DZ8
------------------------------------------------------------------
- 0 11 Bra 0
- 3 Any{3}
- 7 Any{0,2}?
- 11 11 Ket
- 14 End
+ Bra 0
+ Any{3}
+ Any{0,2}?
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -285,11 +276,9 @@ No need char
\x{212ab}\x{212ab}\x{212ab}\x{861}
0: \x{212ab}\x{212ab}\x{212ab}
-/-- These tests are here rather than in testinput4 because Perl 5.6 has --/
-/-- some problems with UTF-8 support, in the area of \x{..} where the --/
-No match
-/-- value is < 255. It grumbles about invalid UTF-8 strings. --/
-No match
+/-- These tests are here rather than in testinput4 because Perl 5.6 has some
+problems with UTF-8 support, in the area of \x{..} where the value is < 255.
+It grumbles about invalid UTF-8 strings. --/
/^[a\x{c0}]b/8
\x{c0}b
@@ -329,11 +318,9 @@ No match
/(?<=\C)X/8
Failed: \C not allowed in lookbehind assertion at offset 6
-/-- This one is here not because it's different to Perl, but because the --/
-/-- way the captured single-byte is displayed. (In Perl it becomes a --/
-No match
-/-- character, and you can't tell the difference.) --/
-No match
+/-- This one is here not because it's different to Perl, but because the way
+the captured single-byte is displayed. (In Perl it becomes a character, and you
+can't tell the difference.) --/
/X(\C)(.*)/8
X\x{1234}
@@ -345,13 +332,13 @@ No match
1: \x{0a}
2: abc
-/^[ab]/8D
+/^[ab]/8DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [ab]
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [ab]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored utf8
@@ -368,13 +355,13 @@ No match
\x{100}
No match
-/^[^ab]/8D
+/^[^ab]/8DZ
------------------------------------------------------------------
- 0 37 Bra 0
- 3 ^
- 4 [\x00-`c-\xff] (neg)
- 37 37 Ket
- 40 End
+ Bra 0
+ ^
+ [\x00-`c-\xff] (neg)
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored utf8
@@ -391,12 +378,12 @@ No need char
aaa
No match
-/[^ab\xC0-\xF0]/8SD
+/[^ab\xC0-\xF0]/8SDZ
------------------------------------------------------------------
- 0 36 Bra 0
- 3 [\x00-`c-\xbf\xf1-\xff] (neg)
- 36 36 Ket
- 39 End
+ Bra 0
+ [\x00-`c-\xbf\xf1-\xff] (neg)
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -427,13 +414,13 @@ No match
\x{f0}
No match
-/Ā{3,4}/8SD
+/Ā{3,4}/8SDZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 \x{100}{3}
- 8 \x{100}?
- 11 11 Ket
- 14 End
+ Bra 0
+ \x{100}{3}
+ \x{100}?
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -444,16 +431,16 @@ Study returned NULL
\x{100}\x{100}\x{100}\x{100\x{100}
0: \x{100}\x{100}\x{100}
-/(\x{100}+|x)/8SD
+/(\x{100}+|x)/8SDZ
------------------------------------------------------------------
- 0 19 Bra 0
- 3 8 Bra 1
- 8 \x{100}+
- 11 5 Alt
- 14 x
- 16 13 Ket
- 19 19 Ket
- 22 End
+ Bra 0
+ Bra 1
+ \x{100}+
+ Alt
+ x
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Partial matching not supported
@@ -462,17 +449,17 @@ No first char
No need char
Starting byte set: x \xc4
-/(\x{100}*a|x)/8SD
+/(\x{100}*a|x)/8SDZ
------------------------------------------------------------------
- 0 21 Bra 0
- 3 10 Bra 1
- 8 \x{100}*+
- 11 a
- 13 5 Alt
- 16 x
- 18 15 Ket
- 21 21 Ket
- 24 End
+ Bra 0
+ Bra 1
+ \x{100}*+
+ a
+ Alt
+ x
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Partial matching not supported
@@ -481,17 +468,17 @@ No first char
No need char
Starting byte set: a x \xc4
-/(\x{100}{0,2}a|x)/8SD
+/(\x{100}{0,2}a|x)/8SDZ
------------------------------------------------------------------
- 0 23 Bra 0
- 3 12 Bra 1
- 8 \x{100}{0,2}
- 13 a
- 15 5 Alt
- 18 x
- 20 17 Ket
- 23 23 Ket
- 26 End
+ Bra 0
+ Bra 1
+ \x{100}{0,2}
+ a
+ Alt
+ x
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Partial matching not supported
@@ -500,18 +487,18 @@ No first char
No need char
Starting byte set: a x \xc4
-/(\x{100}{1,2}a|x)/8SD
+/(\x{100}{1,2}a|x)/8SDZ
------------------------------------------------------------------
- 0 26 Bra 0
- 3 15 Bra 1
- 8 \x{100}
- 11 \x{100}{0,1}
- 16 a
- 18 5 Alt
- 21 x
- 23 20 Ket
- 26 26 Ket
- 29 End
+ Bra 0
+ Bra 1
+ \x{100}
+ \x{100}{0,1}
+ a
+ Alt
+ x
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Partial matching not supported
@@ -544,24 +531,24 @@ No match
\x{100}\x{100}abcd
No match
-/\x{100}/8D
+/\x{100}/8DZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \x{100}
- 6 6 Ket
- 9 End
+ Bra 0
+ \x{100}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 196
Need char = 128
-/\x{100}*/8D
+/\x{100}*/8DZ
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \x{100}*
- 6 6 Ket
- 9 End
+ Bra 0
+ \x{100}*
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -569,13 +556,13 @@ Options: utf8
No first char
No need char
-/a\x{100}*/8D
+/a\x{100}*/8DZ
------------------------------------------------------------------
- 0 8 Bra 0
- 3 a
- 5 \x{100}*
- 8 8 Ket
- 11 End
+ Bra 0
+ a
+ \x{100}*
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -583,13 +570,13 @@ Options: utf8
First char = 'a'
No need char
-/ab\x{100}*/8D
+/ab\x{100}*/8DZ
------------------------------------------------------------------
- 0 10 Bra 0
- 3 ab
- 7 \x{100}*
- 10 10 Ket
- 13 End
+ Bra 0
+ ab
+ \x{100}*
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -597,13 +584,13 @@ Options: utf8
First char = 'a'
Need char = 'b'
-/a\x{100}\x{101}*/8D
+/a\x{100}\x{101}*/8DZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 a\x{100}
- 8 \x{101}*
- 11 11 Ket
- 14 End
+ Bra 0
+ a\x{100}
+ \x{101}*
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -611,13 +598,13 @@ Options: utf8
First char = 'a'
Need char = 128
-/a\x{100}\x{101}+/8D
+/a\x{100}\x{101}+/8DZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 a\x{100}
- 8 \x{101}+
- 11 11 Ket
- 14 End
+ Bra 0
+ a\x{100}
+ \x{101}+
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -625,13 +612,13 @@ Options: utf8
First char = 'a'
Need char = 129
-/\x{100}*A/8D
+/\x{100}*A/8DZ
------------------------------------------------------------------
- 0 8 Bra 0
- 3 \x{100}*+
- 6 A
- 8 8 Ket
- 11 End
+ Bra 0
+ \x{100}*+
+ A
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -641,16 +628,16 @@ Need char = 'A'
A
0: A
-/\x{100}*\d(?R)/8D
+/\x{100}*\d(?R)/8DZ
------------------------------------------------------------------
- 0 16 Bra 0
- 3 \x{100}*+
- 6 \d
- 7 6 Once
- 10 0 Recurse
- 13 6 Ket
- 16 16 Ket
- 19 End
+ Bra 0
+ \x{100}*+
+ \d
+ Once
+ Recurse
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -658,37 +645,36 @@ Options: utf8
No first char
No need char
-/[^\x{c4}]/D
+/[^\x{c4}]/DZ
------------------------------------------------------------------
- 0 5 Bra 0
- 3 [^\xc4]
- 5 5 Ket
- 8 End
+ Bra 0
+ [^\xc4]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/[^\x{c4}]/8D
+/[^\x{c4}]/8DZ
------------------------------------------------------------------
- 0 36 Bra 0
- 3 [\x00-\xc3\xc5-\xff] (neg)
- 36 36 Ket
- 39 End
+ Bra 0
+ [\x00-\xc3\xc5-\xff] (neg)
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
No first char
No need char
-/[\x{100}]/8DM
-Memory allocation (code space): 15
+/[\x{100}]/8DZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 [\x{100}]
- 11 11 Ket
- 14 End
+ Bra 0
+ [\x{100}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -703,13 +689,12 @@ No need char
*** Failers
No match
-/[Z\x{100}]/8DM
-Memory allocation (code space): 47
+/[Z\x{100}]/8DZ
------------------------------------------------------------------
- 0 43 Bra 0
- 3 [Z\x{100}]
- 43 43 Ket
- 46 End
+ Bra 0
+ [Z\x{100}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -739,24 +724,24 @@ No match
\x{ff}
No match
-/[z-\x{100}]/8D
+/[z-\x{100}]/8DZ
------------------------------------------------------------------
- 0 12 Bra 0
- 3 [z-\x{100}]
- 12 12 Ket
- 15 End
+ Bra 0
+ [z-\x{100}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
No first char
No need char
-/[z\Qa-d]Ā\E]/8D
+/[z\Qa-d]Ā\E]/8DZ
------------------------------------------------------------------
- 0 43 Bra 0
- 3 [\-\]adz\x{100}]
- 43 43 Ket
- 46 End
+ Bra 0
+ [\-\]adz\x{100}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -767,12 +752,12 @@ No need char
Ā
0: \x{100}
-/[\xFF]/D
+/[\xFF]/DZ
------------------------------------------------------------------
- 0 5 Bra 0
- 3 \xff
- 5 5 Ket
- 8 End
+ Bra 0
+ \xff
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
@@ -781,12 +766,12 @@ No need char
>\xff<
0: \xff
-/[\xff]/D8
+/[\xff]/DZ8
------------------------------------------------------------------
- 0 6 Bra 0
- 3 \x{ff}
- 6 6 Ket
- 9 End
+ Bra 0
+ \x{ff}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -795,24 +780,24 @@ Need char = 191
>\x{ff}<
0: \x{ff}
-/[^\xFF]/D
+/[^\xFF]/DZ
------------------------------------------------------------------
- 0 5 Bra 0
- 3 [^\xff]
- 5 5 Ket
- 8 End
+ Bra 0
+ [^\xff]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/[^\xff]/8D
+/[^\xff]/8DZ
------------------------------------------------------------------
- 0 36 Bra 0
- 3 [\x00-\xfe] (neg)
- 36 36 Ket
- 39 End
+ Bra 0
+ [\x00-\xfe] (neg)
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -852,12 +837,12 @@ Failed: invalid UTF-8 string at offset 0
/xxx/8
Failed: invalid UTF-8 string at offset 1
-/xxx/8?D
+/xxx/8?DZ
------------------------------------------------------------------
- 0 15 Bra 0
- 3 \X{c0}\X{c0}\X{c0}xxx
- 15 15 Ket
- 18 End
+ Bra 0
+ \X{c0}\X{c0}\X{c0}xxx
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8 no_utf8_check
@@ -910,170 +895,170 @@ No match
\xfd\x83\x80\x80\x80\x80
No match
-/\x{100}abc(xyz(?1))/8D
+/\x{100}abc(xyz(?1))/8DZ
------------------------------------------------------------------
- 0 35 Bra 0
- 3 \x{100}abc
- 12 20 Bra 1
- 17 xyz
- 23 6 Once
- 26 12 Recurse
- 29 6 Ket
- 32 20 Ket
- 35 35 Ket
- 38 End
+ Bra 0
+ \x{100}abc
+ Bra 1
+ xyz
+ Once
+ Recurse
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Options: utf8
First char = 196
Need char = 'z'
-/[^\x{100}]abc(xyz(?1))/8D
+/[^\x{100}]abc(xyz(?1))/8DZ
------------------------------------------------------------------
- 0 40 Bra 0
- 3 [^\x{100}]
- 11 abc
- 17 20 Bra 1
- 22 xyz
- 28 6 Once
- 31 17 Recurse
- 34 6 Ket
- 37 20 Ket
- 40 40 Ket
- 43 End
+ Bra 0
+ [^\x{100}]
+ abc
+ Bra 1
+ xyz
+ Once
+ Recurse
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Options: utf8
No first char
Need char = 'z'
-/[ab\x{100}]abc(xyz(?1))/8D
+/[ab\x{100}]abc(xyz(?1))/8DZ
------------------------------------------------------------------
- 0 72 Bra 0
- 3 [ab\x{100}]
- 43 abc
- 49 20 Bra 1
- 54 xyz
- 60 6 Once
- 63 49 Recurse
- 66 6 Ket
- 69 20 Ket
- 72 72 Ket
- 75 End
+ Bra 0
+ [ab\x{100}]
+ abc
+ Bra 1
+ xyz
+ Once
+ Recurse
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 1
Options: utf8
No first char
Need char = 'z'
-/(\x{100}(b(?2)c))?/D8
-------------------------------------------------------------------
- 0 36 Bra 0
- 3 Brazero
- 4 29 Bra 1
- 9 \x{100}
- 12 18 Bra 2
- 17 b
- 19 6 Once
- 22 12 Recurse
- 25 6 Ket
- 28 c
- 30 18 Ket
- 33 29 Ket
- 36 36 Ket
- 39 End
+/(\x{100}(b(?2)c))?/DZ8
+------------------------------------------------------------------
+ Bra 0
+ Brazero
+ Bra 1
+ \x{100}
+ Bra 2
+ b
+ Once
+ Recurse
+ Ket
+ c
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 2
Options: utf8
No first char
No need char
-/(\x{100}(b(?2)c)){0,2}/D8
-------------------------------------------------------------------
- 0 75 Bra 0
- 3 Brazero
- 4 68 Bra 0
- 7 29 Bra 1
- 12 \x{100}
- 15 18 Bra 2
- 20 b
- 22 6 Once
- 25 15 Recurse
- 28 6 Ket
- 31 c
- 33 18 Ket
- 36 29 Ket
- 39 Brazero
- 40 29 Bra 1
- 45 \x{100}
- 48 18 Bra 2
- 53 b
- 55 6 Once
- 58 15 Recurse
- 61 6 Ket
- 64 c
- 66 18 Ket
- 69 29 Ket
- 72 68 Ket
- 75 75 Ket
- 78 End
+/(\x{100}(b(?2)c)){0,2}/DZ8
+------------------------------------------------------------------
+ Bra 0
+ Brazero
+ Bra 0
+ Bra 1
+ \x{100}
+ Bra 2
+ b
+ Once
+ Recurse
+ Ket
+ c
+ Ket
+ Ket
+ Brazero
+ Bra 1
+ \x{100}
+ Bra 2
+ b
+ Once
+ Recurse
+ Ket
+ c
+ Ket
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 2
Options: utf8
No first char
No need char
-/(\x{100}(b(?1)c))?/D8
-------------------------------------------------------------------
- 0 36 Bra 0
- 3 Brazero
- 4 29 Bra 1
- 9 \x{100}
- 12 18 Bra 2
- 17 b
- 19 6 Once
- 22 4 Recurse
- 25 6 Ket
- 28 c
- 30 18 Ket
- 33 29 Ket
- 36 36 Ket
- 39 End
+/(\x{100}(b(?1)c))?/DZ8
+------------------------------------------------------------------
+ Bra 0
+ Brazero
+ Bra 1
+ \x{100}
+ Bra 2
+ b
+ Once
+ Recurse
+ Ket
+ c
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 2
Options: utf8
No first char
No need char
-/(\x{100}(b(?1)c)){0,2}/D8
-------------------------------------------------------------------
- 0 75 Bra 0
- 3 Brazero
- 4 68 Bra 0
- 7 29 Bra 1
- 12 \x{100}
- 15 18 Bra 2
- 20 b
- 22 6 Once
- 25 7 Recurse
- 28 6 Ket
- 31 c
- 33 18 Ket
- 36 29 Ket
- 39 Brazero
- 40 29 Bra 1
- 45 \x{100}
- 48 18 Bra 2
- 53 b
- 55 6 Once
- 58 7 Recurse
- 61 6 Ket
- 64 c
- 66 18 Ket
- 69 29 Ket
- 72 68 Ket
- 75 75 Ket
- 78 End
+/(\x{100}(b(?1)c)){0,2}/DZ8
+------------------------------------------------------------------
+ Bra 0
+ Brazero
+ Bra 0
+ Bra 1
+ \x{100}
+ Bra 2
+ b
+ Once
+ Recurse
+ Ket
+ c
+ Ket
+ Ket
+ Brazero
+ Bra 1
+ \x{100}
+ Bra 2
+ b
+ Once
+ Recurse
+ Ket
+ c
+ Ket
+ Ket
+ Ket
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 2
Options: utf8
@@ -1094,13 +1079,13 @@ No need char
a\x{1234}b
0: a\x{1234}b
-/^\ሴ/8D
+/^\ሴ/8DZ
------------------------------------------------------------------
- 0 8 Bra 0
- 3 ^
- 4 \x{1234}
- 8 8 Ket
- 11 End
+ Bra 0
+ ^
+ \x{1234}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: anchored utf8
@@ -1120,13 +1105,13 @@ Need char = 191
\777
0: \x{1ff}
-/\x{100}*\d/8D
+/\x{100}*\d/8DZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \x{100}*+
- 6 \d
- 7 7 Ket
- 10 End
+ Bra 0
+ \x{100}*+
+ \d
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1134,13 +1119,13 @@ Options: utf8
No first char
No need char
-/\x{100}*\s/8D
+/\x{100}*\s/8DZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \x{100}*+
- 6 \s
- 7 7 Ket
- 10 End
+ Bra 0
+ \x{100}*+
+ \s
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1148,13 +1133,13 @@ Options: utf8
No first char
No need char
-/\x{100}*\w/8D
+/\x{100}*\w/8DZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \x{100}*+
- 6 \w
- 7 7 Ket
- 10 End
+ Bra 0
+ \x{100}*+
+ \w
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1162,13 +1147,13 @@ Options: utf8
No first char
No need char
-/\x{100}*\D/8D
+/\x{100}*\D/8DZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \x{100}*
- 6 \D
- 7 7 Ket
- 10 End
+ Bra 0
+ \x{100}*
+ \D
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1176,13 +1161,13 @@ Options: utf8
No first char
No need char
-/\x{100}*\S/8D
+/\x{100}*\S/8DZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \x{100}*
- 6 \S
- 7 7 Ket
- 10 End
+ Bra 0
+ \x{100}*
+ \S
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1190,13 +1175,13 @@ Options: utf8
No first char
No need char
-/\x{100}*\W/8D
+/\x{100}*\W/8DZ
------------------------------------------------------------------
- 0 7 Bra 0
- 3 \x{100}*
- 6 \W
- 7 7 Ket
- 10 End
+ Bra 0
+ \x{100}*
+ \W
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1204,13 +1189,13 @@ Options: utf8
No first char
No need char
-/\x{100}+\x{200}/8D
+/\x{100}+\x{200}/8DZ
------------------------------------------------------------------
- 0 9 Bra 0
- 3 \x{100}++
- 6 \x{200}
- 9 9 Ket
- 12 End
+ Bra 0
+ \x{100}++
+ \x{200}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1218,13 +1203,13 @@ Options: utf8
First char = 196
Need char = 128
-/\x{100}+X/8D
+/\x{100}+X/8DZ
------------------------------------------------------------------
- 0 8 Bra 0
- 3 \x{100}++
- 6 X
- 8 8 Ket
- 11 End
+ Bra 0
+ \x{100}++
+ X
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1232,13 +1217,13 @@ Options: utf8
First char = 196
Need char = 'X'
-/X+\x{200}/8D
+/X+\x{200}/8DZ
------------------------------------------------------------------
- 0 8 Bra 0
- 3 X++
- 5 \x{200}
- 8 8 Ket
- 11 End
+ Bra 0
+ X++
+ \x{200}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -1269,25 +1254,25 @@ Matched, but too many substrings
13:
14:
-/^[\x{100}\E-\Q\E\x{150}]/B8
+/^[\x{100}\E-\Q\E\x{150}]/BZ8
------------------------------------------------------------------
- 0 14 Bra 0
- 3 ^
- 4 [\x{100}-\x{150}]
- 14 14 Ket
- 17 End
+ Bra 0
+ ^
+ [\x{100}-\x{150}]
+ Ket
+ End
------------------------------------------------------------------
-/^[\QĀ\E-\QŐ\E]/B8
+/^[\QĀ\E-\QŐ\E]/BZ8
------------------------------------------------------------------
- 0 14 Bra 0
- 3 ^
- 4 [\x{100}-\x{150}]
- 14 14 Ket
- 17 End
+ Bra 0
+ ^
+ [\x{100}-\x{150}]
+ Ket
+ End
------------------------------------------------------------------
-/^[\QĀ\E-\QŐ\E/B8
+/^[\QĀ\E-\QŐ\E/BZ8
Failed: missing terminating ] for character class at offset 15
/^abc./mgx8<any>
@@ -1400,4 +1385,92 @@ No match
a\r
No match
+/\H\h\V\v/8
+ X X\x0a
+ 0: X X\x{0a}
+ X\x09X\x0b
+ 0: X\x{09}X\x{0b}
+ ** Failers
+No match
+ \x{a0} X\x0a
+No match
+
+/\H*\h+\V?\v{3,4}/8
+ \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d}
+ \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}\x{0d}
+ \x09\x20\x{a0}\x0a\x0b\x0c
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}
+ ** Failers
+No match
+ \x09\x20\x{a0}\x0a\x0b
+No match
+
+/\H\h\V\v/8
+ \x{3001}\x{3000}\x{2030}\x{2028}
+ 0: \x{3001}\x{3000}\x{2030}\x{2028}
+ X\x{180e}X\x{85}
+ 0: X\x{180e}X\x{85}
+ ** Failers
+No match
+ \x{2009} X\x0a
+No match
+
+/\H*\h+\V?\v{3,4}/8
+ \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+ 0: \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x{0c}\x{0d}
+ \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+ 0: \x{09}\x{205f}\x{a0}\x{0a}\x{2029}\x{0c}\x{2028}
+ \x09\x20\x{202f}\x0a\x0b\x0c
+ 0: \x{09} \x{202f}\x{0a}\x{0b}\x{0c}
+ ** Failers
+No match
+ \x09\x{200a}\x{a0}\x{2028}\x0b
+No match
+
+/[\h]/8BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x09 \xa0\x{1680}\x{180e}\x{2000}-\x{200a}\x{202f}\x{205f}\x{3000}]
+ Ket
+ End
+------------------------------------------------------------------
+ >\x{1680}
+ 0: \x{1680}
+
+/[\h]{3,}/8BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x09 \xa0\x{1680}\x{180e}\x{2000}-\x{200a}\x{202f}\x{205f}\x{3000}]{3,}
+ Ket
+ End
+------------------------------------------------------------------
+ >\x{1680}\x{180e}\x{2000}\x{2003}\x{200a}\x{202f}\x{205f}\x{3000}<
+ 0: \x{1680}\x{180e}\x{2000}\x{2003}\x{200a}\x{202f}\x{205f}\x{3000}
+
+/[\v]/8BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x0a-\x0d\x85\x{2028}-\x{2029}]
+ Ket
+ End
+------------------------------------------------------------------
+
+/[\H]/8BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x00-\x08\x0a-\x1f!-\x9f\xa1-\xff\x{100}-\x{167f}\x{1681}-\x{180d}\x{180f}-\x{1fff}\x{200b}-\x{202e}\x{2030}-\x{205e}\x{2060}-\x{2fff}\x{3001}-\x{7fffffff}]
+ Ket
+ End
+------------------------------------------------------------------
+
+/[\V]/8BZ
+------------------------------------------------------------------
+ Bra 0
+ [\x00-\x09\x0e-\x84\x86-\xff\x{100}-\x{2027}\x{2029}-\x{7fffffff}]
+ Ket
+ End
+------------------------------------------------------------------
+
/ End of testinput5 /
diff --git a/ext/pcre/pcrelib/testdata/testoutput6 b/ext/pcre/pcrelib/testdata/testoutput6
index a8bb0adaaa..f6a1d0e229 100644
--- a/ext/pcre/pcrelib/testdata/testoutput6
+++ b/ext/pcre/pcrelib/testdata/testoutput6
@@ -548,73 +548,72 @@ No match
WXYZ
No match
-/[\p{L}]/D
+/[\p{L}]/DZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 [\p{L}]
- 11 11 Ket
- 14 End
+ Bra 0
+ [\p{L}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/[\p{^L}]/D
+/[\p{^L}]/DZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 [\P{L}]
- 11 11 Ket
- 14 End
+ Bra 0
+ [\P{L}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/[\P{L}]/D
+/[\P{L}]/DZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 [\P{L}]
- 11 11 Ket
- 14 End
+ Bra 0
+ [\P{L}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/[\P{^L}]/D
+/[\P{^L}]/DZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 [\p{L}]
- 11 11 Ket
- 14 End
+ Bra 0
+ [\p{L}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
No options
No first char
No need char
-/[abc\p{L}\x{0660}]/8D
+/[abc\p{L}\x{0660}]/8DZ
------------------------------------------------------------------
- 0 46 Bra 0
- 3 [a-c\p{L}\x{660}]
- 46 46 Ket
- 49 End
+ Bra 0
+ [a-c\p{L}\x{660}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
No first char
No need char
-/[\p{Nd}]/8DM
-Memory allocation (code space): 15
+/[\p{Nd}]/8DZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 [\p{Nd}]
- 11 11 Ket
- 14 End
+ Bra 0
+ [\p{Nd}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
@@ -623,13 +622,12 @@ No need char
1234
0: 1
-/[\p{Nd}+-]+/8DM
-Memory allocation (code space): 48
+/[\p{Nd}+-]+/8DZ
------------------------------------------------------------------
- 0 44 Bra 0
- 3 [+\-\p{Nd}]+
- 44 44 Ket
- 47 End
+ Bra 0
+ [+\-\p{Nd}]+
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Partial matching not supported
@@ -779,48 +777,48 @@ No match
A\x{391}\x{10427}\x{ff3a}\x{1fb8}
0: A\x{391}\x{10427}\x{ff3a}\x{1fb8}
-/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iD
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iDZ
------------------------------------------------------------------
- 0 21 Bra 0
- 3 NC A\x{391}\x{10427}\x{ff3a}\x{1fb0}
- 21 21 Ket
- 24 End
+ Bra 0
+ NC A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: caseless utf8
First char = 'A' (caseless)
No need char
-/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8D
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8DZ
------------------------------------------------------------------
- 0 21 Bra 0
- 3 A\x{391}\x{10427}\x{ff3a}\x{1fb0}
- 21 21 Ket
- 24 End
+ Bra 0
+ A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 'A'
Need char = 176
-/AB\x{1fb0}/8D
+/AB\x{1fb0}/8DZ
------------------------------------------------------------------
- 0 11 Bra 0
- 3 AB\x{1fb0}
- 11 11 Ket
- 14 End
+ Bra 0
+ AB\x{1fb0}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: utf8
First char = 'A'
Need char = 176
-/AB\x{1fb0}/8Di
+/AB\x{1fb0}/8DZi
------------------------------------------------------------------
- 0 11 Bra 0
- 3 NC AB\x{1fb0}
- 11 11 Ket
- 14 End
+ Bra 0
+ NC AB\x{1fb0}
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: caseless utf8
@@ -857,12 +855,12 @@ Need char = 'B' (caseless)
\x{e0}
0: \x{e0}
-/[\x{105}-\x{109}]/8iD
+/[\x{105}-\x{109}]/8iDZ
------------------------------------------------------------------
- 0 13 Bra 0
- 3 [\x{104}-\x{109}]
- 13 13 Ket
- 16 End
+ Bra 0
+ [\x{104}-\x{109}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: caseless utf8
@@ -881,12 +879,12 @@ No match
\x{10a}
No match
-/[z-\x{100}]/8iD
+/[z-\x{100}]/8iDZ
------------------------------------------------------------------
- 0 20 Bra 0
- 3 [Z\x{39c}\x{178}z-\x{101}]
- 20 20 Ket
- 23 End
+ Bra 0
+ [Z\x{39c}\x{178}z-\x{101}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: caseless utf8
@@ -919,12 +917,12 @@ No match
y
No match
-/[z-\x{100}]/8Di
+/[z-\x{100}]/8DZi
------------------------------------------------------------------
- 0 20 Bra 0
- 3 [Z\x{39c}\x{178}z-\x{101}]
- 20 20 Ket
- 23 End
+ Bra 0
+ [Z\x{39c}\x{178}z-\x{101}]
+ Ket
+ End
------------------------------------------------------------------
Capturing subpattern count = 0
Options: caseless utf8
@@ -1432,4 +1430,18 @@ of case for anything other than the ASCII letters. /
\x{1b00}\x{12000}\x{7c0}\x{a840}\x{10900}
0: \x{1b00}\x{12000}\x{7c0}\x{a840}\x{10900}
+/The next two are special cases where the lengths of the different cases of the
+same character differ. The first went wrong with heap fram storage; the 2nd
+was broken in all cases./
+
+/^\x{023a}+?(\x{0130}+)/8i
+ \x{023a}\x{2c65}\x{0130}
+ 0: \x{23a}\x{2c65}\x{130}
+ 1: \x{130}
+
+/^\x{023a}+([^X])/8i
+ \x{023a}\x{2c65}X
+ 0: \x{23a}\x{2c65}
+ 1: \x{2c65}
+
/ End of testinput6 /
diff --git a/ext/pcre/pcrelib/testdata/testoutput7 b/ext/pcre/pcrelib/testdata/testoutput7
index 5bddc1e153..a77186dbd5 100644
--- a/ext/pcre/pcrelib/testdata/testoutput7
+++ b/ext/pcre/pcrelib/testdata/testoutput7
@@ -3039,9 +3039,9 @@ No match
abcdefghijk\12S
0: abcdefghijk\x0aS
-/ab\hdef/
- abhdef
- 0: abhdef
+/ab\idef/
+ abidef
+ 0: abidef
/a{0}bc/
bc
@@ -6952,4 +6952,124 @@ No match
\nfoo
0: \x0afoo
+/^$/mg<any>
+ abc\r\rxyz
+ 0:
+ abc\n\rxyz
+ 0:
+ ** Failers
+No match
+ abc\r\nxyz
+No match
+
+/^X/m
+ XABC
+ 0: X
+ ** Failers
+No match
+ XABC\B
+No match
+
+/(?m)^$/<any>g+
+ abc\r\n\r\n
+ 0:
+ 0+ \x0d\x0a
+
+/(?m)^$|^\r\n/<any>g+
+ abc\r\n\r\n
+ 0: \x0d\x0a
+ 0+
+ 1:
+
+/(?m)$/<any>g+
+ abc\r\n\r\n
+ 0:
+ 0+ \x0d\x0a\x0d\x0a
+ 0:
+ 0+ \x0d\x0a
+ 0:
+ 0+
+
+/(?|(abc)|(xyz))/
+ >abc<
+ 0: abc
+ >xyz<
+ 0: xyz
+
+/(x)(?|(abc)|(xyz))(x)/
+ xabcx
+ 0: xabcx
+ xxyzx
+ 0: xxyzx
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/
+ xabcpqrx
+ 0: xabcpqrx
+ xxyzx
+ 0: xxyzx
+
+/(?|(abc)|(xyz))(?1)/
+ abcabc
+ 0: abcabc
+ xyzabc
+ 0: xyzabc
+ ** Failers
+No match
+ xyzxyz
+No match
+
+/\H\h\V\v/
+ X X\x0a
+ 0: X X\x0a
+ X\x09X\x0b
+ 0: X\x09X\x0b
+ ** Failers
+No match
+ \xa0 X\x0a
+No match
+
+/\H*\h+\V?\v{3,4}/
+ \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0X\x0a\x0b\x0c\x0d
+ 1: \x09 \xa0X\x0a\x0b\x0c
+ \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0\x0a\x0b\x0c\x0d
+ 1: \x09 \xa0\x0a\x0b\x0c
+ \x09\x20\xa0\x0a\x0b\x0c
+ 0: \x09 \xa0\x0a\x0b\x0c
+ ** Failers
+No match
+ \x09\x20\xa0\x0a\x0b
+No match
+
+/\H{3,4}/
+ XY ABCDE
+ 0: ABCD
+ 1: ABC
+ XY PQR ST
+ 0: PQR
+
+/.\h{3,4}./
+ XY AB PQRS
+ 0: B P
+ 1: B
+
+/\h*X\h?\H+Y\H?Z/
+ >XNNNYZ
+ 0: XNNNYZ
+ > X NYQZ
+ 0: X NYQZ
+ ** Failers
+No match
+ >XYZ
+No match
+ > X NY Z
+No match
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+ >XY\x0aZ\x0aA\x0bNN\x0c
+ 0: XY\x0aZ\x0aA\x0bNN\x0c
+ >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+ 0: \x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
/ End of testinput7 /
diff --git a/ext/pcre/pcrelib/testdata/testoutput8 b/ext/pcre/pcrelib/testdata/testoutput8
index f8251ff5ea..db0f4ade3f 100644
--- a/ext/pcre/pcrelib/testdata/testoutput8
+++ b/ext/pcre/pcrelib/testdata/testoutput8
@@ -1138,4 +1138,70 @@ No match
a\r
No match
+/\h+\V?\v{3,4}/8
+ \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}
+
+/\V?\v{3,4}/8
+ \x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: X\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: X\x{0a}\x{0b}\x{0c}
+
+/\h+\V?\v{3,4}/8
+ >\x09\x20\x{a0}X\x0a\x0a\x0a<
+ 0: \x{09} \x{a0}X\x{0a}\x{0a}\x{0a}
+
+/\V?\v{3,4}/8
+ >\x09\x20\x{a0}X\x0a\x0a\x0a<
+ 0: X\x{0a}\x{0a}\x{0a}
+
+/\H\h\V\v/8
+ X X\x0a
+ 0: X X\x{0a}
+ X\x09X\x0b
+ 0: X\x{09}X\x{0b}
+ ** Failers
+No match
+ \x{a0} X\x0a
+No match
+
+/\H*\h+\V?\v{3,4}/8
+ \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}
+ \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}
+ \x09\x20\x{a0}\x0a\x0b\x0c
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}
+ ** Failers
+No match
+ \x09\x20\x{a0}\x0a\x0b
+No match
+
+/\H\h\V\v/8
+ \x{3001}\x{3000}\x{2030}\x{2028}
+ 0: \x{3001}\x{3000}\x{2030}\x{2028}
+ X\x{180e}X\x{85}
+ 0: X\x{180e}X\x{85}
+ ** Failers
+No match
+ \x{2009} X\x0a
+No match
+
+/\H*\h+\V?\v{3,4}/8
+ \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+ 0: \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x{0c}\x{0d}
+ 1: \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x{0c}
+ \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+ 0: \x{09}\x{205f}\x{a0}\x{0a}\x{2029}\x{0c}\x{2028}
+ 1: \x{09}\x{205f}\x{a0}\x{0a}\x{2029}\x{0c}
+ \x09\x20\x{202f}\x0a\x0b\x0c
+ 0: \x{09} \x{202f}\x{0a}\x{0b}\x{0c}
+ ** Failers
+No match
+ \x09\x{200a}\x{a0}\x{2028}\x0b
+No match
+
/ End of testinput 8 /
diff --git a/ext/pcre/pcrelib/testdata/testoutput9 b/ext/pcre/pcrelib/testdata/testoutput9
index 000e2b9882..2cc61ac593 100644
--- a/ext/pcre/pcrelib/testdata/testoutput9
+++ b/ext/pcre/pcrelib/testdata/testoutput9
@@ -1624,4 +1624,12 @@ No match
AXY
No match
+/^\x{023a}+?(\x{0130}+)/8i
+ \x{023a}\x{2c65}\x{0130}
+ 0: \x{23a}\x{2c65}\x{130}
+
+/^\x{023a}+([^X])/8i
+ \x{023a}\x{2c65}X
+ 0: \x{23a}\x{2c65}
+
/ End /
diff --git a/ext/pcre/pcrelib/ucptable.c b/ext/pcre/pcrelib/ucptable.h
index 0b17906b12..07eaced8f2 100644
--- a/ext/pcre/pcrelib/ucptable.c
+++ b/ext/pcre/pcrelib/ucptable.h
@@ -2,7 +2,7 @@
property table. See ucpinternal.h for a description of the layout.
This version was made from the Unicode 5.0.0 tables. */
-static cnode ucp_table[] = {
+static const cnode ucp_table[] = {
{ 0x09800000, 0x0000001f },
{ 0x09000020, 0x74000000 },
{ 0x09800021, 0x54000002 },
diff --git a/ext/pcre/upgrade-pcre.php b/ext/pcre/upgrade-pcre.php
new file mode 100644
index 0000000000..2f7202e0fb
--- /dev/null
+++ b/ext/pcre/upgrade-pcre.php
@@ -0,0 +1,102 @@
+<?php
+
+// script to upgrade PCRE. just drop the pcre-x.x.tar.xx here and run the script
+
+$pattern = 'pcre-*.tar.*';
+$newpcre = glob($pattern);
+
+if (count($newpcre) > 1) {
+ echo "more than one '$pattern' file. aborting\n";
+ print_r($newpcre);
+ exit;
+}
+
+if (count($newpcre) == 0) {
+ die("need one '$pattern' file. aborting.\n");
+}
+
+
+$newpcre = $newpcre[0];
+
+if (strpos($newpcre, 'gz')) {
+ system("tar xfz $newpcre");
+} elseif (strpos($newpcre, 'bz2')) {
+ system("tar xfj $newpcre");
+} else {
+ die("file type not recognized: $newpcre\n");
+}
+
+$newpcre = substr($newpcre, 0, strpos($newpcre, '.tar'));
+$dirlen = strlen('pcrelib');
+
+function recurse($path)
+{
+ global $newpcre, $dirlen;
+
+ foreach(scandir($path) as $file) {
+
+ if ($file[0] === '.' || $file === 'CVS') continue;
+ if (substr_compare($file, '.lo', -3, 3) == 0 || substr_compare($file, '.o', -2, 2) == 0) continue;
+
+ $file = "$path/$file";
+
+ if (is_dir($file)) {
+ recurse($file);
+ continue;
+ }
+
+ echo "processing $file... ";
+
+ $newfile = $newpcre . substr($file, $dirlen);
+
+ if (is_file($tmp = $newfile . '.generic') || is_file($tmp = $newfile . '.dist')) {
+ $newfile = $tmp;
+ }
+
+
+ if (!is_file($newfile)) {
+ die("$newfile is not available any more\n");
+ }
+
+ copy($newfile, $file);
+ echo "OK\n";
+ }
+
+}
+
+
+recurse('pcrelib');
+
+$dirorig = scandir('pcrelib/testdata');
+$k = array_search('CVS', $dirorig);
+unset($dirorig[$k]);
+
+$dirnew = scandir("$newpcre/testdata");
+$diff = array_diff($dirorig, $dirnew);
+
+foreach ($diff as $file) {
+ $file2 = 'pcrelib'.substr($file, strlen($newpcre));
+ copy($file, $file2);
+}
+
+
+// the config.h needs special care
+$prepend_config_h = '
+#include <php_compat.h>
+#undef PACKAGE_NAME
+#undef PACKAGE_VERSION
+#undef PACKAGE_TARNAME
+#undef PACKAGE_STRING
+
+#define SUPPORT_UCP
+#define SUPPORT_UTF8
+
+
+';
+
+file_put_contents('pcrelib/config.h', $prepend_config_h . file_get_contents('pcrelib/config.h'));
+
+
+echo "\nThe End :-)\n\n"
+
+?>