]> granicus.if.org Git - php/commitdiff
upgrade to PCRE 7.2 RC3
authorNuno Lopes <nlopess@php.net>
Thu, 14 Jun 2007 19:43:42 +0000 (19:43 +0000)
committerNuno Lopes <nlopess@php.net>
Thu, 14 Jun 2007 19:43:42 +0000 (19:43 +0000)
add script to automate upgrade of the bundled PCRE lib

23 files changed:
ext/pcre/pcrelib/ChangeLog
ext/pcre/pcrelib/HACKING
ext/pcre/pcrelib/NEWS
ext/pcre/pcrelib/NON-UNIX-USE
ext/pcre/pcrelib/config.h
ext/pcre/pcrelib/doc/pcre.txt
ext/pcre/pcrelib/pcre.h
ext/pcre/pcrelib/pcre_compile.c
ext/pcre/pcrelib/pcre_exec.c
ext/pcre/pcrelib/pcre_fullinfo.c
ext/pcre/pcrelib/pcre_internal.h
ext/pcre/pcrelib/pcreposix.c
ext/pcre/pcrelib/testdata/testinput1
ext/pcre/pcrelib/testdata/testinput2
ext/pcre/pcrelib/testdata/testinput5
ext/pcre/pcrelib/testdata/testinput7
ext/pcre/pcrelib/testdata/testinput8
ext/pcre/pcrelib/testdata/testoutput1
ext/pcre/pcrelib/testdata/testoutput2
ext/pcre/pcrelib/testdata/testoutput5
ext/pcre/pcrelib/testdata/testoutput7
ext/pcre/pcrelib/testdata/testoutput8
ext/pcre/upgrade-pcre.php [new file with mode: 0644]

index ab7be939e355dd55d96a480962e48878a1057035..fb2747fd09187e7a30b24339dced284bb8880013 100644 (file)
@@ -1,7 +1,7 @@
 ChangeLog for PCRE
 ------------------
 
-Version 7.2 01-May-07
+Version 7.2 13-June-07
 ---------------------
 
  1. If the fr_FR locale cannot be found for test 3, try the "french" locale,
@@ -22,6 +22,53 @@ Version 7.2 01-May-07
     a small improvement under Linux. However, it saves one field in the frame
     in all cases.
 
