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");
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/])
PHP_ADD_INCLUDE(pcrelib)
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
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
Written by: Google Inc.
-Copyright (c) 2006 Google Inc
+Copyright (c) 2007 Google Inc
All rights reserved
####
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
ChangeLog for PCRE
------------------
+Version 7.2 01-May-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.
+
+
+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
---------------------
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.
Contributed by: Google Inc.
-Copyright (c) 2006, Google Inc.
+Copyright (c) 2007, Google Inc.
All rights reserved.
News about PCRE releases
------------------------
-Release 7.0 23-Nov-06
+
+Release 7.2 30-Apr-07
+---------------------
+
+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.
+
+
+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
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.
+
+(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
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 "congifure, make, make install"
+paradigm on Windows systems: using MinGW or using Cygwin. These are not at all
+the same thing; they are completely different from each other. There is also
+some experimental, undocumented support for building using "cmake", which you
+might like to try if you are familiar with "cmake". However, at the present
+time, the "cmake" process builds only a static library (not a dll), and the
+tests are not automatically run.
-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.
-(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
$!
=========================
+Last Updated: 24 April 2007
****
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
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
. 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
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
--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
. 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
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
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
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
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
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
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
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
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,
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
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:
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
--- /dev/null
+#include <php_compat.h>
+#undef PACKAGE_NAME
+#undef PACKAGE_VERSION
+#undef PACKAGE_TARNAME
+#undef PACKAGE_STRING
+
+
+/* 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-RC1"
+
+/* 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-RC1"
+
+
+/* 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) */
+#ifndef PCRE_STATIC
+#define PCRE_STATIC 1
+#endif
+
+/* 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 */
+#ifndef SUPPORT_UCP
+#define SUPPORT_UCP
+#endif
+
+/* Define to enable support for the UTF-8 Unicode encoding. */
+#ifndef SUPPORT_UTF8
+#define SUPPORT_UTF8
+#endif
+
+/* Version number of package */
+#ifndef VERSION
+#define VERSION "7.2-RC1"
+#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 */
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
*/
-/* 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"
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"
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);
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
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.
-Last updated: 23 November 2006
-Copyright (c) 1997-2006 University of Cambridge.
+
+REVISION
+
+ Last updated: 18 April 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
./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
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
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
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
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
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: 16 April 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
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-
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: 06 March 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
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
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
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
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
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
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
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.
+ 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
This option specifies that first character of the subject string is not
- the beginning of a line, so the circumflex metacharacter should not
- match before it. Setting this without PCRE_MULTILINE (at compile time)
- causes circumflex never to match. This option affects only the behav-
+ the beginning of a line, so the circumflex metacharacter should not
+ match before it. Setting this without PCRE_MULTILINE (at compile time)
+ causes circumflex never to match. This option affects only the behav-
iour of the circumflex metacharacter. It does not affect \A.
PCRE_NOTEOL
This option specifies that the end of the subject string is not the end
- of a line, so the dollar metacharacter should not match it nor (except
- in multiline mode) a newline immediately before it. Setting this with-
+ of a line, so the dollar metacharacter should not match it nor (except
+ in multiline mode) a newline immediately before it. Setting this with-
out PCRE_MULTILINE (at compile time) causes dollar never to match. This
- option affects only the behaviour of the dollar metacharacter. It does
+ option affects only the behaviour of the dollar metacharacter. It does
not affect \Z or \z.
PCRE_NOTEMPTY
An empty string is not considered to be a valid match if this option is
- set. If there are alternatives in the pattern, they are tried. If all
- the alternatives match the empty string, the entire match fails. For
+ set. If there are alternatives in the pattern, they are tried. If all
+ the alternatives match the empty string, the entire match fails. For
example, if the pattern
a?b?
- is applied to a string not beginning with "a" or "b", it matches the
- empty string at the start of the subject. With PCRE_NOTEMPTY set, this
+ is applied to a string not beginning with "a" or "b", it matches the
+ empty string at the start of the subject. With PCRE_NOTEMPTY set, this
match is not valid, so PCRE searches further into the string for occur-
rences of "a" or "b".
Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a spe-
- cial case of a pattern match of the empty string within its split()
- function, and when using the /g modifier. It is possible to emulate
+ cial case of a pattern match of the empty string within its split()
+ function, and when using the /g modifier. It is possible to emulate
Perl's behaviour after matching a null string by first trying the match
again at the same offset with PCRE_NOTEMPTY and PCRE_ANCHORED, and then
- if that fails by advancing the starting offset (see below) and trying
+ if that fails by advancing the starting offset (see below) and trying
an ordinary match again. There is some code that demonstrates how to do
this in the pcredemo.c sample program.
PCRE_NO_UTF8_CHECK
When PCRE_UTF8 is set at compile time, the validity of the subject as a
- UTF-8 string is automatically checked when pcre_exec() is subsequently
- called. The value of startoffset is also checked to ensure that it
- points to the start of a UTF-8 character. If an invalid UTF-8 sequence
+ UTF-8 string is automatically checked when pcre_exec() is subsequently
+ called. The value of startoffset is also checked to ensure that it
+ points to the start of a UTF-8 character. If an invalid UTF-8 sequence
of bytes is found, pcre_exec() returns the error PCRE_ERROR_BADUTF8. If
- startoffset contains an invalid value, PCRE_ERROR_BADUTF8_OFFSET is
+ startoffset contains an invalid value, PCRE_ERROR_BADUTF8_OFFSET is
returned.
- If you already know that your subject is valid, and you want to skip
- these checks for performance reasons, you can set the
- PCRE_NO_UTF8_CHECK option when calling pcre_exec(). You might want to
- do this for the second and subsequent calls to pcre_exec() if you are
- making repeated calls to find all the matches in a single subject
- string. However, you should be sure that the value of startoffset
- points to the start of a UTF-8 character. When PCRE_NO_UTF8_CHECK is
- set, the effect of passing an invalid UTF-8 string as a subject, or a
- value of startoffset that does not point to the start of a UTF-8 char-
+ If you already know that your subject is valid, and you want to skip
+ these checks for performance reasons, you can set the
+ PCRE_NO_UTF8_CHECK option when calling pcre_exec(). You might want to
+ do this for the second and subsequent calls to pcre_exec() if you are
+ making repeated calls to find all the matches in a single subject
+ string. However, you should be sure that the value of startoffset
+ points to the start of a UTF-8 character. When PCRE_NO_UTF8_CHECK is
+ set, the effect of passing an invalid UTF-8 string as a subject, or a
+ value of startoffset that does not point to the start of a UTF-8 char-
acter, is undefined. Your program may crash.
PCRE_PARTIAL
- This option turns on the partial matching feature. If the subject
- string fails to match the pattern, but at some point during the match-
- ing process the end of the subject was reached (that is, the subject
- partially matches the pattern and the failure to match occurred only
- because there were not enough subject characters), pcre_exec() returns
- PCRE_ERROR_PARTIAL instead of PCRE_ERROR_NOMATCH. When PCRE_PARTIAL is
- used, there are restrictions on what may appear in the pattern. These
+ This option turns on the partial matching feature. If the subject
+ string fails to match the pattern, but at some point during the match-
+ ing process the end of the subject was reached (that is, the subject
+ partially matches the pattern and the failure to match occurred only
+ because there were not enough subject characters), pcre_exec() returns
+ PCRE_ERROR_PARTIAL instead of PCRE_ERROR_NOMATCH. When PCRE_PARTIAL is
+ used, there are restrictions on what may appear in the pattern. These
are discussed in the pcrepartial documentation.
The string to be matched by pcre_exec()
- The subject string is passed to pcre_exec() as a pointer in subject, a
- length in length, and a starting byte offset in startoffset. In UTF-8
- mode, the byte offset must point to the start of a UTF-8 character.
- Unlike the pattern string, the subject may contain binary zero bytes.
- When the starting offset is zero, the search for a match starts at the
+ The subject string is passed to pcre_exec() as a pointer in subject, a
+ length in length, and a starting byte offset in startoffset. In UTF-8
+ mode, the byte offset must point to the start of a UTF-8 character.
+ Unlike the pattern string, the subject may contain binary zero bytes.
+ When the starting offset is zero, the search for a match starts at the
beginning of the subject, and this is by far the most common case.
- A non-zero starting offset is useful when searching for another match
- in the same subject by calling pcre_exec() again after a previous suc-
- cess. Setting startoffset differs from just passing over a shortened
- string and setting PCRE_NOTBOL in the case of a pattern that begins
+ A non-zero starting offset is useful when searching for another match
+ in the same subject by calling pcre_exec() again after a previous suc-
+ cess. Setting startoffset differs from just passing over a shortened
+ string and setting PCRE_NOTBOL in the case of a pattern that begins
with any kind of lookbehind. For example, consider the pattern
\Biss\B
- which finds occurrences of "iss" in the middle of words. (\B matches
- only if the current position in the subject is not a word boundary.)
- When applied to the string "Mississipi" the first call to pcre_exec()
- finds the first occurrence. If pcre_exec() is called again with just
- the remainder of the subject, namely "issipi", it does not match,
+ which finds occurrences of "iss" in the middle of words. (\B matches
+ only if the current position in the subject is not a word boundary.)
+ When applied to the string "Mississipi" the first call to pcre_exec()
+ finds the first occurrence. If pcre_exec() is called again with just
+ the remainder of the subject, namely "issipi", it does not match,
because \B is always false at the start of the subject, which is deemed
- to be a word boundary. However, if pcre_exec() is passed the entire
+ to be a word boundary. However, if pcre_exec() is passed the entire
string again, but with startoffset set to 4, it finds the second occur-
- rence of "iss" because it is able to look behind the starting point to
+ rence of "iss" because it is able to look behind the starting point to
discover that it is preceded by a letter.
- If a non-zero starting offset is passed when the pattern is anchored,
+ If a non-zero starting offset is passed when the pattern is anchored,
one attempt to match at the given offset is made. This can only succeed
- if the pattern does not require the match to be at the start of the
+ if the pattern does not require the match to be at the start of the
subject.
How pcre_exec() returns captured substrings
- In general, a pattern matches a certain portion of the subject, and in
- addition, further substrings from the subject may be picked out by
- parts of the pattern. Following the usage in Jeffrey Friedl's book,
- this is called "capturing" in what follows, and the phrase "capturing
- subpattern" is used for a fragment of a pattern that picks out a sub-
- string. PCRE supports several other kinds of parenthesized subpattern
+ In general, a pattern matches a certain portion of the subject, and in
+ addition, further substrings from the subject may be picked out by
+ parts of the pattern. Following the usage in Jeffrey Friedl's book,
+ this is called "capturing" in what follows, and the phrase "capturing
+ subpattern" is used for a fragment of a pattern that picks out a sub-
+ string. PCRE supports several other kinds of parenthesized subpattern
that do not cause substrings to be captured.
- Captured substrings are returned to the caller via a vector of integer
- offsets whose address is passed in ovector. The number of elements in
- the vector is passed in ovecsize, which must be a non-negative number.
+ Captured substrings are returned to the caller via a vector of integer
+ offsets whose address is passed in ovector. The number of elements in
+ the vector is passed in ovecsize, which must be a non-negative number.
Note: this argument is NOT the size of ovector in bytes.
- The first two-thirds of the vector is used to pass back captured sub-
- strings, each substring using a pair of integers. The remaining third
- of the vector is used as workspace by pcre_exec() while matching cap-
- turing subpatterns, and is not available for passing back information.
- The length passed in ovecsize should always be a multiple of three. If
+ The first two-thirds of the vector is used to pass back captured sub-
+ strings, each substring using a pair of integers. The remaining third
+ of the vector is used as workspace by pcre_exec() while matching cap-
+ turing subpatterns, and is not available for passing back information.
+ The length passed in ovecsize should always be a multiple of three. If
it is not, it is rounded down.
- When a match is successful, information about captured substrings is
- returned in pairs of integers, starting at the beginning of ovector,
- and continuing up to two-thirds of its length at the most. The first
+ When a match is successful, information about captured substrings is
+ returned in pairs of integers, starting at the beginning of ovector,
+ and continuing up to two-thirds of its length at the most. The first
element of a pair is set to the offset of the first character in a sub-
- string, and the second is set to the offset of the first character
- after the end of a substring. The first pair, ovector[0] and ovec-
- tor[1], identify the portion of the subject string matched by the
- entire pattern. The next pair is used for the first capturing subpat-
+ string, and the second is set to the offset of the first character
+ after the end of a substring. The first pair, ovector[0] and ovec-
+ tor[1], identify the portion of the subject string matched by the
+ entire pattern. The next pair is used for the first capturing subpat-
tern, and so on. The value returned by pcre_exec() is one more than the
highest numbered pair that has been set. For example, if two substrings
- have been captured, the returned value is 3. If there are no capturing
- subpatterns, the return value from a successful match is 1, indicating
+ have been captured, the returned value is 3. If there are no capturing
+ subpatterns, the return value from a successful match is 1, indicating
that just the first pair of offsets has been set.
If a capturing subpattern is matched repeatedly, it is the last portion
of the string that it matched that is returned.
- If the vector is too small to hold all the captured substring offsets,
+ If the vector is too small to hold all the captured substring offsets,
it is used as far as possible (up to two-thirds of its length), and the
- function returns a value of zero. In particular, if the substring off-
+ function returns a value of zero. In particular, if the substring off-
sets are not of interest, pcre_exec() may be called with ovector passed
- as NULL and ovecsize as zero. However, if the pattern contains back
- references and the ovector is not big enough to remember the related
- substrings, PCRE has to get additional memory for use during matching.
+ as NULL and ovecsize as zero. However, if the pattern contains back
+ references and the ovector is not big enough to remember the related
+ substrings, PCRE has to get additional memory for use during matching.
Thus it is usually advisable to supply an ovector.
- The pcre_info() function can be used to find out how many capturing
- subpatterns there are in a compiled pattern. The smallest size for
- ovector that will allow for n captured substrings, in addition to the
+ The pcre_info() function can be used to find out how many capturing
+ subpatterns there are in a compiled pattern. The smallest size for
+ ovector that will allow for n captured substrings, in addition to the
offsets of the substring matched by the whole pattern, is (n+1)*3.
- It is possible for capturing subpattern number n+1 to match some part
+ It is possible for capturing subpattern number n+1 to match some part
of the subject when subpattern n has not been used at all. For example,
- if the string "abc" is matched against the pattern (a|(z))(bc) the
+ if the string "abc" is matched against the pattern (a|(z))(bc) the
return from the function is 4, and subpatterns 1 and 3 are matched, but
- 2 is not. When this happens, both values in the offset pairs corre-
+ 2 is not. When this happens, both values in the offset pairs corre-
sponding to unused subpatterns are set to -1.
- Offset values that correspond to unused subpatterns at the end of the
- expression are also set to -1. For example, if the string "abc" is
- matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not
- matched. The return from the function is 2, because the highest used
+ Offset values that correspond to unused subpatterns at the end of the
+ expression are also set to -1. For example, if the string "abc" is
+ matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not
+ matched. The return from the function is 2, because the highest used
capturing subpattern number is 1. However, you can refer to the offsets
- for the second and third capturing subpatterns if you wish (assuming
+ for the second and third capturing subpatterns if you wish (assuming
the vector is large enough, of course).
- Some convenience functions are provided for extracting the captured
+ Some convenience functions are provided for extracting the captured
substrings as separate strings. These are described below.
Error return values from pcre_exec()
- If pcre_exec() fails, it returns a negative number. The following are
+ If pcre_exec() fails, it returns a negative number. The following are
defined in the header file:
PCRE_ERROR_NOMATCH (-1)
PCRE_ERROR_NULL (-2)
- Either code or subject was passed as NULL, or ovector was NULL and
+ Either code or subject was passed as NULL, or ovector was NULL and
ovecsize was not zero.
PCRE_ERROR_BADOPTION (-3)
PCRE_ERROR_BADMAGIC (-4)
- PCRE stores a 4-byte "magic number" at the start of the compiled code,
+ PCRE stores a 4-byte "magic number" at the start of the compiled code,
to catch the case when it is passed a junk pointer and to detect when a
pattern that was compiled in an environment of one endianness is run in
- an environment with the other endianness. This is the error that PCRE
+ an environment with the other endianness. This is the error that PCRE
gives when the magic number is not present.
PCRE_ERROR_UNKNOWN_OPCODE (-5)
While running the pattern match, an unknown item was encountered in the
- compiled pattern. This error could be caused by a bug in PCRE or by
+ compiled pattern. This error could be caused by a bug in PCRE or by
overwriting of the compiled pattern.
PCRE_ERROR_NOMEMORY (-6)
- If a pattern contains back references, but the ovector that is passed
+ If a pattern contains back references, but the ovector that is passed
to pcre_exec() is not big enough to remember the referenced substrings,
- PCRE gets a block of memory at the start of matching to use for this
- purpose. If the call via pcre_malloc() fails, this error is given. The
+ PCRE gets a block of memory at the start of matching to use for this
+ purpose. If the call via pcre_malloc() fails, this error is given. The
memory is automatically freed at the end of matching.
PCRE_ERROR_NOSUBSTRING (-7)
- This error is used by the pcre_copy_substring(), pcre_get_substring(),
+ This error is used by the pcre_copy_substring(), pcre_get_substring(),
and pcre_get_substring_list() functions (see below). It is never
returned by pcre_exec().
PCRE_ERROR_MATCHLIMIT (-8)
- The backtracking limit, as specified by the match_limit field in a
- pcre_extra structure (or defaulted) was reached. See the description
+ The backtracking limit, as specified by the match_limit field in a
+ pcre_extra structure (or defaulted) was reached. See the description
above.
PCRE_ERROR_CALLOUT (-9)
This error is never generated by pcre_exec() itself. It is provided for
- use by callout functions that want to yield a distinctive error code.
+ use by callout functions that want to yield a distinctive error code.
See the pcrecallout documentation for details.
PCRE_ERROR_BADUTF8 (-10)
- A string that contains an invalid UTF-8 byte sequence was passed as a
+ A string that contains an invalid UTF-8 byte sequence was passed as a
subject.
PCRE_ERROR_BADUTF8_OFFSET (-11)
The UTF-8 byte sequence that was passed as a subject was valid, but the
- value of startoffset did not point to the beginning of a UTF-8 charac-
+ value of startoffset did not point to the beginning of a UTF-8 charac-
ter.
PCRE_ERROR_PARTIAL (-12)
- The subject string did not match, but it did match partially. See the
+ The subject string did not match, but it did match partially. See the
pcrepartial documentation for details of partial matching.
PCRE_ERROR_BADPARTIAL (-13)
- The PCRE_PARTIAL option was used with a compiled pattern containing
- items that are not supported for partial matching. See the pcrepartial
+ The PCRE_PARTIAL option was used with a compiled pattern containing
+ items that are not supported for partial matching. See the pcrepartial
documentation for details of partial matching.
PCRE_ERROR_INTERNAL (-14)
- An unexpected internal error has occurred. This error could be caused
+ An unexpected internal error has occurred. This error could be caused
by a bug in PCRE or by overwriting of the compiled pattern.
PCRE_ERROR_BADCOUNT (-15)
- This error is given if the value of the ovecsize argument is negative.
+ This error is given if the value of the ovecsize argument is negative.
PCRE_ERROR_RECURSIONLIMIT (-21)
The internal recursion limit, as specified by the match_limit_recursion
- field in a pcre_extra structure (or defaulted) was reached. See the
+ field in a pcre_extra structure (or defaulted) was reached. See the
description above.
PCRE_ERROR_NULLWSLIMIT (-22)
- When a group that can match an empty substring is repeated with an
- unbounded upper limit, the subject position at the start of the group
+ When a group that can match an empty substring is repeated with an
+ unbounded upper limit, the subject position at the start of the group
must be remembered, so that a test for an empty string can be made when
- the end of the group is reached. Some workspace is required for this;
+ the end of the group is reached. Some workspace is required for this;
if it runs out, this error is given.
PCRE_ERROR_BADNEWLINE (-23)
int pcre_get_substring_list(const char *subject,
int *ovector, int stringcount, const char ***listptr);
- Captured substrings can be accessed directly by using the offsets
- returned by pcre_exec() in ovector. For convenience, the functions
+ Captured substrings can be accessed directly by using the offsets
+ returned by pcre_exec() in ovector. For convenience, the functions
pcre_copy_substring(), pcre_get_substring(), and pcre_get_sub-
- string_list() are provided for extracting captured substrings as new,
- separate, zero-terminated strings. These functions identify substrings
- by number. The next section describes functions for extracting named
+ string_list() are provided for extracting captured substrings as new,
+ separate, zero-terminated strings. These functions identify substrings
+ by number. The next section describes functions for extracting named
substrings.
- A substring that contains a binary zero is correctly extracted and has
- a further zero added on the end, but the result is not, of course, a C
- string. However, you can process such a string by referring to the
- length that is returned by pcre_copy_substring() and pcre_get_sub-
+ A substring that contains a binary zero is correctly extracted and has
+ a further zero added on the end, but the result is not, of course, a C
+ string. However, you can process such a string by referring to the
+ length that is returned by pcre_copy_substring() and pcre_get_sub-
string(). Unfortunately, the interface to pcre_get_substring_list() is
- not adequate for handling strings containing binary zeros, because the
+ not adequate for handling strings containing binary zeros, because the
end of the final string is not independently indicated.
- The first three arguments are the same for all three of these func-
- tions: subject is the subject string that has just been successfully
+ The first three arguments are the same for all three of these func-
+ tions: subject is the subject string that has just been successfully
matched, ovector is a pointer to the vector of integer offsets that was
passed to pcre_exec(), and stringcount is the number of substrings that
- were captured by the match, including the substring that matched the
+ were captured by the match, including the substring that matched the
entire regular expression. This is the value returned by pcre_exec() if
- it is greater than zero. If pcre_exec() returned zero, indicating that
- it ran out of space in ovector, the value passed as stringcount should
+ it is greater than zero. If pcre_exec() returned zero, indicating that
+ it ran out of space in ovector, the value passed as stringcount should
be the number of elements in the vector divided by three.
- The functions pcre_copy_substring() and pcre_get_substring() extract a
- single substring, whose number is given as stringnumber. A value of
- zero extracts the substring that matched the entire pattern, whereas
- higher values extract the captured substrings. For pcre_copy_sub-
- string(), the string is placed in buffer, whose length is given by
- buffersize, while for pcre_get_substring() a new block of memory is
- obtained via pcre_malloc, and its address is returned via stringptr.
- The yield of the function is the length of the string, not including
+ The functions pcre_copy_substring() and pcre_get_substring() extract a
+ single substring, whose number is given as stringnumber. A value of
+ zero extracts the substring that matched the entire pattern, whereas
+ higher values extract the captured substrings. For pcre_copy_sub-
+ string(), the string is placed in buffer, whose length is given by
+ buffersize, while for pcre_get_substring() a new block of memory is
+ obtained via pcre_malloc, and its address is returned via stringptr.
+ The yield of the function is the length of the string, not including
the terminating zero, or one of these error codes:
PCRE_ERROR_NOMEMORY (-6)
- The buffer was too small for pcre_copy_substring(), or the attempt to
+ The buffer was too small for pcre_copy_substring(), or the attempt to
get memory failed for pcre_get_substring().
PCRE_ERROR_NOSUBSTRING (-7)
There is no substring whose number is stringnumber.
- The pcre_get_substring_list() function extracts all available sub-
- strings and builds a list of pointers to them. All this is done in a
+ The pcre_get_substring_list() function extracts all available sub-
+ strings and builds a list of pointers to them. All this is done in a
single block of memory that is obtained via pcre_malloc. The address of
- the memory block is returned via listptr, which is also the start of
- the list of string pointers. The end of the list is marked by a NULL
- pointer. The yield of the function is zero if all went well, or the
+ the memory block is returned via listptr, which is also the start of
+ the list of string pointers. The end of the list is marked by a NULL
+ pointer. The yield of the function is zero if all went well, or the
error code
PCRE_ERROR_NOMEMORY (-6)
if the attempt to get the memory block failed.
- When any of these functions encounter a substring that is unset, which
- can happen when capturing subpattern number n+1 matches some part of
- the subject, but subpattern n has not been used at all, they return an
+ When any of these functions encounter a substring that is unset, which
+ can happen when capturing subpattern number n+1 matches some part of
+ the subject, but subpattern n has not been used at all, they return an
empty string. This can be distinguished from a genuine zero-length sub-
- string by inspecting the appropriate offset in ovector, which is nega-
+ string by inspecting the appropriate offset in ovector, which is nega-
tive for unset substrings.
- The two convenience functions pcre_free_substring() and pcre_free_sub-
- string_list() can be used to free the memory returned by a previous
+ The two convenience functions pcre_free_substring() and pcre_free_sub-
+ string_list() can be used to free the memory returned by a previous
call of pcre_get_substring() or pcre_get_substring_list(), respec-
- tively. They do nothing more than call the function pointed to by
- pcre_free, which of course could be called directly from a C program.
- However, PCRE is used in some situations where it is linked via a spe-
- cial interface to another programming language that cannot use
- pcre_free directly; it is for these cases that the functions are pro-
+ tively. They do nothing more than call the function pointed to by
+ pcre_free, which of course could be called directly from a C program.
+ However, PCRE is used in some situations where it is linked via a spe-
+ cial interface to another programming language that cannot use
+ pcre_free directly; it is for these cases that the functions are pro-
vided.
int stringcount, const char *stringname,
const char **stringptr);
- To extract a substring by name, you first have to find associated num-
+ To extract a substring by name, you first have to find associated num-
ber. For example, for this pattern
(a+)b(?<xxx>\d+)...
be unique (PCRE_DUPNAMES was not set), you can find the number from the
name by calling pcre_get_stringnumber(). The first argument is the com-
piled pattern, and the second is the name. The yield of the function is
- the subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if there is no
+ the subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if there is no
subpattern of that name.
Given the number, you can extract the substring directly, or use one of
the functions described in the previous section. For convenience, there
are also two functions that do the whole job.
- Most of the arguments of pcre_copy_named_substring() and
- pcre_get_named_substring() are the same as those for the similarly
- named functions that extract by number. As these are described in the
- previous section, they are not re-described here. There are just two
+ Most of the arguments of pcre_copy_named_substring() and
+ pcre_get_named_substring() are the same as those for the similarly
+ named functions that extract by number. As these are described in the
+ previous section, they are not re-described here. There are just two
differences:
- First, instead of a substring number, a substring name is given. Sec-
+ First, instead of a substring number, a substring name is given. Sec-
ond, there is an extra argument, given at the start, which is a pointer
- to the compiled pattern. This is needed in order to gain access to the
+ to the compiled pattern. This is needed in order to gain access to the
name-to-number translation table.
- These functions call pcre_get_stringnumber(), and if it succeeds, they
- then call pcre_copy_substring() or pcre_get_substring(), as appropri-
- ate.
+ These functions call pcre_get_stringnumber(), and if it succeeds, they
+ then call pcre_copy_substring() or pcre_get_substring(), as appropri-
+ 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
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: 24 April 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
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,
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: 06 March 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
(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: 06 March 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
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.
+ 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.
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-
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.
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: 06 March 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
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
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
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:
+ 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
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: 06 March 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
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
7.0 or higher, because there was an internal reorganization at that
release.
-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: 24 April 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
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.
------------------------------------------------------------------------------
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.
------------------------------------------------------------------------------
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
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
------------------------------------------------------------------------------
(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: 06 March 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
PCRESTACK(3) PCRESTACK(3)
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-
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: 12 March 2007
+ Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-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
/* 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
#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 -RC1
+#define PCRE_DATE 2007-05-02
-/* 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
#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 */
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" */
* 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[] = {
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,
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 */
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 */
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
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 - ? */
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,
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 */
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 */
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 */
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 */
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
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
{
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
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
else
{
code += _pcre_OP_lengths[c];
+#ifdef SUPPORT_UTF8
if (utf8) switch(c)
{
case OP_CHAR:
if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f];
break;
}
+#endif
}
}
}
else
{
code += _pcre_OP_lengths[c];
+#ifdef SUPPORT_UTF8
if (utf8) switch(c)
{
case OP_CHAR:
if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f];
break;
}
+#endif
}
}
}
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)
{
}
-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)
{
if (erroroffset == NULL)
{
errorcode = ERR16;
- goto PCRE_EARLY_ERROR_RETURN;
+ goto PCRE_EARLY_ERROR_RETURN2;
}
*erroroffset = 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)
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))
{
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;
}
(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;
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. */
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
Returns: 0 if data returned, negative on error
*/
-PCRE_DATA_SCOPE int
+PCRE_EXP_DEFN int
pcre_config(int what, void *where)
{
switch (what)
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
#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. */
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,rc,rd,re,rf,rg,rdepth+1); \
printf("to line %d\n", __LINE__); \
}
#define RRETURN(ra) \
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,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->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)\
(pcre_stack_free)(newframe);\
if (frame != NULL)\
{\
- frame->Xresult = ra;\
- md->thisframe = frame;\
- longjmp(frame->Xwhere, 1);\
+ rrc = ra;\
+ goto HEAP_RETURN;\
}\
return ra;\
}
int Xprop_category;
int Xprop_chartype;
int Xprop_script;
+ int Xoclength;
+ uschar Xocchars[8];
#endif
int Xctype;
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;
#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
int prop_category;
int prop_chartype;
int prop_script;
+int oclength;
+uschar occhars[8];
#endif
int ctype;
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. */
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
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);
/* 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);
}
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;
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);
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);
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"));
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);
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;
}
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;
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;
{
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++;
}
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;
}
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;
{
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);
}
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;
}
{
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);
{
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++;
}
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);
}
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--;
}
{
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);
}
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)
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
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;
{
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
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 */
}
{
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 */
}
{
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++])
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);
}
{
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);
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);
}
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];
{
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);
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);
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--;
}
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)
{
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);
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);
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--;
}
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);
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);
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);
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);
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);
{
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);
{
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 &&
{
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)))
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);
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 */
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);
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);
}
} /* 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 */
}
< -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)
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 */
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;
}
{
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++;
}
}
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++;
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
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)
{
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
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
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 */
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
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;
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
/* 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. */
#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
#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] && \
#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] && \
#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
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)
/* 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 */
/* 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| \
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. */
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
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
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
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
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/. */
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
*/
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 */
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
*/
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--;
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 */
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
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;
}
*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 */
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
{
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);
if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c);
return a;
}
+#endif
}
*************************************************/
/* 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;
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)
{
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:
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:
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:
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
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;
+++ /dev/null
-// 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
+++ /dev/null
-// 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 */
+++ /dev/null
-// 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;
-}
+++ /dev/null
-// 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());
-}
+++ /dev/null
-// 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 */
+++ /dev/null
-// 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;
-}
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
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:
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];
/* 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];
}
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];
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
/* 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};
const int _pcre_utt_size = sizeof(_pcre_utt)/sizeof(ucp_type_table);
+#endif /* SUPPORT_UTF8 */
+
/* End of pcre_tables.c */
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
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
#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 */
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
int
_pcre_valid_utf8(const uschar *string, int length)
{
+#ifdef SUPPORT_UTF8
register const uschar *p;
if (length < 0)
if ((*(++p) & 0xc0) != 0x80) return p - string;
}
}
+#endif
return -1;
}
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
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)?
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
+++ /dev/null
-// 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
+++ /dev/null
-// 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 */
+++ /dev/null
-// -*- 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;
-}
+++ /dev/null
-// 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 */
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <stdio.h>
#include <string.h>
#include <pcre.h>
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
-----------------------------------------------------------------------------
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <ctype.h>
#include <locale.h>
#include <stdio.h>
#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
/* Line ending types */
-enum { EL_LF, EL_CR, EL_CRLF, EL_ANY };
+enum { EL_LF, EL_CR, EL_CRLF, EL_ANY, EL_ANYCRLF };
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;
{ 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" },
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};
/************* 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>
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
when it did not exist. */
-#elif HAVE_WIN32API
+#elif HAVE_WINDOWS_H
#ifndef STRICT
# define STRICT
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) {}
-#if ! HAVE_STRERROR
+#ifndef HAVE_STRERROR
/*************************************************
* Provide strerror() for non-ANSI libraries *
*************************************************/
}
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)
{
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--;
}
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 */
while ((nextfile = readdirectory(dir)) != NULL)
{
int frc, blen;
- blen = snprintf(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)
{
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;
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;
{
static char buffer[8];
char *p = buffer;
-snprintf(p, sizeof(buffer), "%d", n);
+sprintf(p, "%d", n);
while (*p != 0) p++;
switch (n%10)
{
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 */
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;
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];
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 */
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;
}
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);
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,
{
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. */
{
fprintf(stderr, "pcregrep: Failed to open %s: %s\n", pattern_filename,
strerror(errno));
- return 2;
+ goto EXIT2;
}
filename = pattern_filename;
}
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);
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. */
{
fprintf(stderr, "pcregrep: Error in 'exclude' regex at offset %d: %s\n",
errptr, error);
- return 2;
+ goto EXIT2;
}
}
{
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
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 */
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
* 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;
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);
* Free store held by a regex *
*************************************************/
-PCRE_DATA_SCOPE void
+PCREPOSIX_EXP_DEFN void
regfree(regex_t *preg)
{
(pcre_free)(preg->re_pcre);
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;
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)
{
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
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" */
+++ /dev/null
-/*************************************************
-* 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 */
nineteen
twenty
-Here follows some CR/LF/CRLF test data.
-
-abc
-def
-ghi
-jkl
-
This is the last line of this file.
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 -----------------------------
nineteen
twenty
-Here follows some CR/LF/CRLF test data.
-
+This is the last line of this file.
---------------------------- Test 25 -----------------------------
15-
16-complete pair
nineteen
twenty
-Here follows some CR/LF/CRLF test data.
-
+This is the last line of this file.
---------------------------- Test 27 -----------------------------
four
five
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-
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.
./testdata/grepinputx
RC=0
---------------------------- Test 36 -----------------------------
-./testdata/grepinputx
./testdata/grepinput8
+./testdata/grepinputx
RC=0
---------------------------- Test 37 -----------------------------
aaaaa0
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
--- /dev/null
+---------------------------- 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
--- /dev/null
+/-- 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 /
\O3abcb
\O6abcb
\O9abcb
- \O12abcb
+ \O12abcb
/(a)bc|(a)(b)\2/I
abc
/abc/IP
abc
*** Failers
-
+
/^abc|def/IP
abcdef
abcdef\B
/.*((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
/a[]b/
/[^aeiou ]{3,}/I
- co-processors, and for
-
+ co-processors, and for
+
/<.*>/I
abc<def>ghi<klm>nop
/<.*>/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/
/((?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
/(?!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/
a donkey-cart race
*** Failers
cart
- horse-and-cart
-
+ horse-and-cart
+
/(?<=ab(?i)x|y|z)/I
/(?>.*)(?<=(abcd)|(xyz))/I
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]/
abcd
abcd\C2
abcd\C5
-
+
/(.{20})/I
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz\C1
abcdefghijklmnopqrstuvwxyz\G1
-
+
/(.{15})/I
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz\C1\G1
/(.{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
-/(?s:.*X|^B)/ID
+/(.*X|^B)/IDZs
+
+/(?s)(.*X|^B)/IDZ
+
+/(?s:.*X|^B)/IDZ
/\Biss\B/I+
Mississippi
/^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
ab
\
*** Failers
- \N
-
+ \N
+
/|-/I
abcd
-abc
\Nab-c
*** Failers
- \Nabc
+ \Nabc
/a*(b+)(z)(z)/IP
aaaabbbbzzzz
aaaabbbbzzzz\O3
aaaabbbbzzzz\O4
aaaabbbbzzzz\O5
-
-/^.?abcd/IS
+
+/^.?abcd/IS
/\( # ( at start
(?: # Non-capturing bracket
(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
()
(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
/[[:upper:]]/Ii
A
- a
-
+ a
+
/[[:lower:]]/Ii
A
- a
+ a
/((?-i)[[:lower:]])[[:lower:]]/Ii
ab
aB
*** Failers
Ab
- AB
+ AB
/[\200-\110]/I
/(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
+
+/#/IxDZ
-/a#/IxMD
+/a#/IxDZ
-/[\s]/D
+/[\s]/DZ
-/[\S]/D
+/[\S]/DZ
-/a(?i)b/D
+/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
/([^()]++|\([^()]*\))+/I
((abc(ade)ufh()()x
-
-/\(([^()]++|\([^()]+\))+\)/I
+
+/\(([^()]++|\([^()]+\))+\)/I
(abc)
(abc(def)xyz)
*** Failers
- ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-/(abc){1,3}+/D
+/(abc){1,3}+/DZ
/a+?+/I
/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
/[[: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
/((.*))\d+\1/I
abc123bc
-
+
/a[b]/I
/(?=a).*/I
/^a/Im
abcde
- xy\nabc
- *** Failers
- xyabc
+ xy\nabc
+ *** Failers
+ xyabc
/c|abc/I
/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
/(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+
/(?=(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
xxab
xxxab
*** Failers
- xyab
+ xyab
/(ab|(bc|(de|(?1))))/I
/^([^()]|\((?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
/^(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
/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)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
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
"\[((?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
+
+/(a|b)*.?c/ISDZ
-/abc(?C255)de(?C)f/D
+/abc(?C255)de(?C)f/DZ
-/abcde/ICD
+/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
/(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
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
b\P
c\P
c12\P
- c123\P
+ c123\P
/^(?:\d){3,5}X/I
1\P
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
<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>
/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
/[^()]*(?:\((?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
/^((?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
aabc
bc
** Failers
- abc
+ abc
/(?:(?(ZZ)a|b)(?P<ZZ>X))+/I
bXaX
/(?:(?(A)(?P=A)a|b)(?P<A>X|Y))+/I
bXXaYYaY
- bXYaXXaX
+ bXYaXXaX
/()()()()()()()()()(?:(?(A)(?P=A)a|b)(?P<A>X|Y))+/I
bXXaYYaY
/\s*,\s*/IS
\x0b,\x0b
- \x0c,\x0d
+ \x0c,\x0d
/^abc/Im
xyz\nabc
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
()()()()()()()()()()()()()()()()()()()()
()()()()()()()()()()()()()()()()()()()()
(.(.))/Ix
- XY\O400
+ XY\O400
/(a*b|(?i:c*(?-i)d))/IS
/(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
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
bXaX
bXbX
** Failers
- aXaX
- aXbX
+ aXaX
+ aXbX
/^(?P>abc)(?<abcd>xxx)/
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:
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)/
/^(?(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
/^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
a\r\nb
a\x0bb
a\x0cb
- a\x85b
+ a\x85b
** Failers
- a\n\rb
+ a\n\rb
/^a\R*b/
ab
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
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
/^a[\R]b/
aRb
** Failers
- a\nb
+ a\nb
/(?&abc)X(?<abc>P)/I
abcPXP123
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
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
/.+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
/ End of testinput2 /
>>>\xaa<<<
>>>\xba<<<
-/[[:alpha:]][[:lower:]][[:upper:]]/DLfr_FR
+/[[:alpha:]][[:lower:]][[:upper:]]/DZLfr_FR
/ End of testinput3 /
-/\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
/^\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
/(?<=\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}
\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
*** 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
\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
/ÃÃÃxxx/8
-/ÃÃÃxxx/8?D
+/ÃÃÃxxx/8?DZ
/abc/8
Ã]
\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
/a\x{1234}b/P8
a\x{1234}b
-/^\ሴ/8D
+/^\ሴ/8DZ
/\777/I
\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
/()()()()()()()()()()
()()()()()()()()()()
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
** 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
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}
\x{c0}
\x{e0}
-/[\x{105}-\x{109}]/8iD
+/[\x{105}-\x{109}]/8iDZ
\x{104}
\x{105}
\x{109}
\x{100}
\x{10a}
-/[z-\x{100}]/8iD
+/[z-\x{100}]/8iDZ
Z
z
\x{39c}
Y
y
-/[z-\x{100}]/8Di
+/[z-\x{100}]/8DZi
/^\X/8
A
/^\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 /
\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
+
/ End of testinput7 /
\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 /
--- /dev/null
+/-- 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 /
0: abcb
1: a
2: b
- \O12abcb
+ \O12abcb
0: abcb
1: a
2: b
0: abc
*** Failers
No match: POSIX code 17: match failed
-
+
/^abc|def/IP
abcdef
0: abc
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
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
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
Need char = '>'
abc<def>ghi<klm>nop
0: <def>
-
+
/(?U)<.*>/I
Capturing subpattern count = 0
Partial matching not supported
Need char = '>'
abc<def>ghi<klm>nop
0: <def>ghi<klm>
-
+
/={3,}/IU
Capturing subpattern count = 0
Partial matching not supported
Need char = '='
abc========def
0: ===
-
+
/(?U)={3,}?/I
Capturing subpattern count = 0
Partial matching not supported
Need char = '='
abc========def
0: ========
-
+
/(?<!bar|cattle)foo/I
Capturing subpattern count = 0
No options
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/
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
0: a
a\n
0: a
- *** Failers
+ *** Failers
No match
\Za
No match
- \Za\n
+ \Za\n
No match
/a$/Im
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
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
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
0: abc
*** Failers
No match
- defabc
+ defabc
No match
/(?<=ab(c+)d)ef/
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
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
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
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
aaaaaa
0: aaaaaa
1: aa
-
+
/These are syntax tests from Perl 5.005/I
Capturing subpattern count = 0
No options
1: a
2: d
copy substring 5 failed -7
-
+
/(.{20})/I
Capturing subpattern count = 1
Partial matching not supported
0: abcdefghijklmnopqrst
1: abcdefghijklmnopqrst
1G abcdefghijklmnopqrst (20)
-
+
/(.{15})/I
Capturing subpattern count = 1
Partial matching not supported
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>
1L a
2L
3L f
- bcdef\G1\G2\G3\G4\L
+ bcdef\G1\G2\G3\G4\L
0: bcdef
1: bc
2: bc
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
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
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
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
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
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
0+ river
0: riv
0+ er
- Missouri river\A
+ Missouri river\A
0: Mis
0+ souri river
0:
*** Failers
0:
- \N
+ \N
No match
-
+
/|-/I
Capturing subpattern count = 0
No options
0: -
*** Failers
0:
- \Nabc
+ \Nabc
No match
/a*(b+)(z)(z)/IP
1: bbbb
2: z
3: z
-
-/^.?abcd/IS
+
+/^.?abcd/IS
Capturing subpattern count = 0
Options: anchored
No first 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
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
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
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
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
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
No need char
A
0: A
- a
+ a
0: a
-
+
/[[:lower:]]/Ii
Capturing subpattern count = 0
Options: caseless
No need char
A
0: A
- a
+ a
0: a
/((?-i)[[:lower:]])[[:lower:]]/Ii
1: a
Ab
No match
- AB
+ AB
No match
/[\200-\110]/I
0: mainOmain
1: main
2: O
-
+
/These are all cases where Perl does it differently (nested captures)/I
Capturing subpattern count = 1
No options
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
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: bb
2: b
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: bb
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
Options: anchored
No first char
No need char
- aabbaa
+ aabbaa
0: aabbaa
1: b
Options: anchored
No first char
No need char
- aabbbaa
+ aabbbaa
0: aabbbaa
1: bb
Options: anchored
No first char
No need char
- aabbbaa
+ aabbbaa
0: aabbbaa
1: aa
2: bbb
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
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
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
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
\
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
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
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
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
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
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
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
2: a
*** Failers
No match
- 12345+
+ 12345+
No match
/a++b/I
((abc(ade)ufh()()x
0: abc(ade)ufh()()x
1: x
-
-/\(([^()]++|\([^()]+\))+\)/I
+
+/\(([^()]++|\([^()]+\))+\)/I
Capturing subpattern count = 1
Partial matching not supported
No options
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
/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
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
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
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
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
/[[: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
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
No options
First char at start or follows newline
No need char
-
+
/(.*)\d+\1/Is
Capturing subpattern count = 1
Max back reference = 1
0: bc123bc
1: bc
2: bc
-
+
/a[b]/I
Capturing subpattern count = 0
No options
Need char = 'a'
abcde
0: a
- xy\nabc
+ xy\nabc
0: a
- *** Failers
+ *** Failers
No match
- xyabc
+ xyabc
No match
/c|abc/I
--->abcdef
0 ^ ^ d
0: abcdef
- 1234abcdef
+ 1234abcdef
--->1234abcdef
0 ^ ^ d
0: abcdef
No match
abcxyz
No match
- abcxyzf
+ abcxyzf
--->abcxyzf
0 ^ ^ d
No match
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
0: 4abcdef
*** Failers
No match
- abcdef
+ abcdef
--->abcdef
1 ^ \d
1 ^ \d
1 ^ \d
1 ^ \d
No match
-
+
/(?C255)ab/I
Capturing subpattern count = 0
No options
/(?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
1 ^ ^ f
0: abcdef
1: abc
- 123abcdef\C+
+ 123abcdef\C+
Callout 0: last capture = 1
0: <unset>
1: abc
^ ^ 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
1 ^ ^ )
0: abcabcabc
1: abc
- abcabc\C!1!3
+ abcabc\C!1!3
--->abcabc
0 ^ (abc(?C1))*
1 ^ ^ )
--->*** Failers
0 ^ (abc(?C1))*
0:
- abcabcabc\C!1!3
+ abcabcabc\C!1!3
--->abcabcabc
0 ^ (abc(?C1))*
1 ^ ^ )
^ ^ )
0: 123456
1: 456
- 123456789\C+
+ 123456789\C+
Callout 0: last capture = -1
0: <unset>
--->123456789
^ 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
^ )
0: xyz
1: abc
-
+
/a(b+)(c*)(?C1)/I
Capturing subpattern count = 2
Partial matching not supported
1 ^ ^
Callout data = 1
No match
-
-/(?C)abc/I
+
+/(?C)abc/I
Capturing subpattern count = 0
No options
First char = 'a'
3: xxab
*** Failers
No match
- xyab
+ xyab
No match
/(ab|(bc|(de|(?1))))/I
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
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
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>
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
No match
((2+2)*-3)-7)
No match
-
+
/^(x(y|(?1){2})z)/I
Capturing subpattern count = 2
Options: anchored
0: xyz
1: xyz
2: y
- xxyzxyzz
+ xxyzxyzz
0: xxyzxyzz
1: xxyzxyzz
2: xyzxyz
No match
xxyzz
No match
- xxyzxyzxyzz
+ xxyzxyzxyzz
No match
/((< (?: (?(R) \d++ | [^<>]*+) | (?2)) * >))/Ix
0: <def>
1: <def>
2: <def>
- <abc<>def>
+ <abc<>def>
0: <abc<>def>
1: <abc<>def>
2: <abc<>def>
- <abc<>
+ <abc<>
0: <>
1: <>
2: <>
a=b
0: a=b
1: a
- a=bc
+ a=bc
0: a=bc
1: a
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:
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:
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
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>
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
bb
0: bb
1: b
- bbaa
+ bbaa
0: bba
1: b
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
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:
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:
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:
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:
3: ,4234
*** Failers
No match
- []
+ []
No match
"\[((?P<elem>\d+)(,(?P>elem))*)?\]"I
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
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
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
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:
+4 ^ ^ e
+5 ^ ^
0: abcde
- abcdfe
+ abcdfe
--->abcdfe
+0 ^ a
+1 ^^ b
+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
+2 ^ ^ b
+3 ^ ^
0: aaaab
- aaaacb
+ aaaacb
--->aaaacb
+0 ^ a*
+2 ^ ^ 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
+2 ^ ^ b
+3 ^ ^
0: aaaab
- aaaacb
+ aaaacb
--->aaaacb
+0 ^ a+
+2 ^ ^ 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:
+12 ^ ^
0: abcdabcd
1: cd
- abcdcdcdcdcd
+ abcdcdcdcdcd
--->abcdcdcdcdcd
+0 ^ (ab|cd){3,4}
+1 ^ a
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:
+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
No need char
ab cd\>1
0: cd
-
-/\b.*/Is
+
+/\b.*/Is
Capturing subpattern count = 0
Partial matching not supported
Options: dotall
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
Partial match
abcd\P
Partial match
- abcde\P
+ abcde\P
0: abcde
the quick brown abc\P
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
1: 13
2: 5
3: 20
- 02/05/09\P
+ 02/05/09\P
0: 02/05/09
1: 02
2: 05
Partial match
1/2/0\P
Partial match
- 1/2/04\P
+ 1/2/04\P
0: 1/2/04
1: 1
2: 2
Partial match
02/\P
Partial match
- 02/0\P
+ 02/0\P
Partial match
02/1\P
Partial 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
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
Partial match
c12\P
Partial match
- c123\P
+ c123\P
0: c123
/^(?:\d){3,5}X/I
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
No match
bca
No match
-
+
/abc/IF>testsavedregex
Capturing subpattern count = 0
No options
** Failers
0: a
1: a
- def
+ def
No match
-
+
/(a|b)/ISF>testsavedregex
Capturing subpattern count = 1
No options
** Failers
0: a
1: a
- def
+ def
No match
-
+
~<(\w+)/?>(.)*</(\1)>~smgI
Capturing subpattern count = 3
Max back reference = 1
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
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
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
/ab.cd/IPs
ab-cd
0: ab-cd
- ab=cd
+ ab=cd
0: ab=cd
ab\ncd
0: ab\x0acd
0: AbCd
** Failers
No match
- abcd
+ abcd
No match
-
+
/a{11111111111111111111}/I
Failed: number too big in {} quantifier at offset 22
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
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
No need char
(this(and)that
0:
- (this(and)that)
+ (this(and)that)
0: (this(and)that)
/(?:\((?R)\))*[^()]*/I
No need char
(this(and)that
0:
- (this(and)that)
+ (this(and)that)
0:
- ((this))
+ ((this))
0: ((this))
/(?:\((?R)\))|[^()]*/I
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
1: a1
2: a1
C a1 (2) A
- a2b\CA
+ a2b\CA
0: a2b
1: a2b
2: <unset>
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:
1: a
2: b
C a (1) A
-
+
/^(?P<A>a)(?P<A>b)|cd/IJ
Capturing subpattern count = 2
Named capturing subpatterns:
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:
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:
1: a1
2: a1
G a1 (2) A
- a2b\GA
+ a2b\GA
0: a2b
1: a2b
2: <unset>
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:
1: a
2: b
G a (1) A
-
+
/^(?P<A>a)(?P<A>b)|cd/IJ
Capturing subpattern count = 2
Named capturing subpatterns:
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:
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:
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
0: b
** Failers
No match
- abc
+ abc
No match
/(?:(?(ZZ)a|b)(?P<ZZ>X))+/I
bXXaYYaY
0: bXXaYYaY
1: Y
- bXYaXXaX
+ bXYaXXaX
0: bX
1: X
Starting byte set: \x09 \x0a \x0c \x0d \x20 ,
\x0b,\x0b
0: ,
- \x0c,\x0d
+ \x0c,\x0d
0: \x0c,\x0d
/^abc/Im
0: abc
xyz\r\nabc\<crlf>
0: abc
- ** Failers
+ ** Failers
No match
xyz\nabc\<cr>
No match
No match
xyz\rabc\<lf>
No match
-
+
/abc$/Im<lf>
Capturing subpattern count = 0
Options: multiline
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
0: abc
xyz\nabcdef\<lf>
0: abc
- ** Failers
+ ** Failers
No match
xyz\nabcdef
No match
-
+
/^abc/Im<lf>
Capturing subpattern count = 0
Options: multiline
0: abc
xyz\rabcdef\<cr>
0: abc
- ** Failers
+ ** Failers
No match
xyz\rabcdef
No match
-
+
/^abc/Im<crlf>
Capturing subpattern count = 0
Options: multiline
0: abc
xyz\rabcdef\<cr>
0: abc
- ** Failers
+ ** Failers
No match
xyz\rabcdef
No match
-
+
/^abc/Im<bad>
Unknown newline type at: <bad>
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
Options: extended
No first char
No need char
- XY\O400
+ XY\O400
0: XY
1:
2:
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
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
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
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
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
a
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
- )))
-/Ix
+ )))
+/Ix
Capturing subpattern count = 203
Options: extended
First char = 'a'
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
1: X
** Failers
No match
- aXaX
+ aXaX
No match
- aXbX
+ aXbX
No match
/^(?P>abc)(?<abcd>xxx)/
yy
0: yy
1: y
- yx
+ yx
0: yx
1: x
yy
0: yy
1: y
- yx
+ yx
0: yx
1: x
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))+/
3: y
** Failers
No match
- x
+ x
No match
/^(?1)(abc)/
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
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>
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
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
No match
addd
No match
- adbb
+ adbb
No match
/(?'abc'a|b)(?<abc>d|e)(?&abc){2}/J
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)/
0: ab
1: <unset>
2: <unset>
-
+
/(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
(?(DEFINE)
(?<NAME_PAT>[a-z]+)
2: 33
3: <unset>
4: <unset>
-
+
/^(?(DEFINE) abc | xyz ) /x
Failed: DEFINE group contains more than one branch at offset 22
/^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>
0: abc9
/a/<cr><any>
-Failed: inconsistent NEWLINE options at offset 0
/a/<any><crlf>
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/
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/
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
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
0: aRb
** Failers
No match
- a\nb
+ a\nb
No match
/(?&abc)X(?<abc>P)/I
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))/
No match
10.6
No match
- 455.3.4.5
+ 455.3.4.5
No match
-
+
/(?:a(?&abc)b)*(?<abc>x)/
123axbaxbaxbx456
0: axbaxbaxbx
123axbaxbaxb456
0: x
1: x
-
+
/(?:a(?&abc)b){1,5}(?<abc>x)/
123axbaxbaxbx456
0: axbaxbaxbx
/.+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
/ End of testinput2 /
>>>\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
-/\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
\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
\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
\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
\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
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
\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
/(?<=\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}
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
\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
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
\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
\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
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
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
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
\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
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
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
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
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
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
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
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
*** 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
\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
Ā
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
>\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
>\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
/ÃÃÃ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
\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
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
\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
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
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
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
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
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
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
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
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
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>
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
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
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
\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
\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
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
\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 /
\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+
+
/ End of testinput7 /
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 /
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 },