[Pcre-svn] [471] code/trunk: File tidies, version updates, e…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [471] code/trunk: File tidies, version updates, etc.
Revision: 471
          http://www.exim.org/viewvc/pcre2?view=rev&revision=471
Author:   ph10
Date:     2015-12-17 18:44:06 +0000 (Thu, 17 Dec 2015)
Log Message:
-----------
File tidies, version updates, etc. for 10.21-RC1


Modified Paths:
--------------
    code/trunk/CMakeLists.txt
    code/trunk/ChangeLog
    code/trunk/NEWS
    code/trunk/NON-AUTOTOOLS-BUILD
    code/trunk/README
    code/trunk/RunGrepTest
    code/trunk/RunTest
    code/trunk/configure.ac
    code/trunk/doc/html/NON-AUTOTOOLS-BUILD.txt
    code/trunk/doc/html/README.txt
    code/trunk/doc/html/pcre2.html
    code/trunk/doc/html/pcre2_pattern_info.html
    code/trunk/doc/html/pcre2_set_max_pattern_length.html
    code/trunk/doc/html/pcre2_substitute.html
    code/trunk/doc/html/pcre2api.html
    code/trunk/doc/html/pcre2jit.html
    code/trunk/doc/html/pcre2limits.html
    code/trunk/doc/html/pcre2pattern.html
    code/trunk/doc/html/pcre2posix.html
    code/trunk/doc/html/pcre2serialize.html
    code/trunk/doc/html/pcre2syntax.html
    code/trunk/doc/html/pcre2test.html
    code/trunk/doc/html/pcre2unicode.html
    code/trunk/doc/pcre2.3
    code/trunk/doc/pcre2.txt
    code/trunk/doc/pcre2_set_max_pattern_length.3
    code/trunk/doc/pcre2_substitute.3
    code/trunk/doc/pcre2api.3
    code/trunk/doc/pcre2limits.3
    code/trunk/doc/pcre2pattern.3
    code/trunk/doc/pcre2posix.3
    code/trunk/doc/pcre2serialize.3
    code/trunk/doc/pcre2syntax.3
    code/trunk/doc/pcre2test.1
    code/trunk/doc/pcre2test.txt
    code/trunk/doc/pcre2unicode.3
    code/trunk/perltest.sh
    code/trunk/src/pcre2.h
    code/trunk/src/pcre2_dfa_match.c
    code/trunk/src/pcre2_error.c
    code/trunk/src/pcre2_intmodedep.h
    code/trunk/src/pcre2_match.c
    code/trunk/src/pcre2_pattern_info.c
    code/trunk/src/pcre2_printint.c
    code/trunk/src/pcre2_study.c
    code/trunk/src/pcre2_valid_utf.c
    code/trunk/src/pcre2posix.c
    code/trunk/src/pcre2test.c


Modified: code/trunk/CMakeLists.txt
===================================================================
--- code/trunk/CMakeLists.txt    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/CMakeLists.txt    2015-12-17 18:44:06 UTC (rev 471)
@@ -258,7 +258,7 @@


 IF(PCRE2_NEVER_BACKSLASH_C)
         SET(NEVER_BACKSLASH_C 1)
-ENDIF(PCRE2_NEVER_BACKSLASH_C)         
+ENDIF(PCRE2_NEVER_BACKSLASH_C)


 IF(PCRE2_SUPPORT_UNICODE)
         SET(SUPPORT_UNICODE 1)
@@ -400,7 +400,7 @@
   src/pcre2_context.c
   src/pcre2_dfa_match.c
   src/pcre2_error.c
-  src/pcre2_find_bracket.c 
+  src/pcre2_find_bracket.c
   src/pcre2_jit_compile.c
   src/pcre2_maketables.c
   src/pcre2_match.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/ChangeLog    2015-12-17 18:44:06 UTC (rev 471)
@@ -268,18 +268,18 @@


78. (*NO_AUTO_POSSESS) was not working.

-79. Adding group information caching improves the speed of compiling when
-checking whether a group has a fixed length and/or could match an empty string,
-especially when recursion or subroutine calls are involved. However, this
-cannot be used when (?| is present in the pattern because the same number may
-be used for groups of different sizes. To catch runaway patterns in this
-situation, counts have been introduced to the functions that scan for empty
+79. Adding group information caching improves the speed of compiling when
+checking whether a group has a fixed length and/or could match an empty string,
+especially when recursion or subroutine calls are involved. However, this
+cannot be used when (?| is present in the pattern because the same number may
+be used for groups of different sizes. To catch runaway patterns in this
+situation, counts have been introduced to the functions that scan for empty
branches or compute fixed lengths.

80. Allow for the possibility of the size of the nest_save structure not being
a factor of the size of the compiling workspace (it currently is).

-81. Check for integer overflow in minimum length calculation and cap it at
+81. Check for integer overflow in minimum length calculation and cap it at
65535.

82. Small optimizations in code for finding the minimum matching length.
@@ -290,72 +290,72 @@

85. Check for too many replacements (more than INT_MAX) in pcre2_substitute().

-86. Avoid the possibility of computing with an out-of-bounds pointer (though
+86. Avoid the possibility of computing with an out-of-bounds pointer (though
not dereferencing it) while handling lookbehind assertions.

-87. Failure to get memory for the match data in regcomp() is now given as a
+87. Failure to get memory for the match data in regcomp() is now given as a
regcomp() error instead of waiting for regexec() to pick it up.

-88. In pcre2_substitute(), ensure that CRLF is not split when it is a valid
+88. In pcre2_substitute(), ensure that CRLF is not split when it is a valid
newline sequence.

89. Paranoid check in regcomp() for bad error code from pcre2_compile().

-90. Run test 8 (internal offsets and code sizes) for link sizes 3 and 4 as well
+90. Run test 8 (internal offsets and code sizes) for link sizes 3 and 4 as well
as for link size 2.

-91. Document that JIT has a limit on pattern size, and give more information
+91. Document that JIT has a limit on pattern size, and give more information
about JIT compile failures in pcre2test.

92. Implement PCRE2_INFO_HASBACKSLASHC.

-93. Re-arrange valgrind support code in pcre2test to avoid spurious reports
+93. Re-arrange valgrind support code in pcre2test to avoid spurious reports
with JIT (possibly caused by SSE2?).

94. Support offset_limit in JIT.

-95. A sequence such as [[:punct:]b] that is, a POSIX character class followed
-by a single ASCII character in a class item, was incorrectly compiled in UCP
+95. A sequence such as [[:punct:]b] that is, a POSIX character class followed
+by a single ASCII character in a class item, was incorrectly compiled in UCP
mode. The POSIX class got lost, but only if the single character followed it.

-96. [:punct:] in UCP mode was matching some characters in the range 128-255
+96. [:punct:] in UCP mode was matching some characters in the range 128-255
that should not have been matched.

-97. If [:^ascii:] or [:^xdigit:] are present in a non-negated class, all
-characters with code points greater than 255 are in the class. When a Unicode
-property was also in the class (if PCRE2_UCP is set, escapes such as \w are
-turned into Unicode properties), wide characters were not correctly handled,
+97. If [:^ascii:] or [:^xdigit:] are present in a non-negated class, all
+characters with code points greater than 255 are in the class. When a Unicode
+property was also in the class (if PCRE2_UCP is set, escapes such as \w are
+turned into Unicode properties), wide characters were not correctly handled,
and could fail to match.

-98. In pcre2test, make the "startoffset" modifier a synonym of "offset",
+98. In pcre2test, make the "startoffset" modifier a synonym of "offset",
because it sets the "startoffset" parameter for pcre2_match().

-99. If PCRE2_AUTO_CALLOUT was set on a pattern that had a (?# comment between
-an item and its qualifier (for example, A(?#comment)?B) pcre2_compile()
+99. If PCRE2_AUTO_CALLOUT was set on a pattern that had a (?# comment between
+an item and its qualifier (for example, A(?#comment)?B) pcre2_compile()
misbehaved. This bug was found by the LLVM fuzzer.

-100. The error for an invalid UTF pattern string always gave the code unit
+100. The error for an invalid UTF pattern string always gave the code unit
offset as zero instead of where the invalidity was found.

-101. Further to 97 above, negated classes such as [^[:^ascii:]\d] were also not
+101. Further to 97 above, negated classes such as [^[:^ascii:]\d] were also not
working correctly in UCP mode.

-102. Similar to 99 above, if an isolated \E was present between an item and its
+102. Similar to 99 above, if an isolated \E was present between an item and its
qualifier when PCRE2_AUTO_CALLOUT was set, pcre2_compile() misbehaved. This bug
was found by the LLVM fuzzer.

-103. The POSIX wrapper function regexec() crashed if the option REG_STARTEND
+103. The POSIX wrapper function regexec() crashed if the option REG_STARTEND
was set when the pmatch argument was NULL. It now returns REG_INVARG.

104. Allow for up to 32-bit numbers in the ordin() function in pcre2grep.

-105. An empty \Q\E sequence between an item and its qualifier caused
+105. An empty \Q\E sequence between an item and its qualifier caused
pcre2_compile() to misbehave when auto callouts were enabled. This bug
was found by the LLVM fuzzer.

-106. If both PCRE2_ALT_VERBNAMES and PCRE2_EXTENDED were set, and a (*MARK) or
-other verb "name" ended with whitespace immediately before the closing
-parenthesis, pcre2_compile() misbehaved. Example: /(*:abc )/, but only when
+106. If both PCRE2_ALT_VERBNAMES and PCRE2_EXTENDED were set, and a (*MARK) or
+other verb "name" ended with whitespace immediately before the closing
+parenthesis, pcre2_compile() misbehaved. Example: /(*:abc )/, but only when
both those options were set.

107. In a number of places pcre2_compile() was not handling NULL characters
@@ -363,27 +363,27 @@
displaying fields containing NULLS:

    (a) Within /x extended #-comments
-   (b) Within the "name" part of (*MARK) and other *verbs 
-   (c) Within the text argument of a callout 
-   
-108. If a pattern that was compiled with PCRE2_EXTENDED started with white 
-space or a #-type comment that was followed by (?-x), which turns off 
+   (b) Within the "name" part of (*MARK) and other *verbs
+   (c) Within the text argument of a callout
+
+108. If a pattern that was compiled with PCRE2_EXTENDED started with white
+space or a #-type comment that was followed by (?-x), which turns off
 PCRE2_EXTENDED, and there was no subsequent (?x) to turn it on again,
 pcre2_compile() assumed that (?-x) applied to the whole pattern and
-consequently mis-compiled it. This bug was found by the LLVM fuzzer. The fix 
-for this bug means that a setting of any of the (?imsxU) options at the start 
-of a pattern is no longer transferred to the options that are returned by 
-PCRE2_INFO_ALLOPTIONS. In fact, this was an anachronism that should have 
+consequently mis-compiled it. This bug was found by the LLVM fuzzer. The fix
+for this bug means that a setting of any of the (?imsxU) options at the start
+of a pattern is no longer transferred to the options that are returned by
+PCRE2_INFO_ALLOPTIONS. In fact, this was an anachronism that should have
 changed when the effects of those options were all moved to compile time.


-109. An escaped closing parenthesis in the "name" part of a (*verb) when
+109. An escaped closing parenthesis in the "name" part of a (*verb) when
PCRE2_ALT_VERBNAMES was set caused pcre2_compile() to malfunction. This bug
was found by the LLVM fuzzer.

-110. Implemented PCRE2_SUBSTITUTE_UNSET_EMPTY, and updated pcre2test to make it
+110. Implemented PCRE2_SUBSTITUTE_UNSET_EMPTY, and updated pcre2test to make it
possible to test it.

-111. "Harden" pcre2test against ridiculously large values in modifiers and
+111. "Harden" pcre2test against ridiculously large values in modifiers and
command line arguments.

112. Implemented PCRE2_SUBSTITUTE_UNKNOWN_UNSET and PCRE2_SUBSTITUTE_OVERFLOW_

Modified: code/trunk/NEWS
===================================================================
--- code/trunk/NEWS    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/NEWS    2015-12-17 18:44:06 UTC (rev 471)
@@ -1,6 +1,47 @@
 News about PCRE2 releases
 -------------------------


+Version 10.21 15-December-2015
+------------------------------
+
+1. Many bugs have been fixed. A large number of them were provoked only by very
+strange pattern input, and were discovered by fuzzers. Some others were
+discovered by code auditing. See ChangeLog for details.
+
+2. The Unicode tables have been updated to Unicode version 8.0.0.
+
+3. For Perl compatibility in EBCDIC environments, ranges such as a-z in a
+class, where both values are literal letters in the same case, omit the
+non-letter EBCDIC code points within the range.
+
+4. There have been a number of enhancements to the pcre2_substitute() function,
+giving more flexibility to replacement facilities. It is now also possible to
+cause the function to return the needed buffer size if the one given is too
+small.
+
+5. The PCRE2_ALT_VERBNAMES option causes the "name" parts of special verbs such
+as (*THEN:name) to be processed for backslashes and to take note of
+PCRE2_EXTENDED.
+
+6. PCRE2_INFO_HASBACKSLASHC makes it possible for a client to find out if a
+pattern uses \C, and --never-backslash-C makes it possible to compile a version
+PCRE2 in which the use of \C is always forbidden.
+
+7. A limit to the length of pattern that can be handled can now be set by
+calling pcre2_set_max_pattern_length().
+
+8. When matching an unanchored pattern, a match can be required to begin within
+a given number of code units after the start of the subject by calling
+pcre2_set_offset_limit().
+
+9. The pcre2test program has been extended to test new facilities, and it can
+now run the tests when LF on its own is not a valid newline sequence.
+
+10. The RunTest script has also been updated to enable more tests to be run.
+
+11. There have been some minor performance enhancements.
+
+
Version 10.20 30-June-2015
--------------------------


Modified: code/trunk/NON-AUTOTOOLS-BUILD
===================================================================
--- code/trunk/NON-AUTOTOOLS-BUILD    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/NON-AUTOTOOLS-BUILD    2015-12-17 18:44:06 UTC (rev 471)
@@ -97,7 +97,7 @@
        pcre2_context.c
        pcre2_dfa_match.c
        pcre2_error.c
-       pcre2_find_bracket.c 
+       pcre2_find_bracket.c
        pcre2_jit_compile.c
        pcre2_maketables.c
        pcre2_match.c


Modified: code/trunk/README
===================================================================
--- code/trunk/README    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/README    2015-12-17 18:44:06 UTC (rev 471)
@@ -219,13 +219,13 @@
   to be the end of a line (see above). However, the caller of PCRE2 can
   restrict \R to match only CR, LF, or CRLF. You can make this the default by
   adding --enable-bsr-anycrlf to the "configure" command (bsr = "backslash R").
-  
-. In a pattern, the escape sequence \C matches a single code unit, even in a 
-  UTF mode. This can be dangerous because it breaks up multi-code-unit 
+
+. In a pattern, the escape sequence \C matches a single code unit, even in a
+  UTF mode. This can be dangerous because it breaks up multi-code-unit
   characters. You can build PCRE2 with the use of \C permanently locked out by
-  adding --enable-never-backslash-C (note the upper case C) to the "configure" 
-  command. When \C is allowed by the library, individual applications can lock 
-  it out by calling pcre2_compile() with the PCRE2_NEVER_BACKSLASH_C option. 
+  adding --enable-never-backslash-C (note the upper case C) to the "configure"
+  command. When \C is allowed by the library, individual applications can lock
+  it out by calling pcre2_compile() with the PCRE2_NEVER_BACKSLASH_C option.


 . PCRE2 has a counter that limits the depth of nesting of parentheses in a
   pattern. This limits the amount of system stack that a pattern uses when it
@@ -731,7 +731,7 @@
   src/pcre2_context.c      )
   src/pcre2_dfa_match.c    )
   src/pcre2_error.c        )
-  src/pcre2_find_bracket.c ) 
+  src/pcre2_find_bracket.c )
   src/pcre2_jit_compile.c  )
   src/pcre2_jit_match.c    ) sources for the functions in the library,
   src/pcre2_jit_misc.c     )   and some internal functions that they use


Modified: code/trunk/RunGrepTest
===================================================================
--- code/trunk/RunGrepTest    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/RunGrepTest    2015-12-17 18:44:06 UTC (rev 471)
@@ -82,7 +82,7 @@
 nl=`$pcre2test -C newline`
 if [ "$nl" != "LF" -a "$nl" != "ANY" -a "$nl" != "ANYCRLF" ]; then
   pcre2grep="$pcre2grep -N LF"
-  echo "Default newline setting forced to LF" 
+  echo "Default newline setting forced to LF"
 fi


# ------ Function to run and check a special pcre2grep arguments test -------

Modified: code/trunk/RunTest
===================================================================
--- code/trunk/RunTest    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/RunTest    2015-12-17 18:44:06 UTC (rev 471)
@@ -406,7 +406,7 @@
   jitopt=-jit
   if [ "$valgrind" != "" ] ; then
     vjs="--suppressions=$testdata/valgrind-jit.supp"
-  fi   
+  fi
 fi


# If no specific tests were requested, select all. Those that are not
@@ -439,10 +439,10 @@
do17=yes
do18=yes
do19=yes
- do20=yes
- do21=yes
- do22=yes
- do23=yes
+ do20=yes
+ do21=yes
+ do22=yes
+ do23=yes
fi

 # Handle any explicit skips at this stage, so that an argument list may consist
@@ -720,7 +720,7 @@
       checkresult $? 13 ""
     fi
   fi
-  
+
   # Tests for DFA UTF and UCP features. Output is different for the different widths.


   if [ $do14 = yes ] ; then
@@ -730,7 +730,7 @@
     else
       $sim $valgrind ./pcre2test -q $defaultstack $bmode $opt $testdata/testinput14 testtry
       checkresult $? 14-$bits ""
-    fi   
+    fi
   fi


   # Test non-JIT match and recursion limits
@@ -798,7 +798,7 @@
     $sim $valgrind ./pcre2test -q $defaultstack $bmode $testdata/testinput20 testtry
     checkresult $? 20 ""
   fi
-  
+
   # \C tests without UTF - DFA matching is supported


if [ "$do21" = yes ] ; then
@@ -814,7 +814,7 @@
fi

   # \C tests with UTF - DFA matching is not supported for \C in UTF mode
-   
+
   if [ "$do22" = yes ] ; then
     echo $title22
     if [ $supportBSC -eq 0 ] ; then
@@ -830,7 +830,7 @@
   fi


   # Test when \C is disabled
-   
+
   if [ "$do23" = yes ] ; then
     echo $title23
     if [ $supportBSC -ne 0 ] ; then


Modified: code/trunk/configure.ac
===================================================================
--- code/trunk/configure.ac    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/configure.ac    2015-12-17 18:44:06 UTC (rev 471)
@@ -11,16 +11,16 @@
 m4_define(pcre2_major, [10])
 m4_define(pcre2_minor, [21])
 m4_define(pcre2_prerelease, [-RC1])
-m4_define(pcre2_date, [2015-07-06])
+m4_define(pcre2_date, [2015-12-15])


# NOTE: The CMakeLists.txt file searches for the above variables in the first
# 50 lines of this file. Please update that if the variables above are moved.

 # Libtool shared library interface versions (current:revision:age)
-m4_define(libpcre2_8_version,     [2:0:2])
-m4_define(libpcre2_16_version,    [2:0:2])
-m4_define(libpcre2_32_version,    [2:0:2])
-m4_define(libpcre2_posix_version, [0:0:0])
+m4_define(libpcre2_8_version,     [3:0:3])
+m4_define(libpcre2_16_version,    [3:0:3])
+m4_define(libpcre2_32_version,    [3:0:3])
+m4_define(libpcre2_posix_version, [0:1:0])


 AC_PREREQ(2.57)
 AC_INIT(PCRE2, pcre2_major.pcre2_minor[]pcre2_prerelease, , pcre2)
@@ -189,12 +189,12 @@
               AS_HELP_STRING([--enable-bsr-anycrlf],
                              [\R matches only CR, LF, CRLF by default]),
               , enable_bsr_anycrlf=no)
-              
+
 # Handle --enable-never-backslash-C
 AC_ARG_ENABLE(never-backslash-C,
               AS_HELP_STRING([--enable-never-backslash-C],
                              [use of \C causes an error]),
-              , enable_never_backslash_C=no)                  
+              , enable_never_backslash_C=no)


 # Handle --enable-ebcdic
 AC_ARG_ENABLE(ebcdic,
@@ -348,7 +348,7 @@
     AC_MSG_ERROR([support for EBCDIC and Unicode cannot be enabled at the same time])
   fi
   if test "x$enable_pcre2_16" = "xyes" -o "x$enable_pcre2_32" = "xyes"; then
-    AC_MSG_ERROR([EBCDIC support is available only for the 8-bit library]) 
+    AC_MSG_ERROR([EBCDIC support is available only for the 8-bit library])
   fi
 fi


@@ -617,7 +617,7 @@
 if test "$enable_never_backslash_C" = "yes"; then
   AC_DEFINE([NEVER_BACKSLASH_C], [], [
     Defining NEVER_BACKSLASH_C locks out the use of \C in all patterns.])
-fi      
+fi


 AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [
   The value of LINK_SIZE determines the number of bytes used to store
@@ -896,7 +896,7 @@
     Enable Unicode support .......... : ${enable_unicode}
     Newline char/sequence ........... : ${enable_newline}
     \R matches only ANYCRLF ......... : ${enable_bsr_anycrlf}
-    \C is disabled .................. : ${enable_never_backslash_C} 
+    \C is disabled .................. : ${enable_never_backslash_C}
     EBCDIC coding ................... : ${enable_ebcdic}
     EBCDIC code for NL .............. : ${ebcdic_nl_code}
     Rebuild char tables ............. : ${enable_rebuild_chartables}


Modified: code/trunk/doc/html/NON-AUTOTOOLS-BUILD.txt
===================================================================
--- code/trunk/doc/html/NON-AUTOTOOLS-BUILD.txt    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/NON-AUTOTOOLS-BUILD.txt    2015-12-17 18:44:06 UTC (rev 471)
@@ -97,7 +97,7 @@
        pcre2_context.c
        pcre2_dfa_match.c
        pcre2_error.c
-       pcre2_find_bracket.c 
+       pcre2_find_bracket.c
        pcre2_jit_compile.c
        pcre2_maketables.c
        pcre2_match.c


Modified: code/trunk/doc/html/README.txt
===================================================================
--- code/trunk/doc/html/README.txt    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/README.txt    2015-12-17 18:44:06 UTC (rev 471)
@@ -219,13 +219,13 @@
   to be the end of a line (see above). However, the caller of PCRE2 can
   restrict \R to match only CR, LF, or CRLF. You can make this the default by
   adding --enable-bsr-anycrlf to the "configure" command (bsr = "backslash R").
-  
-. In a pattern, the escape sequence \C matches a single code unit, even in a 
-  UTF mode. This can be dangerous because it breaks up multi-code-unit 
+
+. In a pattern, the escape sequence \C matches a single code unit, even in a
+  UTF mode. This can be dangerous because it breaks up multi-code-unit
   characters. You can build PCRE2 with the use of \C permanently locked out by
-  adding --enable-never-backslash-C (note the upper case C) to the "configure" 
-  command. When \C is allowed by the library, individual applications can lock 
-  it out by calling pcre2_compile() with the PCRE2_NEVER_BACKSLASH_C option. 
+  adding --enable-never-backslash-C (note the upper case C) to the "configure"
+  command. When \C is allowed by the library, individual applications can lock
+  it out by calling pcre2_compile() with the PCRE2_NEVER_BACKSLASH_C option.


 . PCRE2 has a counter that limits the depth of nesting of parentheses in a
   pattern. This limits the amount of system stack that a pattern uses when it
@@ -731,7 +731,7 @@
   src/pcre2_context.c      )
   src/pcre2_dfa_match.c    )
   src/pcre2_error.c        )
-  src/pcre2_find_bracket.c ) 
+  src/pcre2_find_bracket.c )
   src/pcre2_jit_compile.c  )
   src/pcre2_jit_match.c    ) sources for the functions in the library,
   src/pcre2_jit_misc.c     )   and some internal functions that they use


Modified: code/trunk/doc/html/pcre2.html
===================================================================
--- code/trunk/doc/html/pcre2.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -126,9 +126,9 @@
 <P>
 The use of the \C escape sequence in a UTF-8 or UTF-16 pattern can lead to
 problems, because it may leave the current matching point in the middle of a
-multi-code-unit character. The PCRE2_NEVER_BACKSLASH_C option can be used by an 
+multi-code-unit character. The PCRE2_NEVER_BACKSLASH_C option can be used by an
 application to lock out the use of \C, causing a compile-time error if it is
-encountered. It is also possible to build PCRE2 with the use of \C permanently 
+encountered. It is also possible to build PCRE2 with the use of \C permanently
 disabled.
 </P>
 <P>


Modified: code/trunk/doc/html/pcre2_pattern_info.html
===================================================================
--- code/trunk/doc/html/pcre2_pattern_info.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2_pattern_info.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -42,19 +42,20 @@
                                PCRE2_BSR_ANYCRLF: CR, LF, or CRLF only
   PCRE2_INFO_CAPTURECOUNT    Number of capturing subpatterns
   PCRE2_INFO_FIRSTBITMAP     Bitmap of first code units, or NULL
-  PCRE2_INFO_FIRSTCODEUNIT   First code unit when type is 1
   PCRE2_INFO_FIRSTCODETYPE   Type of start-of-match information
                                0 nothing set
                                1 first code unit is set
                                2 start of string or after newline
+  PCRE2_INFO_FIRSTCODEUNIT   First code unit when type is 1
+  PCRE2_INFO_HASBACKSLASHC   Return 1 if pattern contains \C
   PCRE2_INFO_HASCRORLF       Return 1 if explicit CR or LF matches
                                exist in the pattern
   PCRE2_INFO_JCHANGED        Return 1 if (?J) or (?-J) was used
   PCRE2_INFO_JITSIZE         Size of JIT compiled code, or 0
-  PCRE2_INFO_LASTCODEUNIT    Last code unit when type is 1
   PCRE2_INFO_LASTCODETYPE    Type of must-be-present information
                                0 nothing set
                                1 code unit is set
+  PCRE2_INFO_LASTCODEUNIT    Last code unit when type is 1
   PCRE2_INFO_MATCHEMPTY      1 if the pattern can match an
                                empty string, 0 otherwise
   PCRE2_INFO_MATCHLIMIT      Match limit if set,
@@ -62,8 +63,8 @@
   PCRE2_INFO_MAXLOOKBEHIND   Length (in characters) of the longest
                                lookbehind assertion
   PCRE2_INFO_MINLENGTH       Lower bound length of matching strings
+  PCRE2_INFO_NAMECOUNT       Number of named subpatterns
   PCRE2_INFO_NAMEENTRYSIZE   Size of name table entries
-  PCRE2_INFO_NAMECOUNT       Number of named subpatterns
   PCRE2_INFO_NAMETABLE       Pointer to name table
   PCRE2_CONFIG_NEWLINE       Code for the newline sequence:
                                PCRE2_NEWLINE_CR


Modified: code/trunk/doc/html/pcre2_set_max_pattern_length.html
===================================================================
--- code/trunk/doc/html/pcre2_set_max_pattern_length.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2_set_max_pattern_length.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -26,7 +26,7 @@
 DESCRIPTION
 </b><br>
 <P>
-This function sets, in a compile context, the maximum length (in code units) of 
+This function sets, in a compile context, the maximum length (in code units) of
 the pattern that can be compiled. The result is always zero.
 </P>
 <P>


Modified: code/trunk/doc/html/pcre2_substitute.html
===================================================================
--- code/trunk/doc/html/pcre2_substitute.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2_substitute.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -70,6 +70,9 @@
                               PCRE2_UTF was set at compile time)
   PCRE2_SUBSTITUTE_EXTENDED  Do extended replacement processing
   PCRE2_SUBSTITUTE_GLOBAL    Replace all occurrences in the subject
+  PCRE2_SUBSTITUTE_OVERFLOW_LENGTH  If overflow, compute needed length
+  PCRE2_SUBSTITUTE_UNKNOWN_UNSET  Treat unknown group as unset
+  PCRE2_SUBSTITUTE_UNSET_EMPTY  Simple unset insert = empty string
 </pre>
 The function returns the number of substitutions, which may be zero if there
 were no matches. The result can be greater than one only when


Modified: code/trunk/doc/html/pcre2api.html
===================================================================
--- code/trunk/doc/html/pcre2api.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2api.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -618,7 +618,7 @@
   PCRE2's character tables
   The newline character sequence
   The compile time nested parentheses limit
-  The maximum length of the pattern string 
+  The maximum length of the pattern string
   An external function for stack checking
 </pre>
 A compile context is also required if you are using custom memory management.
@@ -661,10 +661,10 @@
 <b>  PCRE2_SIZE <i>value</i>);</b>
 <br>
 <br>
-This sets a maximum length, in code units, for the pattern string that is to be 
-compiled. If the pattern is longer, an error is generated. This facility is 
-provided so that applications that accept patterns from external sources can 
-limit their size. The default is the largest number that a PCRE2_SIZE variable 
+This sets a maximum length, in code units, for the pattern string that is to be
+compiled. If the pattern is longer, an error is generated. This facility is
+provided so that applications that accept patterns from external sources can
+limit their size. The default is the largest number that a PCRE2_SIZE variable
 can hold, which is effectively unlimited.
 <b>int pcre2_set_newline(pcre2_compile_context *<i>ccontext</i>,</b>
 <b>  uint32_t <i>value</i>);</b>
@@ -716,8 +716,8 @@
 <pre>
   A callout function
   The offset limit for matching an unanchored pattern
-  The limit for calling <i>match()</i>
-  The limit for calling <i>match()</i> recursively
+  The limit for calling <b>match()</b> (see below)
+  The limit for calling <b>match()</b> recursively
 </pre>
 A match context is also required if you are using custom memory management.
 If none of these apply, just pass NULL as the context argument of
@@ -771,7 +771,9 @@
 <P>
 The offset limit facility can be used to track progress when searching large
 subject strings. See also the PCRE2_FIRSTLINE option, which requires a match to
-start within the first line of the subject.
+start within the first line of the subject. If this is set with an offset
+limit, a match must occur in the first line and also within the offset limit.
+In other words, whichever limit comes first is used.
 <b>int pcre2_set_match_limit(pcre2_match_context *<i>mcontext</i>,</b>
 <b>  uint32_t <i>value</i>);</b>
 <br>
@@ -1212,7 +1214,9 @@
 If this option is set, an unanchored pattern is required to match before or at
 the first newline in the subject string, though the matched text may continue
 over the newline. See also PCRE2_USE_OFFSET_LIMIT, which provides a more
-general limiting facility.
+general limiting facility. If PCRE2_FIRSTLINE is set with an offset limit, a
+match must occur in the first line and also within the offset limit. In other
+words, whichever limit comes first is used.
 <pre>
   PCRE2_MATCH_UNSET_BACKREF
 </pre>
@@ -1251,7 +1255,7 @@
 This escape can cause unpredictable behaviour in UTF-8 or UTF-16 modes, because
 it may leave the current matching point in the middle of a multi-code-unit
 character. This option may be useful in applications that process patterns from
-external sources. Note that there is also a build-time option that permanently 
+external sources. Note that there is also a build-time option that permanently
 locks out the use of \C.
 <pre>
   PCRE2_NEVER_UCP
@@ -1563,11 +1567,10 @@
 Return a copy of the pattern's options. The third argument should point to a
 <b>uint32_t</b> variable. PCRE2_INFO_ARGOPTIONS returns exactly the options that
 were passed to <b>pcre2_compile()</b>, whereas PCRE2_INFO_ALLOPTIONS returns
-the compile options as modified by any top-level option settings at the start
-of the pattern itself. In other words, they are the options that will be in
-force when matching starts. For example, if the pattern /(?im)abc(?-i)d/ is
-compiled with the PCRE2_EXTENDED option, the result is PCRE2_CASELESS,
-PCRE2_MULTILINE, and PCRE2_EXTENDED.
+the compile options as modified by any top-level option settings such as (*UTF)
+at the start of the pattern itself. For example, if the pattern /(*UTF)abc/ is
+compiled with the PCRE2_EXTENDED option, the result is PCRE2_EXTENDED and
+PCRE2_UTF.
 </P>
 <P>
 A pattern compiled without PCRE2_ANCHORED is automatically anchored by PCRE2 if
@@ -1609,18 +1612,27 @@
 <pre>
   PCRE2_INFO_CAPTURECOUNT
 </pre>