+ 6. Added more features from the forthcoming Perl 5.10:
+
+    (a) (?-n) (where n is a string of digits) is a relative subroutine or
+        recursion call. It refers to the nth most recently opened parentheses.
+
+    (b) (?+n) is also a relative subroutine call; it refers to the nth next
+        to be opened parentheses.
+
+    (c) Conditions that refer to capturing parentheses can be specified
+        relatively, for example, (?(-2)... or (?(+3)...
+
+    (d) \K resets the start of the current match so that everything before
+        is not part of it.
+
+    (e) \k{name} is synonymous with \k<name> and \k'name' (.NET compatible).
+
+    (f) \g{name} is another synonym - part of Perl 5.10's unification of
+        reference syntax.
+
+    (g) (?| introduces a group in which the numbering of parentheses in each
+        alternative starts with the same number.
+
+    (h) \h, \H, \v, and \V match horizontal and vertical whitespace.
+
+ 7. Added two new calls to pcre_fullinfo(): PCRE_INFO_OKPARTIAL and
+    PCRE_INFO_JCHANGED.
+
+ 8. A pattern such as  (.*(.)?)*  caused pcre_exec() to fail by either not
+    terminating or by crashing. Diagnosed by Viktor Griph; it was in the code
+    for detecting groups that can match an empty string.
+
+ 9. A pattern with a very large number of alternatives (more than several
+    hundred) was running out of internal workspace during the pre-compile
+    phase, where pcre_compile() figures out how much memory will be needed. A
+    bit of new cunning has reduced the workspace needed for groups with
+    alternatives. The 1000-alternative test pattern now uses 12 bytes of
+    workspace instead of running out of the 4096 that are available.
+
+10. Inserted some missing (unsigned int) casts to get rid of compiler warnings.
+
+11. Applied patch from Google to remove an optimization that didn't quite work.
+    The report of the bug said:
+
+      pcrecpp::RE("a*").FullMatch("aaa") matches, while
+      pcrecpp::RE("a*?").FullMatch("aaa") does not, and
+      pcrecpp::RE("a*?\\z").FullMatch("aaa") does again.
+
 
 Version 7.1 24-Apr-07
 ---------------------
index c75b3e8a5d1d60d07cbcea6675b1a0d6e5a9cb79..49bba8a702ee30f1e5fe885338cf803278a212d7 100644 (file)
@@ -129,13 +129,18 @@ These items are all just one byte long
   OP_ANYBYTE             match any single byte, even in UTF-8 mode
   OP_SOD                 match start of data: \A
   OP_SOM,                start of match (subject + offset): \G
+  OP_SET_SOM,            set start of match (\K) 
   OP_CIRC                ^ (start of data, or after \n in multiline)
   OP_NOT_WORD_BOUNDARY   \W
   OP_WORD_BOUNDARY       \w
   OP_NOT_DIGIT           \D
   OP_DIGIT               \d
+  OP_NOT_HSPACE          \H
+  OP_HSPACE              \h  
   OP_NOT_WHITESPACE      \S
   OP_WHITESPACE          \s
+  OP_NOT_VSPACE          \V
+  OP_VSPACE              \v  
   OP_NOT_WORDCHAR        \W
   OP_WORDCHAR            \w
   OP_EODN                match end of data or \n at end: \Z
@@ -399,4 +404,4 @@ at compile time, and so does not cause anything to be put into the compiled
 data.
 
 Philip Hazel
-November 2006
+June 2007
index f0fad3e80c3a03f99828cd16a00b4e87d60d9fb5..26d0999d9197fbf9b326dac4660cbcdcfd35e3ba 100644 (file)
@@ -2,9 +2,13 @@ News about PCRE releases
 ------------------------
 
 
-Release 7.2 30-Apr-07
+Release 7.2 13-Jun-07
 ---------------------
 
+WARNING: saved patterns that were compiled by earlier versions of PCRE must be
+recompiled for use with 7.2 (necessitated by the addition of \K, \h, \H, \v,
+and \V).
+
 Correction to the notes for 7.1: the note about shared libraries for Windows is
 wrong. Previously, three libraries were built, but each could function
 independently. For example, the pcreposix library also included all the
@@ -13,6 +17,23 @@ are no longer independent. They are like the Unix libraries. To use the
 pcreposix functions, for example, you need to link with both the pcreposix and
 the basic pcre library.
 
+Some more features from Perl 5.10 have been added:
+
+  (?-n) and (?+n) relative references for recursion and subroutines.
+
+  (?(-n) and (?(+n) relative references as conditions.
+
+  \k{name} and \g{name} are synonyms for \k<name>.
+
+  \K to reset the start of the matched string; for example, (foo)\Kbar
+  matches bar preceded by foo, but only sets bar as the matched string.
+
+  (?| introduces a group where the capturing parentheses in each alternative
+  start from the same number; for example, (?|(abc)|(xyz)) sets capturing
+  parentheses number 1 in both cases.
+
+  \h, \H, \v, \V match horizontal and vertical whitespace, respectively.
+
 
 Release 7.1 24-Apr-07
 ---------------------
index 1d4472569cf11dba9a6ff1335797e0d1beeb68cb..a10c7041aa0698c956e0d2001ef9cbe95b141c26 100644 (file)
@@ -46,6 +46,12 @@ The following are generic comments about building the PCRE C library "by hand".
     An alternative approach is not to edit config.h, but to use -D on the
     compiler command line to make any changes that you need.
 
+    NOTE: There have been occasions when the way in which certain parameters in
+    config.h are used has changed between releases. (In the configure/make
+    world, this is handled automatically.) When upgrading to a new release, you
+    are strongly advised to review config.h.generic before re-using what you
+    had previously.
+
 (2) Copy or rename the file pcre.h.generic as pcre.h.
 
 (3) EITHER:
@@ -127,7 +133,7 @@ for use with VP/Borland: makevp_c.txt, makevp_l.txt, makevp.bat, pcregexp.pas.
 
 COMMENTS ABOUT WIN32 BUILDS
 
-There are two ways of building PCRE using the "congifure, make, make install"
+There are two ways of building PCRE using the "configure, make, make install"
 paradigm on Windows systems: using MinGW or using Cygwin. These are not at all
 the same thing; they are completely different from each other. There is also
 some experimental, undocumented support for building using "cmake", which you
@@ -159,7 +165,11 @@ On both MinGW and Cygwin, PCRE should build correctly using:
   ./configure && make && make install
 
 This should create two libraries called libpcre and libpcreposix, and, if you
-have enabled building the C++ wrapper, a third one called libpcrecpp.
+have enabled building the C++ wrapper, a third one called libpcrecpp. These are
+independent libraries: when you like with libpcreposix or libpcrecpp you must
+also link with libpcre, which contains the basic functions. (Some earlier
+releases of PCRE included the basic libpcre functions in libpcreposix. This no
+longer happens.)
 
 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
@@ -274,5 +284,5 @@ $!   Locale could not be set to fr
 $!
 =========================
 
-Last Updated: 24 April 2007
+Last Updated: 13 June 2007
 ****
index 55f8984cd033d9e0d302bc70d00ae4429dc9f4a6..291398962411ed176ffd7dfebc9de20e4752820f 100644 (file)
@@ -1,9 +1,13 @@
+
 #include <php_compat.h>
 #undef PACKAGE_NAME
 #undef PACKAGE_VERSION
 #undef PACKAGE_TARNAME
 #undef PACKAGE_STRING
 
+#define SUPPORT_UCP
+#define SUPPORT_UTF8
+
 
 /* config.h.  Generated from config.h.in by configure.  */
 /* config.h.in.  Generated from configure.ac by autoheader.  */
@@ -220,13 +224,13 @@ them both to 0; an emulation function will be used. */
 #define PACKAGE_NAME "PCRE"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "PCRE 7.2-RC1"
+#define PACKAGE_STRING "PCRE 7.2-RC3"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "pcre"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "7.2-RC1"
+#define PACKAGE_VERSION "7.2-RC3"
 
 
 /* If you are compiling for a system other than a Unix-like system or
@@ -241,9 +245,7 @@ them both to 0; an emulation function will be used. */
 /* #undef PCRE_EXP_DEFN */
 
 /* Define if linking statically (TODO: make nice with Libtool) */
-#ifndef PCRE_STATIC
-#define PCRE_STATIC 1
-#endif
+/* #undef PCRE_STATIC */
 
 /* When calling PCRE via the POSIX interface, additional working storage is
    required for holding the pointers to capturing substrings because PCRE
@@ -263,18 +265,14 @@ them both to 0; an emulation function will be used. */
 #endif
 
 /* Define to enable support for Unicode properties */
-#ifndef SUPPORT_UCP
-#define SUPPORT_UCP
-#endif
+/* #undef SUPPORT_UCP */
 
 /* Define to enable support for the UTF-8 Unicode encoding. */
-#ifndef SUPPORT_UTF8
-#define SUPPORT_UTF8
-#endif
+/* #undef SUPPORT_UTF8 */
 
 /* Version number of package */
 #ifndef VERSION
-#define VERSION "7.2-RC1"
+#define VERSION "7.2-RC3"
 #endif
 
 /* Define to empty if `const' does not conform to ANSI C. */
index f50b1d36d798f5f00564b5862b2c89cd06b9d16d..e55cf01c3af40a406fc0eaf29fc4024c5f52bf4c 100644 (file)
@@ -197,7 +197,11 @@ UTF-8 AND UNICODE PROPERTY SUPPORT
        8. Similarly, characters that match the POSIX named  character  classes
        are all low-valued characters.
 
-       9.  Case-insensitive  matching  applies only to characters whose values
+       9.  However,  the Perl 5.10 horizontal and vertical whitespace matching
+       escapes (\h, \H, \v, and \V) do match all the appropriate Unicode char-
+       acters.
+
+       10.  Case-insensitive  matching applies only to characters whose values
        are less than 128, unless PCRE is built with Unicode property  support.
        Even  when  Unicode  property support is available, PCRE still uses its
        own character tables when checking the case of  low-valued  characters,
@@ -222,7 +226,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 18 April 2007
+       Last updated: 13 June 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -390,13 +394,17 @@ AVOIDING EXCESSIVE STACK USAGE
 
        to  the  configure  command. With this configuration, PCRE will use the
        pcre_stack_malloc and pcre_stack_free variables to call memory  manage-
-       ment  functions.  Separate  functions are provided because the usage is
-       very predictable: the block sizes requested are always  the  same,  and
-       the  blocks  are always freed in reverse order. A calling program might
-       be able to implement optimized functions that perform better  than  the
-       standard  malloc()  and  free()  functions.  PCRE  runs noticeably more
-       slowly when built in this way. This option affects only the pcre_exec()
-       function; it is not relevant for the the pcre_dfa_exec() function.
+       ment  functions. By default these point to malloc() and free(), but you
+       can replace the pointers so that your own functions are used.
+
+       Separate functions are  provided  rather  than  using  pcre_malloc  and
+       pcre_free  because  the  usage  is  very  predictable:  the block sizes
+       requested are always the same, and  the  blocks  are  always  freed  in
+       reverse  order.  A calling program might be able to implement optimized
+       functions that perform better  than  malloc()  and  free().  PCRE  runs
+       noticeably more slowly when built in this way. This option affects only
+       the  pcre_exec()  function;  it   is   not   relevant   for   the   the
+       pcre_dfa_exec() function.
 
 
 LIMITING PCRE RESOURCE USAGE
@@ -474,7 +482,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 16 April 2007
+       Last updated: 05 June 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -610,34 +618,39 @@ THE ALTERNATIVE MATCHING ALGORITHM
        ence  as  the  condition or test for a specific group recursion are not
        supported.
 
-       5. Callouts are supported, but the value of the  capture_top  field  is
+       5. Because many paths through the tree may be  active,  the  \K  escape
+       sequence, which resets the start of the match when encountered (but may
+       be on some paths and not on others), is not  supported.  It  causes  an
+       error if encountered.
+
+       6.  Callouts  are  supported, but the value of the capture_top field is
        always 1, and the value of the capture_last field is always -1.
 
-       6.  The \C escape sequence, which (in the standard algorithm) matches a
-       single byte, even in UTF-8 mode, is not supported because the  alterna-
-       tive  algorithm  moves  through  the  subject string one character at a
+       7.  The \C escape sequence, which (in the standard algorithm) matches a
+       single  byte, even in UTF-8 mode, is not supported because the alterna-
+       tive algorithm moves through the subject  string  one  character  at  a
        time, for all active paths through the tree.
 
 
 ADVANTAGES OF THE ALTERNATIVE ALGORITHM
 
-       Using the alternative matching algorithm provides the following  advan-
+       Using  the alternative matching algorithm provides the following advan-
        tages:
 
        1. All possible matches (at a single point in the subject) are automat-
-       ically found, and in particular, the longest match is  found.  To  find
+       ically  found,  and  in particular, the longest match is found. To find
        more than one match using the standard algorithm, you have to do kludgy
        things with callouts.
 
-       2. There is much better support for partial matching. The  restrictions
-       on  the content of the pattern that apply when using the standard algo-
-       rithm for partial matching do not apply to the  alternative  algorithm.
-       For  non-anchored patterns, the starting position of a partial match is
+       2.  There is much better support for partial matching. The restrictions
+       on the content of the pattern that apply when using the standard  algo-
+       rithm  for  partial matching do not apply to the alternative algorithm.
+       For non-anchored patterns, the starting position of a partial match  is
        available.
 
-       3. Because the alternative algorithm  scans  the  subject  string  just
-       once,  and  never  needs to backtrack, it is possible to pass very long
-       subject strings to the matching function in  several  pieces,  checking
+       3.  Because  the  alternative  algorithm  scans the subject string just
+       once, and never needs to backtrack, it is possible to  pass  very  long
+       subject  strings  to  the matching function in several pieces, checking
        for partial matching each time.
 
 
@@ -645,8 +658,8 @@ DISADVANTAGES OF THE ALTERNATIVE ALGORITHM
 
        The alternative algorithm suffers from a number of disadvantages:
 
-       1.  It  is  substantially  slower  than the standard algorithm. This is
-       partly because it has to search for all possible matches, but  is  also
+       1. It is substantially slower than  the  standard  algorithm.  This  is
+       partly  because  it has to search for all possible matches, but is also
        because it is less susceptible to optimization.
 
        2. Capturing parentheses and back references are not supported.
@@ -664,7 +677,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 06 March 2007
+       Last updated: 29 May 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -1254,7 +1267,7 @@ COMPILATION ERROR CODES
          26  malformed number or name after (?(
          27  conditional group contains more than two branches
          28  assertion expected after (?(
-         29  (?R or (?digits must be followed by )
+         29  (?R or (?[+-]digits must be followed by )
          30  unknown POSIX class name
          31  POSIX collating elements are not supported
          32  this version of PCRE is not compiled with PCRE_UTF8 support
@@ -1283,6 +1296,9 @@ COMPILATION ERROR CODES
          54  DEFINE group contains more than one branch
          55  repeating a DEFINE group is not allowed
          56  inconsistent NEWLINE options"
+         57  \g is not followed by a braced name or an optionally braced
+               non-zero number
+         58  (?+ or (?- or (?(+ or (?(- must be followed by a non-zero number
 
 
 STUDYING A PATTERN
@@ -1471,6 +1487,12 @@ INFORMATION ABOUT A PATTERN
        returned. The fourth argument should point to an unsigned char *  vari-
        able.
 
+         PCRE_INFO_JCHANGED
+
+       Return  1  if the (?J) option setting is used in the pattern, otherwise
+       0. The fourth argument should point to an int variable. The (?J) inter-
+       nal option setting changes the local PCRE_DUPNAMES option.
+
          PCRE_INFO_LASTLITERAL
 
        Return  the  value of the rightmost literal byte that must exist in any
@@ -1525,14 +1547,21 @@ INFORMATION ABOUT A PATTERN
        name-to-number map, remember that the length of the entries  is  likely
        to be different for each compiled pattern.
 
+         PCRE_INFO_OKPARTIAL
+
+       Return  1 if the pattern can be used for partial matching, otherwise 0.
+       The fourth argument should point to an int  variable.  The  pcrepartial
+       documentation  lists  the restrictions that apply to patterns when par-
+       tial matching is used.
+
          PCRE_INFO_OPTIONS
 
-       Return  a  copy of the options with which the pattern was compiled. The
-       fourth argument should point to an unsigned long  int  variable.  These
+       Return a copy of the options with which the pattern was  compiled.  The
+       fourth  argument  should  point to an unsigned long int variable. These
        option bits are those specified in the call to pcre_compile(), modified
        by any top-level option settings within the pattern itself.
 
-       A pattern is automatically anchored by PCRE if  all  of  its  top-level
+       A  pattern  is  automatically  anchored by PCRE if all of its top-level
        alternatives begin with one of the following:
 
          ^     unless PCRE_MULTILINE is set
@@ -1546,7 +1575,7 @@ INFORMATION ABOUT A PATTERN
 
          PCRE_INFO_SIZE
 
-       Return the size of the compiled pattern, that is, the  value  that  was
+       Return  the  size  of the compiled pattern, that is, the value that was
        passed as the argument to pcre_malloc() when PCRE was getting memory in
        which to place the compiled data. The fourth argument should point to a
        size_t variable.
@@ -1554,9 +1583,9 @@ INFORMATION ABOUT A PATTERN
          PCRE_INFO_STUDYSIZE
 
        Return the size of the data block pointed to by the study_data field in
-       a pcre_extra block. That is,  it  is  the  value  that  was  passed  to
+       a  pcre_extra  block.  That  is,  it  is  the  value that was passed to
        pcre_malloc() when PCRE was getting memory into which to place the data
-       created by pcre_study(). The fourth argument should point to  a  size_t
+       created  by  pcre_study(). The fourth argument should point to a size_t
        variable.
 
 
@@ -1564,21 +1593,21 @@ OBSOLETE INFO FUNCTION
 
        int pcre_info(const pcre *code, int *optptr, int *firstcharptr);
 
-       The  pcre_info()  function is now obsolete because its interface is too
-       restrictive to return all the available data about a compiled  pattern.
-       New   programs   should  use  pcre_fullinfo()  instead.  The  yield  of
-       pcre_info() is the number of capturing subpatterns, or one of the  fol-
+       The pcre_info() function is now obsolete because its interface  is  too
+       restrictive  to return all the available data about a compiled pattern.
+       New  programs  should  use  pcre_fullinfo()  instead.  The   yield   of
+       pcre_info()  is the number of capturing subpatterns, or one of the fol-
        lowing negative numbers:
 
          PCRE_ERROR_NULL       the argument code was NULL
          PCRE_ERROR_BADMAGIC   the "magic number" was not found
 
-       If  the  optptr  argument is not NULL, a copy of the options with which
-       the pattern was compiled is placed in the integer  it  points  to  (see
+       If the optptr argument is not NULL, a copy of the  options  with  which
+       the  pattern  was  compiled  is placed in the integer it points to (see
        PCRE_INFO_OPTIONS above).
 
-       If  the  pattern  is  not anchored and the firstcharptr argument is not
-       NULL, it is used to pass back information about the first character  of
+       If the pattern is not anchored and the  firstcharptr  argument  is  not
+       NULL,  it is used to pass back information about the first character of
        any matched string (see PCRE_INFO_FIRSTBYTE above).
 
 
@@ -1586,21 +1615,21 @@ REFERENCE COUNTS
 
        int pcre_refcount(pcre *code, int adjust);
 
-       The  pcre_refcount()  function is used to maintain a reference count in
+       The pcre_refcount() function is used to maintain a reference  count  in
        the data block that contains a compiled pattern. It is provided for the
-       benefit  of  applications  that  operate  in an object-oriented manner,
+       benefit of applications that  operate  in  an  object-oriented  manner,
        where different parts of the application may be using the same compiled
        pattern, but you want to free the block when they are all done.
 
        When a pattern is compiled, the reference count field is initialized to
-       zero.  It is changed only by calling this function, whose action is  to
-       add  the  adjust  value  (which may be positive or negative) to it. The
+       zero.   It is changed only by calling this function, whose action is to
+       add the adjust value (which may be positive or  negative)  to  it.  The
        yield of the function is the new value. However, the value of the count
-       is  constrained to lie between 0 and 65535, inclusive. If the new value
+       is constrained to lie between 0 and 65535, inclusive. If the new  value
        is outside these limits, it is forced to the appropriate limit value.
 
-       Except when it is zero, the reference count is not correctly  preserved
-       if  a  pattern  is  compiled on one host and then transferred to a host
+       Except  when it is zero, the reference count is not correctly preserved
+       if a pattern is compiled on one host and then  transferred  to  a  host
        whose byte-order is different. (This seems a highly unlikely scenario.)
 
 
@@ -1610,18 +1639,18 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
             const char *subject, int length, int startoffset,
             int options, int *ovector, int ovecsize);
 
-       The  function pcre_exec() is called to match a subject string against a
-       compiled pattern, which is passed in the code argument. If the  pattern
+       The function pcre_exec() is called to match a subject string against  a
+       compiled  pattern, which is passed in the code argument. If the pattern
        has been studied, the result of the study should be passed in the extra
-       argument. This function is the main matching facility of  the  library,
+       argument.  This  function is the main matching facility of the library,
        and it operates in a Perl-like manner. For specialist use there is also
-       an alternative matching function, which is described below in the  sec-
+       an  alternative matching function, which is described below in the sec-
        tion about the pcre_dfa_exec() function.
 
-       In  most applications, the pattern will have been compiled (and option-
-       ally studied) in the same process that calls pcre_exec().  However,  it
+       In most applications, the pattern will have been compiled (and  option-
+       ally  studied)  in the same process that calls pcre_exec(). However, it
        is possible to save compiled patterns and study data, and then use them
-       later in different processes, possibly even on different hosts.  For  a
+       later  in  different processes, possibly even on different hosts. For a
        discussion about this, see the pcreprecompile documentation.
 
        Here is an example of a simple call to pcre_exec():
@@ -1640,10 +1669,10 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
 
    Extra data for pcre_exec()
 
-       If  the  extra argument is not NULL, it must point to a pcre_extra data
-       block. The pcre_study() function returns such a block (when it  doesn't
-       return  NULL), but you can also create one for yourself, and pass addi-
-       tional information in it. The pcre_extra block contains  the  following
+       If the extra argument is not NULL, it must point to a  pcre_extra  data
+       block.  The pcre_study() function returns such a block (when it doesn't
+       return NULL), but you can also create one for yourself, and pass  addi-
+       tional  information  in it. The pcre_extra block contains the following
        fields (not necessarily in this order):
 
          unsigned long int flags;
@@ -1653,7 +1682,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
          void *callout_data;
          const unsigned char *tables;
 
-       The  flags  field  is a bitmap that specifies which of the other fields
+       The flags field is a bitmap that specifies which of  the  other  fields
        are set. The flag bits are:
 
          PCRE_EXTRA_STUDY_DATA
@@ -1662,75 +1691,75 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
          PCRE_EXTRA_CALLOUT_DATA
          PCRE_EXTRA_TABLES
 
-       Other flag bits should be set to zero. The study_data field is  set  in
-       the  pcre_extra  block  that is returned by pcre_study(), together with
+       Other  flag  bits should be set to zero. The study_data field is set in
+       the pcre_extra block that is returned by  pcre_study(),  together  with
        the appropriate flag bit. You should not set this yourself, but you may
-       add  to  the  block by setting the other fields and their corresponding
+       add to the block by setting the other fields  and  their  corresponding
        flag bits.
 
        The match_limit field provides a means of preventing PCRE from using up
-       a  vast amount of resources when running patterns that are not going to
-       match, but which have a very large number  of  possibilities  in  their
-       search  trees.  The  classic  example  is  the  use of nested unlimited
+       a vast amount of resources when running patterns that are not going  to
+       match,  but  which  have  a very large number of possibilities in their
+       search trees. The classic  example  is  the  use  of  nested  unlimited
        repeats.
 
-       Internally, PCRE uses a function called match() which it calls  repeat-
-       edly  (sometimes  recursively). The limit set by match_limit is imposed
-       on the number of times this function is called during  a  match,  which
-       has  the  effect  of  limiting the amount of backtracking that can take
+       Internally,  PCRE uses a function called match() which it calls repeat-
+       edly (sometimes recursively). The limit set by match_limit  is  imposed
+       on  the  number  of times this function is called during a match, which
+       has the effect of limiting the amount of  backtracking  that  can  take
        place. For patterns that are not anchored, the count restarts from zero
        for each position in the subject string.
 
-       The  default  value  for  the  limit can be set when PCRE is built; the
-       default default is 10 million, which handles all but the  most  extreme
-       cases.  You  can  override  the  default by suppling pcre_exec() with a
-       pcre_extra    block    in    which    match_limit    is    set,     and
-       PCRE_EXTRA_MATCH_LIMIT  is  set  in  the  flags  field. If the limit is
+       The default value for the limit can be set  when  PCRE  is  built;  the
+       default  default  is 10 million, which handles all but the most extreme
+       cases. You can override the default  by  suppling  pcre_exec()  with  a
+       pcre_extra     block    in    which    match_limit    is    set,    and
+       PCRE_EXTRA_MATCH_LIMIT is set in the  flags  field.  If  the  limit  is
        exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.
 
-       The match_limit_recursion field is similar to match_limit, but  instead
+       The  match_limit_recursion field is similar to match_limit, but instead
        of limiting the total number of times that match() is called, it limits
-       the depth of recursion. The recursion depth is a  smaller  number  than
-       the  total number of calls, because not all calls to match() are recur-
+       the  depth  of  recursion. The recursion depth is a smaller number than
+       the total number of calls, because not all calls to match() are  recur-
        sive.  This limit is of use only if it is set smaller than match_limit.
 
-       Limiting  the  recursion  depth  limits the amount of stack that can be
+       Limiting the recursion depth limits the amount of  stack  that  can  be
        used, or, when PCRE has been compiled to use memory on the heap instead
        of the stack, the amount of heap memory that can be used.
 
-       The  default  value  for  match_limit_recursion can be set when PCRE is
-       built; the default default  is  the  same  value  as  the  default  for
-       match_limit.  You can override the default by suppling pcre_exec() with
-       a  pcre_extra  block  in  which  match_limit_recursion  is   set,   and
-       PCRE_EXTRA_MATCH_LIMIT_RECURSION  is  set  in  the  flags field. If the
+       The default value for match_limit_recursion can be  set  when  PCRE  is
+       built;  the  default  default  is  the  same  value  as the default for
+       match_limit. You can override the default by suppling pcre_exec()  with
+       a   pcre_extra   block  in  which  match_limit_recursion  is  set,  and
+       PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in  the  flags  field.  If  the
        limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT.
 
-       The pcre_callout field is used in conjunction with the  "callout"  fea-
+       The  pcre_callout  field is used in conjunction with the "callout" fea-
        ture, which is described in the pcrecallout documentation.
 
-       The  tables  field  is  used  to  pass  a  character  tables pointer to
-       pcre_exec(); this overrides the value that is stored with the  compiled
-       pattern.  A  non-NULL value is stored with the compiled pattern only if
-       custom tables were supplied to pcre_compile() via  its  tableptr  argu-
+       The tables field  is  used  to  pass  a  character  tables  pointer  to
+       pcre_exec();  this overrides the value that is stored with the compiled
+       pattern. A non-NULL value is stored with the compiled pattern  only  if
+       custom  tables  were  supplied to pcre_compile() via its tableptr argu-
        ment.  If NULL is passed to pcre_exec() using this mechanism, it forces
-       PCRE's internal tables to be used. This facility is  helpful  when  re-
-       using  patterns  that  have been saved after compiling with an external
-       set of tables, because the external tables  might  be  at  a  different
-       address  when  pcre_exec() is called. See the pcreprecompile documenta-
+       PCRE's  internal  tables  to be used. This facility is helpful when re-
+       using patterns that have been saved after compiling  with  an  external
+       set  of  tables,  because  the  external tables might be at a different
+       address when pcre_exec() is called. See the  pcreprecompile  documenta-
        tion for a discussion of saving compiled patterns for later use.
 
    Option bits for pcre_exec()
 
-       The unused bits of the options argument for pcre_exec() must  be  zero.
-       The  only  bits  that  may  be set are PCRE_ANCHORED, PCRE_NEWLINE_xxx,
+       The  unused  bits of the options argument for pcre_exec() must be zero.
+       The only bits that may  be  set  are  PCRE_ANCHORED,  PCRE_NEWLINE_xxx,
        PCRE_NOTBOL,   PCRE_NOTEOL,   PCRE_NOTEMPTY,   PCRE_NO_UTF8_CHECK   and
        PCRE_PARTIAL.
 
          PCRE_ANCHORED
 
-       The  PCRE_ANCHORED  option  limits pcre_exec() to matching at the first
-       matching position. If a pattern was  compiled  with  PCRE_ANCHORED,  or
-       turned  out to be anchored by virtue of its contents, it cannot be made
+       The PCRE_ANCHORED option limits pcre_exec() to matching  at  the  first
+       matching  position.  If  a  pattern was compiled with PCRE_ANCHORED, or
+       turned out to be anchored by virtue of its contents, it cannot be  made
        unachored at matching time.
 
          PCRE_NEWLINE_CR
@@ -1739,196 +1768,196 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
          PCRE_NEWLINE_ANYCRLF
          PCRE_NEWLINE_ANY
 
-       These options override  the  newline  definition  that  was  chosen  or
-       defaulted  when the pattern was compiled. For details, see the descrip-
-       tion of pcre_compile()  above.  During  matching,  the  newline  choice
-       affects  the  behaviour  of the dot, circumflex, and dollar metacharac-
-       ters. It may also alter the way the match position is advanced after  a
+       These  options  override  the  newline  definition  that  was chosen or
+       defaulted when the pattern was compiled. For details, see the  descrip-
+       tion  of  pcre_compile()  above.  During  matching,  the newline choice
+       affects the behaviour of the dot, circumflex,  and  dollar  metacharac-
+       ters.  It may also alter the way the match position is advanced after a
        match  failure  for  an  unanchored  pattern.  When  PCRE_NEWLINE_CRLF,
-       PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is set, and a  match  attempt
-       fails  when the current position is at a CRLF sequence, the match posi-
-       tion is advanced by two characters instead of one, in other  words,  to
+       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)
@@ -1937,7 +1966,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
 
          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)
@@ -1946,87 +1975,87 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
 
          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)
@@ -2049,78 +2078,78 @@ EXTRACTING CAPTURED SUBSTRINGS BY NUMBER
        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.
 
 
@@ -2139,7 +2168,7 @@ EXTRACTING CAPTURED SUBSTRINGS BY NAME
             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+)...
@@ -2148,27 +2177,27 @@ EXTRACTING CAPTURED SUBSTRINGS BY NAME
        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. NOTE: If PCRE_DUPNAMES is set and there are duplicate  names,  the
+       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).
 
 
@@ -2177,45 +2206,45 @@ DUPLICATE SUBPATTERN NAMES
        int pcre_get_stringtable_entries(const pcre *code,
             const char *name, char **first, char **last);
 
-       When  a  pattern  is  compiled with the PCRE_DUPNAMES option, names for
-       subpatterns are not required to  be  unique.  Normally,  patterns  with
-       duplicate  names  are such that in any one match, only one of the named
-       subpatterns participates. An example is shown in the pcrepattern  docu-
+       When a pattern is compiled with the  PCRE_DUPNAMES  option,  names  for
+       subpatterns  are  not  required  to  be unique. Normally, patterns with
+       duplicate names are such that in any one match, only one of  the  named
+       subpatterns  participates. An example is shown in the pcrepattern docu-
        mentation. When duplicates are present, pcre_copy_named_substring() and
-       pcre_get_named_substring() return the first substring corresponding  to
-       the  given  name  that  is  set.  If  none  are set, an empty string is
+       pcre_get_named_substring()  return the first substring corresponding to
+       the given name that is set.  If  none  are  set,  an  empty  string  is
        returned.  The pcre_get_stringnumber() function returns one of the num-
-       bers  that are associated with the name, but it is not defined which it
+       bers that are associated with the name, but it is not defined which  it
        is.
 
-       If you want to get full details of all captured substrings for a  given
-       name,  you  must  use  the pcre_get_stringtable_entries() function. The
+       If  you want to get full details of all captured substrings for a given
+       name, you must use  the  pcre_get_stringtable_entries()  function.  The
        first argument is the compiled pattern, and the second is the name. The
-       third  and  fourth  are  pointers to variables which are updated by the
+       third and fourth are pointers to variables which  are  updated  by  the
        function. After it has run, they point to the first and last entries in
-       the  name-to-number  table  for  the  given  name.  The function itself
-       returns the length of each entry,  or  PCRE_ERROR_NOSUBSTRING  (-7)  if
-       there  are none. The format of the table is described above in the sec-
-       tion entitled Information about a  pattern.   Given  all  the  relevant
-       entries  for the name, you can extract each of their numbers, and hence
+       the name-to-number table  for  the  given  name.  The  function  itself
+       returns  the  length  of  each entry, or PCRE_ERROR_NOSUBSTRING (-7) if
+       there are none. The format of the table is described above in the  sec-
+       tion  entitled  Information  about  a  pattern.  Given all the relevant
+       entries for the name, you can extract each of their numbers, and  hence
        the captured data, if any.
 
 
 FINDING ALL POSSIBLE MATCHES
 
-       The traditional matching function uses a  similar  algorithm  to  Perl,
+       The  traditional  matching  function  uses a similar algorithm to Perl,
        which stops when it finds the first match, starting at a given point in
-       the subject. If you want to find all possible matches, or  the  longest
-       possible  match,  consider using the alternative matching function (see
-       below) instead. If you cannot use the alternative function,  but  still
-       need  to  find all possible matches, you can kludge it up by making use
+       the  subject.  If you want to find all possible matches, or the longest
+       possible match, consider using the alternative matching  function  (see
+       below)  instead.  If you cannot use the alternative function, but still
+       need to find all possible matches, you can kludge it up by  making  use
        of the callout facility, which is described in the pcrecallout documen-
        tation.
 
        What you have to do is to insert a callout right at the end of the pat-
-       tern.  When your callout function is called, extract and save the  cur-
-       rent  matched  substring.  Then  return  1, which forces pcre_exec() to
-       backtrack and try other alternatives. Ultimately, when it runs  out  of
+       tern.   When your callout function is called, extract and save the cur-
+       rent matched substring. Then return  1,  which  forces  pcre_exec()  to
+       backtrack  and  try other alternatives. Ultimately, when it runs out of
        matches, pcre_exec() will yield PCRE_ERROR_NOMATCH.
 
 
@@ -2226,25 +2255,25 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
             int options, int *ovector, int ovecsize,
             int *workspace, int wscount);
 
-       The  function  pcre_dfa_exec()  is  called  to  match  a subject string
-       against a compiled pattern, using a matching algorithm that  scans  the
-       subject  string  just  once, and does not backtrack. This has different
-       characteristics to the normal algorithm, and  is  not  compatible  with
-       Perl.  Some  of the features of PCRE patterns are not supported. Never-
-       theless, there are times when this kind of matching can be useful.  For
+       The function pcre_dfa_exec()  is  called  to  match  a  subject  string
+       against  a  compiled pattern, using a matching algorithm that scans the
+       subject string just once, and does not backtrack.  This  has  different
+       characteristics  to  the  normal  algorithm, and is not compatible with
+       Perl. Some of the features of PCRE patterns are not  supported.  Never-
+       theless,  there are times when this kind of matching can be useful. For
        a discussion of the two matching algorithms, see the pcrematching docu-
        mentation.
 
-       The arguments for the pcre_dfa_exec() function  are  the  same  as  for
+       The  arguments  for  the  pcre_dfa_exec()  function are the same as for
        pcre_exec(), plus two extras. The ovector argument is used in a differ-
-       ent way, and this is described below. The other  common  arguments  are
-       used  in  the  same way as for pcre_exec(), so their description is not
+       ent  way,  and  this is described below. The other common arguments are
+       used in the same way as for pcre_exec(), so their  description  is  not
        repeated here.
 
-       The two additional arguments provide workspace for  the  function.  The
-       workspace  vector  should  contain at least 20 elements. It is used for
+       The  two  additional  arguments provide workspace for the function. The
+       workspace vector should contain at least 20 elements. It  is  used  for
        keeping  track  of  multiple  paths  through  the  pattern  tree.  More
-       workspace  will  be  needed for patterns and subjects where there are a
+       workspace will be needed for patterns and subjects where  there  are  a
        lot of potential matches.
 
        Here is an example of a simple call to pcre_dfa_exec():
@@ -2266,47 +2295,47 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
 
    Option bits for pcre_dfa_exec()
 
-       The unused bits of the options argument  for  pcre_dfa_exec()  must  be
-       zero.  The  only  bits  that  may  be  set are PCRE_ANCHORED, PCRE_NEW-
-       LINE_xxx, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY,  PCRE_NO_UTF8_CHECK,
+       The  unused  bits  of  the options argument for pcre_dfa_exec() must be
+       zero. The only bits  that  may  be  set  are  PCRE_ANCHORED,  PCRE_NEW-
+       LINE_xxx,  PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK,
        PCRE_PARTIAL, PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last
        three of these are the same as for pcre_exec(), so their description is
        not repeated here.
 
          PCRE_PARTIAL
 
-       This  has  the  same general effect as it does for pcre_exec(), but the
-       details  are  slightly  different.  When  PCRE_PARTIAL   is   set   for
-       pcre_dfa_exec(),  the  return code PCRE_ERROR_NOMATCH is converted into
-       PCRE_ERROR_PARTIAL if the end of the subject  is  reached,  there  have
+       This has the same general effect as it does for  pcre_exec(),  but  the
+       details   are   slightly   different.  When  PCRE_PARTIAL  is  set  for
+       pcre_dfa_exec(), the return code PCRE_ERROR_NOMATCH is  converted  into
+       PCRE_ERROR_PARTIAL  if  the  end  of the subject is reached, there have
        been no complete matches, but there is still at least one matching pos-
-       sibility. The portion of the string that provided the partial match  is
+       sibility.  The portion of the string that provided the partial match is
        set as the first matching string.
 
          PCRE_DFA_SHORTEST
 
-       Setting  the  PCRE_DFA_SHORTEST option causes the matching algorithm to
+       Setting the PCRE_DFA_SHORTEST option causes the matching  algorithm  to
        stop as soon as it has found one match. Because of the way the alterna-
-       tive  algorithm  works, this is necessarily the shortest possible match
+       tive algorithm works, this is necessarily the shortest  possible  match
        at the first possible matching point in the subject string.
 
          PCRE_DFA_RESTART
 
-       When pcre_dfa_exec()  is  called  with  the  PCRE_PARTIAL  option,  and
-       returns  a  partial  match, it is possible to call it again, with addi-
-       tional subject characters, and have it continue with  the  same  match.
-       The  PCRE_DFA_RESTART  option requests this action; when it is set, the
-       workspace and wscount options must reference the same vector as  before
-       because  data  about  the  match so far is left in them after a partial
-       match. There is more discussion of this  facility  in  the  pcrepartial
+       When  pcre_dfa_exec()  is  called  with  the  PCRE_PARTIAL  option, and
+       returns a partial match, it is possible to call it  again,  with  addi-
+       tional  subject  characters,  and have it continue with the same match.
+       The PCRE_DFA_RESTART option requests this action; when it is  set,  the
+       workspace  and wscount options must reference the same vector as before
+       because data about the match so far is left in  them  after  a  partial
+       match.  There  is  more  discussion of this facility in the pcrepartial
        documentation.
 
    Successful returns from pcre_dfa_exec()
 
-       When  pcre_dfa_exec()  succeeds, it may have matched more than one sub-
+       When pcre_dfa_exec() succeeds, it may have matched more than  one  sub-
        string in the subject. Note, however, that all the matches from one run
-       of  the  function  start  at the same point in the subject. The shorter
-       matches are all initial substrings of the longer matches. For  example,
+       of the function start at the same point in  the  subject.  The  shorter
+       matches  are all initial substrings of the longer matches. For example,
        if the pattern
 
          <.*>
@@ -2321,62 +2350,62 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
          <something> <something else>
          <something> <something else> <something further>
 
-       On  success,  the  yield of the function is a number greater than zero,
-       which is the number of matched substrings.  The  substrings  themselves
-       are  returned  in  ovector. Each string uses two elements; the first is
-       the offset to the start, and the second is the offset to  the  end.  In
-       fact,  all  the  strings  have the same start offset. (Space could have
-       been saved by giving this only once, but it was decided to retain  some
-       compatibility  with  the  way pcre_exec() returns data, even though the
+       On success, the yield of the function is a number  greater  than  zero,
+       which  is  the  number of matched substrings. The substrings themselves
+       are returned in ovector. Each string uses two elements;  the  first  is
+       the  offset  to  the start, and the second is the offset to the end. In
+       fact, all the strings have the same start  offset.  (Space  could  have
+       been  saved by giving this only once, but it was decided to retain some
+       compatibility with the way pcre_exec() returns data,  even  though  the
        meaning of the strings is different.)
 
        The strings are returned in reverse order of length; that is, the long-
-       est  matching  string is given first. If there were too many matches to
-       fit into ovector, the yield of the function is zero, and the vector  is
+       est matching string is given first. If there were too many  matches  to
+       fit  into ovector, the yield of the function is zero, and the vector is
        filled with the longest matches.
 
    Error returns from pcre_dfa_exec()
 
-       The  pcre_dfa_exec()  function returns a negative number when it fails.
-       Many of the errors are the same  as  for  pcre_exec(),  and  these  are
-       described  above.   There are in addition the following errors that are
+       The pcre_dfa_exec() function returns a negative number when  it  fails.
+       Many  of  the  errors  are  the  same as for pcre_exec(), and these are
+       described above.  There are in addition the following errors  that  are
        specific to pcre_dfa_exec():
 
          PCRE_ERROR_DFA_UITEM      (-16)
 
-       This return is given if pcre_dfa_exec() encounters an item in the  pat-
-       tern  that  it  does not support, for instance, the use of \C or a back
+       This  return is given if pcre_dfa_exec() encounters an item in the pat-
+       tern that it does not support, for instance, the use of \C  or  a  back
        reference.
 
          PCRE_ERROR_DFA_UCOND      (-17)
 
-       This return is given if pcre_dfa_exec()  encounters  a  condition  item
-       that  uses  a back reference for the condition, or a test for recursion
+       This  return  is  given  if pcre_dfa_exec() encounters a condition item
+       that uses a back reference for the condition, or a test  for  recursion
        in a specific group. These are not supported.
 
          PCRE_ERROR_DFA_UMLIMIT    (-18)
 
-       This return is given if pcre_dfa_exec() is called with an  extra  block
+       This  return  is given if pcre_dfa_exec() is called with an extra block
        that contains a setting of the match_limit field. This is not supported
        (it is meaningless).
 
          PCRE_ERROR_DFA_WSSIZE     (-19)
 
-       This return is given if  pcre_dfa_exec()  runs  out  of  space  in  the
+       This  return  is  given  if  pcre_dfa_exec()  runs  out of space in the
        workspace vector.
 
          PCRE_ERROR_DFA_RECURSE    (-20)
 
-       When  a  recursive subpattern is processed, the matching function calls
-       itself recursively, using private vectors for  ovector  and  workspace.
-       This  error  is  given  if  the output vector is not large enough. This
+       When a recursive subpattern is processed, the matching  function  calls
+       itself  recursively,  using  private vectors for ovector and workspace.
+       This error is given if the output vector  is  not  large  enough.  This
        should be extremely rare, as a vector of size 1000 is used.
 
 
 SEE ALSO
 
-       pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3),  pcrepar-
-       tial(3),  pcreposix(3), pcreprecompile(3), pcresample(3), pcrestack(3).
+       pcrebuild(3),  pcrecallout(3), pcrecpp(3)(3), pcrematching(3), pcrepar-
+       tial(3), pcreposix(3), pcreprecompile(3), pcresample(3),  pcrestack(3).
 
 
 AUTHOR
@@ -2388,7 +2417,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 24 April 2007
+       Last updated: 13 June 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -2491,10 +2520,12 @@ THE CALLOUT INTERFACE
        The subject and subject_length fields contain copies of the values that
        were passed to pcre_exec().
 
-       The start_match field contains the offset within the subject  at  which
-       the  current match attempt started. If the pattern is not anchored, the
-       callout function may be called several times from the same point in the
-       pattern for different starting points in the subject.
+       The start_match field normally contains the offset within  the  subject
+       at  which  the  current  match  attempt started. However, if the escape
+       sequence \K has been encountered, this value is changed to reflect  the
+       modified  starting  point.  If the pattern is not anchored, the callout
+       function may be called several times from the same point in the pattern
+       for different starting points in the subject.
 
        The  current_position  field  contains the offset within the subject of
        the current match pointer.
@@ -2557,7 +2588,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 06 March 2007
+       Last updated: 29 May 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -2573,8 +2604,8 @@ DIFFERENCES BETWEEN PCRE AND PERL
 
        This  document describes the differences in the ways that PCRE and Perl
        handle regular expressions. The differences described here  are  mainly
-       with  respect  to  Perl 5.8, though PCRE version 7.0 contains some fea-
-       tures that are expected to be in the forthcoming Perl 5.10.
+       with  respect  to  Perl 5.8, though PCRE versions 7.0 and later contain
+       some features that are expected to be in the forthcoming Perl 5.10.
 
        1. PCRE has only a subset of Perl's UTF-8 and Unicode support.  Details
        of  what  it does have are given in the section on UTF-8 support in the
@@ -2652,8 +2683,8 @@ DIFFERENCES BETWEEN PCRE AND PERL
        meta-character matches only at the very end of the string.
 
        (c) If PCRE_EXTRA is set, a backslash followed by a letter with no spe-
-       cial  meaning  is  faulted.  Otherwise,  like  Perl,  the  backslash is
-       ignored. (Perl can be made to issue a warning.)
+       cial meaning is faulted. Otherwise, like Perl, the backslash is quietly
+       ignored.  (Perl can be made to issue a warning.)
 
        (d) If PCRE_UNGREEDY is set, the greediness of the  repetition  quanti-
        fiers is inverted, that is, by default they are not greedy, but if fol-
@@ -2685,7 +2716,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 06 March 2007
+       Last updated: 13 June 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -2718,38 +2749,39 @@ PCRE REGULAR EXPRESSION DETAILS
        ported  by  PCRE when its main matching function, pcre_exec(), is used.
        From  release  6.0,   PCRE   offers   a   second   matching   function,
        pcre_dfa_exec(),  which matches using a different algorithm that is not
-       Perl-compatible. The advantages and disadvantages  of  the  alternative
-       function, and how it differs from the normal function, are discussed in
-       the pcrematching page.
+       Perl-compatible. Some of the features discussed below are not available
+       when  pcre_dfa_exec()  is used. The advantages and disadvantages of the
+       alternative function, and how it differs from the normal function,  are
+       discussed in the pcrematching page.
 
 
 CHARACTERS AND METACHARACTERS
 
-       A regular expression is a pattern that is  matched  against  a  subject
-       string  from  left  to right. Most characters stand for themselves in a
-       pattern, and match the corresponding characters in the  subject.  As  a
+       A  regular  expression  is  a pattern that is matched against a subject
+       string from left to right. Most characters stand for  themselves  in  a
+       pattern,  and  match  the corresponding characters in the subject. As a
        trivial example, the pattern
 
          The quick brown fox
 
        matches a portion of a subject string that is identical to itself. When
-       caseless matching is specified (the PCRE_CASELESS option), letters  are
-       matched  independently  of case. In UTF-8 mode, PCRE always understands
-       the concept of case for characters whose values are less than  128,  so
-       caseless  matching  is always possible. For characters with higher val-
-       ues, the concept of case is supported if PCRE is compiled with  Unicode
-       property  support,  but  not  otherwise.   If  you want to use caseless
-       matching for characters 128 and above, you must  ensure  that  PCRE  is
+       caseless  matching is specified (the PCRE_CASELESS option), letters are
+       matched independently of case. In UTF-8 mode, PCRE  always  understands
+       the  concept  of case for characters whose values are less than 128, so
+       caseless matching is always possible. For characters with  higher  val-
+       ues,  the concept of case is supported if PCRE is compiled with Unicode
+       property support, but not otherwise.   If  you  want  to  use  caseless
+       matching  for  characters  128  and above, you must ensure that PCRE is
        compiled with Unicode property support as well as with UTF-8 support.
 
-       The  power  of  regular  expressions  comes from the ability to include
-       alternatives and repetitions in the pattern. These are encoded  in  the
+       The power of regular expressions comes  from  the  ability  to  include
+       alternatives  and  repetitions in the pattern. These are encoded in the
        pattern by the use of metacharacters, which do not stand for themselves
        but instead are interpreted in some special way.
 
-       There are two different sets of metacharacters: those that  are  recog-
-       nized  anywhere in the pattern except within square brackets, and those
-       that are recognized within square brackets.  Outside  square  brackets,
+       There  are  two different sets of metacharacters: those that are recog-
+       nized anywhere in the pattern except within square brackets, and  those
+       that  are  recognized  within square brackets. Outside square brackets,
        the metacharacters are as follows:
 
          \      general escape character with several uses
@@ -2768,7 +2800,7 @@ CHARACTERS AND METACHARACTERS
                 also "possessive quantifier"
          {      start min/max quantifier
 
-       Part  of  a  pattern  that is in square brackets is called a "character
+       Part of a pattern that is in square brackets  is  called  a  "character
        class". In a character class the only metacharacters are:
 
          \      general escape character
@@ -2778,33 +2810,33 @@ CHARACTERS AND METACHARACTERS
                   syntax)
          ]      terminates the character class
 
-       The following sections describe the use of each of the  metacharacters.
+       The  following sections describe the use of each of the metacharacters.
 
 
 BACKSLASH
 
        The backslash character has several uses. Firstly, if it is followed by
-       a non-alphanumeric character, it takes away any  special  meaning  that
-       character  may  have.  This  use  of  backslash  as an escape character
+       a  non-alphanumeric  character,  it takes away any special meaning that
+       character may have. This  use  of  backslash  as  an  escape  character
        applies both inside and outside character classes.
 
-       For example, if you want to match a * character, you write  \*  in  the
-       pattern.   This  escaping  action  applies whether or not the following
-       character would otherwise be interpreted as a metacharacter, so  it  is
-       always  safe  to  precede  a non-alphanumeric with backslash to specify
-       that it stands for itself. In particular, if you want to match a  back-
+       For  example,  if  you want to match a * character, you write \* in the
+       pattern.  This escaping action applies whether  or  not  the  following
+       character  would  otherwise be interpreted as a metacharacter, so it is
+       always safe to precede a non-alphanumeric  with  backslash  to  specify
+       that  it stands for itself. In particular, if you want to match a back-
        slash, you write \\.
 
-       If  a  pattern is compiled with the PCRE_EXTENDED option, whitespace in
-       the pattern (other than in a character class) and characters between  a
+       If a pattern is compiled with the PCRE_EXTENDED option,  whitespace  in
+       the  pattern (other than in a character class) and characters between a
        # outside a character class and the next newline are ignored. An escap-
-       ing backslash can be used to include a whitespace  or  #  character  as
+       ing  backslash  can  be  used to include a whitespace or # character as
        part of the pattern.
 
-       If  you  want  to remove the special meaning from a sequence of charac-
-       ters, you can do so by putting them between \Q and \E. This is  differ-
-       ent  from  Perl  in  that  $  and  @ are handled as literals in \Q...\E
-       sequences in PCRE, whereas in Perl, $ and @ cause  variable  interpola-
+       If you want to remove the special meaning from a  sequence  of  charac-
+       ters,  you can do so by putting them between \Q and \E. This is differ-
+       ent from Perl in that $ and  @  are  handled  as  literals  in  \Q...\E
+       sequences  in  PCRE, whereas in Perl, $ and @ cause variable interpola-
        tion. Note the following examples:
 
          Pattern            PCRE matches   Perl matches
@@ -2814,16 +2846,16 @@ BACKSLASH
          \Qabc\$xyz\E       abc\$xyz       abc\$xyz
          \Qabc\E\$\Qxyz\E   abc$xyz        abc$xyz
 
-       The  \Q...\E  sequence  is recognized both inside and outside character
+       The \Q...\E sequence is recognized both inside  and  outside  character
        classes.
 
    Non-printing characters
 
        A second use of backslash provides a way of encoding non-printing char-
-       acters  in patterns in a visible manner. There is no restriction on the
-       appearance of non-printing characters, apart from the binary zero  that
-       terminates  a  pattern,  but  when  a pattern is being prepared by text
-       editing, it is usually easier  to  use  one  of  the  following  escape
+       acters in patterns in a visible manner. There is no restriction on  the
+       appearance  of non-printing characters, apart from the binary zero that
+       terminates a pattern, but when a pattern  is  being  prepared  by  text
+       editing,  it  is  usually  easier  to  use  one of the following escape
        sequences than the binary character it represents:
 
          \a        alarm, that is, the BEL character (hex 07)
@@ -2837,45 +2869,45 @@ BACKSLASH
          \xhh      character with hex code hh
          \x{hhh..} character with hex code hhh..
 
-       The  precise  effect of \cx is as follows: if x is a lower case letter,
-       it is converted to upper case. Then bit 6 of the character (hex 40)  is
-       inverted.   Thus  \cz becomes hex 1A, but \c{ becomes hex 3B, while \c;
+       The precise effect of \cx is as follows: if x is a lower  case  letter,
+       it  is converted to upper case. Then bit 6 of the character (hex 40) is
+       inverted.  Thus \cz becomes hex 1A, but \c{ becomes hex 3B,  while  \c;
        becomes hex 7B.
 
-       After \x, from zero to two hexadecimal digits are read (letters can  be
-       in  upper  or  lower case). Any number of hexadecimal digits may appear
-       between \x{ and }, but the value of the character  code  must  be  less
+       After  \x, from zero to two hexadecimal digits are read (letters can be
+       in upper or lower case). Any number of hexadecimal  digits  may  appear
+       between  \x{  and  },  but the value of the character code must be less
        than 256 in non-UTF-8 mode, and less than 2**31 in UTF-8 mode (that is,
-       the maximum hexadecimal value is 7FFFFFFF). If  characters  other  than
-       hexadecimal  digits  appear between \x{ and }, or if there is no termi-
-       nating }, this form of escape is not recognized.  Instead, the  initial
+       the  maximum  hexadecimal  value is 7FFFFFFF). If characters other than
+       hexadecimal digits appear between \x{ and }, or if there is  no  termi-
+       nating  }, this form of escape is not recognized.  Instead, the initial
        \x will be interpreted as a basic hexadecimal escape, with no following
        digits, giving a character whose value is zero.
 
        Characters whose value is less than 256 can be defined by either of the
-       two  syntaxes  for  \x. There is no difference in the way they are han-
+       two syntaxes for \x. There is no difference in the way  they  are  han-
        dled. For example, \xdc is exactly the same as \x{dc}.
 
-       After \0 up to two further octal digits are read. If  there  are  fewer
-       than  two  digits,  just  those  that  are  present  are used. Thus the
+       After  \0  up  to two further octal digits are read. If there are fewer
+       than two digits, just  those  that  are  present  are  used.  Thus  the
        sequence \0\x\07 specifies two binary zeros followed by a BEL character
-       (code  value 7). Make sure you supply two digits after the initial zero
+       (code value 7). Make sure you supply two digits after the initial  zero
        if the pattern character that follows is itself an octal digit.
 
        The handling of a backslash followed by a digit other than 0 is compli-
        cated.  Outside a character class, PCRE reads it and any following dig-
-       its as a decimal number. If the number is less than  10,  or  if  there
+       its  as  a  decimal  number. If the number is less than 10, or if there
        have been at least that many previous capturing left parentheses in the
-       expression, the entire  sequence  is  taken  as  a  back  reference.  A
-       description  of how this works is given later, following the discussion
+       expression,  the  entire  sequence  is  taken  as  a  back reference. A
+       description of how this works is given later, following the  discussion
        of parenthesized subpatterns.
 
-       Inside a character class, or if the decimal number is  greater  than  9
-       and  there have not been that many capturing subpatterns, PCRE re-reads
+       Inside  a  character  class, or if the decimal number is greater than 9
+       and there have not been that many capturing subpatterns, PCRE  re-reads
        up to three octal digits following the backslash, and uses them to gen-
-       erate  a data character. Any subsequent digits stand for themselves. In
-       non-UTF-8 mode, the value of a character specified  in  octal  must  be
-       less  than  \400.  In  UTF-8 mode, values up to \777 are permitted. For
+       erate a data character. Any subsequent digits stand for themselves.  In
+       non-UTF-8  mode,  the  value  of a character specified in octal must be
+       less than \400. In UTF-8 mode, values up to  \777  are  permitted.  For
        example:
 
          \040   is another way of writing a space
@@ -2893,22 +2925,22 @@ BACKSLASH
          \81    is either a back reference, or a binary zero
                    followed by the two characters "8" and "1"
 
-       Note that octal values of 100 or greater must not be  introduced  by  a
+       Note  that  octal  values of 100 or greater must not be introduced by a
        leading zero, because no more than three octal digits are ever read.
 
        All the sequences that define a single character value can be used both
-       inside and outside character classes. In addition, inside  a  character
-       class,  the  sequence \b is interpreted as the backspace character (hex
-       08), and the sequences \R and \X are interpreted as the characters  "R"
-       and  "X", respectively. Outside a character class, these sequences have
+       inside  and  outside character classes. In addition, inside a character
+       class, the sequence \b is interpreted as the backspace  character  (hex
+       08),  and the sequences \R and \X are interpreted as the characters "R"
+       and "X", respectively. Outside a character class, these sequences  have
        different meanings (see below).
 
    Absolute and relative back references
 
-       The sequence \g followed by a positive or negative  number,  optionally
-       enclosed  in  braces,  is  an absolute or relative back reference. Back
-       references are discussed later, following the discussion  of  parenthe-
-       sized subpatterns.
+       The  sequence  \g followed by a positive or negative number, optionally
+       enclosed in braces, is an absolute or relative back reference. A  named
+       back  reference can be coded as \g{name}. Back references are discussed
+       later, following the discussion of parenthesized subpatterns.
 
    Generic character types
 
@@ -2917,57 +2949,97 @@ BACKSLASH
 
          \d     any decimal digit
          \D     any character that is not a decimal digit
+         \h     any horizontal whitespace character
+         \H     any character that is not a horizontal whitespace character
          \s     any whitespace character
          \S     any character that is not a whitespace character
+         \v     any vertical whitespace character
+         \V     any character that is not a vertical whitespace character
          \w     any "word" character
          \W     any "non-word" character
 
        Each pair of escape sequences partitions the complete set of characters
-       into  two disjoint sets. Any given character matches one, and only one,
+       into two disjoint sets. Any given character matches one, and only  one,
        of each pair.
 
        These character type sequences can appear both inside and outside char-
-       acter  classes.  They each match one character of the appropriate type.
-       If the current matching point is at the end of the subject string,  all
+       acter classes. They each match one character of the  appropriate  type.
+       If  the current matching point is at the end of the subject string, all
        of them fail, since there is no character to match.
 
-       For  compatibility  with Perl, \s does not match the VT character (code
-       11).  This makes it different from the the POSIX "space" class. The  \s
-       characters  are  HT (9), LF (10), FF (12), CR (13), and space (32). (If
+       For compatibility with Perl, \s does not match the VT  character  (code
+       11).   This makes it different from the the POSIX "space" class. The \s
+       characters are HT (9), LF (10), FF (12), CR (13), and  space  (32).  If
        "use locale;" is included in a Perl script, \s may match the VT charac-
-       ter. In PCRE, it never does.)
+       ter. In PCRE, it never does.
 
-       A "word" character is an underscore or any character less than 256 that
-       is a letter or digit. The definition of  letters  and  digits  is  con-
-       trolled  by PCRE's low-valued character tables, and may vary if locale-
-       specific matching is taking place (see "Locale support" in the  pcreapi
-       page).  For  example,  in  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,
+       In UTF-8 mode, characters with values greater than 128 never match  \d,
        \s, or \w, and always match \D, \S, and \W. This is true even when Uni-
-       code  character  property support is available. The use of locales with
-       Unicode is discouraged.
+       code character property support is available.  These  sequences  retain
+       their original meanings from before UTF-8 support was available, mainly
+       for efficiency reasons.
+
+       The sequences \h, \H, \v, and \V are Perl 5.10 features. In contrast to
+       the  other  sequences, these do match certain high-valued codepoints in
+       UTF-8 mode.  The horizontal space characters are:
+
+         U+0009     Horizontal tab
+         U+0020     Space
+         U+00A0     Non-break space
+         U+1680     Ogham space mark
+         U+180E     Mongolian vowel separator
+         U+2000     En quad
+         U+2001     Em quad
+         U+2002     En space
+         U+2003     Em space
+         U+2004     Three-per-em space
+         U+2005     Four-per-em space
+         U+2006     Six-per-em space
+         U+2007     Figure space
+         U+2008     Punctuation space
+         U+2009     Thin space
+         U+200A     Hair space
+         U+202F     Narrow no-break space
+         U+205F     Medium mathematical space
+         U+3000     Ideographic space
+
+       The vertical space characters are:
+
+         U+000A     Linefeed
+         U+000B     Vertical tab
+         U+000C     Formfeed
+         U+000D     Carriage return
+         U+0085     Next line
+         U+2028     Line separator
+         U+2029     Paragraph separator
+
+       A "word" character is an underscore or any character less than 256 that
+       is  a  letter  or  digit.  The definition of letters and digits is con-
+       trolled by PCRE's low-valued character tables, and may vary if  locale-
+       specific  matching is taking place (see "Locale support" in the pcreapi
+       page). For example, in a French locale such  as  "fr_FR"  in  Unix-like
+       systems,  or "french" in Windows, some character codes greater than 128
+       are used for accented letters, and these are matched by \w. The use  of
+       locales with Unicode is discouraged.
 
    Newline sequences
 
-       Outside a character class, the escape sequence \R matches  any  Unicode
-       newline sequence. This is an extension to Perl. In non-UTF-8 mode \R is
+       Outside  a  character class, the escape sequence \R matches any Unicode
+       newline sequence. This is a Perl 5.10 feature. In non-UTF-8 mode \R  is
        equivalent to the following:
 
          (?>\r\n|\n|\x0b|\f|\r|\x85)
 
-       This is an example of an "atomic group", details  of  which  are  given
+       This  is  an  example  of an "atomic group", details of which are given
        below.  This particular group matches either the two-character sequence
-       CR followed by LF, or  one  of  the  single  characters  LF  (linefeed,
+       CR  followed  by  LF,  or  one  of  the single characters LF (linefeed,
        U+000A), VT (vertical tab, U+000B), FF (formfeed, U+000C), CR (carriage
        return, U+000D), or NEL (next line, U+0085). The two-character sequence
        is treated as a single unit that cannot be split.
 
-       In  UTF-8  mode, two additional characters whose codepoints are greater
+       In UTF-8 mode, two additional characters whose codepoints  are  greater
        than 255 are added: LS (line separator, U+2028) and PS (paragraph sepa-
-       rator,  U+2029).   Unicode character property support is not needed for
+       rator, U+2029).  Unicode character property support is not  needed  for
        these characters to be recognized.
 
        Inside a character class, \R matches the letter "R".
@@ -2975,47 +3047,47 @@ BACKSLASH
    Unicode character properties
 
        When PCRE is built with Unicode character property support, three addi-
-       tional  escape  sequences  to  match character properties are available
+       tional escape sequences to match  character  properties  are  available
        when UTF-8 mode is selected. They are:
 
          \p{xx}   a character with the xx property
          \P{xx}   a character without the xx property
          \X       an extended Unicode sequence
 
-       The property names represented by xx above are limited to  the  Unicode
+       The  property  names represented by xx above are limited to the Unicode
        script names, the general category properties, and "Any", which matches
        any character (including newline). Other properties such as "InMusical-
-       Symbols"  are  not  currently supported by PCRE. Note that \P{Any} does
+       Symbols" are not currently supported by PCRE. Note  that  \P{Any}  does
        not match any characters, so always causes a match failure.
 
        Sets of Unicode characters are defined as belonging to certain scripts.
-       A  character from one of these sets can be matched using a script name.
+       A character from one of these sets can be matched using a script  name.
        For example:
 
          \p{Greek}
          \P{Han}
 
-       Those that are not part of an identified script are lumped together  as
+       Those  that are not part of an identified script are lumped together as
        "Common". The current list of scripts is:
 
        Arabic,  Armenian,  Balinese,  Bengali,  Bopomofo,  Braille,  Buginese,
-       Buhid,  Canadian_Aboriginal,  Cherokee,  Common,   Coptic,   Cuneiform,
+       Buhid,   Canadian_Aboriginal,   Cherokee,  Common,  Coptic,  Cuneiform,
        Cypriot, Cyrillic, Deseret, Devanagari, Ethiopic, Georgian, Glagolitic,
-       Gothic, Greek, Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hebrew,  Hira-
-       gana,  Inherited,  Kannada,  Katakana,  Kharoshthi,  Khmer, Lao, Latin,
+       Gothic,  Greek, Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hebrew, Hira-
+       gana, Inherited, Kannada,  Katakana,  Kharoshthi,  Khmer,  Lao,  Latin,
        Limbu,  Linear_B,  Malayalam,  Mongolian,  Myanmar,  New_Tai_Lue,  Nko,
-       Ogham,  Old_Italic,  Old_Persian, Oriya, Osmanya, Phags_Pa, Phoenician,
+       Ogham, Old_Italic, Old_Persian, Oriya, Osmanya,  Phags_Pa,  Phoenician,
        Runic,  Shavian,  Sinhala,  Syloti_Nagri,  Syriac,  Tagalog,  Tagbanwa,
        Tai_Le, Tamil, Telugu, Thaana, Thai, Tibetan, Tifinagh, Ugaritic, Yi.
 
-       Each  character has exactly one general category property, specified by
+       Each character has exactly one general category property, specified  by
        a two-letter abbreviation. For compatibility with Perl, negation can be
-       specified  by  including a circumflex between the opening brace and the
+       specified by including a circumflex between the opening brace  and  the
        property name. For example, \p{^Lu} is the same as \P{Lu}.
 
        If only one letter is specified with \p or \P, it includes all the gen-
-       eral  category properties that start with that letter. In this case, in
-       the absence of negation, the curly brackets in the escape sequence  are
+       eral category properties that start with that letter. In this case,  in
+       the  absence of negation, the curly brackets in the escape sequence are
        optional; these two examples have the same effect:
 
          \p{L}
@@ -3067,36 +3139,55 @@ BACKSLASH
          Zp    Paragraph separator
          Zs    Space separator
 
-       The  special property L& is also supported: it matches a character that
-       has the Lu, Ll, or Lt property, in other words, a letter  that  is  not
+       The special property L& is also supported: it matches a character  that
+       has  the  Lu,  Ll, or Lt property, in other words, a letter that is not
        classified as a modifier or "other".
 
-       The  long  synonyms  for  these  properties that Perl supports (such as
-       \p{Letter}) are not supported by PCRE, nor is it  permitted  to  prefix
+       The long synonyms for these properties  that  Perl  supports  (such  as
+       \p{Letter})  are  not  supported by PCRE, nor is it permitted to prefix
        any of these properties with "Is".
 
        No character that is in the Unicode table has the Cn (unassigned) prop-
        erty.  Instead, this property is assumed for any code point that is not
        in the Unicode table.
 
-       Specifying  caseless  matching  does not affect these escape sequences.
+       Specifying caseless matching does not affect  these  escape  sequences.
        For example, \p{Lu} always matches only upper case letters.
 
-       The \X escape matches any number of Unicode  characters  that  form  an
+       The  \X  escape  matches  any number of Unicode characters that form an
        extended Unicode sequence. \X is equivalent to
 
          (?>\PM\pM*)
 
-       That  is,  it matches a character without the "mark" property, followed
-       by zero or more characters with the "mark"  property,  and  treats  the
-       sequence  as  an  atomic group (see below).  Characters with the "mark"
+       That is, it matches a character without the "mark"  property,  followed
+       by  zero  or  more  characters with the "mark" property, and treats the
+       sequence as an atomic group (see below).  Characters  with  the  "mark"
        property are typically accents that affect the preceding character.
 
-       Matching characters by Unicode property is not fast, because  PCRE  has
-       to  search  a  structure  that  contains data for over fifteen thousand
+       Matching  characters  by Unicode property is not fast, because PCRE has
+       to search a structure that contains  data  for  over  fifteen  thousand
        characters. That is why the traditional escape sequences such as \d and
        \w do not use Unicode properties in PCRE.
 
+   Resetting the match start
+
+       The escape sequence \K, which is a Perl 5.10 feature, causes any previ-
+       ously  matched  characters  not  to  be  included  in the final matched
+       sequence. For example, the pattern:
+
+         foo\Kbar
+
+       matches "foobar", but reports that it has matched "bar".  This  feature
+       is  similar  to  a lookbehind assertion (described below).  However, in
+       this case, the part of the subject before the real match does not  have
+       to  be of fixed length, as lookbehind assertions do. The use of \K does
+       not interfere with the setting of captured  substrings.   For  example,
+       when the pattern
+
+         (foo)\Kbar
+
+       matches "foobar", the first substring is still set to "foo".
+
    Simple assertions
 
        The  final use of backslash is for certain simple assertions. An asser-
@@ -3497,6 +3588,37 @@ SUBPATTERNS
        "Saturday".
 
 
+DUPLICATE SUBPATTERN NUMBERS
+
+       Perl 5.10 introduced a feature whereby each alternative in a subpattern
+       uses the same numbers for its capturing parentheses. Such a  subpattern
+       starts  with (?| and is itself a non-capturing subpattern. For example,
+       consider this pattern:
+
+         (?|(Sat)ur|(Sun))day
+
+       Because the two alternatives are inside a (?| group, both sets of  cap-
+       turing  parentheses  are  numbered one. Thus, when the pattern matches,
+       you can look at captured substring number  one,  whichever  alternative
+       matched.  This  construct  is useful when you want to capture part, but
+       not all, of one of a number of alternatives. Inside a (?| group, paren-
+       theses  are  numbered as usual, but the number is reset at the start of
+       each branch. The numbers of any capturing buffers that follow the  sub-
+       pattern  start after the highest number used in any branch. The follow-
+       ing example is taken from the Perl documentation.  The  numbers  under-
+       neath show in which buffer the captured content will be stored.
+
+         # before  ---------------branch-reset----------- after
+         / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
+         # 1            2         2  3        2     3     4
+
+       A  backreference  or  a  recursive call to a numbered subpattern always
+       refers to the first one in the pattern with the given number.
+
+       An alternative approach to using this "branch reset" feature is to  use
+       duplicate named subpatterns, as described in the next section.
+
+
 NAMED SUBPATTERNS
 
        Identifying  capturing  parentheses  by number is simple, but it can be
@@ -3536,14 +3658,16 @@ NAMED SUBPATTERNS
          (?<DN>Sat)(?:urday)?
 
        There  are  five capturing substrings, but only one is ever set after a
-       match.  The convenience  function  for  extracting  the  data  by  name
-       returns  the  substring  for  the first (and in this example, the only)
-       subpattern of that name that matched.  This  saves  searching  to  find
-       which  numbered  subpattern  it  was. If you make a reference to a non-
-       unique named subpattern from elsewhere in the  pattern,  the  one  that
-       corresponds  to  the  lowest number is used. For further details of the
-       interfaces for handling named subpatterns, see the  pcreapi  documenta-
-       tion.
+       match.  (An alternative way of solving this problem is to use a "branch
+       reset" subpattern, as described in the previous section.)
+
+       The  convenience  function  for extracting the data by name returns the
+       substring for the first (and in this example, the only)  subpattern  of
+       that  name  that  matched.  This saves searching to find which numbered
+       subpattern it was. If you make a reference to a non-unique  named  sub-
+       pattern  from elsewhere in the pattern, the one that corresponds to the
+       lowest number is used. For further details of the interfaces  for  han-
+       dling named subpatterns, see the pcreapi documentation.
 
 
 REPETITION
@@ -3858,64 +3982,69 @@ BACK REFERENCES
        matches  "rah  rah"  and  "RAH RAH", but not "RAH rah", even though the
        original capturing subpattern is matched caselessly.
 
-       Back references to named subpatterns use the Perl  syntax  \k<name>  or
-       \k'name'  or  the  Python  syntax (?P=name). We could rewrite the above
-       example in either of the following ways:
+       There are several different ways of writing back  references  to  named
+       subpatterns.  The  .NET syntax \k{name} and the Perl syntax \k<name> or
+       \k'name' are supported, as is the Python syntax (?P=name). Perl  5.10's
+       unified back reference syntax, in which \g can be used for both numeric
+       and named references, is also supported. We  could  rewrite  the  above
+       example in any of the following ways:
 
          (?<p1>(?i)rah)\s+\k<p1>
+         (?'p1'(?i)rah)\s+\k{p1}
          (?P<p1>(?i)rah)\s+(?P=p1)
+         (?<p1>(?i)rah)\s+\g{p1}
 
-       A subpattern that is referenced by  name  may  appear  in  the  pattern
+       A  subpattern  that  is  referenced  by  name may appear in the pattern
        before or after the reference.
 
-       There  may be more than one back reference to the same subpattern. If a
-       subpattern has not actually been used in a particular match,  any  back
+       There may be more than one back reference to the same subpattern. If  a
+       subpattern  has  not actually been used in a particular match, any back
        references to it always fail. For example, the pattern
 
          (a|(bc))\2
 
-       always  fails if it starts to match "a" rather than "bc". Because there
-       may be many capturing parentheses in a pattern,  all  digits  following
-       the  backslash  are taken as part of a potential back reference number.
+       always fails if it starts to match "a" rather than "bc". Because  there
+       may  be  many  capturing parentheses in a pattern, all digits following
+       the backslash are taken as part of a potential back  reference  number.
        If the pattern continues with a digit character, some delimiter must be
-       used  to  terminate  the back reference. If the PCRE_EXTENDED option is
-       set, this can be whitespace.  Otherwise an  empty  comment  (see  "Com-
+       used to terminate the back reference. If the  PCRE_EXTENDED  option  is
+       set,  this  can  be  whitespace.  Otherwise an empty comment (see "Com-
        ments" below) can be used.
 
-       A  back reference that occurs inside the parentheses to which it refers
-       fails when the subpattern is first used, so, for example,  (a\1)  never
-       matches.   However,  such references can be useful inside repeated sub-
+       A back reference that occurs inside the parentheses to which it  refers
+       fails  when  the subpattern is first used, so, for example, (a\1) never
+       matches.  However, such references can be useful inside  repeated  sub-
        patterns. For example, the pattern
 
          (a|b\1)+
 
        matches any number of "a"s and also "aba", "ababbaa" etc. At each iter-
-       ation  of  the  subpattern,  the  back  reference matches the character
-       string corresponding to the previous iteration. In order  for  this  to
-       work,  the  pattern must be such that the first iteration does not need
-       to match the back reference. This can be done using alternation, as  in
+       ation of the subpattern,  the  back  reference  matches  the  character
+       string  corresponding  to  the previous iteration. In order for this to
+       work, the pattern must be such that the first iteration does  not  need
+       to  match the back reference. This can be done using alternation, as in
        the example above, or by a quantifier with a minimum of zero.
 
 
 ASSERTIONS
 
-       An  assertion  is  a  test on the characters following or preceding the
-       current matching point that does not actually consume  any  characters.
-       The  simple  assertions  coded  as  \b, \B, \A, \G, \Z, \z, ^ and $ are
+       An assertion is a test on the characters  following  or  preceding  the
+       current  matching  point that does not actually consume any characters.
+       The simple assertions coded as \b, \B, \A, \G, \Z,  \z,  ^  and  $  are
        described above.
 
-       More complicated assertions are coded as  subpatterns.  There  are  two
-       kinds:  those  that  look  ahead of the current position in the subject
-       string, and those that look  behind  it.  An  assertion  subpattern  is
-       matched  in  the  normal way, except that it does not cause the current
+       More  complicated  assertions  are  coded as subpatterns. There are two
+       kinds: those that look ahead of the current  position  in  the  subject
+       string,  and  those  that  look  behind  it. An assertion subpattern is
+       matched in the normal way, except that it does not  cause  the  current
        matching position to be changed.
 
-       Assertion subpatterns are not capturing subpatterns,  and  may  not  be
-       repeated,  because  it  makes no sense to assert the same thing several
-       times. If any kind of assertion contains capturing  subpatterns  within
-       it,  these are counted for the purposes of numbering the capturing sub-
+       Assertion  subpatterns  are  not  capturing subpatterns, and may not be
+       repeated, because it makes no sense to assert the  same  thing  several
+       times.  If  any kind of assertion contains capturing subpatterns within
+       it, these are counted for the purposes of numbering the capturing  sub-
        patterns in the whole pattern.  However, substring capturing is carried
-       out  only  for  positive assertions, because it does not make sense for
+       out only for positive assertions, because it does not  make  sense  for
        negative assertions.
 
    Lookahead assertions
@@ -3925,37 +4054,37 @@ ASSERTIONS
 
          \w+(?=;)
 
-       matches  a word followed by a semicolon, but does not include the semi-
+       matches a word followed by a semicolon, but does not include the  semi-
        colon in the match, and
 
          foo(?!bar)
 
-       matches any occurrence of "foo" that is not  followed  by  "bar".  Note
+       matches  any  occurrence  of  "foo" that is not followed by "bar". Note
        that the apparently similar pattern
 
          (?!foo)bar
 
-       does  not  find  an  occurrence  of "bar" that is preceded by something
-       other than "foo"; it finds any occurrence of "bar" whatsoever,  because
+       does not find an occurrence of "bar"  that  is  preceded  by  something
+       other  than "foo"; it finds any occurrence of "bar" whatsoever, because
        the assertion (?!foo) is always true when the next three characters are
        "bar". A lookbehind assertion is needed to achieve the other effect.
 
        If you want to force a matching failure at some point in a pattern, the
-       most  convenient  way  to  do  it  is with (?!) because an empty string
-       always matches, so an assertion that requires there not to be an  empty
+       most convenient way to do it is  with  (?!)  because  an  empty  string
+       always  matches, so an assertion that requires there not to be an empty
        string must always fail.
 
    Lookbehind assertions
 
-       Lookbehind  assertions start with (?<= for positive assertions and (?<!
+       Lookbehind assertions start with (?<= for positive assertions and  (?<!
        for negative assertions. For example,
 
          (?<!foo)bar
 
-       does find an occurrence of "bar" that is not  preceded  by  "foo".  The
-       contents  of  a  lookbehind  assertion are restricted such that all the
+       does  find  an  occurrence  of "bar" that is not preceded by "foo". The
+       contents of a lookbehind assertion are restricted  such  that  all  the
        strings it matches must have a fixed length. However, if there are sev-
-       eral  top-level  alternatives,  they  do  not all have to have the same
+       eral top-level alternatives, they do not all  have  to  have  the  same
        fixed length. Thus
 
          (?<=bullock|donkey)
@@ -3964,55 +4093,59 @@ ASSERTIONS
 
          (?<!dogs?|cats?)
 
-       causes an error at compile time. Branches that match  different  length
-       strings  are permitted only at the top level of a lookbehind assertion.
-       This is an extension compared with  Perl  (at  least  for  5.8),  which
-       requires  all branches to match the same length of string. An assertion
+       causes  an  error at compile time. Branches that match different length
+       strings are permitted only at the top level of a lookbehind  assertion.
+       This  is  an  extension  compared  with  Perl (at least for 5.8), which
+       requires all branches to match the same length of string. An  assertion
        such as
 
          (?<=ab(c|de))
 
-       is not permitted, because its single top-level  branch  can  match  two
-       different  lengths,  but  it is acceptable if rewritten to use two top-
+       is  not  permitted,  because  its single top-level branch can match two
+       different lengths, but it is acceptable if rewritten to  use  two  top-
        level branches:
 
          (?<=abc|abde)
 
-       The implementation of lookbehind assertions is, for  each  alternative,
-       to  temporarily  move the current position back by the fixed length and
+       In some cases, the Perl 5.10 escape sequence \K (see above) can be used
+       instead of a lookbehind assertion; this is not restricted to  a  fixed-
+       length.
+
+       The  implementation  of lookbehind assertions is, for each alternative,
+       to temporarily move the current position back by the fixed  length  and
        then try to match. If there are insufficient characters before the cur-
        rent position, the assertion fails.
 
        PCRE does not allow the \C escape (which matches a single byte in UTF-8
-       mode) to appear in lookbehind assertions, because it makes it  impossi-
-       ble  to  calculate the length of the lookbehind. The \X and \R escapes,
+       mode)  to appear in lookbehind assertions, because it makes it impossi-
+       ble to calculate the length of the lookbehind. The \X and  \R  escapes,
        which can match different numbers of bytes, are also not permitted.
 
-       Possessive quantifiers can  be  used  in  conjunction  with  lookbehind
-       assertions  to  specify  efficient  matching  at the end of the subject
+       Possessive  quantifiers  can  be  used  in  conjunction with lookbehind
+       assertions to specify efficient matching at  the  end  of  the  subject
        string. Consider a simple pattern such as
 
          abcd$
 
-       when applied to a long string that does  not  match.  Because  matching
+       when  applied  to  a  long string that does not match. Because matching
        proceeds from left to right, PCRE will look for each "a" in the subject
-       and then see if what follows matches the rest of the  pattern.  If  the
+       and  then  see  if what follows matches the rest of the pattern. If the
        pattern is specified as
 
          ^.*abcd$
 
-       the  initial .* matches the entire string at first, but when this fails
+       the initial .* matches the entire string at first, but when this  fails
        (because there is no following "a"), it backtracks to match all but the
-       last  character,  then all but the last two characters, and so on. Once
-       again the search for "a" covers the entire string, from right to  left,
+       last character, then all but the last two characters, and so  on.  Once
+       again  the search for "a" covers the entire string, from right to left,
        so we are no better off. However, if the pattern is written as
 
          ^.*+(?<=abcd)
 
-       there  can  be  no backtracking for the .*+ item; it can match only the
-       entire string. The subsequent lookbehind assertion does a  single  test
-       on  the last four characters. If it fails, the match fails immediately.
-       For long strings, this approach makes a significant difference  to  the
+       there can be no backtracking for the .*+ item; it can  match  only  the
+       entire  string.  The subsequent lookbehind assertion does a single test
+       on the last four characters. If it fails, the match fails  immediately.
+       For  long  strings, this approach makes a significant difference to the
        processing time.
 
    Using multiple assertions
@@ -4021,18 +4154,18 @@ ASSERTIONS
 
          (?<=\d{3})(?<!999)foo
 
-       matches  "foo" preceded by three digits that are not "999". Notice that
-       each of the assertions is applied independently at the  same  point  in
-       the  subject  string.  First  there  is a check that the previous three
-       characters are all digits, and then there is  a  check  that  the  same
+       matches "foo" preceded by three digits that are not "999". Notice  that
+       each  of  the  assertions is applied independently at the same point in
+       the subject string. First there is a  check  that  the  previous  three
+       characters  are  all  digits,  and  then there is a check that the same
        three characters are not "999".  This pattern does not match "foo" pre-
-       ceded by six characters, the first of which are  digits  and  the  last
-       three  of  which  are not "999". For example, it doesn't match "123abc-
+       ceded  by  six  characters,  the first of which are digits and the last
+       three of which are not "999". For example, it  doesn't  match  "123abc-
        foo". A pattern to do that is
 
          (?<=\d{3}...)(?<!999)foo
 
-       This time the first assertion looks at the  preceding  six  characters,
+       This  time  the  first assertion looks at the preceding six characters,
        checking that the first three are digits, and then the second assertion
        checks that the preceding three characters are not "999".
 
@@ -4040,38 +4173,43 @@ ASSERTIONS
 
          (?<=(?<!foo)bar)baz
 
-       matches an occurrence of "baz" that is preceded by "bar" which in  turn
+       matches  an occurrence of "baz" that is preceded by "bar" which in turn
        is not preceded by "foo", while
 
          (?<=\d{3}(?!999)...)foo
 
-       is  another pattern that matches "foo" preceded by three digits and any
+       is another pattern that matches "foo" preceded by three digits and  any
        three characters that are not "999".
 
 
 CONDITIONAL SUBPATTERNS
 
-       It is possible to cause the matching process to obey a subpattern  con-
-       ditionally  or to choose between two alternative subpatterns, depending
-       on the result of an assertion, or whether a previous capturing  subpat-
-       tern  matched  or not. The two possible forms of conditional subpattern
+       It  is possible to cause the matching process to obey a subpattern con-
+       ditionally or to choose between two alternative subpatterns,  depending
+       on  the result of an assertion, or whether a previous capturing subpat-
+       tern matched or not. The two possible forms of  conditional  subpattern
        are
 
          (?(condition)yes-pattern)
          (?(condition)yes-pattern|no-pattern)
 
-       If the condition is satisfied, the yes-pattern is used;  otherwise  the
-       no-pattern  (if  present)  is used. If there are more than two alterna-
+       If  the  condition is satisfied, the yes-pattern is used; otherwise the
+       no-pattern (if present) is used. If there are more  than  two  alterna-
        tives in the subpattern, a compile-time error occurs.
 
-       There are four kinds of condition: references  to  subpatterns,  refer-
+       There  are  four  kinds of condition: references to subpatterns, refer-
        ences to recursion, a pseudo-condition called DEFINE, and assertions.
 
    Checking for a used subpattern by number
 
-       If  the  text between the parentheses consists of a sequence of digits,
-       the condition is true if the capturing subpattern of  that  number  has
-       previously matched.
+       If the text between the parentheses consists of a sequence  of  digits,
+       the  condition  is  true if the capturing subpattern of that number has
+       previously matched. An alternative notation is to  precede  the  digits
+       with a plus or minus sign. In this case, the subpattern number is rela-
+       tive rather than absolute.  The most recently opened parentheses can be
+       referenced  by  (?(-1),  the  next most recent by (?(-2), and so on. In
+       looping constructs it can also make sense to refer to subsequent groups
+       with constructs such as (?(+2).
 
        Consider  the  following  pattern, which contains non-significant white
        space to make it more readable (assume the PCRE_EXTENDED option) and to
@@ -4090,6 +4228,14 @@ CONDITIONAL SUBPATTERNS
        other  words,  this  pattern  matches  a  sequence  of non-parentheses,
        optionally enclosed in parentheses.
 
+       If you were embedding this pattern in a larger one,  you  could  use  a
+       relative reference:
+
+         ...other stuff... ( \( )?    [^()]+    (?(-1) \) ) ...
+
+       This  makes  the  fragment independent of the parentheses in the larger
+       pattern.
+
    Checking for a used subpattern by name
 
        Perl uses the syntax (?(<name>)...) or (?('name')...)  to  test  for  a
@@ -4231,19 +4377,35 @@ RECURSIVE PATTERNS
          ( \( ( (?>[^()]+) | (?1) )* \) )
 
        We  have  put the pattern into parentheses, and caused the recursion to
-       refer to them instead of the whole pattern. In a larger pattern,  keep-
-       ing  track  of parenthesis numbers can be tricky. It may be more conve-
-       nient to use named parentheses instead. The Perl  syntax  for  this  is
-       (?&name);  PCRE's  earlier syntax (?P>name) is also supported. We could
-       rewrite the above example as follows:
+       refer to them instead of the whole pattern.
+
+       In a larger pattern,  keeping  track  of  parenthesis  numbers  can  be
+       tricky.  This is made easier by the use of relative references. (A Perl
+       5.10 feature.)  Instead of (?1) in the  pattern  above  you  can  write
+       (?-2) to refer to the second most recently opened parentheses preceding
+       the recursion. In other  words,  a  negative  number  counts  capturing
+       parentheses leftwards from the point at which it is encountered.
+
+       It  is  also  possible  to refer to subsequently opened parentheses, by
+       writing references such as (?+2). However, these  cannot  be  recursive
+       because  the  reference  is  not inside the parentheses that are refer-
+       enced. They are always "subroutine" calls, as  described  in  the  next
+       section.
+
+       An  alternative  approach is to use named parentheses instead. The Perl
+       syntax for this is (?&name); PCRE's earlier syntax  (?P>name)  is  also
+       supported. We could rewrite the above example as follows:
 
          (?<pn> \( ( (?>[^()]+) | (?&pn) )* \) )
 
-       If there is more than one subpattern with the same name,  the  earliest
-       one  is used. This particular example pattern contains nested unlimited
-       repeats, and so the use of atomic grouping for matching strings of non-
-       parentheses  is  important when applying the pattern to strings that do
-       not match. For example, when this pattern is applied to
+       If  there  is more than one subpattern with the same name, the earliest
+       one is used.
+
+       This particular example pattern that we have been looking  at  contains
+       nested  unlimited repeats, and so the use of atomic grouping for match-
+       ing strings of non-parentheses is important when applying  the  pattern
+       to strings that do not match. For example, when this pattern is applied
+       to
 
          (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
 
@@ -4293,8 +4455,14 @@ SUBPATTERNS AS SUBROUTINES
        If the syntax for a recursive subpattern reference (either by number or
        by  name)  is used outside the parentheses to which it refers, it oper-
        ates like a subroutine in a programming language. The "called"  subpat-
-       tern  may  be defined before or after the reference. An earlier example
-       pointed out that the pattern
+       tern may be defined before or after the reference. A numbered reference
+       can be absolute or relative, as in these examples:
+
+         (...(absolute)...)...(?2)...
+         (...(relative)...)...(?-1)...
+         (...(?+1)...(relative)...
+
+       An earlier example pointed out that the pattern
 
          (sens|respons)e and \1ibility
 
@@ -4316,7 +4484,7 @@ SUBPATTERNS AS SUBROUTINES
        case-independence are fixed when the subpattern is defined. They cannot
        be changed for different calls. For example, consider this pattern:
 
-         (abc)(?i:(?1))
+         (abc)(?i:(?-1))
 
        It matches "abcabc". It does not match "abcABC" because the  change  of
        processing option does not affect the called subpattern.
@@ -4371,7 +4539,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 06 March 2007
+       Last updated: 13 June 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -4452,12 +4620,13 @@ RESTRICTED PATTERNS FOR PCRE_PARTIAL
 
        If PCRE_PARTIAL is set for a pattern  that  does  not  conform  to  the
        restrictions,  pcre_exec() returns the error code PCRE_ERROR_BADPARTIAL
-       (-13).
+       (-13).  You can use the PCRE_INFO_OKPARTIAL call to pcre_fullinfo()  to
+       find out if a compiled pattern can be used for partial matching.
 
 
 EXAMPLE OF PARTIAL MATCHING USING PCRETEST
 
-       If the escape sequence \P is present  in  a  pcretest  data  line,  the
+       If  the  escape  sequence  \P  is  present in a pcretest data line, the
        PCRE_PARTIAL flag is used for the match. Here is a run of pcretest that
        uses the date example quoted above:
 
@@ -4474,10 +4643,10 @@ EXAMPLE OF PARTIAL MATCHING USING PCRETEST
          data> j\P
          No match
 
-       The first data string is matched  completely,  so  pcretest  shows  the
-       matched  substrings.  The  remaining four strings do not match the com-
-       plete pattern, but the first two are partial matches.  The  same  test,
-       using  pcre_dfa_exec()  matching  (by means of the \D escape sequence),
+       The  first  data  string  is  matched completely, so pcretest shows the
+       matched substrings. The remaining four strings do not  match  the  com-
+       plete  pattern,  but  the first two are partial matches. The same test,
+       using pcre_dfa_exec() matching (by means of the  \D  escape  sequence),
        produces the following output:
 
            re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
@@ -4492,18 +4661,18 @@ EXAMPLE OF PARTIAL MATCHING USING PCRETEST
          data> j\P\D
          No match
 
-       Notice that in this case the portion of the string that was matched  is
+       Notice  that in this case the portion of the string that was matched is
        made available.
 
 
 MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
 
        When a partial match has been found using pcre_dfa_exec(), it is possi-
-       ble to continue the match by  providing  additional  subject  data  and
-       calling  pcre_dfa_exec()  again  with the same compiled regular expres-
+       ble  to  continue  the  match  by providing additional subject data and
+       calling pcre_dfa_exec() again with the same  compiled  regular  expres-
        sion, this time setting the PCRE_DFA_RESTART option. You must also pass
-       the  same working space as before, because this is where details of the
-       previous partial match are stored. Here is an example  using  pcretest,
+       the same working space as before, because this is where details of  the
+       previous  partial  match are stored. Here is an example using pcretest,
        using the \R escape sequence to set the PCRE_DFA_RESTART option (\P and
        \D are as above):
 
@@ -4513,35 +4682,35 @@ MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
          data> n05\R\D
           0: n05
 
-       The first call has "23ja" as the subject, and requests  partial  match-
-       ing;  the  second  call  has  "n05"  as  the  subject for the continued
-       (restarted) match.  Notice that when the match is  complete,  only  the
-       last  part  is  shown;  PCRE  does not retain the previously partially-
-       matched string. It is up to the calling program to do that if it  needs
+       The  first  call has "23ja" as the subject, and requests partial match-
+       ing; the second call  has  "n05"  as  the  subject  for  the  continued
+       (restarted)  match.   Notice  that when the match is complete, only the
+       last part is shown; PCRE does  not  retain  the  previously  partially-
+       matched  string. It is up to the calling program to do that if it needs
        to.
 
-       You  can  set  PCRE_PARTIAL  with  PCRE_DFA_RESTART to continue partial
+       You can set PCRE_PARTIAL  with  PCRE_DFA_RESTART  to  continue  partial
        matching over multiple segments. This facility can be used to pass very
-       long  subject  strings to pcre_dfa_exec(). However, some care is needed
+       long subject strings to pcre_dfa_exec(). However, some care  is  needed
        for certain types of pattern.
 
-       1. If the pattern contains tests for the beginning or end  of  a  line,
-       you  need  to pass the PCRE_NOTBOL or PCRE_NOTEOL options, as appropri-
-       ate, when the subject string for any call does not contain  the  begin-
+       1.  If  the  pattern contains tests for the beginning or end of a line,
+       you need to pass the PCRE_NOTBOL or PCRE_NOTEOL options,  as  appropri-
+       ate,  when  the subject string for any call does not contain the begin-
        ning or end of a line.
 
-       2.  If  the  pattern contains backward assertions (including \b or \B),
-       you need to arrange for some overlap in the subject  strings  to  allow
-       for  this.  For  example, you could pass the subject in chunks that are
-       500 bytes long, but in a buffer of 700 bytes, with the starting  offset
+       2. If the pattern contains backward assertions (including  \b  or  \B),
+       you  need  to  arrange for some overlap in the subject strings to allow
+       for this. For example, you could pass the subject in  chunks  that  are
+       500  bytes long, but in a buffer of 700 bytes, with the starting offset
        set to 200 and the previous 200 bytes at the start of the buffer.
 
-       3.  Matching a subject string that is split into multiple segments does
-       not always produce exactly the same result as matching over one  single
-       long  string.   The  difference arises when there are multiple matching
-       possibilities, because a partial match result is given only when  there
-       are  no completed matches in a call to pcre_dfa_exec(). This means that
-       as soon as the shortest match has been found,  continuation  to  a  new
+       3. Matching a subject string that is split into multiple segments  does
+       not  always produce exactly the same result as matching over one single
+       long string.  The difference arises when there  are  multiple  matching
+       possibilities,  because a partial match result is given only when there
+       are no completed matches in a call to pcre_dfa_exec(). This means  that
+       as  soon  as  the  shortest match has been found, continuation to a new
        subject segment is no longer possible.  Consider this pcretest example:
 
            re> /dog(sbody)?/
@@ -4553,13 +4722,13 @@ MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
           0: dogsbody
           1: dog
 
-       The pattern matches the words "dog" or "dogsbody". When the subject  is
-       presented  in  several  parts  ("do" and "gsb" being the first two) the
-       match stops when "dog" has been found, and it is not possible  to  con-
-       tinue.  On  the  other  hand,  if  "dogsbody"  is presented as a single
+       The  pattern matches the words "dog" or "dogsbody". When the subject is
+       presented in several parts ("do" and "gsb" being  the  first  two)  the
+       match  stops  when "dog" has been found, and it is not possible to con-
+       tinue. On the other hand,  if  "dogsbody"  is  presented  as  a  single
        string, both matches are found.
 
-       Because of this phenomenon, it does not usually make  sense  to  end  a
+       Because  of  this  phenomenon,  it does not usually make sense to end a
        pattern that is going to be matched in this way with a variable repeat.
 
        4. Patterns that contain alternatives at the top level which do not all
@@ -4568,13 +4737,13 @@ MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
 
          1234|3789
 
-       If the first part of the subject is "ABC123", a partial  match  of  the
-       first  alternative  is found at offset 3. There is no partial match for
+       If  the  first  part of the subject is "ABC123", a partial match of the
+       first alternative is found at offset 3. There is no partial  match  for
        the second alternative, because such a match does not start at the same
-       point  in  the  subject  string. Attempting to continue with the string
+       point in the subject string. Attempting to  continue  with  the  string
        "789" does not yield a match because only those alternatives that match
-       at  one point in the subject are remembered. The problem arises because
-       the start of the second alternative matches within the  first  alterna-
+       at one point in the subject are remembered. The problem arises  because
+       the  start  of the second alternative matches within the first alterna-
        tive. There is no problem with anchored patterns or patterns such as:
 
          1234|ABCD
@@ -4591,7 +4760,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 06 March 2007
+       Last updated: 04 June 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -4701,19 +4870,9 @@ RE-USING A PRECOMPILED PATTERN
 
 COMPATIBILITY WITH DIFFERENT PCRE RELEASES
 
-       The layout of the control block that is at the start of the  data  that
-       makes  up  a  compiled pattern was changed for release 5.0. If you have
-       any saved patterns that were compiled with  previous  releases  (not  a
-       facility  that  was  previously advertised), you will have to recompile
-       them for release 5.0 and above.
-
-       If you have any saved patterns in UTF-8 mode that use  \p  or  \P  that
-       were  compiled  with any release up to and including 6.4, you will have
-       to recompile them for release 6.5 and above.
-
-       All saved patterns from earlier releases must be recompiled for release
-       7.0  or  higher,  because  there was an internal reorganization at that
-       release.
+       In general, it is safest to  recompile  all  saved  patterns  when  you
+       update  to  a new PCRE release, though not all updates actually require
+       this. Recompiling is definitely needed for release 7.2.
 
 
 AUTHOR
@@ -4725,7 +4884,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 24 April 2007
+       Last updated: 13 June 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -5460,28 +5619,29 @@ PCRE SAMPLE PROGRAM
        bility  of  matching an empty string. Comments in the code explain what
        is going on.
 
-       If PCRE is installed in the standard include  and  library  directories
-       for  your  system, you should be able to compile the demonstration pro-
-       gram using this command:
+       The demonstration program is automatically built if you use  "./config-
+       ure;make"  to  build PCRE. Otherwise, if PCRE is installed in the stan-
+       dard include and library directories for your  system,  you  should  be
+       able to compile the demonstration program using this command:
 
          gcc -o pcredemo pcredemo.c -lpcre
 
-       If PCRE is installed elsewhere, you may need to add additional  options
-       to  the  command line. For example, on a Unix-like system that has PCRE
-       installed in /usr/local, you  can  compile  the  demonstration  program
+       If  PCRE is installed elsewhere, you may need to add additional options
+       to the command line. For example, on a Unix-like system that  has  PCRE
+       installed  in  /usr/local,  you  can  compile the demonstration program
        using a command like this:
 
          gcc -o pcredemo -I/usr/local/include pcredemo.c \
              -L/usr/local/lib -lpcre
 
-       Once  you  have  compiled the demonstration program, you can run simple
+       Once you have compiled the demonstration program, you  can  run  simple
        tests like this:
 
          ./pcredemo 'cat|dog' 'the cat sat on the mat'
          ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
 
-       Note that there is a  much  more  comprehensive  test  program,  called
-       pcretest,  which  supports  many  more  facilities  for testing regular
+       Note  that  there  is  a  much  more comprehensive test program, called
+       pcretest, which supports  many  more  facilities  for  testing  regular
        expressions and the PCRE library. The pcredemo program is provided as a
        simple coding example.
 
@@ -5489,10 +5649,10 @@ PCRE SAMPLE PROGRAM
        the standard library directory, you may get an error like this when you
        try to run pcredemo:
 
-         ld.so.1:  a.out:  fatal:  libpcre.so.0:  open failed: No such file or
+         ld.so.1: a.out: fatal: libpcre.so.0: open failed:  No  such  file  or
        directory
 
-       This is caused by the way shared library support works  on  those  sys-
+       This  is  caused  by the way shared library support works on those sys-
        tems. You need to add
 
          -R/usr/local/lib
@@ -5509,7 +5669,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 06 March 2007
+       Last updated: 13 June 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 PCRESTACK(3)                                                      PCRESTACK(3)
@@ -5579,17 +5739,24 @@ PCRE DISCUSSION OF STACK USAGE
        In environments where stack memory is constrained, you  might  want  to
        compile  PCRE to use heap memory instead of stack for remembering back-
        up points. This makes it run a lot more slowly, however. Details of how
-       to do this are given in the pcrebuild documentation.
-
-       In  Unix-like environments, there is not often a problem with the stack
-       unless very long strings are involved,  though  the  default  limit  on
-       stack  size  varies  from system to system. Values from 8Mb to 64Mb are
+       to do this are given in the pcrebuild documentation. When built in this
+       way, instead of using the stack, PCRE obtains and frees memory by call-
+       ing  the  functions  that  are  pointed to by the pcre_stack_malloc and
+       pcre_stack_free variables. By default,  these  point  to  malloc()  and
+       free(),  but you can replace the pointers to cause PCRE to use your own
+       functions. Since the block sizes are always the same,  and  are  always
+       freed in reverse order, it may be possible to implement customized mem-
+       ory handlers that are more efficient than the standard functions.
+
+       In Unix-like environments, there is not often a problem with the  stack
+       unless  very  long  strings  are  involved, though the default limit on
+       stack size varies from system to system. Values from 8Mb  to  64Mb  are
        common. You can find your default limit by running the command:
 
          ulimit -s
 
-       Unfortunately, the effect of running out of  stack  is  often  SIGSEGV,
-       though  sometimes  a more explicit error message is given. You can nor-
+       Unfortunately,  the  effect  of  running out of stack is often SIGSEGV,
+       though sometimes a more explicit error message is given. You  can  nor-
        mally increase the limit on stack size by code such as this:
 
          struct rlimit rlim;
@@ -5597,21 +5764,21 @@ PCRE DISCUSSION OF STACK USAGE
          rlim.rlim_cur = 100*1024*1024;
          setrlimit(RLIMIT_STACK, &rlim);
 
-       This reads the current limits (soft and hard) using  getrlimit(),  then
-       attempts  to  increase  the  soft limit to 100Mb using setrlimit(). You
+       This  reads  the current limits (soft and hard) using getrlimit(), then
+       attempts to increase the soft limit to  100Mb  using  setrlimit().  You
        must do this before calling pcre_exec().
 
-       PCRE has an internal counter that can be used to  limit  the  depth  of
-       recursion,  and  thus cause pcre_exec() to give an error code before it
-       runs out of stack. By default, the limit is very  large,  and  unlikely
-       ever  to operate. It can be changed when PCRE is built, and it can also
+       PCRE  has  an  internal  counter that can be used to limit the depth of
+       recursion, and thus cause pcre_exec() to give an error code  before  it
+       runs  out  of  stack. By default, the limit is very large, and unlikely
+       ever to operate. It can be changed when PCRE is built, and it can  also
        be set when pcre_exec() is called. For details of these interfaces, see
        the pcrebuild and pcreapi documentation.
 
        As a very rough rule of thumb, you should reckon on about 500 bytes per
-       recursion. Thus, if you want to limit your  stack  usage  to  8Mb,  you
-       should  set  the  limit at 16000 recursions. A 64Mb stack, on the other
-       hand, can support around 128000 recursions. The pcretest  test  program
+       recursion.  Thus,  if  you  want  to limit your stack usage to 8Mb, you
+       should set the limit at 16000 recursions. A 64Mb stack,  on  the  other
+       hand,  can  support around 128000 recursions. The pcretest test program
        has a command line option (-S) that can be used to increase the size of
        its stack.
 
@@ -5625,7 +5792,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 12 March 2007
+       Last updated: 05 June 2007
        Copyright (c) 1997-2007 University of Cambridge.
 ------------------------------------------------------------------------------
 
index 5e3c3fd7e330682e765a1282f6db9e6f5b9acbd3..924a817bbffb9c6aa836c6f859fe71d3a750c9e5 100644 (file)
@@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE.
 
 #define PCRE_MAJOR          7
 #define PCRE_MINOR          2
-#define PCRE_PRERELEASE     -RC1
-#define PCRE_DATE           2007-05-02
+#define PCRE_PRERELEASE     -RC3
+#define PCRE_DATE           2007-06-13
 
 /* 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
@@ -150,6 +150,8 @@ extern "C" {
 #define PCRE_INFO_NAMETABLE          9
 #define PCRE_INFO_STUDYSIZE         10
 #define PCRE_INFO_DEFAULT_TABLES    11
+#define PCRE_INFO_OKPARTIAL         12
+#define PCRE_INFO_JCHANGED          13
 
 /* Request types for pcre_config(). Do not re-arrange, in order to remain
 compatible. */
index dd94473573c9a5469c6eb12e05c0901fd96f9a92..c191539c8b72d439d5cbcdc5d070b50f06d320c5 100644 (file)
@@ -58,6 +58,11 @@ used by pcretest. DEBUG is not defined when building a production library. */
 #endif
 
 
+/* Macro for setting individual bits in class bitmaps. */
+
+#define SETBIT(a,b) a[b/8] |= (1 << (b%8))
+
+
 /*************************************************
 *      Code parameters and static tables         *
 *************************************************/
@@ -87,12 +92,12 @@ static const short int escapes[] = {
      0,      0,      0,      0,      0,      0,      0,      0,   /* 0 - 7 */
      0,      0,    ':',    ';',    '<',    '=',    '>',    '?',   /* 8 - ? */
    '@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E,      0, -ESC_G,   /* @ - G */
-     0,      0,      0,      0,      0,      0,      0,      0,   /* H - O */
--ESC_P, -ESC_Q, -ESC_R, -ESC_S,      0,      0,      0, -ESC_W,   /* P - W */
+-ESC_H,      0,      0, -ESC_K,      0,      0,      0,      0,   /* H - O */
+-ESC_P, -ESC_Q, -ESC_R, -ESC_S,      0,      0, -ESC_V, -ESC_W,   /* P - W */
 -ESC_X,      0, -ESC_Z,    '[',   '\\',    ']',    '^',    '_',   /* X - _ */
    '`',      7, -ESC_b,      0, -ESC_d,  ESC_e,  ESC_f,      0,   /* ` - g */
-     0,      0,      0, -ESC_k,      0,      0,  ESC_n,      0,   /* h - o */
--ESC_p,      0,  ESC_r, -ESC_s,  ESC_tee,    0,      0, -ESC_w,   /* p - w */
+-ESC_h,      0,      0, -ESC_k,      0,      0,  ESC_n,      0,   /* h - o */
+-ESC_p,      0,  ESC_r, -ESC_s,  ESC_tee,    0, -ESC_v, -ESC_w,   /* p - w */
      0,      0, -ESC_z                                            /* x - z */
 };
 
@@ -106,18 +111,18 @@ static const short int escapes[] = {
 /*  70 */     0,     0,      0,       0,      0,     0,      0,      0,
 /*  78 */     0,   '`',    ':',     '#',    '@',  '\'',    '=',    '"',
 /*  80 */     0,     7, -ESC_b,       0, -ESC_d, ESC_e,  ESC_f,      0,
-/*  88 */     0,     0,      0,     '{',      0,     0,      0,      0,
+/*  88 */-ESC_h,     0,      0,     '{',      0,     0,      0,      0,
 /*  90 */     0,     0, -ESC_k,     'l',      0, ESC_n,      0, -ESC_p,
 /*  98 */     0, ESC_r,      0,     '}',      0,     0,      0,      0,
-/*  A0 */     0,   '~', -ESC_s, ESC_tee,      0,     0, -ESC_w,      0,
+/*  A0 */     0,   '~', -ESC_s, ESC_tee,      0,-ESC_v, -ESC_w,      0,
 /*  A8 */     0,-ESC_z,      0,       0,      0,   '[',      0,      0,
 /*  B0 */     0,     0,      0,       0,      0,     0,      0,      0,
 /*  B8 */     0,     0,      0,       0,      0,   ']',    '=',    '-',
 /*  C0 */   '{',-ESC_A, -ESC_B,  -ESC_C, -ESC_D,-ESC_E,      0, -ESC_G,
-/*  C8 */     0,     0,      0,       0,      0,     0,      0,      0,
+/*  C8 */-ESC_H,     0,      0,       0,      0,     0,      0,      0,
 /*  D0 */   '}',     0,      0,       0,      0,     0,      0, -ESC_P,
 /*  D8 */-ESC_Q,-ESC_R,      0,       0,      0,     0,      0,      0,
-/*  E0 */  '\\',     0, -ESC_S,       0,      0,     0, -ESC_W, -ESC_X,
+/*  E0 */  '\\',     0, -ESC_S,       0,      0,-ESC_V, -ESC_W, -ESC_X,
 /*  E8 */     0,-ESC_Z,      0,       0,      0,     0,      0,      0,
 /*  F0 */     0,     0,      0,       0,      0,     0,      0,      0,
 /*  F8 */     0,     0,      0,       0,      0,     0,      0,      0
@@ -208,7 +213,7 @@ static const char *error_texts[] = {
   "malformed number or name after (?(",
   "conditional group contains more than two branches",
   "assertion expected after (?(",
-  "(?R or (?digits must be followed by )",
+  "(?R or (?[+-]digits must be followed by )",
   /* 30 */
   "unknown POSIX class name",
   "POSIX collating elements are not supported",
@@ -242,7 +247,8 @@ static const char *error_texts[] = {
   /* 55 */
   "repeating a DEFINE group is not allowed",
   "inconsistent NEWLINE options",
-  "\\g is not followed by an (optionally braced) non-zero number"
+  "\\g is not followed by a braced name or an optionally braced non-zero number",
+  "(?+ or (?- or (?(+ or (?(- must be followed by a non-zero number"
 };
 
 
@@ -373,8 +379,8 @@ static const unsigned char ebcdic_chartab[] = { /* chartable partial dup */
 /* Definition to allow mutual recursion */
 
 static BOOL
-  compile_regex(int, int, uschar **, const uschar **, int *, BOOL, int, int *,
-    int *, branch_chain *, compile_data *, int *);
+  compile_regex(int, int, uschar **, const uschar **, int *, BOOL, BOOL, int,
+    int *, int *, branch_chain *, compile_data *, int *);
 
 
 
@@ -452,11 +458,22 @@ else
 
     /* \g must be followed by a number, either plain or braced. If positive, it
     is an absolute backreference. If negative, it is a relative backreference.
-    This is a Perl 5.10 feature. */
+    This is a Perl 5.10 feature. Perl 5.10 also supports \g{name} as a
+    reference to a named group. This is part of Perl's movement towards a
+    unified syntax for back references. As this is synonymous with \k{name}, we
+    fudge it up by pretending it really was \k. */
 
     case 'g':
     if (ptr[1] == '{')
       {
+      const uschar *p;
+      for (p = ptr+2; *p != 0 && *p != '}'; p++)
+        if (*p != '-' && (digitab[*p] & ctype_digit) == 0) break;
+      if (*p != 0 && *p != '}')
+        {
+        c = -ESC_k;
+        break;
+        }
       braced = TRUE;
       ptr++;
       }
@@ -1370,6 +1387,18 @@ for (code = first_significant_code(code + _pcre_OP_lengths[*code], NULL, 0, TRUE
 
   c = *code;
 
+  /* Groups with zero repeats can of course be empty; skip them. */
+
+  if (c == OP_BRAZERO || c == OP_BRAMINZERO)
+    {
+    code += _pcre_OP_lengths[c];
+    do code += GET(code, 1); while (*code == OP_ALT);
+    c = *code;
+    continue;
+    }
+
+  /* For other groups, scan the branches. */
+
   if (c == OP_BRA || c == OP_CBRA || c == OP_ONCE)
     {
     BOOL empty_branch;
@@ -1386,12 +1415,7 @@ for (code = first_significant_code(code + _pcre_OP_lengths[*code], NULL, 0, TRUE
       }
     while (*code == OP_ALT);
     if (!empty_branch) return FALSE;   /* All branches are non-empty */
-
-    /* Move past the KET and fudge things so that the increment in the "for"
-    above has no effect. */
-
-    c = OP_END;
-    code += 1 + LINK_SIZE - _pcre_OP_lengths[c];
+    c = *code;
     continue;
     }
 
@@ -1925,6 +1949,50 @@ if (next >= 0) switch(op_code)
   case OP_NOT_WORDCHAR:
   return next <= 127 && (cd->ctypes[next] & ctype_word) != 0;
 
+  case OP_HSPACE:
+  case OP_NOT_HSPACE:
+  switch(next)
+    {
+    case 0x09:
+    case 0x20:
+    case 0xa0:
+    case 0x1680:
+    case 0x180e:
+    case 0x2000:
+    case 0x2001:
+    case 0x2002:
+    case 0x2003:
+    case 0x2004:
+    case 0x2005:
+    case 0x2006:
+    case 0x2007:
+    case 0x2008:
+    case 0x2009:
+    case 0x200A:
+    case 0x202f:
+    case 0x205f:
+    case 0x3000:
+    return op_code != OP_HSPACE;
+    default:
+    return op_code == OP_HSPACE;
+    }
+
+  case OP_VSPACE:
+  case OP_NOT_VSPACE:
+  switch(next)
+    {
+    case 0x0a:
+    case 0x0b:
+    case 0x0c:
+    case 0x0d:
+    case 0x85:
+    case 0x2028:
+    case 0x2029:
+    return op_code != OP_VSPACE;
+    default:
+    return op_code == OP_VSPACE;
+    }
+
   default:
   return FALSE;
   }
@@ -1959,12 +2027,57 @@ switch(op_code)
     case ESC_W:
     return item <= 127 && (cd->ctypes[item] & ctype_word) != 0;
 
+    case ESC_h:
+    case ESC_H:
+    switch(item)
+      {
+      case 0x09:
+      case 0x20:
+      case 0xa0:
+      case 0x1680:
+      case 0x180e:
+      case 0x2000:
+      case 0x2001:
+      case 0x2002:
+      case 0x2003:
+      case 0x2004:
+      case 0x2005:
+      case 0x2006:
+      case 0x2007:
+      case 0x2008:
+      case 0x2009:
+      case 0x200A:
+      case 0x202f:
+      case 0x205f:
+      case 0x3000:
+      return -next != ESC_h;
+      default:
+      return -next == ESC_h;
+      }
+
+    case ESC_v:
+    case ESC_V:
+    switch(item)
+      {
+      case 0x0a:
+      case 0x0b:
+      case 0x0c:
+      case 0x0d:
+      case 0x85:
+      case 0x2028:
+      case 0x2029:
+      return -next != ESC_v;
+      default:
+      return -next == ESC_v;
+      }
+
     default:
     return FALSE;
     }
 
   case OP_DIGIT:
-  return next == -ESC_D || next == -ESC_s || next == -ESC_W;
+  return next == -ESC_D || next == -ESC_s || next == -ESC_W ||
+         next == -ESC_h || next == -ESC_v;
 
   case OP_NOT_DIGIT:
   return next == -ESC_d;
@@ -1973,10 +2086,23 @@ switch(op_code)
   return next == -ESC_S || next == -ESC_d || next == -ESC_w;
 
   case OP_NOT_WHITESPACE:
-  return next == -ESC_s;
+  return next == -ESC_s || next == -ESC_h || next == -ESC_v;
+
+  case OP_HSPACE:
+  return next == -ESC_S || next == -ESC_H || next == -ESC_d || next == -ESC_w;
+
+  case OP_NOT_HSPACE:
+  return next == -ESC_h;
+
+  /* Can't have \S in here because VT matches \S (Perl anomaly) */
+  case OP_VSPACE:
+  return next == -ESC_V || next == -ESC_d || next == -ESC_w;
+
+  case OP_NOT_VSPACE:
+  return next == -ESC_v;
 
   case OP_WORDCHAR:
-  return next == -ESC_W || next == -ESC_s;
+  return next == -ESC_W || next == -ESC_s || next == -ESC_h || next == -ESC_v;
 
   case OP_NOT_WORDCHAR:
   return next == -ESC_w || next == -ESC_d;
@@ -2091,10 +2217,12 @@ for (;; ptr++)
   BOOL possessive_quantifier;
   BOOL is_quantifier;
   BOOL is_recurse;
+  BOOL reset_bracount;
   int class_charcount;
   int class_lastchar;
   int newoptions;
   int recno;
+  int refsign;
   int skipbytes;
   int subreqbyte;
   int subfirstbyte;
@@ -2519,6 +2647,133 @@ for (;; ptr++)
           else if (c == -ESC_d || c == -ESC_D || c == -ESC_w ||
                    c == -ESC_W || c == -ESC_s || c == -ESC_S) continue;
 
+          /* We need to deal with \H, \h, \V, and \v in both phases because
+          they use extra memory. */
+
+          if (-c == ESC_h)
+            {
+            SETBIT(classbits, 0x09); /* VT */
+            SETBIT(classbits, 0x20); /* SPACE */
+            SETBIT(classbits, 0xa0); /* NSBP */
+#ifdef SUPPORT_UTF8
+            if (utf8)
+              {
+              class_utf8 = TRUE;
+              *class_utf8data++ = XCL_SINGLE;
+              class_utf8data += _pcre_ord2utf8(0x1680, class_utf8data);
+              *class_utf8data++ = XCL_SINGLE;
+              class_utf8data += _pcre_ord2utf8(0x180e, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x2000, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x200A, class_utf8data);
+              *class_utf8data++ = XCL_SINGLE;
+              class_utf8data += _pcre_ord2utf8(0x202f, class_utf8data);
+              *class_utf8data++ = XCL_SINGLE;
+              class_utf8data += _pcre_ord2utf8(0x205f, class_utf8data);
+              *class_utf8data++ = XCL_SINGLE;
+              class_utf8data += _pcre_ord2utf8(0x3000, class_utf8data);
+              }
+#endif
+            continue;
+            }
+
+          if (-c == ESC_H)
+            {
+            for (c = 0; c < 32; c++)
+              {
+              int x = 0xff;
+              switch (c)
+                {
+                case 0x09/8: x ^= 1 << (0x09%8); break;
+                case 0x20/8: x ^= 1 << (0x20%8); break;
+                case 0xa0/8: x ^= 1 << (0xa0%8); break;
+                default: break;
+                }
+              classbits[c] |= x;
+              }
+
+#ifdef SUPPORT_UTF8
+            if (utf8)
+              {
+              class_utf8 = TRUE;
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x0100, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x167f, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x1681, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x180d, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x180f, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x1fff, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x200B, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x202e, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x2030, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x205e, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x2060, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x2fff, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x3001, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x7fffffff, class_utf8data);
+              }
+#endif
+            continue;
+            }
+
+          if (-c == ESC_v)
+            {
+            SETBIT(classbits, 0x0a); /* LF */
+            SETBIT(classbits, 0x0b); /* VT */
+            SETBIT(classbits, 0x0c); /* FF */
+            SETBIT(classbits, 0x0d); /* CR */
+            SETBIT(classbits, 0x85); /* NEL */
+#ifdef SUPPORT_UTF8
+            if (utf8)
+              {
+              class_utf8 = TRUE;
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x2028, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x2029, class_utf8data);
+              }
+#endif
+            continue;
+            }
+
+          if (-c == ESC_V)
+            {
+            for (c = 0; c < 32; c++)
+              {
+              int x = 0xff;
+              switch (c)
+                {
+                case 0x0a/8: x ^= 1 << (0x0a%8);
+                             x ^= 1 << (0x0b%8);
+                             x ^= 1 << (0x0c%8);
+                             x ^= 1 << (0x0d%8);
+                             break;
+                case 0x85/8: x ^= 1 << (0x85%8); break;
+                default: break;
+                }
+              classbits[c] |= x;
+              }
+
+#ifdef SUPPORT_UTF8
+            if (utf8)
+              {
+              class_utf8 = TRUE;
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x0100, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x2027, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x2029, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x7fffffff, class_utf8data);
+              }
+#endif
+            continue;
+            }
+
           /* We need to deal with \P and \p in both phases. */
 
 #ifdef SUPPORT_UCP
@@ -2659,14 +2914,18 @@ for (;; ptr++)
             unsigned int origd = d;
             while (get_othercase_range(&cc, origd, &occ, &ocd))
               {
-              if (occ >= c && ocd <= d) continue;  /* Skip embedded ranges */
+              if (occ >= (unsigned int)c &&
+                  ocd <= (unsigned int)d)
+                continue;                          /* Skip embedded ranges */
 
-              if (occ < c  && ocd >= c - 1)        /* Extend the basic range */
+              if (occ < (unsigned int)c  &&
+                  ocd >= (unsigned int)c - 1)      /* Extend the basic range */
                 {                                  /* if there is overlap,   */
                 c = occ;                           /* noting that if occ < c */
                 continue;                          /* we can't have ocd > d  */
                 }                                  /* because a subrange is  */
-              if (ocd > d && occ <= d + 1)         /* always shorter than    */
+              if (ocd > (unsigned int)d &&
+                  occ <= (unsigned int)d + 1)      /* always shorter than    */
                 {                                  /* the basic range.       */
                 d = ocd;
                 continue;
@@ -3564,6 +3823,7 @@ for (;; ptr++)
     skipbytes = 0;
     bravalue = OP_CBRA;
     save_hwm = cd->hwm;
+    reset_bracount = FALSE;
 
     if (*(++ptr) == '?')
       {
@@ -3585,6 +3845,11 @@ for (;; ptr++)
         continue;
 
 
+        /* ------------------------------------------------------------ */
+        case '|':                 /* Reset capture count for each branch */
+        reset_bracount = TRUE;
+        /* Fall through */
+
         /* ------------------------------------------------------------ */
         case ':':                 /* Non-capturing bracket */
         bravalue = OP_BRA;
@@ -3621,6 +3886,7 @@ for (;; ptr++)
 
         code[1+LINK_SIZE] = OP_CREF;
         skipbytes = 3;
+        refsign = -1;
 
         /* Check for a test for recursion in a named group. */
 
@@ -3644,7 +3910,11 @@ for (;; ptr++)
           terminator = '\'';
           ptr++;
           }
-        else terminator = 0;
+        else
+          {
+          terminator = 0;
+          if (ptr[1] == '-' || ptr[1] == '+') refsign = *(++ptr);
+          }
 
         /* We now expect to read a name; any thing else is an error */
 
@@ -3680,7 +3950,32 @@ for (;; ptr++)
         if (lengthptr != NULL) break;
 
         /* In the real compile we do the work of looking for the actual
-        reference. */
+        reference. If the string started with "+" or "-" we require the rest to
+        be digits, in which case recno will be set. */
+
+        if (refsign > 0)
+          {
+          if (recno <= 0)
+            {
+            *errorcodeptr = ERR58;
+            goto FAILED;
+            }
+          if (refsign == '-')
+            {
+            recno = cd->bracount - recno + 1;
+            if (recno <= 0)
+              {
+              *errorcodeptr = ERR15;
+              goto FAILED;
+              }
+            }
+          else recno += cd->bracount;
+          PUT2(code, 2+LINK_SIZE, recno);
+          break;
+          }
+
+        /* Otherwise (did not start with "+" or "-"), start by looking for the
+        name. */
 
         slot = cd->name_table;
         for (i = 0; i < cd->names_found; i++)
@@ -3999,19 +4294,54 @@ for (;; ptr++)
 
 
         /* ------------------------------------------------------------ */
+        case '-': case '+':
         case '0': case '1': case '2': case '3': case '4':   /* Recursion or */
         case '5': case '6': case '7': case '8': case '9':   /* subroutine */
           {
           const uschar *called;
+
+          if ((refsign = *ptr) == '+') ptr++;
+          else if (refsign == '-')
+            {
+            if ((digitab[ptr[1]] & ctype_digit) == 0)
+              goto OTHER_CHAR_AFTER_QUERY;
+            ptr++;
+            }
+
           recno = 0;
           while((digitab[*ptr] & ctype_digit) != 0)
             recno = recno * 10 + *ptr++ - '0';
+
           if (*ptr != ')')
             {
             *errorcodeptr = ERR29;
             goto FAILED;
             }
 
+          if (refsign == '-')
+            {
+            if (recno == 0)
+              {
+              *errorcodeptr = ERR58;
+              goto FAILED;
+              }
+            recno = cd->bracount - recno + 1;
+            if (recno <= 0)
+              {
+              *errorcodeptr = ERR15;
+              goto FAILED;
+              }
+            }
+          else if (refsign == '+')
+            {
+            if (recno == 0)
+              {
+              *errorcodeptr = ERR58;
+              goto FAILED;
+              }
+            recno += cd->bracount;
+            }
+
           /* Come here from code above that handles a named recursion */
 
           HANDLE_RECURSION:
@@ -4084,6 +4414,7 @@ for (;; ptr++)
 
         /* ------------------------------------------------------------ */
         default:              /* Other characters: check option setting */
+        OTHER_CHAR_AFTER_QUERY:
         set = unset = 0;
         optset = &set;
 
@@ -4218,6 +4549,7 @@ for (;; ptr++)
          errorcodeptr,                 /* Where to put an error message */
          (bravalue == OP_ASSERTBACK ||
           bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */
+         reset_bracount,               /* True if (?| group */
          skipbytes,                    /* Skip over bracket number */
          &subfirstbyte,                /* For possible first char */
          &subreqbyte,                  /* For possible last char */
@@ -4234,9 +4566,11 @@ for (;; ptr++)
     is on the bracket. */
 
     /* If this is a conditional bracket, check that there are no more than
-    two branches in the group, or just one if it's a DEFINE group. */
+    two branches in the group, or just one if it's a DEFINE group. We do this
+    in the real compile phase, not in the pre-pass, where the whole group may
+    not be available. */
 
-    if (bravalue == OP_COND)
+    if (bravalue == OP_COND && lengthptr == NULL)
       {
       uschar *tc = code;
       int condcount = 0;
@@ -4396,12 +4730,13 @@ for (;; ptr++)
       zerofirstbyte = firstbyte;
       zeroreqbyte = reqbyte;
 
-      /* \k<name> or \k'name' is a back reference by name (Perl syntax) */
+      /* \k<name> or \k'name' is a back reference by name (Perl syntax).
+      We also support \k{name} (.NET syntax) */
 
-      if (-c == ESC_k && (ptr[1] == '<' || ptr[1] == '\''))
+      if (-c == ESC_k && (ptr[1] == '<' || ptr[1] == '\'' || ptr[1] == '{'))
         {
         is_recurse = FALSE;
-        terminator = (*(++ptr) == '<')? '>' : '\'';
+        terminator = (*(++ptr) == '<')? '>' : (*ptr == '\'')? '\'' : '}';
         goto NAMED_REF_OR_RECURSE;
         }
 
@@ -4567,13 +4902,14 @@ This function is used during the pre-compile phase when we are trying to find
 out the amount of memory needed, as well as during the real compile phase. The
 value of lengthptr distinguishes the two phases.
 
-Argument:
+Arguments:
   options        option bits, including any changes for this subpattern
   oldims         previous settings of ims option bits
   codeptr        -> the address of the current code pointer
   ptrptr         -> the address of the current pattern pointer
   errorcodeptr   -> pointer to error code variable
   lookbehind     TRUE if this is a lookbehind assertion
+  reset_bracount TRUE to reset the count for each branch
   skipbytes      skip this many bytes at start (for brackets and OP_COND)
   firstbyteptr   place to put the first required character, or a negative number
   reqbyteptr     place to put the last required character, or a negative number
@@ -4587,8 +4923,9 @@ Returns:         TRUE on success
 
 static BOOL
 compile_regex(int options, int oldims, uschar **codeptr, const uschar **ptrptr,
-  int *errorcodeptr, BOOL lookbehind, int skipbytes, int *firstbyteptr,
-  int *reqbyteptr, branch_chain *bcptr, compile_data *cd, int *lengthptr)
+  int *errorcodeptr, BOOL lookbehind, BOOL reset_bracount, int skipbytes,
+  int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr, compile_data *cd,
+  int *lengthptr)
 {
 const uschar *ptr = *ptrptr;
 uschar *code = *codeptr;
@@ -4598,6 +4935,8 @@ uschar *reverse_count = NULL;
 int firstbyte, reqbyte;
 int branchfirstbyte, branchreqbyte;
 int length;
+int orig_bracount;
+int max_bracount;
 branch_chain bc;
 
 bc.outer = bcptr;
@@ -4626,8 +4965,14 @@ code += 1 + LINK_SIZE + skipbytes;
 
 /* Loop for each alternative branch */
 
+orig_bracount = max_bracount = cd->bracount;
 for (;;)
   {
+  /* For a (?| group, reset the capturing bracket count so that each branch
+  uses the same numbers. */
+
+  if (reset_bracount) cd->bracount = orig_bracount;
+
   /* Handle a change of ims options at the start of the branch */
 
   if ((options & PCRE_IMS) != oldims)
@@ -4657,6 +5002,11 @@ for (;;)
     return FALSE;
     }
 
+  /* Keep the highest bracket count in case (?| was used and some branch
+  has fewer than the rest. */
+
+  if (cd->bracount > max_bracount) max_bracount = cd->bracount;
+
   /* In the real compile phase, there is some post-processing to be done. */
 
   if (lengthptr == NULL)
@@ -4720,26 +5070,29 @@ for (;;)
       }
     }
 
-  /* Reached end of expression, either ')' or end of pattern. Go back through
-  the alternative branches and reverse the chain of offsets, with the field in
-  the BRA item now becoming an offset to the first alternative. If there are
-  no alternatives, it points to the end of the group. The length in the
-  terminating ket is always the length of the whole bracketed item. If any of
-  the ims options were changed inside the group, compile a resetting op-code
-  following, except at the very end of the pattern. Return leaving the pointer
-  at the terminating char. */
+  /* Reached end of expression, either ')' or end of pattern. In the real
+  compile phase, go back through the alternative branches and reverse the chain
+  of offsets, with the field in the BRA item now becoming an offset to the
+  first alternative. If there are no alternatives, it points to the end of the
+  group. The length in the terminating ket is always the length of the whole
+  bracketed item. If any of the ims options were changed inside the group,
+  compile a resetting op-code following, except at the very end of the pattern.
+  Return leaving the pointer at the terminating char. */
 
   if (*ptr != '|')
     {
-    int branch_length = code - last_branch;
-    do
+    if (lengthptr == NULL)
       {
-      int prev_length = GET(last_branch, 1);
-      PUT(last_branch, 1, branch_length);
-      branch_length = prev_length;
-      last_branch -= branch_length;
+      int branch_length = code - last_branch;
+      do
+        {
+        int prev_length = GET(last_branch, 1);
+        PUT(last_branch, 1, branch_length);
+        branch_length = prev_length;
+        last_branch -= branch_length;
+        }
+      while (branch_length > 0);
       }
-    while (branch_length > 0);
 
     /* Fill in the ket */
 
@@ -4756,6 +5109,10 @@ for (;;)
       length += 2;
       }
 
+    /* Retain the highest bracket number, in case resetting was used. */
+
+    cd->bracount = max_bracount;
+
     /* Set values to pass back */
 
     *codeptr = code;
@@ -4766,17 +5123,29 @@ for (;;)
     return TRUE;
     }
 
-  /* Another branch follows; insert an "or" node. Its length field points back
+  /* Another branch follows. In the pre-compile phase, we can move the code
+  pointer back to where it was for the start of the first branch. (That is,
+  pretend that each branch is the only one.)
+
+  In the real compile phase, insert an ALT node. Its length field points back
   to the previous branch while the bracket remains open. At the end the chain
   is reversed. It's done like this so that the start of the bracket has a
   zero offset until it is closed, making it possible to detect recursion. */
 
-  *code = OP_ALT;
-  PUT(code, 1, code - last_branch);
-  bc.current = last_branch = code;
-  code += 1 + LINK_SIZE;
+  if (lengthptr != NULL)
+    {
+    code = *codeptr + 1 + LINK_SIZE + skipbytes;
+    length += 1 + LINK_SIZE;
+    }
+  else
+    {
+    *code = OP_ALT;
+    PUT(code, 1, code - last_branch);
+    bc.current = last_branch = code;
+    code += 1 + LINK_SIZE;
+    }
+
   ptr++;
-  length += 1 + LINK_SIZE;
   }
 /* Control never reaches here */
 }
@@ -5218,7 +5587,8 @@ outside can help speed up starting point checks. */
 code = cworkspace;
 *code = OP_BRA;
 (void)compile_regex(cd->external_options, cd->external_options & PCRE_IMS,
-  &code, &ptr, &errorcode, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, &length);
+  &code, &ptr, &errorcode, FALSE, FALSE, 0, &firstbyte, &reqbyte, NULL, cd,
+  &length);
 if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN;
 
 DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,
@@ -5286,7 +5656,7 @@ ptr = (const uschar *)pattern;
 code = (uschar *)codestart;
 *code = OP_BRA;
 (void)compile_regex(re->options, re->options & PCRE_IMS, &code, &ptr,
-  &errorcode, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, NULL);
+  &errorcode, FALSE, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, NULL);
 re->top_bracket = cd->bracount;
 re->top_backref = cd->top_backref;
 
index 68620829fb247217239b87b8a923015d30475da9..f62b5fc18e04d60ebbee9818c5cdef16582d6e2a 100644 (file)
@@ -226,7 +226,7 @@ actuall used in this definition. */
 #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
   { \
   printf("match() called in line %d\n", __LINE__); \
-  rrc = match(ra,rb,rc,rd,re,rf,rg,rdepth+1); \
+  rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1); \
   printf("to line %d\n", __LINE__); \
   }
 #define RRETURN(ra) \
@@ -236,7 +236,7 @@ actuall used in this definition. */
   }
 #else
 #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
-  rrc = match(ra,rb,rc,rd,re,rf,rg,rdepth+1)
+  rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1)
 #define RRETURN(ra) return ra
 #endif
 
@@ -255,6 +255,7 @@ argument of match(), which never changes. */
   frame->Xwhere = rw; \
   newframe->Xeptr = ra;\
   newframe->Xecode = rb;\
+  newframe->Xmstart = mstart;\
   newframe->Xoffset_top = rc;\
   newframe->Xims = re;\
   newframe->Xeptrb = rf;\
@@ -291,6 +292,7 @@ typedef struct heapframe {
 
   const uschar *Xeptr;
   const uschar *Xecode;
+  const uschar *Xmstart;
   int Xoffset_top;
   long int Xims;
   eptrblock *Xeptrb;
@@ -371,6 +373,8 @@ made performance worse.
 Arguments:
    eptr        pointer to current character in subject
    ecode       pointer to current position in compiled code
+   mstart      pointer to the current match start position (can be modified
+                 by encountering \K)
    offset_top  current top pointer
    md          pointer to "static" info for the match
    ims         current /i, /m, and /s options
@@ -390,7 +394,7 @@ Returns:       MATCH_MATCH if matched            )  these values are >= 0
 */
 
 static int
-match(REGISTER USPTR eptr, REGISTER const uschar *ecode,
+match(REGISTER USPTR eptr, REGISTER const uschar *ecode, const uschar *mstart,
   int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,
   int flags, unsigned int rdepth)
 {
@@ -418,6 +422,7 @@ frame->Xprevframe = NULL;            /* Marks the top level */
 
 frame->Xeptr = eptr;
 frame->Xecode = ecode;
+frame->Xmstart = mstart;
 frame->Xoffset_top = offset_top;
 frame->Xims = ims;
 frame->Xeptrb = eptrb;
@@ -432,6 +437,7 @@ HEAP_RECURSE:
 
 #define eptr               frame->Xeptr
 #define ecode              frame->Xecode
+#define mstart             frame->Xmstart
 #define offset_top         frame->Xoffset_top
 #define ims                frame->Xims
 #define eptrb              frame->Xeptrb
@@ -610,7 +616,7 @@ for (;;)
 
   if (md->partial &&
       eptr >= md->end_subject &&
-      eptr > md->start_match)
+      eptr > mstart)
     md->hitend = TRUE;
 
   switch(op)
@@ -787,7 +793,7 @@ for (;;)
       md->recursive = rec->prevrec;
       memmove(md->offset_vector, rec->offset_save,
         rec->saved_max * sizeof(int));
-      md->start_match = rec->save_start;
+      mstart = rec->save_start;
       ims = original_ims;
       ecode = rec->after_call;
       break;
@@ -796,9 +802,10 @@ for (;;)
     /* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty
     string - backtracking will then try other alternatives, if any. */
 
-    if (md->notempty && eptr == md->start_match) RRETURN(MATCH_NOMATCH);
-    md->end_match_ptr = eptr;          /* Record where we ended */
-    md->end_offset_top = offset_top;   /* and how many extracts were taken */
+    if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH);
+    md->end_match_ptr = eptr;           /* Record where we ended */
+    md->end_offset_top = offset_top;    /* and how many extracts were taken */
+    md->start_match_ptr = mstart;  /* and the start (\K can modify) */
     RRETURN(MATCH_MATCH);
 
     /* Change option settings */
@@ -904,7 +911,7 @@ for (;;)
       cb.offset_vector    = md->offset_vector;
       cb.subject          = (PCRE_SPTR)md->start_subject;
       cb.subject_length   = md->end_subject - md->start_subject;
-      cb.start_match      = md->start_match - md->start_subject;
+      cb.start_match      = mstart - md->start_subject;
       cb.current_position = eptr - md->start_subject;
       cb.pattern_position = GET(ecode, 2);
       cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
@@ -966,8 +973,8 @@ for (;;)
 
       memcpy(new_recursive.offset_save, md->offset_vector,
             new_recursive.saved_max * sizeof(int));
-      new_recursive.save_start = md->start_match;
-      md->start_match = eptr;
+      new_recursive.save_start = mstart;
+      mstart = eptr;
 
       /* OK, now we can do the recursion. For each top-level alternative we
       restore the offset and recursion data. */
@@ -1180,7 +1187,7 @@ for (;;)
         recursion_info *rec = md->recursive;
         DPRINTF(("Recursion (%d) succeeded - continuing\n", number));
         md->recursive = rec->prevrec;
-        md->start_match = rec->save_start;
+        mstart = rec->save_start;
         memcpy(md->offset_vector, rec->offset_save,
           rec->saved_max * sizeof(int));
         ecode = rec->after_call;
@@ -1260,6 +1267,13 @@ for (;;)
     ecode++;
     break;
 
+    /* Reset the start of match point */
+
+    case OP_SET_SOM:
+    mstart = eptr;
+    ecode++;
+    break;
+
     /* Assert before internal newline if multiline, or before a terminating
     newline unless endonly is set, else end of subject unless noteol is set. */
 
@@ -1468,6 +1482,102 @@ for (;;)
     ecode++;
     break;
 
+    case OP_NOT_HSPACE:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    switch(c)
+      {
+      default: break;
+      case 0x09:      /* HT */
+      case 0x20:      /* SPACE */
+      case 0xa0:      /* NBSP */
+      case 0x1680:    /* OGHAM SPACE MARK */
+      case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+      case 0x2000:    /* EN QUAD */
+      case 0x2001:    /* EM QUAD */
+      case 0x2002:    /* EN SPACE */
+      case 0x2003:    /* EM SPACE */
+      case 0x2004:    /* THREE-PER-EM SPACE */
+      case 0x2005:    /* FOUR-PER-EM SPACE */
+      case 0x2006:    /* SIX-PER-EM SPACE */
+      case 0x2007:    /* FIGURE SPACE */
+      case 0x2008:    /* PUNCTUATION SPACE */
+      case 0x2009:    /* THIN SPACE */
+      case 0x200A:    /* HAIR SPACE */
+      case 0x202f:    /* NARROW NO-BREAK SPACE */
+      case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+      case 0x3000:    /* IDEOGRAPHIC SPACE */
+      RRETURN(MATCH_NOMATCH);
+      }
+    ecode++;
+    break;
+
+    case OP_HSPACE:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    switch(c)
+      {
+      default: RRETURN(MATCH_NOMATCH);
+      case 0x09:      /* HT */
+      case 0x20:      /* SPACE */
+      case 0xa0:      /* NBSP */
+      case 0x1680:    /* OGHAM SPACE MARK */
+      case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+      case 0x2000:    /* EN QUAD */
+      case 0x2001:    /* EM QUAD */
+      case 0x2002:    /* EN SPACE */
+      case 0x2003:    /* EM SPACE */
+      case 0x2004:    /* THREE-PER-EM SPACE */
+      case 0x2005:    /* FOUR-PER-EM SPACE */
+      case 0x2006:    /* SIX-PER-EM SPACE */
+      case 0x2007:    /* FIGURE SPACE */
+      case 0x2008:    /* PUNCTUATION SPACE */
+      case 0x2009:    /* THIN SPACE */
+      case 0x200A:    /* HAIR SPACE */
+      case 0x202f:    /* NARROW NO-BREAK SPACE */
+      case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+      case 0x3000:    /* IDEOGRAPHIC SPACE */
+      break;
+      }
+    ecode++;
+    break;
+
+    case OP_NOT_VSPACE:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    switch(c)
+      {
+      default: break;
+      case 0x0a:      /* LF */
+      case 0x0b:      /* VT */
+      case 0x0c:      /* FF */
+      case 0x0d:      /* CR */
+      case 0x85:      /* NEL */
+      case 0x2028:    /* LINE SEPARATOR */
+      case 0x2029:    /* PARAGRAPH SEPARATOR */
+      RRETURN(MATCH_NOMATCH);
+      }
+    ecode++;
+    break;
+
+    case OP_VSPACE:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    switch(c)
+      {
+      default: RRETURN(MATCH_NOMATCH);
+      case 0x0a:      /* LF */
+      case 0x0b:      /* VT */
+      case 0x0c:      /* FF */
+      case 0x0d:      /* CR */
+      case 0x85:      /* NEL */
+      case 0x2028:    /* LINE SEPARATOR */
+      case 0x2029:    /* PARAGRAPH SEPARATOR */
+      break;
+      }
+    ecode++;
+    break;
+
 #ifdef SUPPORT_UCP
     /* Check the next character by Unicode property. We will get here only
     if the support is in the binary; otherwise a compile-time error occurs. */
@@ -2800,6 +2910,110 @@ for (;;)
           }
         break;
 
+        case OP_NOT_HSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          switch(c)
+            {
+            default: break;
+            case 0x09:      /* HT */
+            case 0x20:      /* SPACE */
+            case 0xa0:      /* NBSP */
+            case 0x1680:    /* OGHAM SPACE MARK */
+            case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+            case 0x2000:    /* EN QUAD */
+            case 0x2001:    /* EM QUAD */
+            case 0x2002:    /* EN SPACE */
+            case 0x2003:    /* EM SPACE */
+            case 0x2004:    /* THREE-PER-EM SPACE */
+            case 0x2005:    /* FOUR-PER-EM SPACE */
+            case 0x2006:    /* SIX-PER-EM SPACE */
+            case 0x2007:    /* FIGURE SPACE */
+            case 0x2008:    /* PUNCTUATION SPACE */
+            case 0x2009:    /* THIN SPACE */
+            case 0x200A:    /* HAIR SPACE */
+            case 0x202f:    /* NARROW NO-BREAK SPACE */
+            case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+            case 0x3000:    /* IDEOGRAPHIC SPACE */
+            RRETURN(MATCH_NOMATCH);
+            }
+          }
+        break;
+
+        case OP_HSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          switch(c)
+            {
+            default: RRETURN(MATCH_NOMATCH);
+            case 0x09:      /* HT */
+            case 0x20:      /* SPACE */
+            case 0xa0:      /* NBSP */
+            case 0x1680:    /* OGHAM SPACE MARK */
+            case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+            case 0x2000:    /* EN QUAD */
+            case 0x2001:    /* EM QUAD */
+            case 0x2002:    /* EN SPACE */
+            case 0x2003:    /* EM SPACE */
+            case 0x2004:    /* THREE-PER-EM SPACE */
+            case 0x2005:    /* FOUR-PER-EM SPACE */
+            case 0x2006:    /* SIX-PER-EM SPACE */
+            case 0x2007:    /* FIGURE SPACE */
+            case 0x2008:    /* PUNCTUATION SPACE */
+            case 0x2009:    /* THIN SPACE */
+            case 0x200A:    /* HAIR SPACE */
+            case 0x202f:    /* NARROW NO-BREAK SPACE */
+            case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+            case 0x3000:    /* IDEOGRAPHIC SPACE */
+            break;
+            }
+          }
+        break;
+
+        case OP_NOT_VSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          switch(c)
+            {
+            default: break;
+            case 0x0a:      /* LF */
+            case 0x0b:      /* VT */
+            case 0x0c:      /* FF */
+            case 0x0d:      /* CR */
+            case 0x85:      /* NEL */
+            case 0x2028:    /* LINE SEPARATOR */
+            case 0x2029:    /* PARAGRAPH SEPARATOR */
+            RRETURN(MATCH_NOMATCH);
+            }
+          }
+        break;
+
+        case OP_VSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          switch(c)
+            {
+            default: RRETURN(MATCH_NOMATCH);
+            case 0x0a:      /* LF */
+            case 0x0b:      /* VT */
+            case 0x0c:      /* FF */
+            case 0x0d:      /* CR */
+            case 0x85:      /* NEL */
+            case 0x2028:    /* LINE SEPARATOR */
+            case 0x2029:    /* PARAGRAPH SEPARATOR */
+            break;
+            }
+          }
+        break;
+
         case OP_NOT_DIGIT:
         for (i = 1; i <= min; i++)
           {
@@ -2911,6 +3125,70 @@ for (;;)
           }
         break;
 
+        case OP_NOT_HSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          switch(*eptr++)
+            {
+            default: break;
+            case 0x09:      /* HT */
+            case 0x20:      /* SPACE */
+            case 0xa0:      /* NBSP */
+            RRETURN(MATCH_NOMATCH);
+            }
+          }
+        break;
+
+        case OP_HSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          switch(*eptr++)
+            {
+            default: RRETURN(MATCH_NOMATCH);
+            case 0x09:      /* HT */
+            case 0x20:      /* SPACE */
+            case 0xa0:      /* NBSP */
+            break;
+            }
+          }
+        break;
+
+        case OP_NOT_VSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          switch(*eptr++)
+            {
+            default: break;
+            case 0x0a:      /* LF */
+            case 0x0b:      /* VT */
+            case 0x0c:      /* FF */
+            case 0x0d:      /* CR */
+            case 0x85:      /* NEL */
+            RRETURN(MATCH_NOMATCH);
+            }
+          }
+        break;
+
+        case OP_VSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          switch(*eptr++)
+            {
+            default: RRETURN(MATCH_NOMATCH);
+            case 0x0a:      /* LF */
+            case 0x0b:      /* VT */
+            case 0x0c:      /* FF */
+            case 0x0d:      /* CR */
+            case 0x85:      /* NEL */
+            break;
+            }
+          }
+        break;
+
         case OP_NOT_DIGIT:
         for (i = 1; i <= min; i++)
           if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
@@ -3102,6 +3380,90 @@ for (;;)
               }
             break;
 
+            case OP_NOT_HSPACE:
+            switch(c)
+              {
+              default: break;
+              case 0x09:      /* HT */
+              case 0x20:      /* SPACE */
+              case 0xa0:      /* NBSP */
+              case 0x1680:    /* OGHAM SPACE MARK */
+              case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+              case 0x2000:    /* EN QUAD */
+              case 0x2001:    /* EM QUAD */
+              case 0x2002:    /* EN SPACE */
+              case 0x2003:    /* EM SPACE */
+              case 0x2004:    /* THREE-PER-EM SPACE */
+              case 0x2005:    /* FOUR-PER-EM SPACE */
+              case 0x2006:    /* SIX-PER-EM SPACE */
+              case 0x2007:    /* FIGURE SPACE */
+              case 0x2008:    /* PUNCTUATION SPACE */
+              case 0x2009:    /* THIN SPACE */
+              case 0x200A:    /* HAIR SPACE */
+              case 0x202f:    /* NARROW NO-BREAK SPACE */
+              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+              case 0x3000:    /* IDEOGRAPHIC SPACE */
+              RRETURN(MATCH_NOMATCH);
+              }
+            break;
+
+            case OP_HSPACE:
+            switch(c)
+              {
+              default: RRETURN(MATCH_NOMATCH);
+              case 0x09:      /* HT */
+              case 0x20:      /* SPACE */
+              case 0xa0:      /* NBSP */
+              case 0x1680:    /* OGHAM SPACE MARK */
+              case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+              case 0x2000:    /* EN QUAD */
+              case 0x2001:    /* EM QUAD */
+              case 0x2002:    /* EN SPACE */
+              case 0x2003:    /* EM SPACE */
+              case 0x2004:    /* THREE-PER-EM SPACE */
+              case 0x2005:    /* FOUR-PER-EM SPACE */
+              case 0x2006:    /* SIX-PER-EM SPACE */
+              case 0x2007:    /* FIGURE SPACE */
+              case 0x2008:    /* PUNCTUATION SPACE */
+              case 0x2009:    /* THIN SPACE */
+              case 0x200A:    /* HAIR SPACE */
+              case 0x202f:    /* NARROW NO-BREAK SPACE */
+              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+              case 0x3000:    /* IDEOGRAPHIC SPACE */
+              break;
+              }
+            break;
+
+            case OP_NOT_VSPACE:
+            switch(c)
+              {
+              default: break;
+              case 0x0a:      /* LF */
+              case 0x0b:      /* VT */
+              case 0x0c:      /* FF */
+              case 0x0d:      /* CR */
+              case 0x85:      /* NEL */
+              case 0x2028:    /* LINE SEPARATOR */
+              case 0x2029:    /* PARAGRAPH SEPARATOR */
+              RRETURN(MATCH_NOMATCH);
+              }
+            break;
+
+            case OP_VSPACE:
+            switch(c)
+              {
+              default: RRETURN(MATCH_NOMATCH);
+              case 0x0a:      /* LF */
+              case 0x0b:      /* VT */
+              case 0x0c:      /* FF */
+              case 0x0d:      /* CR */
+              case 0x85:      /* NEL */
+              case 0x2028:    /* LINE SEPARATOR */
+              case 0x2029:    /* PARAGRAPH SEPARATOR */
+              break;
+              }
+            break;
+
             case OP_NOT_DIGIT:
             if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
               RRETURN(MATCH_NOMATCH);
@@ -3173,6 +3535,54 @@ for (;;)
               }
             break;
 
+            case OP_NOT_HSPACE:
+            switch(c)
+              {
+              default: break;
+              case 0x09:      /* HT */
+              case 0x20:      /* SPACE */
+              case 0xa0:      /* NBSP */
+              RRETURN(MATCH_NOMATCH);
+              }
+            break;
+
+            case OP_HSPACE:
+            switch(c)
+              {
+              default: RRETURN(MATCH_NOMATCH);
+              case 0x09:      /* HT */
+              case 0x20:      /* SPACE */
+              case 0xa0:      /* NBSP */
+              break;
+              }
+            break;
+
+            case OP_NOT_VSPACE:
+            switch(c)
+              {
+              default: break;
+              case 0x0a:      /* LF */
+              case 0x0b:      /* VT */
+              case 0x0c:      /* FF */
+              case 0x0d:      /* CR */
+              case 0x85:      /* NEL */
+              RRETURN(MATCH_NOMATCH);
+              }
+            break;
+
+            case OP_VSPACE:
+            switch(c)
+              {
+              default: RRETURN(MATCH_NOMATCH);
+              case 0x0a:      /* LF */
+              case 0x0b:      /* VT */
+              case 0x0c:      /* FF */
+              case 0x0d:      /* CR */
+              case 0x85:      /* NEL */
+              break;
+              }
+            break;
+
             case OP_NOT_DIGIT:
             if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
             break;
@@ -3434,6 +3844,70 @@ for (;;)
             }
           break;
 
+          case OP_NOT_HSPACE:
+          case OP_HSPACE:
+          for (i = min; i < max; i++)
+            {
+            BOOL gotspace;
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            switch(c)
+              {
+              default: gotspace = FALSE; break;
+              case 0x09:      /* HT */
+              case 0x20:      /* SPACE */
+              case 0xa0:      /* NBSP */
+              case 0x1680:    /* OGHAM SPACE MARK */
+              case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+              case 0x2000:    /* EN QUAD */
+              case 0x2001:    /* EM QUAD */
+              case 0x2002:    /* EN SPACE */
+              case 0x2003:    /* EM SPACE */
+              case 0x2004:    /* THREE-PER-EM SPACE */
+              case 0x2005:    /* FOUR-PER-EM SPACE */
+              case 0x2006:    /* SIX-PER-EM SPACE */
+              case 0x2007:    /* FIGURE SPACE */
+              case 0x2008:    /* PUNCTUATION SPACE */
+              case 0x2009:    /* THIN SPACE */
+              case 0x200A:    /* HAIR SPACE */
+              case 0x202f:    /* NARROW NO-BREAK SPACE */
+              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+              case 0x3000:    /* IDEOGRAPHIC SPACE */
+              gotspace = TRUE;
+              break;
+              }
+            if (gotspace == (ctype == OP_NOT_HSPACE)) break;
+            eptr += len;
+            }
+          break;
+
+          case OP_NOT_VSPACE:
+          case OP_VSPACE:
+          for (i = min; i < max; i++)
+            {
+            BOOL gotspace;
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            switch(c)
+              {
+              default: gotspace = FALSE; break;
+              case 0x0a:      /* LF */
+              case 0x0b:      /* VT */
+              case 0x0c:      /* FF */
+              case 0x0d:      /* CR */
+              case 0x85:      /* NEL */
+              case 0x2028:    /* LINE SEPARATOR */
+              case 0x2029:    /* PARAGRAPH SEPARATOR */
+              gotspace = TRUE;
+              break;
+              }
+            if (gotspace == (ctype == OP_NOT_VSPACE)) break;
+            eptr += len;
+            }
+          break;
+
           case OP_NOT_DIGIT:
           for (i = min; i < max; i++)
             {
@@ -3560,6 +4034,48 @@ for (;;)
             }
           break;
 
+          case OP_NOT_HSPACE:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject) break;
+            c = *eptr;
+            if (c == 0x09 || c == 0x20 || c == 0xa0) break;
+            eptr++;
+            }
+          break;
+
+          case OP_HSPACE:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject) break;
+            c = *eptr;
+            if (c != 0x09 && c != 0x20 && c != 0xa0) break;
+            eptr++;
+            }
+          break;
+
+          case OP_NOT_VSPACE:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject) break;
+            c = *eptr;
+            if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85)
+              break;
+            eptr++;
+            }
+          break;
+
+          case OP_VSPACE:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject) break;
+            c = *eptr;
+            if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85)
+              break;
+            eptr++;
+            }
+          break;
+
           case OP_NOT_DIGIT:
           for (i = min; i < max; i++)
             {
@@ -3684,6 +4200,7 @@ Undefine all the macros that were defined above to handle this. */
 #ifdef NO_RECURSE
 #undef eptr
 #undef ecode
+#undef mstart
 #undef offset_top
 #undef ims
 #undef eptrb
@@ -4163,10 +4680,11 @@ for(;;)
 
   /* OK, we can now run the match. */
 
-  md->start_match = start_match;
+  md->start_match_ptr = start_match;      /* Insurance */
   md->match_call_count = 0;
   md->eptrn = 0;                          /* Next free eptrchain slot */
-  rc = match(start_match, md->start_code, 2, md, ims, NULL, 0, 0);
+  rc = match(start_match, md->start_code, start_match, 2, md,
+    ims, NULL, 0, 0);
 
   /* Any return other than MATCH_NOMATCH breaks the loop. */
 
@@ -4246,11 +4764,13 @@ if (rc == MATCH_MATCH)
 
   rc = md->offset_overflow? 0 : md->end_offset_top/2;
 
-  /* If there is space, set up the whole thing as substring 0. */
+  /* If there is space, set up the whole thing as substring 0. The value of
+  md->start_match_ptr might be modified if \K was encountered on the success
+  matching path. */
 
   if (offsetcount < 2) rc = 0; else
     {
-    offsets[0] = start_match - md->start_subject;
+    offsets[0] = md->start_match_ptr - md->start_subject;
     offsets[1] = md->end_match_ptr - md->start_subject;
     }
 
index 8c0e54d41619ac8008bbfe42c54fc07a635dabb6..797eddecf2dcde2ccb0a2dd65e5f65386304827d 100644 (file)
@@ -140,6 +140,14 @@ switch (what)
   *((const uschar **)where) = (const uschar *)(_pcre_default_tables);
   break;
 
+  case PCRE_INFO_OKPARTIAL:
+  *((int *)where) = (re->options & PCRE_NOPARTIAL) == 0;
+  break;
+
+  case PCRE_INFO_JCHANGED:
+  *((int *)where) = (re->options & PCRE_JCHANGED) != 0;
+  break;
+
   default: return PCRE_ERROR_BADOPTION;
   }
 