-Return the number of capturing subpatterns in the pattern. The third argument
-should point to an <b>uint32_t</b> variable.
+Return the highest capturing subpattern number in the pattern. In patterns
+where (?| is not used, this is also the total number of capturing subpatterns.
+The third argument should point to an <b>uint32_t</b> variable.
 <pre>
+  PCRE2_INFO_FIRSTBITMAP
+</pre>
+In the absence of a single first code unit for a non-anchored pattern,
+<b>pcre2_compile()</b> may construct a 256-bit table that defines a fixed set of
+values for the first code unit in any match. For example, a pattern that starts
+with [abc] results in a table with three bits set. When code unit values
+greater than 255 are supported, the flag bit for 255 means "any code unit of
+value 255 or above". If such a table was constructed, a pointer to it is
+returned. Otherwise NULL is returned. The third argument should point to an
+<b>const uint8_t *</b> variable.
+<pre>
   PCRE2_INFO_FIRSTCODETYPE
 </pre>
 Return information about the first code unit of any matched string, for a
 non-anchored pattern. The third argument should point to an <b>uint32_t</b>
-variable.
-</P>
-<P>
-If there is a fixed first value, for example, the letter "c" from a pattern
-such as (cat|cow|coyote), 1 is returned, and the character value can be
+variable. If there is a fixed first value, for example, the letter "c" from a
+pattern such as (cat|cow|coyote), 1 is returned, and the character value can be
 retrieved using PCRE2_INFO_FIRSTCODEUNIT. If there is no fixed first value, but
 it is known that a match can occur only at the start of the subject or
 following a newline in the subject, 2 is returned. Otherwise, and for anchored
@@ -1635,16 +1647,10 @@
 0xffff. In the 32-bit library in UTF-32 mode the value can be up to 0x10ffff,
 and up to 0xffffffff when not using UTF-32 mode.
 <pre>
-  PCRE2_INFO_FIRSTBITMAP
+  PCRE2_INFO_HASBACKSLASHC
 </pre>
-In the absence of a single first code unit for a non-anchored pattern,
-<b>pcre2_compile()</b> may construct a 256-bit table that defines a fixed set of
-values for the first code unit in any match. For example, a pattern that starts
-with [abc] results in a table with three bits set. When code unit values
-greater than 255 are supported, the flag bit for 255 means "any code unit of
-value 255 or above". If such a table was constructed, a pointer to it is
-returned. Otherwise NULL is returned. The third argument should point to an
-<b>const uint8_t *</b> variable.
+Return 1 if the pattern contains any instances of \C, otherwise 0. The third
+argument should point to an <b>uint32_t</b> variable.
 <pre>
   PCRE2_INFO_HASCRORLF
 </pre>
@@ -1670,13 +1676,10 @@
 matched string, other than at its start. The third argument should  point to an
 <b>uint32_t</b> variable. If there is no such value, 0 is returned. When 1 is
 returned, the code unit value itself can be retrieved using
-PCRE2_INFO_LASTCODEUNIT.
-</P>
-<P>
-For anchored patterns, a last literal value is recorded only if it follows
-something of variable length. For example, for the pattern /^a\d+z\d+/ the
-returned value is 1 (with "z" returned from PCRE2_INFO_LASTCODEUNIT), but for
-/^a\dz\d/ the returned value is 0.
+PCRE2_INFO_LASTCODEUNIT. For anchored patterns, a last literal value is
+recorded only if it follows something of variable length. For example, for the
+pattern /^a\d+z\d+/ the returned value is 1 (with "z" returned from
+PCRE2_INFO_LASTCODEUNIT), but for /^a\dz\d/ the returned value is 0.
 <pre>
   PCRE2_INFO_LASTCODEUNIT
 </pre>
@@ -1687,8 +1690,11 @@
 <pre>
   PCRE2_INFO_MATCHEMPTY
 </pre>
-Return 1 if the pattern can match an empty string, otherwise 0. The third
-argument should point to an <b>uint32_t</b> variable.
+Return 1 if the pattern might match an empty string, otherwise 0. The third
+argument should point to an <b>uint32_t</b> variable. When a pattern contains
+recursive subroutine calls it is not always possible to determine whether or
+not it can match an empty string. PCRE2 takes a cautious approach and returns 1
+in such cases.
 <pre>
   PCRE2_INFO_MATCHLIMIT
 </pre>
@@ -2142,8 +2148,13 @@
 When PCRE2 is built, a default newline convention is set; this is usually the
 standard convention for the operating system. The default can be overridden in
 a
-<a href="#compilecontext">compile context.</a>
-During matching, the newline choice affects the behaviour of the dot,
+<a href="#compilecontext">compile context</a>
+by calling <b>pcre2_set_newline()</b>. It can also be overridden by starting a
+pattern string with, for example, (*CRLF), as described in the
+<a href="pcre2pattern.html#newlines">section on newline conventions</a>
+in the
+<a href="pcre2pattern.html"><b>pcre2pattern</b></a>
+page. During matching, the newline choice affects the behaviour of the dot,
 circumflex, and dollar metacharacters. It may also alter the way the match
 starting position is advanced after a match failure for an unanchored pattern.
 </P>
@@ -2191,21 +2202,22 @@
 compiled pattern.
 </P>
 <P>
-A successful match returns the overall matched string and any captured
-substrings to the caller via a vector of PCRE2_SIZE values. This is called the
-<b>ovector</b>, and is contained within the
-<a href="#matchdatablock">match data block.</a>
-You can obtain direct access to the ovector by calling
-<b>pcre2_get_ovector_pointer()</b> to find its address, and
-<b>pcre2_get_ovector_count()</b> to find the number of pairs of values it
-contains. Alternatively, you can use the auxiliary functions for accessing
-captured substrings
+You can use auxiliary functions for accessing captured substrings
 <a href="#extractbynumber">by number</a>
 or
-<a href="#extractbyname">by name</a>
-(see below).
+<a href="#extractbyname">by name,</a>
+as described in sections below.
 </P>
 <P>
+Alternatively, you can make direct use of the vector of PCRE2_SIZE values,
+called the <b>ovector</b>, which contains the offsets of captured strings. It is
+part of the
+<a href="#matchdatablock">match data block.</a>
+The function <b>pcre2_get_ovector_pointer()</b> returns the address of the
+ovector, and <b>pcre2_get_ovector_count()</b> returns the number of pairs of
+values it contains.
+</P>
+<P>
 Within the ovector, the first in each pair of values is set to the offset of
 the first code unit of a substring, and the second is set to the offset of the
 first code unit after the end of a substring. These values are always code unit
@@ -2292,7 +2304,13 @@
 to match (PCRE2_ERROR_NOMATCH), a (*MARK) name may be available, and
 <b>pcre2_get_mark()</b> can be called. It returns a pointer to the
 zero-terminated name, which is within the compiled pattern. Otherwise NULL is
-returned. After a successful match, the (*MARK) name that is returned is the
+returned. The length of the (*MARK) name (excluding the terminating zero) is
+stored in the code unit that preceeds the name. You should use this instead of
+relying on the terminating zero if the (*MARK) name might contain a binary
+zero.
+</P>
+<P>
+After a successful match, the (*MARK) name that is returned is the
 last one encountered on the matching path through the pattern. After a "no
 match" or a partial match, the last encountered (*MARK) name is returned. For
 example, consider this pattern:
@@ -2313,7 +2331,7 @@
 as <i>ovector[0]</i> because \K does not affect the result of a partial match.
 </P>
 <P>
-After a UTF check failure, \fBpcre2_get_startchar()\fB can be used to obtain
+After a UTF check failure, <b>pcre2_get_startchar()</b> can be used to obtain
 the code unit offset of the invalid UTF character. Details are given in the
 <a href="pcre2unicode.html"><b>pcre2unicode</b></a>
 page.
@@ -2636,7 +2654,7 @@
 This function calls <b>pcre2_match()</b> and then makes a copy of the subject
 string in <i>outputbuffer</i>, replacing the part that was matched with the
 <i>replacement</i> string, whose length is supplied in <b>rlength</b>. This can
-be given as PCRE2_ZERO_TERMINATED for a zero-terminated string. Matches in 
+be given as PCRE2_ZERO_TERMINATED for a zero-terminated string. Matches in
 which a \K item in a lookahead in the pattern causes the match to end before
 it starts are not supported, and give rise to an error return.
 </P>
@@ -2650,14 +2668,23 @@
 </P>
 <P>
 The <i>outlengthptr</i> argument must point to a variable that contains the
-length, in code units, of the output buffer. If the function is successful,
-the value is updated to contain the length of the new string, excluding the
-trailing zero that is automatically added. If the function is not successful,
-the value is set to PCRE2_UNSET for general errors (such as output buffer too
-small). For syntax errors in the replacement string, the value is set to the
-offset in the replacement string where the error was detected.
+length, in code units, of the output buffer. If the function is successful, the
+value is updated to contain the length of the new string, excluding the
+trailing zero that is automatically added.
 </P>
 <P>
+If the function is not successful, the value set via <i>outlengthptr</i> depends
+on the type of error. For syntax errors in the replacement string, the value is
+the offset in the replacement string where the error was detected. For other
+errors, the value is PCRE2_UNSET by default. This includes the case of the
+output buffer being too small, unless PCRE2_SUBSTITUTE_OVERFLOW_LENGTH is set
+(see below), in which case the value is the minimum length needed, including
+space for the trailing zero. Note that in order to compute the required length,
+<b>pcre2_substitute()</b> has to simulate all the matching and copying, instead
+of giving an error return as soon as the buffer overflows. Note also that the
+length is in code units, not bytes.
+</P>
+<P>
 In the replacement string, which is interpreted as a UTF string in UTF mode,
 and is checked for UTF validity unless the PCRE2_NO_UTF_CHECK option is set, a
 dollar character is an escape character that can specify the insertion of
@@ -2682,17 +2709,55 @@
       apple lemon
    2: pear orange
 </pre>
-There is an additional option, PCRE2_SUBSTITUTE_GLOBAL, which causes the
-function to iterate over the subject string, replacing every matching
-substring. If this is not set, only the first matching substring is replaced.
+As well as the usual options for <b>pcre2_match()</b>, a number of additional
+options can be set in the <i>options</i> argument.
 </P>
 <P>
-A second additional option, PCRE2_SUBSTITUTE_EXTENDED, causes extra processing
-to be applied to the replacement string. Without this option, only the dollar
-character is special, and only the group insertion forms listed above are
-valid. When PCRE2_SUBSTITUTE_EXTENDED is set, two things change:
+PCRE2_SUBSTITUTE_GLOBAL causes the function to iterate over the subject string,
+replacing every matching substring. If this is not set, only the first matching
+substring is replaced. If any matched substring has zero length, after the
+substitution has happened, an attempt to find a non-empty match at the same
+position is performed. If this is not successful, the current position is
+advanced by one character except when CRLF is a valid newline sequence and the
+next two characters are CR, LF. In this case, the current position is advanced
+by two characters.
 </P>
 <P>
+PCRE2_SUBSTITUTE_OVERFLOW_LENGTH changes what happens when the output buffer is
+too small. The default action is to return PCRE2_ERROR_NOMEMORY immediately. If
+this option is set, however, <b>pcre2_substitute()</b> continues to go through
+the motions of matching and substituting (without, of course, writing anything)
+in order to compute the size of buffer that is needed. This value is passed
+back via the <i>outlengthptr</i> variable, with the result of the function still
+being PCRE2_ERROR_NOMEMORY.
+</P>
+<P>
+Passing a buffer size of zero is a permitted way of finding out how much memory
+is needed for given substitution. However, this does mean that the entire
+operation is carried out twice. Depending on the application, it may be more
+efficient to allocate a large buffer and free the excess afterwards, instead of
+using PCRE2_SUBSTITUTE_OVERFLOW_LENGTH.
+</P>
+<P>
+PCRE2_SUBSTITUTE_UNKNOWN_UNSET causes references to capturing groups that do
+not appear in the pattern to be treated as unset groups. This option should be
+used with care, because it means that a typo in a group name or number no
+longer causes the PCRE2_ERROR_NOSUBSTRING error.
+</P>
+<P>
+PCRE2_SUBSTITUTE_UNSET_EMPTY causes unset capturing groups (including unknown
+groups when PCRE2_SUBSTITUTE_UNKNOWN_UNSET is set) to be treated as empty
+strings when inserted as described above. If this option is not set, an attempt
+to insert an unset group causes the PCRE2_ERROR_UNSET error. This option does
+not influence the extended substitution syntax described below.
+</P>
+<P>
+PCRE2_SUBSTITUTE_EXTENDED causes extra processing to be applied to the
+replacement string. Without this option, only the dollar character is special,
+and only the group insertion forms listed above are valid. When
+PCRE2_SUBSTITUTE_EXTENDED is set, two things change:
+</P>
+<P>
 Firstly, backslash in a replacement string is interpreted as an escape
 character. The usual forms such as \n or \x{ddd} can be used to specify
 particular character codes, and backslash followed by any non-alphanumeric
@@ -2740,23 +2805,47 @@
       somebody
    1: HELLO
 </pre>
-If successful, the function returns the number of replacements that were made.
-This may be zero if no matches were found, and is never greater than 1 unless
-PCRE2_SUBSTITUTE_GLOBAL is set.
+The PCRE2_SUBSTITUTE_UNSET_EMPTY option does not affect these extended
+substitutions. However, PCRE2_SUBSTITUTE_UNKNOWN_UNSET does cause unknown
+groups in the extended syntax forms to be treated as unset.
 </P>
 <P>
+If successful, <b>pcre2_substitute()</b> returns the number of replacements that
+were made. This may be zero if no matches were found, and is never greater than
+1 unless PCRE2_SUBSTITUTE_GLOBAL is set.
+</P>
+<P>
 In the event of an error, a negative error code is returned. Except for
 PCRE2_ERROR_NOMATCH (which is never returned), errors from <b>pcre2_match()</b>
-are passed straight back. PCRE2_ERROR_NOMEMORY is returned if the output buffer
-is not big enough. PCRE2_ERROR_BADREPLACEMENT is used for miscellaneous syntax
-errors in the replacement string, with more particular errors being
-PCRE2_ERROR_BADREPESCAPE (invalid escape sequence),
-PCRE2_ERROR_REPMISSING_BRACE (closing curly bracket not found),
-PCRE2_BADSUBSTITUTION (syntax error in extended group substitution), and
-PCRE2_BADSUBPATTERN (the pattern match ended before it started). As for all
-PCRE2 errors, a text message that describes the error can be obtained by
-calling <b>pcre2_get_error_message()</b>.
+are passed straight back.
 </P>
+<P>
+PCRE2_ERROR_NOSUBSTRING is returned for a non-existent substring insertion,
+unless PCRE2_SUBSTITUTE_UNKNOWN_UNSET is set.
+</P>
+<P>
+PCRE2_ERROR_UNSET is returned for an unset substring insertion (including an
+unknown substring when PCRE2_SUBSTITUTE_UNKNOWN_UNSET is set) when the simple
+(non-extended) syntax is used and PCRE2_SUBSTITUTE_UNSET_EMPTY is not set.
+</P>
+<P>
+PCRE2_ERROR_NOMEMORY is returned if the output buffer is not big enough. If the
+PCRE2_SUBSTITUTE_OVERFLOW_LENGTH option is set, the size of buffer that is
+needed is returned via <i>outlengthptr</i>. Note that this does not happen by
+default.
+</P>
+<P>
+PCRE2_ERROR_BADREPLACEMENT is used for miscellaneous syntax errors in the
+replacement string, with more particular errors being PCRE2_ERROR_BADREPESCAPE
+(invalid escape sequence), PCRE2_ERROR_REPMISSING_BRACE (closing curly bracket
+not found), PCRE2_BADSUBSTITUTION (syntax error in extended group
+substitution), and PCRE2_BADSUBPATTERN (the pattern match ended before it
+started, which can happen if \K is used in an assertion).
+</P>
+<P>
+As for all PCRE2 errors, a text message that describes the error can be
+obtained by calling <b>pcre2_get_error_message()</b>.
+</P>
 <br><a name="SEC35" href="#TOC1">DUPLICATE SUBPATTERN NAMES</a><br>
 <P>
 <b>int pcre2_substring_nametable_scan(const pcre2_code *<i>code</i>,</b>
@@ -2796,11 +2885,11 @@
 PCRE2_ERROR_NOSUBSTRING is returned if there are no entries for the given name.
 </P>
 <P>
-The format of the name table is described above in the section entitled
-<i>Information about a pattern</i>
-<a href="#infoaboutpattern">above.</a>
-Given all the relevant entries for the name, you can extract each of their
-numbers, and hence the captured data.
+The format of the name table is described
+<a href="#infoaboutpattern">above</a>
+in the section entitled <i>Information about a pattern</i>. Given all the
+relevant entries for the name, you can extract each of their numbers, and hence
+the captured data.
 </P>
 <br><a name="SEC36" href="#TOC1">FINDING ALL POSSIBLE MATCHES AT ONE POSITION</a><br>
 <P>
@@ -3032,7 +3121,7 @@
 </P>
 <br><a name="SEC40" href="#TOC1">REVISION</a><br>
 <P>
-Last updated: 05 November 2015
+Last updated: 16 December 2015
 <br>
 Copyright &copy; 1997-2015 University of Cambridge.
 <br>


Modified: code/trunk/doc/html/pcre2jit.html
===================================================================
--- code/trunk/doc/html/pcre2jit.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2jit.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -86,6 +86,13 @@
 or a negative error code.
 </P>
 <P>
+There is a limit to the size of pattern that JIT supports, imposed by the size
+of machine stack that it uses. The exact rules are not documented because they
+may change at any time, in particular, when new optimizations are introduced.
+If a pattern is too big, a call to \fBpcre2_jit_compile()\fB returns
+PCRE2_ERROR_NOMEMORY.
+</P>
+<P>
 PCRE2_JIT_COMPLETE requests the JIT compiler to generate code for complete
 matches. If you want to run partial matches using the PCRE2_PARTIAL_HARD or
 PCRE2_PARTIAL_SOFT options of <b>pcre2_match()</b>, you should set one or both
@@ -425,7 +432,7 @@
 </P>
 <br><a name="SEC13" href="#TOC1">REVISION</a><br>
 <P>
-Last updated: 28 July 2015
+Last updated: 14 November 2015
 <br>
 Copyright &copy; 1997-2015 University of Cambridge.
 <br>


Modified: code/trunk/doc/html/pcre2limits.html
===================================================================
--- code/trunk/doc/html/pcre2limits.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2limits.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -32,8 +32,8 @@
 linkage size is always 4.
 </P>
 <P>
-The maximum length of a source pattern string is essentially unlimited; it is 
-the largest number a PCRE2_SIZE variable can hold. However, the program that 
+The maximum length of a source pattern string is essentially unlimited; it is
+the largest number a PCRE2_SIZE variable can hold. However, the program that
 calls <b>pcre2_compile()</b> can specify a smaller limit.
 </P>
 <P>


Modified: code/trunk/doc/html/pcre2pattern.html
===================================================================
--- code/trunk/doc/html/pcre2pattern.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2pattern.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -669,8 +669,8 @@
 This particular group matches either the two-character sequence CR followed by
 LF, or one of the single characters LF (linefeed, U+000A), VT (vertical tab,
 U+000B), FF (form feed, 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.
+line, U+0085). Because this is an atomic group, the two-character sequence is
+treated as a single unit that cannot be split.
 </P>
 <P>
 In other modes, two additional characters whose codepoints are greater than 255
@@ -1186,6 +1186,16 @@
 PCRE2_DOLLAR_ENDONLY option is ignored if PCRE2_MULTILINE is set.
 </P>
 <P>
+When the newline convention (see
+<a href="#newlines">"Newline conventions"</a>
+below) recognizes the two-character sequence CRLF as a newline, this is
+preferred, even if the single characters CR and LF are also recognized as
+newlines. For example, if the newline convention is "any", a multiline mode
+circumflex matches before "xyz" in the string "abc\r\nxyz" rather than after
+CR, even though CR on its own is a valid newline. (It also matches at the very
+start of the string, of course.)
+</P>
+<P>
 Note that the sequences \A, \Z, and \z can be used to match the start and
 end of the subject in both modes, and if all branches of a pattern start with
 \A it is always anchored, whether or not PCRE2_MULTILINE is set.
@@ -1236,7 +1246,7 @@
 with a malformed UTF character. This has undefined results, because PCRE2
 assumes that it is matching character by character in a valid UTF string (by
 default it checks the subject string's validity at the start of processing
-unless the PCRE2_NO_UTF_CHECK option is used). 
+unless the PCRE2_NO_UTF_CHECK option is used).
 </P>
 <P>
 An application can lock out the use of \C by setting the
@@ -1247,9 +1257,9 @@
 PCRE2 does not allow \C to appear in lookbehind assertions
 <a href="#lookbehind">(described below)</a>
 in a UTF mode, because this would make it impossible to calculate the length of
-the lookbehind. Neither the alternative matching function 
-<b>pcre2_dfa_match()</b> not the JIT optimizer support \C in a UTF mode. The 
-former gives a match-time error; the latter fails to optimize and so the match 
+the lookbehind. Neither the alternative matching function
+<b>pcre2_dfa_match()</b> not the JIT optimizer support \C in a UTF mode. The
+former gives a match-time error; the latter fails to optimize and so the match
 is always run using the interpreter.
 </P>
 <P>
@@ -1341,11 +1351,11 @@
 current mode.
 </P>
 <P>
-There is a special case in EBCDIC environments for ranges whose end points are 
-both specified as literal letters in the same case. For compatibility with 
-Perl, EBCDIC code points within the range that are not letters are omitted. For 
-example, [h-k] matches only four characters, even though the codes for h and k 
-are 0x88 and 0x92, a range of 11 code points. However, if the range is 
+There is a special case in EBCDIC environments for ranges whose end points are
+both specified as literal letters in the same case. For compatibility with
+Perl, EBCDIC code points within the range that are not letters are omitted. For
+example, [h-k] matches only four characters, even though the codes for h and k
+are 0x88 and 0x92, a range of 11 code points. However, if the range is
 specified numerically, for example, [\x88-\x92] or [h-\x92], all code points
 are included.
 </P>
@@ -1672,6 +1682,10 @@
 <pre>
   /(?|(abc)|(def))(?1)/
 </pre>
+A relative reference such as (?-1) is no different: it is just a convenient way
+of computing an absolute group number.
+</P>
+<P>
 If a
 <a href="#conditions">condition test</a>
 for a subpattern's having matched refers to a non-unique number, the test is
@@ -2512,7 +2526,7 @@
   (?(VERSION&#62;=10.4)yes|no)
 </pre>
 This pattern matches "yes" if the PCRE2 version is greater or equal to 10.4, or
-"no" otherwise. The fractional part of the version number may not contain more 
+"no" otherwise. The fractional part of the version number may not contain more
 than two digits.
 </P>
 <br><b>
@@ -2626,6 +2640,21 @@
 capturing parentheses leftwards from the point at which it is encountered.
 </P>
 <P>
+Be aware however, that if
+<a href="#dupsubpatternnumber">duplicate subpattern numbers</a>
+are in use, relative references refer to the earliest subpattern with the
+appropriate number. Consider, for example:
+<pre>
+  (?|(a)|(b)) (c) (?-2)
+</pre>
+The first two capturing groups (a) and (b) are both numbered 1, and group (c)
+is number 2. When the reference (?-2) is encountered, the second most recently
+opened parentheses has the number 1, but it is the first such group (the (a)
+group) to which the recursion refers. This would be the same if an absolute
+reference (?1) was used. In other words, relative references are just a
+shorthand for computing a group number.
+</P>
+<P>
 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 referenced. They are always
@@ -2929,13 +2958,13 @@
 </P>
 <P>
 By default, for compatibility with Perl, a name is any sequence of characters
-that does not include a closing parenthesis. The name is not processed in 
+that does not include a closing parenthesis. The name is not processed in
 any way, and it is not possible to include a closing parenthesis in the name.
-However, if the PCRE2_ALT_VERBNAMES option is set, normal backslash processing 
-is applied to verb names and only an unescaped closing parenthesis terminates 
-the name. A closing parenthesis can be included in a name either as \) or 
-between \Q and \E. If the PCRE2_EXTENDED option is set, unescaped whitespace 
-in verb names is skipped and #-comments are recognized, exactly as in the rest 
+However, if the PCRE2_ALT_VERBNAMES option is set, normal backslash processing
+is applied to verb names and only an unescaped closing parenthesis terminates
+the name. A closing parenthesis can be included in a name either as \) or
+between \Q and \E. If the PCRE2_EXTENDED option is set, unescaped whitespace
+in verb names is skipped and #-comments are recognized, exactly as in the rest
 of the pattern.
 </P>
 <P>
@@ -3359,7 +3388,7 @@
 </P>
 <br><a name="SEC30" href="#TOC1">REVISION</a><br>
 <P>
-Last updated: 01 November 2015
+Last updated: 13 November 2015
 <br>
 Copyright &copy; 1997-2015 University of Cambridge.
 <br>


Modified: code/trunk/doc/html/pcre2posix.html
===================================================================
--- code/trunk/doc/html/pcre2posix.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2posix.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -200,7 +200,7 @@
 PCRE2_DOLLAR_ENDONLY when calling <b>pcre2_compile()</b> directly, but there is
 no way to make PCRE2 behave exactly as for the REG_NEWLINE action. When using
 the POSIX API, passing REG_NEWLINE to PCRE2's <b>regcomp()</b> function
-causes PCRE2_MULTILINE to be passed to <b>pcre2_compile()</b>, and REG_DOTALL 
+causes PCRE2_MULTILINE to be passed to <b>pcre2_compile()</b>, and REG_DOTALL
 passes PCRE2_DOTALL. There is no way to pass PCRE2_DOLLAR_ENDONLY.
 </P>
 <br><a name="SEC5" href="#TOC1">MATCHING A PATTERN</a><br>
@@ -235,7 +235,8 @@
 IEEE Standard 1003.2 (POSIX.2), and should be used with caution in software
 intended to be portable to other systems. Note that a non-zero <i>rm_so</i> does
 not imply REG_NOTBOL; REG_STARTEND affects only the location of the string, not
-how it is matched.
+how it is matched. Setting REG_STARTEND and passing <i>pmatch</i> as NULL are
+mutually exclusive; the error REG_INVARG is returned.
 </P>
 <P>
 If the pattern was compiled with the REG_NOSUB flag, no data about any matched
@@ -289,7 +290,7 @@
 </P>
 <br><a name="SEC9" href="#TOC1">REVISION</a><br>
 <P>
-Last updated: 30 October 2015
+Last updated: 29 November 2015
 <br>
 Copyright &copy; 1997-2015 University of Cambridge.
 <br>


Modified: code/trunk/doc/html/pcre2serialize.html
===================================================================
--- code/trunk/doc/html/pcre2serialize.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2serialize.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -154,13 +154,13 @@
 <P>
 Decoded patterns can be used for matching in the usual way, and must be freed
 by calling <b>pcre2_code_free()</b>. However, be aware that there is a potential
-race issue if you are using multiple patterns that were decoded from a single 
+race issue if you are using multiple patterns that were decoded from a single
 byte stream in a multithreaded application. A single copy of the character
 tables is used by all the decoded patterns and a reference count is used to
 arrange for its memory to be automatically freed when the last pattern is
 freed, but there is no locking on this reference count. Therefore, if you want
 to call <b>pcre2_code_free()</b> for these patterns in different threads, you
-must arrange your own locking, and ensure that <b>pcre2_code_free()</b> cannot 
+must arrange your own locking, and ensure that <b>pcre2_code_free()</b> cannot
 be called by two threads at the same time.
 </P>
 <P>


Modified: code/trunk/doc/html/pcre2syntax.html
===================================================================
--- code/trunk/doc/html/pcre2syntax.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2syntax.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -113,7 +113,7 @@
 </pre>
 \C is dangerous because it may leave the current matching point in the middle
 of a UTF-8 or UTF-16 character. The application can lock out the use of \C by
-setting the PCRE2_NEVER_BACKSLASH_C option. It is also possible to build PCRE2 
+setting the PCRE2_NEVER_BACKSLASH_C option. It is also possible to build PCRE2
 with the use of \C permanently disabled.
 </P>
 <P>


Modified: code/trunk/doc/html/pcre2test.html
===================================================================
--- code/trunk/doc/html/pcre2test.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2test.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -486,7 +486,7 @@
 <pre>
   abc\=notbol,notempty
 </pre>
-If the subject string is empty and \= is followed by whitespace, the line is 
+If the subject string is empty and \= is followed by whitespace, the line is
 treated as a comment line, and is not used for matching. For example:
 <pre>
   \= This is a comment.
@@ -538,7 +538,7 @@
       no_utf_check              set PCRE2_NO_UTF_CHECK
       ucp                       set PCRE2_UCP
       ungreedy                  set PCRE2_UNGREEDY
-      use_offset_limit          set PCRE2_USE_OFFSET_LIMIT 
+      use_offset_limit          set PCRE2_USE_OFFSET_LIMIT
       utf                       set PCRE2_UTF
 </pre>
 As well as turning on the PCRE2_UTF option, the <b>utf</b> modifier causes all
@@ -564,7 +564,7 @@
       jitfast                   use JIT fast path
       jitverify                 verify JIT use
       locale=&#60;name&#62;             use this locale
-      max_pattern_length=&#60;n&#62;    set the maximum pattern length 
+      max_pattern_length=&#60;n&#62;    set the maximum pattern length
       memory                    show memory used
       newline=&#60;type&#62;            set newline type
       null_context              compile with a NULL context
@@ -649,9 +649,9 @@
 Passing a NULL context
 </b><br>
 <P>
-Normally, <b>pcre2test</b> passes a context block to <b>pcre2_compile()</b>. If 
-the <b>null_context</b> modifier is set, however, NULL is passed. This is for 
-testing that <b>pcre2_compile()</b> behaves correctly in this case (it uses 
+Normally, <b>pcre2test</b> passes a context block to <b>pcre2_compile()</b>. If
+the <b>null_context</b> modifier is set, however, NULL is passed. This is for
+testing that <b>pcre2_compile()</b> behaves correctly in this case (it uses
 default values).
 </P>
 <br><b>
@@ -675,9 +675,9 @@
 </b><br>
 <P>
 Some tests use long patterns that are very repetitive. Instead of creating a
-very long input line for such a pattern, you can use a special repetition 
-feature, similar to the one described for subject lines above. If the 
-<b>expand</b> modifier is present on a pattern, parts of the pattern that have 
+very long input line for such a pattern, you can use a special repetition
+feature, similar to the one described for subject lines above. If the
+<b>expand</b> modifier is present on a pattern, parts of the pattern that have
 the form
 <pre>
   \[&#60;characters&#62;]{&#60;count&#62;}
@@ -689,13 +689,13 @@
 remain in the pattern unaltered.
 </P>
 <P>
-If part of an expanded pattern looks like an expansion, but is really part of 
-the actual pattern, unwanted expansion can be avoided by giving two values in 
-the quantifier. For example, \[AB]{6000,6000} is not recognized as an 
+If part of an expanded pattern looks like an expansion, but is really part of
+the actual pattern, unwanted expansion can be avoided by giving two values in
+the quantifier. For example, \[AB]{6000,6000} is not recognized as an
 expansion item.
 </P>
 <P>
-If the <b>info</b> modifier is set on an expanded pattern, the result of the 
+If the <b>info</b> modifier is set on an expanded pattern, the result of the
 expansion is included in the information that is output.
 </P>
 <br><b>
@@ -812,9 +812,9 @@
 Limiting the pattern length
 </b><br>
 <P>
-The <b>max_pattern_length</b> modifier sets a limit, in code units, to the 
-length of pattern that <b>pcre2_compile()</b> will accept. Breaching the limit 
-causes a compilation error. The default is the largest number a PCRE2_SIZE 
+The <b>max_pattern_length</b> modifier sets a limit, in code units, to the
+length of pattern that <b>pcre2_compile()</b> will accept. Breaching the limit
+causes a compilation error. The default is the largest number a PCRE2_SIZE
 variable can hold (essentially unlimited).
 </P>
 <br><b>
@@ -836,13 +836,13 @@
   ucp                REG_UCP        )   the POSIX standard
   utf                REG_UTF8       )
 </pre>
-The <b>regerror_buffsize</b> modifier specifies a size for the error buffer that 
+The <b>regerror_buffsize</b> modifier specifies a size for the error buffer that
 is passed to <b>regerror()</b> in the event of a compilation error. For example:
 <pre>
   /abc/posix,regerror_buffsize=20
 </pre>
-This provides a means of testing the behaviour of <b>regerror()</b> when the 
-buffer is too small for the error message. If this modifier has not been set, a 
+This provides a means of testing the behaviour of <b>regerror()</b> when the
+buffer is too small for the error message. If this modifier has not been set, a
 large buffer is used.
 </P>
 <P>
@@ -892,14 +892,18 @@
 not appear in <b>#pattern</b> commands. These modifiers do not affect the
 compilation process.
 <pre>
-      aftertext           show text after match
-      allaftertext        show text after captures
-      allcaptures         show all captures
-      allusedtext         show all consulted text
-  /g  global              global matching
-      mark                show mark values
-      replace=&#60;string&#62;    specify a replacement string
-      startchar           show starting character when relevant
+      aftertext                  show text after match
+      allaftertext               show text after captures
+      allcaptures                show all captures
+      allusedtext                show all consulted text
+  /g  global                     global matching
+      mark                       show mark values
+      replace=&#60;string&#62;           specify a replacement string
+      startchar                  show starting character when relevant
+      substitute_extended        use PCRE2_SUBSTITUTE_EXTENDED
+      substitute_overflow_length use PCRE2_SUBSTITUTE_OVERFLOW_LENGTH
+      substitute_unknown_unset   use PCRE2_SUBSTITUTE_UNKNOWN_UNSET
+      substitute_unset_empty     use PCRE2_SUBSTITUTE_UNSET_EMPTY
 </pre>
 These modifiers may not appear in a <b>#pattern</b> command. If you want them as
 defaults, set them in a <b>#subject</b> command.
@@ -964,33 +968,38 @@
 in which case they apply to every subject line that is matched against that
 pattern.
 <pre>
-      aftertext                 show text after match
-      allaftertext              show text after captures
-      allcaptures               show all captures
-      allusedtext               show all consulted text (non-JIT only)
-      altglobal                 alternative global matching
-      callout_capture           show captures at callout time
-      callout_data=&#60;n&#62;          set a value to pass via callouts
-      callout_fail=&#60;n&#62;[:&#60;m&#62;]    control callout failure
-      callout_none              do not supply a callout function
-      copy=&#60;number or name&#62;     copy captured substring
-      dfa                       use <b>pcre2_dfa_match()</b>
-      find_limits               find match and recursion limits
-      get=&#60;number or name&#62;      extract captured substring
-      getall                    extract all captured substrings
-  /g  global                    global matching
-      jitstack=&#60;n&#62;              set size of JIT stack
-      mark                      show mark values
-      match_limit=&#60;n&#62;           set a match limit
-      memory                    show memory usage
-      null_context              match with a NULL context 
-      offset=&#60;n&#62;                set starting offset
-      offset_limit=&#60;n&#62;          set offset limit
-      ovector=&#60;n&#62;               set size of output vector
-      recursion_limit=&#60;n&#62;       set a recursion limit
-      replace=&#60;string&#62;          specify a replacement string
-      startchar                 show startchar when relevant
-      zero_terminate            pass the subject as zero-terminated
+      aftertext                  show text after match
+      allaftertext               show text after captures
+      allcaptures                show all captures
+      allusedtext                show all consulted text (non-JIT only)
+      altglobal                  alternative global matching
+      callout_capture            show captures at callout time
+      callout_data=&#60;n&#62;           set a value to pass via callouts
+      callout_fail=&#60;n&#62;[:&#60;m&#62;]     control callout failure
+      callout_none               do not supply a callout function
+      copy=&#60;number or name&#62;      copy captured substring
+      dfa                        use <b>pcre2_dfa_match()</b>
+      find_limits                find match and recursion limits
+      get=&#60;number or name&#62;       extract captured substring
+      getall                     extract all captured substrings
+  /g  global                     global matching
+      jitstack=&#60;n&#62;               set size of JIT stack
+      mark                       show mark values
+      match_limit=&#60;n&#62;            set a match limit
+      memory                     show memory usage
+      null_context               match with a NULL context
+      offset=&#60;n&#62;                 set starting offset
+      offset_limit=&#60;n&#62;           set offset limit
+      ovector=&#60;n&#62;                set size of output vector
+      recursion_limit=&#60;n&#62;        set a recursion limit
+      replace=&#60;string&#62;           specify a replacement string
+      startchar                  show startchar when relevant
+      startoffset=&#60;n&#62;            same as offset=&#60;n&#62;
+      substitute_extedded        use PCRE2_SUBSTITUTE_EXTENDED
+      substitute_overflow_length use PCRE2_SUBSTITUTE_OVERFLOW_LENGTH
+      substitute_unknown_unset   use PCRE2_SUBSTITUTE_UNKNOWN_UNSET
+      substitute_unset_empty     use PCRE2_SUBSTITUTE_UNSET_EMPTY
+      zero_terminate             pass the subject as zero-terminated
 </pre>
 The effects of these modifiers are described in the following sections.
 </P>
@@ -1129,20 +1138,35 @@
 </b><br>
 <P>
 If the <b>replace</b> modifier is set, the <b>pcre2_substitute()</b> function is
-called instead of one of the matching functions. Unlike subject strings,
-<b>pcre2test</b> does not process replacement strings for escape sequences. In
-UTF mode, a replacement string is checked to see if it is a valid UTF-8 string.
-If so, it is correctly converted to a UTF string of the appropriate code unit
-width. If it is not a valid UTF-8 string, the individual code units are copied
-directly. This provides a means of passing an invalid UTF-8 string for testing
-purposes.
+called instead of one of the matching functions. Note that replacement strings
+cannot contain commas, because a comma signifies the end of a modifier. This is
+not thought to be an issue in a test program.
 </P>
 <P>
-If the <b>global</b> modifier is set, PCRE2_SUBSTITUTE_GLOBAL is passed to
-<b>pcre2_substitute()</b>. After a successful substitution, the modified string
-is output, preceded by the number of replacements. This may be zero if there
-were no matches. Here is a simple example of a substitution test:
+Unlike subject strings, <b>pcre2test</b> does not process replacement strings
+for escape sequences. In UTF mode, a replacement string is checked to see if it
+is a valid UTF-8 string. If so, it is correctly converted to a UTF string of
+the appropriate code unit width. If it is not a valid UTF-8 string, the
+individual code units are copied directly. This provides a means of passing an
+invalid UTF-8 string for testing purposes.
+</P>
+<P>
+The following modifiers set options (in additional to the normal match options)
+for <b>pcre2_substitute()</b>:
 <pre>
+  global                      PCRE2_SUBSTITUTE_GLOBAL
+  substitute_extended         PCRE2_SUBSTITUTE_EXTENDED
+  substitute_overflow_length  PCRE2_SUBSTITUTE_OVERFLOW_LENGTH
+  substitute_unknown_unset    PCRE2_SUBSTITUTE_UNKNOWN_UNSET
+  substitute_unset_empty      PCRE2_SUBSTITUTE_UNSET_EMPTY
+
+</PRE>
+</P>
+<P>
+After a successful substitution, the modified string is output, preceded by the
+number of replacements. This may be zero if there were no matches. Here is a
+simple example of a substitution test:
+<pre>
   /abc/replace=xxx
       =abc=abc=
    1: =xxx=abc=
@@ -1149,12 +1173,12 @@
       =abc=abc=\=global
    2: =xxx=xxx=
 </pre>
-Subject and replacement strings should be kept relatively short for
-substitution tests, as fixed-size buffers are used. To make it easy to test for
-buffer overflow, if the replacement string starts with a number in square
-brackets, that number is passed to <b>pcre2_substitute()</b> as the size of the
-output buffer, with the replacement string starting at the next character. Here
-is an example that tests the edge case:
+Subject and replacement strings should be kept relatively short (fewer than 256
+characters) for substitution tests, as fixed-size buffers are used. To make it
+easy to test for buffer overflow, if the replacement string starts with a
+number in square brackets, that number is passed to <b>pcre2_substitute()</b> as
+the size of the output buffer, with the replacement string starting at the next
+character. Here is an example that tests the edge case:
 <pre>
   /abc/
       123abc123\=replace=[10]XYZ
@@ -1162,6 +1186,19 @@
       123abc123\=replace=[9]XYZ
   Failed: error -47: no more memory
 </pre>
+The default action of <b>pcre2_substitute()</b> is to return
+PCRE2_ERROR_NOMEMORY when the output buffer is too small. However, if the
+PCRE2_SUBSTITUTE_OVERFLOW_LENGTH option is set (by using the
+<b>substitute_overflow_length</b> modifier), <b>pcre2_substitute()</b> continues
+to go through the motions of matching and substituting, in order to compute the
+size of buffer that is required. When this happens, <b>pcre2test</b> shows the
+required buffer length (which includes space for the trailing zero) as part of
+the error message. For example:
+<pre>
+  /abc/substitute_overflow_length
+      123abc123\=replace=[9]XYZ
+  Failed: error -47: no more memory: 10 code units are needed
+</pre>
 A replacement string is ignored with POSIX and DFA matching. Specifying partial
 matching provokes an error return ("bad option value") from
 <b>pcre2_substitute()</b>.
@@ -1236,10 +1273,10 @@
 Setting an offset limit
 </b><br>
 <P>
-The <b>offset_limit</b> modifier sets a limit for unanchored matches. If a match 
-cannot be found starting at or before this offset in the subject, a "no match" 
-return is given. The data value is a number of code units, not characters. When 
-this modifier is used, the <b>use_offset_limit</b> modifier must have been set 
+The <b>offset_limit</b> modifier sets a limit for unanchored matches. If a match
+cannot be found starting at or before this offset in the subject, a "no match"
+return is given. The data value is a number of code units, not characters. When
+this modifier is used, the <b>use_offset_limit</b> modifier must have been set
 for the pattern; if not, an error is generated.
 </P>
 <br><b>
@@ -1281,8 +1318,8 @@
 Normally, <b>pcre2test</b> passes a context block to <b>pcre2_match()</b>,
 <b>pcre2_dfa_match()</b> or <b>pcre2_jit_match()</b>. If the <b>null_context</b>
 modifier is set, however, NULL is passed. This is for testing that the matching
-functions behave correctly in this case (they use default values). This 
-modifier cannot be used with the <b>find_limits</b> modifier or when testing the 
+functions behave correctly in this case (they use default values). This
+modifier cannot be used with the <b>find_limits</b> modifier or when testing the
 substitution function.
 </P>
 <br><a name="SEC12" href="#TOC1">THE ALTERNATIVE MATCHING FUNCTION</a><br>
@@ -1623,7 +1660,7 @@
 </P>
 <br><a name="SEC21" href="#TOC1">REVISION</a><br>
 <P>
-Last updated: 05 November 2015
+Last updated: 12 December 2015
 <br>
 Copyright &copy; 1997-2015 University of Cambridge.
 <br>


Modified: code/trunk/doc/html/pcre2unicode.html
===================================================================
--- code/trunk/doc/html/pcre2unicode.html    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/html/pcre2unicode.html    2015-12-17 18:44:06 UTC (rev 471)
@@ -127,8 +127,8 @@
 strings to be in host byte order.
 </P>
 <P>
-A UTF string is checked before any other processing takes place. In the case of 
-<b>pcre2_match()</b> and <b>pcre2_dfa_match()</b> calls with a non-zero starting 
+A UTF string is checked before any other processing takes place. In the case of
+<b>pcre2_match()</b> and <b>pcre2_dfa_match()</b> calls with a non-zero starting
 offset, the check is applied only to that part of the subject that could be
 inspected during matching, and there is a check that the starting offset points
 to the first code unit of a character or to the end of the subject. If there


Modified: code/trunk/doc/pcre2.3
===================================================================
--- code/trunk/doc/pcre2.3    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2.3    2015-12-17 18:44:06 UTC (rev 471)
@@ -118,9 +118,9 @@
 .P
 The use of the \eC escape sequence in a UTF-8 or UTF-16 pattern can lead to
 problems, because it may leave the current matching point in the middle of a
-multi-code-unit character. The PCRE2_NEVER_BACKSLASH_C option can be used by an 
+multi-code-unit character. The PCRE2_NEVER_BACKSLASH_C option can be used by an
 application to lock out the use of \eC, causing a compile-time error if it is
-encountered. It is also possible to build PCRE2 with the use of \eC permanently 
+encountered. It is also possible to build PCRE2 with the use of \eC permanently
 disabled.
 .P
 Another way that performance can be hit is by running a pattern that has a very


Modified: code/trunk/doc/pcre2.txt
===================================================================
--- code/trunk/doc/pcre2.txt    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2.txt    2015-12-17 18:44:06 UTC (rev 471)
@@ -169,8 +169,8 @@
        Last updated: 16 October 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2API(3)                Library Functions Manual                PCRE2API(3)



@@ -774,7 +774,7 @@

          A callout function
          The offset limit for matching an unanchored pattern
-         The limit for calling match()
+         The limit for calling match() (see below)
          The limit for calling match() recursively


        A match context is also required if you are using custom memory manage-
@@ -824,42 +824,45 @@


        The offset limit facility can be used to track progress when  searching
        large  subject  strings.  See  also  the  PCRE2_FIRSTLINE option, which
-       requires a match to start within the first line of the subject.
+       requires a match to start within the first line of the subject. If this
+       is  set  with an offset limit, a match must occur in the first line and
+       also within the offset limit.  In other words,  whichever  limit  comes
+       first is used.


        int pcre2_set_match_limit(pcre2_match_context *mcontext,
          uint32_t value);


-       The match_limit parameter provides a means  of  preventing  PCRE2  from
+       The  match_limit  parameter  provides  a means of preventing PCRE2 from
        using up too many resources when processing patterns that are not going
-       to match, but which have a very large number of possibilities in  their
-       search  trees. The classic example is a pattern that uses nested unlim-
+       to  match, but which have a very large number of possibilities in their
+       search trees. The classic example is a pattern that uses nested  unlim-
        ited repeats.


-       Internally, pcre2_match() uses a  function  called  match(),  which  it
-       calls  repeatedly (sometimes recursively). The limit set by match_limit
-       is imposed on the number of times this  function  is  called  during  a
+       Internally,  pcre2_match()  uses  a  function  called match(), which it
+       calls repeatedly (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. This limit is not
+       can  take place. For patterns that are not anchored, the count restarts
+       from zero for each position in the subject string. This  limit  is  not
        relevant to pcre2_dfa_match(), which ignores it.


-       When pcre2_match() is called with a pattern that was successfully  pro-
+       When  pcre2_match() is called with a pattern that was successfully pro-
        cessed by pcre2_jit_compile(), the way in which matching is executed is
-       entirely different. However, there is still the possibility of  runaway
-       matching  that  goes  on  for  a very long time, and so the match_limit
-       value is also used in this case (but in a different way) to  limit  how
+       entirely  different. However, there is still the possibility of runaway
+       matching that goes on for a very long  time,  and  so  the  match_limit
+       value  is  also used in this case (but in a different way) to limit how
        long the matching can continue.


-       The  default  value  for  the limit can be set when PCRE2 is built; the
-       default default is 10 million, which handles all but the  most  extreme
-       cases.    If    the    limit   is   exceeded,   pcre2_match()   returns
-       PCRE2_ERROR_MATCHLIMIT. A value for the match limit may  also  be  sup-
+       The default value for the limit can be set when  PCRE2  is  built;  the
+       default  default  is 10 million, which handles all but the most extreme
+       cases.   If   the   limit   is    exceeded,    pcre2_match()    returns
+       PCRE2_ERROR_MATCHLIMIT.  A  value  for the match limit may also be sup-
        plied by an item at the start of a pattern of the form


          (*LIMIT_MATCH=ddd)


-       where  ddd  is  a  decimal  number.  However, such a setting is ignored
-       unless ddd is less than the limit set by the  caller  of  pcre2_match()
+       where ddd is a decimal number.  However,  such  a  setting  is  ignored
+       unless  ddd  is  less than the limit set by the caller of pcre2_match()
        or, if no such limit is set, less than the default.


        int pcre2_set_recursion_limit(pcre2_match_context *mcontext,
@@ -866,27 +869,27 @@
          uint32_t value);


        The recursion_limit parameter 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-
+       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-
        sive.  This limit is of use only if it is set smaller than match_limit.


        Limiting the recursion depth limits the amount of system stack that can
-       be used, or, when PCRE2 has been compiled to use  memory  on  the  heap
-       instead  of the stack, the amount of heap memory that can be used. This
-       limit is not relevant, and is ignored, when matching is done using  JIT
+       be  used,  or,  when  PCRE2 has been compiled to use memory on the heap
+       instead of the stack, the amount of heap memory that can be used.  This
+       limit  is not relevant, and is ignored, when matching is done using JIT
        compiled code or by the pcre2_dfa_match() function.


-       The  default  value for recursion_limit can be set when PCRE2 is built;
-       the default default is the same value as the default  for  match_limit.
-       If  the limit is exceeded, pcre2_match() returns PCRE2_ERROR_RECURSION-
-       LIMIT. A value for the recursion limit may also be supplied by an  item
+       The default value for recursion_limit can be set when PCRE2  is  built;
+       the  default  default is the same value as the default for match_limit.
+       If the limit is exceeded, pcre2_match() returns  PCRE2_ERROR_RECURSION-
+       LIMIT.  A value for the recursion limit may also be supplied by an item
        at the start of a pattern of the form


          (*LIMIT_RECURSION=ddd)


-       where  ddd  is  a  decimal  number.  However, such a setting is ignored
-       unless ddd is less than the limit set by the  caller  of  pcre2_match()
+       where ddd is a decimal number.  However,  such  a  setting  is  ignored
+       unless  ddd  is  less than the limit set by the caller of pcre2_match()
        or, if no such limit is set, less than the default.


        int pcre2_set_recursion_memory_management(
@@ -895,21 +898,21 @@
          void (*private_free)(void *, void *), void *memory_data);


        This function sets up two additional custom memory management functions
-       for use by pcre2_match() when PCRE2 is compiled to  use  the  heap  for
+       for  use  by  pcre2_match()  when PCRE2 is compiled to use the heap for
        remembering backtracking data, instead of recursive function calls that
-       use the system stack. There is a discussion about PCRE2's  stack  usage
-       in  the  pcre2stack documentation. See the pcre2build documentation for
+       use  the  system stack. There is a discussion about PCRE2's stack usage
+       in the pcre2stack documentation. See the pcre2build  documentation  for
        details of how to build PCRE2.


-       Using the heap for recursion is a non-standard way of  building  PCRE2,
-       for  use  in  environments  that  have  limited  stacks. Because of the
+       Using  the  heap for recursion is a non-standard way of building PCRE2,
+       for use in environments  that  have  limited  stacks.  Because  of  the
        greater use of memory management, pcre2_match() runs more slowly. Func-
-       tions  that  are  different  to the general custom memory functions are
-       provided so that special-purpose external code can  be  used  for  this
-       case,  because  the memory blocks are all the same size. The blocks are
+       tions that are different to the general  custom  memory  functions  are
+       provided  so  that  special-purpose  external code can be used for this
+       case, because the memory blocks are all the same size. The  blocks  are
        retained by pcre2_match() until it is about to exit so that they can be
-       re-used  when  possible during the match. In the absence of these func-
-       tions, the normal custom memory management functions are used, if  sup-
+       re-used when possible during the match. In the absence of  these  func-
+       tions,  the normal custom memory management functions are used, if sup-
        plied, otherwise the system functions.



@@ -917,75 +920,75 @@

        int pcre2_config(uint32_t what, void *where);


-       The  function  pcre2_config()  makes  it possible for a PCRE2 client to
-       discover which optional features have  been  compiled  into  the  PCRE2
-       library.  The  pcre2build  documentation  has  more details about these
+       The function pcre2_config() makes it possible for  a  PCRE2  client  to
+       discover  which  optional  features  have  been compiled into the PCRE2
+       library. The pcre2build documentation  has  more  details  about  these
        optional features.


-       The first argument for pcre2_config() specifies  which  information  is
-       required.  The  second  argument  is a pointer to memory into which the
-       information is placed. If NULL is  passed,  the  function  returns  the
-       amount  of  memory  that  is  needed for the requested information. For
-       calls that return  numerical  values,  the  value  is  in  bytes;  when
-       requesting  these  values,  where should point to appropriately aligned
-       memory. For calls that return strings, the required length is given  in
+       The  first  argument  for pcre2_config() specifies which information is
+       required. The second argument is a pointer to  memory  into  which  the
+       information  is  placed.  If  NULL  is passed, the function returns the
+       amount of memory that is needed  for  the  requested  information.  For
+       calls  that  return  numerical  values,  the  value  is  in bytes; when
+       requesting these values, where should point  to  appropriately  aligned
+       memory.  For calls that return strings, the required length is given in
        code units, not counting the terminating zero.


-       When  requesting information, the returned value from pcre2_config() is
-       non-negative on success, or the negative error code  PCRE2_ERROR_BADOP-
-       TION  if the value in the first argument is not recognized. The follow-
+       When requesting information, the returned value from pcre2_config()  is
+       non-negative  on success, or the negative error code PCRE2_ERROR_BADOP-
+       TION if the value in the first argument is not recognized. The  follow-
        ing information is available:


          PCRE2_CONFIG_BSR


-       The output is a uint32_t integer whose value indicates  what  character
-       sequences  the  \R  escape  sequence  matches  by  default.  A value of
+       The  output  is a uint32_t integer whose value indicates what character
+       sequences the \R  escape  sequence  matches  by  default.  A  value  of
        PCRE2_BSR_UNICODE  means  that  \R  matches  any  Unicode  line  ending
-       sequence;  a  value of PCRE2_BSR_ANYCRLF means that \R matches only CR,
+       sequence; a value of PCRE2_BSR_ANYCRLF means that \R matches  only  CR,
        LF, or CRLF. The default can be overridden when a pattern is compiled.


          PCRE2_CONFIG_JIT


-       The output is a uint32_t integer that is set  to  one  if  support  for
+       The  output  is  a  uint32_t  integer that is set to one if support for
        just-in-time compiling is available; otherwise it is set to zero.


          PCRE2_CONFIG_JITTARGET


-       The  where  argument  should point to a buffer that is at least 48 code
-       units long.  (The  exact  length  required  can  be  found  by  calling
-       pcre2_config()  with  where  set  to NULL.) The buffer is filled with a
-       string that contains the name of the architecture  for  which  the  JIT
-       compiler  is  configured,  for  example  "x86  32bit  (little  endian +
-       unaligned)". If JIT support is not available, PCRE2_ERROR_BADOPTION  is
-       returned,  otherwise the number of code units used is returned. This is
+       The where argument should point to a buffer that is at  least  48  code
+       units  long.  (The  exact  length  required  can  be  found  by calling
+       pcre2_config() with where set to NULL.) The buffer  is  filled  with  a
+       string  that  contains  the  name of the architecture for which the JIT
+       compiler is  configured,  for  example  "x86  32bit  (little  endian  +
+       unaligned)".  If JIT support is not available, PCRE2_ERROR_BADOPTION is
+       returned, otherwise the number of code units used is returned. This  is
        the length of the string, plus one unit for the terminating zero.


          PCRE2_CONFIG_LINKSIZE


        The output is a uint32_t integer that contains the number of bytes used