index 7ce6079b046d58d5bd6639dec27a384e39bd3975..d87b95cb27966716dd6d5f6c9320cb30712091fb 100644 (file)
@@ -605,9 +605,9 @@ ESC_Z to detect the types that may be repeated. These are the types that
 consume characters. If any new escapes are put in between that don't consume a
 character, that code will have to change. */
 
-enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,
-       ESC_w, ESC_dum1, ESC_C, ESC_P, ESC_p, ESC_R, ESC_X, ESC_Z, ESC_z,
-       ESC_E, ESC_Q, ESC_k, ESC_REF };
+enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
+       ESC_W, ESC_w, ESC_dum1, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H, ESC_h,
+       ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_k, ESC_REF };
 
 
 /* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
@@ -629,133 +629,138 @@ enum {
 
   OP_SOD,            /* 1 Start of data: \A */
   OP_SOM,            /* 2 Start of match (subject + offset): \G */
-  OP_NOT_WORD_BOUNDARY,  /*  3 \B */
-  OP_WORD_BOUNDARY,      /*  4 \b */
-  OP_NOT_DIGIT,          /*  5 \D */
-  OP_DIGIT,              /*  6 \d */
-  OP_NOT_WHITESPACE,     /*  7 \S */
-  OP_WHITESPACE,         /*  8 \s */
-  OP_NOT_WORDCHAR,       /*  9 \W */
-  OP_WORDCHAR,           /* 10 \w */
-  OP_ANY,            /* 11 Match any character */
-  OP_ANYBYTE,        /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */
-  OP_NOTPROP,        /* 13 \P (not Unicode property) */
-  OP_PROP,           /* 14 \p (Unicode property) */
-  OP_ANYNL,          /* 15 \R (any newline sequence) */
-  OP_EXTUNI,         /* 16 \X (extended Unicode sequence */
-  OP_EODN,           /* 17 End of data or \n at end of data: \Z. */
-  OP_EOD,            /* 18 End of data: \z */
-
-  OP_OPT,            /* 19 Set runtime options */
-  OP_CIRC,           /* 20 Start of line - varies with multiline switch */
-  OP_DOLL,           /* 21 End of line - varies with multiline switch */
-  OP_CHAR,           /* 22 Match one character, casefully */
-  OP_CHARNC,         /* 23 Match one character, caselessly */
-  OP_NOT,            /* 24 Match one character, not the following one */
-
-  OP_STAR,           /* 25 The maximizing and minimizing versions of */
-  OP_MINSTAR,        /* 26 these six opcodes must come in pairs, with */
-  OP_PLUS,           /* 27 the minimizing one second. */
-  OP_MINPLUS,        /* 28 This first set applies to single characters.*/
-  OP_QUERY,          /* 29 */
-  OP_MINQUERY,       /* 30 */
-
-  OP_UPTO,           /* 31 From 0 to n matches */
-  OP_MINUPTO,        /* 32 */
-  OP_EXACT,          /* 33 Exactly n matches */
-
-  OP_POSSTAR,        /* 34 Possessified star */
-  OP_POSPLUS,        /* 35 Possessified plus */
-  OP_POSQUERY,       /* 36 Posesssified query */
-  OP_POSUPTO,        /* 37 Possessified upto */
-
-  OP_NOTSTAR,        /* 38 The maximizing and minimizing versions of */
-  OP_NOTMINSTAR,     /* 39 these six opcodes must come in pairs, with */
-  OP_NOTPLUS,        /* 40 the minimizing one second. They must be in */
-  OP_NOTMINPLUS,     /* 41 exactly the same order as those above. */
-  OP_NOTQUERY,       /* 42 This set applies to "not" single characters. */
-  OP_NOTMINQUERY,    /* 43 */
-
-  OP_NOTUPTO,        /* 44 From 0 to n matches */
-  OP_NOTMINUPTO,     /* 45 */
-  OP_NOTEXACT,       /* 46 Exactly n matches */
-
-  OP_NOTPOSSTAR,     /* 47 Possessified versions */
-  OP_NOTPOSPLUS,     /* 48 */
-  OP_NOTPOSQUERY,    /* 49 */
-  OP_NOTPOSUPTO,     /* 50 */
-
-  OP_TYPESTAR,       /* 51 The maximizing and minimizing versions of */
-  OP_TYPEMINSTAR,    /* 52 these six opcodes must come in pairs, with */
-  OP_TYPEPLUS,       /* 53 the minimizing one second. These codes must */
-  OP_TYPEMINPLUS,    /* 54 be in exactly the same order as those above. */
-  OP_TYPEQUERY,      /* 55 This set applies to character types such as \d */
-  OP_TYPEMINQUERY,   /* 56 */
-
-  OP_TYPEUPTO,       /* 57 From 0 to n matches */
-  OP_TYPEMINUPTO,    /* 58 */
-  OP_TYPEEXACT,      /* 59 Exactly n matches */
-
-  OP_TYPEPOSSTAR,    /* 60 Possessified versions */
-  OP_TYPEPOSPLUS,    /* 61 */
-  OP_TYPEPOSQUERY,   /* 62 */
-  OP_TYPEPOSUPTO,    /* 63 */
-
-  OP_CRSTAR,         /* 64 The maximizing and minimizing versions of */
-  OP_CRMINSTAR,      /* 65 all these opcodes must come in pairs, with */
-  OP_CRPLUS,         /* 66 the minimizing one second. These codes must */
-  OP_CRMINPLUS,      /* 67 be in exactly the same order as those above. */
-  OP_CRQUERY,        /* 68 These are for character classes and back refs */
-  OP_CRMINQUERY,     /* 69 */
-  OP_CRRANGE,        /* 70 These are different to the three sets above. */
-  OP_CRMINRANGE,     /* 71 */
-
-  OP_CLASS,          /* 72 Match a character class, chars < 256 only */
-  OP_NCLASS,         /* 73 Same, but the bitmap was created from a negative
+  OP_SET_SOM,        /* 3 Set start of match (\K) */
+  OP_NOT_WORD_BOUNDARY,  /*  4 \B */
+  OP_WORD_BOUNDARY,      /*  5 \b */
+  OP_NOT_DIGIT,          /*  6 \D */
+  OP_DIGIT,              /*  7 \d */
+  OP_NOT_WHITESPACE,     /*  8 \S */
+  OP_WHITESPACE,         /*  9 \s */
+  OP_NOT_WORDCHAR,       /* 10 \W */
+  OP_WORDCHAR,           /* 11 \w */
+  OP_ANY,            /* 12 Match any character */
+  OP_ANYBYTE,        /* 13 Match any byte (\C); different to OP_ANY for UTF-8 */
+  OP_NOTPROP,        /* 14 \P (not Unicode property) */
+  OP_PROP,           /* 15 \p (Unicode property) */
+  OP_ANYNL,          /* 16 \R (any newline sequence) */
+  OP_NOT_HSPACE,     /* 17 \H (not horizontal whitespace) */
+  OP_HSPACE,         /* 18 \h (horizontal whitespace) */
+  OP_NOT_VSPACE,     /* 19 \V (not vertical whitespace) */
+  OP_VSPACE,         /* 20 \v (vertical whitespace) */
+  OP_EXTUNI,         /* 21 \X (extended Unicode sequence */
+  OP_EODN,           /* 22 End of data or \n at end of data: \Z. */
+  OP_EOD,            /* 23 End of data: \z */
+
+  OP_OPT,            /* 24 Set runtime options */
+  OP_CIRC,           /* 25 Start of line - varies with multiline switch */
+  OP_DOLL,           /* 26 End of line - varies with multiline switch */
+  OP_CHAR,           /* 27 Match one character, casefully */
+  OP_CHARNC,         /* 28 Match one character, caselessly */
+  OP_NOT,            /* 29 Match one character, not the following one */
+
+  OP_STAR,           /* 30 The maximizing and minimizing versions of */
+  OP_MINSTAR,        /* 31 these six opcodes must come in pairs, with */
+  OP_PLUS,           /* 32 the minimizing one second. */
+  OP_MINPLUS,        /* 33 This first set applies to single characters.*/
+  OP_QUERY,          /* 34 */
+  OP_MINQUERY,       /* 35 */
+
+  OP_UPTO,           /* 36 From 0 to n matches */
+  OP_MINUPTO,        /* 37 */
+  OP_EXACT,          /* 38 Exactly n matches */
+
+  OP_POSSTAR,        /* 39 Possessified star */
+  OP_POSPLUS,        /* 40 Possessified plus */
+  OP_POSQUERY,       /* 41 Posesssified query */
+  OP_POSUPTO,        /* 42 Possessified upto */
+
+  OP_NOTSTAR,        /* 43 The maximizing and minimizing versions of */
+  OP_NOTMINSTAR,     /* 44 these six opcodes must come in pairs, with */
+  OP_NOTPLUS,        /* 45 the minimizing one second. They must be in */
+  OP_NOTMINPLUS,     /* 46 exactly the same order as those above. */
+  OP_NOTQUERY,       /* 47 This set applies to "not" single characters. */
+  OP_NOTMINQUERY,    /* 48 */
+
+  OP_NOTUPTO,        /* 49 From 0 to n matches */
+  OP_NOTMINUPTO,     /* 50 */
+  OP_NOTEXACT,       /* 51 Exactly n matches */
+
+  OP_NOTPOSSTAR,     /* 52 Possessified versions */
+  OP_NOTPOSPLUS,     /* 53 */
+  OP_NOTPOSQUERY,    /* 54 */
+  OP_NOTPOSUPTO,     /* 55 */
+
+  OP_TYPESTAR,       /* 56 The maximizing and minimizing versions of */
+  OP_TYPEMINSTAR,    /* 57 these six opcodes must come in pairs, with */
+  OP_TYPEPLUS,       /* 58 the minimizing one second. These codes must */
+  OP_TYPEMINPLUS,    /* 59 be in exactly the same order as those above. */
+  OP_TYPEQUERY,      /* 60 This set applies to character types such as \d */
+  OP_TYPEMINQUERY,   /* 61 */
+
+  OP_TYPEUPTO,       /* 62 From 0 to n matches */
+  OP_TYPEMINUPTO,    /* 63 */
+  OP_TYPEEXACT,      /* 64 Exactly n matches */
+
+  OP_TYPEPOSSTAR,    /* 65 Possessified versions */
+  OP_TYPEPOSPLUS,    /* 66 */
+  OP_TYPEPOSQUERY,   /* 67 */
+  OP_TYPEPOSUPTO,    /* 68 */
+
+  OP_CRSTAR,         /* 69 The maximizing and minimizing versions of */
+  OP_CRMINSTAR,      /* 70 all these opcodes must come in pairs, with */
+  OP_CRPLUS,         /* 71 the minimizing one second. These codes must */
+  OP_CRMINPLUS,      /* 72 be in exactly the same order as those above. */
+  OP_CRQUERY,        /* 73 These are for character classes and back refs */
+  OP_CRMINQUERY,     /* 74 */
+  OP_CRRANGE,        /* 75 These are different to the three sets above. */
+  OP_CRMINRANGE,     /* 76 */
+
+  OP_CLASS,          /* 77 Match a character class, chars < 256 only */
+  OP_NCLASS,         /* 78 Same, but the bitmap was created from a negative
                            class - the difference is relevant only when a UTF-8
                            character > 255 is encountered. */
 