-       for  internal  linkage  in  compiled regular expressions. When PCRE2 is
-       configured, the value can be set to 2, 3, or 4, with the default  being
-       2.  This is the value that is returned by pcre2_config(). However, when
-       the 16-bit library is compiled, a value of 3 is rounded up  to  4,  and
-       when  the  32-bit  library  is compiled, internal linkages always use 4
+       for internal linkage in compiled regular  expressions.  When  PCRE2  is
+       configured,  the value can be set to 2, 3, or 4, with the default being
+       2. This is the value that is returned by pcre2_config(). However,  when
+       the  16-bit  library  is compiled, a value of 3 is rounded up to 4, and
+       when the 32-bit library is compiled, internal  linkages  always  use  4
        bytes, so the configured value is not relevant.


        The default value of 2 for the 8-bit and 16-bit libraries is sufficient
-       for  all but the most massive patterns, since it allows the size of the
+       for all but the most massive patterns, since it allows the size of  the
        compiled pattern to be up to 64K code units. Larger values allow larger
-       regular  expressions  to be compiled by those two libraries, but at the
+       regular expressions to be compiled by those two libraries, but  at  the
        expense of slower matching.


          PCRE2_CONFIG_MATCHLIMIT


-       The output is a uint32_t integer that gives the default limit  for  the
-       number  of  internal  matching function calls in a pcre2_match() execu-
+       The  output  is a uint32_t integer that gives the default limit for the
+       number of internal matching function calls in  a  pcre2_match()  execu-
        tion. Further details are given with pcre2_match() below.


          PCRE2_CONFIG_NEWLINE


-       The output is a uint32_t integer  whose  value  specifies  the  default
-       character  sequence that is recognized as meaning "newline". The values
+       The  output  is  a  uint32_t  integer whose value specifies the default
+       character sequence that is recognized as meaning "newline". The  values
        are:


          PCRE2_NEWLINE_CR       Carriage return (CR)
@@ -994,56 +997,56 @@
          PCRE2_NEWLINE_ANY      Any Unicode line ending
          PCRE2_NEWLINE_ANYCRLF  Any of CR, LF, or CRLF


-       The default should normally correspond to  the  standard  sequence  for
+       The  default  should  normally  correspond to the standard sequence for
        your operating system.


          PCRE2_CONFIG_PARENSLIMIT


-       The  output is a uint32_t integer that gives the maximum depth of nest-
+       The output is a uint32_t integer that gives the maximum depth of  nest-
        ing of parentheses (of any kind) in a pattern. This limit is imposed to
-       cap  the  amount of system stack used when a pattern is compiled. It is
-       specified when PCRE2 is built; the default is 250. This limit does  not
-       take  into  account  the  stack that may already be used by the calling
-       application. For  finer  control  over  compilation  stack  usage,  see
+       cap the amount of system stack used when a pattern is compiled.  It  is
+       specified  when PCRE2 is built; the default is 250. This limit does not
+       take into account the stack that may already be  used  by  the  calling
+       application.  For  finer  control  over  compilation  stack  usage, see
        pcre2_set_compile_recursion_guard().


          PCRE2_CONFIG_RECURSIONLIMIT


-       The  output  is a uint32_t integer that gives the default limit for the
-       depth of recursion when calling the internal  matching  function  in  a
-       pcre2_match()  execution.  Further details are given with pcre2_match()
+       The output is a uint32_t integer that gives the default limit  for  the
+       depth  of  recursion  when  calling the internal matching function in a
+       pcre2_match() execution. Further details are given  with  pcre2_match()
        below.


          PCRE2_CONFIG_STACKRECURSE


-       The output is a uint32_t integer that is set to one if internal  recur-
-       sion  when  running  pcre2_match() is implemented by recursive function
-       calls that use the system stack to remember their state.  This  is  the
-       usual  way that PCRE2 is compiled. The output is zero if PCRE2 was com-
-       piled to use blocks of data on the heap instead of  recursive  function
+       The  output is a uint32_t integer that is set to one if internal recur-
+       sion when running pcre2_match() is implemented  by  recursive  function
+       calls  that  use  the system stack to remember their state. This is the
+       usual way that PCRE2 is compiled. The output is zero if PCRE2 was  com-
+       piled  to  use blocks of data on the heap instead of recursive function
        calls.


          PCRE2_CONFIG_UNICODE_VERSION


-       The  where  argument  should point to a buffer that is at least 24 code
-       units long.  (The  exact  length  required  can  be  found  by  calling
-       pcre2_config()  with  where  set  to  NULL.) If PCRE2 has been compiled
-       without Unicode support, the buffer is filled with  the  text  "Unicode
-       not  supported".  Otherwise,  the  Unicode version string (for example,
-       "8.0.0") is inserted. The number of code units used is  returned.  This
+       The where argument should point to a buffer that is at  least  24  code
+       units  long.  (The  exact  length  required  can  be  found  by calling
+       pcre2_config() with where set to NULL.)  If  PCRE2  has  been  compiled
+       without  Unicode  support,  the buffer is filled with the text "Unicode
+       not supported". Otherwise, the Unicode  version  string  (for  example,
+       "8.0.0")  is  inserted. The number of code units used is returned. This
        is the length of the string plus one unit for the terminating zero.


          PCRE2_CONFIG_UNICODE


-       The  output is a uint32_t integer that is set to one if Unicode support
-       is available; otherwise it is set to zero. Unicode support implies  UTF
+       The output is a uint32_t integer that is set to one if Unicode  support
+       is  available; otherwise it is set to zero. Unicode support implies UTF
        support.


          PCRE2_CONFIG_VERSION


-       The  where  argument  should point to a buffer that is at least 12 code
-       units long.  (The  exact  length  required  can  be  found  by  calling
-       pcre2_config()  with  where set to NULL.) The buffer is filled with the
+       The where argument should point to a buffer that is at  least  12  code
+       units  long.  (The  exact  length  required  can  be  found  by calling
+       pcre2_config() with where set to NULL.) The buffer is filled  with  the
        PCRE2 version string, zero-terminated. The number of code units used is
        returned. This is the length of the string plus one unit for the termi-
        nating zero.
@@ -1057,58 +1060,58 @@


        void pcre2_code_free(pcre2_code *code);


-       The pcre2_compile() function compiles a pattern into an internal  form.
-       The  pattern  is  defined  by a pointer to a string of code units and a
-       length, If the pattern is zero-terminated, the length can be  specified
-       as  PCRE2_ZERO_TERMINATED. The function returns a pointer to a block of
-       memory that contains the compiled pattern and related data. The  caller
-       must  free the memory by calling pcre2_code_free() when it is no longer
+       The  pcre2_compile() function compiles a pattern into an internal form.
+       The pattern is defined by a pointer to a string of  code  units  and  a
+       length,  If the pattern is zero-terminated, the length can be specified
+       as PCRE2_ZERO_TERMINATED. The function returns a pointer to a block  of
+       memory  that contains the compiled pattern and related data. The caller
+       must free the memory by calling pcre2_code_free() when it is no  longer
        needed.


-       NOTE: When one of the matching functions is  called,  pointers  to  the
+       NOTE:  When  one  of  the matching functions is called, pointers to the
        compiled pattern and the subject string are set in the match data block
-       so that they can be referenced by the extraction functions. After  run-
-       ning  a  match,  you  must  not  free  a compiled pattern (or a subject
-       string) until after all operations on the match data block  have  taken
+       so  that they can be referenced by the extraction functions. After run-
+       ning a match, you must not  free  a  compiled  pattern  (or  a  subject
+       string)  until  after all operations on the match data block have taken
        place.


-       If  the  compile context argument ccontext is NULL, memory for the com-
-       piled pattern  is  obtained  by  calling  malloc().  Otherwise,  it  is
-       obtained  from  the  same memory function that was used for the compile
+       If the compile context argument ccontext is NULL, memory for  the  com-
+       piled  pattern  is  obtained  by  calling  malloc().  Otherwise,  it is
+       obtained from the same memory function that was used  for  the  compile
        context.


        The options argument contains various bit settings that affect the com-
-       pilation.  It  should be zero if no options are required. The available
-       options are described below. Some of them (in  particular,  those  that
-       are  compatible with Perl, but some others as well) can also be set and
-       unset from within the pattern (see  the  detailed  description  in  the
+       pilation. It should be zero if no options are required.  The  available
+       options  are  described  below. Some of them (in particular, those that
+       are compatible with Perl, but some others as well) can also be set  and
+       unset  from  within  the  pattern  (see the detailed description in the
        pcre2pattern documentation).


-       For  those options that can be different in different parts of the pat-
-       tern, the contents of the options argument specifies their settings  at
-       the  start  of  compilation.  The PCRE2_ANCHORED and PCRE2_NO_UTF_CHECK
+       For those options that can be different in different parts of the  pat-
+       tern,  the contents of the options argument specifies their settings at
+       the start of compilation.  The  PCRE2_ANCHORED  and  PCRE2_NO_UTF_CHECK
        options can be set at the time of matching as well as at compile time.


-       Other, less frequently required compile-time parameters  (for  example,
+       Other,  less  frequently required compile-time parameters (for example,
        the newline setting) can be provided in a compile context (as described
        above).


        If errorcode or erroroffset is NULL, pcre2_compile() returns NULL imme-
-       diately.  Otherwise, if compilation of a pattern fails, pcre2_compile()
+       diately. Otherwise, if compilation of a pattern fails,  pcre2_compile()
        returns NULL, having set these variables to an error code and an offset
-       (number   of   code   units)  within  the  pattern,  respectively.  The
-       pcre2_get_error_message() function provides a textual message for  each
+       (number  of  code  units)  within  the   pattern,   respectively.   The
+       pcre2_get_error_message()  function provides a textual message for each
        error code. Compilation errors are positive numbers, but UTF formatting
        errors are negative numbers. For an invalid UTF-8 or UTF-16 string, the
        offset is that of the first code unit of the failing character.


-       Some  errors are not detected until the whole pattern has been scanned;
-       in these cases, the offset passed back is the length  of  the  pattern.
-       Note  that  the  offset is in code units, not characters, even in a UTF
+       Some errors are not detected until the whole pattern has been  scanned;
+       in  these  cases,  the offset passed back is the length of the pattern.
+       Note that the offset is in code units, not characters, even  in  a  UTF
        mode. It may sometimes point into the middle of a UTF-8 or UTF-16 char-
        acter.


-       This  code  fragment shows a typical straightforward call to pcre2_com-
+       This code fragment shows a typical straightforward call  to  pcre2_com-
        pile():


          pcre2_code *re;
@@ -1122,28 +1125,28 @@
            &erroffset,             /* for error offset */
            NULL);                  /* no compile context */


-       The following names for option bits are defined in the  pcre2.h  header
+       The  following  names for option bits are defined in the pcre2.h header
        file:


          PCRE2_ANCHORED


        If this bit is set, the pattern is forced to be "anchored", that is, it
-       is constrained to match only at the first matching point in the  string
-       that  is being searched (the "subject string"). This effect can also be
-       achieved by appropriate constructs in the pattern itself, which is  the
+       is  constrained to match only at the first matching point in the string
+       that is being searched (the "subject string"). This effect can also  be
+       achieved  by appropriate constructs in the pattern itself, which is the
        only way to do it in Perl.


          PCRE2_ALLOW_EMPTY_CLASS


-       By  default, for compatibility with Perl, a closing square bracket that
-       immediately follows an opening one is treated as a data  character  for
-       the  class.  When  PCRE2_ALLOW_EMPTY_CLASS  is  set,  it terminates the
+       By default, for compatibility with Perl, a closing square bracket  that
+       immediately  follows  an opening one is treated as a data character for
+       the class. When  PCRE2_ALLOW_EMPTY_CLASS  is  set,  it  terminates  the
        class, which therefore contains no characters and so can never match.


          PCRE2_ALT_BSUX


-       This option request alternative handling  of  three  escape  sequences,
-       which  makes  PCRE2's  behaviour more like ECMAscript (aka JavaScript).
+       This  option  request  alternative  handling of three escape sequences,
+       which makes PCRE2's behaviour more like  ECMAscript  (aka  JavaScript).
        When it is set:


        (1) \U matches an upper case "U" character; by default \U causes a com-
@@ -1150,13 +1153,13 @@
        pile time error (Perl uses \U to upper case subsequent characters).


        (2) \u matches a lower case "u" character unless it is followed by four
-       hexadecimal digits, in which case the hexadecimal  number  defines  the
-       code  point  to match. By default, \u causes a compile time error (Perl
+       hexadecimal  digits,  in  which case the hexadecimal number defines the
+       code point to match. By default, \u causes a compile time  error  (Perl
        uses it to upper case the following character).


-       (3) \x matches a lower case "x" character unless it is followed by  two
-       hexadecimal  digits,  in  which case the hexadecimal number defines the
-       code point to match. By default, as in Perl, a  hexadecimal  number  is
+       (3)  \x matches a lower case "x" character unless it is followed by two
+       hexadecimal digits, in which case the hexadecimal  number  defines  the
+       code  point  to  match. By default, as in Perl, a hexadecimal number is
        always expected after \x, but it may have zero, one, or two digits (so,
        for example, \xz matches a binary zero character followed by z).


@@ -1163,53 +1166,53 @@
          PCRE2_ALT_CIRCUMFLEX


        In  multiline  mode  (when  PCRE2_MULTILINE  is  set),  the  circumflex
-       metacharacter  matches at the start of the subject (unless PCRE2_NOTBOL
-       is set), and also after any internal  newline.  However,  it  does  not
+       metacharacter matches at the start of the subject (unless  PCRE2_NOTBOL
+       is  set),  and  also  after  any internal newline. However, it does not
        match after a newline at the end of the subject, for compatibility with
-       Perl. If you want a multiline circumflex also to match after  a  termi-
+       Perl.  If  you want a multiline circumflex also to match after a termi-
        nating newline, you must set PCRE2_ALT_CIRCUMFLEX.


          PCRE2_ALT_VERBNAMES


-       By  default, for compatibility with Perl, the name in any verb sequence
-       such as (*MARK:NAME) is  any  sequence  of  characters  that  does  not
-       include  a  closing  parenthesis. The name is not processed in any way,
-       and it is not possible to include a closing parenthesis  in  the  name.
-       However,  if  the  PCRE2_ALT_VERBNAMES  option is set, normal backslash
-       processing is applied to verb  names  and  only  an  unescaped  closing
-       parenthesis  terminates the name. A closing parenthesis can be included
-       in a name either as \) or between \Q  and  \E.  If  the  PCRE2_EXTENDED
+       By default, for compatibility with Perl, the name in any verb  sequence
+       such  as  (*MARK:NAME)  is  any  sequence  of  characters that does not
+       include a closing parenthesis. The name is not processed  in  any  way,
+       and  it  is  not possible to include a closing parenthesis in the name.
+       However, if the PCRE2_ALT_VERBNAMES option  is  set,  normal  backslash
+       processing  is  applied  to  verb  names  and only an unescaped closing
+       parenthesis terminates the name. A closing parenthesis can be  included
+       in  a  name  either  as  \) or between \Q and \E. If the PCRE2_EXTENDED
        option is set, unescaped whitespace in verb names is skipped and #-com-
        ments are recognized, exactly as in the rest of the pattern.


          PCRE2_AUTO_CALLOUT


-       If this bit  is  set,  pcre2_compile()  automatically  inserts  callout
+       If  this  bit  is  set,  pcre2_compile()  automatically inserts callout
        items, all with number 255, before each pattern item. For discussion of
        the callout facility, see the pcre2callout documentation.


          PCRE2_CASELESS


-       If this bit is set, letters in the pattern match both upper  and  lower
-       case  letters in the subject. It is equivalent to Perl's /i option, and
+       If  this  bit is set, letters in the pattern match both upper and lower
+       case letters in the subject. It is equivalent to Perl's /i option,  and
        it can be changed within a pattern by a (?i) option setting.


          PCRE2_DOLLAR_ENDONLY


-       If this bit is set, a dollar metacharacter in the pattern matches  only
-       at  the  end  of the subject string. Without this option, a dollar also
-       matches immediately before a newline at the end of the string (but  not
-       before  any other newlines). The PCRE2_DOLLAR_ENDONLY option is ignored
-       if PCRE2_MULTILINE is set. There is no equivalent  to  this  option  in
+       If  this bit is set, a dollar metacharacter in the pattern matches only
+       at the end of the subject string. Without this option,  a  dollar  also
+       matches  immediately before a newline at the end of the string (but not
+       before any other newlines). The PCRE2_DOLLAR_ENDONLY option is  ignored
+       if  PCRE2_MULTILINE  is  set.  There is no equivalent to this option in
        Perl, and no way to set it within a pattern.


          PCRE2_DOTALL


-       If  this  bit  is  set,  a dot metacharacter in the pattern matches any
-       character, including one that indicates a  newline.  However,  it  only
+       If this bit is set, a dot metacharacter  in  the  pattern  matches  any
+       character,  including  one  that  indicates a newline. However, it only
        ever matches one character, even if newlines are coded as CRLF. Without
        this option, a dot does not match when the current position in the sub-