-  OP_XCLASS,         /* 74 Extended class for handling UTF-8 chars within the
+  OP_XCLASS,         /* 79 Extended class for handling UTF-8 chars within the
                            class. This does both positive and negative. */
 
-  OP_REF,            /* 75 Match a back reference */
-  OP_RECURSE,        /* 76 Match a numbered subpattern (possibly recursive) */
-  OP_CALLOUT,        /* 77 Call out to external function if provided */
+  OP_REF,            /* 80 Match a back reference */
+  OP_RECURSE,        /* 81 Match a numbered subpattern (possibly recursive) */
+  OP_CALLOUT,        /* 82 Call out to external function if provided */
 
-  OP_ALT,            /* 78 Start of alternation */
-  OP_KET,            /* 79 End of group that doesn't have an unbounded repeat */
-  OP_KETRMAX,        /* 80 These two must remain together and in this */
-  OP_KETRMIN,        /* 81 order. They are for groups the repeat for ever. */
+  OP_ALT,            /* 83 Start of alternation */
+  OP_KET,            /* 84 End of group that doesn't have an unbounded repeat */
+  OP_KETRMAX,        /* 85 These two must remain together and in this */
+  OP_KETRMIN,        /* 86 order. They are for groups the repeat for ever. */
 
   /* The assertions must come before BRA, CBRA, ONCE, and COND.*/
 