-       ject  is  at  a newline. This option is equivalent to Perl's /s option,
+       ject is at a newline. This option is equivalent to  Perl's  /s  option,
        and it can be changed within a pattern by a (?s) option setting. A neg-
        ative class such as [^a] always matches newline characters, independent
        of the setting of this option.
@@ -1216,42 +1219,45 @@


          PCRE2_DUPNAMES


-       If this bit is set, names used to identify capturing  subpatterns  need
+       If  this  bit is set, names used to identify capturing subpatterns need
        not be unique. This can be helpful for certain types of pattern when it
-       is known that only one instance of the named  subpattern  can  ever  be
-       matched.  There  are  more details of named subpatterns below; see also
+       is  known  that  only  one instance of the named subpattern can ever be
+       matched. There are more details of named subpatterns  below;  see  also
        the pcre2pattern documentation.


          PCRE2_EXTENDED


-       If this bit is set, most white space  characters  in  the  pattern  are
-       totally  ignored  except when escaped or inside a character class. How-
-       ever, white space is not allowed within  sequences  such  as  (?>  that
+       If  this  bit  is  set,  most white space characters in the pattern are
+       totally ignored except when escaped or inside a character  class.  How-
+       ever,  white  space  is  not  allowed within sequences such as (?> that
        introduce various parenthesized subpatterns, nor within numerical quan-
-       tifiers such as {1,3}.  Ignorable white space is permitted  between  an
-       item  and a following quantifier and between a quantifier and a follow-
+       tifiers  such  as {1,3}.  Ignorable white space is permitted between an
+       item and a following quantifier and between a quantifier and a  follow-
        ing + that indicates possessiveness.


-       PCRE2_EXTENDED also causes characters between an unescaped # outside  a
-       character  class  and the next newline, inclusive, to be ignored, which
+       PCRE2_EXTENDED  also causes characters between an unescaped # outside a
+       character class and the next newline, inclusive, to be  ignored,  which
        makes it possible to include comments inside complicated patterns. Note
-       that  the  end of this type of comment is a literal newline sequence in
+       that the end of this type of comment is a literal newline  sequence  in
        the pattern; escape sequences that happen to represent a newline do not
-       count.  PCRE2_EXTENDED is equivalent to Perl's /x option, and it can be
+       count. PCRE2_EXTENDED is equivalent to Perl's /x option, and it can  be
        changed within a pattern by a (?x) option setting.


        Which characters are interpreted as newlines can be specified by a set-
-       ting  in  the compile context that is passed to pcre2_compile() or by a
-       special sequence at the start of the pattern, as described in the  sec-
-       tion  entitled "Newline conventions" in the pcre2pattern documentation.
+       ting in the compile context that is passed to pcre2_compile() or  by  a
+       special  sequence at the start of the pattern, as described in the sec-
+       tion entitled "Newline conventions" in the pcre2pattern  documentation.
        A default is defined when PCRE2 is built.


          PCRE2_FIRSTLINE


-       If this option is set, an  unanchored  pattern  is  required  to  match
-       before  or  at  the  first  newline  in  the subject string, though the
-       matched text may continue over the  newline.  See  also  PCRE2_USE_OFF-
-       SET_LIMIT, which provides a more general limiting facility.
+       If  this  option  is  set,  an  unanchored pattern is required to match
+       before or at the first  newline  in  the  subject  string,  though  the
+       matched  text  may  continue  over the newline. See also PCRE2_USE_OFF-
+       SET_LIMIT,  which  provides  a  more  general  limiting  facility.   If
+       PCRE2_FIRSTLINE  is set with an offset limit, a match must occur in the
+       first line and also within the offset limit. In other words,  whichever
+       limit comes first is used.


          PCRE2_MATCH_UNSET_BACKREF


@@ -1590,11 +1596,9 @@
        to  a  uint32_t  variable.  PCRE2_INFO_ARGOPTIONS  returns  exactly the
        options that were passed to pcre2_compile(), whereas  PCRE2_INFO_ALLOP-
        TIONS  returns  the compile options as modified by any top-level option
-       settings at the start of the pattern itself. In other words,  they  are
-       the options that will be in force when matching starts. For example, if
-       the  pattern  /(?im)abc(?-i)d/  is  compiled  with  the  PCRE2_EXTENDED
-       option,    the   result   is   PCRE2_CASELESS,   PCRE2_MULTILINE,   and
-       PCRE2_EXTENDED.
+       settings such as (*UTF) at the start of the pattern itself.  For  exam-
+       ple,  if  the  pattern  /(*UTF)abc/ is compiled with the PCRE2_EXTENDED
+       option, the result is PCRE2_EXTENDED and PCRE2_UTF.


        A pattern compiled without PCRE2_ANCHORED is automatically anchored  by
        PCRE2 if the first significant item in every top-level branch is one of
@@ -1638,20 +1642,30 @@


          PCRE2_INFO_CAPTURECOUNT


-       Return the number of capturing subpatterns in the  pattern.  The  third
-       argument should point to an uint32_t variable.
+       Return the highest capturing subpattern number in the pattern. In  pat-
+       terns where (?| is not used, this is also the total number of capturing
+       subpatterns.  The third argument should point to an uint32_t variable.


+         PCRE2_INFO_FIRSTBITMAP
+
+       In the absence of a single first code unit for a non-anchored  pattern,
+       pcre2_compile()  may construct a 256-bit table that defines a fixed set
+       of values for the first code unit in any match. For example, a  pattern
+       that  starts  with  [abc]  results in a table with three bits set. When
+       code unit values greater than 255 are supported, the flag bit  for  255
+       means  "any  code unit of value 255 or above". If such a table was con-
+       structed, a pointer to it is returned. Otherwise NULL is returned.  The
+       third argument should point to an const uint8_t * variable.
+
          PCRE2_INFO_FIRSTCODETYPE


        Return information about the first code unit of any matched string, for
        a non-anchored pattern. The third argument should point to an  uint32_t
-       variable.
-
-       If  there  is  a  fixed first value, for example, the letter "c" from a
-       pattern such as (cat|cow|coyote), 1  is  returned,  and  the  character
-       value  can  be retrieved using PCRE2_INFO_FIRSTCODEUNIT. If there is no
-       fixed first value, but it is known that a match can occur only  at  the
-       start  of  the  subject  or  following  a  newline in the subject, 2 is
+       variable.  If there is a fixed first value, for example, the letter "c"
+       from a pattern such as (cat|cow|coyote), 1 is returned, and the charac-
+       ter  value can be retrieved using PCRE2_INFO_FIRSTCODEUNIT. If there is
+       no fixed first value, but it is known that a match can  occur  only  at
+       the  start  of  the subject or following a newline in the subject, 2 is
        returned. Otherwise, and for anchored patterns, 0 is returned.


          PCRE2_INFO_FIRSTCODEUNIT
@@ -1664,16 +1678,10 @@
        value can be up to 0x10ffff, and up to 0xffffffff when not using UTF-32
        mode.


-         PCRE2_INFO_FIRSTBITMAP
+         PCRE2_INFO_HASBACKSLASHC


-       In the absence of a single first code unit for a non-anchored  pattern,
-       pcre2_compile()  may construct a 256-bit table that defines a fixed set
-       of values for the first code unit in any match. For example, a  pattern
-       that  starts  with  [abc]  results in a table with three bits set. When
-       code unit values greater than 255 are supported, the flag bit  for  255
-       means  "any  code unit of value 255 or above". If such a table was con-
-       structed, a pointer to it is returned. Otherwise NULL is returned.  The
-       third argument should point to an const uint8_t * variable.
+       Return 1 if the pattern contains any instances of \C, otherwise 0.  The
+       third argument should point to an uint32_t variable.


          PCRE2_INFO_HASCRORLF


@@ -1701,24 +1709,26 @@
        any matched string, other than at its start. The third argument  should
        point  to  an  uint32_t  variable.  If  there  is  no  such value, 0 is
        returned. When 1 is  returned,  the  code  unit  value  itself  can  be
-       retrieved using PCRE2_INFO_LASTCODEUNIT.
+       retrieved  using PCRE2_INFO_LASTCODEUNIT. For anchored patterns, a last
+       literal value is recorded only if  it  follows  something  of  variable
+       length.  For example, for the pattern /^a\d+z\d+/ the returned value is
+       1 (with "z" returned from PCRE2_INFO_LASTCODEUNIT), but  for  /^a\dz\d/
+       the returned value is 0.


-       For anchored patterns, a last literal value is recorded only if it fol-
-       lows something  of  variable  length.  For  example,  for  the  pattern
-       /^a\d+z\d+/   the   returned   value  is  1  (with  "z"  returned  from
-       PCRE2_INFO_LASTCODEUNIT), but for /^a\dz\d/ the returned value is 0.
-
          PCRE2_INFO_LASTCODEUNIT


-       Return the value of the rightmost literal data unit that must exist  in
-       any  matched  string, other than at its start, if such a value has been
-       recorded. The third argument should point to an uint32_t  variable.  If
+       Return  the value of the rightmost literal data unit that must exist in
+       any matched string, other than at its start, if such a value  has  been
+       recorded.  The  third argument should point to an uint32_t variable. If
        there is no such value, 0 is returned.


          PCRE2_INFO_MATCHEMPTY


-       Return  1  if  the  pattern can match an empty string, otherwise 0. The
-       third argument should point to an uint32_t variable.
+       Return 1 if the pattern might match an empty string, otherwise  0.  The
+       third  argument  should  point  to an uint32_t variable. When a pattern
+       contains recursive subroutine calls it is not always possible to deter-
+       mine  whether  or  not it can match an empty string. PCRE2 takes a cau-
+       tious approach and returns 1 in such cases.


          PCRE2_INFO_MATCHLIMIT


@@ -2142,32 +2152,35 @@

        When  PCRE2 is built, a default newline convention is set; this is usu-
        ally the standard convention for the operating system. The default  can
-       be  overridden  in  a  compile  context.   During matching, the newline
-       choice affects  the  behaviour  of  the  dot,  circumflex,  and  dollar
-       metacharacters.  It  may also alter the way the match starting position
-       is advanced after a match failure for an unanchored pattern.
+       be  overridden  in a compile context by calling pcre2_set_newline(). It
+       can also be overridden by starting a pattern string with, for  example,
+       (*CRLF),  as  described  in  the  section on newline conventions in the
+       pcre2pattern page. During matching, the newline choice affects the  be-
+       haviour  of the dot, circumflex, and dollar metacharacters. It may also
+       alter the way the match starting position is  advanced  after  a  match
+       failure for an unanchored pattern.


        When PCRE2_NEWLINE_CRLF, PCRE2_NEWLINE_ANYCRLF, or PCRE2_NEWLINE_ANY is
-       set  as  the  newline convention, and a match attempt for an unanchored
+       set as the newline convention, and a match attempt  for  an  unanchored
        pattern fails when the current starting position is at a CRLF sequence,
-       and  the  pattern contains no explicit matches for CR or LF characters,
-       the match position is advanced by two characters  instead  of  one,  in
+       and the pattern contains no explicit matches for CR or  LF  characters,
+       the  match  position  is  advanced by two characters instead of one, in
        other words, to after the CRLF.


        The above rule is a compromise that makes the most common cases work as
-       expected. For example, if the pattern  is  .+A  (and  the  PCRE2_DOTALL
+       expected.  For  example,  if  the  pattern is .+A (and the PCRE2_DOTALL
        option is not set), it does not match the string "\r\nA" because, after
-       failing at the start, it skips both the CR and the LF before  retrying.
-       However,  the  pattern  [\r\n]A does match that string, because it con-
+       failing  at the start, it skips both the CR and the LF before retrying.
+       However, the pattern [\r\n]A does match that string,  because  it  con-
        tains an explicit CR or LF reference, and so advances only by one char-
        acter after the first failure.


        An explicit match for CR of LF is either a literal appearance of one of
-       those characters in the  pattern,  or  one  of  the  \r  or  \n  escape
-       sequences.  Implicit  matches  such  as [^X] do not count, nor does \s,
+       those  characters  in  the  pattern,  or  one  of  the  \r or \n escape
+       sequences. Implicit matches such as [^X] do not  count,  nor  does  \s,
        even though it includes CR and LF in the characters that it matches.


-       Notwithstanding the above, anomalous effects may still occur when  CRLF
+       Notwithstanding  the above, anomalous effects may still occur when CRLF
        is a valid newline sequence and explicit \r or \n escapes appear in the
        pattern.


@@ -2178,25 +2191,26 @@

        PCRE2_SIZE *pcre2_get_ovector_pointer(pcre2_match_data *match_data);


-       In general, a pattern matches a certain portion of the subject, and  in
-       addition,  further  substrings  from  the  subject may be picked out by
-       parenthesized parts of the pattern.  Following  the  usage  in  Jeffrey
-       Friedl's  book,  this  is  called  "capturing" in what follows, and the
-       phrase "capturing subpattern" or "capturing group" is used for a  frag-
-       ment  of  a  pattern that picks out a substring. PCRE2 supports several
+       In  general, a pattern matches a certain portion of the subject, and in
+       addition, further substrings from the subject  may  be  picked  out  by
+       parenthesized  parts  of  the  pattern.  Following the usage in Jeffrey
+       Friedl's book, this is called "capturing"  in  what  follows,  and  the
+       phrase  "capturing subpattern" or "capturing group" is used for a frag-
+       ment of a pattern that picks out a substring.  PCRE2  supports  several
        other kinds of parenthesized subpattern that do not cause substrings to
-       be  captured. The pcre2_pattern_info() function can be used to find out
+       be captured. The pcre2_pattern_info() function can be used to find  out
        how many capturing subpatterns there are in a compiled pattern.


-       A successful match returns the overall matched string and any  captured
-       substrings  to  the  caller  via a vector of PCRE2_SIZE values. This is
-       called the ovector, and is contained within the match data block.   You
-       can  obtain  direct  access  to  the ovector by calling pcre2_get_ovec-
-       tor_pointer() to find its  address,  and  pcre2_get_ovector_count()  to
-       find  the number of pairs of values it contains. Alternatively, you can
-       use the auxiliary functions for accessing captured substrings by number
-       or by name (see below).
+       You  can  use  auxiliary functions for accessing captured substrings by
+       number or by name, as described in sections below.


+       Alternatively, you can make direct use of the vector of PCRE2_SIZE val-
+       ues,  called  the  ovector,  which  contains  the  offsets  of captured
+       strings.  It  is  part  of  the  match  data   block.    The   function
+       pcre2_get_ovector_pointer()  returns  the  address  of the ovector, and
+       pcre2_get_ovector_count() returns the number of pairs of values it con-
+       tains.
+
        Within the ovector, the first in each pair of values is set to the off-
        set of the first code unit of a substring, and the second is set to the
        offset  of the first code unit after the end of a substring. These val-
@@ -2274,28 +2288,33 @@
        failure to match (PCRE2_ERROR_NOMATCH), a (*MARK) name  may  be  avail-
        able,  and  pcre2_get_mark() can be called. It returns a pointer to the
        zero-terminated name, which is within the compiled  pattern.  Otherwise
-       NULL  is  returned.  After a successful match, the (*MARK) name that is
-       returned is the last one encountered on the matching path  through  the
-       pattern.  After  a  "no match" or a partial match, the last encountered
-       (*MARK) name is returned. For example, consider this pattern:
+       NULL  is returned. The length of the (*MARK) name (excluding the termi-
+       nating zero) is stored in the code unit that  preceeds  the  name.  You
+       should  use  this  instead  of  relying  on the terminating zero if the
+       (*MARK) name might contain a binary zero.


+       After a successful match, the (*MARK) name that is returned is the last
+       one  encountered  on the matching path through the pattern. After a "no
+       match" or a  partial  match,  the  last  encountered  (*MARK)  name  is
+       returned. For example, consider this pattern:
+
          ^(*MARK:A)((*MARK:B)a|b)c


-       When it matches "bc", the returned mark is A. The B mark is  "seen"  in
-       the  first  branch of the group, but it is not on the matching path. On
-       the other hand, when this pattern fails to  match  "bx",  the  returned
+       When  it  matches "bc", the returned mark is A. The B mark is "seen" in
+       the first branch of the group, but it is not on the matching  path.  On
+       the  other  hand,  when  this pattern fails to match "bx", the returned
        mark is B.


-       After  a  successful  match, a partial match, or one of the invalid UTF
-       errors (for example, PCRE2_ERROR_UTF8_ERR5), pcre2_get_startchar()  can
+       After a successful match, a partial match, or one of  the  invalid  UTF
+       errors  (for example, PCRE2_ERROR_UTF8_ERR5), pcre2_get_startchar() can
        be called. After a successful or partial match it returns the code unit
-       offset of the character at which the match started. For  a  non-partial
-       match,  this can be different to the value of ovector[0] if the pattern
-       contains the \K escape sequence. After a partial match,  however,  this
-       value  is  always the same as ovector[0] because \K does not affect the
+       offset  of  the character at which the match started. For a non-partial
+       match, this can be different to the value of ovector[0] if the  pattern
+       contains  the  \K escape sequence. After a partial match, however, this
+       value is always the same as ovector[0] because \K does not  affect  the
        result of a partial match.


-       After a UTF check failure, pcre2_get_startchar() can be used to  obtain
+       After  a UTF check failure, pcre2_get_startchar() can be used to obtain
        the code unit offset of the invalid UTF character. Details are given in
        the pcre2unicode page.


@@ -2302,12 +2321,12 @@

ERROR RETURNS FROM pcre2_match()

-       If pcre2_match() fails, it returns a negative number. This can be  con-
-       verted  to a text string by calling pcre2_get_error_message(). Negative
-       error codes are also returned by other functions,  and  are  documented
+       If  pcre2_match() fails, it returns a negative number. This can be con-
+       verted to a text string by calling pcre2_get_error_message().  Negative
+       error  codes  are  also returned by other functions, and are documented
        with them.  The codes are given names in the header file. If UTF check-
        ing is in force and an invalid UTF subject string is detected, one of a
-       number  of  UTF-specific  negative error codes is returned. Details are
+       number of UTF-specific negative error codes is  returned.  Details  are
        given in the pcre2unicode page. The following are the other errors that
        may be returned by pcre2_match():


@@ -2317,19 +2336,19 @@

          PCRE2_ERROR_PARTIAL


-       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
        pcre2partial documentation for details of partial matching.


          PCRE2_ERROR_BADMAGIC


        PCRE2 stores a 4-byte "magic number" at the start of the compiled code,
-       to  catch  the case when it is passed a junk pointer. This is the error
+       to catch the case when it is passed a junk pointer. This is  the  error
        that is returned when the magic number is not present.


          PCRE2_ERROR_BADMODE


-       This error is given when a pattern  that  was  compiled  by  the  8-bit
-       library  is  passed  to  a  16-bit  or 32-bit library function, or vice
+       This  error  is  given  when  a  pattern that was compiled by the 8-bit
+       library is passed to a 16-bit  or  32-bit  library  function,  or  vice
        versa.


          PCRE2_ERROR_BADOFFSET
@@ -2343,35 +2362,35 @@
          PCRE2_ERROR_BADUTFOFFSET


        The UTF code unit sequence that was passed as a subject was checked and
-       found  to be valid (the PCRE2_NO_UTF_CHECK option was not set), but the
-       value of startoffset did not point to the beginning of a UTF  character
+       found to be valid (the PCRE2_NO_UTF_CHECK option was not set), but  the
+       value  of startoffset did not point to the beginning of a UTF character
        or the end of the subject.


          PCRE2_ERROR_CALLOUT


-       This  error  is never generated by pcre2_match() itself. It is provided
-       for use by callout  functions  that  want  to  cause  pcre2_match()  or
-       pcre2_callout_enumerate()  to  return a distinctive error code. See the
+       This error is never generated by pcre2_match() itself. It  is  provided
+       for  use  by  callout  functions  that  want  to cause pcre2_match() or
+       pcre2_callout_enumerate() to return a distinctive error code.  See  the
        pcre2callout documentation for details.


          PCRE2_ERROR_INTERNAL


-       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 PCRE2 or by overwriting of the compiled pattern.


          PCRE2_ERROR_JIT_BADOPTION


-       This  error  is  returned  when a pattern that was successfully studied
-       using JIT is being matched, but the matching mode (partial or  complete
-       match)  does  not  correspond to any JIT compilation mode. When the JIT
-       fast path function is used, this error may be also  given  for  invalid
+       This error is returned when a pattern  that  was  successfully  studied
+       using  JIT is being matched, but the matching mode (partial or complete
+       match) does not correspond to any JIT compilation mode.  When  the  JIT
+       fast  path  function  is used, this error may be also given for invalid
        options. See the pcre2jit documentation for more details.


          PCRE2_ERROR_JIT_STACKLIMIT


-       This  error  is  returned  when a pattern that was successfully studied
-       using JIT is being matched, but the memory available for  the  just-in-
-       time  processing stack is not large enough. See the pcre2jit documenta-
+       This error is returned when a pattern  that  was  successfully  studied
+       using  JIT  is being matched, but the memory available for the just-in-
+       time processing stack is not large enough. See the pcre2jit  documenta-
        tion for more details.


          PCRE2_ERROR_MATCHLIMIT
@@ -2380,10 +2399,10 @@


          PCRE2_ERROR_NOMEMORY


-       If a pattern contains back references,  but  the  ovector  is  not  big
-       enough  to  remember  the  referenced substrings, PCRE2 gets a block of
+       If  a  pattern  contains  back  references,  but the ovector is not big
+       enough to remember the referenced substrings, PCRE2  gets  a  block  of
        memory at the start of matching to use for this purpose. There are some
-       other  special cases where extra memory is needed during matching. This
+       other special cases where extra memory is needed during matching.  This
        error is given when memory cannot be obtained.


          PCRE2_ERROR_NULL
@@ -2392,12 +2411,12 @@


          PCRE2_ERROR_RECURSELOOP


-       This error is returned when  pcre2_match()  detects  a  recursion  loop
-       within  the  pattern. Specifically, it means that either the whole pat-
+       This  error  is  returned  when  pcre2_match() detects a recursion loop
+       within the pattern. Specifically, it means that either the  whole  pat-
        tern or a subpattern has been called recursively for the second time at
-       the  same  position  in  the  subject string. Some simple patterns that
-       might do this are detected and faulted at compile time, but  more  com-
-       plicated  cases,  in particular mutual recursions between two different
+       the same position in the subject  string.  Some  simple  patterns  that
+       might  do  this are detected and faulted at compile time, but more com-
+       plicated cases, in particular mutual recursions between  two  different
        subpatterns, cannot be detected until matching is attempted.


          PCRE2_ERROR_RECURSIONLIMIT
@@ -2420,39 +2439,39 @@


        void pcre2_substring_free(PCRE2_UCHAR *buffer);


-       Captured substrings can be accessed directly by using  the  ovector  as
+       Captured  substrings  can  be accessed directly by using the ovector as
        described above.  For convenience, auxiliary functions are provided for
-       extracting  captured  substrings  as  new,  separate,   zero-terminated
+       extracting   captured  substrings  as  new,  separate,  zero-terminated
        strings. 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
+       and  has  a  further  zero  added on the end, but the result is not, of
        course, a C string.


        The functions in this section identify substrings by number. The number
        zero refers to the entire matched substring, with higher numbers refer-
-       ring  to  substrings  captured by parenthesized groups. After a partial
-       match, only substring zero is available.  An  attempt  to  extract  any
-       other  substring  gives the error PCRE2_ERROR_PARTIAL. The next section
+       ring to substrings captured by parenthesized groups.  After  a  partial
+       match,  only  substring  zero  is  available. An attempt to extract any
+       other substring gives the error PCRE2_ERROR_PARTIAL. The  next  section
        describes similar functions for extracting captured substrings by name.


-       If a pattern uses the \K escape sequence within a  positive  assertion,
+       If  a  pattern uses the \K escape sequence within a positive assertion,
        the reported start of a successful match can be greater than the end of
-       the match.  For example, if the pattern  (?=ab\K)  is  matched  against
-       "ab",  the  start  and  end offset values for the match are 2 and 0. In
-       this situation, calling these functions with a  zero  substring  number
+       the  match.   For  example,  if the pattern (?=ab\K) is matched against
+       "ab", the start and end offset values for the match are  2  and  0.  In
+       this  situation,  calling  these functions with a zero substring number
        extracts a zero-length empty string.


-       You  can  find the length in code units of a captured substring without
-       extracting it by calling pcre2_substring_length_bynumber().  The  first
-       argument  is a pointer to the match data block, the second is the group
-       number, and the third is a pointer to a variable into which the  length
-       is  placed.  If  you just want to know whether or not the substring has
+       You can find the length in code units of a captured  substring  without
+       extracting  it  by calling pcre2_substring_length_bynumber(). The first
+       argument is a pointer to the match data block, the second is the  group
+       number,  and the third is a pointer to a variable into which the length
+       is placed. If you just want to know whether or not  the  substring  has
        been captured, you can pass the third argument as NULL.


-       The pcre2_substring_copy_bynumber() function  copies  a  captured  sub-
-       string  into  a supplied buffer, whereas pcre2_substring_get_bynumber()
-       copies it into new memory, obtained using the  same  memory  allocation
-       function  that  was  used for the match data block. The first two argu-
-       ments of these functions are a pointer to the match data  block  and  a
+       The  pcre2_substring_copy_bynumber()  function  copies  a captured sub-
+       string into a supplied buffer,  whereas  pcre2_substring_get_bynumber()
+       copies  it  into  new memory, obtained using the same memory allocation
+       function that was used for the match data block. The  first  two  argu-
+       ments  of  these  functions are a pointer to the match data block and a
        capturing group number.


        The final arguments of pcre2_substring_copy_bynumber() are a pointer to
@@ -2461,25 +2480,25 @@
        for the extracted substring, excluding the terminating zero.


        For pcre2_substring_get_bynumber() the third and fourth arguments point
-       to  variables that are updated with a pointer to the new memory and the
-       number of code units that comprise the substring, again  excluding  the
-       terminating  zero.  When  the substring is no longer needed, the memory
+       to variables that are updated with a pointer to the new memory and  the
+       number  of  code units that comprise the substring, again excluding the
+       terminating zero. When the substring is no longer  needed,  the  memory
        should be freed by calling pcre2_substring_free().


-       The return value from all these functions is zero  for  success,  or  a
-       negative  error  code.  If  the pattern match failed, the match failure
-       code is returned.  If a substring number  greater  than  zero  is  used
-       after  a partial match, PCRE2_ERROR_PARTIAL is returned. Other possible
+       The  return  value  from  all these functions is zero for success, or a
+       negative error code. If the pattern match  failed,  the  match  failure
+       code  is  returned.   If  a  substring number greater than zero is used
+       after a partial match, PCRE2_ERROR_PARTIAL is returned. Other  possible
        error codes are:


          PCRE2_ERROR_NOMEMORY


-       The buffer was too small for  pcre2_substring_copy_bynumber(),  or  the
+       The  buffer  was  too small for pcre2_substring_copy_bynumber(), or the
        attempt to get memory failed for pcre2_substring_get_bynumber().


          PCRE2_ERROR_NOSUBSTRING


-       There  is  no  substring  with that number in the pattern, that is, the
+       There is no substring with that number in the  pattern,  that  is,  the
        number is greater than the number of capturing parentheses.


          PCRE2_ERROR_UNAVAILABLE
@@ -2490,8 +2509,8 @@


          PCRE2_ERROR_UNSET


-       The substring did not participate in the match.  For  example,  if  the
-       pattern  is  (abc)|(def) and the subject is "def", and the ovector con-
+       The  substring  did  not  participate in the match. For example, if the
+       pattern is (abc)|(def) and the subject is "def", and the  ovector  con-
        tains at least two capturing slots, substring number 1 is unset.



@@ -2502,32 +2521,32 @@

        void pcre2_substring_list_free(PCRE2_SPTR *list);


-       The pcre2_substring_list_get() function  extracts  all  available  sub-
-       strings  and  builds  a  list of pointers to them. It also (optionally)
-       builds a second list that  contains  their  lengths  (in  code  units),
+       The  pcre2_substring_list_get()  function  extracts  all available sub-
+       strings and builds a list of pointers to  them.  It  also  (optionally)
+       builds  a  second  list  that  contains  their lengths (in code units),
        excluding a terminating zero that is added to each of them. All this is
        done in a single block of memory that is obtained using the same memory
        allocation function that was used to get the match data block.


-       This  function  must be called only after a successful match. If called
+       This function must be called only after a successful match.  If  called
        after a partial match, the error code PCRE2_ERROR_PARTIAL is returned.


-       The address of the memory block is returned via listptr, which is  also
+       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 address of the list of lengths is  returned  via
-       lengthsptr.  If your strings do not contain binary zeros and you do not
+       by  a  NULL pointer. The address of the list of lengths is returned via
+       lengthsptr. If your strings do not contain binary zeros and you do  not
        therefore need the lengths, you may supply NULL as the lengthsptr argu-
-       ment  to  disable  the  creation of a list of lengths. The yield of the
-       function is zero if all went well, or PCRE2_ERROR_NOMEMORY if the  mem-
-       ory  block could not be obtained. When the list is no longer needed, it
+       ment to disable the creation of a list of lengths.  The  yield  of  the
+       function  is zero if all went well, or PCRE2_ERROR_NOMEMORY if the mem-
+       ory block could not be obtained. When the list is no longer needed,  it
        should be freed by calling pcre2_substring_list_free().


        If this function encounters 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, it returns an empty  string.
-       This  can  be  distinguished  from  a  genuine zero-length substring by
+       when capturing subpattern number n+1 matches some part of the  subject,
+       but  subpattern n has not been used at all, it returns an empty string.
+       This can be distinguished  from  a  genuine  zero-length  substring  by
        inspecting  the  appropriate  offset  in  the  ovector,  which  contain
-       PCRE2_UNSET   for   unset   substrings,   or   by   calling  pcre2_sub-
+       PCRE2_UNSET  for   unset   substrings,   or   by   calling   pcre2_sub-
        string_length_bynumber().



@@ -2547,39 +2566,39 @@

        void pcre2_substring_free(PCRE2_UCHAR *buffer);


-       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+)...


        the number of the subpattern called "xxx" is 2. If the name is known to
-       be unique (PCRE2_DUPNAMES was not set), you can find  the  number  from
+       be  unique  (PCRE2_DUPNAMES  was not set), you can find the number from
        the name by calling pcre2_substring_number_from_name(). The first argu-
-       ment is the compiled pattern, and the second is the name. The yield  of
+       ment  is the compiled pattern, and the second is the name. The yield of
        the function is the subpattern number, PCRE2_ERROR_NOSUBSTRING if there
-       is no subpattern of  that  name,  or  PCRE2_ERROR_NOUNIQUESUBSTRING  if
-       there  is  more than one subpattern of that name. Given the number, you
-       can extract the  substring  directly,  or  use  one  of  the  functions
+       is  no  subpattern  of  that  name, or PCRE2_ERROR_NOUNIQUESUBSTRING if
+       there is more than one subpattern of that name. Given the  number,  you
+       can  extract  the  substring  directly,  or  use  one  of the functions
        described above.


-       For  convenience,  there are also "byname" functions that correspond to
-       the "bynumber" functions, the only difference  being  that  the  second
-       argument  is  a  name instead of a number. If PCRE2_DUPNAMES is set and
+       For convenience, there are also "byname" functions that  correspond  to
+       the  "bynumber"  functions,  the  only difference being that the second
+       argument is a name instead of a number. If PCRE2_DUPNAMES  is  set  and
        there are duplicate names, these functions scan all the groups with the
        given name, and return the first named string that is set.


-       If  there are no groups with the given name, PCRE2_ERROR_NOSUBSTRING is
-       returned. If all groups with the name have  numbers  that  are  greater
-       than  the  number  of  slots in the ovector, PCRE2_ERROR_UNAVAILABLE is
-       returned. If there is at least one group with a slot  in  the  ovector,
+       If there are no groups with the given name, PCRE2_ERROR_NOSUBSTRING  is
+       returned.  If  all  groups  with the name have numbers that are greater
+       than the number of slots in  the  ovector,  PCRE2_ERROR_UNAVAILABLE  is
+       returned.  If  there  is at least one group with a slot in the ovector,
        but no group is found to be set, PCRE2_ERROR_UNSET is returned.


        Warning: If the pattern uses the (?| feature to set up multiple subpat-
-       terns with the same number, as described in the  section  on  duplicate
-       subpattern  numbers  in  the pcre2pattern page, you cannot use names to
-       distinguish the different subpatterns, because names are  not  included
-       in  the compiled code. The matching process uses only numbers. For this
-       reason, the use of different names for subpatterns of the  same  number
+       terns  with  the  same number, as described in the section on duplicate
+       subpattern numbers in the pcre2pattern page, you cannot  use  names  to
+       distinguish  the  different subpatterns, because names are not included
+       in the compiled code. The matching process uses only numbers. For  this
+       reason,  the  use of different names for subpatterns of the same number
        causes an error at compile time.



@@ -2592,33 +2611,41 @@
          PCRE2_SIZE rlength, PCRE2_UCHAR *outputbufferP,
          PCRE2_SIZE *outlengthptr);


-       This  function calls pcre2_match() and then makes a copy of the subject
-       string in outputbuffer, replacing the part that was  matched  with  the
-       replacement  string,  whose  length is supplied in rlength. This can be
+       This function calls pcre2_match() and then makes a copy of the  subject
+       string  in  outputbuffer,  replacing the part that was matched with the
+       replacement string, whose length is supplied in rlength.  This  can  be
        given as PCRE2_ZERO_TERMINATED for a zero-terminated string. Matches in
-       which  a  \K item in a lookahead in the pattern causes the match to end
+       which a \K item in a lookahead in the pattern causes the match  to  end
        before it starts are not supported, and give rise to an error return.


-       The first seven arguments of pcre2_substitute() are  the  same  as  for
+       The  first  seven  arguments  of pcre2_substitute() are the same as for
        pcre2_match(), except that the partial matching options are not permit-
-       ted, and match_data may be passed as NULL, in which case a  match  data
-       block  is obtained and freed within this function, using memory manage-
-       ment functions from the match context, if provided, or else those  that
+       ted,  and  match_data may be passed as NULL, in which case a match data
+       block is obtained and freed within this function, using memory  manage-
+       ment  functions from the match context, if provided, or else those that
        were used to allocate memory for the compiled code.


-       The  outlengthptr  argument  must point to a variable that contains the
-       length, in code units, of the output buffer. If the  function  is  suc-
-       cessful,  the value is updated to contain the length of the new string,
-       excluding the trailing zero that is automatically added. If  the  func-
-       tion  is  not  successful,  the value is set to PCRE2_UNSET for general
-       errors (such as output buffer too small).  For  syntax  errors  in  the
-       replacement  string,  the value is set to the offset in the replacement
-       string where the error was detected.
+       The outlengthptr argument must point to a variable  that  contains  the
+       length,  in  code  units, of the output buffer. If the function is suc-
+       cessful, the value is updated to contain the length of the new  string,
+       excluding the trailing zero that is automatically added.


-       In the replacement string, which is interpreted as a UTF string in  UTF
-       mode,  and  is  checked  for UTF validity unless the PCRE2_NO_UTF_CHECK
+       If  the  function  is  not  successful,  the value set via outlengthptr
+       depends on the type of error. For  syntax  errors  in  the  replacement
+       string,  the  value  is  the offset in the replacement string where the
+       error was detected. For other  errors,  the  value  is  PCRE2_UNSET  by
+       default.  This  includes the case of the output buffer being too small,
+       unless PCRE2_SUBSTITUTE_OVERFLOW_LENGTH is set (see  below),  in  which
+       case  the  value  is the minimum length needed, including space for the
+       trailing zero. Note that in  order  to  compute  the  required  length,
+       pcre2_substitute()  has  to  simulate  all  the  matching  and copying,
+       instead of giving an error return as soon as the buffer overflows. Note
+       also that the length is in code units, not bytes.
+
+       In  the replacement string, which is interpreted as a UTF string in UTF
+       mode, and is checked for UTF  validity  unless  the  PCRE2_NO_UTF_CHECK
        option is set, a dollar character is an escape character that can spec-
-       ify  the insertion of characters from capturing groups or (*MARK) items
+       ify the insertion of characters from capturing groups or (*MARK)  items
        in the pattern. The following forms are always recognized:


          $$                  insert a dollar character
@@ -2625,11 +2652,11 @@
          $<n> or ${<n>}      insert the contents of group <n>
          $*MARK or ${*MARK}  insert the name of the last (*MARK) encountered


-       Either a group number or a group name  can  be  given  for  <n>.  Curly
-       brackets  are  required only if the following character would be inter-
+       Either  a  group  number  or  a  group name can be given for <n>. Curly
+       brackets are required only if the following character would  be  inter-
        preted as part of the number or name. The number may be zero to include
-       the  entire  matched  string.   For  example,  if  the pattern a(b)c is
-       matched with "=abc=" and the replacement string "+$1$0$1+", the  result
+       the entire matched string.   For  example,  if  the  pattern  a(b)c  is
+       matched  with "=abc=" and the replacement string "+$1$0$1+", the result
        is "=+babcb+=".


        The facility for inserting a (*MARK) name can be used to perform simple
@@ -2639,17 +2666,52 @@
              apple lemon
           2: pear orange


-       There is an additional option,  PCRE2_SUBSTITUTE_GLOBAL,  which  causes
-       the function to iterate over the subject string, replacing every match-
-       ing substring. If this is not set, only the first matching substring is
-       replaced.
+       As  well as the usual options for pcre2_match(), a number of additional
+       options can be set in the options argument.


-       A  second  additional  option,  PCRE2_SUBSTITUTE_EXTENDED, causes extra
-       processing to be  applied  to  the  replacement  string.  Without  this
-       option, only the dollar character is special, and only the group inser-
-       tion forms listed above are valid.  When  PCRE2_SUBSTITUTE_EXTENDED  is
-       set, two things change:
+       PCRE2_SUBSTITUTE_GLOBAL causes the function to iterate over the subject
+       string,  replacing  every  matching substring. If this is not set, only
+       the first matching substring is replaced. If any matched substring  has
+       zero  length, after the substitution has happened, an attempt to find a
+       non-empty match at the same position is performed. If this is not  suc-
+       cessful,  the current position is advanced by one character except when
+       CRLF is a valid newline sequence and the next two  characters  are  CR,
+       LF. In this case, the current position is advanced by two characters.


+       PCRE2_SUBSTITUTE_OVERFLOW_LENGTH  changes  what happens when the output
+       buffer is too small. The default action is to return PCRE2_ERROR_NOMEM-
+       ORY  immediately.  If  this  option is set, however, pcre2_substitute()
+       continues to go through the motions of matching and substituting (with-
+       out,  of course, writing anything) in order to compute the size of buf-
+       fer that is needed. This value is  passed  back  via  the  outlengthptr
+       variable,    with    the   result   of   the   function   still   being
+       PCRE2_ERROR_NOMEMORY.
+
+       Passing a buffer size of zero is a permitted way  of  finding  out  how
+       much  memory  is needed for given substitution. However, this does mean
+       that the entire operation is carried out twice. Depending on the appli-
+       cation,  it  may  be more efficient to allocate a large buffer and free
+       the  excess  afterwards,  instead   of   using   PCRE2_SUBSTITUTE_OVER-
+       FLOW_LENGTH.
+
+       PCRE2_SUBSTITUTE_UNKNOWN_UNSET  causes  references  to capturing groups
+       that do not appear in the pattern to be treated as unset  groups.  This
+       option  should  be  used  with  care, because it means that a typo in a
+       group name or  number  no  longer  causes  the  PCRE2_ERROR_NOSUBSTRING
+       error.
+
+       PCRE2_SUBSTITUTE_UNSET_EMPTY  causes  unset capturing groups (including
+       unknown  groups  when  PCRE2_SUBSTITUTE_UNKNOWN_UNSET  is  set)  to  be
+       treated  as  empty  strings  when  inserted as described above. If this
+       option is not set, an attempt to  insert  an  unset  group  causes  the
+       PCRE2_ERROR_UNSET  error.  This  option does not influence the extended
+       substitution syntax described below.
+
+       PCRE2_SUBSTITUTE_EXTENDED causes extra processing to be applied to  the
+       replacement  string.  Without this option, only the dollar character is
+       special, and only the group insertion forms  listed  above  are  valid.
+       When PCRE2_SUBSTITUTE_EXTENDED is set, two things change:
+
        Firstly,  backslash in a replacement string is interpreted as an escape
        character. The usual forms such as \n or \x{ddd} can be used to specify
        particular  character codes, and backslash followed by any non-alphanu-
@@ -2698,79 +2760,98 @@
              somebody
           1: HELLO


-       If successful, the function returns the  number  of  replacements  that
-       were  made.   This  may  be zero if no matches were found, and is never
+       The PCRE2_SUBSTITUTE_UNSET_EMPTY option does not affect these  extended
+       substitutions.   However,   PCRE2_SUBSTITUTE_UNKNOWN_UNSET  does  cause
+       unknown groups in the extended syntax forms to be treated as unset.
+
+       If successful, pcre2_substitute() returns the  number  of  replacements
+       that were made. This may be zero if no matches were found, and is never
        greater than 1 unless PCRE2_SUBSTITUTE_GLOBAL is set.


        In the event of an error, a negative error code is returned. Except for
        PCRE2_ERROR_NOMATCH    (which   is   never   returned),   errors   from
-       pcre2_match()  are  passed  straight  back.   PCRE2_ERROR_NOMEMORY   is
-       returned    if    the    output    buffer    is    not    big   enough.
-       PCRE2_ERROR_BADREPLACEMENT is used for miscellaneous syntax  errors  in
+       pcre2_match() are passed straight back.
+
+       PCRE2_ERROR_NOSUBSTRING is returned for a non-existent substring inser-
+       tion, unless PCRE2_SUBSTITUTE_UNKNOWN_UNSET is set.
+
+       PCRE2_ERROR_UNSET is returned for an unset substring insertion (includ-
+       ing an unknown substring when  PCRE2_SUBSTITUTE_UNKNOWN_UNSET  is  set)
+       when  the  simple  (non-extended)  syntax  is  used  and  PCRE2_SUBSTI-
+       TUTE_UNSET_EMPTY is not set.
+
+       PCRE2_ERROR_NOMEMORY is returned  if  the  output  buffer  is  not  big
+       enough. If the PCRE2_SUBSTITUTE_OVERFLOW_LENGTH option is set, the size
+       of buffer that is needed is returned via outlengthptr. Note  that  this
+       does not happen by default.
+
+       PCRE2_ERROR_BADREPLACEMENT  is  used for miscellaneous syntax errors in
        the   replacement   string,   with   more   particular   errors   being
-       PCRE2_ERROR_BADREPESCAPE (invalid  escape  sequence),  PCRE2_ERROR_REP-
-       MISSING_BRACE  (closing curly bracket not found), PCRE2_BADSUBSTITUTION
-       (syntax error in extended group substitution), and  PCRE2_BADSUBPATTERN
-       (the pattern match ended before it started). As for all PCRE2 errors, a
-       text message that describes  the  error  can  be  obtained  by  calling
-       pcre2_get_error_message().
+       PCRE2_ERROR_BADREPESCAPE  (invalid  escape  sequence), PCRE2_ERROR_REP-
+       MISSING_BRACE (closing curly bracket not found),  PCRE2_BADSUBSTITUTION
+       (syntax  error in extended group substitution), and PCRE2_BADSUBPATTERN
+       (the pattern match ended before it started, which can happen if  \K  is
+       used in an assertion).


+       As for all PCRE2 errors, a text message that describes the error can be
+       obtained by calling pcre2_get_error_message().


+
DUPLICATE SUBPATTERN NAMES

        int pcre2_substring_nametable_scan(const pcre2_code *code,
          PCRE2_SPTR name, PCRE2_SPTR *first, PCRE2_SPTR *last);


-       When  a  pattern  is compiled with the PCRE2_DUPNAMES option, names for
-       subpatterns are not required to be unique. Duplicate names  are  always
-       allowed  for subpatterns with the same number, created by using the (?|
-       feature. Indeed, if such subpatterns are named, they  are  required  to
+       When a pattern is compiled with the PCRE2_DUPNAMES  option,  names  for
+       subpatterns  are  not required to be unique. Duplicate names are always
+       allowed for subpatterns with the same number, created by using the  (?|
+       feature.  Indeed,  if  such subpatterns are named, they are required to
        use the same names.


        Normally, patterns with duplicate names are such that in any one match,
-       only one of the named subpatterns participates. An example is shown  in
+       only  one of the named subpatterns participates. An example is shown in
        the pcre2pattern documentation.


-       When   duplicates   are   present,   pcre2_substring_copy_byname()  and
-       pcre2_substring_get_byname() return the first  substring  corresponding
-       to   the   given   name   that   is  set.  Only  if  none  are  set  is
-       PCRE2_ERROR_UNSET is returned.  The  pcre2_substring_number_from_name()
+       When  duplicates   are   present,   pcre2_substring_copy_byname()   and
+       pcre2_substring_get_byname()  return  the first substring corresponding
+       to  the  given  name  that  is  set.  Only   if   none   are   set   is
+       PCRE2_ERROR_UNSET  is  returned. The pcre2_substring_number_from_name()
        function returns the error PCRE2_ERROR_NOUNIQUESUBSTRING when there are
        duplicate names.


-       If you want to get full details of all captured substrings for a  given
-       name,  you  must use the pcre2_substring_nametable_scan() function. The
-       first argument is the compiled pattern, and the second is the name.  If
-       the  third  and fourth arguments are NULL, the function returns a group
+       If  you want to get full details of all captured substrings for a given
+       name, you must use the pcre2_substring_nametable_scan()  function.  The
+       first  argument is the compiled pattern, and the second is the name. If
+       the third and fourth arguments are NULL, the function returns  a  group
        number for a unique name, or PCRE2_ERROR_NOUNIQUESUBSTRING otherwise.


        When the third and fourth arguments are not NULL, they must be pointers
-       to  variables  that are updated by the function. After it has run, they
+       to variables that 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,  and the function returns the length of each entry in code
-       units. In both cases, PCRE2_ERROR_NOSUBSTRING is returned if there  are
+       given name, and the function returns the length of each entry  in  code
+       units.  In both cases, PCRE2_ERROR_NOSUBSTRING is returned if there are
        no entries for the given name.


        The format of the name table is described above in the section entitled
-       Information about a pattern above.  Given all the relevant entries  for
-       the name, you can extract each of their numbers, and hence the captured
+       Information  about  a  pattern.  Given all the relevant entries for the
+       name, you can extract each of their numbers,  and  hence  the  captured
        data.



FINDING ALL POSSIBLE MATCHES AT ONE POSITION

-       The traditional matching function uses a  similar  algorithm  to  Perl,
-       which  stops when it finds the first match at a given point in the sub-
+       The  traditional  matching  function  uses a similar algorithm to Perl,
+       which stops when it finds the first match at a given point in the  sub-
        ject. If you want to find all possible matches, or the longest possible
-       match  at  a  given  position,  consider using the alternative matching
-       function (see below) instead. If you cannot use the  alternative  func-
+       match at a given position,  consider  using  the  alternative  matching
+       function  (see  below) instead. If you cannot use the alternative func-
        tion, you can kludge it up by making use of the callout facility, which
        is described in the pcre2callout documentation.


        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  pcre2_match()  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 pcre2_match() to
+       backtrack and try other alternatives. Ultimately, when it runs  out  of
        matches, pcre2_match() will yield PCRE2_ERROR_NOMATCH.



@@ -2782,26 +2863,26 @@
          pcre2_match_context *mcontext,
          int *workspace, PCRE2_SIZE wscount);


-       The function pcre2_dfa_match() 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 PCRE2 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, and  a  list  of  features
+       The  function  pcre2_dfa_match()  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 PCRE2 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, and a list of features
        that pcre2_dfa_match() does not support, see the pcre2matching documen-
        tation.


-       The arguments for the pcre2_dfa_match() function are the  same  as  for
+       The  arguments  for  the pcre2_dfa_match() function are the same as for
        pcre2_match(), plus two extras. The ovector within the match data block
        is used in a different way, and this is described below. The other com-
-       mon  arguments  are used in the same way as for pcre2_match(), so their
+       mon arguments are used in the same way as for pcre2_match(),  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  is needed for patterns and subjects where there are a lot of
+       workspace is needed for patterns and subjects where there are a lot  of
        potential matches.


        Here is an example of a simple call to pcre2_dfa_match():
@@ -2821,45 +2902,45 @@


    Option bits for pcre_dfa_match()


-       The unused bits of the options argument for pcre2_dfa_match()  must  be
-       zero.  The  only bits that may be set are PCRE2_ANCHORED, PCRE2_NOTBOL,
+       The  unused  bits of the options argument for pcre2_dfa_match() must be
+       zero. The only bits that may be set are  PCRE2_ANCHORED,  PCRE2_NOTBOL,
        PCRE2_NOTEOL,          PCRE2_NOTEMPTY,          PCRE2_NOTEMPTY_ATSTART,
        PCRE2_NO_UTF_CHECK,       PCRE2_PARTIAL_HARD,       PCRE2_PARTIAL_SOFT,
-       PCRE2_DFA_SHORTEST, and PCRE2_DFA_RESTART. All but  the  last  four  of
-       these  are  exactly the same as for pcre2_match(), so their description
+       PCRE2_DFA_SHORTEST,  and  PCRE2_DFA_RESTART.  All  but the last four of
+       these are exactly the same as for pcre2_match(), so  their  description
        is not repeated here.


          PCRE2_PARTIAL_HARD
          PCRE2_PARTIAL_SOFT


-       These have the same general effect as they do  for  pcre2_match(),  but
-       the  details are slightly different. When PCRE2_PARTIAL_HARD is set for
-       pcre2_dfa_match(), it returns PCRE2_ERROR_PARTIAL if  the  end  of  the
+       These  have  the  same general effect as they do for pcre2_match(), but
+       the details are slightly different. When PCRE2_PARTIAL_HARD is set  for
+       pcre2_dfa_match(),  it  returns  PCRE2_ERROR_PARTIAL  if the end of the
        subject is reached and there is still at least one matching possibility
        that requires additional characters. This happens even if some complete
-       matches  have  already  been found. When PCRE2_PARTIAL_SOFT is set, the
-       return code PCRE2_ERROR_NOMATCH is converted  into  PCRE2_ERROR_PARTIAL
-       if  the  end  of  the  subject  is reached, there have been no complete
+       matches have already been found. When PCRE2_PARTIAL_SOFT  is  set,  the
+       return  code  PCRE2_ERROR_NOMATCH is converted into PCRE2_ERROR_PARTIAL
+       if the end of the subject is  reached,  there  have  been  no  complete
        matches, but there is still at least one matching possibility. The por-
-       tion  of  the  string that was inspected when the longest partial match
+       tion of the string that was inspected when the  longest  partial  match
        was found is set as the first matching string in both cases. There is a
-       more  detailed  discussion  of partial and multi-segment matching, with
+       more detailed discussion of partial and  multi-segment  matching,  with
        examples, in the pcre2partial documentation.


          PCRE2_DFA_SHORTEST


-       Setting the PCRE2_DFA_SHORTEST option causes the matching algorithm  to
+       Setting  the PCRE2_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.


          PCRE2_DFA_RESTART


-       When  pcre2_dfa_match() returns a partial match, it is possible to call
+       When pcre2_dfa_match() returns a partial match, it is possible to  call
        it again, with additional subject characters, and have it continue with
        the same match. The PCRE2_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
+       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
        pcre2partial documentation.


@@ -2867,8 +2948,8 @@

        When pcre2_dfa_match() 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


          <.*>
@@ -2883,17 +2964,17 @@
          <something> <something else>
          <something>


-       On  success,  the  yield of the function is a number greater than zero,
-       which is the number of matched substrings.  The  offsets  of  the  sub-
-       strings  are returned in the ovector, and can be extracted by number in
-       the same way as for pcre2_match(), but the numbers bear no relation  to
-       any  capturing groups that may exist in the pattern, because DFA match-
+       On success, the yield of the function is a number  greater  than  zero,
+       which  is  the  number  of  matched substrings. The offsets of the sub-
+       strings are returned in the ovector, and can be extracted by number  in
+       the  same way as for pcre2_match(), but the numbers bear no relation to
+       any capturing groups that may exist in the pattern, because DFA  match-
        ing does not support group capture.


-       Calls to the convenience functions  that  extract  substrings  by  name
-       return  the  error PCRE2_ERROR_DFA_UFUNC (unsupported function) if used
+       Calls  to  the  convenience  functions  that extract substrings by name
+       return the error PCRE2_ERROR_DFA_UFUNC (unsupported function)  if  used
        after a DFA match. The convenience functions that extract substrings by
-       number  never  return PCRE2_ERROR_NOSUBSTRING, and the meanings of some
+       number never return PCRE2_ERROR_NOSUBSTRING, and the meanings  of  some
        other errors are slightly different:


          PCRE2_ERROR_UNAVAILABLE
@@ -2903,64 +2984,64 @@


          PCRE2_ERROR_UNSET


-       There  is  a  slot  in  the  ovector for this substring, but there were
+       There is a slot in the ovector  for  this  substring,  but  there  were
        insufficient matches to fill it.


-       The matched strings are stored in  the  ovector  in  reverse  order  of
-       length;  that  is,  the longest matching string is first. If there were
-       too many matches to fit into the ovector, the yield of the function  is
+       The  matched  strings  are  stored  in  the ovector in reverse order of
+       length; that is, the longest matching string is first.  If  there  were
+       too  many matches to fit into the ovector, the yield of the function is
        zero, and the vector is filled with the longest matches.


-       NOTE:  PCRE2's  "auto-possessification" optimization usually applies to
-       character repeats at the end of a pattern (as well as internally).  For
-       example,  the pattern "a\d+" is compiled as if it were "a\d++". For DFA
-       matching, this means that only one possible  match  is  found.  If  you
-       really  do  want multiple matches in such cases, either use an ungreedy
-       repeat auch as "a\d+?" or set  the  PCRE2_NO_AUTO_POSSESS  option  when
+       NOTE: PCRE2's "auto-possessification" optimization usually  applies  to
+       character  repeats at the end of a pattern (as well as internally). For
+       example, the pattern "a\d+" is compiled as if it were "a\d++". For  DFA
+       matching,  this  means  that  only  one possible match is found. If you
+       really do want multiple matches in such cases, either use  an  ungreedy
+       repeat  auch  as  "a\d+?"  or set the PCRE2_NO_AUTO_POSSESS option when
        compiling.


    Error returns from pcre2_dfa_match()


        The pcre2_dfa_match() function returns a negative number when it fails.
-       Many of the errors are the same  as  for  pcre2_match(),  as  described
+       Many  of  the  errors  are  the same as for pcre2_match(), as described
        above.  There are in addition the following errors that are specific to
        pcre2_dfa_match():


          PCRE2_ERROR_DFA_UITEM


-       This return is given if pcre2_dfa_match() encounters  an  item  in  the
-       pattern  that it does not support, for instance, the use of \C in a UTF
+       This  return  is  given  if pcre2_dfa_match() encounters an item in the
+       pattern that it does not support, for instance, the use of \C in a  UTF
        mode or a back reference.


          PCRE2_ERROR_DFA_UCOND


-       This return is given if pcre2_dfa_match() encounters a  condition  item
-       that  uses  a back reference for the condition, or a test for recursion
+       This  return  is given if pcre2_dfa_match() 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.


          PCRE2_ERROR_DFA_WSSIZE


-       This return is given if pcre2_dfa_match() runs  out  of  space  in  the
+       This  return  is  given  if  pcre2_dfa_match() runs out of space in the
        workspace vector.


          PCRE2_ERROR_DFA_RECURSE


-       When  a  recursive subpattern is processed, the matching function calls
+       When a recursive subpattern is processed, the matching  function  calls
        itself recursively, using private memory for the ovector and workspace.
-       This  error  is given if the internal ovector is not large enough. This
+       This error is given if the internal ovector is not large  enough.  This
        should be extremely rare, as a vector of size 1000 is used.


          PCRE2_ERROR_DFA_BADRESTART


-       When pcre2_dfa_match() is called  with  the  PCRE2_DFA_RESTART  option,
-       some  plausibility  checks  are  made on the contents of the workspace,
-       which should contain data about the previous partial match. If  any  of
+       When  pcre2_dfa_match()  is  called  with the PCRE2_DFA_RESTART option,
+       some plausibility checks are made on the  contents  of  the  workspace,
+       which  should  contain data about the previous partial match. If any of
        these checks fail, this error is given.



SEE ALSO

-       pcre2build(3),    pcre2callout(3),    pcre2demo(3),   pcre2matching(3),
+       pcre2build(3),   pcre2callout(3),    pcre2demo(3),    pcre2matching(3),
        pcre2partial(3),    pcre2posix(3),    pcre2sample(3),    pcre2stack(3),
        pcre2unicode(3).


@@ -2974,11 +3055,11 @@

REVISION

-       Last updated: 05 November 2015
+       Last updated: 16 December 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2BUILD(3)              Library Functions Manual              PCRE2BUILD(3)



@@ -3461,8 +3542,8 @@
        Last updated: 16 October 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2CALLOUT(3)            Library Functions Manual            PCRE2CALLOUT(3)



@@ -3825,8 +3906,8 @@
        Last updated: 23 March 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2COMPAT(3)             Library Functions Manual             PCRE2COMPAT(3)



@@ -4010,8 +4091,8 @@
        Last updated: 15 March 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2JIT(3)                Library Functions Manual                PCRE2JIT(3)



@@ -4078,6 +4159,12 @@
        exactly the same results. The returned value  from  pcre2_jit_compile()
        is zero on success, or a negative error code.


+       There  is  a limit to the size of pattern that JIT supports, imposed by
+       the size of machine stack that it uses. The exact rules are  not  docu-
+       mented  because  they  may  change at any time, in particular, when new
+       optimizations are introduced.  If a pattern  is  too  big,  a  call  to
+       pcre2_jit_compile() returns PCRE2_ERROR_NOMEMORY.
+
        PCRE2_JIT_COMPLETE  requests the JIT compiler to generate code for com-
        plete matches. If you want to run partial matches using the  PCRE2_PAR-
        TIAL_HARD  or  PCRE2_PARTIAL_SOFT  options of pcre2_match(), you should
@@ -4394,11 +4481,11 @@


REVISION

-       Last updated: 28 July 2015
+       Last updated: 14 November 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2LIMITS(3)             Library Functions Manual             PCRE2LIMITS(3)



@@ -4475,8 +4562,8 @@
        Last updated: 05 November 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2MATCHING(3)           Library Functions Manual           PCRE2MATCHING(3)



@@ -4694,8 +4781,8 @@
        Last updated: 29 September 2014
        Copyright (c) 1997-2014 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2PARTIAL(3)            Library Functions Manual            PCRE2PARTIAL(3)



@@ -5134,8 +5221,8 @@
        Last updated: 22 December 2014
        Copyright (c) 1997-2014 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2PATTERN(3)            Library Functions Manual            PCRE2PATTERN(3)



@@ -5706,20 +5793,21 @@
        below.  This particular group matches either the two-character sequence
        CR  followed  by  LF,  or  one  of  the single characters LF (linefeed,
        U+000A), VT (vertical tab, U+000B), FF (form feed,  U+000C),  CR  (car-
-       riage  return,  U+000D),  or NEL (next line, U+0085). The two-character
-       sequence is treated as a single unit that cannot be split.
+       riage  return,  U+000D), or NEL (next line, U+0085). Because this is an
+       atomic group, the two-character sequence is treated as  a  single  unit
+       that cannot be split.


-       In other modes, two additional characters whose codepoints are  greater
+       In  other modes, two additional characters whose codepoints are greater
        than 255 are added: LS (line separator, U+2028) and PS (paragraph sepa-
-       rator, U+2029).  Unicode support is not needed for these characters  to
+       rator,  U+2029).  Unicode support is not needed for these characters to
        be recognized.


        It is possible to restrict \R to match only CR, LF, or CRLF (instead of
-       the complete set  of  Unicode  line  endings)  by  setting  the  option
-       PCRE2_BSR_ANYCRLF  at  compile  time. (BSR is an abbrevation for "back-
+       the  complete  set  of  Unicode  line  endings)  by  setting the option
+       PCRE2_BSR_ANYCRLF at compile time. (BSR is an  abbrevation  for  "back-
        slash R".) This can be made the default when PCRE2 is built; if this is
-       the  case,  the other behaviour can be requested via the PCRE2_BSR_UNI-
-       CODE option. It is also possible to specify these settings by  starting
+       the case, the other behaviour can be requested via  the  PCRE2_BSR_UNI-
+       CODE  option. It is also possible to specify these settings by starting
        a pattern string with one of the following sequences:


          (*BSR_ANYCRLF)   CR, LF, or CRLF only
@@ -5727,23 +5815,23 @@


        These override the default and the options given to the compiling func-
        tion.  Note that these special settings, which are not Perl-compatible,
-       are  recognized only at the very start of a pattern, and that they must
-       be in upper case. If more than one of them is present, the last one  is
-       used.  They  can  be  combined with a change of newline convention; for
+       are recognized only at the very start of a pattern, and that they  must
+       be  in upper case. If more than one of them is present, the last one is
+       used. They can be combined with a change  of  newline  convention;  for
        example, a pattern can start with:


          (*ANY)(*BSR_ANYCRLF)


-       They can also be combined with the (*UTF) or (*UCP) special  sequences.
-       Inside  a  character  class,  \R  is  treated as an unrecognized escape
+       They  can also be combined with the (*UTF) or (*UCP) special sequences.
+       Inside a character class, \R  is  treated  as  an  unrecognized  escape
        sequence, and causes an error.


    Unicode character properties


-       When PCRE2 is built with Unicode support  (the  default),  three  addi-
-       tional  escape sequences that match characters with specific properties
-       are available. In 8-bit non-UTF-8 mode, these sequences are  of  course
-       limited  to  testing characters whose codepoints are less than 256, but
+       When  PCRE2  is  built  with Unicode support (the default), three addi-
+       tional escape sequences that match characters with specific  properties
+       are  available.  In 8-bit non-UTF-8 mode, these sequences are of course
+       limited to testing characters whose codepoints are less than  256,  but
        they do work in this mode.  The extra escape sequences are:


          \p{xx}   a character with the xx property
@@ -5750,53 +5838,53 @@
          \P{xx}   a character without the xx property
          \X       a Unicode extended grapheme cluster


-       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, "Any", which matches any
        character  (including  newline),  and  some  special  PCRE2  properties
-       (described  in the next section).  Other Perl properties such as "InMu-
-       sicalSymbols" are not supported by PCRE2.  Note that \P{Any}  does  not
+       (described in the next section).  Other Perl properties such as  "InMu-
+       sicalSymbols"  are  not supported by PCRE2.  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:


-       Ahom,  Anatolian_Hieroglyphs,  Arabic,  Armenian,  Avestan,   Balinese,
-       Bamum,  Bassa_Vah, Batak, Bengali, Bopomofo, Brahmi, Braille, Buginese,
-       Buhid, Canadian_Aboriginal, Carian, Caucasian_Albanian,  Chakma,  Cham,
-       Cherokee,   Common,  Coptic,  Cuneiform,  Cypriot,  Cyrillic,  Deseret,
-       Devanagari, Duployan, Egyptian_Hieroglyphs,  Elbasan,  Ethiopic,  Geor-
-       gian,  Glagolitic,  Gothic,  Grantha,  Greek,  Gujarati, Gurmukhi, Han,
+       Ahom,   Anatolian_Hieroglyphs,  Arabic,  Armenian,  Avestan,  Balinese,
+       Bamum, Bassa_Vah, Batak, Bengali, Bopomofo, Brahmi, Braille,  Buginese,
+       Buhid,  Canadian_Aboriginal,  Carian, Caucasian_Albanian, Chakma, Cham,
+       Cherokee,  Common,  Coptic,  Cuneiform,  Cypriot,  Cyrillic,   Deseret,
+       Devanagari,  Duployan,  Egyptian_Hieroglyphs,  Elbasan, Ethiopic, Geor-
+       gian, Glagolitic, Gothic,  Grantha,  Greek,  Gujarati,  Gurmukhi,  Han,
        Hangul, Hanunoo, Hatran, Hebrew, Hiragana, Imperial_Aramaic, Inherited,
-       Inscriptional_Pahlavi,  Inscriptional_Parthian,  Javanese, Kaithi, Kan-
-       nada, Katakana, Kayah_Li, Kharoshthi, Khmer,  Khojki,  Khudawadi,  Lao,
-       Latin,  Lepcha,  Limbu, Linear_A, Linear_B, Lisu, Lycian, Lydian, Maha-
+       Inscriptional_Pahlavi, Inscriptional_Parthian, Javanese,  Kaithi,  Kan-
+       nada,  Katakana,  Kayah_Li,  Kharoshthi, Khmer, Khojki, Khudawadi, Lao,
+       Latin, Lepcha, Limbu, Linear_A, Linear_B, Lisu, Lycian,  Lydian,  Maha-
        jani,  Malayalam,  Mandaic,  Manichaean,  Meetei_Mayek,  Mende_Kikakui,
-       Meroitic_Cursive,  Meroitic_Hieroglyphs,  Miao,  Modi,  Mongolian, Mro,
-       Multani,  Myanmar,  Nabataean,  New_Tai_Lue,  Nko,   Ogham,   Ol_Chiki,
-       Old_Hungarian,  Old_Italic, Old_North_Arabian, Old_Permic, Old_Persian,
+       Meroitic_Cursive, Meroitic_Hieroglyphs,  Miao,  Modi,  Mongolian,  Mro,
+       Multani,   Myanmar,   Nabataean,  New_Tai_Lue,  Nko,  Ogham,  Ol_Chiki,
+       Old_Hungarian, Old_Italic, Old_North_Arabian, Old_Permic,  Old_Persian,
        Old_South_Arabian, Old_Turkic, Oriya, Osmanya, Pahawh_Hmong, Palmyrene,
        Pau_Cin_Hau,  Phags_Pa,  Phoenician,  Psalter_Pahlavi,  Rejang,  Runic,
        Samaritan, Saurashtra, Sharada, Shavian, Siddham, SignWriting, Sinhala,
-       Sora_Sompeng,   Sundanese,  Syloti_Nagri,  Syriac,  Tagalog,  Tagbanwa,
-       Tai_Le,  Tai_Tham,  Tai_Viet,  Takri,  Tamil,  Telugu,  Thaana,   Thai,
+       Sora_Sompeng,  Sundanese,  Syloti_Nagri,  Syriac,  Tagalog,   Tagbanwa,
+       Tai_Le,   Tai_Tham,  Tai_Viet,  Takri,  Tamil,  Telugu,  Thaana,  Thai,
        Tibetan, Tifinagh, Tirhuta, Ugaritic, Vai, Warang_Citi, Yi.


        Each character has exactly one Unicode general category property, spec-
-       ified by a two-letter abbreviation. For compatibility with Perl,  nega-
-       tion  can  be  specified  by including a circumflex between the opening
-       brace and the property name.  For  example,  \p{^Lu}  is  the  same  as
+       ified  by a two-letter abbreviation. For compatibility with Perl, nega-
+       tion can be 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}
@@ -5848,18 +5936,18 @@
          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 Cs (Surrogate) property applies only to  characters  in  the  range
-       U+D800  to U+DFFF. Such characters are not valid in Unicode strings and
-       so cannot be tested by PCRE2, unless UTF  validity  checking  has  been
-       turned  off  (see  the discussion of PCRE2_NO_UTF_CHECK in the pcre2api
+       The  Cs  (Surrogate)  property  applies only to characters in the range
+       U+D800 to U+DFFF. Such characters are not valid in Unicode strings  and
+       so  cannot  be  tested  by PCRE2, unless UTF validity checking has been
+       turned off (see the discussion of PCRE2_NO_UTF_CHECK  in  the  pcre2api
        page). Perl does not support the Cs property.


-       The long synonyms for  property  names  that  Perl  supports  (such  as
-       \p{Letter})  are  not supported by PCRE2, nor is it permitted to prefix
+       The  long  synonyms  for  property  names  that  Perl supports (such as
+       \p{Letter}) are not supported by PCRE2, 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-
@@ -5866,41 +5954,41 @@
        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.
-       For  example,  \p{Lu}  always  matches only upper case letters. This is
+       Specifying  caseless  matching  does not affect these escape sequences.
+       For example, \p{Lu} always matches only upper  case  letters.  This  is
        different from the behaviour of current versions of Perl.


-       Matching characters by Unicode property is not fast, because PCRE2  has
-       to  do  a  multistage table lookup in order to find a character's prop-
+       Matching  characters by Unicode property is not fast, because PCRE2 has
+       to do a multistage table lookup in order to find  a  character's  prop-
        erty. That is why the traditional escape sequences such as \d and \w do
-       not  use  Unicode  properties  in PCRE2 by default, though you can make
-       them do so by setting the PCRE2_UCP option or by starting  the  pattern
+       not use Unicode properties in PCRE2 by default,  though  you  can  make
+       them  do  so by setting the PCRE2_UCP option or by starting the pattern
        with (*UCP).


    Extended grapheme clusters


-       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 grapheme cluster", and treats the sequence as an atomic group
-       (see  below).  Unicode supports various kinds of composite character by
-       giving each character a grapheme breaking property,  and  having  rules
+       (see below).  Unicode supports various kinds of composite character  by
+       giving  each  character  a grapheme breaking property, and having rules
        that use these properties to define the boundaries of extended grapheme
-       clusters. \X always matches at least one  character.  Then  it  decides
-       whether  to  add additional characters according to the following rules
+       clusters.  \X  always  matches  at least one character. Then it decides
+       whether to add additional characters according to the  following  rules
        for ending a cluster:


        1. End at the end of the subject string.


-       2. Do not end between CR and LF; otherwise end after any control  char-
+       2.  Do not end between CR and LF; otherwise end after any control char-
        acter.


-       3.  Do  not  break  Hangul (a Korean script) syllable sequences. Hangul
-       characters are of five types: L, V, T, LV, and LVT. An L character  may
-       be  followed by an L, V, LV, or LVT character; an LV or V character may
+       3. Do not break Hangul (a Korean  script)  syllable  sequences.  Hangul
+       characters  are of five types: L, V, T, LV, and LVT. An L character may
+       be followed by an L, V, LV, or LVT character; an LV or V character  may
        be followed by a V or T character; an LVT or T character may be follwed
        only by a T character.


-       4.  Do not end before extending characters or spacing marks. Characters
-       with the "mark" property always have  the  "extend"  grapheme  breaking
+       4. Do not end before extending characters or spacing marks.  Characters
+       with  the  "mark"  property  always have the "extend" grapheme breaking
        property.


        5. Do not end after prepend characters.
@@ -5909,10 +5997,10 @@


    PCRE2's additional properties


-       As  well as the standard Unicode properties described above, PCRE2 sup-
-       ports four more that make it possible  to  convert  traditional  escape
+       As well as the standard Unicode properties described above, PCRE2  sup-
+       ports  four  more  that  make it possible to convert traditional escape
        sequences such as \w and \s to use Unicode properties. PCRE2 uses these
-       non-standard, non-Perl properties internally  when  PCRE2_UCP  is  set.
+       non-standard,  non-Perl  properties  internally  when PCRE2_UCP is set.
        However, they may also be used explicitly. These properties are:


          Xan   Any alphanumeric character
@@ -5920,35 +6008,35 @@
          Xsp   Any Perl space character
          Xwd   Any Perl "word" character


-       Xan  matches  characters that have either the L (letter) or the N (num-
-       ber) property. Xps matches the characters tab, linefeed, vertical  tab,
-       form  feed,  or carriage return, and any other character that has the Z
-       (separator) property.  Xsp is the same as Xps;  in  PCRE1  it  used  to
-       exclude  vertical  tab,  for  Perl compatibility, but Perl changed. Xwd
+       Xan matches characters that have either the L (letter) or the  N  (num-
+       ber)  property. Xps matches the characters tab, linefeed, vertical tab,
+       form feed, or carriage return, and any other character that has  the  Z
+       (separator)  property.   Xsp  is  the  same as Xps; in PCRE1 it used to
+       exclude vertical tab, for Perl compatibility,  but  Perl  changed.  Xwd
        matches the same characters as Xan, plus underscore.


-       There is another non-standard property, Xuc, which matches any  charac-
-       ter  that  can  be represented by a Universal Character Name in C++ and
-       other programming languages. These are the characters $,  @,  `  (grave
-       accent),  and  all  characters with Unicode code points greater than or
-       equal to U+00A0, except for the surrogates U+D800 to U+DFFF. Note  that
-       most  base  (ASCII) characters are excluded. (Universal Character Names
-       are of the form \uHHHH or \UHHHHHHHH where H is  a  hexadecimal  digit.
+       There  is another non-standard property, Xuc, which matches any charac-
+       ter that can be represented by a Universal Character Name  in  C++  and
+       other  programming  languages.  These are the characters $, @, ` (grave
+       accent), and all characters with Unicode code points  greater  than  or
+       equal  to U+00A0, except for the surrogates U+D800 to U+DFFF. Note that
+       most base (ASCII) characters are excluded. (Universal  Character  Names
+       are  of  the  form \uHHHH or \UHHHHHHHH where H is a hexadecimal digit.
        Note that the Xuc property does not match these sequences but the char-
        acters that they represent.)


    Resetting the match start


-       The escape sequence \K causes any previously matched characters not  to
+       The  escape sequence \K causes any previously 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,
+       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
@@ -5955,18 +6043,18 @@


        matches "foobar", the first substring is still set to "foo".


-       Perl documents that the use  of  \K  within  assertions  is  "not  well
-       defined".  In  PCRE2,  \K  is acted upon when it occurs inside positive
-       assertions, but is ignored in negative assertions.  Note  that  when  a
-       pattern  such  as (?=ab\K) matches, the reported start of the match can
+       Perl  documents  that  the  use  of  \K  within assertions is "not well
+       defined". In PCRE2, \K is acted upon when  it  occurs  inside  positive
+       assertions,  but  is  ignored  in negative assertions. Note that when a
+       pattern such as (?=ab\K) matches, the reported start of the  match  can
        be greater than the end of the match.


    Simple assertions


-       The final use of backslash is for certain simple assertions. An  asser-
-       tion  specifies a condition that has to be met at a particular point in
-       a match, without consuming any characters from the subject string.  The
-       use  of subpatterns for more complicated assertions is described below.
+       The  final use of backslash is for certain simple assertions. An asser-
+       tion specifies a condition that has to be met at a particular point  in
+       a  match, without consuming any characters from the subject string. The
+       use of subpatterns for more complicated assertions is described  below.
        The backslashed assertions are:


          \b     matches at a word boundary
@@ -5977,46 +6065,46 @@
          \z     matches only at the end of the subject
          \G     matches at the first matching position in the subject


-       Inside a character class, \b has a different meaning;  it  matches  the
-       backspace  character.  If  any  other  of these assertions appears in a
+       Inside  a  character  class, \b has a different meaning; it matches the
+       backspace character. If any other of  these  assertions  appears  in  a
        character class, an "invalid escape sequence" error is generated.


-       A word boundary is a position in the subject string where  the  current
-       character  and  the previous character do not both match \w or \W (i.e.
-       one matches \w and the other matches \W), or the start or  end  of  the
-       string  if  the  first or last character matches \w, respectively. In a
-       UTF mode, the meanings of \w and \W  can  be  changed  by  setting  the
+       A  word  boundary is a position in the subject string where the current
+       character and the previous character do not both match \w or  \W  (i.e.
+       one  matches  \w  and the other matches \W), or the start or end of the
+       string if the first or last character matches \w,  respectively.  In  a
+       UTF  mode,  the  meanings  of  \w  and \W can be changed by setting the
        PCRE2_UCP option. When this is done, it also affects \b and \B. Neither
-       PCRE2 nor Perl has a separate "start of word" or "end of word"  metase-
-       quence.  However,  whatever follows \b normally determines which it is.
+       PCRE2  nor Perl has a separate "start of word" or "end of word" metase-
+       quence. However, whatever follows \b normally determines which  it  is.
        For example, the fragment \ba matches "a" at the start of a word.


-       The \A, \Z, and \z assertions differ from  the  traditional  circumflex
+       The  \A,  \Z,  and \z assertions differ from the traditional circumflex
        and dollar (described in the next section) in that they only ever match
-       at the very start and end of the subject string, whatever  options  are
-       set.  Thus,  they are independent of multiline mode. These three asser-
-       tions are not affected by the  PCRE2_NOTBOL  or  PCRE2_NOTEOL  options,
-       which  affect only the behaviour of the circumflex and dollar metachar-
-       acters. However, if the startoffset argument of pcre2_match()  is  non-
-       zero,  indicating  that  matching is to start at a point other than the
-       beginning of the subject, \A can never match.  The  difference  between
-       \Z  and \z is that \Z matches before a newline at the end of the string
+       at  the  very start and end of the subject string, whatever options are
+       set. Thus, they are independent of multiline mode. These  three  asser-
+       tions  are  not  affected  by the PCRE2_NOTBOL or PCRE2_NOTEOL options,
+       which affect only the behaviour of the circumflex and dollar  metachar-
+       acters.  However,  if the startoffset argument of pcre2_match() is non-
+       zero, indicating that matching is to start at a point  other  than  the
+       beginning  of  the subject, \A can never match.  The difference between
+       \Z and \z is that \Z matches before a newline at the end of the  string
        as well as at the very end, whereas \z matches only at the end.


-       The \G assertion is true only when the current matching position is  at
-       the  start point of the match, as specified by the startoffset argument
-       of pcre2_match(). It differs from \A when the value of  startoffset  is
-       non-zero.  By  calling  pcre2_match()  multiple  times with appropriate
-       arguments, you can mimic Perl's /g option, and it is in  this  kind  of
+       The  \G assertion is true only when the current matching position is at
+       the start point of the match, as specified by the startoffset  argument
+       of  pcre2_match().  It differs from \A when the value of startoffset is
+       non-zero. By calling  pcre2_match()  multiple  times  with  appropriate
+       arguments,  you  can  mimic Perl's /g option, and it is in this kind of
        implementation where \G can be useful.


-       Note,  however,  that PCRE2's interpretation of \G, as the start of the
+       Note, however, that PCRE2's interpretation of \G, as the start  of  the
        current match, is subtly different from Perl's, which defines it as the
-       end  of  the  previous  match. In Perl, these can be different when the
-       previously matched string was empty. Because PCRE2 does just one  match
+       end of the previous match. In Perl, these can  be  different  when  the
+       previously  matched string was empty. Because PCRE2 does just one match
        at a time, it cannot reproduce this behaviour.


-       If  all  the alternatives of a pattern begin with \G, the expression is
+       If all the alternatives of a pattern begin with \G, the  expression  is
        anchored to the starting match position, and the "anchored" flag is set
        in the compiled regular expression.


@@ -6023,62 +6111,70 @@

CIRCUMFLEX AND DOLLAR

-       The  circumflex  and  dollar  metacharacters are zero-width assertions.
-       That is, they test for a particular condition being true  without  con-
+       The circumflex and dollar  metacharacters  are  zero-width  assertions.
+       That  is,  they test for a particular condition being true without con-
        suming any characters from the subject string. These two metacharacters
-       are concerned with matching the starts and ends of lines. If  the  new-
-       line  convention is set so that only the two-character sequence CRLF is
-       recognized as a newline, isolated CR and LF characters are  treated  as
+       are  concerned  with matching the starts and ends of lines. If the new-
+       line convention is set so that only the two-character sequence CRLF  is
+       recognized  as  a newline, isolated CR and LF characters are treated as
        ordinary data characters, and are not recognized as newlines.


        Outside a character class, in the default matching mode, the circumflex
-       character is an assertion that is true only  if  the  current  matching
-       point  is  at the start of the subject string. If the startoffset argu-
-       ment of pcre2_match() is non-zero, or if PCRE2_NOTBOL is  set,  circum-
-       flex  can  never match if the PCRE2_MULTILINE option is unset. Inside a
-       character class, circumflex has  an  entirely  different  meaning  (see
+       character  is  an  assertion  that is true only if the current matching
+       point is at the start of the subject string. If the  startoffset  argu-
+       ment  of  pcre2_match() is non-zero, or if PCRE2_NOTBOL is set, circum-
+       flex can never match if the PCRE2_MULTILINE option is unset.  Inside  a
+       character  class,  circumflex  has  an  entirely different meaning (see
        below).


-       Circumflex  need  not be the first character of the pattern if a number
-       of alternatives are involved, but it should be the first thing in  each
-       alternative  in  which  it appears if the pattern is ever to match that
-       branch. If all possible alternatives start with a circumflex, that  is,
-       if  the  pattern  is constrained to match only at the start of the sub-
-       ject, it is said to be an "anchored" pattern.  (There  are  also  other
+       Circumflex need not be the first character of the pattern if  a  number
+       of  alternatives are involved, but it should be the first thing in each
+       alternative in which it appears if the pattern is ever  to  match  that
+       branch.  If all possible alternatives start with a circumflex, that is,
+       if the pattern is constrained to match only at the start  of  the  sub-
+       ject,  it  is  said  to be an "anchored" pattern. (There are also other
        constructs that can cause a pattern to be anchored.)


-       The  dollar  character is an assertion that is true only if the current
-       matching point is at the end of  the  subject  string,  or  immediately
-       before  a  newline  at  the  end  of  the  string  (by default), unless
+       The dollar character is an assertion that is true only if  the  current
+       matching  point  is  at  the  end of the subject string, or immediately
+       before a newline  at  the  end  of  the  string  (by  default),  unless
        PCRE2_NOTEOL is set. Note, however, that it does not actually match the
        newline. Dollar need not be the last character of the pattern if a num-
        ber of alternatives are involved, but it should be the last item in any
-       branch  in which it appears. Dollar has no special meaning in a charac-
+       branch in which it appears. Dollar has no special meaning in a  charac-
        ter class.


-       The meaning of dollar can be changed so that it  matches  only  at  the
-       very  end  of the string, by setting the PCRE2_DOLLAR_ENDONLY option at
+       The  meaning  of  dollar  can be changed so that it matches only at the
+       very end of the string, by setting the PCRE2_DOLLAR_ENDONLY  option  at
        compile time. This does not affect the \Z assertion.


        The meanings of the circumflex and dollar metacharacters are changed if
-       the  PCRE2_MULTILINE  option  is  set.  When this is the case, a dollar
-       character matches before any newlines in the string, as well as at  the
-       very  end, and a circumflex matches immediately after internal newlines
-       as well as at the start of the subject string. It does not match  after
-       a  newline  that ends the string, for compatibility with Perl. However,
+       the PCRE2_MULTILINE option is set. When this  is  the  case,  a  dollar
+       character  matches before any newlines in the string, as well as at the
+       very end, and a circumflex matches immediately after internal  newlines
+       as  well as at the start of the subject string. It does not match after
+       a newline that ends the string, for compatibility with  Perl.  However,
        this can be changed by setting the PCRE2_ALT_CIRCUMFLEX option.


-       For example, the pattern /^abc$/ matches the subject string  "def\nabc"
-       (where  \n  represents a newline) in multiline mode, but not otherwise.
-       Consequently, patterns that are anchored in single  line  mode  because
-       all  branches  start  with  ^ are not anchored in multiline mode, and a
-       match for circumflex is  possible  when  the  startoffset  argument  of
-       pcre2_match()  is  non-zero. The PCRE2_DOLLAR_ENDONLY option is ignored
+       For  example, the pattern /^abc$/ matches the subject string "def\nabc"
+       (where \n represents a newline) in multiline mode, but  not  otherwise.
+       Consequently,  patterns  that  are anchored in single line mode because
+       all branches start with ^ are not anchored in  multiline  mode,  and  a
+       match  for  circumflex  is  possible  when  the startoffset argument of
+       pcre2_match() is non-zero. The PCRE2_DOLLAR_ENDONLY option  is  ignored
        if PCRE2_MULTILINE is set.


-       Note that the sequences \A, \Z, and \z can be used to match  the  start
-       and  end of the subject in both modes, and if all branches of a pattern
-       start with \A it is always anchored, whether or not PCRE2_MULTILINE  is
+       When  the  newline  convention (see "Newline conventions" below) recog-
+       nizes the two-character sequence CRLF as a newline, this is  preferred,
+       even  if  the  single  characters CR and LF are also recognized as new-
+       lines. For example, if the newline convention  is  "any",  a  multiline
+       mode  circumflex matches before "xyz" in the string "abc\r\nxyz" rather
+       than after CR, even though CR on its own is a valid newline.  (It  also
+       matches at the very start of the string, of course.)
+
+       Note  that  the sequences \A, \Z, and \z can be used to match the start
+       and end of the subject in both modes, and if all branches of a  pattern
+       start  with \A it is always anchored, whether or not PCRE2_MULTILINE is
        set.



@@ -6085,64 +6181,64 @@
FULL STOP (PERIOD, DOT) AND \N

        Outside a character class, a dot in the pattern matches any one charac-
-       ter in the subject string except (by default) a character  that  signi-
+       ter  in  the subject string except (by default) a character that signi-
        fies the end of a line.


-       When  a line ending is defined as a single character, dot never matches
-       that character; when the two-character sequence CRLF is used, dot  does
-       not  match  CR  if  it  is immediately followed by LF, but otherwise it
-       matches all characters (including isolated CRs and LFs). When any  Uni-
-       code  line endings are being recognized, dot does not match CR or LF or
+       When a line ending is defined as a single character, dot never  matches
+       that  character; when the two-character sequence CRLF is used, dot does
+       not match CR if it is immediately followed  by  LF,  but  otherwise  it
+       matches  all characters (including isolated CRs and LFs). When any Uni-
+       code line endings are being recognized, dot does not match CR or LF  or
        any of the other line ending characters.


-       The behaviour of dot with regard to newlines can  be  changed.  If  the
-       PCRE2_DOTALL  option  is  set, a dot matches any one character, without
-       exception.  If the two-character sequence CRLF is present in  the  sub-
+       The  behaviour  of  dot  with regard to newlines can be changed. If the
+       PCRE2_DOTALL option is set, a dot matches any  one  character,  without
+       exception.   If  the two-character sequence CRLF is present in the sub-
        ject string, it takes two dots to match it.


-       The  handling of dot is entirely independent of the handling of circum-
-       flex and dollar, the only relationship being  that  they  both  involve
+       The handling of dot is entirely independent of the handling of  circum-
+       flex  and  dollar,  the  only relationship being that they both involve
        newlines. Dot has no special meaning in a character class.


-       The  escape  sequence  \N  behaves  like  a  dot, except that it is not
-       affected by the PCRE2_DOTALL option. In other  words,  it  matches  any
-       character  except  one that signifies the end of a line. Perl also uses
+       The escape sequence \N behaves like  a  dot,  except  that  it  is  not
+       affected  by  the  PCRE2_DOTALL  option. In other words, it matches any
+       character except one that signifies the end of a line. Perl  also  uses
        \N to match characters by name; PCRE2 does not support this.



MATCHING A SINGLE CODE UNIT

-       Outside a character class, the escape sequence \C matches any one  code
-       unit,  whether or not a UTF mode is set. In the 8-bit library, one code
-       unit is one byte; in the 16-bit library it is a  16-bit  unit;  in  the
-       32-bit  library  it  is  a 32-bit unit. Unlike a dot, \C always matches
-       line-ending characters. The feature is provided in  Perl  in  order  to
+       Outside  a character class, the escape sequence \C matches any one code
+       unit, whether or not a UTF mode is set. In the 8-bit library, one  code
+       unit  is  one  byte;  in the 16-bit library it is a 16-bit unit; in the
+       32-bit library it is a 32-bit unit. Unlike a  dot,  \C  always  matches
+       line-ending  characters.  The  feature  is provided in Perl in order to
        match individual bytes in UTF-8 mode, but it is unclear how it can use-
        fully be used.


-       Because \C breaks up characters into individual  code  units,  matching
-       one  unit  with  \C  in UTF-8 or UTF-16 mode means that the rest of the
-       string may start with a malformed UTF  character.  This  has  undefined
+       Because  \C  breaks  up characters into individual code units, matching
+       one unit with \C in UTF-8 or UTF-16 mode means that  the  rest  of  the
+       string  may  start  with  a malformed UTF character. This has undefined
        results, because PCRE2 assumes that it is matching character by charac-
-       ter in a valid UTF string (by default it checks  the  subject  string's
-       validity  at  the  start  of  processing  unless the PCRE2_NO_UTF_CHECK
+       ter  in  a  valid UTF string (by default it checks the subject string's
+       validity at the  start  of  processing  unless  the  PCRE2_NO_UTF_CHECK
        option is used).


-       An  application  can  lock  out  the  use  of   \C   by   setting   the
-       PCRE2_NEVER_BACKSLASH_C  option  when  compiling  a pattern. It is also
+       An   application   can   lock   out  the  use  of  \C  by  setting  the
+       PCRE2_NEVER_BACKSLASH_C option when compiling a  pattern.  It  is  also
        possible to build PCRE2 with the use of \C permanently disabled.


-       PCRE2 does not allow \C to appear in lookbehind  assertions  (described
-       below)  in  a UTF mode, because this would make it impossible to calcu-
-       late the length of the lookbehind.  Neither  the  alternative  matching
-       function  pcre2_dfa_match()  not  the JIT optimizer support \C in a UTF
+       PCRE2  does  not allow \C to appear in lookbehind assertions (described
+       below) in a UTF mode, because this would make it impossible  to  calcu-
+       late  the  length  of  the lookbehind. Neither the alternative matching
+       function pcre2_dfa_match() not the JIT optimizer support \C  in  a  UTF
        mode. The former gives a match-time error; the latter fails to optimize
        and so the match is always run using the interpreter.


        In general, the \C escape sequence is best avoided. However, one way of
-       using it that avoids the problem of malformed UTF characters is to  use
-       a  lookahead to check the length of the next character, as in this pat-
-       tern, which could be used with a UTF-8 string (ignore white  space  and
+       using  it that avoids the problem of malformed UTF characters is to use
+       a lookahead to check the length of the next character, as in this  pat-
+       tern,  which  could be used with a UTF-8 string (ignore white space and
        line breaks):


          (?| (?=[\x00-\x7f])(\C) |
@@ -6150,10 +6246,10 @@
              (?=[\x{800}-\x{ffff}])(\C)(\C)(\C) |
              (?=[\x{10000}-\x{1fffff}])(\C)(\C)(\C)(\C))


-       In  this  example,  a  group  that starts with (?| resets the capturing
+       In this example, a group that starts  with  (?|  resets  the  capturing
        parentheses numbers in each alternative (see "Duplicate Subpattern Num-
        bers" below). The assertions at the start of each branch check the next
-       UTF-8 character for values whose encoding uses 1, 2,  3,  or  4  bytes,
+       UTF-8  character  for  values  whose encoding uses 1, 2, 3, or 4 bytes,
        respectively. The character's individual bytes are then captured by the
        appropriate number of \C groups.


@@ -6162,105 +6258,105 @@

        An opening square bracket introduces a character class, terminated by a
        closing square bracket. A closing square bracket on its own is not spe-
-       cial by default.  If a closing square bracket is required as  a  member
+       cial  by  default.  If a closing square bracket is required as a member
        of the class, it should be the first data character in the class (after
-       an initial circumflex, if present) or escaped with  a  backslash.  This
-       means  that,  by default, an empty class cannot be defined. However, if
-       the PCRE2_ALLOW_EMPTY_CLASS option is set, a closing square bracket  at
+       an  initial  circumflex,  if present) or escaped with a backslash. This
+       means that, by default, an empty class cannot be defined.  However,  if
+       the  PCRE2_ALLOW_EMPTY_CLASS option is set, a closing square bracket at
        the start does end the (empty) class.


-       A  character class matches a single character in the subject. A matched
+       A character class matches a single character in the subject. A  matched
        character must be in the set of characters defined by the class, unless
-       the  first  character in the class definition is a circumflex, in which
+       the first character in the class definition is a circumflex,  in  which
        case the subject character must not be in the set defined by the class.
-       If  a  circumflex is actually required as a member of the class, ensure
+       If a circumflex is actually required as a member of the  class,  ensure
        it is not the first character, or escape it with a backslash.


-       For example, the character class [aeiou] matches any lower case  vowel,
-       while  [^aeiou]  matches  any character that is not a lower case vowel.
+       For  example, the character class [aeiou] matches any lower case vowel,
+       while [^aeiou] matches any character that is not a  lower  case  vowel.
        Note that a circumflex is just a convenient notation for specifying the
-       characters  that  are in the class by enumerating those that are not. A
-       class that starts with a circumflex is not an assertion; it still  con-
-       sumes  a  character  from the subject string, and therefore it fails if
+       characters that are in the class by enumerating those that are  not.  A
+       class  that starts with a circumflex is not an assertion; it still con-
+       sumes a character from the subject string, and therefore  it  fails  if
        the current pointer is at the end of the string.


-       When caseless matching is set, any letters in a  class  represent  both
-       their  upper  case  and lower case versions, so for example, a caseless
-       [aeiou] matches "A" as well as "a", and a caseless  [^aeiou]  does  not
+       When  caseless  matching  is set, any letters in a class represent both
+       their upper case and lower case versions, so for  example,  a  caseless
+       [aeiou]  matches  "A"  as well as "a", and a caseless [^aeiou] does not
        match "A", whereas a caseful version would.


-       Characters  that  might  indicate  line breaks are never treated in any
-       special way  when  matching  character  classes,  whatever  line-ending
-       sequence  is  in  use,  and  whatever  setting  of the PCRE2_DOTALL and
-       PCRE2_MULTILINE options is used. A class such as  [^a]  always  matches
+       Characters that might indicate line breaks are  never  treated  in  any
+       special  way  when  matching  character  classes,  whatever line-ending
+       sequence is in use,  and  whatever  setting  of  the  PCRE2_DOTALL  and
+       PCRE2_MULTILINE  options  is  used. A class such as [^a] always matches
        one of these characters.


-       The  minus (hyphen) character can be used to specify a range of charac-
-       ters in a character  class.  For  example,  [d-m]  matches  any  letter
-       between  d  and  m,  inclusive.  If  a minus character is required in a
-       class, it must be escaped with a backslash  or  appear  in  a  position
-       where  it cannot be interpreted as indicating a range, typically as the
+       The minus (hyphen) character can be used to specify a range of  charac-
+       ters  in  a  character  class.  For  example,  [d-m] matches any letter
+       between d and m, inclusive. If a  minus  character  is  required  in  a
+       class,  it  must  be  escaped  with a backslash or appear in a position
+       where it cannot be interpreted as indicating a range, typically as  the
        first or last character in the class, or immediately after a range. For
-       example,  [b-d-z] matches letters in the range b to d, a hyphen charac-
+       example, [b-d-z] matches letters in the range b to d, a hyphen  charac-
        ter, or z.


        It is not possible to have the literal character "]" as the end charac-
-       ter  of a range. A pattern such as [W-]46] is interpreted as a class of
-       two characters ("W" and "-") followed by a literal string "46]", so  it
-       would  match  "W46]"  or  "-46]". However, if the "]" is escaped with a
-       backslash it is interpreted as the end of range, so [W-\]46] is  inter-
-       preted  as a class containing a range followed by two other characters.
-       The octal or hexadecimal representation of "]" can also be used to  end
+       ter of a range. A pattern such as [W-]46] is interpreted as a class  of
+       two  characters ("W" and "-") followed by a literal string "46]", so it
+       would match "W46]" or "-46]". However, if the "]"  is  escaped  with  a
+       backslash  it is interpreted as the end of range, so [W-\]46] is inter-
+       preted as a class containing a range followed by two other  characters.
+       The  octal or hexadecimal representation of "]" can also be used to end
        a range.


-       An  error  is  generated  if  a POSIX character class (see below) or an
-       escape sequence other than one that defines a single character  appears
-       at  a  point  where  a range ending character is expected. For example,
+       An error is generated if a POSIX character  class  (see  below)  or  an
+       escape  sequence other than one that defines a single character appears
+       at a point where a range ending character  is  expected.  For  example,
        [z-\xff] is valid, but [A-\d] and [A-[:digit:]] are not.


        Ranges normally include all code points between the start and end char-
-       acters,  inclusive.  They  can  also  be used for code points specified
+       acters, inclusive. They can also be  used  for  code  points  specified
        numerically, for example [\000-\037]. Ranges can include any characters
        that are valid for the current mode.


-       There  is  a  special  case in EBCDIC environments for ranges whose end
+       There is a special case in EBCDIC environments  for  ranges  whose  end
        points are both specified as literal letters in the same case. For com-
-       patibility  with Perl, EBCDIC code points within the range that are not
-       letters are omitted. For example, [h-k] matches only  four  characters,
+       patibility with Perl, EBCDIC code points within the range that are  not
+       letters  are  omitted. For example, [h-k] matches only four characters,
        even though the codes for h and k are 0x88 and 0x92, a range of 11 code
-       points. However, if the range is specified  numerically,  for  example,
+       points.  However,  if  the range is specified numerically, for example,
        [\x88-\x92] or [h-\x92], all code points are included.


        If a range that includes letters is used when caseless matching is set,
        it matches the letters in either case. For example, [W-c] is equivalent
-       to  [][\\^_`wxyzabc],  matched  caselessly,  and  in a non-UTF mode, if
-       character tables for a French locale are in  use,  [\xc8-\xcb]  matches
+       to [][\\^_`wxyzabc], matched caselessly, and  in  a  non-UTF  mode,  if
+       character  tables  for  a French locale are in use, [\xc8-\xcb] matches
        accented E characters in both cases.


-       The  character escape sequences \d, \D, \h, \H, \p, \P, \s, \S, \v, \V,
+       The character escape sequences \d, \D, \h, \H, \p, \P, \s, \S, \v,  \V,
        \w, and \W may appear in a character class, and add the characters that
-       they  match to the class. For example, [\dABCDEF] matches any hexadeci-
-       mal digit. In UTF modes, the PCRE2_UCP option affects the  meanings  of
-       \d,  \s,  \w  and  their upper case partners, just as it does when they
-       appear outside a character class, as described in the section  entitled
+       they match to the class. For example, [\dABCDEF] matches any  hexadeci-
+       mal  digit.  In UTF modes, the PCRE2_UCP option affects the meanings of
+       \d, \s, \w and their upper case partners, just as  it  does  when  they
+       appear  outside a character class, as described in the section entitled
        "Generic character types" above. The escape sequence \b has a different
-       meaning inside a character class; it matches the  backspace  character.
-       The  sequences  \B,  \N,  \R, and \X are not special inside a character
-       class. Like any other unrecognized  escape  sequences,  they  cause  an
+       meaning  inside  a character class; it matches the backspace character.
+       The sequences \B, \N, \R, and \X are not  special  inside  a  character
+       class.  Like  any  other  unrecognized  escape sequences, they cause an
        error.


-       A  circumflex  can  conveniently  be used with the upper case character
-       types to specify a more restricted set of characters than the  matching
-       lower  case  type.  For example, the class [^\W_] matches any letter or
+       A circumflex can conveniently be used with  the  upper  case  character
+       types  to specify a more restricted set of characters than the matching
+       lower case type.  For example, the class [^\W_] matches any  letter  or
        digit, but not underscore, whereas [\w] includes underscore. A positive
        character class should be read as "something OR something OR ..." and a
        negative class as "NOT something AND NOT something AND NOT ...".


-       The only metacharacters that are recognized in  character  classes  are
-       backslash,  hyphen  (only  where  it can be interpreted as specifying a
-       range), circumflex (only at the start), opening  square  bracket  (only
-       when  it can be interpreted as introducing a POSIX class name, or for a
-       special compatibility feature - see the next  two  sections),  and  the
+       The  only  metacharacters  that are recognized in character classes are
+       backslash, hyphen (only where it can be  interpreted  as  specifying  a
+       range),  circumflex  (only  at the start), opening square bracket (only
+       when it can be interpreted as introducing a POSIX class name, or for  a
+       special  compatibility  feature  -  see the next two sections), and the
        terminating  closing  square  bracket.  However,  escaping  other  non-
        alphanumeric characters does no harm.


@@ -6268,7 +6364,7 @@
POSIX CHARACTER CLASSES

        Perl supports the POSIX notation for character classes. This uses names
-       enclosed  by [: and :] within the enclosing square brackets. PCRE2 also
+       enclosed by [: and :] within the enclosing square brackets. PCRE2  also
        supports this notation. For example,


          [01[:alpha:]%]
@@ -6291,13 +6387,13 @@
          word     "word" characters (same as \w)
          xdigit   hexadecimal digits


-       The  default  "space" characters are HT (9), LF (10), VT (11), FF (12),
-       CR (13), and space (32). If locale-specific matching is  taking  place,
-       the  list  of  space characters may be different; there may be fewer or
+       The default "space" characters are HT (9), LF (10), VT (11),  FF  (12),
+       CR  (13),  and space (32). If locale-specific matching is taking place,
+       the list of space characters may be different; there may  be  fewer  or
        more of them. "Space" and \s match the same set of characters.


-       The name "word" is a Perl extension, and "blank"  is  a  GNU  extension
-       from  Perl  5.8. Another Perl extension is negation, which is indicated
+       The  name  "word"  is  a Perl extension, and "blank" is a GNU extension
+       from Perl 5.8. Another Perl extension is negation, which  is  indicated
        by a ^ character after the colon. For example,


          [12[:^digit:]]
@@ -6308,9 +6404,9 @@


        By default, characters with values greater than 127 do not match any of
        the POSIX character classes, although this may be different for charac-
-       ters in the range 128-255 when locale-specific matching  is  happening.
-       However,  if the PCRE2_UCP option is passed to pcre2_compile(), some of
-       the classes are changed so that Unicode character properties are  used.
+       ters  in  the range 128-255 when locale-specific matching is happening.
+       However, if the PCRE2_UCP option is passed to pcre2_compile(), some  of
+       the  classes are changed so that Unicode character properties are used.
        This  is  achieved  by  replacing  certain  POSIX  classes  with  other
        sequences, as follows:


@@ -6324,10 +6420,10 @@
          [:upper:]  becomes  \p{Lu}
          [:word:]   becomes  \p{Xwd}


-       Negated versions, such as [:^alpha:] use \P instead of \p. Three  other
+       Negated  versions, such as [:^alpha:] use \P instead of \p. Three other
        POSIX classes are handled specially in UCP mode:


-       [:graph:] This  matches  characters that have glyphs that mark the page
+       [:graph:] This matches characters that have glyphs that mark  the  page
                  when printed. In Unicode property terms, it matches all char-
                  acters with the L, M, N, P, S, or Cf properties, except for:


@@ -6336,22 +6432,22 @@
                    U+2066 - U+2069  Various "isolate"s



-       [:print:] This  matches  the  same  characters  as [:graph:] plus space
-                 characters that are not controls, that  is,  characters  with
+       [:print:] This matches the same  characters  as  [:graph:]  plus  space
+                 characters  that  are  not controls, that is, characters with
                  the Zs property.


        [:punct:] This matches all characters that have the Unicode P (punctua-
-                 tion) property, plus those characters with code  points  less
+                 tion)  property,  plus those characters with code points less
                  than 256 that have the S (Symbol) property.


-       The  other  POSIX classes are unchanged, and match only characters with
+       The other POSIX classes are unchanged, and match only  characters  with
        code points less than 256.



COMPATIBILITY FEATURE FOR WORD BOUNDARIES

-       In the POSIX.2 compliant library that was included in 4.4BSD Unix,  the
-       ugly  syntax  [[:<:]]  and [[:>:]] is used for matching "start of word"
+       In  the POSIX.2 compliant library that was included in 4.4BSD Unix, the
+       ugly syntax [[:<:]] and [[:>:]] is used for matching  "start  of  word"
        and "end of word". PCRE2 treats these items as follows:


          [[:<:]]  is converted to  \b(?=\w)
@@ -6358,36 +6454,36 @@
          [[:>:]]  is converted to  \b(?<=\w)


        Only these exact character sequences are recognized. A sequence such as
-       [a[:<:]b]  provokes  error  for  an unrecognized POSIX class name. This
-       support is not compatible with Perl. It is provided to help  migrations
+       [a[:<:]b] provokes error for an unrecognized  POSIX  class  name.  This
+       support  is not compatible with Perl. It is provided to help migrations
        from other environments, and is best not used in any new patterns. Note
-       that \b matches at the start and the end of a word (see "Simple  asser-
-       tions"  above),  and in a Perl-style pattern the preceding or following
-       character normally shows which is wanted,  without  the  need  for  the
-       assertions  that  are used above in order to give exactly the POSIX be-
+       that  \b matches at the start and the end of a word (see "Simple asser-
+       tions" above), and in a Perl-style pattern the preceding  or  following
+       character  normally  shows  which  is  wanted, without the need for the
+       assertions that are used above in order to give exactly the  POSIX  be-
        haviour.



VERTICAL BAR

-       Vertical bar characters are used to separate alternative patterns.  For
+       Vertical  bar characters are used to separate alternative patterns. For
        example, the pattern


          gilbert|sullivan


-       matches  either "gilbert" or "sullivan". Any number of alternatives may
-       appear, and an empty  alternative  is  permitted  (matching  the  empty
+       matches either "gilbert" or "sullivan". Any number of alternatives  may
+       appear,  and  an  empty  alternative  is  permitted (matching the empty
        string). The matching process tries each alternative in turn, from left
-       to right, and the first one that succeeds is used. If the  alternatives
-       are  within a subpattern (defined below), "succeeds" means matching the
+       to  right, and the first one that succeeds is used. If the alternatives
+       are within a subpattern (defined below), "succeeds" means matching  the
        rest of the main pattern as well as the alternative in the subpattern.



INTERNAL OPTION SETTING

-       The settings of the PCRE2_CASELESS, PCRE2_MULTILINE, PCRE2_DOTALL,  and
-       PCRE2_EXTENDED  options (which are Perl-compatible) can be changed from
-       within the pattern by  a  sequence  of  Perl  option  letters  enclosed
+       The  settings of the PCRE2_CASELESS, PCRE2_MULTILINE, PCRE2_DOTALL, and
+       PCRE2_EXTENDED options (which are Perl-compatible) can be changed  from
+       within  the  pattern  by  a  sequence  of  Perl option letters enclosed
        between "(?" and ")".  The option letters are


          i  for PCRE2_CASELESS
@@ -6398,30 +6494,30 @@
        For example, (?im) sets caseless, multiline matching. It is also possi-
        ble to unset these options by preceding the letter with a hyphen, and a
        combined setting and unsetting such as (?im-sx), which sets PCRE2_CASE-
-       LESS   and   PCRE2_MULTILINE   while   unsetting    PCRE2_DOTALL    and
-       PCRE2_EXTENDED,  is also permitted. If a letter appears both before and
-       after the hyphen, the option is unset. An empty options  setting  "(?)"
+       LESS    and    PCRE2_MULTILINE   while   unsetting   PCRE2_DOTALL   and
+       PCRE2_EXTENDED, is also permitted. If a letter appears both before  and
+       after  the  hyphen, the option is unset. An empty options setting "(?)"
        is allowed. Needless to say, it has no effect.


-       The  PCRE2-specific  options  PCRE2_DUPNAMES  and PCRE2_UNGREEDY can be
-       changed in the same way as the Perl-compatible  options  by  using  the
+       The PCRE2-specific options PCRE2_DUPNAMES  and  PCRE2_UNGREEDY  can  be
+       changed  in  the  same  way as the Perl-compatible options by using the
        characters J and U respectively.


-       When  one  of  these  option  changes occurs at top level (that is, not
-       inside subpattern parentheses), the change applies to the remainder  of
+       When one of these option changes occurs at  top  level  (that  is,  not
+       inside  subpattern parentheses), the change applies to the remainder of
        the pattern that follows. If the change is placed right at the start of
-       a pattern, PCRE2 extracts it into  the  global  options  (and  it  will
-       therefore  show  up in data extracted by the pcre2_pattern_info() func-
+       a  pattern,  PCRE2  extracts  it  into  the global options (and it will
+       therefore show up in data extracted by the  pcre2_pattern_info()  func-
        tion).


-       An option change within a subpattern (see below for  a  description  of
-       subpatterns)  affects only that part of the subpattern that follows it,
+       An  option  change  within a subpattern (see below for a description of
+       subpatterns) affects only that part of the subpattern that follows  it,
        so


          (a(?i)b)c


-       matches abc and aBc and no other strings  (assuming  PCRE2_CASELESS  is
-       not  used).   By this means, options can be made to have different set-
+       matches  abc  and  aBc and no other strings (assuming PCRE2_CASELESS is
+       not used).  By this means, options can be made to have  different  set-
        tings in different parts of the pattern. Any changes made in one alter-
        native do carry on into subsequent branches within the same subpattern.
        For example,
@@ -6428,13 +6524,13 @@


          (a(?i)b|c)


-       matches "ab", "aB", "c", and "C", even though  when  matching  "C"  the
-       first  branch  is  abandoned before the option setting. This is because
-       the effects of option settings happen at compile time. There  would  be
+       matches  "ab",  "aB",  "c",  and "C", even though when matching "C" the
+       first branch is abandoned before the option setting.  This  is  because
+       the  effects  of option settings happen at compile time. There would be
        some very weird behaviour otherwise.


-       As  a  convenient shorthand, if any option settings are required at the
-       start of a non-capturing subpattern (see the next section), the  option
+       As a convenient shorthand, if any option settings are required  at  the
+       start  of a non-capturing subpattern (see the next section), the option
        letters may appear between the "?" and the ":". Thus the two patterns


          (?i:saturday|sunday)
@@ -6442,14 +6538,14 @@


        match exactly the same set of strings.


-       Note:  There  are  other  PCRE2-specific options that can be set by the
+       Note: There are other PCRE2-specific options that can  be  set  by  the
        application when the compiling function is called. The pattern can con-
-       tain  special  leading  sequences  such as (*CRLF) to override what the
-       application has set or what has been defaulted. Details  are  given  in
-       the  section  entitled  "Newline  sequences"  above. There are also the
-       (*UTF) and (*UCP) leading sequences that can be used  to  set  UTF  and
-       Unicode  property  modes;  they are equivalent to setting the PCRE2_UTF
-       and PCRE2_UCP options, respectively. However, the application  can  set
+       tain special leading sequences such as (*CRLF)  to  override  what  the
+       application  has  set  or what has been defaulted. Details are given in
+       the section entitled "Newline sequences"  above.  There  are  also  the
+       (*UTF)  and  (*UCP)  leading  sequences that can be used to set UTF and
+       Unicode property modes; they are equivalent to  setting  the  PCRE2_UTF
+       and  PCRE2_UCP  options, respectively. However, the application can set
        the PCRE2_NEVER_UTF and PCRE2_NEVER_UCP options, which lock out the use
        of the (*UTF) and (*UCP) sequences.


@@ -6463,18 +6559,18 @@

          cat(aract|erpillar|)


-       matches  "cataract",  "caterpillar", or "cat". Without the parentheses,
+       matches "cataract", "caterpillar", or "cat". Without  the  parentheses,
        it would match "cataract", "erpillar" or an empty string.


-       2. It sets up the subpattern as  a  capturing  subpattern.  This  means
+       2.  It  sets  up  the  subpattern as a capturing subpattern. This means
        that, when the whole pattern matches, the portion of the subject string
-       that matched the subpattern is passed back to  the  caller,  separately
-       from  the portion that matched the whole pattern. (This applies only to
-       the traditional matching function; the DFA matching function  does  not
+       that  matched  the  subpattern is passed back to the caller, separately
+       from the portion that matched the whole pattern. (This applies only  to
+       the  traditional  matching function; the DFA matching function does not
        support capturing.)


        Opening parentheses are counted from left to right (starting from 1) to
-       obtain numbers for the  capturing  subpatterns.  For  example,  if  the
+       obtain  numbers  for  the  capturing  subpatterns.  For example, if the
        string "the red king" is matched against the pattern


          the ((red|white) (king|queen))
@@ -6482,12 +6578,12 @@
        the captured substrings are "red king", "red", and "king", and are num-
        bered 1, 2, and 3, respectively.


-       The fact that plain parentheses fulfil  two  functions  is  not  always
-       helpful.   There are often times when a grouping subpattern is required
-       without a capturing requirement. If an opening parenthesis is  followed
-       by  a question mark and a colon, the subpattern does not do any captur-
-       ing, and is not counted when computing the  number  of  any  subsequent
-       capturing  subpatterns. For example, if the string "the white queen" is
+       The  fact  that  plain  parentheses  fulfil two functions is not always
+       helpful.  There are often times when a grouping subpattern is  required
+       without  a capturing requirement. If an opening parenthesis is followed
+       by a question mark and a colon, the subpattern does not do any  captur-
+       ing,  and  is  not  counted when computing the number of any subsequent
+       capturing subpatterns. For example, if the string "the white queen"  is
        matched against the pattern


          the ((?:red|white) (king|queen))
@@ -6495,8 +6591,8 @@
        the captured substrings are "white queen" and "queen", and are numbered
        1 and 2. The maximum number of capturing subpatterns is 65535.


-       As  a  convenient shorthand, if any option settings are required at the
-       start of a non-capturing subpattern,  the  option  letters  may  appear
+       As a convenient shorthand, if any option settings are required  at  the
+       start  of  a  non-capturing  subpattern,  the option letters may appear
        between the "?" and the ":". Thus the two patterns


          (?i:saturday|sunday)
@@ -6503,9 +6599,9 @@
          (?:(?i)saturday|sunday)


        match exactly the same set of strings. Because alternative branches are
-       tried from left to right, and options are not reset until  the  end  of
-       the  subpattern is reached, an option setting in one branch does affect
-       subsequent branches, so the above patterns match "SUNDAY"  as  well  as
+       tried  from  left  to right, and options are not reset until the end of
+       the subpattern is reached, an option setting in one branch does  affect
+       subsequent  branches,  so  the above patterns match "SUNDAY" as well as
        "Saturday".



@@ -6512,20 +6608,20 @@
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,
+       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
+       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 parentheses that  follow  the
-       subpattern  start after the highest number used in any branch. The fol-
+       theses are numbered as usual, but the number is reset at the  start  of
+       each  branch.  The numbers of any capturing parentheses that follow the
+       subpattern start after the highest number used in any branch. The  fol-
        lowing example is taken from the Perl documentation. The numbers under-
        neath show in which buffer the captured content will be stored.


@@ -6533,18 +6629,21 @@
          / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
          # 1            2         2  3        2     3     4


-       A  back  reference  to a numbered subpattern uses the most recent value
-       that is set for that number by any subpattern.  The  following  pattern
+       A back reference to a numbered subpattern uses the  most  recent  value
+       that  is  set  for that number by any subpattern. The following pattern
        matches "abcabc" or "defdef":


          /(?|(abc)|(def))\1/


-       In  contrast,  a subroutine call to a numbered subpattern always refers
-       to the first one in the pattern with the given  number.  The  following
+       In contrast, a subroutine call to a numbered subpattern  always  refers
+       to  the  first  one in the pattern with the given number. The following
        pattern matches "abcabc" or "defabc":


          /(?|(abc)|(def))(?1)/


+       A relative reference such as (?-1) is no different: it is just a conve-
+       nient way of computing an absolute group number.
+
        If  a condition test for a subpattern's having matched refers to a non-
        unique number, the test is true if any of the subpatterns of that  num-
        ber have matched.
@@ -7444,6 +7543,20 @@
        words, a negative number counts capturing  parentheses  leftwards  from
        the point at which it is encountered.


+       Be aware however, that if duplicate subpattern numbers are in use, rel-
+       ative references refer to the earliest subpattern with the  appropriate
+       number. Consider, for example:
+
+         (?|(a)|(b)) (c) (?-2)
+
+       The  first  two  capturing  groups (a) and (b) are both numbered 1, and
+       group (c) is number 2. When the reference  (?-2)  is  encountered,  the
+       second most recently opened parentheses has the number 1, but it is the
+       first such group (the (a) group) to which the  recursion  refers.  This
+       would  be  the  same  if  an absolute reference (?1) was used. In other
+       words, relative references are just a shorthand for computing  a  group
+       number.
+
        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-
@@ -8141,11 +8254,11 @@


REVISION

-       Last updated: 01 November 2015
+       Last updated: 13 November 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2PERFORM(3)            Library Functions Manual            PCRE2PERFORM(3)



@@ -8317,8 +8430,8 @@
        Last updated: 02 January 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2POSIX(3)              Library Functions Manual              PCRE2POSIX(3)



@@ -8534,7 +8647,9 @@
        IEEE  Standard  1003.2  (POSIX.2),  and  should be used with caution in
        software intended to be portable to other systems. Note that a non-zero
        rm_so does not imply REG_NOTBOL; REG_STARTEND affects only the location
-       of the string, not how it is matched.
+       of the string, not how it is matched. Setting REG_STARTEND and  passing
+       pmatch  as  NULL  are  mutually  exclusive;  the  error  REG_INVARG  is
+       returned.


        If the pattern was compiled with the REG_NOSUB flag, no data about  any
        matched  strings  is  returned.  The  nmatch  and  pmatch  arguments of
@@ -8587,11 +8702,11 @@


REVISION

-       Last updated: 30 October 2015
+       Last updated: 29 November 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2SAMPLE(3)             Library Functions Manual             PCRE2SAMPLE(3)



@@ -8839,8 +8954,8 @@
        Last updated: 03 November 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2STACK(3)              Library Functions Manual              PCRE2STACK(3)



@@ -9005,8 +9120,8 @@
        Last updated: 21 November 2014
        Copyright (c) 1997-2014 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2SYNTAX(3)             Library Functions Manual             PCRE2SYNTAX(3)



@@ -9441,8 +9556,8 @@
        Last updated: 16 October 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+
 PCRE2UNICODE(3)            Library Functions Manual            PCRE2UNICODE(3)



@@ -9680,5 +9795,5 @@
        Last updated: 16 October 2015
        Copyright (c) 1997-2015 University of Cambridge.
 ------------------------------------------------------------------------------
- 
- 
+
+


Modified: code/trunk/doc/pcre2_set_max_pattern_length.3
===================================================================
--- code/trunk/doc/pcre2_set_max_pattern_length.3    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2_set_max_pattern_length.3    2015-12-17 18:44:06 UTC (rev 471)
@@ -14,7 +14,7 @@
 .SH DESCRIPTION
 .rs
 .sp
-This function sets, in a compile context, the maximum length (in code units) of 
+This function sets, in a compile context, the maximum length (in code units) of
 the pattern that can be compiled. The result is always zero.
 .P
 There is a complete description of the PCRE2 native API in the


Modified: code/trunk/doc/pcre2_substitute.3
===================================================================
--- code/trunk/doc/pcre2_substitute.3    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2_substitute.3    2015-12-17 18:44:06 UTC (rev 471)
@@ -58,9 +58,9 @@
                               PCRE2_UTF was set at compile time)
   PCRE2_SUBSTITUTE_EXTENDED  Do extended replacement processing
   PCRE2_SUBSTITUTE_GLOBAL    Replace all occurrences in the subject
-  PCRE2_SUBSTITUTE_OVERFLOW_LENGTH  If overflow, compute needed length 
-  PCRE2_SUBSTITUTE_UNKNOWN_UNSET  Treat unknown group as unset 
-  PCRE2_SUBSTITUTE_UNSET_EMPTY  Simple unset insert = empty string 
+  PCRE2_SUBSTITUTE_OVERFLOW_LENGTH  If overflow, compute needed length
+  PCRE2_SUBSTITUTE_UNKNOWN_UNSET  Treat unknown group as unset
+  PCRE2_SUBSTITUTE_UNSET_EMPTY  Simple unset insert = empty string
 .sp
 The function returns the number of substitutions, which may be zero if there
 were no matches. The result can be greater than one only when


Modified: code/trunk/doc/pcre2api.3
===================================================================
--- code/trunk/doc/pcre2api.3    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2api.3    2015-12-17 18:44:06 UTC (rev 471)
@@ -1,4 +1,4 @@
-.TH PCRE2API 3 "12 December 2015" "PCRE2 10.21"
+.TH PCRE2API 3 "16 December 2015" "PCRE2 10.21"
 .SH NAME
 PCRE2 - Perl-compatible regular expressions (revised API)
 .sp
@@ -570,7 +570,7 @@
   PCRE2's character tables
   The newline character sequence
   The compile time nested parentheses limit
-  The maximum length of the pattern string 
+  The maximum length of the pattern string
   An external function for stack checking
 .sp
 A compile context is also required if you are using custom memory management.
@@ -618,10 +618,10 @@
 .B "  PCRE2_SIZE \fIvalue\fP);"
 .fi
 .sp
-This sets a maximum length, in code units, for the pattern string that is to be 
-compiled. If the pattern is longer, an error is generated. This facility is 
-provided so that applications that accept patterns from external sources can 
-limit their size. The default is the largest number that a PCRE2_SIZE variable 
+This sets a maximum length, in code units, for the pattern string that is to be
+compiled. If the pattern is longer, an error is generated. This facility is
+provided so that applications that accept patterns from external sources can
+limit their size. The default is the largest number that a PCRE2_SIZE variable
 can hold, which is effectively unlimited.
 .sp
 .nf
@@ -678,8 +678,8 @@
 .sp
   A callout function
   The offset limit for matching an unanchored pattern
-  The limit for calling \fImatch()\fP
-  The limit for calling \fImatch()\fP recursively
+  The limit for calling \fBmatch()\fP (see below)
+  The limit for calling \fBmatch()\fP recursively
 .sp
 A match context is also required if you are using custom memory management.
 If none of these apply, just pass NULL as the context argument of
@@ -736,7 +736,7 @@
 .P
 The offset limit facility can be used to track progress when searching large
 subject strings. See also the PCRE2_FIRSTLINE option, which requires a match to
-start within the first line of the subject. If this is set with an offset 
+start within the first line of the subject. If this is set with an offset
 limit, a match must occur in the first line and also within the offset limit.
 In other words, whichever limit comes first is used.
 .sp
@@ -1228,7 +1228,7 @@
 This escape can cause unpredictable behaviour in UTF-8 or UTF-16 modes, because
 it may leave the current matching point in the middle of a multi-code-unit
 character. This option may be useful in applications that process patterns from
-external sources. Note that there is also a build-time option that permanently 
+external sources. Note that there is also a build-time option that permanently
 locks out the use of \eC.
 .sp
   PCRE2_NEVER_UCP
@@ -1565,7 +1565,7 @@
 Return a copy of the pattern's options. The third argument should point to a
 \fBuint32_t\fP variable. PCRE2_INFO_ARGOPTIONS returns exactly the options that
 were passed to \fBpcre2_compile()\fP, whereas PCRE2_INFO_ALLOPTIONS returns
-the compile options as modified by any top-level option settings such as (*UTF) 
+the compile options as modified by any top-level option settings such as (*UTF)
 at the start of the pattern itself. For example, if the pattern /(*UTF)abc/ is
 compiled with the PCRE2_EXTENDED option, the result is PCRE2_EXTENDED and
 PCRE2_UTF.
@@ -1611,8 +1611,9 @@
 .sp
   PCRE2_INFO_CAPTURECOUNT
 .sp
-Return the number of capturing subpatterns in the pattern. The third argument
-should point to an \fBuint32_t\fP variable.
+Return the highest capturing subpattern number in the pattern. In patterns
+where (?| is not used, this is also the total number of capturing subpatterns.
+The third argument should point to an \fBuint32_t\fP variable.
 .sp
   PCRE2_INFO_FIRSTBITMAP
 .sp
@@ -1629,10 +1630,8 @@
 .sp
 Return information about the first code unit of any matched string, for a
 non-anchored pattern. The third argument should point to an \fBuint32_t\fP
-variable.
-.P
-If there is a fixed first value, for example, the letter "c" from a pattern
-such as (cat|cow|coyote), 1 is returned, and the character value can be
+variable. If there is a fixed first value, for example, the letter "c" from a
+pattern such as (cat|cow|coyote), 1 is returned, and the character value can be
 retrieved using PCRE2_INFO_FIRSTCODEUNIT. If there is no fixed first value, but
 it is known that a match can occur only at the start of the subject or
 following a newline in the subject, 2 is returned. Otherwise, and for anchored
@@ -1676,12 +1675,10 @@
 matched string, other than at its start. The third argument should  point to an
 \fBuint32_t\fP variable. If there is no such value, 0 is returned. When 1 is
 returned, the code unit value itself can be retrieved using
-PCRE2_INFO_LASTCODEUNIT.
-.P
-For anchored patterns, a last literal value is recorded only if it follows
-something of variable length. For example, for the pattern /^a\ed+z\ed+/ the
-returned value is 1 (with "z" returned from PCRE2_INFO_LASTCODEUNIT), but for
-/^a\edz\ed/ the returned value is 0.
+PCRE2_INFO_LASTCODEUNIT. For anchored patterns, a last literal value is
+recorded only if it follows something of variable length. For example, for the
+pattern /^a\ed+z\ed+/ the returned value is 1 (with "z" returned from
+PCRE2_INFO_LASTCODEUNIT), but for /^a\edz\ed/ the returned value is 0.
 .sp
   PCRE2_INFO_LASTCODEUNIT
 .sp
@@ -1693,9 +1690,9 @@
   PCRE2_INFO_MATCHEMPTY
 .sp
 Return 1 if the pattern might match an empty string, otherwise 0. The third
-argument should point to an \fBuint32_t\fP variable. When a pattern contains 
-recursive subroutine calls it is not always possible to determine whether or 
-not it can match an empty string. PCRE2 takes a cautious approach and returns 1 
+argument should point to an \fBuint32_t\fP variable. When a pattern contains
+recursive subroutine calls it is not always possible to determine whether or
+not it can match an empty string. PCRE2 takes a cautious approach and returns 1
 in such cases.
 .sp
   PCRE2_INFO_MATCHLIMIT
@@ -2181,9 +2178,19 @@
 a
 .\" HTML <a href="#compilecontext">
 .\" </a>
-compile context.
+compile context
 .\"
-During matching, the newline choice affects the behaviour of the dot,
+by calling \fBpcre2_set_newline()\fP. It can also be overridden by starting a
+pattern string with, for example, (*CRLF), as described in the
+.\" HTML <a href="pcre2pattern.html#newlines">
+.\" </a>
+section on newline conventions
+.\"
+in the
+.\" HREF
+\fBpcre2pattern\fP
+.\"
+page. During matching, the newline choice affects the behaviour of the dot,
 circumflex, and dollar metacharacters. It may also alter the way the match
 starting position is advanced after a match failure for an unanchored pattern.
 .P
@@ -2229,18 +2236,7 @@
 function can be used to find out how many capturing subpatterns there are in a
 compiled pattern.
 .P
-A successful match returns the overall matched string and any captured
-substrings to the caller via a vector of PCRE2_SIZE values. This is called the
-\fBovector\fP, and is contained within the
-.\" HTML <a href="#matchdatablock">
-.\" </a>
-match data block.
-.\"
-You can obtain direct access to the ovector by calling
-\fBpcre2_get_ovector_pointer()\fP to find its address, and
-\fBpcre2_get_ovector_count()\fP to find the number of pairs of values it
-contains. Alternatively, you can use the auxiliary functions for accessing
-captured substrings
+You can use auxiliary functions for accessing captured substrings
 .\" HTML <a href="#extractbynumber">
 .\" </a>
 by number
@@ -2248,10 +2244,21 @@
 or
 .\" HTML <a href="#extractbyname">
 .\" </a>
-by name
+by name,
 .\"
-(see below).
+as described in sections below.
 .P
+Alternatively, you can make direct use of the vector of PCRE2_SIZE values,
+called the \fBovector\fP, which contains the offsets of captured strings. It is
+part of the
+.\" HTML <a href="#matchdatablock">
+.\" </a>
+match data block.
+.\"
+The function \fBpcre2_get_ovector_pointer()\fP returns the address of the
+ovector, and \fBpcre2_get_ovector_count()\fP returns the number of pairs of
+values it contains.
+.P
 Within the ovector, the first in each pair of values is set to the offset of
 the first code unit of a substring, and the second is set to the offset of the
 first code unit after the end of a substring. These values are always code unit
@@ -2334,7 +2341,12 @@
 to match (PCRE2_ERROR_NOMATCH), a (*MARK) name may be available, and
 \fBpcre2_get_mark()\fP can be called. It returns a pointer to the
 zero-terminated name, which is within the compiled pattern. Otherwise NULL is
-returned. After a successful match, the (*MARK) name that is returned is the
+returned. The length of the (*MARK) name (excluding the terminating zero) is
+stored in the code unit that preceeds the name. You should use this instead of
+relying on the terminating zero if the (*MARK) name might contain a binary
+zero.
+.P
+After a successful match, the (*MARK) name that is returned is the
 last one encountered on the matching path through the pattern. After a "no
 match" or a partial match, the last encountered (*MARK) name is returned. For
 example, consider this pattern:
@@ -2353,7 +2365,7 @@
 escape sequence. After a partial match, however, this value is always the same
 as \fIovector[0]\fP because \eK does not affect the result of a partial match.
 .P
-After a UTF check failure, \fBpcre2_get_startchar()\fB can be used to obtain
+After a UTF check failure, \fBpcre2_get_startchar()\fP can be used to obtain
 the code unit offset of the invalid UTF character. Details are given in the
 .\" HREF
 \fBpcre2unicode\fP
@@ -2692,7 +2704,7 @@
 This function calls \fBpcre2_match()\fP and then makes a copy of the subject
 string in \fIoutputbuffer\fP, replacing the part that was matched with the
 \fIreplacement\fP string, whose length is supplied in \fBrlength\fP. This can
-be given as PCRE2_ZERO_TERMINATED for a zero-terminated string. Matches in 
+be given as PCRE2_ZERO_TERMINATED for a zero-terminated string. Matches in
 which a \eK item in a lookahead in the pattern causes the match to end before
 it starts are not supported, and give rise to an error return.
 .P
@@ -2706,7 +2718,7 @@
 The \fIoutlengthptr\fP argument must point to a variable that contains the
 length, in code units, of the output buffer. If the function is successful, the
 value is updated to contain the length of the new string, excluding the
-trailing zero that is automatically added. 
+trailing zero that is automatically added.
 .P
 If the function is not successful, the value set via \fIoutlengthptr\fP depends
 on the type of error. For syntax errors in the replacement string, the value is
@@ -2754,7 +2766,7 @@
 next two characters are CR, LF. In this case, the current position is advanced
 by two characters.
 .P
-PCRE2_SUBSTITUTE_OVERFLOW_LENGTH changes what happens when the output buffer is 
+PCRE2_SUBSTITUTE_OVERFLOW_LENGTH changes what happens when the output buffer is
 too small. The default action is to return PCRE2_ERROR_NOMEMORY immediately. If
 this option is set, however, \fBpcre2_substitute()\fP continues to go through
 the motions of matching and substituting (without, of course, writing anything)
@@ -2762,15 +2774,15 @@
 back via the \fIoutlengthptr\fP variable, with the result of the function still
 being PCRE2_ERROR_NOMEMORY.
 .P
-Passing a buffer size of zero is a permitted way of finding out how much memory 
-is needed for given substitution. However, this does mean that the entire 
-operation is carried out twice. Depending on the application, it may be more 
-efficient to allocate a large buffer and free the excess afterwards, instead of 
+Passing a buffer size of zero is a permitted way of finding out how much memory
+is needed for given substitution. However, this does mean that the entire
+operation is carried out twice. Depending on the application, it may be more
+efficient to allocate a large buffer and free the excess afterwards, instead of
 using PCRE2_SUBSTITUTE_OVERFLOW_LENGTH.
 .P
-PCRE2_SUBSTITUTE_UNKNOWN_UNSET causes references to capturing groups that do 
-not appear in the pattern to be treated as unset groups. This option should be 
-used with care, because it means that a typo in a group name or number no 
+PCRE2_SUBSTITUTE_UNKNOWN_UNSET causes references to capturing groups that do
+not appear in the pattern to be treated as unset groups. This option should be
+used with care, because it means that a typo in a group name or number no
 longer causes the PCRE2_ERROR_NOSUBSTRING error.
 .P
 PCRE2_SUBSTITUTE_UNSET_EMPTY causes unset capturing groups (including unknown
@@ -2828,8 +2840,8 @@
       somebody
    1: HELLO
 .sp
-The PCRE2_SUBSTITUTE_UNSET_EMPTY option does not affect these extended 
-substitutions. However, PCRE2_SUBSTITUTE_UNKNOWN_UNSET does cause unknown 
+The PCRE2_SUBSTITUTE_UNSET_EMPTY option does not affect these extended
+substitutions. However, PCRE2_SUBSTITUTE_UNKNOWN_UNSET does cause unknown
 groups in the extended syntax forms to be treated as unset.
 .P
 If successful, \fBpcre2_substitute()\fP returns the number of replacements that
@@ -2838,7 +2850,7 @@
 .P
 In the event of an error, a negative error code is returned. Except for
 PCRE2_ERROR_NOMATCH (which is never returned), errors from \fBpcre2_match()\fP
-are passed straight back. 
+are passed straight back.
 .P
 PCRE2_ERROR_NOSUBSTRING is returned for a non-existent substring insertion,
 unless PCRE2_SUBSTITUTE_UNKNOWN_UNSET is set.
@@ -2849,7 +2861,7 @@
 .P
 PCRE2_ERROR_NOMEMORY is returned if the output buffer is not big enough. If the
 PCRE2_SUBSTITUTE_OVERFLOW_LENGTH option is set, the size of buffer that is
-needed is returned via \fIoutlengthptr\fP. Note that this does not happen by 
+needed is returned via \fIoutlengthptr\fP. Note that this does not happen by
 default.
 .P
 PCRE2_ERROR_BADREPLACEMENT is used for miscellaneous syntax errors in the
@@ -2857,7 +2869,7 @@
 (invalid escape sequence), PCRE2_ERROR_REPMISSING_BRACE (closing curly bracket
 not found), PCRE2_BADSUBSTITUTION (syntax error in extended group
 substitution), and PCRE2_BADSUBPATTERN (the pattern match ended before it
-started, which can happen if \eK is used in an assertion). 
+started, which can happen if \eK is used in an assertion).
 .P
 As for all PCRE2 errors, a text message that describes the error can be
 obtained by calling \fBpcre2_get_error_message()\fP.
@@ -2901,14 +2913,14 @@
 function returns the length of each entry in code units. In both cases,
 PCRE2_ERROR_NOSUBSTRING is returned if there are no entries for the given name.
 .P
-The format of the name table is described above in the section entitled
-\fIInformation about a pattern\fP
+The format of the name table is described
 .\" HTML <a href="#infoaboutpattern">
 .\" </a>
-above.
+above
 .\"
-Given all the relevant entries for the name, you can extract each of their
-numbers, and hence the captured data.
+in the section entitled \fIInformation about a pattern\fP. Given all the
+relevant entries for the name, you can extract each of their numbers, and hence
+the captured data.
 .
 .
 .SH "FINDING ALL POSSIBLE MATCHES AT ONE POSITION"
@@ -3154,6 +3166,6 @@
 .rs
 .sp
 .nf
-Last updated: 21 December 2015
+Last updated: 16 December 2015
 Copyright (c) 1997-2015 University of Cambridge.
 .fi


Modified: code/trunk/doc/pcre2limits.3
===================================================================
--- code/trunk/doc/pcre2limits.3    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2limits.3    2015-12-17 18:44:06 UTC (rev 471)
@@ -20,8 +20,8 @@
 However, the speed of execution is slower. In the 32-bit library, the internal
 linkage size is always 4.
 .P
-The maximum length of a source pattern string is essentially unlimited; it is 
-the largest number a PCRE2_SIZE variable can hold. However, the program that 
+The maximum length of a source pattern string is essentially unlimited; it is
+the largest number a PCRE2_SIZE variable can hold. However, the program that
 calls \fBpcre2_compile()\fP can specify a smaller limit.
 .P
 The maximum length (in code units) of a subject string is one less than the


Modified: code/trunk/doc/pcre2pattern.3
===================================================================
--- code/trunk/doc/pcre2pattern.3    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2pattern.3    2015-12-17 18:44:06 UTC (rev 471)
@@ -1188,11 +1188,11 @@
 .\" </a>
 "Newline conventions"
 .\"
-below) recognizes the two-character sequence CRLF as a newline, this is 
-preferred, even if the single characters CR and LF are also recognized as 
+below) recognizes the two-character sequence CRLF as a newline, this is
+preferred, even if the single characters CR and LF are also recognized as
 newlines. For example, if the newline convention is "any", a multiline mode
 circumflex matches before "xyz" in the string "abc\er\enxyz" rather than after
-CR, even though CR on its own is a valid newline. (It also matches at the very 
+CR, even though CR on its own is a valid newline. (It also matches at the very
 start of the string, of course.)
 .P
 Note that the sequences \eA, \eZ, and \ez can be used to match the start and
@@ -1245,7 +1245,7 @@
 with a malformed UTF character. This has undefined results, because PCRE2
 assumes that it is matching character by character in a valid UTF string (by
 default it checks the subject string's validity at the start of processing
-unless the PCRE2_NO_UTF_CHECK option is used). 
+unless the PCRE2_NO_UTF_CHECK option is used).
 .P
 An application can lock out the use of \eC by setting the
 PCRE2_NEVER_BACKSLASH_C option when compiling a pattern. It is also possible to
@@ -1257,9 +1257,9 @@
 (described below)
 .\"
 in a UTF mode, because this would make it impossible to calculate the length of
-the lookbehind. Neither the alternative matching function 
-\fBpcre2_dfa_match()\fP not the JIT optimizer support \eC in a UTF mode. The 
-former gives a match-time error; the latter fails to optimize and so the match 
+the lookbehind. Neither the alternative matching function
+\fBpcre2_dfa_match()\fP not the JIT optimizer support \eC in a UTF mode. The
+former gives a match-time error; the latter fails to optimize and so the match
 is always run using the interpreter.
 .P
 In general, the \eC escape sequence is best avoided. However, one way of using
@@ -1347,11 +1347,11 @@
 example [\e000-\e037]. Ranges can include any characters that are valid for the
 current mode.
 .P
-There is a special case in EBCDIC environments for ranges whose end points are 
-both specified as literal letters in the same case. For compatibility with 
-Perl, EBCDIC code points within the range that are not letters are omitted. For 
-example, [h-k] matches only four characters, even though the codes for h and k 
-are 0x88 and 0x92, a range of 11 code points. However, if the range is 
+There is a special case in EBCDIC environments for ranges whose end points are
+both specified as literal letters in the same case. For compatibility with
+Perl, EBCDIC code points within the range that are not letters are omitted. For
+example, [h-k] matches only four characters, even though the codes for h and k
+are 0x88 and 0x92, a range of 11 code points. However, if the range is
 specified numerically, for example, [\ex88-\ex92] or [h-\ex92], all code points
 are included.
 .P
@@ -1683,7 +1683,7 @@
 .sp
   /(?|(abc)|(def))(?1)/
 .sp
-A relative reference such as (?-1) is no different: it is just a convenient way 
+A relative reference such as (?-1) is no different: it is just a convenient way
 of computing an absolute group number.
 .P
 If a
@@ -2549,7 +2549,7 @@
   (?(VERSION>=10.4)yes|no)
 .sp
 This pattern matches "yes" if the PCRE2 version is greater or equal to 10.4, or
-"no" otherwise. The fractional part of the version number may not contain more 
+"no" otherwise. The fractional part of the version number may not contain more
 than two digits.
 .
 .
@@ -2667,12 +2667,12 @@
 parentheses preceding the recursion. In other words, a negative number counts
 capturing parentheses leftwards from the point at which it is encountered.
 .P
-Be aware however, that if 
+Be aware however, that if
 .\" HTML <a href="#dupsubpatternnumber">
 .\" </a>
 duplicate subpattern numbers
 .\"
-are in use, relative references refer to the earliest subpattern with the 
+are in use, relative references refer to the earliest subpattern with the
 appropriate number. Consider, for example:
 .sp
   (?|(a)|(b)) (c) (?-2)
@@ -2679,9 +2679,9 @@
 .sp
 The first two capturing groups (a) and (b) are both numbered 1, and group (c)
 is number 2. When the reference (?-2) is encountered, the second most recently
-opened parentheses has the number 1, but it is the first such group (the (a) 
-group) to which the recursion refers. This would be the same if an absolute 
-reference (?1) was used. In other words, relative references are just a 
+opened parentheses has the number 1, but it is the first such group (the (a)
+group) to which the recursion refers. This would be the same if an absolute
+reference (?1) was used. In other words, relative references are just a
 shorthand for computing a group number.
 .P
 It is also possible to refer to subsequently opened parentheses, by writing
@@ -2988,13 +2988,13 @@
 depending on whether or not a name is present.
 .P
 By default, for compatibility with Perl, a name is any sequence of characters
-that does not include a closing parenthesis. The name is not processed in 
+that does not include a closing parenthesis. The name is not processed in
 any way, and it is not possible to include a closing parenthesis in the name.
-However, if the PCRE2_ALT_VERBNAMES option is set, normal backslash processing 
-is applied to verb names and only an unescaped closing parenthesis terminates 
-the name. A closing parenthesis can be included in a name either as \e) or 
-between \eQ and \eE. If the PCRE2_EXTENDED option is set, unescaped whitespace 
-in verb names is skipped and #-comments are recognized, exactly as in the rest 
+However, if the PCRE2_ALT_VERBNAMES option is set, normal backslash processing
+is applied to verb names and only an unescaped closing parenthesis terminates
+the name. A closing parenthesis can be included in a name either as \e) or
+between \eQ and \eE. If the PCRE2_EXTENDED option is set, unescaped whitespace
+in verb names is skipped and #-comments are recognized, exactly as in the rest
 of the pattern.
 .P
 The maximum length of a name is 255 in the 8-bit library and 65535 in the


Modified: code/trunk/doc/pcre2posix.3
===================================================================
--- code/trunk/doc/pcre2posix.3    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2posix.3    2015-12-17 18:44:06 UTC (rev 471)
@@ -174,7 +174,7 @@
 PCRE2_DOLLAR_ENDONLY when calling \fBpcre2_compile()\fP directly, but there is
 no way to make PCRE2 behave exactly as for the REG_NEWLINE action. When using
 the POSIX API, passing REG_NEWLINE to PCRE2's \fBregcomp()\fP function
-causes PCRE2_MULTILINE to be passed to \fBpcre2_compile()\fP, and REG_DOTALL 
+causes PCRE2_MULTILINE to be passed to \fBpcre2_compile()\fP, and REG_DOTALL
 passes PCRE2_DOTALL. There is no way to pass PCRE2_DOLLAR_ENDONLY.
 .
 .
@@ -211,7 +211,7 @@
 IEEE Standard 1003.2 (POSIX.2), and should be used with caution in software
 intended to be portable to other systems. Note that a non-zero \fIrm_so\fP does
 not imply REG_NOTBOL; REG_STARTEND affects only the location of the string, not
-how it is matched. Setting REG_STARTEND and passing \fIpmatch\fP as NULL are 
+how it is matched. Setting REG_STARTEND and passing \fIpmatch\fP as NULL are
 mutually exclusive; the error REG_INVARG is returned.
 .P
 If the pattern was compiled with the REG_NOSUB flag, no data about any matched


Modified: code/trunk/doc/pcre2serialize.3
===================================================================
--- code/trunk/doc/pcre2serialize.3    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2serialize.3    2015-12-17 18:44:06 UTC (rev 471)
@@ -140,13 +140,13 @@
 .P
 Decoded patterns can be used for matching in the usual way, and must be freed
 by calling \fBpcre2_code_free()\fP. However, be aware that there is a potential
-race issue if you are using multiple patterns that were decoded from a single 
+race issue if you are using multiple patterns that were decoded from a single
 byte stream in a multithreaded application. A single copy of the character
 tables is used by all the decoded patterns and a reference count is used to
 arrange for its memory to be automatically freed when the last pattern is
 freed, but there is no locking on this reference count. Therefore, if you want
 to call \fBpcre2_code_free()\fP for these patterns in different threads, you
-must arrange your own locking, and ensure that \fBpcre2_code_free()\fP cannot 
+must arrange your own locking, and ensure that \fBpcre2_code_free()\fP cannot
 be called by two threads at the same time.
 .P
 If a pattern was processed by \fBpcre2_jit_compile()\fP before being


Modified: code/trunk/doc/pcre2syntax.3
===================================================================
--- code/trunk/doc/pcre2syntax.3    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2syntax.3    2015-12-17 18:44:06 UTC (rev 471)
@@ -83,7 +83,7 @@
 .sp
 \eC is dangerous because it may leave the current matching point in the middle
 of a UTF-8 or UTF-16 character. The application can lock out the use of \eC by
-setting the PCRE2_NEVER_BACKSLASH_C option. It is also possible to build PCRE2 
+setting the PCRE2_NEVER_BACKSLASH_C option. It is also possible to build PCRE2
 with the use of \eC permanently disabled.
 .P
 By default, \ed, \es, and \ew match only ASCII characters, even in UTF-8 mode


Modified: code/trunk/doc/pcre2test.1
===================================================================
--- code/trunk/doc/pcre2test.1    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2test.1    2015-12-17 18:44:06 UTC (rev 471)
@@ -444,12 +444,12 @@
 .sp
   abc\e=notbol,notempty
 .sp
-If the subject string is empty and \e= is followed by whitespace, the line is 
+If the subject string is empty and \e= is followed by whitespace, the line is
 treated as a comment line, and is not used for matching. For example:
 .sp
   \e= This is a comment.
   abc\e= This is an invalid modifier list.
-.sp    
+.sp
 A backslash followed by any other non-alphanumeric character just escapes that
 character. A backslash followed by anything else causes an error. However, if
 the very last character in the line is a backslash (and there is no modifier
@@ -501,7 +501,7 @@
       no_utf_check              set PCRE2_NO_UTF_CHECK
       ucp                       set PCRE2_UCP
       ungreedy                  set PCRE2_UNGREEDY
-      use_offset_limit          set PCRE2_USE_OFFSET_LIMIT 
+      use_offset_limit          set PCRE2_USE_OFFSET_LIMIT
       utf                       set PCRE2_UTF
 .sp
 As well as turning on the PCRE2_UTF option, the \fButf\fP modifier causes all
@@ -528,7 +528,7 @@
       jitfast                   use JIT fast path
       jitverify                 verify JIT use
       locale=<name>             use this locale
-      max_pattern_length=<n>    set the maximum pattern length 
+      max_pattern_length=<n>    set the maximum pattern length
       memory                    show memory used
       newline=<type>            set newline type
       null_context              compile with a NULL context
@@ -608,9 +608,9 @@
 .SS "Passing a NULL context"
 .rs
 .sp
-Normally, \fBpcre2test\fP passes a context block to \fBpcre2_compile()\fP. If 
-the \fBnull_context\fP modifier is set, however, NULL is passed. This is for 
-testing that \fBpcre2_compile()\fP behaves correctly in this case (it uses 
+Normally, \fBpcre2test\fP passes a context block to \fBpcre2_compile()\fP. If
+the \fBnull_context\fP modifier is set, however, NULL is passed. This is for
+testing that \fBpcre2_compile()\fP behaves correctly in this case (it uses
 default values).
 .
 .
@@ -634,9 +634,9 @@
 .rs
 .sp
 Some tests use long patterns that are very repetitive. Instead of creating a
-very long input line for such a pattern, you can use a special repetition 
-feature, similar to the one described for subject lines above. If the 
-\fBexpand\fP modifier is present on a pattern, parts of the pattern that have 
+very long input line for such a pattern, you can use a special repetition
+feature, similar to the one described for subject lines above. If the
+\fBexpand\fP modifier is present on a pattern, parts of the pattern that have
 the form
 .sp
   \e[<characters>]{<count>}
@@ -647,12 +647,12 @@
 by decimal digits and "}" is found later in the pattern. If not, the characters
 remain in the pattern unaltered.
 .P
-If part of an expanded pattern looks like an expansion, but is really part of 
-the actual pattern, unwanted expansion can be avoided by giving two values in 
-the quantifier. For example, \e[AB]{6000,6000} is not recognized as an 
+If part of an expanded pattern looks like an expansion, but is really part of
+the actual pattern, unwanted expansion can be avoided by giving two values in
+the quantifier. For example, \e[AB]{6000,6000} is not recognized as an
 expansion item.
 .P
-If the \fBinfo\fP modifier is set on an expanded pattern, the result of the 
+If the \fBinfo\fP modifier is set on an expanded pattern, the result of the
 expansion is included in the information that is output.
 .
 .
@@ -771,9 +771,9 @@
 .SS "Limiting the pattern length"
 .rs
 .sp
-The \fBmax_pattern_length\fP modifier sets a limit, in code units, to the 
-length of pattern that \fBpcre2_compile()\fP will accept. Breaching the limit 
-causes a compilation error. The default is the largest number a PCRE2_SIZE 
+The \fBmax_pattern_length\fP modifier sets a limit, in code units, to the
+length of pattern that \fBpcre2_compile()\fP will accept. Breaching the limit
+causes a compilation error. The default is the largest number a PCRE2_SIZE
 variable can hold (essentially unlimited).
 .
 .
@@ -797,13 +797,13 @@
   ucp                REG_UCP        )   the POSIX standard
   utf                REG_UTF8       )
 .sp
-The \fBregerror_buffsize\fP modifier specifies a size for the error buffer that 
+The \fBregerror_buffsize\fP modifier specifies a size for the error buffer that
 is passed to \fBregerror()\fP in the event of a compilation error. For example:
 .sp
   /abc/posix,regerror_buffsize=20
 .sp
-This provides a means of testing the behaviour of \fBregerror()\fP when the 
-buffer is too small for the error message. If this modifier has not been set, a 
+This provides a means of testing the behaviour of \fBregerror()\fP when the
+buffer is too small for the error message. If this modifier has not been set, a
 large buffer is used.
 .P
 The \fBaftertext\fP and \fBallaftertext\fP subject modifiers work as described
@@ -863,9 +863,9 @@
       replace=<string>           specify a replacement string
       startchar                  show starting character when relevant
       substitute_extended        use PCRE2_SUBSTITUTE_EXTENDED
-      substitute_overflow_length use PCRE2_SUBSTITUTE_OVERFLOW_LENGTH 
-      substitute_unknown_unset   use PCRE2_SUBSTITUTE_UNKNOWN_UNSET 
-      substitute_unset_empty     use PCRE2_SUBSTITUTE_UNSET_EMPTY  
+      substitute_overflow_length use PCRE2_SUBSTITUTE_OVERFLOW_LENGTH
+      substitute_unknown_unset   use PCRE2_SUBSTITUTE_UNKNOWN_UNSET
+      substitute_unset_empty     use PCRE2_SUBSTITUTE_UNSET_EMPTY
 .sp
 These modifiers may not appear in a \fB#pattern\fP command. If you want them as
 defaults, set them in a \fB#subject\fP command.
@@ -956,7 +956,7 @@
       mark                       show mark values
       match_limit=<n>            set a match limit
       memory                     show memory usage
-      null_context               match with a NULL context 
+      null_context               match with a NULL context
       offset=<n>                 set starting offset
       offset_limit=<n>           set offset limit
       ovector=<n>                set size of output vector
@@ -965,9 +965,9 @@
       startchar                  show startchar when relevant
       startoffset=<n>            same as offset=<n>
       substitute_extedded        use PCRE2_SUBSTITUTE_EXTENDED
-      substitute_overflow_length use PCRE2_SUBSTITUTE_OVERFLOW_LENGTH 
-      substitute_unknown_unset   use PCRE2_SUBSTITUTE_UNKNOWN_UNSET 
-      substitute_unset_empty     use PCRE2_SUBSTITUTE_UNSET_EMPTY  
+      substitute_overflow_length use PCRE2_SUBSTITUTE_OVERFLOW_LENGTH
+      substitute_unknown_unset   use PCRE2_SUBSTITUTE_UNKNOWN_UNSET
+      substitute_unset_empty     use PCRE2_SUBSTITUTE_UNSET_EMPTY
       zero_terminate             pass the subject as zero-terminated
 .sp
 The effects of these modifiers are described in the following sections.
@@ -1102,7 +1102,7 @@
 If the \fBreplace\fP modifier is set, the \fBpcre2_substitute()\fP function is
 called instead of one of the matching functions. Note that replacement strings
 cannot contain commas, because a comma signifies the end of a modifier. This is
-not thought to be an issue in a test program. 
+not thought to be an issue in a test program.
 .P
 Unlike subject strings, \fBpcre2test\fP does not process replacement strings
 for escape sequences. In UTF mode, a replacement string is checked to see if it
@@ -1119,7 +1119,7 @@
   substitute_overflow_length  PCRE2_SUBSTITUTE_OVERFLOW_LENGTH
   substitute_unknown_unset    PCRE2_SUBSTITUTE_UNKNOWN_UNSET
   substitute_unset_empty      PCRE2_SUBSTITUTE_UNSET_EMPTY
-.sp       
+.sp
 .P
 After a successful substitution, the modified string is output, preceded by the
 number of replacements. This may be zero if there were no matches. Here is a
@@ -1230,10 +1230,10 @@
 .SS "Setting an offset limit"
 .rs
 .sp
-The \fBoffset_limit\fP modifier sets a limit for unanchored matches. If a match 
-cannot be found starting at or before this offset in the subject, a "no match" 
-return is given. The data value is a number of code units, not characters. When 
-this modifier is used, the \fBuse_offset_limit\fP modifier must have been set 
+The \fBoffset_limit\fP modifier sets a limit for unanchored matches. If a match
+cannot be found starting at or before this offset in the subject, a "no match"
+return is given. The data value is a number of code units, not characters. When
+this modifier is used, the \fBuse_offset_limit\fP modifier must have been set
 for the pattern; if not, an error is generated.
 .
 .
@@ -1273,8 +1273,8 @@
 Normally, \fBpcre2test\fP passes a context block to \fBpcre2_match()\fP,
 \fBpcre2_dfa_match()\fP or \fBpcre2_jit_match()\fP. If the \fBnull_context\fP
 modifier is set, however, NULL is passed. This is for testing that the matching
-functions behave correctly in this case (they use default values). This 
-modifier cannot be used with the \fBfind_limits\fP modifier or when testing the 
+functions behave correctly in this case (they use default values). This
+modifier cannot be used with the \fBfind_limits\fP modifier or when testing the
 substitution function.
 .
 .


Modified: code/trunk/doc/pcre2test.txt
===================================================================
--- code/trunk/doc/pcre2test.txt    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2test.txt    2015-12-17 18:44:06 UTC (rev 471)
@@ -797,14 +797,18 @@
        with that pattern. They may not appear in #pattern commands. These mod-
        ifiers do not affect the compilation process.


-             aftertext           show text after match
-             allaftertext        show text after captures
-             allcaptures         show all captures
-             allusedtext         show all consulted text
-         /g  global              global matching
-             mark                show mark values
-             replace=<string>    specify a replacement string
-             startchar           show starting character when relevant
+             aftertext                  show text after match
+             allaftertext               show text after captures
+             allcaptures                show all captures
+             allusedtext                show all consulted text
+         /g  global                     global matching
+             mark                       show mark values
+             replace=<string>           specify a replacement string
+             startchar                  show starting character when relevant
+             substitute_extended        use PCRE2_SUBSTITUTE_EXTENDED
+             substitute_overflow_length use PCRE2_SUBSTITUTE_OVERFLOW_LENGTH
+             substitute_unknown_unset   use PCRE2_SUBSTITUTE_UNKNOWN_UNSET
+             substitute_unset_empty     use PCRE2_SUBSTITUTE_UNSET_EMPTY


        These  modifiers may not appear in a #pattern command. If you want them
        as defaults, set them in a #subject command.
@@ -860,33 +864,38 @@
        line (see above), in which case they apply to every subject  line  that
        is matched against that pattern.


-             aftertext                 show text after match
-             allaftertext              show text after captures
-             allcaptures               show all captures
-             allusedtext               show all consulted text (non-JIT only)
-             altglobal                 alternative global matching
-             callout_capture           show captures at callout time
-             callout_data=<n>          set a value to pass via callouts
-             callout_fail=<n>[:<m>]    control callout failure
-             callout_none              do not supply a callout function
-             copy=<number or name>     copy captured substring
-             dfa                       use pcre2_dfa_match()
-             find_limits               find match and recursion limits
-             get=<number or name>      extract captured substring
-             getall                    extract all captured substrings
-         /g  global                    global matching
-             jitstack=<n>              set size of JIT stack
-             mark                      show mark values
-             match_limit=<n>           set a match limit
-             memory                    show memory usage
-             null_context              match with a NULL context
-             offset=<n>                set starting offset
-             offset_limit=<n>          set offset limit
-             ovector=<n>               set size of output vector
-             recursion_limit=<n>       set a recursion limit
-             replace=<string>          specify a replacement string
-             startchar                 show startchar when relevant
-             zero_terminate            pass the subject as zero-terminated
+             aftertext                  show text after match
+             allaftertext               show text after captures
+             allcaptures                show all captures
+             allusedtext                show all consulted text (non-JIT only)
+             altglobal                  alternative global matching
+             callout_capture            show captures at callout time
+             callout_data=<n>           set a value to pass via callouts
+             callout_fail=<n>[:<m>]     control callout failure
+             callout_none               do not supply a callout function
+             copy=<number or name>      copy captured substring
+             dfa                        use pcre2_dfa_match()
+             find_limits                find match and recursion limits
+             get=<number or name>       extract captured substring
+             getall                     extract all captured substrings
+         /g  global                     global matching
+             jitstack=<n>               set size of JIT stack
+             mark                       show mark values
+             match_limit=<n>            set a match limit
+             memory                     show memory usage
+             null_context               match with a NULL context
+             offset=<n>                 set starting offset
+             offset_limit=<n>           set offset limit
+             ovector=<n>                set size of output vector
+             recursion_limit=<n>        set a recursion limit
+             replace=<string>           specify a replacement string
+             startchar                  show startchar when relevant
+             startoffset=<n>            same as offset=<n>
+             substitute_extedded        use PCRE2_SUBSTITUTE_EXTENDED
+             substitute_overflow_length use PCRE2_SUBSTITUTE_OVERFLOW_LENGTH
+             substitute_unknown_unset   use PCRE2_SUBSTITUTE_UNKNOWN_UNSET
+             substitute_unset_empty     use PCRE2_SUBSTITUTE_UNSET_EMPTY
+             zero_terminate             pass the subject as zero-terminated


        The effects of these modifiers are described in the following sections.


@@ -1011,20 +1020,31 @@
    Testing the substitution function


        If  the  replace  modifier  is  set, the pcre2_substitute() function is
-       called instead  of  one  of  the  matching  functions.  Unlike  subject
-       strings,  pcre2test  does  not  process  replacement strings for escape
-       sequences. In UTF mode, a replacement string is checked to see if it is
-       a valid UTF-8 string.  If so, it is correctly converted to a UTF string
-       of the appropriate code unit width. If it is not a valid UTF-8  string,
-       the individual code units are copied directly. This provides a means of
-       passing an invalid UTF-8 string for testing purposes.
+       called instead of one of the matching functions. Note that  replacement
+       strings  cannot  contain commas, because a comma signifies the end of a
+       modifier. This is not thought to be an issue in a test program.


-       If the global modifier is set,  PCRE2_SUBSTITUTE_GLOBAL  is  passed  to
-       pcre2_substitute().  After  a  successful  substitution,  the  modified
-       string is output, preceded by the number of replacements. This  may  be
-       zero  if there were no matches. Here is a simple example of a substitu-
-       tion test:
+       Unlike subject strings, pcre2test does not process replacement  strings
+       for  escape  sequences. In UTF mode, a replacement string is checked to
+       see if it is a valid UTF-8 string. If so, it is correctly converted  to
+       a  UTF  string of the appropriate code unit width. If it is not a valid
+       UTF-8 string, the individual code units are copied directly. This  pro-
+       vides a means of passing an invalid UTF-8 string for testing purposes.


+       The  following modifiers set options (in additional to the normal match
+       options) for pcre2_substitute():
+
+         global                      PCRE2_SUBSTITUTE_GLOBAL
+         substitute_extended         PCRE2_SUBSTITUTE_EXTENDED
+         substitute_overflow_length  PCRE2_SUBSTITUTE_OVERFLOW_LENGTH
+         substitute_unknown_unset    PCRE2_SUBSTITUTE_UNKNOWN_UNSET
+         substitute_unset_empty      PCRE2_SUBSTITUTE_UNSET_EMPTY
+
+
+       After a successful substitution, the modified string  is  output,  pre-
+       ceded  by the number of replacements. This may be zero if there were no
+       matches. Here is a simple example of a substitution test:
+
          /abc/replace=xxx
              =abc=abc=
           1: =xxx=abc=
@@ -1031,12 +1051,13 @@
              =abc=abc=\=global
           2: =xxx=xxx=


-       Subject and replacement strings should be  kept  relatively  short  for
-       substitution  tests, as fixed-size buffers are used. To make it easy to
-       test for buffer overflow, if the replacement string starts with a  num-
-       ber  in square brackets, that number is passed to pcre2_substitute() as
-       the size of the output buffer, with the replacement string starting  at
-       the next character. Here is an example that tests the edge case:
+       Subject and replacement strings should be kept relatively short  (fewer
+       than  256 characters) for substitution tests, as fixed-size buffers are
+       used. To make it easy to test for buffer overflow, if  the  replacement
+       string  starts  with a number in square brackets, that number is passed
+       to pcre2_substitute() as the  size  of  the  output  buffer,  with  the
+       replacement  string  starting at the next character. Here is an example
+       that tests the edge case:


          /abc/
              123abc123\=replace=[10]XYZ
@@ -1044,6 +1065,19 @@
              123abc123\=replace=[9]XYZ
          Failed: error -47: no more memory


+       The   default   action   of    pcre2_substitute()    is    to    return
+       PCRE2_ERROR_NOMEMORY  when  the output buffer is too small. However, if
+       the PCRE2_SUBSTITUTE_OVERFLOW_LENGTH option is set (by using  the  sub-
+       stitute_overflow_length  modifier),  pcre2_substitute() continues to go
+       through the motions of matching and substituting, in order  to  compute
+       the size of buffer that is required. When this happens, pcre2test shows
+       the required buffer length (which includes space for the trailing zero)
+       as part of the error message. For example:
+
+         /abc/substitute_overflow_length
+             123abc123\=replace=[9]XYZ
+         Failed: error -47: no more memory: 10 code units are needed
+
        A replacement string is ignored with POSIX and DFA matching. Specifying
        partial matching provokes an error return  ("bad  option  value")  from
        pcre2_substitute().
@@ -1471,5 +1505,5 @@


REVISION

-       Last updated: 05 November 2015
+       Last updated: 12 December 2015
        Copyright (c) 1997-2015 University of Cambridge.


Modified: code/trunk/doc/pcre2unicode.3
===================================================================
--- code/trunk/doc/pcre2unicode.3    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/doc/pcre2unicode.3    2015-12-17 18:44:06 UTC (rev 471)
@@ -118,8 +118,8 @@
 as a byte-order mark (BOM). The PCRE2 functions do not handle this, expecting
 strings to be in host byte order.
 .P
-A UTF string is checked before any other processing takes place. In the case of 
-\fBpcre2_match()\fP and \fBpcre2_dfa_match()\fP calls with a non-zero starting 
+A UTF string is checked before any other processing takes place. In the case of
+\fBpcre2_match()\fP and \fBpcre2_dfa_match()\fP calls with a non-zero starting
 offset, the check is applied only to that part of the subject that could be
 inspected during matching, and there is a check that the starting offset points
 to the first code unit of a character or to the end of the subject. If there


Modified: code/trunk/perltest.sh
===================================================================
--- code/trunk/perltest.sh    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/perltest.sh    2015-12-17 18:44:06 UTC (rev 471)
@@ -211,7 +211,7 @@


     last if ($_ eq "");
     next if $_ =~ /^\\=(?:\s|$)/;   # Comment line
- 
+
     $x = eval "\"$_\"";   # To get escapes processed


     # Empty array for holding results, ensure $REGERROR and $REGMARK are


Modified: code/trunk/src/pcre2.h
===================================================================
--- code/trunk/src/pcre2.h    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2.h    2015-12-17 18:44:06 UTC (rev 471)
@@ -44,7 +44,7 @@
 #define PCRE2_MAJOR          10
 #define PCRE2_MINOR          21
 #define PCRE2_PRERELEASE     -RC1
-#define PCRE2_DATE           2015-07-06
+#define PCRE2_DATE           2015-12-15


/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE2, the appropriate

Modified: code/trunk/src/pcre2_dfa_match.c
===================================================================
--- code/trunk/src/pcre2_dfa_match.c    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2_dfa_match.c    2015-12-17 18:44:06 UTC (rev 471)
@@ -466,7 +466,7 @@
   /* In byte-mode we can do this quickly. */


     {
-    size_t current_offset = (size_t)(current_subject - start_subject); 
+    size_t current_offset = (size_t)(current_subject - start_subject);
     gone_back = (current_offset < max_back)? current_offset : max_back;
     current_subject -= gone_back;
     }


Modified: code/trunk/src/pcre2_error.c
===================================================================
--- code/trunk/src/pcre2_error.c    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2_error.c    2015-12-17 18:44:06 UTC (rev 471)
@@ -251,7 +251,7 @@
   "bad substitution in replacement string\0"
   /* 60 */
   "match with end before start is not supported\0"
-  "too many replacements (more than INT_MAX)\0" 
+  "too many replacements (more than INT_MAX)\0"
   ;




Modified: code/trunk/src/pcre2_intmodedep.h
===================================================================
--- code/trunk/src/pcre2_intmodedep.h    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2_intmodedep.h    2015-12-17 18:44:06 UTC (rev 471)
@@ -562,7 +562,7 @@
   int (*stack_guard)(uint32_t, void *);
   void *stack_guard_data;
   const uint8_t *tables;
-  PCRE2_SIZE max_pattern_length; 
+  PCRE2_SIZE max_pattern_length;
   uint16_t bsr_convention;
   uint16_t newline_convention;
   uint32_t parens_nest_limit;
@@ -581,7 +581,7 @@
 #endif
   int    (*callout)(pcre2_callout_block *, void *);
   void    *callout_data;
-  PCRE2_SIZE offset_limit; 
+  PCRE2_SIZE offset_limit;
   uint32_t match_limit;
   uint32_t recursion_limit;
 } pcre2_real_match_context;
@@ -592,7 +592,7 @@
 type. Use a macro rather than a typedef to avoid compiler warnings when this
 file is included multiple times by pcre2test. LOOKBEHIND_MAX specifies the
 largest lookbehind that is supported. (OP_REVERSE in a pattern has a 16-bit
-argument in 8-bit and 16-bit modes, so we need no more than a 16-bit field 
+argument in 8-bit and 16-bit modes, so we need no more than a 16-bit field
 here.) */


 #undef  CODE_BLOCKSIZE_TYPE
@@ -660,7 +660,7 @@
 typedef struct recurse_cache {
   PCRE2_SPTR group;
   int recno;
-} recurse_cache;    
+} recurse_cache;


 /* Structure for maintaining a chain of pointers to the currently incomplete
 branches, for testing for left recursion while compiling. */
@@ -693,7 +693,7 @@
   PCRE2_SPTR start_code;           /* The start of the compiled code */
   PCRE2_SPTR start_pattern;        /* The start of the pattern */
   PCRE2_SPTR end_pattern;          /* The end of the pattern */
-  PCRE2_SPTR nestptr[2];           /* Pointer(s) saved for string substitution */ 
+  PCRE2_SPTR nestptr[2];           /* Pointer(s) saved for string substitution */
   PCRE2_UCHAR *name_table;         /* The name/number table */
   size_t workspace_size;           /* Size of workspace */
   uint16_t names_found;            /* Number of entries so far */
@@ -717,7 +717,7 @@
   int  req_varyopt;                /* "After variable item" flag for reqbyte */
   BOOL had_accept;                 /* (*ACCEPT) encountered */
   BOOL had_pruneorskip;            /* (*PRUNE) or (*SKIP) encountered */
-  BOOL had_recurse;                /* Had a recursion or subroutine call */ 
+  BOOL had_recurse;                /* Had a recursion or subroutine call */
   BOOL check_lookbehind;           /* Lookbehinds need later checking */
   BOOL dupnames;                   /* Duplicate names exist */
   BOOL iscondassert;               /* Next assert is a condition */


Modified: code/trunk/src/pcre2_match.c
===================================================================
--- code/trunk/src/pcre2_match.c    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2_match.c    2015-12-17 18:44:06 UTC (rev 471)
@@ -2409,7 +2409,7 @@
     break;


     /* Match a single code unit, even in UTF-8 mode. This opcode really does
-    match any code unit, even newline. (It really should be called ANYCODEUNIT, 
+    match any code unit, even newline. (It really should be called ANYCODEUNIT,
     of course - the byte name is from pre-16 bit days.) */


     case OP_ANYBYTE:


Modified: code/trunk/src/pcre2_pattern_info.c
===================================================================
--- code/trunk/src/pcre2_pattern_info.c    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2_pattern_info.c    2015-12-17 18:44:06 UTC (rev 471)
@@ -77,7 +77,7 @@
     case PCRE2_INFO_CAPTURECOUNT:
     case PCRE2_INFO_FIRSTCODETYPE:
     case PCRE2_INFO_FIRSTCODEUNIT:
-    case PCRE2_INFO_HASBACKSLASHC: 
+    case PCRE2_INFO_HASBACKSLASHC:
     case PCRE2_INFO_HASCRORLF:
     case PCRE2_INFO_JCHANGED:
     case PCRE2_INFO_LASTCODETYPE:


Modified: code/trunk/src/pcre2_printint.c
===================================================================
--- code/trunk/src/pcre2_printint.c    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2_printint.c    2015-12-17 18:44:06 UTC (rev 471)
@@ -190,13 +190,13 @@
 *************************************************/


/* These take no account of UTF as they always print each individual code unit.
-The string is zero-terminated for print_custring(); the length is given for
+The string is zero-terminated for print_custring(); the length is given for
print_custring_bylen().

 Arguments:
   f          file to write to
   ptr        point to the string
-  len        length for print_custring_bylen() 
+  len        length for print_custring_bylen()


 Returns:     nothing
 */


Modified: code/trunk/src/pcre2_study.c
===================================================================
--- code/trunk/src/pcre2_study.c    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2_study.c    2015-12-17 18:44:06 UTC (rev 471)
@@ -1546,7 +1546,7 @@
   if (rc == SSB_DONE) re->flags |= PCRE2_FIRSTMAPSET;
   }


-/* Find the minimum length of subject string. If it can match an empty string,
+/* Find the minimum length of subject string. If it can match an empty string,
the minimum length is already known. */

 if ((re->flags & PCRE2_MATCH_EMPTY) == 0)
@@ -1555,19 +1555,19 @@
     {
     case -1:  /* \C in UTF mode or (*ACCEPT) or over-complex regex */
     break;    /* Leave minlength unchanged (will be zero) */
-  
+
     case -2:
     return 2; /* missing capturing bracket */
-  
+
     case -3:
     return 3; /* unrecognized opcode */
-  
+
     default:
     if (min > UINT16_MAX) min = UINT16_MAX;
     re->minlength = min;
     break;
     }
-  }   
+  }