-  OP_ASSERT,         /* 82 Positive lookahead */
-  OP_ASSERT_NOT,     /* 83 Negative lookahead */
-  OP_ASSERTBACK,     /* 84 Positive lookbehind */
-  OP_ASSERTBACK_NOT, /* 85 Negative lookbehind */
-  OP_REVERSE,        /* 86 Move pointer back - used in lookbehind assertions */
+  OP_ASSERT,         /* 87 Positive lookahead */
+  OP_ASSERT_NOT,     /* 88 Negative lookahead */
+  OP_ASSERTBACK,     /* 89 Positive lookbehind */
+  OP_ASSERTBACK_NOT, /* 90 Negative lookbehind */
+  OP_REVERSE,        /* 91 Move pointer back - used in lookbehind assertions */
 
   /* ONCE, BRA, CBRA, and COND must come after the assertions, with ONCE first,
   as there's a test for >= ONCE for a subpattern that isn't an assertion. */
 
-  OP_ONCE,           /* 87 Atomic group */
-  OP_BRA,            /* 88 Start of non-capturing bracket */
-  OP_CBRA,           /* 89 Start of capturing bracket */
-  OP_COND,           /* 90 Conditional group */
+  OP_ONCE,           /* 92 Atomic group */
+  OP_BRA,            /* 83 Start of non-capturing bracket */
+  OP_CBRA,           /* 94 Start of capturing bracket */
+  OP_COND,           /* 95 Conditional group */
 
   /* These three must follow the previous three, in the same order. There's a
   check for >= SBRA to distinguish the two sets. */
 