return 0;
}

Modified: code/trunk/src/pcre2_valid_utf.c
===================================================================
--- code/trunk/src/pcre2_valid_utf.c    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2_valid_utf.c    2015-12-17 18:44:06 UTC (rev 471)
@@ -136,7 +136,7 @@
   register uint32_t ab, d;


c = *p;
- length--;
+ length--;

   if (c < 128) continue;                /* ASCII character */


@@ -329,7 +329,7 @@
for (p = string; length > 0; p++)
{
c = *p;
- length--;
+ length--;

   if ((c & 0xf800) != 0xd800)
     {


Modified: code/trunk/src/pcre2posix.c
===================================================================
--- code/trunk/src/pcre2posix.c    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2posix.c    2015-12-17 18:44:06 UTC (rev 471)
@@ -285,7 +285,7 @@


if ((eflags & REG_STARTEND) != 0)
{
- if (pmatch == NULL) return REG_INVARG;
+ if (pmatch == NULL) return REG_INVARG;
so = pmatch[0].rm_so;
eo = pmatch[0].rm_eo;
}

Modified: code/trunk/src/pcre2test.c
===================================================================
--- code/trunk/src/pcre2test.c    2015-12-17 17:15:19 UTC (rev 470)
+++ code/trunk/src/pcre2test.c    2015-12-17 18:44:06 UTC (rev 471)
@@ -6033,7 +6033,7 @@


   if (rc < 0)
     {
-    PCRE2_SIZE msize; 
+    PCRE2_SIZE msize;
     fprintf(outfile, "Failed: error %d", rc);
     if (rc != PCRE2_ERROR_NOMEMORY && nsize != PCRE2_UNSET)
       fprintf(outfile, " at offset %ld in replacement", (long int)nsize);
@@ -6040,7 +6040,7 @@
     fprintf(outfile, ": ");
     PCRE2_GET_ERROR_MESSAGE(msize, rc, pbuffer);
     PCHARSV(CASTVAR(void *, pbuffer), 0, msize, FALSE, outfile);
-    if (rc == PCRE2_ERROR_NOMEMORY && 
+    if (rc == PCRE2_ERROR_NOMEMORY &&
         (xoptions & PCRE2_SUBSTITUTE_OVERFLOW_LENGTH) != 0)
       fprintf(outfile, ": %ld code units are needed", (long int)nsize);
     }
@@ -6405,7 +6405,7 @@
          TESTFLD(match_data, mark, !=, NULL))
       {
       fprintf(outfile, ", mark=");
-      PCHARS(rubriclength, CASTFLD(void *, match_data, mark), 0, -1, utf, 
+      PCHARS(rubriclength, CASTFLD(void *, match_data, mark), 0, -1, utf,
         outfile);
       rubriclength += 7;
       }