-  OP_SBRA,           /* 91 Start of non-capturing bracket, check empty  */
-  OP_SCBRA,          /* 92 Start of capturing bracket, check empty */
-  OP_SCOND,          /* 93 Conditional group, check empty */
+  OP_SBRA,           /* 96 Start of non-capturing bracket, check empty  */
+  OP_SCBRA,          /* 97 Start of capturing bracket, check empty */
+  OP_SCOND,          /* 98 Conditional group, check empty */
 
-  OP_CREF,           /* 94 Used to hold a capture number as condition */
-  OP_RREF,           /* 95 Used to hold a recursion number as condition */
-  OP_DEF,            /* 96 The DEFINE condition */
+  OP_CREF,           /* 99 Used to hold a capture number as condition */
+  OP_RREF,           /* 100 Used to hold a recursion number as condition */
+  OP_DEF,            /* 101 The DEFINE condition */
 
-  OP_BRAZERO,        /* 97 These two must remain together and in this */
-  OP_BRAMINZERO      /* 98 order. */
+  OP_BRAZERO,        /* 102 These two must remain together and in this */
+  OP_BRAMINZERO      /* 103 order. */
 };
 
 
@@ -763,10 +768,10 @@ enum {
 for debugging. The macro is referenced only in pcre_printint.c. */
 
 #define OP_NAME_LIST \
-  "End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d",                \
+  "End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d",         \
   "\\S", "\\s", "\\W", "\\w", "Any", "Anybyte",                   \
-  "notprop", "prop", "anynl", "extuni",                           \
-  "\\Z", "\\z",                                                   \
+  "notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v",           \
+  "extuni",  "\\Z", "\\z",                                        \
   "Opt", "^", "$", "char", "charnc", "not",                       \
   "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
   "*+","++", "?+", "{",                                           \
@@ -793,9 +798,11 @@ in UTF-8 mode. The code that uses this table must know about such things. */
 
 #define OP_LENGTHS \
   1,                             /* End                                    */ \
-  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* \A, \G, \B, \B, \D, \d, \S, \s, \W, \w */ \
+  1, 1, 1, 1, 1,                 /* \A, \G, \K, \B, \b                     */ \
+  1, 1, 1, 1, 1, 1,              /* \D, \d, \S, \s, \W, \w                 */ \
   1, 1,                          /* Any, Anybyte                           */ \
-  3, 3, 1, 1,                    /* NOTPROP, PROP, EXTUNI, ANYNL           */ \
+  3, 3, 1,                       /* NOTPROP, PROP, EXTUNI                  */ \
+  1, 1, 1, 1, 1,                 /* \R, \H, \h, \V, \v                     */ \
   1, 1, 2, 1, 1,                 /* \Z, \z, Opt, ^, $                      */ \
   2,                             /* Char  - the minimum length             */ \
   2,                             /* Charnc  - the minimum length           */ \
@@ -855,7 +862,7 @@ enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4,  ERR5,  ERR6,  ERR7,  ERR8,  ERR9,
        ERR20, ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29,
        ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,
        ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
-       ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57 };
+       ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58 };
 
 /* The real format of the start of the pcre block; the index of names and the
 code vector run on as long as necessary after the end. We store an explicit
@@ -944,7 +951,7 @@ typedef struct recursion_info {
   struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
   int group_num;                /* Number of group that was called */
   const uschar *after_call;     /* "Return value": points after the call in the expr */
-  USPTR save_start;             /* Old value of md->start_match */
+  USPTR save_start;             /* Old value of mstart */
   int *offset_save;             /* Pointer to start of saved offsets */
   int saved_max;                /* Number of saved offsets */
 } recursion_info;
@@ -985,7 +992,7 @@ typedef struct match_data {
   const uschar *start_code;     /* For use when recursing */
   USPTR  start_subject;         /* Start of the subject string */
   USPTR  end_subject;           /* End of the subject string */
-  USPTR  start_match;           /* Start of this match attempt */
+  USPTR  start_match_ptr;       /* Start of matched string */
   USPTR  end_match_ptr;         /* Subject position at end match */
   int    end_offset_top;        /* Highwater mark at end of match */
   int    capture_last;          /* Most recent capture number */
index 267034680158297246c384e896e3e610b23166a2..8582fba0976ba4d012a78fd5c13c61093b32a2bf 100644 (file)
@@ -80,7 +80,7 @@ static const int eint[] = {
   REG_BADPAT,  /* malformed number or name after (?( */
   REG_BADPAT,  /* conditional group contains more than two branches */
   REG_BADPAT,  /* assertion expected after (?( */
-  REG_BADPAT,  /* (?R or (?digits must be followed by ) */
+  REG_BADPAT,  /* (?R or (?[+-]digits must be followed by ) */
   REG_ECTYPE,  /* unknown POSIX class name */
   REG_BADPAT,  /* POSIX collating elements are not supported */
   REG_INVARG,  /* this version of PCRE is not compiled with PCRE_UTF8 support */
@@ -108,7 +108,8 @@ static const int eint[] = {
   REG_BADPAT,  /* DEFINE group contains more than one branch */
   REG_BADPAT,  /* repeating a DEFINE group is not allowed */
   REG_INVARG,  /* inconsistent NEWLINE options */
-  REG_BADPAT   /* \g is not followed followed by an (optionally braced) non-zero number */
+  REG_BADPAT,  /* \g is not followed followed by an (optionally braced) non-zero number */
+  REG_BADPAT   /* (?+ or (?- must be followed by a non-zero number */
 };
 
 /* Table of texts corresponding to POSIX error codes */
index d8ef12bc429b7f2294b8488afa5ad88a4d991cdc..7e8e9f0c4d6d881c0a7d52e7e035509d9651ac7a 100644 (file)
 /(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
     abcdefghijk\12S
 
-/ab\hdef/
-    abhdef
+/ab\idef/
+    abidef
 
 /a{0}bc/
     bc
   abc
   abc\n  
 
+/(.*(.)?)*/
+    abcd
+
 / End of testinput1 /
index 280684650b7480ce0aa1360ab40401a0f853569f..2ce7ad0321e0ab3467e8a3f73fb34e4f98156516 100644 (file)
@@ -28,9 +28,9 @@
     *** Failers
     def\nabc
 
-/ab\hdef/X
+/ab\idef/X
 
-/(?X)ab\hdef/X
+/(?X)ab\idef/X
 
 /x{5,4}/
 
@@ -2156,4 +2156,174 @@ a random value. /Ix
     ** Failers 
     XABC\B
 
+/(ab|c)(?-1)/BZ
+    abc
+
+/xy(?+1)(abc)/BZ
+    xyabcabc
+    ** Failers
+    xyabc  
+    
+/x(?-0)y/
+
+/x(?-1)y/
+
+/x(?+0)y/ 
+
+/x(?+1)y/
+
+/^(abc)?(?(-1)X|Y)/BZ
+    abcX
+    Y
+    ** Failers
+    abcY   
+    
+/^((?(+1)X|Y)(abc))+/BZ 
+    YabcXabc
+    YabcXabcXabc
+    ** Failers
+    XabcXabc  
+
+/(?(-1)a)/BZ
+
+/((?(-1)a))/BZ
+
+/((?(-2)a))/BZ
+
+/^(?(+1)X|Y)/BZ
+    Y
+
+/(foo)\Kbar/
+    foobar
+   
+/(foo)(\Kbar|baz)/
+    foobar
+    foobaz 
+
+/(foo\Kbar)baz/
+    foobarbaz
+
+/(?<A>tom|bon)-\k{A}/
+    tom-tom
+    bon-bon 
+    ** Failers
+    tom-bon  
+
+/(?<A>tom|bon)-\g{A}/
+    tom-tom
+    bon-bon 
+    
+/\g{A/ 
+
+/(?|(abc)|(xyz))/BZ
+   >abc<
+   >xyz< 
+
+/(x)(?|(abc)|(xyz))(x)/BZ
+    xabcx
+    xxyzx 
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/BZ
+    xabcpqrx
+    xxyzx 
+
+/(?|(abc)|(xyz))\1/
+    abcabc
+    xyzxyz 
+    ** Failers
+    abcxyz
+    xyzabc   
+    
+/(?|(abc)|(xyz))(?1)/
+    abcabc
+    xyzabc 
+    ** Failers 
+    xyzxyz 
+/\H\h\V\v/
+    X X\x0a
+    X\x09X\x0b
+    ** Failers
+    \xa0 X\x0a   
+    
+/\H*\h+\V?\v{3,4}/ 
+    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\xa0\x0a\x0b\x0c
+    ** Failers 
+    \x09\x20\xa0\x0a\x0b
+     
+/\H{3,4}/
+    XY  ABCDE
+    XY  PQR ST 
+    
+/.\h{3,4}./
+    XY  AB    PQRS
+
+/\h*X\h?\H+Y\H?Z/
+    >XNNNYZ
+    >  X NYQZ
+    ** Failers
+    >XYZ   
+    >  X NY Z
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+    >XY\x0aZ\x0aA\x0bNN\x0c
+    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
+/[\h]/BZ
+    >\x09<
+
+/[\h]+/BZ
+    >\x09\x20\xa0<
+
+/[\v]/BZ
+
+/[\H]/BZ
+
+/[^\h]/BZ
+
+/[\V]/BZ
+
+/[\x0a\V]/BZ
+
+/\H++X/BZ
+    ** Failers
+    XXXX
+    
+/\H+\hY/BZ
+    XXXX Y 
+
+/\H+ Y/BZ
+
+/\h+A/BZ
+
+/\v*B/BZ
+
+/\V+\x0a/BZ
+
+/A+\h/BZ
+
+/ *\H/BZ
+
+/A*\v/BZ
+
+/\x0b*\V/BZ
+
+/\d+\h/BZ
+
+/\d*\v/BZ
+
+/S+\h\S+\v/BZ
+
+/\w{3,}\h\w+\v/BZ
+
+/\h+\d\h+\w\h+\S\h+\H/BZ
+
+/\v+\d\v+\w\v+\S\v+\V/BZ
+
+/\H+\h\H+\d/BZ
+
+/\V+\v\V+\w/BZ
+
 / End of testinput2 /
index c99bee7c5f403ef8e28ef0ea44e8218fd8ed3152..e8e3cf799f18d4dfa378d5c1811390c212c25b18 100644 (file)
@@ -355,4 +355,42 @@ can't tell the difference.) --/
     a\n\n\n\rb
     a\r
 
+/\H\h\V\v/8
+    X X\x0a
+    X\x09X\x0b
+    ** Failers
+    \x{a0} X\x0a   
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\x{a0}\x0a\x0b\x0c
+    ** Failers 
+    \x09\x20\x{a0}\x0a\x0b
+     
+/\H\h\V\v/8
+    \x{3001}\x{3000}\x{2030}\x{2028}
+    X\x{180e}X\x{85}
+    ** Failers
+    \x{2009} X\x0a   
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+    \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+    \x09\x20\x{202f}\x0a\x0b\x0c
+    ** Failers 
+    \x09\x{200a}\x{a0}\x{2028}\x0b
+     
+/[\h]/8BZ
+    >\x{1680}
+
+/[\h]{3,}/8BZ
+    >\x{1680}\x{180e}\x{2000}\x{2003}\x{200a}\x{202f}\x{205f}\x{3000}<
+
+/[\v]/8BZ
+
+/[\H]/8BZ
+
+/[\V]/8BZ
+
 / End of testinput5 /
index 5c2dd6f6da0833ea6c631eff6e07b286c23ac981..2722980ad6144178c693ca9f564ae4d571da3550 100644 (file)
 /(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
     abcdefghijk\12S
 
-/ab\hdef/
-    abhdef
+/ab\idef/
+    abidef
 
 /a{0}bc/
     bc
 /(?m)$/<any>g+ 
     abc\r\n\r\n
 
+/(?|(abc)|(xyz))/
+   >abc<
+   >xyz< 
+
+/(x)(?|(abc)|(xyz))(x)/
+    xabcx
+    xxyzx 
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/
+    xabcpqrx
+    xxyzx 
+
+/(?|(abc)|(xyz))(?1)/
+    abcabc
+    xyzabc 
+    ** Failers 
+    xyzxyz 
+/\H\h\V\v/
+    X X\x0a
+    X\x09X\x0b
+    ** Failers
+    \xa0 X\x0a   
+    
+/\H*\h+\V?\v{3,4}/ 
+    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\xa0\x0a\x0b\x0c
+    ** Failers 
+    \x09\x20\xa0\x0a\x0b
+     
+/\H{3,4}/
+    XY  ABCDE
+    XY  PQR ST 
+    
+/.\h{3,4}./
+    XY  AB    PQRS
+
+/\h*X\h?\H+Y\H?Z/
+    >XNNNYZ
+    >  X NYQZ
+    ** Failers
+    >XYZ   
+    >  X NY Z
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+    >XY\x0aZ\x0aA\x0bNN\x0c
+    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
 / End of testinput7 /
index a19493fe63b87c0fc6ba2547ca33ffc505891924..61e70e55ac32e13f440fb181e4ee4ec0de58ca30 100644 (file)
     a\n\n\n\rb
     a\r
 
+/\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+
+/\V?\v{3,4}/8 
+    \x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+
+/\h+\V?\v{3,4}/8
+    >\x09\x20\x{a0}X\x0a\x0a\x0a<
+
+/\V?\v{3,4}/8
+    >\x09\x20\x{a0}X\x0a\x0a\x0a<
+
+/\H\h\V\v/8
+    X X\x0a
+    X\x09X\x0b
+    ** Failers
+    \x{a0} X\x0a   
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\x{a0}\x0a\x0b\x0c
+    ** Failers 
+    \x09\x20\x{a0}\x0a\x0b
+     
+/\H\h\V\v/8
+    \x{3001}\x{3000}\x{2030}\x{2028}
+    X\x{180e}X\x{85}
+    ** Failers
+    \x{2009} X\x0a   
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+    \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+    \x09\x20\x{202f}\x0a\x0b\x0c
+    ** Failers 
+    \x09\x{200a}\x{a0}\x{2028}\x0b
+     
 / End of testinput 8 / 
index b513dca417b22777e54cf3aaa091a21fc0cb8195..209b0d3f4c866e369178852bdadbc4f2f55babc0 100644 (file)
@@ -2189,9 +2189,9 @@ No match
 10: j
 11: k
 
-/ab\hdef/
-    abhdef
- 0: abhdef
+/ab\idef/
+    abidef
+ 0: abidef
 
 /a{0}bc/
     bc
@@ -6571,4 +6571,9 @@ No match
   abc\n  
 No match
 
+/(.*(.)?)*/
+    abcd
+ 0: abcd
+ 1: 
+
 / End of testinput1 /
index 8684dd77a3c7cfad318d6807c89a9e2752aa0c5e..cd8f82eb10cc71ed57c09bfc1504a54896ecf78e 100644 (file)
@@ -78,10 +78,10 @@ No match
     def\nabc
 No match
 
-/ab\hdef/X
+/ab\idef/X
 Failed: unrecognized character follows \ at offset 3
 
-/(?X)ab\hdef/X
+/(?X)ab\idef/X
 Failed: unrecognized character follows \ at offset 7
 
 /x{5,4}/
@@ -6193,6 +6193,7 @@ Named capturing subpatterns:
   B   3
   C   4
 Options: anchored
+Duplicate name status changes
 No first char
 No need char
     a bc d\CA\CB\CC
@@ -8066,16 +8067,16 @@ No match
 Failed: reference to non-existent subpattern at offset 4
 
 /^(a)\g/
-Failed: \g is not followed by an (optionally braced) non-zero number at offset 4
+Failed: \g is not followed by a braced name or an optionally braced non-zero number at offset 4
 
 /^(a)\g{0}/
-Failed: \g is not followed by an (optionally braced) non-zero number at offset 4
+Failed: \g is not followed by a braced name or an optionally braced non-zero number at offset 4
 
 /^(a)\g{3/
-Failed: \g is not followed by an (optionally braced) non-zero number at offset 4
+Failed: \g is not followed by a braced name or an optionally braced non-zero number at offset 4
 
 /^(a)\g{4a}/
-Failed: \g is not followed by an (optionally braced) non-zero number at offset 4
+Failed: reference to non-existent subpattern at offset 9
 
 /^a.b/<lf>
     a\rb
@@ -8169,4 +8170,608 @@ No match
     XABC\B
 No match
 
+/(ab|c)(?-1)/BZ
+------------------------------------------------------------------
+        Bra 0
+        Bra 1
+        ab
+        Alt
+        c
+        Ket
+        Once
+        Recurse
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    abc
+ 0: abc
+ 1: ab
+
+/xy(?+1)(abc)/BZ
+------------------------------------------------------------------
+        Bra 0
+        xy
+        Once
+        Recurse
+        Ket
+        Bra 1
+        abc
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    xyabcabc
+ 0: xyabcabc
+ 1: abc
+    ** Failers
+No match
+    xyabc  
+No match
+    
+/x(?-0)y/
+Failed: (?+ or (?- or (?(+ or (?(- must be followed by a non-zero number at offset 5
+
+/x(?-1)y/
+Failed: reference to non-existent subpattern at offset 5
+
+/x(?+0)y/ 
+Failed: (?+ or (?- or (?(+ or (?(- must be followed by a non-zero number at offset 5
+
+/x(?+1)y/
+Failed: reference to non-existent subpattern at offset 5
+
+/^(abc)?(?(-1)X|Y)/BZ
+------------------------------------------------------------------
+        Bra 0
+        ^
+        Brazero
+        Bra 1
+        abc
+        Ket
+        Cond
+      1 Cond ref
+        X
+        Alt
+        Y
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    abcX
+ 0: abcX
+ 1: abc
+    Y
+ 0: Y
+    ** Failers
+No match
+    abcY   
+No match
+    
+/^((?(+1)X|Y)(abc))+/BZ 
+------------------------------------------------------------------
+        Bra 0
+        ^
+        Bra 1
+        Cond
+      2 Cond ref
+        X
+        Alt
+        Y
+        Ket
+        Bra 2
+        abc
+        Ket
+        KetRmax
+        Ket
+        End
+------------------------------------------------------------------
+    YabcXabc
+ 0: YabcXabc
+ 1: Xabc
+ 2: abc
+    YabcXabcXabc
+ 0: YabcXabcXabc
+ 1: Xabc
+ 2: abc
+    ** Failers
+No match
+    XabcXabc  
+No match
+
+/(?(-1)a)/BZ
+Failed: reference to non-existent subpattern at offset 6
+
+/((?(-1)a))/BZ
+------------------------------------------------------------------
+        Bra 0
+        Bra 1
+        Cond
+      1 Cond ref
+        a
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
+/((?(-2)a))/BZ
+Failed: reference to non-existent subpattern at offset 7
+
+/^(?(+1)X|Y)/BZ
+------------------------------------------------------------------
+        Bra 0
+        ^
+        Cond
+      1 Cond ref
+        X
+        Alt
+        Y
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    Y
+ 0: Y
+
+/(foo)\Kbar/
+    foobar
+ 0: bar
+ 1: foo
+   
+/(foo)(\Kbar|baz)/
+    foobar
+ 0: bar
+ 1: foo
+ 2: bar
+    foobaz 
+ 0: foobaz
+ 1: foo
+ 2: baz
+
+/(foo\Kbar)baz/
+    foobarbaz
+ 0: barbaz
+ 1: foobar
+
+/(?<A>tom|bon)-\k{A}/
+    tom-tom
+ 0: tom-tom
+ 1: tom
+    bon-bon 
+ 0: bon-bon
+ 1: bon
+    ** Failers
+No match
+    tom-bon  
+No match
+
+/(?<A>tom|bon)-\g{A}/
+    tom-tom
+ 0: tom-tom
+ 1: tom
+    bon-bon 
+ 0: bon-bon
+ 1: bon
+    
+/\g{A/ 
+Failed: syntax error in subpattern name (missing terminator) at offset 4
+
+/(?|(abc)|(xyz))/BZ
+------------------------------------------------------------------
+        Bra 0
+        Bra 0
+        Bra 1
+        abc
+        Ket
+        Alt
+        Bra 1
+        xyz
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+   >abc<
+ 0: abc
+ 1: abc
+   >xyz< 
+ 0: xyz
+ 1: xyz
+
+/(x)(?|(abc)|(xyz))(x)/BZ
+------------------------------------------------------------------
+        Bra 0
+        Bra 1
+        x
+        Ket
+        Bra 0
+        Bra 2
+        abc
+        Ket
+        Alt
+        Bra 2
+        xyz
+        Ket
+        Ket
+        Bra 3
+        x
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    xabcx
+ 0: xabcx
+ 1: x
+ 2: abc
+ 3: x
+    xxyzx 
+ 0: xxyzx
+ 1: x
+ 2: xyz
+ 3: x
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/BZ
+------------------------------------------------------------------
+        Bra 0
+        Bra 1
+        x
+        Ket
+        Bra 0
+        Bra 2
+        abc
+        Ket
+        Bra 3
+        pqr
+        Ket
+        Alt
+        Bra 2
+        xyz
+        Ket
+        Ket
+        Bra 4
+        x
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    xabcpqrx
+ 0: xabcpqrx
+ 1: x
+ 2: abc
+ 3: pqr
+ 4: x
+    xxyzx 
+ 0: xxyzx
+ 1: x
+ 2: xyz
+ 3: <unset>
+ 4: x
+
+/(?|(abc)|(xyz))\1/
+    abcabc
+ 0: abcabc
+ 1: abc
+    xyzxyz 
+ 0: xyzxyz
+ 1: xyz
+    ** Failers
+No match
+    abcxyz
+No match
+    xyzabc   
+No match
+    
+/(?|(abc)|(xyz))(?1)/
+    abcabc
+ 0: abcabc
+ 1: abc
+    xyzabc 
+ 0: xyzabc
+ 1: xyz
+    ** Failers 
+No match
+    xyzxyz 
+No match
+/\H\h\V\v/
+    X X\x0a
+ 0: X X\x0a
+    X\x09X\x0b
+ 0: X\x09X\x0b
+    ** Failers
+No match
+    \xa0 X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/ 
+    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0X\x0a\x0b\x0c\x0d
+    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0\x0a\x0b\x0c\x0d
+    \x09\x20\xa0\x0a\x0b\x0c
+ 0: \x09 \xa0\x0a\x0b\x0c
+    ** Failers 
+No match
+    \x09\x20\xa0\x0a\x0b
+No match
+     
+/\H{3,4}/
+    XY  ABCDE
+ 0: ABCD
+    XY  PQR ST 
+ 0: PQR
+    
+/.\h{3,4}./
+    XY  AB    PQRS
+ 0: B    P
+
+/\h*X\h?\H+Y\H?Z/
+    >XNNNYZ
+ 0: XNNNYZ
+    >  X NYQZ
+ 0:   X NYQZ
+    ** Failers
+No match
+    >XYZ   
+No match
+    >  X NY Z
+No match
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+    >XY\x0aZ\x0aA\x0bNN\x0c
+ 0: XY\x0aZ\x0aA\x0bNN\x0c
+    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+ 0: \x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
+/[\h]/BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x09 \xa0]
+        Ket
+        End
+------------------------------------------------------------------
+    >\x09<
+ 0: \x09
+
+/[\h]+/BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x09 \xa0]+
+        Ket
+        End
+------------------------------------------------------------------
+    >\x09\x20\xa0<
+ 0: \x09 \xa0
+
+/[\v]/BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x0a-\x0d\x85]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\H]/BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x00-\x08\x0a-\x1f!-\x9f\xa1-\xff]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[^\h]/BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x00-\x08\x0a-\x1f!-\x9f\xa1-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\V]/BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x00-\x09\x0e-\x84\x86-\xff]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\x0a\V]/BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x00-\x0a\x0e-\x84\x86-\xff]
+        Ket
+        End
+------------------------------------------------------------------
+
+/\H++X/BZ
+------------------------------------------------------------------
+        Bra 0
+        \H++
+        X
+        Ket
+        End
+------------------------------------------------------------------
+    ** Failers
+No match
+    XXXX
+No match
+    
+/\H+\hY/BZ
+------------------------------------------------------------------
+        Bra 0
+        \H++
+        \h
+        Y
+        Ket
+        End
+------------------------------------------------------------------
+    XXXX Y 
+ 0: XXXX Y
+
+/\H+ Y/BZ
+------------------------------------------------------------------
+        Bra 0
+        \H++
+         Y
+        Ket
+        End
+------------------------------------------------------------------
+
+/\h+A/BZ
+------------------------------------------------------------------
+        Bra 0
+        \h++
+        A
+        Ket
+        End
+------------------------------------------------------------------
+
+/\v*B/BZ
+------------------------------------------------------------------
+        Bra 0
+        \v*+
+        B
+        Ket
+        End
+------------------------------------------------------------------
+
+/\V+\x0a/BZ
+------------------------------------------------------------------
+        Bra 0
+        \V++
+        \x0a
+        Ket
+        End
+------------------------------------------------------------------
+
+/A+\h/BZ
+------------------------------------------------------------------
+        Bra 0
+        A++
+        \h
+        Ket
+        End
+------------------------------------------------------------------
+
+/ *\H/BZ
+------------------------------------------------------------------
+        Bra 0
+         *+
+        \H
+        Ket
+        End
+------------------------------------------------------------------
+
+/A*\v/BZ
+------------------------------------------------------------------
+        Bra 0
+        A*+
+        \v
+        Ket
+        End
+------------------------------------------------------------------
+
+/\x0b*\V/BZ
+------------------------------------------------------------------
+        Bra 0
+        \x0b*+
+        \V
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d+\h/BZ
+------------------------------------------------------------------
+        Bra 0
+        \d++
+        \h
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*\v/BZ
+------------------------------------------------------------------
+        Bra 0
+        \d*+
+        \v
+        Ket
+        End
+------------------------------------------------------------------
+
+/S+\h\S+\v/BZ
+------------------------------------------------------------------
+        Bra 0
+        S++
+        \h
+        \S++
+        \v
+        Ket
+        End
+------------------------------------------------------------------
+
+/\w{3,}\h\w+\v/BZ
+------------------------------------------------------------------
+        Bra 0
+        \w{3}
+        \w*+
+        \h
+        \w++
+        \v
+        Ket
+        End
+------------------------------------------------------------------
+
+/\h+\d\h+\w\h+\S\h+\H/BZ
+------------------------------------------------------------------
+        Bra 0
+        \h++
+        \d
+        \h++
+        \w
+        \h++
+        \S
+        \h++
+        \H
+        Ket
+        End
+------------------------------------------------------------------
+
+/\v+\d\v+\w\v+\S\v+\V/BZ
+------------------------------------------------------------------
+        Bra 0
+        \v++
+        \d
+        \v++
+        \w
+        \v+
+        \S
+        \v++
+        \V
+        Ket
+        End
+------------------------------------------------------------------
+
+/\H+\h\H+\d/BZ
+------------------------------------------------------------------
+        Bra 0
+        \H++
+        \h
+        \H+
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/\V+\v\V+\w/BZ
+------------------------------------------------------------------
+        Bra 0
+        \V++
+        \v
+        \V+
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+
 / End of testinput2 /
index cf80cd992bba4277278fc30583846c675c38fdec..1f0b2b1243555809e70e518a00c2b28a175f347a 100644 (file)
@@ -1385,4 +1385,92 @@ No match
     a\r
 No match
 
+/\H\h\V\v/8
+    X X\x0a
+ 0: X X\x{0a}
+    X\x09X\x0b
+ 0: X\x{09}X\x{0b}
+    ** Failers
+No match
+    \x{a0} X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d}
+    \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}\x{0d}
+    \x09\x20\x{a0}\x0a\x0b\x0c
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}
+    ** Failers 
+No match
+    \x09\x20\x{a0}\x0a\x0b
+No match
+     
+/\H\h\V\v/8
+    \x{3001}\x{3000}\x{2030}\x{2028}
+ 0: \x{3001}\x{3000}\x{2030}\x{2028}
+    X\x{180e}X\x{85}
+ 0: X\x{180e}X\x{85}
+    ** Failers
+No match
+    \x{2009} X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+ 0: \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x{0c}\x{0d}
+    \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+ 0: \x{09}\x{205f}\x{a0}\x{0a}\x{2029}\x{0c}\x{2028}
+    \x09\x20\x{202f}\x0a\x0b\x0c
+ 0: \x{09} \x{202f}\x{0a}\x{0b}\x{0c}
+    ** Failers 
+No match
+    \x09\x{200a}\x{a0}\x{2028}\x0b
+No match
+     
+/[\h]/8BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x09 \xa0\x{1680}\x{180e}\x{2000}-\x{200a}\x{202f}\x{205f}\x{3000}]
+        Ket
+        End
+------------------------------------------------------------------
+    >\x{1680}
+ 0: \x{1680}
+
+/[\h]{3,}/8BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x09 \xa0\x{1680}\x{180e}\x{2000}-\x{200a}\x{202f}\x{205f}\x{3000}]{3,}
+        Ket
+        End
+------------------------------------------------------------------
+    >\x{1680}\x{180e}\x{2000}\x{2003}\x{200a}\x{202f}\x{205f}\x{3000}<
+ 0: \x{1680}\x{180e}\x{2000}\x{2003}\x{200a}\x{202f}\x{205f}\x{3000}
+
+/[\v]/8BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x0a-\x0d\x85\x{2028}-\x{2029}]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\H]/8BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x00-\x08\x0a-\x1f!-\x9f\xa1-\xff\x{100}-\x{167f}\x{1681}-\x{180d}\x{180f}-\x{1fff}\x{200b}-\x{202e}\x{2030}-\x{205e}\x{2060}-\x{2fff}\x{3001}-\x{7fffffff}]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\V]/8BZ
+------------------------------------------------------------------
+        Bra 0
+        [\x00-\x09\x0e-\x84\x86-\xff\x{100}-\x{2027}\x{2029}-\x{7fffffff}]
+        Ket
+        End
+------------------------------------------------------------------
+
 / End of testinput5 /
index 6860b66146937cf17b5fdba5d1773b6cedf12175..a77186dbd57c2b18974898e5762f95c100bb7358 100644 (file)
@@ -3039,9 +3039,9 @@ No match
     abcdefghijk\12S
  0: abcdefghijk\x0aS
 
-/ab\hdef/
-    abhdef
- 0: abhdef
+/ab\idef/
+    abidef
+ 0: abidef
 
 /a{0}bc/
     bc
@@ -6990,4 +6990,86 @@ No match
  0: 
  0+ 
 
+/(?|(abc)|(xyz))/
+   >abc<
+ 0: abc
+   >xyz< 
+ 0: xyz
+
+/(x)(?|(abc)|(xyz))(x)/
+    xabcx
+ 0: xabcx
+    xxyzx 
+ 0: xxyzx
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/
+    xabcpqrx
+ 0: xabcpqrx
+    xxyzx 
+ 0: xxyzx
+
+/(?|(abc)|(xyz))(?1)/
+    abcabc
+ 0: abcabc
+    xyzabc 
+ 0: xyzabc
+    ** Failers 
+No match
+    xyzxyz 
+No match
+/\H\h\V\v/
+    X X\x0a
+ 0: X X\x0a
+    X\x09X\x0b
+ 0: X\x09X\x0b
+    ** Failers
+No match
+    \xa0 X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/ 
+    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0X\x0a\x0b\x0c\x0d
+ 1: \x09 \xa0X\x0a\x0b\x0c
+    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0\x0a\x0b\x0c\x0d
+ 1: \x09 \xa0\x0a\x0b\x0c
+    \x09\x20\xa0\x0a\x0b\x0c
+ 0: \x09 \xa0\x0a\x0b\x0c
+    ** Failers 
+No match
+    \x09\x20\xa0\x0a\x0b
+No match
+     
+/\H{3,4}/
+    XY  ABCDE
+ 0: ABCD
+ 1: ABC
+    XY  PQR ST 
+ 0: PQR
+    
+/.\h{3,4}./
+    XY  AB    PQRS
+ 0: B    P
+ 1: B    
+
+/\h*X\h?\H+Y\H?Z/
+    >XNNNYZ
+ 0: XNNNYZ
+    >  X NYQZ
+ 0:   X NYQZ
+    ** Failers
+No match
+    >XYZ   
+No match
+    >  X NY Z
+No match
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+    >XY\x0aZ\x0aA\x0bNN\x0c
+ 0: XY\x0aZ\x0aA\x0bNN\x0c
+    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+ 0: \x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
 / End of testinput7 /
index f8251ff5eaa1a62236930b9960e810454a91ffa5..db0f4ade3fd86ddad72d8d0f8802c69fd0983b4f 100644 (file)
@@ -1138,4 +1138,70 @@ No match
     a\r
 No match
 
+/\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}
+
+/\V?\v{3,4}/8 
+    \x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: X\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: X\x{0a}\x{0b}\x{0c}
+
+/\h+\V?\v{3,4}/8
+    >\x09\x20\x{a0}X\x0a\x0a\x0a<
+ 0: \x{09} \x{a0}X\x{0a}\x{0a}\x{0a}
+
+/\V?\v{3,4}/8
+    >\x09\x20\x{a0}X\x0a\x0a\x0a<
+ 0: X\x{0a}\x{0a}\x{0a}
+
+/\H\h\V\v/8
+    X X\x0a
+ 0: X X\x{0a}
+    X\x09X\x0b
+ 0: X\x{09}X\x{0b}
+    ** Failers
+No match
+    \x{a0} X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}
+    \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}
+    \x09\x20\x{a0}\x0a\x0b\x0c
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}
+    ** Failers 
+No match
+    \x09\x20\x{a0}\x0a\x0b
+No match
+     
+/\H\h\V\v/8
+    \x{3001}\x{3000}\x{2030}\x{2028}
+ 0: \x{3001}\x{3000}\x{2030}\x{2028}
+    X\x{180e}X\x{85}
+ 0: X\x{180e}X\x{85}
+    ** Failers
+No match
+    \x{2009} X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+ 0: \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x{0c}\x{0d}
+ 1: \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x{0c}
+    \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+ 0: \x{09}\x{205f}\x{a0}\x{0a}\x{2029}\x{0c}\x{2028}
+ 1: \x{09}\x{205f}\x{a0}\x{0a}\x{2029}\x{0c}
+    \x09\x20\x{202f}\x0a\x0b\x0c
+ 0: \x{09} \x{202f}\x{0a}\x{0b}\x{0c}
+    ** Failers 
+No match
+    \x09\x{200a}\x{a0}\x{2028}\x0b
+No match
+     
 / End of testinput 8 / 
diff --git a/ext/pcre/upgrade-pcre.php b/ext/pcre/upgrade-pcre.php
new file mode 100644 (file)
index 0000000..2f7202e
--- /dev/null
@@ -0,0 +1,102 @@
+<?php
+
+// script to upgrade PCRE. just drop the pcre-x.x.tar.xx here and run the script
+
+$pattern = 'pcre-*.tar.*';
+$newpcre = glob($pattern);
+
+if (count($newpcre) > 1) {
+       echo "more than one '$pattern' file. aborting\n";
+       print_r($newpcre);
+       exit;
+}
+
+if (count($newpcre) == 0) {
+       die("need one '$pattern' file. aborting.\n");
+}
+
+
+$newpcre = $newpcre[0];
+
+if (strpos($newpcre, 'gz')) {
+       system("tar xfz $newpcre");
+} elseif (strpos($newpcre, 'bz2')) {
+       system("tar xfj $newpcre");
+} else {
+       die("file type not recognized: $newpcre\n");
+}
+
+$newpcre = substr($newpcre, 0, strpos($newpcre, '.tar'));
+$dirlen = strlen('pcrelib');
+
+function recurse($path)
+{
+       global $newpcre, $dirlen;
+
+       foreach(scandir($path) as $file) {
+
+               if ($file[0] === '.' || $file === 'CVS') continue;
+               if (substr_compare($file, '.lo', -3, 3) == 0 || substr_compare($file, '.o', -2, 2) == 0) continue;
+
+               $file = "$path/$file";
+
+               if (is_dir($file)) {
+                       recurse($file);
+                       continue;
+               }
+
+               echo "processing $file... ";
+
+               $newfile = $newpcre . substr($file, $dirlen);
+
+               if (is_file($tmp = $newfile . '.generic') || is_file($tmp = $newfile . '.dist')) {
+                       $newfile = $tmp;
+               }
+
+
+               if (!is_file($newfile)) {
+                       die("$newfile is not available any more\n");
+               }
+
+               copy($newfile, $file);
+               echo "OK\n";
+       }
+
+}
+
+
+recurse('pcrelib');
+
+$dirorig = scandir('pcrelib/testdata');
+$k = array_search('CVS', $dirorig);
+unset($dirorig[$k]);
+
+$dirnew = scandir("$newpcre/testdata");
+$diff   = array_diff($dirorig, $dirnew);
+
+foreach ($diff as $file) {
+       $file2 = 'pcrelib'.substr($file, strlen($newpcre));
+       copy($file, $file2);
+}
+
+
+// the config.h needs special care
+$prepend_config_h = '
+#include <php_compat.h>
+#undef PACKAGE_NAME
+#undef PACKAGE_VERSION
+#undef PACKAGE_TARNAME
+#undef PACKAGE_STRING
+
+#define SUPPORT_UCP
+#define SUPPORT_UTF8
+
+
+';
+
+file_put_contents('pcrelib/config.h', $prepend_config_h . file_get_contents('pcrelib/config.h'));
+
+
+echo "\nThe End :-)\n\n"
+
+?>