summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornigel <nigel@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-02-24 21:40:03 +0000
committernigel <nigel@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-02-24 21:40:03 +0000
commitc8cb607ab7e12e185e86a8b23d413b7f9536f24c (patch)
treee1c3675d531d498d2a84490908e187a249456d2c
parente27c89c9227398c6feee3ca0748827fd064154cd (diff)
downloadpcre-c8cb607ab7e12e185e86a8b23d413b7f9536f24c.tar.gz
Load pcre-4.0 into code/trunk.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@63 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog429
-rw-r--r--LICENCE8
-rw-r--r--Makefile.in136
-rw-r--r--NEWS38
-rw-r--r--NON-UNIX-USE70
-rw-r--r--README146
-rwxr-xr-xRunTest.in54
-rwxr-xr-xconfig.guess603
-rw-r--r--config.in23
-rwxr-xr-xconfig.sub325
-rwxr-xr-xconfigure4863
-rw-r--r--configure.in69
-rw-r--r--dll.mk60
-rw-r--r--doc/Tech.Notes77
-rw-r--r--doc/html/.html0
-rw-r--r--doc/html/index.html102
-rw-r--r--doc/html/pcre.html183
-rw-r--r--doc/html/pcre_compile.html67
-rw-r--r--doc/html/pcre_config.html55
-rw-r--r--doc/html/pcre_copy_named_substring.html46
-rw-r--r--doc/html/pcre_copy_substring.html44
-rw-r--r--doc/html/pcre_exec.html55
-rw-r--r--doc/html/pcre_free_substring.html29
-rw-r--r--doc/html/pcre_free_substring_list.html29
-rw-r--r--doc/html/pcre_fullinfo.html68
-rw-r--r--doc/html/pcre_get_named_substring.html46
-rw-r--r--doc/html/pcre_get_stringnumber.html39
-rw-r--r--doc/html/pcre_get_substring.html44
-rw-r--r--doc/html/pcre_get_substring_list.html41
-rw-r--r--doc/html/pcre_info.html28
-rw-r--r--doc/html/pcre_maketables.html31
-rw-r--r--doc/html/pcre_study.html45
-rw-r--r--doc/html/pcre_version.html28
-rw-r--r--doc/html/pcreapi.html1260
-rw-r--r--doc/html/pcrebuild.html148
-rw-r--r--doc/html/pcrecallout.html116
-rw-r--r--doc/html/pcrecompat.html128
-rw-r--r--doc/html/pcregrep.html153
-rw-r--r--doc/html/pcrepattern.html1607
-rw-r--r--doc/html/pcreperform.html93
-rw-r--r--doc/html/pcreposix.html235
-rw-r--r--doc/html/pcresample.html79
-rw-r--r--doc/html/pcretest.html434
-rw-r--r--doc/pcre.32066
-rw-r--r--doc/pcre.html2669
-rw-r--r--doc/pcre.txt2498
-rw-r--r--doc/pcre_compile.355
-rw-r--r--doc/pcre_config.344
-rw-r--r--doc/pcre_copy_named_substring.340
-rw-r--r--doc/pcre_copy_substring.337
-rw-r--r--doc/pcre_exec.345
-rw-r--r--doc/pcre_free_substring.324
-rw-r--r--doc/pcre_free_substring_list.324
-rw-r--r--doc/pcre_fullinfo.353
-rw-r--r--doc/pcre_get_named_substring.340
-rw-r--r--doc/pcre_get_stringnumber.331
-rw-r--r--doc/pcre_get_substring.337
-rw-r--r--doc/pcre_get_substring_list.333
-rw-r--r--doc/pcre_info.323
-rw-r--r--doc/pcre_maketables.326
-rw-r--r--doc/pcre_study.336
-rw-r--r--doc/pcre_version.323
-rw-r--r--doc/pcreapi.31014
-rw-r--r--doc/pcrebuild.3112
-rw-r--r--doc/pcrecallout.391
-rw-r--r--doc/pcrecompat.395
-rw-r--r--doc/pcregrep.168
-rw-r--r--doc/pcregrep.html120
-rw-r--r--doc/pcregrep.txt65
-rw-r--r--doc/pcrepattern.31231
-rw-r--r--doc/pcreperform.366
-rw-r--r--doc/pcreposix.393
-rw-r--r--doc/pcreposix.html191
-rw-r--r--doc/pcreposix.txt159
-rw-r--r--doc/pcresample.352
-rw-r--r--doc/pcretest.1152
-rw-r--r--doc/pcretest.html369
-rw-r--r--doc/pcretest.txt159
-rw-r--r--doc/perltest.txt15
-rw-r--r--get.c124
-rw-r--r--internal.h497
-rw-r--r--ltmain.sh383
-rw-r--r--maketables.c12
-rw-r--r--makevp.bat25
-rw-r--r--pcre.c4854
-rw-r--r--pcre.def3
-rw-r--r--pcre.in175
-rw-r--r--pcredemo.c250
-rw-r--r--pcregrep.c124
-rw-r--r--pcreposix.c47
-rw-r--r--pcreposix.h2
-rw-r--r--pcretest.c653
-rwxr-xr-xperltest62
-rwxr-xr-xperltest8208
-rw-r--r--printint.c360
-rw-r--r--study.c87
-rw-r--r--testdata/testinput11877
-rw-r--r--testdata/testinput2509
-rw-r--r--testdata/testinput31735
-rw-r--r--testdata/testinput4496
-rw-r--r--testdata/testinput5261
-rw-r--r--testdata/testinput678
-rw-r--r--testdata/testoutput13235
-rw-r--r--testdata/testoutput22078
-rw-r--r--testdata/testoutput33037
-rw-r--r--testdata/testoutput4884
-rw-r--r--testdata/testoutput5962
-rw-r--r--testdata/testoutput6319
108 files changed, 30960 insertions, 16367 deletions
diff --git a/ChangeLog b/ChangeLog
index 6a71290..9c99cf3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,434 @@
ChangeLog for PCRE
------------------
-Version 3.0 02-Jan-02
+Version 4.00 17-Feb-03
+----------------------
+
+1. If a comment in an extended regex that started immediately after a meta-item
+extended to the end of string, PCRE compiled incorrect data. This could lead to
+all kinds of weird effects. Example: /#/ was bad; /()#/ was bad; /a#/ was not.
+
+2. Moved to autoconf 2.53 and libtool 1.4.2.
+
+3. Perl 5.8 no longer needs "use utf8" for doing UTF-8 things. Consequently,
+the special perltest8 script is no longer needed - all the tests can be run
+from a single perltest script.
+
+4. From 5.004, Perl has not included the VT character (0x0b) in the set defined
+by \s. It has now been removed in PCRE. This means it isn't recognized as
+whitespace in /x regexes too, which is the same as Perl. Note that the POSIX
+class [:space:] *does* include VT, thereby creating a mess.
+
+5. Added the class [:blank:] (a GNU extension from Perl 5.8) to match only
+space and tab.
+
+6. Perl 5.005 was a long time ago. It's time to amalgamate the tests that use
+its new features into the main test script, reducing the number of scripts.
+
+7. Perl 5.8 has changed the meaning of patterns like /a(?i)b/. Earlier versions
+were backward compatible, and made the (?i) apply to the whole pattern, as if
+/i were given. Now it behaves more logically, and applies the option setting
+only to what follows. PCRE has been changed to follow suit. However, if it
+finds options settings right at the start of the pattern, it extracts them into
+the global options, as before. Thus, they show up in the info data.
+
+8. Added support for the \Q...\E escape sequence. Characters in between are
+treated as literals. This is slightly different from Perl in that $ and @ are
+also handled as literals inside the quotes. In Perl, they will cause variable
+interpolation. Note the following examples:
+
+ Pattern PCRE matches Perl matches
+
+ \Qabc$xyz\E abc$xyz abc followed by the contents of $xyz
+ \Qabc\$xyz\E abc\$xyz abc\$xyz
+ \Qabc\E\$\Qxyz\E abc$xyz abc$xyz
+
+For compatibility with Perl, \Q...\E sequences are recognized inside character
+classes as well as outside them.
+
+9. Re-organized 3 code statements in pcretest to avoid "overflow in
+floating-point constant arithmetic" warnings from a Microsoft compiler. Added a
+(size_t) cast to one statement in pcretest and one in pcreposix to avoid
+signed/unsigned warnings.
+
+10. SunOS4 doesn't have strtoul(). This was used only for unpicking the -o
+option for pcretest, so I've replaced it by a simple function that does just
+that job.
+
+11. pcregrep was ending with code 0 instead of 2 for the commands "pcregrep" or
+"pcregrep -".
+
+12. Added "possessive quantifiers" ?+, *+, ++, and {,}+ which come from Sun's
+Java package. This provides some syntactic sugar for simple cases of what my
+documentation calls "once-only subpatterns". A pattern such as x*+ is the same
+as (?>x*). In other words, if what is inside (?>...) is just a single repeated
+item, you can use this simplified notation. Note that only makes sense with
+greedy quantifiers. Consequently, the use of the possessive quantifier forces
+greediness, whatever the setting of the PCRE_UNGREEDY option.
+
+13. A change of greediness default within a pattern was not taking effect at
+the current level for patterns like /(b+(?U)a+)/. It did apply to parenthesized
+subpatterns that followed. Patterns like /b+(?U)a+/ worked because the option
+was abstracted outside.
+
+14. PCRE now supports the \G assertion. It is true when the current matching
+position is at the start point of the match. This differs from \A when the
+starting offset is non-zero. Used with the /g option of pcretest (or similar
+code), it works in the same way as it does for Perl's /g option. If all
+alternatives of a regex begin with \G, the expression is anchored to the start
+match position, and the "anchored" flag is set in the compiled expression.
+
+15. Some bugs concerning the handling of certain option changes within patterns
+have been fixed. These applied to options other than (?ims). For example,
+"a(?x: b c )d" did not match "XabcdY" but did match "Xa b c dY". It should have
+been the other way round. Some of this was related to change 7 above.
+
+16. PCRE now gives errors for /[.x.]/ and /[=x=]/ as unsupported POSIX
+features, as Perl does. Previously, PCRE gave the warnings only for /[[.x.]]/
+and /[[=x=]]/. PCRE now also gives an error for /[:name:]/ because it supports
+POSIX classes only within a class (e.g. /[[:alpha:]]/).
+
+17. Added support for Perl's \C escape. This matches one byte, even in UTF8
+mode. Unlike ".", it always matches newline, whatever the setting of
+PCRE_DOTALL. However, PCRE does not permit \C to appear in lookbehind
+assertions. Perl allows it, but it doesn't (in general) work because it can't
+calculate the length of the lookbehind. At least, that's the case for Perl
+5.8.0 - I've been told they are going to document that it doesn't work in
+future.
+
+18. Added an error diagnosis for escapes that PCRE does not support: these are
+\L, \l, \N, \P, \p, \U, \u, and \X.
+
+19. Although correctly diagnosing a missing ']' in a character class, PCRE was
+reading past the end of the pattern in cases such as /[abcd/.
+
+20. PCRE was getting more memory than necessary for patterns with classes that
+contained both POSIX named classes and other characters, e.g. /[[:space:]abc/.
+
+21. Added some code, conditional on #ifdef VPCOMPAT, to make life easier for
+compiling PCRE for use with Virtual Pascal.
+
+22. Small fix to the Makefile to make it work properly if the build is done
+outside the source tree.
+
+23. Added a new extension: a condition to go with recursion. If a conditional
+subpattern starts with (?(R) the "true" branch is used if recursion has
+happened, whereas the "false" branch is used only at the top level.
+
+24. When there was a very long string of literal characters (over 255 bytes
+without UTF support, over 250 bytes with UTF support), the computation of how
+much memory was required could be incorrect, leading to segfaults or other
+strange effects.
+
+25. PCRE was incorrectly assuming anchoring (either to start of subject or to
+start of line for a non-DOTALL pattern) when a pattern started with (.*) and
+there was a subsequent back reference to those brackets. This meant that, for
+example, /(.*)\d+\1/ failed to match "abc123bc". Unfortunately, it isn't
+possible to check for precisely this case. All we can do is abandon the
+optimization if .* occurs inside capturing brackets when there are any back
+references whatsoever. (See below for a better fix that came later.)
+
+26. The handling of the optimization for finding the first character of a
+non-anchored pattern, and for finding a character that is required later in the
+match were failing in some cases. This didn't break the matching; it just
+failed to optimize when it could. The way this is done has been re-implemented.
+
+27. Fixed typo in error message for invalid (?R item (it said "(?p").
+
+28. Added a new feature that provides some of the functionality that Perl
+provides with (?{...}). The facility is termed a "callout". The way it is done
+in PCRE is for the caller to provide an optional function, by setting
+pcre_callout to its entry point. Like pcre_malloc and pcre_free, this is a
+global variable. By default it is unset, which disables all calling out. To get
+the function called, the regex must include (?C) at appropriate points. This
+is, in fact, equivalent to (?C0), and any number <= 255 may be given with (?C).
+This provides a means of identifying different callout points. When PCRE
+reaches such a point in the regex, if pcre_callout has been set, the external
+function is called. It is provided with data in a structure called
+pcre_callout_block, which is defined in pcre.h. If the function returns 0,
+matching continues; if it returns a non-zero value, the match at the current
+point fails. However, backtracking will occur if possible. [This was changed
+later and other features added - see item 49 below.]
+
+29. pcretest is upgraded to test the callout functionality. It provides a
+callout function that displays information. By default, it shows the start of
+the match and the current position in the text. There are some new data escapes
+to vary what happens:
+
+ \C+ in addition, show current contents of captured substrings
+ \C- do not supply a callout function
+ \C!n return 1 when callout number n is reached
+ \C!n!m return 1 when callout number n is reached for the mth time
+
+30. If pcregrep was called with the -l option and just a single file name, it
+output "<stdin>" if a match was found, instead of the file name.
+
+31. Improve the efficiency of the POSIX API to PCRE. If the number of capturing
+slots is less than POSIX_MALLOC_THRESHOLD, use a block on the stack to pass to
+pcre_exec(). This saves a malloc/free per call. The default value of
+POSIX_MALLOC_THRESHOLD is 10; it can be changed by --with-posix-malloc-threshold
+when configuring.
+
+32. The default maximum size of a compiled pattern is 64K. There have been a
+few cases of people hitting this limit. The code now uses macros to handle the
+storing of links as offsets within the compiled pattern. It defaults to 2-byte
+links, but this can be changed to 3 or 4 bytes by --with-link-size when
+configuring. Tests 2 and 5 work only with 2-byte links because they output
+debugging information about compiled patterns.
+
+33. Internal code re-arrangements:
+
+(a) Moved the debugging function for printing out a compiled regex into
+ its own source file (printint.c) and used #include to pull it into
+ pcretest.c and, when DEBUG is defined, into pcre.c, instead of having two
+ separate copies.
+
+(b) Defined the list of op-code names for debugging as a macro in
+ internal.h so that it is next to the definition of the opcodes.
+
+(c) Defined a table of op-code lengths for simpler skipping along compiled
+ code. This is again a macro in internal.h so that it is next to the
+ definition of the opcodes.
+
+34. Added support for recursive calls to individual subpatterns, along the
+lines of Robin Houston's patch (but implemented somewhat differently).
+
+35. Further mods to the Makefile to help Win32. Also, added code to pcregrep to
+allow it to read and process whole directories in Win32. This code was
+contributed by Lionel Fourquaux; it has not been tested by me.
+
+36. Added support for named subpatterns. The Python syntax (?P<name>...) is
+used to name a group. Names consist of alphanumerics and underscores, and must
+be unique. Back references use the syntax (?P=name) and recursive calls use
+(?P>name) which is a PCRE extension to the Python extension. Groups still have
+numbers. The function pcre_fullinfo() can be used after compilation to extract
+a name/number map. There are three relevant calls:
+
+ PCRE_INFO_NAMEENTRYSIZE yields the size of each entry in the map
+ PCRE_INFO_NAMECOUNT yields the number of entries
+ PCRE_INFO_NAMETABLE yields a pointer to the map.
+
+The map is a vector of fixed-size entries. The size of each entry depends on
+the length of the longest name used. The first two bytes of each entry are the
+group number, most significant byte first. There follows the corresponding
+name, zero terminated. The names are in alphabetical order.
+
+37. Make the maximum literal string in the compiled code 250 for the non-UTF-8
+case instead of 255. Making it the same both with and without UTF-8 support
+means that the same test output works with both.
+
+38. There was a case of malloc(0) in the POSIX testing code in pcretest. Avoid
+calling malloc() with a zero argument.
+
+39. Change 25 above had to resort to a heavy-handed test for the .* anchoring
+optimization. I've improved things by keeping a bitmap of backreferences with
+numbers 1-31 so that if .* occurs inside capturing brackets that are not in
+fact referenced, the optimization can be applied. It is unlikely that a
+relevant occurrence of .* (i.e. one which might indicate anchoring or forcing
+the match to follow \n) will appear inside brackets with a number greater than
+31, but if it does, any back reference > 31 suppresses the optimization.
+
+40. Added a new compile-time option PCRE_NO_AUTO_CAPTURE. This has the effect
+of disabling numbered capturing parentheses. Any opening parenthesis that is
+not followed by ? behaves as if it were followed by ?: but named parentheses
+can still be used for capturing (and they will acquire numbers in the usual
+way).
+
+41. Redesigned the return codes from the match() function into yes/no/error so
+that errors can be passed back from deep inside the nested calls. A malloc
+failure while inside a recursive subpattern call now causes the
+PCRE_ERROR_NOMEMORY return instead of quietly going wrong.
+
+42. It is now possible to set a limit on the number of times the match()
+function is called in a call to pcre_exec(). This facility makes it possible to
+limit the amount of recursion and backtracking, though not in a directly
+obvious way, because the match() function is used in a number of different
+circumstances. The count starts from zero for each position in the subject
+string (for non-anchored patterns). The default limit is, for compatibility, a
+large number, namely 10 000 000. You can change this in two ways:
+
+(a) When configuring PCRE before making, you can use --with-match-limit=n
+ to set a default value for the compiled library.
+
+(b) For each call to pcre_exec(), you can pass a pcre_extra block in which
+ a different value is set. See 45 below.
+
+If the limit is exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.
+
+43. Added a new function pcre_config(int, void *) to enable run-time extraction
+of things that can be changed at compile time. The first argument specifies
+what is wanted and the second points to where the information is to be placed.
+The current list of available information is:
+
+ PCRE_CONFIG_UTF8
+
+The output is an integer that is set to one if UTF-8 support is available;
+otherwise it is set to zero.
+
+ PCRE_CONFIG_NEWLINE
+
+The output is an integer that it set to the value of the code that is used for
+newline. It is either LF (10) or CR (13).
+
+ PCRE_CONFIG_LINK_SIZE
+
+The output is an integer that contains the number of bytes used for internal
+linkage in compiled expressions. The value is 2, 3, or 4. See item 32 above.
+
+ PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+
+The output is an integer that contains the threshold above which the POSIX
+interface uses malloc() for output vectors. See item 31 above.
+
+ PCRE_CONFIG_MATCH_LIMIT
+
+The output is an unsigned integer that contains the default limit of the number
+of match() calls in a pcre_exec() execution. See 42 above.
+
+44. pcretest has been upgraded by the addition of the -C option. This causes it
+to extract all the available output from the new pcre_config() function, and to
+output it. The program then exits immediately.
+
+45. A need has arisen to pass over additional data with calls to pcre_exec() in
+order to support additional features. One way would have been to define
+pcre_exec2() (for example) with extra arguments, but this would not have been
+extensible, and would also have required all calls to the original function to
+be mapped to the new one. Instead, I have chosen to extend the mechanism that
+is used for passing in "extra" data from pcre_study().
+
+The pcre_extra structure is now exposed and defined in pcre.h. It currently
+contains the following fields:
+
+ flags a bitmap indicating which of the following fields are set
+ study_data opaque data from pcre_study()
+ match_limit a way of specifying a limit on match() calls for a specific
+ call to pcre_exec()
+ callout_data data for callouts (see 49 below)
+
+The flag bits are also defined in pcre.h, and are
+
+ PCRE_EXTRA_STUDY_DATA
+ PCRE_EXTRA_MATCH_LIMIT
+ PCRE_EXTRA_CALLOUT_DATA
+
+The pcre_study() function now returns one of these new pcre_extra blocks, with
+the actual study data pointed to by the study_data field, and the
+PCRE_EXTRA_STUDY_DATA flag set. This can be passed directly to pcre_exec() as
+before. That is, this change is entirely upwards-compatible and requires no
+change to existing code.
+
+If you want to pass in additional data to pcre_exec(), you can either place it
+in a pcre_extra block provided by pcre_study(), or create your own pcre_extra
+block.
+
+46. pcretest has been extended to test the PCRE_EXTRA_MATCH_LIMIT feature. If a
+data string contains the escape sequence \M, pcretest calls pcre_exec() several
+times with different match limits, until it finds the minimum value needed for
+pcre_exec() to complete. The value is then output. This can be instructive; for
+most simple matches the number is quite small, but for pathological cases it
+gets very large very quickly.
+
+47. There's a new option for pcre_fullinfo() called PCRE_INFO_STUDYSIZE. It
+returns the size of the data block pointed to by the study_data field in a
+pcre_extra block, that is, the value that was passed as the argument to
+pcre_malloc() when PCRE was getting memory in which to place the information
+created by pcre_study(). The fourth argument should point to a size_t variable.
+pcretest has been extended so that this information is shown after a successful
+pcre_study() call when information about the compiled regex is being displayed.
+
+48. Cosmetic change to Makefile: there's no need to have / after $(DESTDIR)
+because what follows is always an absolute path. (Later: it turns out that this
+is more than cosmetic for MinGW, because it doesn't like empty path
+components.)
+
+49. Some changes have been made to the callout feature (see 28 above):
+
+(i) A callout function now has three choices for what it returns:
+
+ 0 => success, carry on matching
+ > 0 => failure at this point, but backtrack if possible
+ < 0 => serious error, return this value from pcre_exec()
+
+ Negative values should normally be chosen from the set of PCRE_ERROR_xxx
+ values. In particular, returning PCRE_ERROR_NOMATCH forces a standard
+ "match failed" error. The error number PCRE_ERROR_CALLOUT is reserved for
+ use by callout functions. It will never be used by PCRE itself.
+
+(ii) The pcre_extra structure (see 45 above) has a void * field called
+ callout_data, with corresponding flag bit PCRE_EXTRA_CALLOUT_DATA. The
+ pcre_callout_block structure has a field of the same name. The contents of
+ the field passed in the pcre_extra structure are passed to the callout
+ function in the corresponding field in the callout block. This makes it
+ easier to use the same callout-containing regex from multiple threads. For
+ testing, the pcretest program has a new data escape
+
+ \C*n pass the number n (may be negative) as callout_data
+
+ If the callout function in pcretest receives a non-zero value as
+ callout_data, it returns that value.
+
+50. Makefile wasn't handling CFLAGS properly when compiling dftables. Also,
+there were some redundant $(CFLAGS) in commands that are now specified as
+$(LINK), which already includes $(CFLAGS).
+
+51. Extensions to UTF-8 support are listed below. These all apply when (a) PCRE
+has been compiled with UTF-8 support *and* pcre_compile() has been compiled
+with the PCRE_UTF8 flag. Patterns that are compiled without that flag assume
+one-byte characters throughout. Note that case-insensitive matching applies
+only to characters whose values are less than 256. PCRE doesn't support the
+notion of cases for higher-valued characters.
+
+(i) A character class whose characters are all within 0-255 is handled as
+ a bit map, and the map is inverted for negative classes. Previously, a
+ character > 255 always failed to match such a class; however it should
+ match if the class was a negative one (e.g. [^ab]). This has been fixed.
+
+(ii) A negated character class with a single character < 255 is coded as
+ "not this character" (OP_NOT). This wasn't working properly when the test
+ character was multibyte, either singly or repeated.
+
+(iii) Repeats of multibyte characters are now handled correctly in UTF-8
+ mode, for example: \x{100}{2,3}.
+
+(iv) The character escapes \b, \B, \d, \D, \s, \S, \w, and \W (either
+ singly or repeated) now correctly test multibyte characters. However,
+ PCRE doesn't recognize any characters with values greater than 255 as
+ digits, spaces, or word characters. Such characters always match \D, \S,
+ and \W, and never match \d, \s, or \w.
+
+(v) Classes may now contain characters and character ranges with values
+ greater than 255. For example: [ab\x{100}-\x{400}].
+
+(vi) pcregrep now has a --utf-8 option (synonym -u) which makes it call
+ PCRE in UTF-8 mode.
+
+52. The info request value PCRE_INFO_FIRSTCHAR has been renamed
+PCRE_INFO_FIRSTBYTE because it is a byte value. However, the old name is
+retained for backwards compatibility. (Note that LASTLITERAL is also a byte
+value.)
+
+53. The single man page has become too large. I have therefore split it up into
+a number of separate man pages. These also give rise to individual HTML pages;
+these are now put in a separate directory, and there is an index.html page that
+lists them all. Some hyperlinking between the pages has been installed.
+
+54. Added convenience functions for handling named capturing parentheses.
+
+55. Unknown escapes inside character classes (e.g. [\M]) and escapes that
+aren't interpreted therein (e.g. [\C]) are literals in Perl. This is now also
+true in PCRE, except when the PCRE_EXTENDED option is set, in which case they
+are faulted.
+
+56. Introduced HOST_CC and HOST_CFLAGS which can be set in the environment when
+calling configure. These values are used when compiling the dftables.c program
+which is run to generate the source of the default character tables. They
+default to the values of CC and CFLAGS. If you are cross-compiling PCRE,
+you will need to set these values.
+
+57. Updated the building process for Windows DLL, as provided by Fred Cox.
+
+
+Version 3.9 02-Jan-02
---------------------
1. A bit of extraneous text had somehow crept into the pcregrep documentation.
diff --git a/LICENCE b/LICENCE
index 8effa66..8d68061 100644
--- a/LICENCE
+++ b/LICENCE
@@ -21,7 +21,7 @@ restrictions:
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission. In practice, this means that if you use
- PCRE in software which you distribute to others, commercially or
+ PCRE in software that you distribute to others, commercially or
otherwise, you must put a sentence like this
Regular expression support is provided by the PCRE library package,
@@ -34,7 +34,11 @@ restrictions:
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
- should also be given in the documentation.
+ should also be given in the documentation. However, this condition is not
+ intended to apply to whole chains of software. If package A includes PCRE,
+ it must acknowledge it, but if package B is software that includes package
+ A, the condition is not imposed on package B (unless it uses PCRE
+ independently).
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.
diff --git a/Makefile.in b/Makefile.in
index b7e862b..5d621b8 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2,14 +2,12 @@
# Makefile.in for PCRE (Perl-Compatible Regular Expression) library.
#---------------------------------------------------------------------------#
-# To build mingw32 DLL uncomment the next two lines. This addition for #
-# mingw32 was contributed by <Paul.Sokolovsky@technologist.com>. I (Philip #
-# Hazel) don't know anything about it! There are some additional targets at #
-# the bottom of this Makefile. #
+# MinGW DLLs are built automatically with this configure.in and Makefile.in #
+# as long you are using autoconf 2.50 or higher. The Win32 static libraries #
+# have not been tested, but appear to be generated. This functionality is #
+# by courtesy of Fred Cox. I (Philip Hazel) don't know anything about it, #
+# as I live entirely in a non-Windows world. #
#---------------------------------------------------------------------------#
-#
-# include dll.mk
-# DLL_LDFLAGS=-s
#############################################################################
@@ -58,9 +56,13 @@ MANDIR = @mandir@
CC = @CC@
CFLAGS = @CFLAGS@
-RANLIB = @RANLIB@
+HOST_CC = @HOST_CC@
+HOST_CFLAGS = @HOST_CFLAGS@
UTF8 = @UTF8@
NEWLINE = @NEWLINE@
+POSIX_MALLOC_THRESHOLD = @POSIX_MALLOC_THRESHOLD@
+LINK_SIZE = @LINK_SIZE@
+MATCH_LIMIT= @MATCH_LIMIT@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
@@ -69,8 +71,8 @@ INSTALL_DATA = @INSTALL_DATA@
# to do one or the other or both by ./configure.
LIBTOOL = @LIBTOOL@
-LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) -c $(CFLAGS) -I. $(NEWLINE)
-LINK = $(LIBTOOL) --mode=link $(CC)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) -c $(CFLAGS) -I. -I$(top_srcdir) $(NEWLINE) $(LINK_SIZE) $(MATCH_LIMIT)
+LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) -I. -I$(top_srcdir)
# These are the version numbers for the shared libraries
@@ -80,17 +82,17 @@ PCREPOSIXLIBVERSION = @PCRE_POSIXLIB_VERSION@
##############################################################################
-OBJ = maketables.o get.o study.o pcre.o
-LOBJ = maketables.lo get.lo study.lo pcre.lo
+OBJ = maketables.o get.o study.o pcre.o @POSIX_OBJ@
+LOBJ = maketables.lo get.lo study.lo pcre.lo @POSIX_LOBJ@
-all: libpcre.la libpcreposix.la pcretest pcregrep
+all: libpcre.la @POSIX_LIB@ pcretest pcregrep
pcregrep: libpcre.la pcregrep.o
- $(LINK) $(CFLAGS) -o pcregrep pcregrep.o libpcre.la
+ $(LINK) -o pcregrep pcregrep.o libpcre.la
-pcretest: libpcre.la libpcreposix.la pcretest.o
- $(LINK) $(PURIFY) $(CFLAGS) -o pcretest pcretest.o \
- libpcre.la libpcreposix.la
+pcretest: libpcre.la @POSIX_LIB@ pcretest.o
+ $(LINK) $(PURIFY) $(EFENCE) -o pcretest pcretest.o \
+ libpcre.la @POSIX_LIB@
libpcre.la: $(OBJ)
-rm -f libpcre.la
@@ -103,12 +105,13 @@ libpcreposix.la: pcreposix.o
'$(PCREPOSIXLIBVERSION)' -o libpcreposix.la pcreposix.lo
pcre.o: $(top_srcdir)/chartables.c $(top_srcdir)/pcre.c \
- $(top_srcdir)/internal.h pcre.h config.h Makefile
- $(LTCOMPILE) $(UTF8) $(top_srcdir)/pcre.c
+ $(top_srcdir)/internal.h $(top_srcdir)/printint.c \
+ pcre.h config.h Makefile
+ $(LTCOMPILE) $(UTF8) $(POSIX_MALLOC_THRESHOLD) $(top_srcdir)/pcre.c
pcreposix.o: $(top_srcdir)/pcreposix.c $(top_srcdir)/pcreposix.h \
$(top_srcdir)/internal.h pcre.h config.h Makefile
- $(LTCOMPILE) $(top_srcdir)/pcreposix.c
+ $(LTCOMPILE) $(POSIX_MALLOC_THRESHOLD) $(top_srcdir)/pcreposix.c
maketables.o: $(top_srcdir)/maketables.c $(top_srcdir)/internal.h \
pcre.h config.h Makefile
@@ -122,8 +125,10 @@ study.o: $(top_srcdir)/study.c $(top_srcdir)/internal.h \
pcre.h config.h Makefile
$(LTCOMPILE) $(UTF8) $(top_srcdir)/study.c
-pcretest.o: $(top_srcdir)/pcretest.c $(top_srcdir)/internal.h pcre.h config.h Makefile
- $(CC) -c $(CFLAGS) -I. $(UTF8) $(top_srcdir)/pcretest.c
+pcretest.o: $(top_srcdir)/pcretest.c $(top_srcdir)/internal.h \
+ $(top_srcdir)/printint.c \
+ pcre.h config.h Makefile
+ $(CC) -c $(CFLAGS) -I. $(UTF8) $(LINK_SIZE) $(top_srcdir)/pcretest.c
pcregrep.o: $(top_srcdir)/pcregrep.c pcre.h Makefile config.h
$(CC) -c $(CFLAGS) -I. $(UTF8) $(PCREGREP_OSTYPE) $(top_srcdir)/pcregrep.c
@@ -133,30 +138,56 @@ pcregrep.o: $(top_srcdir)/pcregrep.c pcre.h Makefile config.h
$(top_srcdir)/chartables.c: dftables
./dftables >$(top_srcdir)/chartables.c
-dftables: $(top_srcdir)/dftables.c $(top_srcdir)/maketables.c \
+dftables.o: $(top_srcdir)/dftables.c $(top_srcdir)/maketables.c \
$(top_srcdir)/internal.h pcre.h config.h Makefile
- $(LINK) -o dftables $(CFLAGS) $(top_srcdir)/dftables.c
+ $(HOST_CC) -c $(HOST_CFLAGS) -I. $(top_srcdir)/dftables.c
+
+dftables: dftables.o
+ $(LINK) -o dftables dftables.o
install: all
- $(mkinstalldirs) $(DESTDIR)/$(LIBDIR)
- echo "$(LIBTOOL) --mode=install $(INSTALL) libpcre.la $(DESTDIR)/$(LIBDIR)/libpcre.la"
- $(LIBTOOL) --mode=install $(INSTALL) libpcre.la $(DESTDIR)/$(LIBDIR)/libpcre.la
- echo "$(LIBTOOL) --mode=install $(INSTALL) libpcreposix.la $(DESTDIR)/$(LIBDIR)/libpcreposix.la"
- $(LIBTOOL) --mode=install $(INSTALL) libpcreposix.la $(DESTDIR)/$(LIBDIR)/libpcreposix.la
- $(LIBTOOL) --finish $(DESTDIR)/$(LIBDIR)
- $(mkinstalldirs) $(DESTDIR)/$(INCDIR)
- $(INSTALL_DATA) pcre.h $(DESTDIR)/$(INCDIR)/pcre.h
- $(INSTALL_DATA) $(top_srcdir)/pcreposix.h $(DESTDIR)/$(INCDIR)/pcreposix.h
- $(mkinstalldirs) $(DESTDIR)/$(MANDIR)/man3
- $(INSTALL_DATA) $(top_srcdir)/doc/pcre.3 $(DESTDIR)/$(MANDIR)/man3/pcre.3
- $(INSTALL_DATA) $(top_srcdir)/doc/pcreposix.3 $(DESTDIR)/$(MANDIR)/man3/pcreposix.3
- $(mkinstalldirs) $(DESTDIR)/$(MANDIR)/man1
- $(INSTALL_DATA) $(top_srcdir)/doc/pcregrep.1 $(DESTDIR)/$(MANDIR)/man1/pcregrep.1
- $(INSTALL_DATA) $(top_srcdir)/doc/pcretest.1 $(DESTDIR)/$(MANDIR)/man1/pcretest.1
- $(mkinstalldirs) $(DESTDIR)/$(BINDIR)
- $(LIBTOOL) --mode=install $(INSTALL) pcregrep $(DESTDIR)/$(BINDIR)/pcregrep
- $(LIBTOOL) --mode=install $(INSTALL) pcretest $(DESTDIR)/$(BINDIR)/pcretest
- $(INSTALL) pcre-config $(DESTDIR)/$(BINDIR)/pcre-config
+ $(mkinstalldirs) $(DESTDIR)$(LIBDIR)
+ echo "$(LIBTOOL) --mode=install $(INSTALL) libpcre.la $(DESTDIR)$(LIBDIR)/libpcre.la"
+ $(LIBTOOL) --mode=install $(INSTALL) libpcre.la $(DESTDIR)$(LIBDIR)/libpcre.la
+ echo "$(LIBTOOL) --mode=install $(INSTALL) libpcreposix.la $(DESTDIR)$(LIBDIR)/libpcreposix.la"
+ $(LIBTOOL) --mode=install $(INSTALL) libpcreposix.la $(DESTDIR)$(LIBDIR)/libpcreposix.la
+ $(LIBTOOL) --finish $(DESTDIR)$(LIBDIR)
+ $(mkinstalldirs) $(DESTDIR)$(INCDIR)
+ $(INSTALL_DATA) pcre.h $(DESTDIR)$(INCDIR)/pcre.h
+ $(INSTALL_DATA) $(top_srcdir)/pcreposix.h $(DESTDIR)$(INCDIR)/pcreposix.h
+ $(mkinstalldirs) $(DESTDIR)$(MANDIR)/man3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre.3 $(DESTDIR)$(MANDIR)/man3/pcre.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcreapi.3 $(DESTDIR)$(MANDIR)/man3/pcreapi.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcrebuild.3 $(DESTDIR)$(MANDIR)/man3/pcrebuild.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcrecallout.3 $(DESTDIR)$(MANDIR)/man3/pcrecallout.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcrecompat.3 $(DESTDIR)$(MANDIR)/man3/pcrecompat.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcrepattern.3 $(DESTDIR)$(MANDIR)/man3/pcrepattern.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcreperform.3 $(DESTDIR)$(MANDIR)/man3/pcreperform.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcreposix.3 $(DESTDIR)$(MANDIR)/man3/pcreposix.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcresample.3 $(DESTDIR)$(MANDIR)/man3/pcresample.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_compile.3 $(DESTDIR)$(MANDIR)/man3/pcre_compile.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_config.3 $(DESTDIR)$(MANDIR)/man3/pcre_config.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_copy_named_substring.3 $(DESTDIR)$(MANDIR)/man3/pcre_copy_named_substring.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_copy_substring.3 $(DESTDIR)$(MANDIR)/man3/pcre_copy_substring.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_exec.3 $(DESTDIR)$(MANDIR)/man3/pcre_exec.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_free_substring.3 $(DESTDIR)$(MANDIR)/man3/pcre_free_substring.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_free_substring_list.3 $(DESTDIR)$(MANDIR)/man3/pcre_free_substring_list.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_fullinfo.3 $(DESTDIR)$(MANDIR)/man3/pcre_fullinfo.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_get_named_substring.3 $(DESTDIR)$(MANDIR)/man3/pcre_get_named_substring.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_get_stringnumber.3 $(DESTDIR)$(MANDIR)/man3/pcre_get_stringnumber.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_get_substring.3 $(DESTDIR)$(MANDIR)/man3/pcre_get_substring.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_get_substring_list.3 $(DESTDIR)$(MANDIR)/man3/pcre_get_substring_list.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_info.3 $(DESTDIR)$(MANDIR)/man3/pcre_info.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_maketables.3 $(DESTDIR)$(MANDIR)/man3/pcre_maketables.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_study.3 $(DESTDIR)$(MANDIR)/man3/pcre_study.3
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcre_version.3 $(DESTDIR)$(MANDIR)/man3/pcre_version.3
+ $(mkinstalldirs) $(DESTDIR)$(MANDIR)/man1
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcregrep.1 $(DESTDIR)$(MANDIR)/man1/pcregrep.1
+ $(INSTALL_DATA) $(top_srcdir)/doc/pcretest.1 $(DESTDIR)$(MANDIR)/man1/pcretest.1
+ $(mkinstalldirs) $(DESTDIR)$(BINDIR)
+ $(LIBTOOL) --mode=install $(INSTALL) pcregrep $(DESTDIR)$(BINDIR)/pcregrep
+ $(LIBTOOL) --mode=install $(INSTALL) pcretest $(DESTDIR)$(BINDIR)/pcretest
+ $(INSTALL) pcre-config $(DESTDIR)$(BINDIR)/pcre-config
# We deliberately omit dftables and chartables.c from 'make clean'; once made
# chartables.c shouldn't change, and if people have edited the tables by hand,
@@ -177,23 +208,4 @@ test: runtest
runtest: all
./RunTest
-######## MINGW32 ############### MINGW32 ############### MINGW32 #############
-
-# This addition for mingw32 was contributed by Paul Sokolovsky
-# <Paul.Sokolovsky@technologist.com>. I (PH) don't know anything about it!
-
-dll: _dll libpcre.dll.a pcregrep_d pcretest_d
-
-_dll:
- $(MAKE) CFLAGS=-DSTATIC pcre.dll
-
-pcre.dll: $(OBJ) pcreposix.o pcre.def
-libpcre.dll.a: pcre.def
-
-pcregrep_d: libpcre.dll.a pcregrep.o
- $(CC) $(CFLAGS) -L. -o pcregrep pcregrep.o -lpcre.dll
-
-pcretest_d: libpcre.dll.a pcretest.o
- $(PURIFY) $(CC) $(CFLAGS) -L. -o pcretest pcretest.o -lpcre.dll
-
# End
diff --git a/NEWS b/NEWS
index 27866b6..e620b2d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,44 @@
News about PCRE releases
------------------------
+Release 4.0 17-Feb-03
+---------------------
+
+There have been a lot of changes for the 4.0 release, adding additional
+functionality and mending bugs. Below is a list of the highlights of the new
+functionality. For full details of these features, please consult the
+documentation. For a complete list of changes, see the ChangeLog file.
+
+1. Support for Perl's \Q...\E escapes.
+
+2. "Possessive quantifiers" ?+, *+, ++, and {,}+ which come from Sun's Java
+package. They provide some syntactic sugar for simple cases of "atomic
+grouping".
+
+3. Support for the \G assertion. It is true when the current matching position
+is at the start point of the match.
+
+4. A new feature that provides some of the functionality that Perl provides
+with (?{...}). The facility is termed a "callout". The way it is done in PCRE
+is for the caller to provide an optional function, by setting pcre_callout to
+its entry point. To get the function called, the regex must include (?C) at
+appropriate points.
+
+5. Support for recursive calls to individual subpatterns. This makes it really
+easy to get totally confused.
+
+6. Support for named subpatterns. The Python syntax (?P<name>...) is used to
+name a group.
+
+7. Several extensions to UTF-8 support; it is now fairly complete. There is an
+option for pcregrep to make it operate in UTF-8 mode.
+
+8. The single man page has been split into a number of separate man pages.
+These also give rise to individual HTML pages which are put in a separate
+directory. There is an index.html page that lists them all. Some hyperlinking
+between the pages has been installed.
+
+
Release 3.5 15-Aug-01
---------------------
diff --git a/NON-UNIX-USE b/NON-UNIX-USE
index 14b1cc0..a000c29 100644
--- a/NON-UNIX-USE
+++ b/NON-UNIX-USE
@@ -1,6 +1,8 @@
Compiling PCRE on non-Unix systems
----------------------------------
+See below for comments on Cygwin or MinGW usage.
+
If you want to compile PCRE for a non-Unix system, note that it consists
entirely of code written in Standard C, and so should compile successfully
on any machine with a Standard C compiler and library, using normal compiling
@@ -24,7 +26,7 @@ character tables.
(4) Compile maketables.c, get.c, study.c and pcre.c and link them all
together into an object library in whichever form your system keeps such
-libraries. This is the pcre library (chartables.c gets included by means of an
+libraries. This is the pcre library (chartables.c is included by means of an
#include directive).
(5) Similarly, compile pcreposix.c and link it as the pcreposix library.
@@ -34,20 +36,78 @@ pcre and pcreposix libraries when linking.
(7) Run pcretest on the testinput files in the testdata directory, and check
that the output matches the corresponding testoutput files. You must use the
--i option when checking testinput2.
+-i option when checking testinput2. Note that the supplied files are in Unix
+format, with just LF characters as line terminators. You may need to edit them
+to change this if your system uses a different convention.
If you have a system without "configure" but where you can use a Makefile, edit
Makefile.in to create Makefile, substituting suitable values for the variables
at the head of the file.
Some help in building a Win32 DLL of PCRE in GnuWin32 environments was
-contributed by Paul.Sokolovsky@technologist.com. These environments are
-Mingw32 (http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and
-CygWin (http://sourceware.cygnus.com/cygwin/). Paul comments:
+contributed by Paul Sokolovsky. These environments are Mingw32
+(http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and CygWin
+(http://sourceware.cygnus.com/cygwin/). Paul comments:
For CygWin, set CFLAGS=-mno-cygwin, and do 'make dll'. You'll get
pcre.dll (containing pcreposix also), libpcre.dll.a, and dynamically
linked pgrep and pcretest. If you have /bin/sh, run RunTest (three
main test go ok, locale not supported).
+Changes to do MinGW with autoconf 2.50 were supplied by Fred Cox
+<sailorFred@yahoo.com>, who comments as follows:
+
+ If you are using the PCRE DLL, the normal Unix style configure && make &&
+ make check && make install should just work[*]. If you want to statically
+ link against the .a file, you must define PCRE_STATIC before including
+ pcre.h, otherwise the pcre_malloc and pcre_free exported functions will be
+ declared __declspec(dllimport), with hilarious results. See the configure.in
+ and pcretest.c for how it is done for the static test.
+
+ Also, there will only be a libpcre.la, not a libpcreposix.la, as you
+ would expect from the Unix version. The single DLL includes the pcreposix
+ interface.
+
+[*] But note that the supplied test files are in Unix format, with just LF
+characters as line terminators. You will have to edit them to change to CR LF
+terminators.
+
+A script for building PCRE using Borland's C++ compiler for use with VPASCAL
+was contributed by Alexander Tokarev. It is called makevp.bat.
+
+These are some further comments about Win32 builds from Mark Evans. They
+were contributed before Fred Cox's changes were made, so it is possible that
+they may no longer be relevant.
+
+The documentation for Win32 builds is a bit shy. Under MSVC6 I
+followed their instructions to the letter, but there were still
+some things missing.
+
+(1) Must #define STATIC for entire project if linking statically.
+ (I see no reason to use DLLs for code this compact.) This of
+ course is a project setting in MSVC under Preprocessor.
+
+(2) Missing some #ifdefs relating to the function pointers
+ pcre_malloc and pcre_free. See my solution below. (The stubs
+ may not be mandatory but they made me feel better.)
+
+=========================
+#ifdef _WIN32
+#include <malloc.h>
+
+void* malloc_stub(size_t N)
+{ return malloc(N); }
+void free_stub(void* p)
+{ free(p); }
+void *(*pcre_malloc)(size_t) = &malloc_stub;
+void (*pcre_free)(void *) = &free_stub;
+
+#else
+
+void *(*pcre_malloc)(size_t) = malloc;
+void (*pcre_free)(void *) = free;
+
+#endif
+=========================
+
****
diff --git a/README b/README
index 7557374..a1e04cb 100644
--- a/README
+++ b/README
@@ -30,13 +30,14 @@ Windows systems (I myself do not use Windows). Some are complete in themselves;
others are pointers to URLs containing relevant files.
-Building PCRE on a Unix system
-------------------------------
+Building PCRE on a Unix-like system
+-----------------------------------
-To build PCRE on a Unix system, first run the "configure" command from the PCRE
-distribution directory, with your current directory set to the directory where
-you want the files to be created. This command is a standard GNU "autoconf"
-configuration script, for which generic instructions are supplied in INSTALL.
+To build PCRE on a Unix-like system, first run the "configure" command from the
+PCRE distribution directory, with your current directory set to the directory
+where you want the files to be created. This command is a standard GNU
+"autoconf" configuration script, for which generic instructions are supplied in
+INSTALL.
Most commonly, people build PCRE within its own distribution directory, and in
this case, on many systems, just running "./configure" is sufficient, but the
@@ -55,11 +56,45 @@ into /source/pcre/pcre-xxx, but you want to build it in /build/pcre/pcre-xxx:
cd /build/pcre/pcre-xxx
/source/pcre/pcre-xxx/configure
-If you want to make use of the experimential, incomplete support for UTF-8
-character strings in PCRE, you must add --enable-utf8 to the "configure"
-command. Without it, the code for handling UTF-8 is not included in the
-library. (Even when included, it still has to be enabled by an option at run
-time.)
+There are some optional features that can be included or omitted from the PCRE
+library. You can read more about them in the pcrebuild man page.
+
+. If you want to make use of the support for UTF-8 character strings in PCRE,
+ you must add --enable-utf8 to the "configure" command. Without it, the code
+ for handling UTF-8 is not included in the library. (Even when included, it
+ still has to be enabled by an option at run time.)
+
+. You can build PCRE to recognized CR or NL as the newline character, instead
+ of whatever your compiler uses for "\n", by adding --newline-is-cr or
+ --newline-is-nl to the "configure" command, respectively. Only do this if you
+ really understand what you are doing. On traditional Unix-like systems, the
+ newline character is NL.
+
+. When called via the POSIX interface, PCRE uses malloc() to get additional
+ storage for processing capturing parentheses if there are more than 10 of
+ them. You can increase this threshold by setting, for example,
+
+ --with-posix-malloc-threshold=20
+
+ on the "configure" command.
+
+. PCRE has a counter which can be set to limit the amount of resources it uses.
+ If the limit is exceeded during a match, the match fails. The default is ten
+ million. You can change the default by setting, for example,
+
+ --with-match-limit=500000
+
+ on the "configure" command. This is just the default; individual calls to
+ pcre_exec() can supply their own value. There is discussion on the pcreapi
+ man page.
+
+. The default maximum compiled pattern size is around 64K. You can increase
+ this by adding --with-link-size=3 to the "configure" command. You can
+ increase it even more by setting --with-link-size=4, but this is unlikely
+ ever to be necessary. If you build PCRE with an increased link size, test 2
+ (and 5 if you are using UTF-8) will fail. Part of the output of these tests
+ is a representation of the compiled pattern, and this changes with the link
+ size.
The "configure" script builds five files:
@@ -89,16 +124,9 @@ outputs information about where the library is installed. This command can be
included in makefiles for programs that use PCRE, saving the programmer from
having to remember too many details.
-There is one esoteric feature that is controlled by "configure". It concerns
-the character value used for "newline", and is something that you probably do
-not want to change on a Unix system. The default is to use whatever value your
-compiler gives to '\n'. By using --enable-newline-is-cr or
---enable-newline-is-lf you can force the value to be CR (13) or LF (10) if you
-really want to.
-
-Shared libraries on Unix systems
---------------------------------
+Shared libraries on Unix-like systems
+-------------------------------------
The default distribution builds PCRE as two shared libraries and two static
libraries, as long as the operating system supports shared libraries. Shared
@@ -123,6 +151,19 @@ Then run "make" in the usual way. Similarly, you can use --disable-static to
build only shared libraries.
+Cross-compiling on a Unix-like system
+-------------------------------------
+
+You can specify CC and CFLAGS in the normal way to the "configure" command, in
+order to cross-compile PCRE for some other host. However, during the building
+process, the dftables.c source file is compiled *and run* on the local host, in
+order to generate the default character tables (the chartables.c file). It
+therefore needs to be compiled with the local compiler, not the cross compiler.
+You can do this by specifying HOST_CC (and if necessary HOST_CFLAGS) when
+calling the "configure" command. If they are not specified, they default to the
+values of CC and CFLAGS.
+
+
Building on non-Unix systems
----------------------------
@@ -140,20 +181,18 @@ To test PCRE on a Unix system, run the RunTest script that is created by the
configuring process. (This can also be run by "make runtest", "make check", or
"make test".) For other systems, see the instruction in NON-UNIX-USE.
-The script runs the pcretest test program (which is documented in the doc
-directory) on each of the testinput files (in the testdata directory) in turn,
+The script runs the pcretest test program (which is documented in its own man
+page) on each of the testinput files (in the testdata directory) in turn,
and compares the output with the contents of the corresponding testoutput file.
A file called testtry is used to hold the output from pcretest. To run pcretest
on just one of the test files, give its number as an argument to RunTest, for
example:
- RunTest 3
+ RunTest 2
-The first and third test files can also be fed directly into the perltest
-script to check that Perl gives the same results. The third file requires the
-additional features of release 5.005, which is why it is kept separate from the
-main test input, which needs only Perl 5.004. In the long run, when 5.005 (or
-higher) is widespread, these two test files may get amalgamated.
+The first file can also be fed directly into the perltest script to check that
+Perl gives the same results. The only difference you should see is in the first
+few lines, where the Perl version is given instead of the PCRE version.
The second set of tests check pcre_fullinfo(), pcre_info(), pcre_study(),
pcre_copy_substring(), pcre_get_substring(), pcre_get_substring_list(), error
@@ -171,12 +210,12 @@ listed for checking. Where the comparison test output contains [\x00-\x7f] the
test will contain [\x00-\xff], and similarly in some other cases. This is not a
bug in PCRE.
-The fourth set of tests checks pcre_maketables(), the facility for building a
+The third set of tests checks pcre_maketables(), the facility for building a
set of character tables for a specific locale and using them instead of the
default tables. The tests make use of the "fr" (French) locale. Before running
the test, the script checks for the presence of this locale by running the
"locale" command. If that command fails, or if it doesn't include "fr" in the
-list of available locales, the fourth test cannot be run, and a comment is
+list of available locales, the third test cannot be run, and a comment is
output to say why. If running this test produces instances of the error
** Failed to set locale "fr"
@@ -184,10 +223,14 @@ output to say why. If running this test produces instances of the error
in the comparison output, it means that locale is not available on your system,
despite being listed by "locale". This does not mean that PCRE is broken.
-The fifth test checks the experimental, incomplete UTF-8 support. It is not run
-automatically unless PCRE is built with UTF-8 support. This file can be fed
-directly to the perltest8 script, which requires Perl 5.6 or higher. The sixth
-file tests internal UTF-8 features of PCRE that are not relevant to Perl.
+The fourth test checks the UTF-8 support. It is not run automatically unless
+PCRE is built with UTF-8 support. To do this you must set --enable-utf8 when
+running "configure". This file can be also fed directly to the perltest script,
+provided you are running Perl 5.8 or higher. (For Perl 5.6, a small patch,
+commented in the script, can be be used.)
+
+The fifth and final file tests error handling with UTF-8 encoding, and internal
+UTF-8 features of PCRE that are not relevant to Perl.
Character tables
@@ -243,6 +286,7 @@ The distribution should contain the following files:
study.c ) source of
pcre.c ) the functions
pcreposix.c )
+ printint.c )
pcre.in "source" for the header for the external API; pcre.h
is built from this by "configure"
pcreposix.h header for the external POSIX wrapper API
@@ -266,42 +310,38 @@ The distribution should contain the following files:
configure a configuring shell script (built by autoconf)
configure.in the autoconf input used to build configure
doc/Tech.Notes notes on the encoding
- doc/pcre.3 man page source for the PCRE functions
- doc/pcre.html HTML version
- doc/pcre.txt plain text version
- doc/pcreposix.3 man page source for the POSIX wrapper API
- doc/pcreposix.html HTML version
- doc/pcreposix.txt plain text version
- doc/pcretest.txt documentation of test program
- doc/perltest.txt documentation of Perl test program
- doc/pcregrep.1 man page source for the pcregrep utility
- doc/pcregrep.html HTML version
- doc/pcregrep.txt plain text version
+ doc/*.3 man page sources for the PCRE functions
+ doc/*.1 man page sources for pcregrep and pcretest
+ doc/html/* HTML documentation
+ doc/pcre.txt plain text version of the man pages
+ doc/pcretest.txt plain text documentation of test program
+ doc/perltest.txt plain text documentation of Perl test program
install-sh a shell script for installing files
ltmain.sh file used to build a libtool script
pcretest.c comprehensive test program
pcredemo.c simple demonstration of coding calls to PCRE
perltest Perl test program
- perltest8 Perl test program for UTF-8 tests
pcregrep.c source of a grep utility that uses PCRE
pcre-config.in source of script which retains PCRE information
- testdata/testinput1 test data, compatible with Perl 5.004 and 5.005
+ testdata/testinput1 test data, compatible with Perl
testdata/testinput2 test data for error messages and non-Perl things
- testdata/testinput3 test data, compatible with Perl 5.005
- testdata/testinput4 test data for locale-specific tests
- testdata/testinput5 test data for UTF-8 tests compatible with Perl 5.6
- testdata/testinput6 test data for other UTF-8 tests
+ testdata/testinput3 test data for locale-specific tests
+ testdata/testinput4 test data for UTF-8 tests compatible with Perl
+ testdata/testinput5 test data for other UTF-8 tests
testdata/testoutput1 test results corresponding to testinput1
testdata/testoutput2 test results corresponding to testinput2
testdata/testoutput3 test results corresponding to testinput3
testdata/testoutput4 test results corresponding to testinput4
testdata/testoutput5 test results corresponding to testinput5
- testdata/testoutput6 test results corresponding to testinput6
(C) Auxiliary files for Win32 DLL
dll.mk
pcre.def
+(D) Auxiliary file for VPASCAL
+
+ makevp.bat
+
Philip Hazel <ph10@cam.ac.uk>
-August 2001
+February 2003
diff --git a/RunTest.in b/RunTest.in
index 63c4b26..dd5a02f 100755
--- a/RunTest.in
+++ b/RunTest.in
@@ -15,7 +15,6 @@ do2=no
do3=no
do4=no
do5=no
-do6=no
while [ $# -gt 0 ] ; do
case $1 in
@@ -24,31 +23,29 @@ while [ $# -gt 0 ] ; do
3) do3=yes;;
4) do4=yes;;
5) do5=yes;;
- 6) do6=yes;;
*) echo "Unknown test number $1"; exit 1;;
esac
shift
done
if [ "@UTF8@" = "" ] ; then
- if [ $do5 = yes ] ; then
- echo "Can't run test 5 because UFT8 support is not configured"
+ if [ $do4 = yes ] ; then
+ echo "Can't run test 4 because UFT8 support is not configured"
exit 1
fi
- if [ $do6 = yes ] ; then
- echo "Can't run test 6 because UFT8 support is not configured"
+ if [ $do5 = yes ] ; then
+ echo "Can't run test 5 because UFT8 support is not configured"
exit 1
fi
fi
if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a\
- $do5 = no -a $do6 = no ] ; then
+ $do5 = no ] ; then
do1=yes
do2=yes
do3=yes
- do4=yes
+ if [ "@UTF8@" != "" ] ; then do4=yes; fi
if [ "@UTF8@" != "" ] ; then do5=yes; fi
- if [ "@UTF8@" != "" ] ; then do6=yes; fi
fi
# Primary test, Perl-compatible
@@ -59,6 +56,7 @@ if [ $do1 = yes ] ; then
if [ $? = 0 ] ; then
$cf testtry $testdata/testoutput1
if [ $? != 0 ] ; then exit 1; fi
+ echo " "
else exit 1
fi
fi
@@ -75,33 +73,21 @@ if [ $do2 = yes ] ; then
fi
fi
-# Additional Perl-compatible tests for Perl 5.005's new features
-
-if [ $do3 = yes ] ; then
- echo "Testing Perl 5.005 features (Perl 5.005 compatible)"
- ./pcretest $testdata/testinput3 testtry
- if [ $? = 0 ] ; then
- $cf testtry $testdata/testoutput3
- if [ $? != 0 ] ; then exit 1; fi
- else exit 1
- fi
-fi
-
-if [ $do1 = yes -a $do2 = yes -a $do3 = yes ] ; then
+if [ $do1 = yes -a $do2 = yes ] ; then
echo " "
- echo "The three main tests all ran OK"
+ echo "The two main tests ran OK"
echo " "
fi
# Locale-specific tests, provided the "fr" locale is available
-if [ $do4 = yes ] ; then
+if [ $do3 = yes ] ; then
locale -a | grep '^fr$' >/dev/null
if [ $? -eq 0 ] ; then
echo "Testing locale-specific features (using 'fr' locale)"
- ./pcretest $testdata/testinput4 testtry
+ ./pcretest $testdata/testinput3 testtry
if [ $? = 0 ] ; then
- $cf testtry $testdata/testoutput4
+ $cf testtry $testdata/testoutput3
if [ $? != 0 ] ; then
echo " "
echo "Locale test did not run entirely successfully."
@@ -122,11 +108,11 @@ fi
# Additional tests for UTF8 support
-if [ $do5 = yes ] ; then
- echo "Testing experimental, incomplete UTF8 support (Perl compatible)"
- ./pcretest $testdata/testinput5 testtry
+if [ $do4 = yes ] ; then
+ echo "Testing UTF-8 support (Perl compatible)"
+ ./pcretest $testdata/testinput4 testtry
if [ $? = 0 ] ; then
- $cf testtry $testdata/testoutput5
+ $cf testtry $testdata/testoutput4
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
@@ -134,11 +120,11 @@ if [ $do5 = yes ] ; then
echo " "
fi
-if [ $do6 = yes ] ; then
- echo "Testing API and internals for UTF8 support (not Perl compatible)"
- ./pcretest $testdata/testinput6 testtry
+if [ $do5 = yes ] ; then
+ echo "Testing API and internals for UTF-8 support (not Perl compatible)"
+ ./pcretest $testdata/testinput5 testtry
if [ $? = 0 ] ; then
- $cf testtry $testdata/testoutput6
+ $cf testtry $testdata/testoutput5
if [ $? != 0 ] ; then exit 1; fi
else exit 1
fi
diff --git a/config.guess b/config.guess
index ba66165..9b1384b 100755
--- a/config.guess
+++ b/config.guess
@@ -1,9 +1,9 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002 Free Software Foundation, Inc.
-timestamp='2001-04-20'
+timestamp='2002-11-30'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -24,8 +24,9 @@ timestamp='2001-04-20'
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
-# Written by Per Bothner <bothner@cygnus.com>.
-# Please send patches to <config-patches@gnu.org>.
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
@@ -52,7 +53,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
@@ -87,33 +88,43 @@ if test $# != 0; then
exit 1
fi
+trap 'exit 1' 1 2 15
-dummy=dummy-$$
-trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
-# CC_FOR_BUILD -- compiler used by this script.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
+# This shell variable is my proudest work .. or something. --bje
+
+set_cc_for_build='tmpdir=${TMPDIR-/tmp}/config-guess-$$ ;
+(old=`umask` && umask 077 && mkdir $tmpdir && umask $old && unset old)
+ || (echo "$me: cannot create $tmpdir" >&2 && exit 1) ;
+dummy=$tmpdir/dummy ;
+files="$dummy.c $dummy.o $dummy.rel $dummy" ;
+trap '"'"'rm -f $files; rmdir $tmpdir; exit 1'"'"' 1 2 15 ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,) echo "int dummy(){}" > $dummy.c
- for c in cc gcc c89 ; do
- ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1
- if test $? = 0 ; then
- CC_FOR_BUILD="$c"; break
- fi
- done
- rm -f $dummy.c $dummy.o $dummy.rel
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ rm -f $files ;
if test x"$CC_FOR_BUILD" = x ; then
- CC_FOR_BUILD=no_compiler_found
+ CC_FOR_BUILD=no_compiler_found ;
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
-esac
+esac ;
+unset files'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 8/24/94.)
+# (ghazi@noc.rutgers.edu 1994-08-24)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
@@ -127,29 +138,31 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
- # Netbsd (nbsd) targets should (where applicable) match one or
+ # NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
- # Determine the machine/vendor (is the vendor relevant).
- case "${UNAME_MACHINE}" in
- amiga) machine=m68k-unknown ;;
- arm32) machine=arm-unknown ;;
- atari*) machine=m68k-atari ;;
- sun3*) machine=m68k-sun ;;
- mac68k) machine=m68k-apple ;;
- macppc) machine=powerpc-apple ;;
- hp3[0-9][05]) machine=m68k-hp ;;
- ibmrt|romp-ibm) machine=romp-ibm ;;
- *) machine=${UNAME_MACHINE}-unknown ;;
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
- case "${UNAME_MACHINE}" in
- i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep __ELF__ >/dev/null
then
@@ -165,12 +178,62 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
;;
esac
# The OS release
- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit 0 ;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ macppc:OpenBSD:*:*)
+ echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvmeppc:OpenBSD:*:*)
+ echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mipseb-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sun3:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
alpha:OSF1:*:*)
if test $UNAME_RELEASE = "V4.0"; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -179,6 +242,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
+ eval $set_cc_for_build
cat <<EOF >$dummy.s
.data
\$Lformat:
@@ -204,9 +268,9 @@ main:
jsr \$26,exit
.end main
EOF
- $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+ $CC_FOR_BUILD -o $dummy $dummy.s 2>/dev/null
if test "$?" = 0 ; then
- case `./$dummy` in
+ case `$dummy` in
0-0)
UNAME_MACHINE="alpha"
;;
@@ -225,9 +289,15 @@ EOF
2-307)
UNAME_MACHINE="alphaev67"
;;
+ 2-1307)
+ UNAME_MACHINE="alphaev68"
+ ;;
+ 3-1307)
+ UNAME_MACHINE="alphaev7"
+ ;;
esac
fi
- rm -f $dummy.s $dummy
+ rm -f $dummy.s $dummy && rmdir $tmpdir
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit 0 ;;
Alpha\ *:Windows_NT*:*)
@@ -242,29 +312,11 @@ EOF
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
exit 0;;
- amiga:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
exit 0 ;;
- arc64:OpenBSD:*:*)
- echo mips64el-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- arc:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- hkmips:OpenBSD:*:*)
- echo mips-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- pmax:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- sgi:OpenBSD:*:*)
- echo mips-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- wgrisc:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
exit 0 ;;
*:OS/390:*:*)
echo i370-ibm-openedition
@@ -286,6 +338,10 @@ EOF
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit 0 ;;
+ DRS?6000:UNIX_SV:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7 && exit 0 ;;
+ esac ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
@@ -314,7 +370,7 @@ EOF
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
sun*:*:4.2BSD:*)
- UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
@@ -328,9 +384,6 @@ EOF
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit 0 ;;
- atari*:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
@@ -357,18 +410,6 @@ EOF
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit 0 ;;
- sun3*:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mac68k:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvme68k:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvme88k:OpenBSD:*:*)
- echo m88k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;;
@@ -385,6 +426,7 @@ EOF
echo clipper-intergraph-clix${UNAME_RELEASE}
exit 0 ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
@@ -406,15 +448,21 @@ EOF
exit (-1);
}
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy \
- && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
- && rm -f $dummy.c $dummy && exit 0
- rm -f $dummy.c $dummy
+ $CC_FOR_BUILD -o $dummy $dummy.c \
+ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
+ rm -f $dummy.c $dummy && rmdir $tmpdir
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit 0 ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit 0 ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit 0 ;;
@@ -475,6 +523,7 @@ EOF
exit 0 ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <sys/systemcfg.h>
@@ -486,8 +535,8 @@ EOF
exit(0);
}
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
- rm -f $dummy.c $dummy
+ $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
+ rm -f $dummy.c $dummy && rmdir $tmpdir
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
@@ -496,7 +545,7 @@ EOF
fi
exit 0 ;;
*:AIX:*:[45])
- IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
@@ -536,10 +585,8 @@ EOF
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
- case "${HPUX_REV}" in
- 11.[0-9][0-9])
- if [ -x /usr/bin/getconf ]; then
- sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
@@ -548,12 +595,13 @@ EOF
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
- fi ;;
- esac
- if [ "${HP_ARCH}" = "" ]; then
- sed 's/^ //' << EOF >$dummy.c
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include <stdlib.h>
@@ -586,10 +634,10 @@ EOF
exit (0);
}
EOF
- (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
- if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
- rm -f $dummy.c $dummy
- fi ;;
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
+ rm -f $dummy.c $dummy && rmdir $tmpdir
+ fi ;;
esac
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
@@ -598,6 +646,7 @@ EOF
echo ia64-hp-hpux${HPUX_REV}
exit 0 ;;
3050*:HI-UX:*:*)
+ eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <unistd.h>
int
@@ -623,8 +672,8 @@ EOF
exit (0);
}
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
- rm -f $dummy.c $dummy
+ $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
+ rm -f $dummy.c $dummy && rmdir $tmpdir
echo unknown-hitachi-hiuxwe2
exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
@@ -633,7 +682,7 @@ EOF
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit 0 ;;
- *9??*:MPE/iX:*:*)
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
exit 0 ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
@@ -652,9 +701,6 @@ EOF
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
- hppa*:OpenBSD:*:*)
- echo hppa-unknown-openbsd
- exit 0 ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit 0 ;;
@@ -673,16 +719,14 @@ EOF
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit 0 ;;
- CRAY*X-MP:*:*:*)
- echo xmp-cray-unicos
- exit 0 ;;
CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE}
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*[A-Z]90:*:*:*)
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
- -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
@@ -696,18 +740,12 @@ EOF
CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
- CRAY-2:*:*:*)
- echo cray2-cray-unicos
- exit 0 ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
- hp300:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
@@ -718,10 +756,19 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit 0 ;;
- *:OpenBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ # Determine whether the default compiler uses glibc.
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #if __GLIBC__ >= 2
+ LIBC=gnu
+ #else
+ LIBC=
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+ rm -f $dummy.c && rmdir $tmpdir
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
exit 0 ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
@@ -732,11 +779,17 @@ EOF
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit 0 ;;
+ x86:Interix*:3*)
+ echo i586-pc-interix3
+ exit 0 ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit 0 ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386?
- echo i386-pc-interix
+ echo i586-pc-interix
exit 0 ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
@@ -757,103 +810,69 @@ EOF
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
mips:Linux:*:*)
- cat >$dummy.c <<EOF
-#ifdef __cplusplus
-#include <stdio.h> /* for printf() prototype */
-int main (int argc, char *argv[]) {
-#else
-int main (argc, argv) int argc; char *argv[]; {
-#endif
-#ifdef __MIPSEB__
- printf ("%s-unknown-linux-gnu\n", argv[1]);
-#endif
-#ifdef __MIPSEL__
- printf ("%sel-unknown-linux-gnu\n", argv[1]);
-#endif
- return 0;
-}
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
- rm -f $dummy.c $dummy
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ rm -f $dummy.c && rmdir $tmpdir
+ test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
;;
- ppc:Linux:*:*)
- # Determine Lib Version
- cat >$dummy.c <<EOF
-#include <features.h>
-#if defined(__GLIBC__)
-extern char __libc_version[];
-extern char __libc_release[];
-#endif
-main(argc, argv)
- int argc;
- char *argv[];
-{
-#if defined(__GLIBC__)
- printf("%s %s\n", __libc_version, __libc_release);
-#else
- printf("unknown\n");
-#endif
- return 0;
-}
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
EOF
- LIBC=""
- $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
- if test "$?" = 0 ; then
- ./$dummy | grep 1\.99 > /dev/null
- if test "$?" = 0 ; then LIBC="libc1" ; fi
- fi
- rm -f $dummy.c $dummy
- echo powerpc-unknown-linux-gnu${LIBC}
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ rm -f $dummy.c && rmdir $tmpdir
+ test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+ ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit 0 ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
exit 0 ;;
alpha:Linux:*:*)
- cat <<EOF >$dummy.s
- .data
- \$Lformat:
- .byte 37,100,45,37,120,10,0 # "%d-%x\n"
- .text
- .globl main
- .align 4
- .ent main
- main:
- .frame \$30,16,\$26,0
- ldgp \$29,0(\$27)
- .prologue 1
- .long 0x47e03d80 # implver \$0
- lda \$2,-1
- .long 0x47e20c21 # amask \$2,\$1
- lda \$16,\$Lformat
- mov \$0,\$17
- not \$1,\$18
- jsr \$26,printf
- ldgp \$29,0(\$26)
- mov 0,\$16
- jsr \$26,exit
- .end main
-EOF
- LIBC=""
- $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
- if test "$?" = 0 ; then
- case `./$dummy` in
- 0-0) UNAME_MACHINE="alpha" ;;
- 1-0) UNAME_MACHINE="alphaev5" ;;
- 1-1) UNAME_MACHINE="alphaev56" ;;
- 1-101) UNAME_MACHINE="alphapca56" ;;
- 2-303) UNAME_MACHINE="alphaev6" ;;
- 2-307) UNAME_MACHINE="alphaev67" ;;
- esac
- objdump --private-headers $dummy | \
- grep ld.so.1 > /dev/null
- if test "$?" = 0 ; then
- LIBC="libc1"
- fi
- fi
- rm -f $dummy.s $dummy
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit 0 ;;
parisc:Linux:*:* | hppa:Linux:*:*)
@@ -883,71 +902,60 @@ EOF
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
- ld_supported_emulations=`cd /; ld --help 2>&1 \
- | sed -ne '/supported emulations:/!d
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g
- s/.*supported emulations: *//
+ s/.*supported targets: *//
s/ .*//
p'`
- case "$ld_supported_emulations" in
- i*86linux)
- echo "${UNAME_MACHINE}-pc-linux-gnuaout"
- exit 0
- ;;
- elf_i*86)
+ case "$ld_supported_targets" in
+ elf32-i386)
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;;
- i*86coff)
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit 0 ;;
+ coff-i386)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
- exit 0
- ;;
- esac
- # Either a pre-BFD a.out linker (linux-gnuoldld)
- # or one that does not give us useful --help.
- # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
- # If ld does not provide *any* "supported emulations:"
- # that means it is gnuoldld.
- test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
- case "${UNAME_MACHINE}" in
- i*86)
- VENDOR=pc;
- ;;
- *)
- VENDOR=unknown;
- ;;
+ exit 0 ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit 0 ;;
esac
# Determine whether the default compiler is a.out or elf
- cat >$dummy.c <<EOF
-#include <features.h>
-#ifdef __cplusplus
-#include <stdio.h> /* for printf() prototype */
- int main (int argc, char *argv[]) {
-#else
- int main (argc, argv) int argc; char *argv[]; {
-#endif
-#ifdef __ELF__
-# ifdef __GLIBC__
-# if __GLIBC__ >= 2
- printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
-# else
- printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
-# endif
-# else
- printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
-# endif
-#else
- printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
-#endif
- return 0;
-}
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #ifdef __INTEL_COMPILER
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
- rm -f $dummy.c $dummy
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+ rm -f $dummy.c && rmdir $tmpdir
+ test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
;;
-# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
-# are messed up and put the nodename in both sysname and nodename.
i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
echo i386-sequent-sysv4
exit 0 ;;
i*86:UNIX_SV:4.2MP:2.*)
@@ -958,6 +966,23 @@ EOF
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit 0 ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit 0 ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit 0 ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit 0 ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit 0 ;;
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
@@ -966,36 +991,32 @@ EOF
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
exit 0 ;;
- i*86:*:5:7*)
- # Fixed at (any) Pentium or better
- UNAME_MACHINE=i586
- if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
- echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
- else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
- fi
+ i*86:*:5:[78]*)
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
exit 0 ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
elif /bin/uname -X 2>/dev/null >/dev/null ; then
- UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
- (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
- (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
- (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
- i*86:*DOS:*:*)
- echo ${UNAME_MACHINE}-pc-msdosdjgpp
- exit 0 ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
@@ -1019,9 +1040,15 @@ EOF
# "miniframe"
echo m68010-convergent-sysv
exit 0 ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit 0 ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit 0 ;;
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
- 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+ 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -1038,9 +1065,6 @@ EOF
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
@@ -1067,8 +1091,8 @@ EOF
echo ns32k-sni-sysv
fi
exit 0 ;;
- PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit 0 ;;
*:UNIX_System_V:4*:FTX*)
@@ -1080,6 +1104,10 @@ EOF
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit 0 ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit 0 ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit 0 ;;
@@ -1108,6 +1136,9 @@ EOF
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
exit 0 ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
@@ -1118,15 +1149,17 @@ EOF
echo `uname -p`-apple-darwin${UNAME_RELEASE}
exit 0 ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
- if test "${UNAME_MACHINE}" = "x86pc"; then
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
- echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit 0 ;;
*:QNX:*:4*)
echo i386-pc-qnx
exit 0 ;;
- NSR-[KW]:NONSTOP_KERNEL:*:*)
+ NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit 0 ;;
*:NonStop-UX:*:*)
@@ -1149,11 +1182,6 @@ EOF
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit 0 ;;
- i*86:OS/2:*:*)
- # If we were able to find `uname', then EMX Unix compatibility
- # is probably installed.
- echo ${UNAME_MACHINE}-pc-os2-emx
- exit 0 ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
exit 0 ;;
@@ -1177,6 +1205,7 @@ esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+eval $set_cc_for_build
cat >$dummy.c <<EOF
#ifdef _SEQUENT_
# include <sys/types.h>
@@ -1291,8 +1320,8 @@ main ()
}
EOF
-$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
-rm -f $dummy.c $dummy
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
+rm -f $dummy.c $dummy && rmdir $tmpdir
# Apollos put the system type in the environment.
diff --git a/config.in b/config.in
index 767cbd0..62a594e 100644
--- a/config.in
+++ b/config.in
@@ -44,4 +44,27 @@ On Unix systems, "configure" can be used to override this default. */
#define NEWLINE '\n'
#endif
+/* The value of LINK_SIZE determines the number of bytes used to store
+links as offsets within the compiled regex. The default is 2, which allows for
+compiled patterns up to 64K long. This covers the vast majority of cases.
+However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows for
+longer patterns in extreme cases. On Unix systems, "configure" can be used to
+override this default. */
+
+#ifndef LINK_SIZE
+#define LINK_SIZE 2
+#endif
+
+/* The value of MATCH_LIMIT determines the default number of times the match()
+function can be called during a single execution of pcre_exec(). (There is a
+runtime method of setting a different limit.) The limit exists in order to
+catch runaway regular expressions that take for ever to determine that they do
+not match. The default is set very large so that it does not accidentally catch
+legitimate cases. On Unix systems, "configure" can be used to override this
+default default. */
+
+#ifndef MATCH_LIMIT
+#define MATCH_LIMIT 10000000
+#endif
+
/* End */
diff --git a/config.sub b/config.sub
index 93a3a14..f0675aa 100755
--- a/config.sub
+++ b/config.sub
@@ -1,9 +1,9 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002 Free Software Foundation, Inc.
-timestamp='2001-05-11'
+timestamp='2002-11-30'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -29,7 +29,8 @@ timestamp='2001-05-11'
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
-# Please send patches to <config-patches@gnu.org>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
@@ -117,7 +118,7 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
- nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*)
+ nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -157,6 +158,14 @@ case $os in
os=-vxworks
basic_machine=$1
;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
-hiux*)
os=-hiuxwe2
;;
@@ -215,26 +224,46 @@ esac
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
- tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
- | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
- | pyramid | mn10200 | mn10300 | tron | a29k \
- | 580 | i960 | h8300 \
- | x86 | ppcbe | mipsbe | mipsle | shbe | shle \
- | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
- | hppa64 \
- | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
- | alphaev6[78] \
- | we32k | ns16k | clipper | i370 | sh | sh[34] \
- | powerpc | powerpcle \
- | 1750a | dsp16xx | pdp10 | pdp11 \
- | mips16 | mips64 | mipsel | mips64el \
- | mips64orion | mips64orionel | mipstx39 | mipstx39el \
- | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
- | mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \
- | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \
- | v850 | c4x \
- | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \
- | pj | pjl | h8500 | z8k)
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+ | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k \
+ | m32r | m68000 | m68k | m88k | mcore \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | ns16k | ns32k \
+ | openrisc | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
+ | strongarm \
+ | tahoe | thumb | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xscale | xstormy16 | xtensa \
+ | z8k)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
@@ -242,7 +271,7 @@ case $basic_machine in
basic_machine=$basic_machine-unknown
os=-none
;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65 | z8k)
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
# We use `pc' rather than `unknown'
@@ -257,31 +286,56 @@ case $basic_machine in
exit 1
;;
# Recognize the basic CPU types with company name.
- # FIXME: clean up the formatting here.
- vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
- | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
- | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
- | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
- | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
- | xmp-* | ymp-* \
- | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
- | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
- | hppa2.0n-* | hppa64-* \
- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
- | alphaev6[78]-* \
- | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
- | clipper-* | orion-* \
- | sparclite-* | pdp10-* | pdp11-* | sh-* | sh[34]-* | sh[34]eb-* \
- | powerpc-* | powerpcle-* | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \
- | mips16-* | mips64-* | mipsel-* \
- | mips64el-* | mips64orion-* | mips64orionel-* \
- | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
- | mipstx39-* | mipstx39el-* | mcore-* \
- | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \
- | [cjt]90-* \
- | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
- | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \
- | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*)
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* \
+ | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* \
+ | clipper-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* \
+ | m32r-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39 | mipstx39el \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
+ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* | tic30-* | tic4x-* | tic54x-* | tic80-* | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
+ | xtensa-* \
+ | ymp-* \
+ | z8k-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@@ -344,6 +398,10 @@ case $basic_machine in
basic_machine=ns32k-sequent
os=-dynix
;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
convex-c1)
basic_machine=c1-convex
os=-bsd
@@ -364,16 +422,8 @@ case $basic_machine in
basic_machine=c38-convex
os=-bsd
;;
- cray | ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- cray2)
- basic_machine=cray2-cray
- os=-unicos
- ;;
- [cjt]90)
- basic_machine=${basic_machine}-cray
+ cray | j90)
+ basic_machine=j90-cray
os=-unicos
;;
crds | unos)
@@ -388,6 +438,14 @@ case $basic_machine in
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
@@ -568,14 +626,6 @@ case $basic_machine in
basic_machine=m68k-atari
os=-mint
;;
- mipsel*-linux*)
- basic_machine=mipsel-unknown
- os=-linux-gnu
- ;;
- mips*-linux*)
- basic_machine=mips-unknown
- os=-linux-gnu
- ;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
@@ -590,6 +640,10 @@ case $basic_machine in
basic_machine=m68k-rom68k
os=-coff
;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
msdos)
basic_machine=i386-pc
os=-msdos
@@ -669,6 +723,10 @@ case $basic_machine in
basic_machine=hppa1.1-oki
os=-proelf
;;
+ or32 | or32-*)
+ basic_machine=or32-unknown
+ os=-coff
+ ;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
@@ -691,19 +749,19 @@ case $basic_machine in
pbb)
basic_machine=m68k-tti
;;
- pc532 | pc532-*)
+ pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
- pentium | p5 | k5 | k6 | nexgen)
+ pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
- pentiumpro | p6 | 6x86 | athlon)
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
basic_machine=i686-pc
;;
pentiumii | pentium2)
basic_machine=i686-pc
;;
- pentium-* | p5-* | k5-* | k6-* | nexgen-*)
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
@@ -718,15 +776,25 @@ case $basic_machine in
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
- ;;
+ ;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
- ;;
+ ;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
ps2)
basic_machine=i386-ibm
;;
@@ -744,10 +812,22 @@ case $basic_machine in
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
sequent)
basic_machine=i386-sequent
;;
@@ -755,7 +835,7 @@ case $basic_machine in
basic_machine=sh-hitachi
os=-hms
;;
- sparclite-wrs)
+ sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
@@ -821,10 +901,22 @@ case $basic_machine in
basic_machine=i386-sequent
os=-dynix
;;
+ t3d)
+ basic_machine=alpha-cray
+ os=-unicos
+ ;;
t3e)
- basic_machine=t3e-cray
+ basic_machine=alphaev5-cray
os=-unicos
;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic4x | c4x*)
+ basic_machine=tic4x-unknown
+ os=-coff
+ ;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
@@ -835,6 +927,10 @@ case $basic_machine in
tx39el)
basic_machine=mipstx39el-unknown
;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
tower | tower-32)
basic_machine=m68k-ncr
;;
@@ -859,8 +955,8 @@ case $basic_machine in
os=-vms
;;
vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
- ;;
+ basic_machine=f301-fujitsu
+ ;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
@@ -881,13 +977,13 @@ case $basic_machine in
basic_machine=hppa1.1-winbond
os=-proelf
;;
- xmp)
- basic_machine=xmp-cray
- os=-unicos
- ;;
- xps | xps100)
+ xps | xps100)
basic_machine=xps100-honeywell
;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
@@ -908,13 +1004,6 @@ case $basic_machine in
op60c)
basic_machine=hppa1.1-oki
;;
- mips)
- if [ x$os = x-linux-gnu ]; then
- basic_machine=mips-unknown
- else
- basic_machine=mips-mips
- fi
- ;;
romp)
basic_machine=romp-ibm
;;
@@ -934,13 +1023,16 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
- sh3 | sh4)
+ sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele)
basic_machine=sh-unknown
;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun
;;
- cydra)
+ cydra)
basic_machine=cydra-cydrome
;;
orion)
@@ -955,10 +1047,6 @@ case $basic_machine in
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
- c4x*)
- basic_machine=c4x-none
- os=-coff
- ;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
@@ -1018,11 +1106,15 @@ case $os in
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
- | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*)
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1034,8 +1126,10 @@ case $os in
;;
esac
;;
+ -nto-qnx*)
+ ;;
-nto*)
- os=-nto-qnx
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \
@@ -1074,14 +1168,20 @@ case $os in
-acis*)
os=-aos
;;
+ -atheos*)
+ os=-atheos
+ ;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
-ns2 )
- os=-nextstep2
+ os=-nextstep2
;;
-nsk*)
os=-nsk
@@ -1120,8 +1220,8 @@ case $os in
-xenix)
os=-xenix
;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- os=-mint
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
;;
-none)
;;
@@ -1154,10 +1254,11 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
+ # This must come before the *-dec entry.
pdp10-*)
os=-tops20
;;
- pdp11-*)
+ pdp11-*)
os=-none
;;
*-dec | vax-*)
@@ -1184,6 +1285,9 @@ case $basic_machine in
mips*-*)
os=-elf
;;
+ or32-*)
+ os=-coff
+ ;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
@@ -1247,19 +1351,19 @@ case $basic_machine in
*-next)
os=-nextstep3
;;
- *-gould)
+ *-gould)
os=-sysv
;;
- *-highlevel)
+ *-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
- *-sgi)
+ *-sgi)
os=-irix
;;
- *-siemens)
+ *-siemens)
os=-sysv4
;;
*-masscomp)
@@ -1331,7 +1435,7 @@ case $basic_machine in
-ptx*)
vendor=sequent
;;
- -vxsim* | -vxworks*)
+ -vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
-aux*)
@@ -1346,6 +1450,9 @@ case $basic_machine in
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
+ -vos*)
+ vendor=stratus
+ ;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
diff --git a/configure b/configure
index 6fb9fdf..d5fad7f 100755
--- a/configure
+++ b/configure
@@ -1,11 +1,244 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by Autoconf 2.50.
+# Generated by GNU Autoconf 2.57.
#
-# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
# Find the correct PATH separator. Usually this is `:', but
# DJGPP uses `;' like DOS.
@@ -17,6 +250,7 @@ if test "X${PATH_SEPARATOR+set}" != Xset; then
esac
fi
+
# Check that we are running under the correct shell.
SHELL=${CONFIG_SHELL-/bin/sh}
@@ -162,68 +396,7 @@ if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
fi
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-
-# Name of the executable.
-as_me=`echo "$0" |sed 's,.*[\\/],,'`
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-as_executable_p="test -f"
-
-# Support unset when possible.
-if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-# NLS nuisances.
-$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
-$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
-$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
-$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
-$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
-$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
-$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
-$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
# Name of the host.
# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
@@ -236,9 +409,11 @@ exec 6>&1
# Initializations.
#
ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
cross_compiling=no
subdirs=
-MFLAGS= MAKEFLAGS=
+MFLAGS=
+MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
@@ -246,22 +421,23 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# only ac_max_sed_lines should be used.
: ${ac_max_here_lines=38}
-# Avoid depending upon Character Ranges.
-ac_cr_az='abcdefghijklmnopqrstuvwxyz'
-ac_cr_AZ='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-ac_cr_09='0123456789'
-ac_cr_alnum=$ac_cr_az$ac_cr_AZ$ac_cr_09
-
-# Sed expression to map a string onto a valid sh and CPP variable names.
-ac_tr_sh="sed y%*+%pp%;s%[^_$ac_cr_alnum]%_%g"
-ac_tr_cpp="sed y%*$ac_cr_az%P$ac_cr_AZ%;s%[^_$ac_cr_alnum]%_%g"
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
ac_unique_file="dftables.c"
# Factoring default headers for most tests.
ac_includes_default="\
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
@@ -275,18 +451,24 @@ ac_includes_default="\
# include <memory.h>
# endif
# include <string.h>
-#else
-# if HAVE_STRINGS_H
-# include <strings.h>
-# endif
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif"
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CPP EGREP LIBTOOL HAVE_MEMMOVE HAVE_STRERROR HOST_CC HOST_CFLAGS NEWLINE LINK_SIZE MATCH_LIMIT UTF8 PCRE_MAJOR PCRE_MINOR PCRE_DATE PCRE_VERSION PCRE_LIB_VERSION PCRE_POSIXLIB_VERSION POSIX_MALLOC_THRESHOLD POSIX_OBJ POSIX_LOBJ POSIX_LIB LIBOBJS LTLIBOBJS'
+ac_subst_files=''
+
# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
@@ -325,13 +507,6 @@ oldincludedir='/usr/include'
infodir='${prefix}/info'
mandir='${prefix}/man'
-# Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
-
ac_prev=
for ac_option
do
@@ -377,7 +552,7 @@ do
-disable-* | --disable-*)
ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
# Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$ac_cr_alnum]" >/dev/null &&
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid feature name: $ac_feature" >&2
{ (exit 1); exit 1; }; }
ac_feature=`echo $ac_feature | sed 's/-/_/g'`
@@ -386,7 +561,7 @@ do
-enable-* | --enable-*)
ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
# Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$ac_cr_alnum]" >/dev/null &&
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid feature name: $ac_feature" >&2
{ (exit 1); exit 1; }; }
ac_feature=`echo $ac_feature | sed 's/-/_/g'`
@@ -464,7 +639,7 @@ do
with_fp=no ;;
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c)
+ | --no-cr | --no-c | -n)
no_create=yes ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
@@ -568,7 +743,7 @@ do
-with-* | --with-*)
ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$ac_cr_alnum]" >/dev/null &&
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid package name: $ac_package" >&2
{ (exit 1); exit 1; }; }
ac_package=`echo $ac_package| sed 's/-/_/g'`
@@ -581,7 +756,7 @@ do
-without-* | --without-*)
ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
# Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$ac_cr_alnum]" >/dev/null &&
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid package name: $ac_package" >&2
{ (exit 1); exit 1; }; }
ac_package=`echo $ac_package | sed 's/-/_/g'`
@@ -613,7 +788,7 @@ Try \`$0 --help' for more information." >&2
*=*)
ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
# Reject names that are not valid shell variable names.
- expr "x$ac_envvar" : ".*[^_$ac_cr_alnum]" >/dev/null &&
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid variable name: $ac_envvar" >&2
{ (exit 1); exit 1; }; }
ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
@@ -623,7 +798,7 @@ Try \`$0 --help' for more information." >&2
*)
# FIXME: should be removed in autoconf 3.0.
echo "$as_me: WARNING: you should use --build, --host, --target" >&2
- expr "x$ac_option" : ".*[^-._$ac_cr_alnum]" >/dev/null &&
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
echo "$as_me: WARNING: invalid host type: $ac_option" >&2
: ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
;;
@@ -638,26 +813,36 @@ if test -n "$ac_prev"; then
fi
# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# Be sure to have absolute paths.
for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
- localstatedir libdir includedir oldincludedir infodir mandir \
- exec_prefix prefix
+ localstatedir libdir includedir oldincludedir infodir mandir
do
eval ac_val=$`echo $ac_var`
case $ac_val in
[\\/$]* | ?:[\\/]* ) ;;
- NONE ) ;;
- *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
{ (exit 1); exit 1; }; };;
esac
done
# There might be people who depend on the old broken behavior: `$host'
# used to hold the argument of --host etc.
+# FIXME: To remove some day.
build=$build_alias
host=$host_alias
target=$target_alias
-# FIXME: should be removed in autoconf 3.0.
+# FIXME: To remove some day.
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
@@ -673,13 +858,23 @@ test -n "$host_alias" && ac_tool_prefix=$host_alias-
test "$silent" = yes && exec 6>/dev/null
+
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
ac_srcdir_defaulted=yes
# Try the directory containing this script, then its parent.
- ac_prog=$0
- ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$0" : 'X\(//\)[^/]' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
srcdir=$ac_confdir
if test ! -r $srcdir/$ac_unique_file; then
srcdir=..
@@ -689,13 +884,16 @@ else
fi
if test ! -r $srcdir/$ac_unique_file; then
if test "$ac_srcdir_defaulted" = yes; then
- { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
{ (exit 1); exit 1; }; }
else
- { echo "$as_me: error: cannot find sources in $srcdir" >&2
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
{ (exit 1); exit 1; }; }
fi
fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+ { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+ { (exit 1); exit 1; }; }
srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
ac_env_build_alias_set=${build_alias+set}
ac_env_build_alias_value=$build_alias
@@ -738,8 +936,17 @@ if test "$ac_init_help" = "long"; then
# The list generated by autoconf has been trimmed to remove many
# options that are totally irrelevant to PCRE (e.g. relating to X),
# or are not supported by its Makefile.
+ # The list generated by autoconf has been trimmed to remove many
+ # options that are totally irrelevant to PCRE (e.g. relating to X),
+ # or are not supported by its Makefile.
+ # The list generated by autoconf has been trimmed to remove many
+ # options that are totally irrelevant to PCRE (e.g. relating to X),
+ # or are not supported by its Makefile.
+ # The list generated by autoconf has been trimmed to remove many
+ # options that are totally irrelevant to PCRE (e.g. relating to X),
+ # or are not supported by its Makefile.
# This message is too long to be a string in the A/UX 3.1 sh.
- cat <<EOF
+ cat <<_ACEOF
\`configure' configures this package to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -760,9 +967,9 @@ Configuration:
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or \`..']
-EOF
+_ACEOF
- cat <<EOF
+ cat <<_ACEOF
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
@@ -781,31 +988,34 @@ Fine tuning of the installation directories:
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--mandir=DIR man documentation [PREFIX/man]
-EOF
+_ACEOF
- cat <<\EOF
+ cat <<\_ACEOF
-EOF
+_ACEOF
fi
if test -n "$ac_init_help"; then
- cat <<\EOF
+ cat <<\_ACEOF
Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --enable-utf8 enable UTF8 support (incomplete)
- --enable-newline-is-cr use CR as the newline character
- --enable-newline-is-lf use LF as the newline character
--enable-shared build shared libraries default=yes
--enable-static build static libraries default=yes
--enable-fast-install optimize for fast installation default=yes
--disable-libtool-lock avoid locking (might break parallel builds)
+ --enable-utf8 enable UTF8 support
+ --enable-newline-is-cr use CR as the newline character
+ --enable-newline-is-lf use LF as the newline character
Optional Packages:
--with-gnu-ld assume the C compiler uses GNU ld default=no
--with-pic try to use only PIC/non-PIC objects default=use both
+ --with-posix-malloc-threshold=5 threshold for POSIX malloc usage
+ --with-link-size=2 internal link size (2, 3, or 4 allowed)
+ --with-match-limit=10000000 default limit on internal looping)
Some influential environment variables:
CC C compiler command
@@ -819,40 +1029,60 @@ Some influential environment variables:
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
-EOF
+_ACEOF
fi
if test "$ac_init_help" = "recursive"; then
# If there are subdirs, report their specific --help.
ac_popdir=`pwd`
- for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue
- cd $ac_subdir
- # A "../" for each directory in /$ac_subdir.
- ac_dots=`echo $ac_subdir |
- sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'`
-
- case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_sub_srcdir=$srcdir ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_sub_srcdir=$srcdir/$ac_subdir ;;
- *) # Relative path.
- ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;;
- esac
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d $ac_dir || continue
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+ cd $ac_dir
# Check for guested configure; otherwise get Cygnus style configure.
- if test -f $ac_sub_srcdir/configure.gnu; then
+ if test -f $ac_srcdir/configure.gnu; then
echo
- $SHELL $ac_sub_srcdir/configure.gnu --help=recursive
- elif test -f $ac_sub_srcdir/configure; then
+ $SHELL $ac_srcdir/configure.gnu --help=recursive
+ elif test -f $ac_srcdir/configure; then
echo
- $SHELL $ac_sub_srcdir/configure --help=recursive
- elif test -f $ac_sub_srcdir/configure.ac ||
- test -f $ac_sub_srcdir/configure.in; then
+ $SHELL $ac_srcdir/configure --help=recursive
+ elif test -f $ac_srcdir/configure.ac ||
+ test -f $ac_srcdir/configure.in; then
echo
$ac_configure --help
else
- echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2
+ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
fi
cd $ac_popdir
done
@@ -860,31 +1090,31 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
- cat <<\EOF
+ cat <<\_ACEOF
-Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
-EOF
+_ACEOF
exit 0
fi
exec 5>config.log
-cat >&5 <<EOF
+cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by $as_me, which was
-generated by GNU Autoconf 2.50. Invocation command line was
+generated by GNU Autoconf 2.57. Invocation command line was
$ $0 $@
-EOF
+_ACEOF
{
cat <<_ASUNAME
-## ---------- ##
-## Platform. ##
-## ---------- ##
+## --------- ##
+## Platform. ##
+## --------- ##
hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
@@ -903,83 +1133,160 @@ hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
-PATH = $PATH
-
_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ echo "PATH: $as_dir"
+done
+
} >&5
-cat >&5 <<EOF
-## ------------ ##
-## Core tests. ##
-## ------------ ##
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
-EOF
# Keep a trace of the command line.
# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
ac_sep=
-for ac_arg
+ac_must_keep_next=false
+for ac_pass in 1 2
do
- case $ac_arg in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
- ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
- ac_sep=" " ;;
- *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg"
- ac_sep=" " ;;
- esac
- # Get rid of the leading space.
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+ # Get rid of the leading space.
+ ac_sep=" "
+ ;;
+ esac
+ done
done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
# When interrupted or exit'd, cleanup temporary files, and complete
# config.log. We remove comments because anyway the quotes in there
# would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
trap 'exit_status=$?
# Save into config.log some information that might help in debugging.
- echo >&5
- echo "## ----------------- ##" >&5
- echo "## Cache variables. ##" >&5
- echo "## ----------------- ##" >&5
- echo >&5
- # The following way of writing the cache mishandles newlines in values,
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
{
(set) 2>&1 |
case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
*ac_space=\ *)
sed -n \
"s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
- s/^\\([_$ac_cr_alnum]*_cv_[_$ac_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
;;
*)
sed -n \
- "s/^\\([_$ac_cr_alnum]*_cv_[_$ac_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
;;
esac;
-} >&5
- sed "/^$/d" confdefs.h >conftest.log
- if test -s conftest.log; then
- echo >&5
- echo "## ------------ ##" >&5
- echo "## confdefs.h. ##" >&5
- echo "## ------------ ##" >&5
- echo >&5
- cat conftest.log >&5
- fi
- (echo; echo) >&5
- test "$ac_signal" != 0 &&
- echo "$as_me: caught signal $ac_signal" >&5
- echo "$as_me: exit $exit_status" >&5
- rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files &&
+}
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ sed "/^$/d" confdefs.h | sort
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ echo "$as_me: caught signal $ac_signal"
+ echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core core.* *.core &&
+ rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
exit $exit_status
' 0
for ac_signal in 1 2 13 15; do
- trap 'ac_status=$?; ac_signal='$ac_signal'; { (exit $ac_status); exit $ac_status; }' $ac_signal
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
done
ac_signal=0
@@ -988,6 +1295,33 @@ rm -rf conftest* confdefs.h
# AIX cpp loses on an empty file, so make sure it contains at least a newline.
echo >confdefs.h
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
# Let the site file select an alternate cache file if it wants to.
# Prefer explicitly selected file to automatically selected ones.
if test -z "$CONFIG_SITE"; then
@@ -999,9 +1333,9 @@ if test -z "$CONFIG_SITE"; then
fi
for ac_site_file in $CONFIG_SITE; do
if test -r "$ac_site_file"; then
- { echo "$as_me:1012: loading site script $ac_site_file" >&5
+ { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
echo "$as_me: loading site script $ac_site_file" >&6;}
- cat "$ac_site_file" >&5
+ sed 's/^/| /' "$ac_site_file" >&5
. "$ac_site_file"
fi
done
@@ -1010,7 +1344,7 @@ if test -r "$cache_file"; then
# Some versions of bash will fail to source /dev/null (special
# files actually), so we avoid doing that.
if test -f "$cache_file"; then
- { echo "$as_me:1023: loading cache $cache_file" >&5
+ { echo "$as_me:$LINENO: loading cache $cache_file" >&5
echo "$as_me: loading cache $cache_file" >&6;}
case $cache_file in
[\\/]* | ?:[\\/]* ) . $cache_file;;
@@ -1018,14 +1352,14 @@ echo "$as_me: loading cache $cache_file" >&6;}
esac
fi
else
- { echo "$as_me:1031: creating cache $cache_file" >&5
+ { echo "$as_me:$LINENO: creating cache $cache_file" >&5
echo "$as_me: creating cache $cache_file" >&6;}
>$cache_file
fi
# Check that the precious variables saved in the cache have kept the same
# value.
-ac_suggest_removing_cache=false
+ac_cache_corrupted=false
for ac_var in `(set) 2>&1 |
sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
eval ac_old_set=\$ac_cv_env_${ac_var}_set
@@ -1034,31 +1368,44 @@ for ac_var in `(set) 2>&1 |
eval ac_new_val="\$ac_env_${ac_var}_value"
case $ac_old_set,$ac_new_set in
set,)
- { echo "$as_me:1047: WARNING: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-echo "$as_me: WARNING: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
- ac_suggest_removing_cache=: ;;
+ { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
,set)
- { echo "$as_me:1051: WARNING: \`$ac_var' was not set in the previous run" >&5
-echo "$as_me: WARNING: \`$ac_var' was not set in the previous run" >&2;}
- ac_suggest_removing_cache=: ;;
+ { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
,);;
*)
if test "x$ac_old_val" != "x$ac_new_val"; then
- { echo "$as_me:1057: WARNING: \`$ac_var' has changed since the previous run:" >&5
-echo "$as_me: WARNING: \`$ac_var' has changed since the previous run:" >&2;}
- { echo "$as_me:1059: WARNING: former value: $ac_old_val" >&5
-echo "$as_me: WARNING: former value: $ac_old_val" >&2;}
- { echo "$as_me:1061: WARNING: current value: $ac_new_val" >&5
-echo "$as_me: WARNING: current value: $ac_new_val" >&2;}
- ac_suggest_removing_cache=:
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+echo "$as_me: former value: $ac_old_val" >&2;}
+ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
+echo "$as_me: current value: $ac_new_val" >&2;}
+ ac_cache_corrupted=:
fi;;
esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
done
-if $ac_suggest_removing_cache; then
- { echo "$as_me:1068: WARNING: changes in the environment can compromise the build" >&5
-echo "$as_me: WARNING: changes in the environment can compromise the build" >&2;}
- { echo "$as_me:1070: WARNING: consider removing $cache_file and starting over" >&5
-echo "$as_me: WARNING: consider removing $cache_file and starting over" >&2;}
+if $ac_cache_corrupted; then
+ { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
fi
ac_ext=c
@@ -1067,37 +1414,44 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-echo "#! $SHELL" >conftest.sh
-echo "exit 0" >>conftest.sh
-chmod +x conftest.sh
-if { (echo "$as_me:1089: PATH=\".;.\"; conftest.sh") >&5
- (PATH=".;."; conftest.sh) 2>&5
- ac_status=$?
- echo "$as_me:1092: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- ac_path_separator=';'
-else
- ac_path_separator=:
-fi
-PATH_SEPARATOR="$ac_path_separator"
-rm -f conftest.sh
-ac_config_headers="$ac_config_headers config.h:config.in"
-PCRE_MAJOR=3
-PCRE_MINOR=9
-PCRE_DATE=02-Jan-2002
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ac_config_headers="$ac_config_headers config.h:config.in"
+
+
+
+PCRE_MAJOR=4
+PCRE_MINOR=0
+PCRE_DATE=17-Feb-2003
PCRE_VERSION=${PCRE_MAJOR}.${PCRE_MINOR}
+
+POSIX_MALLOC_THRESHOLD=-DPOSIX_MALLOC_THRESHOLD=10
+HOST_CC=${HOST_CC:-'$(CC)'}
+HOST_CFLAGS=${HOST_CFLAGS:-'$(CFLAGS)'}
+
+
PCRE_LIB_VERSION=0:1:0
PCRE_POSIXLIB_VERSION=0:0:0
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -1106,7 +1460,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:1119: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1114,25 +1468,28 @@ else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_CC="${ac_tool_prefix}gcc"
-echo "$as_me:1134: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
- echo "$as_me:1142: result: $CC" >&5
+ echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
- echo "$as_me:1145: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -1141,7 +1498,7 @@ if test -z "$ac_cv_prog_CC"; then
ac_ct_CC=$CC
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
-echo "$as_me:1154: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1149,25 +1506,28 @@ else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_CC="gcc"
-echo "$as_me:1169: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
- echo "$as_me:1177: result: $ac_ct_CC" >&5
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
- echo "$as_me:1180: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -1180,7 +1540,7 @@ if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:1193: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1188,25 +1548,28 @@ else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_CC="${ac_tool_prefix}cc"
-echo "$as_me:1208: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
- echo "$as_me:1216: result: $CC" >&5
+ echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
- echo "$as_me:1219: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -1215,7 +1578,7 @@ if test -z "$ac_cv_prog_CC"; then
ac_ct_CC=$CC
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
-echo "$as_me:1228: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1223,25 +1586,28 @@ else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_CC="cc"
-echo "$as_me:1243: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
- echo "$as_me:1251: result: $ac_ct_CC" >&5
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
- echo "$as_me:1254: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -1254,7 +1620,7 @@ fi
if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
-echo "$as_me:1267: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1263,19 +1629,22 @@ else
ac_cv_prog_CC="$CC" # Let the user override the test.
else
ac_prog_rejected=no
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
-fi
-ac_cv_prog_CC="cc"
-echo "$as_me:1287: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
if test $ac_prog_rejected = yes; then
@@ -1287,19 +1656,17 @@ if test $ac_prog_rejected = yes; then
# However, it has the same basename, so the bogon will be chosen
# first if we set CC to just the basename; use the full file name.
shift
- set dummy "$ac_dir/$ac_word" ${1+"$@"}
- shift
- ac_cv_prog_CC="$@"
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
fi
fi
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
- echo "$as_me:1309: result: $CC" >&5
+ echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
- echo "$as_me:1312: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -1310,7 +1677,7 @@ if test -z "$CC"; then
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:1323: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1318,25 +1685,28 @@ else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-echo "$as_me:1338: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
- echo "$as_me:1346: result: $CC" >&5
+ echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
- echo "$as_me:1349: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -1349,7 +1719,7 @@ if test -z "$CC"; then
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
-echo "$as_me:1362: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1357,25 +1727,28 @@ else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_CC="$ac_prog"
-echo "$as_me:1377: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
- echo "$as_me:1385: result: $ac_ct_CC" >&5
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
- echo "$as_me:1388: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -1387,13 +1760,40 @@ fi
fi
-test -z "$CC" && { { echo "$as_me:1400: error: no acceptable cc found in \$PATH" >&5
-echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+ "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+ (eval $ac_compiler --version </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+ (eval $ac_compiler -v </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+ (eval $ac_compiler -V </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
cat >conftest.$ac_ext <<_ACEOF
-#line 1405 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
int
main ()
@@ -1404,94 +1804,120 @@ main ()
}
_ACEOF
ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe"
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compiler, and finding out an intuition
+# It will help us diagnose broken compilers, and finding out an intuition
# of exeext.
-echo "$as_me:1421: checking for C compiler default output" >&5
+echo "$as_me:$LINENO: checking for C compiler default output" >&5
echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:1424: \"$ac_link_default\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
(eval $ac_link_default) 2>&5
ac_status=$?
- echo "$as_me:1427: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
- for ac_file in `ls a.exe conftest.exe a.* conftest conftest.* 2>/dev/null`; do
+ # Find the output, starting from the most likely. This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+ test -f "$ac_file" || continue
case $ac_file in
- *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
- a.out ) # We found the default executable, but exeext='' is most
- # certainly right.
- break;;
- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- export ac_cv_exeext
- break;;
- * ) break;;
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+ ;;
+ conftest.$ac_ext )
+ # This is the source file.
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ # FIXME: I believe we export ac_cv_exeext for Libtool,
+ # but it would be cool to find out if it's true. Does anybody
+ # maintain Libtool? --akim.
+ export ac_cv_exeext
+ break;;
+ * )
+ break;;
esac
done
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-{ { echo "$as_me:1444: error: C compiler cannot create executables" >&5
-echo "$as_me: error: C compiler cannot create executables" >&2;}
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
{ (exit 77); exit 77; }; }
fi
ac_exeext=$ac_cv_exeext
-echo "$as_me:1450: result: $ac_file" >&5
+echo "$as_me:$LINENO: result: $ac_file" >&5
echo "${ECHO_T}$ac_file" >&6
# Check the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
-echo "$as_me:1455: checking whether the C compiler works" >&5
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
# If not cross compiling, check that we can run a simple program.
if test "$cross_compiling" != yes; then
if { ac_try='./$ac_file'
- { (eval echo "$as_me:1461: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:1464: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
cross_compiling=no
else
if test "$cross_compiling" = maybe; then
cross_compiling=yes
else
- { { echo "$as_me:1471: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'." >&5
+ { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
echo "$as_me: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'." >&2;}
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
fi
fi
-echo "$as_me:1479: result: yes" >&5
+echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
-rm -f a.out a.exe conftest$ac_cv_exeext
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
# Check the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
-echo "$as_me:1486: checking whether we are cross compiling" >&5
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:1488: result: $cross_compiling" >&5
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
echo "${ECHO_T}$cross_compiling" >&6
-echo "$as_me:1491: checking for executable suffix" >&5
-echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
-if { (eval echo "$as_me:1493: \"$ac_link\"") >&5
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:1496: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
# If both `conftest.exe' and `conftest' are `present' (well, observable)
# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
# work properly (i.e., refer to `conftest.exe'), while it won't with
# `rm'.
-for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
case $ac_file in
- *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
*.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
export ac_cv_exeext
break;;
@@ -1499,26 +1925,32 @@ for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
esac
done
else
- { { echo "$as_me:1512: error: cannot compute EXEEXT: cannot compile and link" >&5
-echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
+ { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
rm -f conftest$ac_cv_exeext
-echo "$as_me:1518: result: $ac_cv_exeext" >&5
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
echo "${ECHO_T}$ac_cv_exeext" >&6
rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
-echo "$as_me:1524: checking for object suffix" >&5
-echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
if test "${ac_cv_objext+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
-#line 1530 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
int
main ()
@@ -1529,40 +1961,47 @@ main ()
}
_ACEOF
rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:1542: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:1545: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;;
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
*) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
break;;
esac
done
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-{ { echo "$as_me:1557: error: cannot compute OBJEXT: cannot compile" >&5
-echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
-echo "$as_me:1564: result: $ac_cv_objext" >&5
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
echo "${ECHO_T}$ac_cv_objext" >&6
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
-echo "$as_me:1568: checking whether we are using the GNU C compiler" >&5
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
if test "${ac_cv_c_compiler_gnu+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
-#line 1574 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
int
main ()
@@ -1576,41 +2015,46 @@ main ()
}
_ACEOF
rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1589: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:1592: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:1595: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:1598: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_compiler_gnu=yes
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
ac_compiler_gnu=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu
fi
-echo "$as_me:1610: result: $ac_cv_c_compiler_gnu" >&5
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
GCC=`test $ac_compiler_gnu = yes && echo yes`
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
CFLAGS="-g"
-echo "$as_me:1616: checking whether $CC accepts -g" >&5
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
if test "${ac_cv_prog_cc_g+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
-#line 1622 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
int
main ()
@@ -1621,26 +2065,27 @@ main ()
}
_ACEOF
rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1634: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:1637: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:1640: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:1643: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_prog_cc_g=yes
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
ac_cv_prog_cc_g=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
-echo "$as_me:1653: result: $ac_cv_prog_cc_g" >&5
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
if test "$ac_test_CFLAGS" = set; then
CFLAGS=$ac_save_CFLAGS
@@ -1657,6 +2102,102 @@ else
CFLAGS=
fi
fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX -qlanglvl=ansi
+# Ultrix and OSF/1 -std1
+# HP-UX 10.20 and later -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+ x|xno)
+ echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+ *)
+ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+ CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
# Some people use a C++ compiler to compile C. Since we use `exit',
# in C++ we need to declare it. In case someone uses the same compiler
# for both compiling C and C++ we need to have the C++ compiler decide
@@ -1667,16 +2208,16 @@ cat >conftest.$ac_ext <<_ACEOF
#endif
_ACEOF
rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1680: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:1683: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:1686: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:1689: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
for ac_declaration in \
''\
@@ -1688,8 +2229,12 @@ if { (eval echo "$as_me:1680: \"$ac_compile\"") >&5
'void exit (int);'
do
cat >conftest.$ac_ext <<_ACEOF
-#line 1701 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
#include <stdlib.h>
$ac_declaration
int
@@ -1701,27 +2246,32 @@ exit (42);
}
_ACEOF
rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1714: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:1717: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:1720: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:1723: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
:
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
continue
fi
rm -f conftest.$ac_objext conftest.$ac_ext
cat >conftest.$ac_ext <<_ACEOF
-#line 1733 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
$ac_declaration
int
main ()
@@ -1732,31 +2282,36 @@ exit (42);
}
_ACEOF
rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1745: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:1748: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:1751: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:1754: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
break
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
fi
rm -f conftest.$ac_objext conftest.$ac_ext
done
-echo '#ifdef __cplusplus' >>confdefs.h
-echo $ac_declaration >>confdefs.h
-echo '#endif' >>confdefs.h
+rm -f conftest*
+if test -n "$ac_declaration"; then
+ echo '#ifdef __cplusplus' >>confdefs.h
+ echo $ac_declaration >>confdefs.h
+ echo '#endif' >>confdefs.h
+fi
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
fi
rm -f conftest.$ac_objext conftest.$ac_ext
ac_ext=c
@@ -1782,7 +2337,7 @@ for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
fi
done
if test -z "$ac_aux_dir"; then
- { { echo "$as_me:1795: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+ { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
{ (exit 1); exit 1; }; }
fi
@@ -1802,43 +2357,48 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:1815: checking for a BSD compatible install" >&5
-echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
if test -z "$INSTALL"; then
if test "${ac_cv_path_install+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
- for ac_dir in $PATH; do
- IFS=$ac_save_IFS
- # Account for people who put trailing slashes in PATH elements.
- case $ac_dir/ in
- / | ./ | .// | /cC/* \
- | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \
- | /usr/ucb/* ) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- # Don't use installbsd from OSF since it installs stuff as root
- # by default.
- for ac_prog in ginstall scoinst install; do
- if $as_executable_p "$ac_dir/$ac_prog"; then
- if test $ac_prog = install &&
- grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- elif test $ac_prog = install &&
- grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then
- # program-specific install script used by HP pwplus--don't use.
- :
- else
- ac_cv_path_install="$ac_dir/$ac_prog -c"
- break 2
- fi
- fi
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+ ./ | .// | /cC/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
done
- ;;
- esac
- done
+ done
+ ;;
+esac
+done
+
fi
if test "${ac_cv_path_install+set}" = set; then
@@ -1851,7 +2411,7 @@ fi
INSTALL=$ac_install_sh
fi
fi
-echo "$as_me:1864: result: $INSTALL" >&5
+echo "$as_me:$LINENO: result: $INSTALL" >&5
echo "${ECHO_T}$INSTALL" >&6
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
@@ -1862,846 +2422,6 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:1878: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_RANLIB+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-echo "$as_me:1893: found $ac_dir/$ac_word" >&5
-break
-done
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
- echo "$as_me:1901: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6
-else
- echo "$as_me:1904: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
- ac_ct_RANLIB=$RANLIB
- # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo "$as_me:1913: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_RANLIB"; then
- ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_RANLIB="ranlib"
-echo "$as_me:1928: found $ac_dir/$ac_word" >&5
-break
-done
-
- test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
- echo "$as_me:1937: result: $ac_ct_RANLIB" >&5
-echo "${ECHO_T}$ac_ct_RANLIB" >&6
-else
- echo "$as_me:1940: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- RANLIB=$ac_ct_RANLIB
-else
- RANLIB="$ac_cv_prog_RANLIB"
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:1954: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
- if test "${ac_cv_prog_CPP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Double quotes because CPP needs to be expanded
- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
- do
- # break 2 since there is a loop in there.
- ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-#line 1976 "configure"
-#include "confdefs.h"
-#include <assert.h>
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:1981: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- egrep -v '^ *\+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:1987: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
- cat conftest.$ac_ext >&5
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-#line 2010 "configure"
-#include "confdefs.h"
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:2014: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- egrep -v '^ *\+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:2020: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
- cat conftest.$ac_ext >&5
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- break 2
-fi
-
- done
- ac_cv_prog_CPP=$CPP
-
-fi
- CPP=$ac_cv_prog_CPP
-else
- ac_cv_prog_CPP=$CPP
-fi
-echo "$as_me:2057: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-#line 2067 "configure"
-#include "confdefs.h"
-#include <assert.h>
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:2072: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- egrep -v '^ *\+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:2078: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
- cat conftest.$ac_ext >&5
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-#line 2101 "configure"
-#include "confdefs.h"
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:2105: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- egrep -v '^ *\+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:2111: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
- cat conftest.$ac_ext >&5
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- :
-else
- { { echo "$as_me:2139: error: C preprocessor \"$CPP\" fails sanity check" >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-echo "$as_me:2150: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-#line 2156 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-_ACEOF
-if { (eval echo "$as_me:2164: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- egrep -v '^ *\+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:2170: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_cv_header_stdc=yes
-else
- echo "$as_me: failed program was:" >&5
- cat conftest.$ac_ext >&5
- ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-#line 2192 "configure"
-#include "confdefs.h"
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "memchr" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-#line 2210 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "free" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then
- :
-else
- cat >conftest.$ac_ext <<_ACEOF
-#line 2231 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- exit(2);
- exit (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:2257: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:2260: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:2262: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:2265: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_header_stdc=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:2278: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
-
-for ac_header in limits.h
-do
-ac_ac_Header=`echo "ac_cv_header_$ac_header" | $ac_tr_sh`
-echo "$as_me:2291: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$ac_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-#line 2297 "configure"
-#include "confdefs.h"
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:2301: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- egrep -v '^ *\+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:2307: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- eval "$ac_ac_Header=yes"
-else
- echo "$as_me: failed program was:" >&5
- cat conftest.$ac_ext >&5
- eval "$ac_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_ext
-fi
-echo "$as_me:2326: result: `eval echo '${'$ac_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$ac_ac_Header'}'`" >&6
-if test `eval echo '${'$ac_ac_Header'}'` = yes; then
- cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $ac_tr_cpp` 1
-EOF
-
-fi
-done
-
-echo "$as_me:2336: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-#line 2344 "configure"
-#include "confdefs.h"
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX -qlanglvl=ansi
-# Ultrix and OSF/1 -std1
-# HP-UX 10.20 and later -Ae
-# HP-UX older versions -Aa -D_HPUX_SOURCE
-# SVR4 -Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2393: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:2396: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:2399: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:2402: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_stdc=$ac_arg
-break
-else
- echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
-
-fi
-
-case "x$ac_cv_prog_cc_stdc" in
- x|xno)
- echo "$as_me:2419: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
- *)
- echo "$as_me:2422: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
- CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-
-echo "$as_me:2427: checking for an ANSI C-conforming const" >&5
-echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
-if test "${ac_cv_c_const+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-#line 2433 "configure"
-#include "confdefs.h"
-
-int
-main ()
-{
-/* FIXME: Include the comments suggested by Paul. */
-#ifndef __cplusplus
- /* Ultrix mips cc rejects this. */
- typedef int charset[2];
- const charset x;
- /* SunOS 4.1.1 cc rejects this. */
- char const *const *ccp;
- char **p;
- /* NEC SVR4.0.2 mips cc rejects this. */
- struct point {int x, y;};
- static struct point const zero = {0,0};
- /* AIX XL C 1.02.0.0 rejects this.
- It does not let you subtract one const X* pointer from another in
- an arm of an if-expression whose if-part is not a constant
- expression */
- const char *g = "string";
- ccp = &g + (g ? g-g : 0);
- /* HPUX 7.0 cc rejects these. */
- ++ccp;
- p = (char**) ccp;
- ccp = (char const *const *) p;
- { /* SCO 3.2v4 cc rejects this. */
- char *t;
- char const *s = 0 ? (char *) 0 : (char const *) 0;
-
- *t++ = 0;
- }
- { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
- int x[] = {25, 17};
- const int *foo = &x[0];
- ++foo;
- }
- { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
- typedef const int *iptr;
- iptr p = 0;
- ++p;
- }
- { /* AIX XL C 1.02.0.0 rejects this saying
- "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
- struct s { int j; const int *ap[3]; };
- struct s *b; b->j = 5;
- }
- { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
- const int foo = 10;
- }
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2491: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:2494: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:2497: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:2500: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_c_const=yes
-else
- echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_c_const=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:2510: result: $ac_cv_c_const" >&5
-echo "${ECHO_T}$ac_cv_c_const" >&6
-if test $ac_cv_c_const = no; then
-
-cat >>confdefs.h <<\EOF
-#define const
-EOF
-
-fi
-
-for ac_header in stdlib.h string.h memory.h strings.h inttypes.h unistd.h
-do
-ac_ac_Header=`echo "ac_cv_header_$ac_header" | $ac_tr_sh`
-echo "$as_me:2523: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$ac_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-#line 2529 "configure"
-#include "confdefs.h"
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:2533: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- egrep -v '^ *\+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:2539: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- eval "$ac_ac_Header=yes"
-else
- echo "$as_me: failed program was:" >&5
- cat conftest.$ac_ext >&5
- eval "$ac_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_ext
-fi
-echo "$as_me:2558: result: `eval echo '${'$ac_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$ac_ac_Header'}'`" >&6
-if test `eval echo '${'$ac_ac_Header'}'` = yes; then
- cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $ac_tr_cpp` 1
-EOF
-
-fi
-done
-
-echo "$as_me:2568: checking for size_t" >&5
-echo $ECHO_N "checking for size_t... $ECHO_C" >&6
-if test "${ac_cv_type_size_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-#line 2574 "configure"
-#include "confdefs.h"
-$ac_includes_default
-int
-main ()
-{
-if ((size_t *) 0)
- return 0;
-if (sizeof (size_t))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2589: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:2592: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:2595: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:2598: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_size_t=yes
-else
- echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_type_size_t=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:2608: result: $ac_cv_type_size_t" >&5
-echo "${ECHO_T}$ac_cv_type_size_t" >&6
-if test $ac_cv_type_size_t = yes; then
- :
-else
-
-cat >>confdefs.h <<EOF
-#define size_t unsigned
-EOF
-
-fi
-
-for ac_func in bcopy memmove strerror
-do
-ac_ac_var=`echo "ac_cv_func_$ac_func" | $ac_tr_sh`
-echo "$as_me:2623: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$ac_ac_var+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-#line 2629 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func (); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char $ac_func ();
-char (*f) ();
-
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func;
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:2660: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:2663: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:2666: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:2669: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$ac_ac_var=yes"
-else
- echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$ac_ac_var=no"
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:2679: result: `eval echo '${'$ac_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$ac_ac_var'}'`" >&6
-if test `eval echo '${'$ac_ac_var'}'` = yes; then
- cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_func" | $ac_tr_cpp` 1
-EOF
-
-fi
-done
-
-# Check whether --enable-utf8 or --disable-utf8 was given.
-if test "${enable_utf8+set}" = set; then
- enableval="$enable_utf8"
- if test "$enableval" = "yes"; then
- UTF8=-DSUPPORT_UTF8
-fi
-
-fi;
-
-# Check whether --enable-newline-is-cr or --disable-newline-is-cr was given.
-if test "${enable_newline_is_cr+set}" = set; then
- enableval="$enable_newline_is_cr"
- if test "$enableval" = "yes"; then
- NEWLINE=-DNEWLINE=13
-fi
-
-fi;
-
-# Check whether --enable-newline-is-lf or --disable-newline-is-lf was given.
-if test "${enable_newline_is_lf+set}" = set; then
- enableval="$enable_newline_is_lf"
- if test "$enableval" = "yes"; then
- NEWLINE=-DNEWLINE=10
-fi
-
-fi;
# Check whether --enable-shared or --disable-shared was given.
if test "${enable_shared+set}" = set; then
@@ -2771,11 +2491,11 @@ else
fi;
# Make sure we can run config.sub.
$ac_config_sub sun4 >/dev/null 2>&1 ||
- { { echo "$as_me:2784: error: cannot run $ac_config_sub" >&5
+ { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
echo "$as_me: error: cannot run $ac_config_sub" >&2;}
{ (exit 1); exit 1; }; }
-echo "$as_me:2788: checking build system type" >&5
+echo "$as_me:$LINENO: checking build system type" >&5
echo $ECHO_N "checking build system type... $ECHO_C" >&6
if test "${ac_cv_build+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2784,23 +2504,24 @@ else
test -z "$ac_cv_build_alias" &&
ac_cv_build_alias=`$ac_config_guess`
test -z "$ac_cv_build_alias" &&
- { { echo "$as_me:2797: error: cannot guess build type; you must specify one" >&5
+ { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
{ (exit 1); exit 1; }; }
ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
- { { echo "$as_me:2801: error: $ac_config_sub $ac_cv_build_alias failed." >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;}
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
{ (exit 1); exit 1; }; }
fi
-echo "$as_me:2806: result: $ac_cv_build" >&5
+echo "$as_me:$LINENO: result: $ac_cv_build" >&5
echo "${ECHO_T}$ac_cv_build" >&6
build=$ac_cv_build
build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$as_me:2813: checking host system type" >&5
+
+echo "$as_me:$LINENO: checking host system type" >&5
echo $ECHO_N "checking host system type... $ECHO_C" >&6
if test "${ac_cv_host+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2809,18 +2530,20 @@ else
test -z "$ac_cv_host_alias" &&
ac_cv_host_alias=$ac_cv_build_alias
ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
- { { echo "$as_me:2822: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
{ (exit 1); exit 1; }; }
fi
-echo "$as_me:2827: result: $ac_cv_host" >&5
+echo "$as_me:$LINENO: result: $ac_cv_host" >&5
echo "${ECHO_T}$ac_cv_host" >&6
host=$ac_cv_host
host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
# Check whether --with-gnu-ld or --without-gnu-ld was given.
if test "${with_gnu_ld+set}" = set; then
withval="$with_gnu_ld"
@@ -2831,7 +2554,7 @@ fi;
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
- echo "$as_me:2844: checking for ld used by GCC" >&5
+ echo "$as_me:$LINENO: checking for ld used by GCC" >&5
echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6
case $host in
*-*-mingw*)
@@ -2861,10 +2584,10 @@ echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6
;;
esac
elif test "$with_gnu_ld" = yes; then
- echo "$as_me:2874: checking for GNU ld" >&5
+ echo "$as_me:$LINENO: checking for GNU ld" >&5
echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
else
- echo "$as_me:2877: checking for non-GNU ld" >&5
+ echo "$as_me:$LINENO: checking for non-GNU ld" >&5
echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
fi
if test "${lt_cv_path_LD+set}" = set; then
@@ -2894,16 +2617,16 @@ fi
LD="$lt_cv_path_LD"
if test -n "$LD"; then
- echo "$as_me:2907: result: $LD" >&5
+ echo "$as_me:$LINENO: result: $LD" >&5
echo "${ECHO_T}$LD" >&6
else
- echo "$as_me:2910: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
-test -z "$LD" && { { echo "$as_me:2913: error: no acceptable ld found in \$PATH" >&5
+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
{ (exit 1); exit 1; }; }
-echo "$as_me:2916: checking if the linker ($LD) is GNU ld" >&5
+echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
if test "${lt_cv_prog_gnu_ld+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2915,23 +2638,24 @@ else
lt_cv_prog_gnu_ld=no
fi
fi
-echo "$as_me:2928: result: $lt_cv_prog_gnu_ld" >&5
+echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
with_gnu_ld=$lt_cv_prog_gnu_ld
-echo "$as_me:2932: checking for $LD option to reload object files" >&5
+
+echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
if test "${lt_cv_ld_reload_flag+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
lt_cv_ld_reload_flag='-r'
fi
-echo "$as_me:2939: result: $lt_cv_ld_reload_flag" >&5
+echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
reload_flag=$lt_cv_ld_reload_flag
test -n "$reload_flag" && reload_flag=" $reload_flag"
-echo "$as_me:2944: checking for BSD-compatible nm" >&5
+echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
if test "${lt_cv_path_NM+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2967,21 +2691,21 @@ fi
fi
NM="$lt_cv_path_NM"
-echo "$as_me:2980: result: $NM" >&5
+echo "$as_me:$LINENO: result: $NM" >&5
echo "${ECHO_T}$NM" >&6
-echo "$as_me:2983: checking whether ln -s works" >&5
+echo "$as_me:$LINENO: checking whether ln -s works" >&5
echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
LN_S=$as_ln_s
if test "$LN_S" = "ln -s"; then
- echo "$as_me:2987: result: yes" >&5
+ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
else
- echo "$as_me:2990: result: no, using $LN_S" >&5
+ echo "$as_me:$LINENO: result: no, using $LN_S" >&5
echo "${ECHO_T}no, using $LN_S" >&6
fi
-echo "$as_me:2994: checking how to recognise dependant libraries" >&5
+echo "$as_me:$LINENO: checking how to recognise dependant libraries" >&5
echo $ECHO_N "checking how to recognise dependant libraries... $ECHO_C" >&6
if test "${lt_cv_deplibs_check_method+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3149,13 +2873,20 @@ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
esac
fi
-echo "$as_me:3162: result: $lt_cv_deplibs_check_method" >&5
+echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6
file_magic_cmd=$lt_cv_file_magic_cmd
deplibs_check_method=$lt_cv_deplibs_check_method
+
+
+
+
+
+
+
# Check for command to grab the raw symbol name followed by C symbol from nm.
-echo "$as_me:3168: checking command to parse $NM output" >&5
+echo "$as_me:$LINENO: checking command to parse $NM output" >&5
echo $ECHO_N "checking command to parse $NM output... $ECHO_C" >&6
if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3232,17 +2963,17 @@ void nm_test_func(){}
int main(){nm_test_var='a';nm_test_func();return(0);}
EOF
- if { (eval echo "$as_me:3245: \"$ac_compile\"") >&5
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:3248: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
# Now try to grab the symbols.
nlist=conftest.nm
- if { (eval echo "$as_me:3252: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
+ if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
(eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
ac_status=$?
- echo "$as_me:3255: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && test -s "$nlist"; then
# Try sorting and uniquifying the output.
if sort "$nlist" | uniq > "$nlist"T; then
@@ -3294,10 +3025,10 @@ EOF
save_CFLAGS="$CFLAGS"
LIBS="conftstm.$ac_objext"
CFLAGS="$CFLAGS$no_builtin_flag"
- if { (eval echo "$as_me:3307: \"$ac_link\"") >&5
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:3310: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && test -s conftest; then
pipe_works=yes
fi
@@ -3335,33 +3066,554 @@ else
global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl"
fi
if test -z "$global_symbol_pipe$global_symbol_to_cdecl"; then
- echo "$as_me:3348: result: failed" >&5
+ echo "$as_me:$LINENO: result: failed" >&5
echo "${ECHO_T}failed" >&6
else
- echo "$as_me:3351: result: ok" >&5
+ echo "$as_me:$LINENO: result: ok" >&5
echo "${ECHO_T}ok" >&6
fi
-for ac_header in dlfcn.h
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
do
-ac_ac_Header=`echo "ac_cv_header_$ac_header" | $ac_tr_sh`
-echo "$as_me:3358: checking for $ac_header" >&5
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+ then ac_cv_prog_egrep='grep -E'
+ else ac_cv_prog_egrep='egrep'
+ fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_stdc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+ exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$ac_ac_Header+set}\" = set"; then
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
-#line 3364 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
#include <$ac_header>
_ACEOF
-if { (eval echo "$as_me:3368: \"$ac_cpp conftest.$ac_ext\"") >&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+for ac_header in dlfcn.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
- egrep -v '^ *\+' conftest.er1 >conftest.err
+ grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
- echo "$as_me:3374: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
@@ -3372,29 +3624,79 @@ else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
- eval "$ac_ac_Header=yes"
+ ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
- cat conftest.$ac_ext >&5
- eval "$ac_ac_Header=no"
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+ yes:no )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+ no:yes )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=$ac_header_preproc"
fi
-echo "$as_me:3393: result: `eval echo '${'$ac_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$ac_ac_Header'}'`" >&6
-if test `eval echo '${'$ac_ac_Header'}'` = yes; then
- cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $ac_tr_cpp` 1
-EOF
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
fi
+
done
+
+
+
+
# Only perform the check for file, if the check method requires it
case $deplibs_check_method in
file_magic*)
if test "$file_magic_cmd" = '$MAGIC_CMD'; then
- echo "$as_me:3407: checking for ${ac_tool_prefix}file" >&5
+ echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3449,16 +3751,16 @@ fi
MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
if test -n "$MAGIC_CMD"; then
- echo "$as_me:3462: result: $MAGIC_CMD" >&5
+ echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
echo "${ECHO_T}$MAGIC_CMD" >&6
else
- echo "$as_me:3465: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
if test -z "$lt_cv_path_MAGIC_CMD"; then
if test -n "$ac_tool_prefix"; then
- echo "$as_me:3471: checking for file" >&5
+ echo "$as_me:$LINENO: checking for file" >&5
echo $ECHO_N "checking for file... $ECHO_C" >&6
if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3513,10 +3815,10 @@ fi
MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
if test -n "$MAGIC_CMD"; then
- echo "$as_me:3526: result: $MAGIC_CMD" >&5
+ echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
echo "${ECHO_T}$MAGIC_CMD" >&6
else
- echo "$as_me:3529: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -3532,7 +3834,7 @@ esac
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:3545: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_RANLIB+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3540,25 +3842,28 @@ else
if test -n "$RANLIB"; then
ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-echo "$as_me:3560: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
fi
fi
RANLIB=$ac_cv_prog_RANLIB
if test -n "$RANLIB"; then
- echo "$as_me:3568: result: $RANLIB" >&5
+ echo "$as_me:$LINENO: result: $RANLIB" >&5
echo "${ECHO_T}$RANLIB" >&6
else
- echo "$as_me:3571: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -3567,7 +3872,7 @@ if test -z "$ac_cv_prog_RANLIB"; then
ac_ct_RANLIB=$RANLIB
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
-echo "$as_me:3580: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3575,15 +3880,18 @@ else
if test -n "$ac_ct_RANLIB"; then
ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_RANLIB="ranlib"
-echo "$as_me:3595: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
@@ -3591,10 +3899,10 @@ fi
fi
ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
if test -n "$ac_ct_RANLIB"; then
- echo "$as_me:3604: result: $ac_ct_RANLIB" >&5
+ echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
echo "${ECHO_T}$ac_ct_RANLIB" >&6
else
- echo "$as_me:3607: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -3606,7 +3914,7 @@ fi
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
set dummy ${ac_tool_prefix}strip; ac_word=$2
-echo "$as_me:3619: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_STRIP+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3614,25 +3922,28 @@ else
if test -n "$STRIP"; then
ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_STRIP="${ac_tool_prefix}strip"
-echo "$as_me:3634: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
fi
fi
STRIP=$ac_cv_prog_STRIP
if test -n "$STRIP"; then
- echo "$as_me:3642: result: $STRIP" >&5
+ echo "$as_me:$LINENO: result: $STRIP" >&5
echo "${ECHO_T}$STRIP" >&6
else
- echo "$as_me:3645: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -3641,7 +3952,7 @@ if test -z "$ac_cv_prog_STRIP"; then
ac_ct_STRIP=$STRIP
# Extract the first word of "strip", so it can be a program name with args.
set dummy strip; ac_word=$2
-echo "$as_me:3654: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3649,15 +3960,18 @@ else
if test -n "$ac_ct_STRIP"; then
ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
else
- ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
- IFS=$ac_save_IFS
- test -z "$ac_dir" && ac_dir=.
- $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_STRIP="strip"
-echo "$as_me:3669: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
done
test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
@@ -3665,10 +3979,10 @@ fi
fi
ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
if test -n "$ac_ct_STRIP"; then
- echo "$as_me:3678: result: $ac_ct_STRIP" >&5
+ echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
echo "${ECHO_T}$ac_ct_STRIP" >&6
else
- echo "$as_me:3681: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
@@ -3677,6 +3991,7 @@ else
STRIP="$ac_cv_prog_STRIP"
fi
+
enable_dlopen=no
enable_win32_dll=no
@@ -3692,11 +4007,11 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
case $host in
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 3705 "configure"' > conftest.$ac_ext
- if { (eval echo "$as_me:3706: \"$ac_compile\"") >&5
+ echo '#line 4011 "configure"' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:3709: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
case `/usr/bin/file conftest.$ac_objext` in
*32-bit*)
@@ -3717,12 +4032,13 @@ case $host in
# On SCO OpenServer 5, we need -belf to get full-featured binaries.
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -belf"
- echo "$as_me:3730: checking whether the C compiler needs -belf" >&5
+ echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6
if test "${lt_cv_cc_needs_belf+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3730,8 +4046,12 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
cat >conftest.$ac_ext <<_ACEOF
-#line 3743 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
int
main ()
@@ -3742,21 +4062,22 @@ main ()
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:3755: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:3758: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:3761: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:3764: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
lt_cv_cc_needs_belf=yes
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
lt_cv_cc_needs_belf=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
@@ -3767,7 +4088,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
-echo "$as_me:3780: result: $lt_cv_cc_needs_belf" >&5
+echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
if test x"$lt_cv_cc_needs_belf" != x"yes"; then
# this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
@@ -3775,6 +4096,7 @@ echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
fi
;;
+
esac
# Sed substitution that helps us do robust quoting. It backslashifies
@@ -3862,7 +4184,7 @@ compiler="$2"
## FIXME: this should be a separate macro
##
-echo "$as_me:3875: checking for objdir" >&5
+echo "$as_me:$LINENO: checking for objdir" >&5
echo $ECHO_N "checking for objdir... $ECHO_C" >&6
rm -f .libs 2>/dev/null
mkdir .libs 2>/dev/null
@@ -3873,11 +4195,12 @@ else
objdir=_libs
fi
rmdir .libs 2>/dev/null
-echo "$as_me:3886: result: $objdir" >&5
+echo "$as_me:$LINENO: result: $objdir" >&5
echo "${ECHO_T}$objdir" >&6
##
## END FIXME
+
## FIXME: this should be a separate macro
##
@@ -3893,7 +4216,7 @@ test -z "$pic_mode" && pic_mode=default
# We assume here that the value for lt_cv_prog_cc_pic will not be cached
# in isolation, and that seeing it set (from the cache) indicates that
# the associated values are set (in the cache) correctly too.
-echo "$as_me:3906: checking for $compiler option to produce PIC" >&5
+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
if test "${lt_cv_prog_cc_pic+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4040,14 +4363,14 @@ else
fi
if test -z "$lt_cv_prog_cc_pic"; then
- echo "$as_me:4053: result: none" >&5
+ echo "$as_me:$LINENO: result: none" >&5
echo "${ECHO_T}none" >&6
else
- echo "$as_me:4056: result: $lt_cv_prog_cc_pic" >&5
+ echo "$as_me:$LINENO: result: $lt_cv_prog_cc_pic" >&5
echo "${ECHO_T}$lt_cv_prog_cc_pic" >&6
# Check to make sure the pic_flag actually works.
- echo "$as_me:4060: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5
+ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5
echo $ECHO_N "checking if $compiler PIC flag $lt_cv_prog_cc_pic works... $ECHO_C" >&6
if test "${lt_cv_prog_cc_pic_works+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4055,8 +4378,12 @@ else
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC"
cat >conftest.$ac_ext <<_ACEOF
-#line 4068 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
int
main ()
@@ -4067,16 +4394,16 @@ main ()
}
_ACEOF
rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4080: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:4083: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:4086: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:4089: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
case $host_os in
hpux9* | hpux10* | hpux11*)
@@ -4096,7 +4423,8 @@ if { (eval echo "$as_me:4080: \"$ac_compile\"") >&5
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
lt_cv_prog_cc_pic_works=no
fi
@@ -4105,6 +4433,7 @@ rm -f conftest.$ac_objext conftest.$ac_ext
fi
+
if test "X$lt_cv_prog_cc_pic_works" = Xno; then
lt_cv_prog_cc_pic=
lt_cv_prog_cc_can_build_shared=no
@@ -4112,7 +4441,7 @@ fi
lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic"
fi
- echo "$as_me:4125: result: $lt_cv_prog_cc_pic_works" >&5
+ echo "$as_me:$LINENO: result: $lt_cv_prog_cc_pic_works" >&5
echo "${ECHO_T}$lt_cv_prog_cc_pic_works" >&6
fi
##
@@ -4120,11 +4449,11 @@ fi
# Check for any special shared library compilation flags.
if test -n "$lt_cv_prog_cc_shlib"; then
- { echo "$as_me:4133: WARNING: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" >&5
+ { echo "$as_me:$LINENO: WARNING: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" >&5
echo "$as_me: WARNING: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" >&2;}
if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$lt_cv_prog_cc_shlib[ ]" >/dev/null; then :
else
- { echo "$as_me:4137: WARNING: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5
+ { echo "$as_me:$LINENO: WARNING: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5
echo "$as_me: WARNING: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;}
lt_cv_prog_cc_can_build_shared=no
fi
@@ -4132,7 +4461,7 @@ fi
## FIXME: this should be a separate macro
##
-echo "$as_me:4145: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5
+echo "$as_me:$LINENO: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5
echo $ECHO_N "checking if $compiler static flag $lt_cv_prog_cc_static works... $ECHO_C" >&6
if test "${lt_cv_prog_cc_static_works+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4141,8 +4470,12 @@ else
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static"
cat >conftest.$ac_ext <<_ACEOF
-#line 4154 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
int
main ()
@@ -4153,30 +4486,32 @@ main ()
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:4166: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:4169: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:4172: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:4175: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
lt_cv_prog_cc_static_works=yes
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LDFLAGS="$save_LDFLAGS"
fi
+
# Belt *and* braces to stop my trousers falling down:
test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static=
-echo "$as_me:4189: result: $lt_cv_prog_cc_static_works" >&5
+echo "$as_me:$LINENO: result: $lt_cv_prog_cc_static_works" >&5
echo "${ECHO_T}$lt_cv_prog_cc_static_works" >&6
pic_flag="$lt_cv_prog_cc_pic"
@@ -4188,10 +4523,11 @@ can_build_shared="$lt_cv_prog_cc_can_build_shared"
##
## END FIXME
+
## FIXME: this should be a separate macro
##
# Check to see if options -o and -c are simultaneously supported by compiler
-echo "$as_me:4204: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
if test "${lt_cv_compiler_c_o+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4211,7 +4547,7 @@ chmod -w .
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
compiler_c_o=no
-if { (eval echo configure:4224: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+if { (eval echo configure:4551: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
if test -s out/conftest.err; then
@@ -4235,12 +4571,12 @@ $rm -r conftest 2>/dev/null
fi
compiler_c_o=$lt_cv_compiler_c_o
-echo "$as_me:4248: result: $compiler_c_o" >&5
+echo "$as_me:$LINENO: result: $compiler_c_o" >&5
echo "${ECHO_T}$compiler_c_o" >&6
if test x"$compiler_c_o" = x"yes"; then
# Check to see if we can write to a .lo
- echo "$as_me:4253: checking if $compiler supports -c -o file.lo" >&5
+ echo "$as_me:$LINENO: checking if $compiler supports -c -o file.lo" >&5
echo $ECHO_N "checking if $compiler supports -c -o file.lo... $ECHO_C" >&6
if test "${lt_cv_compiler_o_lo+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4250,8 +4586,12 @@ else
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -c -o conftest.lo"
cat >conftest.$ac_ext <<_ACEOF
-#line 4263 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
int
main ()
@@ -4262,16 +4602,16 @@ int some_variable = 0;
}
_ACEOF
rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4275: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:4278: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:4281: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:4284: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -4283,7 +4623,8 @@ if { (eval echo "$as_me:4275: \"$ac_compile\"") >&5
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
fi
rm -f conftest.$ac_objext conftest.$ac_ext
CFLAGS="$save_CFLAGS"
@@ -4291,7 +4632,7 @@ rm -f conftest.$ac_objext conftest.$ac_ext
fi
compiler_o_lo=$lt_cv_compiler_o_lo
- echo "$as_me:4304: result: $compiler_c_lo" >&5
+ echo "$as_me:$LINENO: result: $compiler_c_lo" >&5
echo "${ECHO_T}$compiler_c_lo" >&6
else
compiler_o_lo=no
@@ -4305,7 +4646,7 @@ fi
hard_links="nottested"
if test "$compiler_c_o" = no && test "$need_locks" != no; then
# do not overwrite the value of need_locks provided by the user
- echo "$as_me:4318: checking if we can lock with hard links" >&5
+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
hard_links=yes
$rm conftest*
@@ -4313,10 +4654,10 @@ echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
touch conftest.a
ln conftest.a conftest.b 2>&5 || hard_links=no
ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:4326: result: $hard_links" >&5
+ echo "$as_me:$LINENO: result: $hard_links" >&5
echo "${ECHO_T}$hard_links" >&6
if test "$hard_links" = no; then
- { echo "$as_me:4329: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
need_locks=warn
fi
@@ -4330,15 +4671,19 @@ fi
##
if test "$GCC" = yes; then
# Check to see if options -fno-rtti -fno-exceptions are supported by compiler
- echo "$as_me:4343: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+ echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
echo "int some_variable = 0;" > conftest.$ac_ext
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext"
compiler_rtti_exceptions=no
cat >conftest.$ac_ext <<_ACEOF
-#line 4350 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
int
main ()
@@ -4349,16 +4694,16 @@ int some_variable = 0;
}
_ACEOF
rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4362: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:4365: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:4368: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:4371: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -4370,11 +4715,12 @@ if { (eval echo "$as_me:4362: \"$ac_compile\"") >&5
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
fi
rm -f conftest.$ac_objext conftest.$ac_ext
CFLAGS="$save_CFLAGS"
- echo "$as_me:4387: result: $compiler_rtti_exceptions" >&5
+ echo "$as_me:$LINENO: result: $compiler_rtti_exceptions" >&5
echo "${ECHO_T}$compiler_rtti_exceptions" >&6
if test "$compiler_rtti_exceptions" = "yes"; then
@@ -4389,7 +4735,7 @@ fi
## FIXME: this should be a separate macro
##
# See if the linker supports building shared libraries.
-echo "$as_me:4402: checking whether the linker ($LD) supports shared libraries" >&5
+echo "$as_me:$LINENO: checking whether the linker ($LD) supports shared libraries" >&5
echo $ECHO_N "checking whether the linker ($LD) supports shared libraries... $ECHO_C" >&6
allow_undefined_flag=
@@ -4756,7 +5102,17 @@ else
;;
darwin* | rhapsody*)
- allow_undefined_flag='-undefined suppress'
+ # This patch put in by hand by PH (19-Feb-2003) for Darwin 1.3.
+ case "$host_os" in
+ rhapsody* | darwin1.[[012]])
+ allow_undefined_flag='-undefined suppress'
+ ;;
+ *) # Darwin 1.3 on
+ allow_undefined_flag='-flat_namespace -undefined suppress'
+ ;;
+ esac
+ # End of hand-inserted patch
+
# FIXME: Relying on posixy $() will cause problems for
# cross-compilation, but unfortunately the echo tests do not
# yet detect zsh echo's removal of \ escapes.
@@ -5001,7 +5357,7 @@ else
;;
esac
fi
-echo "$as_me:5014: result: $ld_shlibs" >&5
+echo "$as_me:$LINENO: result: $ld_shlibs" >&5
echo "${ECHO_T}$ld_shlibs" >&6
test "$ld_shlibs" = no && can_build_shared=no
##
@@ -5010,7 +5366,7 @@ test "$ld_shlibs" = no && can_build_shared=no
## FIXME: this should be a separate macro
##
# Check hardcoding attributes.
-echo "$as_me:5023: checking how to hardcode library paths into programs" >&5
+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
hardcode_action=
if test -n "$hardcode_libdir_flag_spec" || \
@@ -5034,7 +5390,7 @@ else
# directories.
hardcode_action=unsupported
fi
-echo "$as_me:5047: result: $hardcode_action" >&5
+echo "$as_me:$LINENO: result: $hardcode_action" >&5
echo "${ECHO_T}$hardcode_action" >&6
##
## END FIXME
@@ -5043,15 +5399,15 @@ echo "${ECHO_T}$hardcode_action" >&6
##
striplib=
old_striplib=
-echo "$as_me:5056: checking whether stripping libraries is possible" >&5
+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
test -z "$striplib" && striplib="$STRIP --strip-unneeded"
- echo "$as_me:5061: result: yes" >&5
+ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
else
- echo "$as_me:5064: result: no" >&5
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
##
@@ -5063,7 +5419,7 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
## FIXME: this should be a separate macro
##
# PORTME Fill in your ld.so characteristics
-echo "$as_me:5076: checking dynamic linker characteristics" >&5
+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
library_names_spec=
libname_spec='lib$name'
@@ -5445,7 +5801,7 @@ sysv4*MP*)
dynamic_linker=no
;;
esac
-echo "$as_me:5458: result: $dynamic_linker" >&5
+echo "$as_me:$LINENO: result: $dynamic_linker" >&5
echo "${ECHO_T}$dynamic_linker" >&6
test "$dynamic_linker" = no && can_build_shared=no
##
@@ -5454,9 +5810,9 @@ test "$dynamic_linker" = no && can_build_shared=no
## FIXME: this should be a separate macro
##
# Report the final consequences.
-echo "$as_me:5467: checking if libtool supports shared libraries" >&5
+echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
-echo "$as_me:5469: result: $can_build_shared" >&5
+echo "$as_me:$LINENO: result: $can_build_shared" >&5
echo "${ECHO_T}$can_build_shared" >&6
##
## END FIXME
@@ -5496,7 +5852,7 @@ else
;;
*)
- echo "$as_me:5509: checking for dlopen in -ldl" >&5
+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
if test "${ac_cv_lib_dl_dlopen+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5504,8 +5860,12 @@ else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl $LIBS"
cat >conftest.$ac_ext <<_ACEOF
-#line 5517 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
@@ -5523,154 +5883,183 @@ dlopen ();
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5536: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:5539: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:5542: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:5545: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_dl_dlopen=yes
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
ac_cv_lib_dl_dlopen=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-echo "$as_me:5556: result: $ac_cv_lib_dl_dlopen" >&5
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
if test $ac_cv_lib_dl_dlopen = yes; then
lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
else
- echo "$as_me:5561: checking for dlopen" >&5
+ echo "$as_me:$LINENO: checking for dlopen" >&5
echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
if test "${ac_cv_func_dlopen+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
-#line 5567 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char dlopen (); below. */
-#include <assert.h>
+ which can conflict with char dlopen (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
+{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char dlopen ();
-char (*f) ();
-
-int
-main ()
-{
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_dlopen) || defined (__stub___dlopen)
choke me
#else
-f = dlopen;
+char (*f) () = dlopen;
+#endif
+#ifdef __cplusplus
+}
#endif
+int
+main ()
+{
+return f != dlopen;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5598: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:5601: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:5604: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:5607: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_func_dlopen=yes
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
ac_cv_func_dlopen=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
-echo "$as_me:5617: result: $ac_cv_func_dlopen" >&5
+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
echo "${ECHO_T}$ac_cv_func_dlopen" >&6
if test $ac_cv_func_dlopen = yes; then
lt_cv_dlopen="dlopen"
else
- echo "$as_me:5622: checking for shl_load" >&5
+ echo "$as_me:$LINENO: checking for shl_load" >&5
echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
if test "${ac_cv_func_shl_load+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
-#line 5628 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char shl_load (); below. */
-#include <assert.h>
+ which can conflict with char shl_load (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
+{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char shl_load ();
-char (*f) ();
-
-int
-main ()
-{
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_shl_load) || defined (__stub___shl_load)
choke me
#else
-f = shl_load;
+char (*f) () = shl_load;
+#endif
+#ifdef __cplusplus
+}
#endif
+int
+main ()
+{
+return f != shl_load;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5659: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:5662: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:5665: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:5668: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_func_shl_load=yes
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
ac_cv_func_shl_load=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
-echo "$as_me:5678: result: $ac_cv_func_shl_load" >&5
+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
echo "${ECHO_T}$ac_cv_func_shl_load" >&6
if test $ac_cv_func_shl_load = yes; then
lt_cv_dlopen="shl_load"
else
- echo "$as_me:5683: checking for dlopen in -lsvld" >&5
+ echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
if test "${ac_cv_lib_svld_dlopen+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5678,8 +6067,12 @@ else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsvld $LIBS"
cat >conftest.$ac_ext <<_ACEOF
-#line 5691 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
@@ -5697,32 +6090,33 @@ dlopen ();
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5710: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:5713: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:5716: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:5719: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_svld_dlopen=yes
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
ac_cv_lib_svld_dlopen=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-echo "$as_me:5730: result: $ac_cv_lib_svld_dlopen" >&5
+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
if test $ac_cv_lib_svld_dlopen = yes; then
lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
else
- echo "$as_me:5735: checking for shl_load in -ldld" >&5
+ echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
if test "${ac_cv_lib_dld_shl_load+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5730,8 +6124,12 @@ else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldld $LIBS"
cat >conftest.$ac_ext <<_ACEOF
-#line 5743 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
@@ -5749,38 +6147,43 @@ shl_load ();
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5762: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:5765: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:5768: \"$ac_try\"") >&5
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
- echo "$as_me:5771: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_dld_shl_load=yes
else
echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
ac_cv_lib_dld_shl_load=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-echo "$as_me:5782: result: $ac_cv_lib_dld_shl_load" >&5
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
if test $ac_cv_lib_dld_shl_load = yes; then
lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
fi
+
fi
+
fi
+
fi
+
fi
;;
@@ -5803,7 +6206,7 @@ fi
save_LIBS="$LIBS"
LIBS="$lt_cv_dlopen_libs $LIBS"
- echo "$as_me:5816: checking whether a program can dlopen itself" >&5
+ echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
if test "${lt_cv_dlopen_self+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5814,7 +6217,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 5827 "configure"
+#line 6211 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -5875,10 +6278,10 @@ int main ()
exit (status);
}
EOF
- if { (eval echo "$as_me:5888: \"$ac_link\"") >&5
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:5891: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
(./conftest; exit; ) 2>/dev/null
lt_status=$?
@@ -5894,13 +6297,14 @@ EOF
fi
rm -fr conftest*
+
fi
-echo "$as_me:5908: result: $lt_cv_dlopen_self" >&5
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
echo "${ECHO_T}$lt_cv_dlopen_self" >&6
if test "x$lt_cv_dlopen_self" = xyes; then
LDFLAGS="$LDFLAGS $link_static_flag"
- echo "$as_me:5913: checking whether a statically linked program can dlopen itself" >&5
+ echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
if test "${lt_cv_dlopen_self_static+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5911,7 +6315,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 5924 "configure"
+#line 6309 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -5972,10 +6376,10 @@ int main ()
exit (status);
}
EOF
- if { (eval echo "$as_me:5985: \"$ac_link\"") >&5
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
- echo "$as_me:5988: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
(./conftest; exit; ) 2>/dev/null
lt_status=$?
@@ -5991,8 +6395,9 @@ EOF
fi
rm -fr conftest*
+
fi
-echo "$as_me:6005: result: $lt_cv_dlopen_self_static" >&5
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
fi
@@ -6013,6 +6418,7 @@ echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
esac
fi
+
## FIXME: this should be a separate macro
##
if test "$enable_shared" = yes && test "$GCC" = yes; then
@@ -6024,7 +6430,7 @@ if test "$enable_shared" = yes && test "$GCC" = yes; then
# Test whether the compiler implicitly links with -lc since on some
# systems, -lgcc has to come before -lc. If gcc already passes -lc
# to ld, don't add -lc before -lgcc.
- echo "$as_me:6037: checking whether -lc should be explicitly linked in" >&5
+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
if test "${lt_cv_archive_cmds_need_lc+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6032,10 +6438,10 @@ else
$rm conftest*
echo 'static int dummy;' > conftest.$ac_ext
- if { (eval echo "$as_me:6045: \"$ac_compile\"") >&5
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
- echo "$as_me:6048: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
soname=conftest
lib=conftest
@@ -6049,10 +6455,10 @@ else
libname=conftest
save_allow_undefined_flag=$allow_undefined_flag
allow_undefined_flag=
- if { (eval echo "$as_me:6062: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
(eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
ac_status=$?
- echo "$as_me:6065: \$? = $ac_status" >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
then
lt_cv_archive_cmds_need_lc=no
@@ -6065,7 +6471,7 @@ else
fi
fi
- echo "$as_me:6078: result: $lt_cv_archive_cmds_need_lc" >&5
+ echo "$as_me:$LINENO: result: $lt_cv_archive_cmds_need_lc" >&5
echo "${ECHO_T}$lt_cv_archive_cmds_need_lc" >&6
;;
esac
@@ -6624,6 +7030,10 @@ fi
##
## END FIXME
+
+
+
+
# This can be used to rebuild libtool when needed
LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
@@ -6632,8 +7042,661 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool'
# Prevent multiple expansion
-ac_config_files="$ac_config_files Makefile pcre.h:pcre.in pcre-config:pcre-config.in RunTest:RunTest.in"
-ac_config_commands="$ac_config_commands default"
+
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_stdc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+ exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+
+for ac_header in limits.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+ yes:no )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+ no:yes )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+if test "${ac_cv_c_const+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+ /* Ultrix mips cc rejects this. */
+ typedef int charset[2];
+ const charset x;
+ /* SunOS 4.1.1 cc rejects this. */
+ char const *const *ccp;
+ char **p;
+ /* NEC SVR4.0.2 mips cc rejects this. */
+ struct point {int x, y;};
+ static struct point const zero = {0,0};
+ /* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in
+ an arm of an if-expression whose if-part is not a constant
+ expression */
+ const char *g = "string";
+ ccp = &g + (g ? g-g : 0);
+ /* HPUX 7.0 cc rejects these. */
+ ++ccp;
+ p = (char**) ccp;
+ ccp = (char const *const *) p;
+ { /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+ }
+ { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+ }
+ { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+ }
+ { /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+ }
+ { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+ }
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_c_const=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_const=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define const
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for size_t" >&5
+echo $ECHO_N "checking for size_t... $ECHO_C" >&6
+if test "${ac_cv_type_size_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((size_t *) 0)
+ return 0;
+if (sizeof (size_t))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_size_t=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_size_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
+echo "${ECHO_T}$ac_cv_type_size_t" >&6
+if test $ac_cv_type_size_t = yes; then
+ :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned
+_ACEOF
+
+fi
+
+
+
+
+
+
+for ac_func in bcopy memmove strerror
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+# Check whether --enable-utf8 or --disable-utf8 was given.
+if test "${enable_utf8+set}" = set; then
+ enableval="$enable_utf8"
+ if test "$enableval" = "yes"; then
+ UTF8=-DSUPPORT_UTF8
+fi
+
+fi;
+
+
+# Check whether --enable-newline-is-cr or --disable-newline-is-cr was given.
+if test "${enable_newline_is_cr+set}" = set; then
+ enableval="$enable_newline_is_cr"
+ if test "$enableval" = "yes"; then
+ NEWLINE=-DNEWLINE=13
+fi
+
+fi;
+
+
+# Check whether --enable-newline-is-lf or --disable-newline-is-lf was given.
+if test "${enable_newline_is_lf+set}" = set; then
+ enableval="$enable_newline_is_lf"
+ if test "$enableval" = "yes"; then
+ NEWLINE=-DNEWLINE=10
+fi
+
+fi;
+
+
+
+
+# Check whether --with-posix-malloc-threshold or --without-posix-malloc-threshold was given.
+if test "${with_posix_malloc_threshold+set}" = set; then
+ withval="$with_posix_malloc_threshold"
+ POSIX_MALLOC_THRESHOLD=-DPOSIX_MALLOC_THRESHOLD=$withval
+
+fi;
+
+
+
+# Check whether --with-link-size or --without-link-size was given.
+if test "${with_link_size+set}" = set; then
+ withval="$with_link_size"
+ LINK_SIZE=-DLINK_SIZE=$withval
+
+fi;
+
+
+
+# Check whether --with-match-limit or --without-match-limit was given.
+if test "${with_match_limit+set}" = set; then
+ withval="$with_match_limit"
+ MATCH_LIMIT=-DMATCH_LIMIT=$withval
+
+fi;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+case $host_os in
+mingw* )
+ POSIX_OBJ=pcreposix.o
+ POSIX_LOBJ=pcreposix.lo
+ POSIX_LIB=
+ ;;
+* )
+ POSIX_OBJ=
+ POSIX_LOBJ=
+ POSIX_LIB=libpcreposix.la
+ ;;
+esac
+
+
+
+
+if test "x$enable_shared" = "xno" ; then
+ cat >>confdefs.h <<\_ACEOF
+#define PCRE_STATIC 1
+_ACEOF
+
+fi
+
+ ac_config_files="$ac_config_files Makefile pcre.h:pcre.in pcre-config:pcre-config.in RunTest:RunTest.in"
+ ac_config_commands="$ac_config_commands default"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
@@ -6644,7 +7707,7 @@ cat >confcache <<\_ACEOF
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
-# `ac_cv_env_foo' variables (set or unset) will be overriden when
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.
@@ -6663,12 +7726,12 @@ _ACEOF
# substitution turns \\\\ into \\, and sed turns \\ into \).
sed -n \
"s/'/'\\\\''/g;
- s/^\\([_$ac_cr_alnum]*_cv_[_$ac_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
;;
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n \
- "s/^\\([_$ac_cr_alnum]*_cv_[_$ac_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
;;
esac;
} |
@@ -6679,7 +7742,7 @@ _ACEOF
t end
/^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
: end' >>confcache
-if cmp -s $cache_file confcache; then :; else
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
if test -w $cache_file; then
test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
cat confcache >$cache_file
@@ -6710,35 +7773,227 @@ fi
DEFS=-DHAVE_CONFIG_H
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_i=`echo "$ac_i" |
+ sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+ # 2. Add them.
+ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:6726: creating $CONFIG_STATUS" >&5
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
echo "$as_me: creating $CONFIG_STATUS" >&6;}
cat >$CONFIG_STATUS <<_ACEOF
#! $SHELL
-# Generated automatically by configure.
+# Generated by $as_me.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.
debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
SHELL=\${CONFIG_SHELL-$SHELL}
-ac_cs_invocation="\$0 \$@"
-
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
set -o posix
fi
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
# Name of the executable.
-as_me=`echo "$0" |sed 's,.*[\\/],,'`
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
if expr a : '\(a\)' >/dev/null 2>&1; then
as_expr=expr
@@ -6764,24 +8019,20 @@ else
fi
rm -f conf$$ conf$$.exe conf$$.file
-as_executable_p="test -f"
-
-# Support unset when possible.
-if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
- as_unset=unset
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
else
- as_unset=false
+ as_mkdir_p=false
fi
-# NLS nuisances.
-$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
-$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
-$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
-$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
-$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
-$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
-$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
-$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+
# IFS
# We need space, tab and new line, in precisely that order.
@@ -6790,10 +8041,34 @@ as_nl='
IFS=" $as_nl"
# CDPATH.
-$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
+$as_unset CDPATH
exec 6>&1
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling. Logging --version etc. is OK.
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.57. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
_ACEOF
# Files that config.status was made for.
@@ -6813,7 +8088,7 @@ if test -n "$ac_config_commands"; then
echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
fi
-cat >>$CONFIG_STATUS <<\EOF
+cat >>$CONFIG_STATUS <<\_ACEOF
ac_cs_usage="\
\`$as_me' instantiates files from templates according to the
@@ -6823,6 +8098,7 @@ Usage: $0 [OPTIONS] [FILE]...
-h, --help print this help, then exit
-V, --version print version number, then exit
+ -q, --quiet do not print progress messages
-d, --debug don't remove temporary files
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
@@ -6840,12 +8116,12 @@ Configuration commands:
$config_commands
Report bugs to <bug-autoconf@gnu.org>."
-EOF
+_ACEOF
-cat >>$CONFIG_STATUS <<EOF
+cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
config.status
-configured by $0, generated by GNU Autoconf 2.50,
+configured by $0, generated by GNU Autoconf 2.57,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
@@ -6854,9 +8130,9 @@ This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
srcdir=$srcdir
INSTALL="$INSTALL"
-EOF
+_ACEOF
-cat >>$CONFIG_STATUS <<\EOF
+cat >>$CONFIG_STATUS <<\_ACEOF
# If no file are specified by the user, then we need to provide default
# value. By we need to know if files were specified by the user.
ac_need_defaults=:
@@ -6866,30 +8142,30 @@ do
--*=*)
ac_option=`expr "x$1" : 'x\([^=]*\)='`
ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
- shift
- set dummy "$ac_option" "$ac_optarg" ${1+"$@"}
- shift
+ ac_shift=:
+ ;;
+ -*)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
;;
- -*);;
*) # This is not an option, so the user has probably given explicit
# arguments.
+ ac_option=$1
ac_need_defaults=false;;
esac
- case $1 in
+ case $ac_option in
# Handling of the options.
-EOF
-cat >>$CONFIG_STATUS <<EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion"
- exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;;
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+ ac_cs_recheck=: ;;
--version | --vers* | -V )
echo "$ac_cs_version"; exit 0 ;;
--he | --h)
# Conflict between --help and --header
- { { echo "$as_me:6902: error: ambiguous option: $1
+ { { echo "$as_me:$LINENO: error: ambiguous option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2;}
@@ -6899,50 +8175,67 @@ Try \`$0 --help' for more information." >&2;}
--debug | --d* | -d )
debug=: ;;
--file | --fil | --fi | --f )
- shift
- CONFIG_FILES="$CONFIG_FILES $1"
+ $ac_shift
+ CONFIG_FILES="$CONFIG_FILES $ac_optarg"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
- shift
- CONFIG_HEADERS="$CONFIG_HEADERS $1"
+ $ac_shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
ac_need_defaults=false;;
-
- # Handling of arguments.
- 'Makefile' ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
- 'pcre.h' ) CONFIG_FILES="$CONFIG_FILES pcre.h:pcre.in" ;;
- 'pcre-config' ) CONFIG_FILES="$CONFIG_FILES pcre-config:pcre-config.in" ;;
- 'RunTest' ) CONFIG_FILES="$CONFIG_FILES RunTest:RunTest.in" ;;
- 'default' ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
- 'config.h' ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
# This is an error.
- -*) { { echo "$as_me:6929: error: unrecognized option: $1
+ -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2;}
{ (exit 1); exit 1; }; } ;;
- *) { { echo "$as_me:6934: error: invalid argument: $1" >&5
-echo "$as_me: error: invalid argument: $1" >&2;}
- { (exit 1); exit 1; }; };;
+
+ *) ac_config_targets="$ac_config_targets $1" ;;
+
esac
shift
done
-exec 5>>config.log
-cat >&5 << _ACEOF
+ac_configure_extra_args=
-## ----------------------- ##
-## Running config.status. ##
-## ----------------------- ##
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
-This file was extended by $as_me 2.50, executed with
- > $ac_cs_invocation
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+ echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+ exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
_ACEOF
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+ case "$ac_config_target" in
+ # Handling of arguments.
+ "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "pcre.h" ) CONFIG_FILES="$CONFIG_FILES pcre.h:pcre.in" ;;
+ "pcre-config" ) CONFIG_FILES="$CONFIG_FILES pcre-config:pcre-config.in" ;;
+ "RunTest" ) CONFIG_FILES="$CONFIG_FILES RunTest:RunTest.in" ;;
+ "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
+ "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
+ *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used. Set only those that are not.
# We use the long form for the default assignment because of an extremely
@@ -6953,31 +8246,34 @@ if $ac_need_defaults; then
test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
fi
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
# Create a temporary directory, and hook for its removal unless debugging.
$debug ||
{
trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
- trap '{ (exit $?); exit $?; }' 1 2 13 15
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
-: ${TMPDIR=/tmp}
+
{
- tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` &&
+ tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
- tmp=$TMPDIR/cs$$-$RANDOM
+ tmp=./confstat$$-$RANDOM
(umask 077 && mkdir $tmp)
} ||
{
- echo "$me: cannot create a temporary directory in $TMPDIR" >&2
+ echo "$me: cannot create a temporary directory in ." >&2
{ (exit 1); exit 1; }
}
-EOF
+_ACEOF
-cat >>$CONFIG_STATUS <<EOF
+cat >>$CONFIG_STATUS <<_ACEOF
#
# CONFIG_FILES section.
@@ -6990,6 +8286,12 @@ if test -n "\$CONFIG_FILES"; then
sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
s,@SHELL@,$SHELL,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
s,@exec_prefix@,$exec_prefix,;t t
s,@prefix@,$prefix,;t t
s,@program_transform_name@,$program_transform_name,;t t
@@ -7005,16 +8307,13 @@ s,@includedir@,$includedir,;t t
s,@oldincludedir@,$oldincludedir,;t t
s,@infodir@,$infodir,;t t
s,@mandir@,$mandir,;t t
-s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@DEFS@,$DEFS,;t t
s,@ECHO_C@,$ECHO_C,;t t
s,@ECHO_N@,$ECHO_N,;t t
s,@ECHO_T@,$ECHO_T,;t t
-s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s,@DEFS@,$DEFS,;t t
s,@LIBS@,$LIBS,;t t
s,@CC@,$CC,;t t
s,@CFLAGS@,$CFLAGS,;t t
@@ -7026,9 +8325,6 @@ s,@OBJEXT@,$OBJEXT,;t t
s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
s,@INSTALL_DATA@,$INSTALL_DATA,;t t
-s,@RANLIB@,$RANLIB,;t t
-s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
-s,@CPP@,$CPP,;t t
s,@build@,$build,;t t
s,@build_cpu@,$build_cpu,;t t
s,@build_vendor@,$build_vendor,;t t
@@ -7039,12 +8335,20 @@ s,@host_vendor@,$host_vendor,;t t
s,@host_os@,$host_os,;t t
s,@LN_S@,$LN_S,;t t
s,@ECHO@,$ECHO,;t t
+s,@RANLIB@,$RANLIB,;t t
+s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
s,@STRIP@,$STRIP,;t t
s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
+s,@CPP@,$CPP,;t t
+s,@EGREP@,$EGREP,;t t
s,@LIBTOOL@,$LIBTOOL,;t t
s,@HAVE_MEMMOVE@,$HAVE_MEMMOVE,;t t
s,@HAVE_STRERROR@,$HAVE_STRERROR,;t t
+s,@HOST_CC@,$HOST_CC,;t t
+s,@HOST_CFLAGS@,$HOST_CFLAGS,;t t
s,@NEWLINE@,$NEWLINE,;t t
+s,@LINK_SIZE@,$LINK_SIZE,;t t
+s,@MATCH_LIMIT@,$MATCH_LIMIT,;t t
s,@UTF8@,$UTF8,;t t
s,@PCRE_MAJOR@,$PCRE_MAJOR,;t t
s,@PCRE_MINOR@,$PCRE_MINOR,;t t
@@ -7052,11 +8356,17 @@ s,@PCRE_DATE@,$PCRE_DATE,;t t
s,@PCRE_VERSION@,$PCRE_VERSION,;t t
s,@PCRE_LIB_VERSION@,$PCRE_LIB_VERSION,;t t
s,@PCRE_POSIXLIB_VERSION@,$PCRE_POSIXLIB_VERSION,;t t
+s,@POSIX_MALLOC_THRESHOLD@,$POSIX_MALLOC_THRESHOLD,;t t
+s,@POSIX_OBJ@,$POSIX_OBJ,;t t
+s,@POSIX_LOBJ@,$POSIX_LOBJ,;t t
+s,@POSIX_LIB@,$POSIX_LIB,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
+s,@LTLIBOBJS@,$LTLIBOBJS,;t t
CEOF
-EOF
+_ACEOF
- cat >>$CONFIG_STATUS <<\EOF
+ cat >>$CONFIG_STATUS <<\_ACEOF
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_lines=48
@@ -7095,8 +8405,8 @@ EOF
fi
fi # test -n "$CONFIG_FILES"
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case $ac_file in
@@ -7110,7 +8420,8 @@ for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
esac
# Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
- ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| \
@@ -7121,60 +8432,84 @@ echo X"$ac_file" |
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- { case "$ac_dir" in
- [\\/]* | ?:[\\/]* ) as_incr_dir=;;
- *) as_incr_dir=.;;
-esac
-as_dummy="$ac_dir"
-for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
- case $as_mkdir_dir in
- # Skip DOS drivespec
- ?:) as_incr_dir=$as_mkdir_dir ;;
- *)
- as_incr_dir=$as_incr_dir/$as_mkdir_dir
- test -d "$as_incr_dir" || mkdir "$as_incr_dir"
- ;;
- esac
-done; }
-
- ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
else
- ac_dir_suffix= ac_dots=
- fi
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
- case $srcdir in
- .) ac_srcdir=.
- if test -z "$ac_dots"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* )
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
*) # Relative path.
- ac_srcdir=$ac_dots$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_dots$srcdir ;;
- esac
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
case $INSTALL in
[\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
- *) ac_INSTALL=$ac_dots$INSTALL ;;
+ *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
esac
if test x"$ac_file" != x-; then
- { echo "$as_me:7179: creating $ac_file" >&5
+ { echo "$as_me:$LINENO: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
rm -f "$ac_file"
fi
# Let's still pretend it is `configure' which instantiates (i.e., don't
# use $as_me), people would be surprised to read:
- # /* config.h. Generated automatically by config.status. */
- configure_input="Generated automatically from `echo $ac_file_in |
- sed 's,.*/,,'` by configure."
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ configure_input=
+ else
+ configure_input="$ac_file. "
+ fi
+ configure_input=$configure_input"Generated from `echo $ac_file_in |
+ sed 's,.*/,,'` by configure."
# First look for the input files in the build tree, otherwise in the
# src tree.
@@ -7184,7 +8519,7 @@ echo "$as_me: creating $ac_file" >&6;}
-) echo $tmp/stdin ;;
[\\/$]*)
# Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:7197: error: cannot find input file: $f" >&5
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
echo $f;;
@@ -7197,23 +8532,29 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
echo $srcdir/$f
else
# /dev/null tree
- { { echo "$as_me:7210: error: cannot find input file: $f" >&5
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
fi;;
esac
done` || { (exit 1); exit 1; }
-EOF
-cat >>$CONFIG_STATUS <<EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
sed "$ac_vpsub
$extrasub
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s,@configure_input@,$configure_input,;t t
s,@srcdir@,$ac_srcdir,;t t
+s,@abs_srcdir@,$ac_abs_srcdir,;t t
s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s,@builddir@,$ac_builddir,;t t
+s,@abs_builddir@,$ac_abs_builddir,;t t
+s,@top_builddir@,$ac_top_builddir,;t t
+s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
s,@INSTALL@,$ac_INSTALL,;t t
" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
rm -f $tmp/stdin
@@ -7225,8 +8566,8 @@ s,@INSTALL@,$ac_INSTALL,;t t
fi
done
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
#
# CONFIG_HEADER section.
@@ -7258,7 +8599,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
* ) ac_file_in=$ac_file.in ;;
esac
- test x"$ac_file" != x- && { echo "$as_me:7271: creating $ac_file" >&5
+ test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
# First look for the input files in the build tree, otherwise in the
@@ -7269,7 +8610,7 @@ echo "$as_me: creating $ac_file" >&6;}
-) echo $tmp/stdin ;;
[\\/$]*)
# Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:7282: error: cannot find input file: $f" >&5
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
echo $f;;
@@ -7282,7 +8623,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
echo $srcdir/$f
else
# /dev/null tree
- { { echo "$as_me:7295: error: cannot find input file: $f" >&5
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
fi;;
@@ -7291,7 +8632,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
# Remove the trailing spaces.
sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
-EOF
+_ACEOF
# Transform confdefs.h into two sed scripts, `conftest.defines' and
# `conftest.undefs', that substitutes the proper values into
@@ -7307,16 +8648,16 @@ rm -f conftest.defines conftest.undefs
# `end' is used to avoid that the second main sed command (meant for
# 0-ary CPP macros) applies to n-ary macro definitions.
# See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\EOF
+cat >confdef2sed.sed <<\_ACEOF
s/[\\&,]/\\&/g
s,[\\$`],\\&,g
t clear
: clear
-s,^[ ]*#[ ]*define[ ][ ]*\(\([^ (][^ (]*\)([^)]*)\)[ ]*\(.*\)$,${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD},gp
+s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
t end
s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
: end
-EOF
+_ACEOF
# If some macros were called several times there might be several times
# the same #defines, which is useless. Nevertheless, we may not want to
# sort them, since we want the *last* AC-DEFINE to be honored.
@@ -7327,14 +8668,14 @@ rm -f confdef2sed.sed
# This sed command replaces #undef with comments. This is necessary, for
# example, in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\EOF
+cat >>conftest.undefs <<\_ACEOF
s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-EOF
+_ACEOF
# Break up conftest.defines because some shells have a limit on the size
# of here documents, and old seds have small limits too (100 cmds).
echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo ' if egrep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
echo ' :' >>$CONFIG_STATUS
rm -f conftest.tail
@@ -7358,7 +8699,7 @@ do
mv conftest.tail conftest.defines
done
rm -f conftest.defines
-echo ' fi # egrep' >>$CONFIG_STATUS
+echo ' fi # grep' >>$CONFIG_STATUS
echo >>$CONFIG_STATUS
# Break up conftest.undefs because some shells have a limit on the size
@@ -7386,23 +8727,24 @@ do
done
rm -f conftest.undefs
-cat >>$CONFIG_STATUS <<\EOF
+cat >>$CONFIG_STATUS <<\_ACEOF
# Let's still pretend it is `configure' which instantiates (i.e., don't
# use $as_me), people would be surprised to read:
- # /* config.h. Generated automatically by config.status. */
+ # /* config.h. Generated by config.status. */
if test x"$ac_file" = x-; then
- echo "/* Generated automatically by configure. */" >$tmp/config.h
+ echo "/* Generated by configure. */" >$tmp/config.h
else
- echo "/* $ac_file. Generated automatically by configure. */" >$tmp/config.h
+ echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
fi
cat $tmp/in >>$tmp/config.h
rm -f $tmp/in
if test x"$ac_file" != x-; then
- if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
- { echo "$as_me:7412: $ac_file is unchanged" >&5
+ if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+ { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
echo "$as_me: $ac_file is unchanged" >&6;}
else
- ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| \
@@ -7413,24 +8755,31 @@ echo X"$ac_file" |
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- { case "$ac_dir" in
- [\\/]* | ?:[\\/]* ) as_incr_dir=;;
- *) as_incr_dir=.;;
-esac
-as_dummy="$ac_dir"
-for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
- case $as_mkdir_dir in
- # Skip DOS drivespec
- ?:) as_incr_dir=$as_mkdir_dir ;;
- *)
- as_incr_dir=$as_incr_dir/$as_mkdir_dir
- test -d "$as_incr_dir" || mkdir "$as_incr_dir"
- ;;
- esac
-done; }
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
- fi
rm -f $ac_file
mv $tmp/config.h $ac_file
fi
@@ -7439,8 +8788,8 @@ done; }
rm -f $tmp/config.h
fi
done
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
#
# CONFIG_COMMANDS section.
@@ -7448,20 +8797,67 @@ cat >>$CONFIG_STATUS <<\EOF
for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
+$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_dest" : 'X\(//\)[^/]' \| \
+ X"$ac_dest" : 'X\(//\)$' \| \
+ X"$ac_dest" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_dest" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+ { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
+echo "$as_me: executing $ac_dest commands" >&6;}
case $ac_dest in
default ) chmod a+x RunTest pcre-config ;;
esac
done
-EOF
+_ACEOF
-cat >>$CONFIG_STATUS <<\EOF
+cat >>$CONFIG_STATUS <<\_ACEOF
{ (exit 0); exit 0; }
-EOF
+_ACEOF
chmod +x $CONFIG_STATUS
ac_clean_files=$ac_clean_files_save
+
# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
@@ -7472,8 +8868,11 @@ ac_clean_files=$ac_clean_files_save
# need to make the FD available again.
if test "$no_create" != yes; then
ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
exec 5>/dev/null
- $SHELL $CONFIG_STATUS || ac_cs_success=false
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
exec 5>>config.log
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
# would make configure fail if this is the last instruction.
diff --git a/configure.in b/configure.in
index e158d46..77bdaa9 100644
--- a/configure.in
+++ b/configure.in
@@ -16,11 +16,17 @@ dnl macro, and may be treated as octal constants. Stick to single
dnl digits for minor numbers less than 10. There are unlikely to be
dnl that many releases anyway.
-PCRE_MAJOR=3
-PCRE_MINOR=9
-PCRE_DATE=02-Jan-2002
+PCRE_MAJOR=4
+PCRE_MINOR=0
+PCRE_DATE=17-Feb-2003
PCRE_VERSION=${PCRE_MAJOR}.${PCRE_MINOR}
+dnl Default values for miscellaneous macros
+
+POSIX_MALLOC_THRESHOLD=-DPOSIX_MALLOC_THRESHOLD=10
+HOST_CC=${HOST_CC:-'$(CC)'}
+HOST_CFLAGS=${HOST_CFLAGS:-'$(CFLAGS)'}
+
dnl Provide versioning information for libtool shared libraries that
dnl are built by default on Unix systems.
@@ -31,7 +37,8 @@ dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
-AC_PROG_RANLIB
+AC_LIBTOOL_WIN32_DLL
+AC_PROG_LIBTOOL
dnl Checks for header files.
@@ -50,7 +57,7 @@ AC_CHECK_FUNCS(bcopy memmove strerror)
dnl Handle --enable-utf8
AC_ARG_ENABLE(utf8,
-[ --enable-utf8 enable UTF8 support (incomplete)],
+[ --enable-utf8 enable UTF8 support],
if test "$enableval" = "yes"; then
UTF8=-DSUPPORT_UTF8
fi
@@ -74,6 +81,31 @@ if test "$enableval" = "yes"; then
fi
)
+dnl There doesn't seem to be a straightforward way of having parameters
+dnl that set values, other than fudging the --with thing. So that's what
+dnl I've done.
+
+dnl Handle --with-posix-malloc-threshold=n
+
+AC_ARG_WITH(posix-malloc-threshold,
+[ --with-posix-malloc-threshold=5 threshold for POSIX malloc usage],
+ POSIX_MALLOC_THRESHOLD=-DPOSIX_MALLOC_THRESHOLD=$withval
+)
+
+dnl Handle --with-link-size=n
+
+AC_ARG_WITH(link-size,
+[ --with-link-size=2 internal link size (2, 3, or 4 allowed)],
+ LINK_SIZE=-DLINK_SIZE=$withval
+)
+
+dnl Handle --with-match_limit=n
+
+AC_ARG_WITH(match-limit,
+[ --with-match-limit=10000000 default limit on internal looping)],
+ MATCH_LIMIT=-DMATCH_LIMIT=$withval
+)
+
dnl Now arrange to build libtool
AC_PROG_LIBTOOL
@@ -82,7 +114,11 @@ dnl "Export" these variables
AC_SUBST(HAVE_MEMMOVE)
AC_SUBST(HAVE_STRERROR)
+AC_SUBST(HOST_CC)
+AC_SUBST(HOST_CFLAGS)
AC_SUBST(NEWLINE)
+AC_SUBST(LINK_SIZE)
+AC_SUBST(MATCH_LIMIT)
AC_SUBST(UTF8)
AC_SUBST(PCRE_MAJOR)
AC_SUBST(PCRE_MINOR)
@@ -90,6 +126,29 @@ AC_SUBST(PCRE_DATE)
AC_SUBST(PCRE_VERSION)
AC_SUBST(PCRE_LIB_VERSION)
AC_SUBST(PCRE_POSIXLIB_VERSION)
+AC_SUBST(POSIX_MALLOC_THRESHOLD)
+
+dnl Stuff to make Win32 work better
+
+case $host_os in
+mingw* )
+ POSIX_OBJ=pcreposix.o
+ POSIX_LOBJ=pcreposix.lo
+ POSIX_LIB=
+ ;;
+* )
+ POSIX_OBJ=
+ POSIX_LOBJ=
+ POSIX_LIB=libpcreposix.la
+ ;;
+esac
+AC_SUBST(POSIX_OBJ)
+AC_SUBST(POSIX_LOBJ)
+AC_SUBST(POSIX_LIB)
+
+if test "x$enable_shared" = "xno" ; then
+ AC_DEFINE(PCRE_STATIC,1)
+fi
dnl This must be last; it determines what files are written as well as config.h
AC_OUTPUT(Makefile pcre.h:pcre.in pcre-config:pcre-config.in RunTest:RunTest.in,[chmod a+x RunTest pcre-config])
diff --git a/dll.mk b/dll.mk
deleted file mode 100644
index d8b728e..0000000
--- a/dll.mk
+++ /dev/null
@@ -1,60 +0,0 @@
-# dll.mk - auxilary Makefile to easy build dll's for mingw32 target
-# ver. 0.6 of 1999-03-25
-#
-# Homepage of this makefile - http://www.is.lg.ua/~paul/devel/
-# Homepage of original mingw32 project -
-# http://www.fu.is.saga-u.ac.jp/~colin/gcc.html
-#
-# How to use:
-# This makefile can:
-# 1. Create automatical .def file from list of objects
-# 2. Create .dll from objects and .def file, either automatical, or your
-# hand-written (maybe) file, which must have same basename as dll
-# WARNING! There MUST be object, which name match dll's name. Make sux.
-# 3. Create import library from .def (as for .dll, only its name required,
-# not dll itself)
-# By convention implibs for dll have .dll.a suffix, e.g. libstuff.dll.a
-# Why not just libstuff.a? 'Cos that's name for static lib, ok?
-# Process divided into 3 phases because:
-# 1. Pre-existent .def possible
-# 2. Generating implib is enough time-consuming
-#
-# Variables:
-# DLL_LDLIBS - libs for linking dll
-# DLL_LDFLAGS - flags for linking dll
-#
-# By using $(DLL_SUFFIX) instead of 'dll', e.g. stuff.$(DLL_SUFFIX)
-# you may help porting makefiles to other platforms
-#
-# Put this file in your make's include path (e.g. main include dir, for
-# more information see include section in make doc). Put in the beginning
-# of your own Makefile line "include dll.mk". Specify dependences, e.g.:
-#
-# Do all stuff in one step
-# libstuff.dll.a: $(OBJECTS) stuff.def
-# stuff.def: $(OBJECTS)
-#
-# Steps separated, pre-provided .def, link with user32
-#
-# DLL_LDLIBS=-luser32
-# stuff.dll: $(OBJECTS)
-# libstuff.dll.a: $(OBJECTS)
-
-
-DLLWRAP=dllwrap
-DLLTOOL=dlltool
-
-DLL_SUFFIX=dll
-
-.SUFFIXES: .o .$(DLL_SUFFIX)
-
-_%.def: %.o
- $(DLLTOOL) --export-all --output-def $@ $^
-
-%.$(DLL_SUFFIX): %.o
- $(DLLWRAP) --dllname $(notdir $@) --driver-name $(CC) --def $*.def -o $@ $(filter %.o,$^) $(DLL_LDFLAGS) $(DLL_LDLIBS)
-
-lib%.$(DLL_SUFFIX).a:%.def
- $(DLLTOOL) --dllname $(notdir $*.dll) --def $< --output-lib $@
-
-# End
diff --git a/doc/Tech.Notes b/doc/Tech.Notes
index f5ca280..dd01932 100644
--- a/doc/Tech.Notes
+++ b/doc/Tech.Notes
@@ -6,14 +6,14 @@ suggested by Martin Richards. These were not Unix-like in form, and were quite
restricted in what they could do by comparison with Perl. The interesting part
about the algorithm was that the amount of space required to hold the compiled
form of an expression was known in advance. The code to apply an expression did
-not operate by backtracking, as the Henry Spencer and Perl code does, but
-instead checked all possibilities simultaneously by keeping a list of current
-states and checking all of them as it advanced through the subject string. (In
-the terminology of Jeffrey Friedl's book, it was a "DFA algorithm".) When the
-pattern was all used up, all remaining states were possible matches, and the
-one matching the longest subset of the subject string was chosen. This did not
-necessarily maximize the individual wild portions of the pattern, as is
-expected in Unix and Perl-style regular expressions.
+not operate by backtracking, as the original Henry Spencer code and current
+Perl code does, but instead checked all possibilities simultaneously by keeping
+a list of current states and checking all of them as it advanced through the
+subject string. (In the terminology of Jeffrey Friedl's book, it was a "DFA
+algorithm".) When the pattern was all used up, all remaining states were
+possible matches, and the one matching the longest subset of the subject string
+was chosen. This did not necessarily maximize the individual wild portions of
+the pattern, as is expected in Unix and Perl-style regular expressions.
By contrast, the code originally written by Henry Spencer and subsequently
heavily modified for Perl actually compiles the expression twice: once in a
@@ -28,14 +28,13 @@ mentioned above), I tried at first to invent an algorithm that used an amount
of store bounded by a multiple of the number of characters in the pattern, to
save on compiling time. However, because of the greater complexity in Perl
regular expressions, I couldn't do this. In any case, a first pass through the
-pattern is needed, in order to find internal flag settings like (?i) at top
-level. So PCRE works by running a very degenerate first pass to calculate a
-maximum store size, and then a second pass to do the real compile - which may
-use a bit less than the predicted amount of store. The idea is that this is
-going to turn out faster because the first pass is degenerate and the second
-pass can just store stuff straight into the vector. It does make the compiling
-functions bigger, of course, but they have got quite big anyway to handle all
-the Perl stuff.
+pattern is needed, for a number of reasons. PCRE works by running a very
+degenerate first pass to calculate a maximum store size, and then a second pass
+to do the real compile - which may use a bit less than the predicted amount of
+store. The idea is that this is going to turn out faster because the first pass
+is degenerate and the second pass can just store stuff straight into the
+vector. It does make the compiling functions bigger, of course, but they have
+got quite big anyway to handle all the Perl stuff.
The compiled form of a pattern is a vector of bytes, containing items of
variable length. The first byte in an item is an opcode, and the length of the
@@ -120,17 +119,25 @@ instances of OP_CHARS are used.
Character classes
-----------------
-OP_CLASS is used for a character class, provided there are at least two
-characters in the class. If there is only one character, OP_CHARS is used for a
-positive class, and OP_NOT for a negative one (that is, for something like
-[^a]). Another set of repeating opcodes (OP_NOTSTAR etc.) are used for a
-repeated, negated, single-character class. The normal ones (OP_STAR etc.) are
-used for a repeated positive single-character class.
+When characters less than 256 are involved, OP_CLASS is used for a character
+class. If there is only one character, OP_CHARS is used for a positive class,
+and OP_NOT for a negative one (that is, for something like [^a]). However, in
+UTF-8 mode, this applies only to characters with values < 128, because OP_NOT
+is confined to single bytes.
+
+Another set of repeating opcodes (OP_NOTSTAR etc.) are used for a repeated,
+negated, single-character class. The normal ones (OP_STAR etc.) are used for a
+repeated positive single-character class.
OP_CLASS is followed by a 32-byte bit map containing a 1 bit for every
character that is acceptable. The bits are counted from the least significant
end of each byte.
+For classes containing characters with values > 255, OP_XCLASS is used. It
+optionally uses a bit map (if any characters lie within it), followed by a list
+of pairs and single characters. There is a flag character than indicates
+whether it's a positive or a negative class.
+
Back references
---------------
@@ -231,23 +238,23 @@ Conditional subpatterns
These are like other subpatterns, but they start with the opcode OP_COND. If
the condition is a back reference, this is stored at the start of the
subpattern using the opcode OP_CREF followed by two bytes containing the
-reference number. Otherwise, a conditional subpattern will always start with
-one of the assertions.
+reference number. If the condition is "in recursion" (coded as "(?(R)"), the
+same scheme is used, with a "reference number" of 0xffff. Otherwise, a
+conditional subpattern always starts with one of the assertions.
Changing options
----------------
-If any of the /i, /m, or /s options are changed within a parenthesized group,
-an OP_OPT opcode is compiled, followed by one byte containing the new settings
-of these flags. If there are several alternatives in a group, there is an
-occurrence of OP_OPT at the start of all those following the first options
-change, to set appropriate options for the start of the alternative.
-Immediately after the end of the group there is another such item to reset the
-flags to their previous values. Other changes of flag within the pattern can be
-handled entirely at compile time, and so do not cause anything to be put into
-the compiled data.
-
+If any of the /i, /m, or /s options are changed within a pattern, an OP_OPT
+opcode is compiled, followed by one byte containing the new settings of these
+flags. If there are several alternatives, there is an occurrence of OP_OPT at
+the start of all those following the first options change, to set appropriate
+options for the start of the alternative. Immediately after the end of the
+group there is another such item to reset the flags to their previous values. A
+change of flag right at the very start of the pattern can be handled entirely
+at compile time, and so does not cause anything to be put into the compiled
+data.
Philip Hazel
-August 2001
+August 2002
diff --git a/doc/html/.html b/doc/html/.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/doc/html/.html
diff --git a/doc/html/index.html b/doc/html/index.html
new file mode 100644
index 0000000..3751ff0
--- /dev/null
+++ b/doc/html/index.html
@@ -0,0 +1,102 @@
+<html>
+<head>
+<title>PCRE specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>Perl-compatible Regular Expressions (PCRE)</h1>
+<p>
+The HTML documentation for PCRE comprises the following pages:
+</p>
+
+<table>
+<tr><td><a href="pcre.html">pcre</a></td>
+ <td>&nbsp;&nbsp;Introductory page</td></tr>
+
+<tr><td><a href="pcreapi.html">pcreapi</a></td>
+ <td>&nbsp;&nbsp;PCRE's native API</td></tr>
+
+<tr><td><a href="pcrebuild.html">pcrebuild</a></td>
+ <td>&nbsp;&nbsp;Options for building PCRE</td></tr>
+
+<tr><td><a href="pcrecallout.html">pcrecallout</a></td>
+ <td>&nbsp;&nbsp;The <i>callout</i> facility</td></tr>
+
+<tr><td><a href="pcrecompat.html">pcrecompat</a></td>
+ <td>&nbsp;&nbsp;Compability with Perl</td></tr>
+
+<tr><td><a href="pcregrep.html">pcregrep</a></td>
+ <td>&nbsp;&nbsp;The <b>pcregrep</b> command</td></tr>
+
+<tr><td><a href="pcrepattern.html">pcrepattern</a></td>
+ <td>&nbsp;&nbsp;Regular expressions supported by PCRE</td></tr>
+
+<tr><td><a href="pcreperform.html">pcreperform</a></td>
+ <td>&nbsp;&nbsp;Some comments on performance</td></tr>
+
+<tr><td><a href="pcreposix.html">pcreposix</a></td>
+ <td>&nbsp;&nbsp;The POSIX API to the PCRE library</td></tr>
+
+<tr><td><a href="pcresample.html">pcresample</a></td>
+ <td>&nbsp;&nbsp;Description of the sample program</td></tr>
+
+<tr><td><a href="pcretest.html">pcretest</a></td>
+ <td>&nbsp;&nbsp;The <b>pcretest</b> command for testing PCRE</td></tr>
+</table>
+
+<p>
+There are also individual pages that summarize the interface for each function
+in the library:
+</p>
+
+<table>
+
+<tr><td><a href="pcre_compile.html">pcre_compile</a></td>
+ <td>&nbsp;&nbsp;Compile a regular expression</td></tr>
+
+<tr><td><a href="pcre_config.html">pcre_config</a></td>
+ <td>&nbsp;&nbsp;Show build-time configuration options</td></tr>
+
+<tr><td><a href="pcre_copy_named_substring.html">pcre_copy_named_substring</a></td>
+ <td>&nbsp;&nbsp;Extract named substring into given buffer</td></tr>
+
+<tr><td><a href="pcre_copy_substring.html">pcre_copy_substring</a></td>
+ <td>&nbsp;&nbsp;Extract numbered substring into given buffer</td></tr>
+
+<tr><td><a href="pcre_exec.html">pcre_exec</a></td>
+ <td>&nbsp;&nbsp;Match a compiled pattern to a subject string</td></tr>
+
+<tr><td><a href="pcre_free_substring.html">pcre_free_substring</a></td>
+ <td>&nbsp;&nbsp;Free extracted substring</td></tr>
+
+<tr><td><a href="pcre_free_substring_list.html">pcre_free_substring_list</a></td>
+ <td>&nbsp;&nbsp;Free list of extracted substrings</td></tr>
+
+<tr><td><a href="pcre_fullinfo.html">pcre_fullinfo</a></td>
+ <td>&nbsp;&nbsp;Extract information about a pattern</td></tr>
+
+<tr><td><a href="pcre_get_named_substring.html">pcre_get_named_substring</a></td>
+ <td>&nbsp;&nbsp;Extract named substring into new memory</td></tr>
+
+<tr><td><a href="pcre_get_stringnumber.html">pcre_get_stringnumber</a></td>
+ <td>&nbsp;&nbsp;Convert captured string name to number</td></tr>
+
+<tr><td><a href="pcre_get_substring.html">pcre_get_substring</a></td>
+ <td>&nbsp;&nbsp;Extract numbered substring into new memory</td></tr>
+
+<tr><td><a href="pcre_get_substring_list.html">pcre_get_substring_list</a></td>
+ <td>&nbsp;&nbsp;Extract all substrings into new memory</td></tr>
+
+<tr><td><a href="pcre_info.html">pcre_info</a></td>
+ <td>&nbsp;&nbsp;Obsolete information extraction function</td></tr>
+
+<tr><td><a href="pcre_maketables.html">pcre_maketables</a></td>
+ <td>&nbsp;&nbsp;Build character tables in current locale</td></tr>
+
+<tr><td><a href="pcre_study.html">pcre_study</a></td>
+ <td>&nbsp;&nbsp;Study a compiled pattern</td></tr>
+
+<tr><td><a href="pcre_version.html">pcre_version</a></td>
+ <td>&nbsp;&nbsp;Return PCRE version and release date</td></tr>
+</table>
+
+</html>
diff --git a/doc/html/pcre.html b/doc/html/pcre.html
new file mode 100644
index 0000000..fb319f3
--- /dev/null
+++ b/doc/html/pcre.html
@@ -0,0 +1,183 @@
+<html>
+<head>
+<title>pcre specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">DESCRIPTION</a>
+<li><a name="TOC2" href="#SEC2">USER DOCUMENTATION</a>
+<li><a name="TOC3" href="#SEC3">LIMITATIONS</a>
+<li><a name="TOC4" href="#SEC4">UTF-8 SUPPORT</a>
+<li><a name="TOC5" href="#SEC5">AUTHOR</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">DESCRIPTION</a><br>
+<P>
+The PCRE library is a set of functions that implement regular expression
+pattern matching using the same syntax and semantics as Perl, with just a few
+differences. The current implementation of PCRE (release 4.x) corresponds
+approximately with Perl 5.8, including support for UTF-8 encoded strings.
+However, this support has to be explicitly enabled; it is not the default.
+</P>
+<P>
+PCRE is written in C and released as a C library. However, a number of people
+have written wrappers and interfaces of various kinds. A C++ class is included
+in these contributions, which can be found in the <i>Contrib</i> directory at
+the primary FTP site, which is:
+</P>
+<a href="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre">ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre</a>
+<P>
+Details of exactly which Perl regular expression features are and are not
+supported by PCRE are given in separate documents. See the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+and
+<a href="pcrecompat.html"><b>pcrecompat</b></a>
+pages.
+</P>
+<P>
+Some features of PCRE can be included, excluded, or changed when the library is
+built. The
+<a href="pcre_config.html"><b>pcre_config()</b></a>
+function makes it possible for a client to discover which features are
+available. Documentation about building PCRE for various operating systems can
+be found in the <b>README</b> file in the source distribution.
+</P>
+<br><a name="SEC2" href="#TOC1">USER DOCUMENTATION</a><br>
+<P>
+The user documentation for PCRE has been split up into a number of different
+sections. In the "man" format, each of these is a separate "man page". In the
+HTML format, each is a separate page, linked from the index page. In the plain
+text format, all the sections are concatenated, for ease of searching. The
+sections are as follows:
+</P>
+<P>
+<pre>
+ pcre this document
+ pcreapi details of PCRE's native API
+ pcrebuild options for building PCRE
+ pcrecallout details of the callout feature
+ pcrecompat discussion of Perl compatibility
+ pcregrep description of the <b>pcregrep</b> command
+ pcrepattern syntax and semantics of supported
+ regular expressions
+ pcreperform discussion of performance issues
+ pcreposix the POSIX-compatible API
+ pcresample discussion of the sample program
+ pcretest the <b>pcretest</b> testing command
+</PRE>
+</P>
+<P>
+In addition, in the "man" and HTML formats, there is a short page for each
+library function, listing its arguments and results.
+</P>
+<br><a name="SEC3" href="#TOC1">LIMITATIONS</a><br>
+<P>
+There are some size limitations in PCRE but it is hoped that they will never in
+practice be relevant.
+</P>
+<P>
+The maximum length of a compiled pattern is 65539 (sic) bytes if PCRE is
+compiled with the default internal linkage size of 2. If you want to process
+regular expressions that are truly enormous, you can compile PCRE with an
+internal linkage size of 3 or 4 (see the <b>README</b> file in the source
+distribution and the
+<a href="pcrebuild.html"><b>pcrebuild</b></a>
+documentation for details). If these cases the limit is substantially larger.
+However, the speed of execution will be slower.
+</P>
+<P>
+All values in repeating quantifiers must be less than 65536.
+The maximum number of capturing subpatterns is 65535.
+</P>
+<P>
+There is no limit to the number of non-capturing subpatterns, but the maximum
+depth of nesting of all kinds of parenthesized subpattern, including capturing
+subpatterns, assertions, and other types of subpattern, is 200.
+</P>
+<P>
+The maximum length of a subject string is the largest positive number that an
+integer variable can hold. However, PCRE uses recursion to handle subpatterns
+and indefinite repetition. This means that the available stack space may limit
+the size of a subject string that can be processed by certain patterns.
+</P>
+<a name="utf8support"></a><br><a name="SEC4" href="#TOC1">UTF-8 SUPPORT</a><br>
+<P>
+Starting at release 3.3, PCRE has had some support for character strings
+encoded in the UTF-8 format. For release 4.0 this has been greatly extended to
+cover most common requirements.
+</P>
+<P>
+In order process UTF-8 strings, you must build PCRE to include UTF-8 support in
+the code, and, in addition, you must call
+<a href="pcre_compile.html"><b>pcre_compile()</b></a>
+with the PCRE_UTF8 option flag. When you do this, both the pattern and any
+subject strings that are matched against it are treated as UTF-8 strings
+instead of just strings of bytes.
+</P>
+<P>
+If you compile PCRE with UTF-8 support, but do not use it at run time, the
+library will be a bit bigger, but the additional run time overhead is limited
+to testing the PCRE_UTF8 flag in several places, so should not be very large.
+</P>
+<P>
+The following comments apply when PCRE is running in UTF-8 mode:
+</P>
+<P>
+1. PCRE assumes that the strings it is given contain valid UTF-8 codes. It does
+not diagnose invalid UTF-8 strings. If you pass invalid UTF-8 strings to PCRE,
+the results are undefined.
+</P>
+<P>
+2. In a pattern, the escape sequence \x{...}, where the contents of the braces
+is a string of hexadecimal digits, is interpreted as a UTF-8 character whose
+code number is the given hexadecimal number, for example: \x{1234}. If a
+non-hexadecimal digit appears between the braces, the item is not recognized.
+This escape sequence can be used either as a literal, or within a character
+class.
+</P>
+<P>
+3. The original hexadecimal escape sequence, \xhh, matches a two-byte UTF-8
+character if the value is greater than 127.
+</P>
+<P>
+4. Repeat quantifiers apply to complete UTF-8 characters, not to individual
+bytes, for example: \x{100}{3}.
+</P>
+<P>
+5. The dot metacharacter matches one UTF-8 character instead of a single byte.
+</P>
+<P>
+6. The escape sequence \C can be used to match a single byte in UTF-8 mode,
+but its use can lead to some strange effects.
+</P>
+<P>
+7. The character escapes \b, \B, \d, \D, \s, \S, \w, and \W correctly
+test characters of any code value, but the characters that PCRE recognizes as
+digits, spaces, or word characters remain the same set as before, all with
+values less than 256.
+</P>
+<P>
+8. Case-insensitive matching applies only to characters whose values are less
+than 256. PCRE does not support the notion of "case" for higher-valued
+characters.
+</P>
+<P>
+9. PCRE does not support the use of Unicode tables and properties or the Perl
+escapes \p, \P, and \X.
+</P>
+<br><a name="SEC5" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel &#60;ph10@cam.ac.uk&#62;
+<br>
+University Computing Service,
+<br>
+Cambridge CB2 3QG, England.
+<br>
+Phone: +44 1223 334714
+</P>
+<P>
+Last updated: 04 February 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/html/pcre_compile.html b/doc/html/pcre_compile.html
new file mode 100644
index 0000000..0b21683
--- /dev/null
+++ b/doc/html/pcre_compile.html
@@ -0,0 +1,67 @@
+<html>
+<head>
+<title>pcre_compile specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>pcre *pcre_compile(const char *<i>pattern</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function compiles a regular expression into an internal form. Its
+arguments are:
+</P>
+<P>
+<pre>
+ <i>pattern</i> A zero-terminated string containing the
+ regular expression to be compiled
+ <i>options</i> Zero or more option bits
+ <i>errptr</i> Where to put an error message
+ <i>erroffset</i> Offset in pattern where error was found
+ <i>tableptr</i> Pointer to character tables, or NULL to
+ use the built-in default
+</PRE>
+</P>
+<P>
+The option bits are:
+</P>
+<P>
+<pre>
+ PCRE_ANCHORED Force pattern anchoring
+ PCRE_CASELESS Do caseless matching
+ PCRE_DOLLAR_ENDONLY $ not to match newline at end
+ PCRE_DOTALL . matches anything including NL
+ PCRE_EXTENDED Ignore whitespace and # comments
+ PCRE_EXTRA PCRE extra features
+ (not much use currently)
+ PCRE_MULTILINE ^ and $ match newlines within data
+ PCRE_NO_AUTO_CAPTURE Disable numbered capturing paren-
+ theses (named ones available)
+ PCRE_UNGREEDY Invert greediness of quantifiers
+ PCRE_UTF8 Run in UTF-8 mode
+</PRE>
+</P>
+<P>
+PCRE must have been compiled with UTF-8 support when PCRE_UTF8 is used.
+</P>
+<P>
+The yield of the function is a pointer to a private data structure that
+contains the compiled pattern, or NULL if an error was detected.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_config.html b/doc/html/pcre_config.html
new file mode 100644
index 0000000..30c601a
--- /dev/null
+++ b/doc/html/pcre_config.html
@@ -0,0 +1,55 @@
+<html>
+<head>
+<title>pcre_config specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function makes it possible for a client program to find out which optional
+features are available in the version of the PCRE library it is using. Its
+arguments are as follows:
+</P>
+<P>
+<pre>
+ <i>what</i> A code specifying what information is required
+ <i>where</i> Points to where to put the data
+</PRE>
+</P>
+<P>
+The available codes are:
+</P>
+<P>
+<pre>
+ PCRE_CONFIG_LINK_SIZE Internal link size: 2, 3, or 4
+ PCRE_CONFIG_MATCH_LIMIT Internal resource limit
+ PCRE_CONFIG_NEWLINE Value of the newline character
+ PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+ Threshold of return slots, above
+ which <b>malloc()</b> is used by
+ the POSIX API
+ PCRE_CONFIG_UTF8 Availability of UTF-8 support
+</PRE>
+</P>
+<P>
+The function yields 0 on success or PCRE_ERROR_BADOPTION otherwise.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page, and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
diff --git a/doc/html/pcre_copy_named_substring.html b/doc/html/pcre_copy_named_substring.html
new file mode 100644
index 0000000..3b1da36
--- /dev/null
+++ b/doc/html/pcre_copy_named_substring.html
@@ -0,0 +1,46 @@
+<html>
+<head>
+<title>pcre_copy_named_substring specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_copy_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>char *<i>buffer</i>, int <i>buffersize</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for extracting a captured substring, identified
+by name, into a given buffer. The arguments are:
+</P>
+<P>
+<pre>
+ <i>code</i> Pattern that was successfully matched
+ <i>subject</i> Subject that has been successfully matched
+ <i>ovector</i> Offset vector that <b>pcre_exec()</b> used
+ <i>stringcount</i> Value returned by <b>pcre_exec()</b>
+ <i>stringname</i> Name of the required substring
+ <i>buffer</i> Buffer to receive the string
+ <i>buffersize</i> Size of buffer
+</PRE>
+</P>
+<P>
+The yield is the length of the substring, PCRE_ERROR_NOMEMORY if the buffer was
+too small, or PCRE_ERROR_NOSUBSTRING if the string name is invalid.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_copy_substring.html b/doc/html/pcre_copy_substring.html
new file mode 100644
index 0000000..f5b9b55
--- /dev/null
+++ b/doc/html/pcre_copy_substring.html
@@ -0,0 +1,44 @@
+<html>
+<head>
+<title>pcre_copy_substring specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_copy_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>, char *<i>buffer</i>,</b>
+<b>int <i>buffersize</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for extracting a captured substring into a given
+buffer. The arguments are:
+</P>
+<P>
+<pre>
+ <i>subject</i> Subject that has been successfully matched
+ <i>ovector</i> Offset vector that <b>pcre_exec()</b> used
+ <i>stringcount</i> Value returned by <b>pcre_exec()</b>
+ <i>stringnumber</i> Number of the required substring
+ <i>buffer</i> Buffer to receive the string
+ <i>buffersize</i> Size of buffer
+</PRE>
+</P>
+<P>
+The yield is the legnth of the string, PCRE_ERROR_NOMEMORY if the buffer was
+too small, or PCRE_ERROR_NOSUBSTRING if the string number is invalid.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_exec.html b/doc/html/pcre_exec.html
new file mode 100644
index 0000000..915bc73
--- /dev/null
+++ b/doc/html/pcre_exec.html
@@ -0,0 +1,55 @@
+<html>
+<head>
+<title>pcre_exec specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function matches a compiled regular expression against a given subject
+string, and returns offsets to capturing subexpressions. Its arguments are:
+</P>
+<P>
+<pre>
+ <i>code</i> Points to the compiled pattern
+ <i>extra</i> Points to an associated <b>pcre_extra</b> structure,
+ or is NULL
+ <i>subject</i> Points to the subject string
+ <i>length</i> Length of the subject string, in bytes
+ <i>startoffset</i> Offset in bytes in the subject at which to
+ start matching
+ <i>options</i> Option bits
+ <i>ovector</i> Points to a vector of ints for result offsets
+ <i>ovecsize</i> Size of the vector (a multiple of 3)
+</PRE>
+</P>
+<P>
+The options are:
+</P>
+<P>
+<pre>
+ PCRE_ANCHORED Match only at the first position
+ PCRE_NOTBOL Subject is not the beginning of a line
+ PCRE_NOTEOL Subject is not the end of a line
+ PCRE_NOTEMPTY An empty string is not a valid match
+</PRE>
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_free_substring.html b/doc/html/pcre_free_substring.html
new file mode 100644
index 0000000..08b1607
--- /dev/null
+++ b/doc/html/pcre_free_substring.html
@@ -0,0 +1,29 @@
+<html>
+<head>
+<title>pcre_free_substring specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>void pcre_free_substring(const char *<i>stringptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for freeing the store obtained by a previous
+call to <b>pcre_get_substring()</b> or <b>pcre_get_named_substring()</b>. Its
+only argument is a pointer to the string.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_free_substring_list.html b/doc/html/pcre_free_substring_list.html
new file mode 100644
index 0000000..c130f28
--- /dev/null
+++ b/doc/html/pcre_free_substring_list.html
@@ -0,0 +1,29 @@
+<html>
+<head>
+<title>pcre_free_substring_list specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>void pcre_free_substring_list(const char **<i>stringptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for freeing the store obtained by a previous
+call to <b>pcre_get_substring_list()</b>. Its only argument is a pointer to the
+list of string pointers.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_fullinfo.html b/doc/html/pcre_fullinfo.html
new file mode 100644
index 0000000..f43fa65
--- /dev/null
+++ b/doc/html/pcre_fullinfo.html
@@ -0,0 +1,68 @@
+<html>
+<head>
+<title>pcre_fullinfo specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_fullinfo(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function returns information about a compiled pattern. Its arguments are:
+</P>
+<P>
+<pre>
+ <i>code</i> Compiled regular expression
+ <i>extra</i> Result of <b>pcre_study()</b> or NULL
+ <i>what</i> What information is required
+ <i>where</i> Where to put the information
+</PRE>
+</P>
+<P>
+The following information is available:
+</P>
+<P>
+<pre>
+ PCRE_INFO_BACKREFMAX Number of highest back reference
+ PCRE_INFO_CAPTURECOUNT Number of capturing subpatterns
+ PCRE_INFO_FIRSTBYTE Fixed first byte for a match, or
+ -1 for start of string
+ or after newline, or
+ -2 otherwise
+ PCRE_INFO_FIRSTTABLE Table of first bytes
+ (after studying)
+ PCRE_INFO_LASTLITERAL Literal last byte required
+ PCRE_INFO_NAMECOUNT Number of named subpatterns
+ PCRE_INFO_NAMEENTRYSIZE Size of name table entry
+ PCRE_INFO_NAMETABLE Pointer to name table
+ PCRE_INFO_OPTIONS Options used for compilation
+ PCRE_INFO_SIZE Size of compiled pattern
+</PRE>
+</P>
+<P>
+The yield of the function is zero on success or:
+</P>
+<P>
+<pre>
+ PCRE_ERROR_NULL the argument <i>code</i> was NULL
+ the argument <i>where</i> was NULL
+ PCRE_ERROR_BADMAGIC the "magic number" was not found
+ PCRE_ERROR_BADOPTION the value of <i>what</i> was invalid
+</PRE>
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_get_named_substring.html b/doc/html/pcre_get_named_substring.html
new file mode 100644
index 0000000..89a2bee
--- /dev/null
+++ b/doc/html/pcre_get_named_substring.html
@@ -0,0 +1,46 @@
+<html>
+<head>
+<title>pcre_get_named_substring specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_get_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for extracting a captured substring by name. The
+arguments are:
+</P>
+<P>
+<pre>
+ <i>code</i> Compiled pattern
+ <i>subject</i> Subject that has been successfully matched
+ <i>ovector</i> Offset vector that <b>pcre_exec()</b> used
+ <i>stringcount</i> Value returned by <b>pcre_exec()</b>
+ <i>stringname</i> Name of the required substring
+ <i>stringptr</i> Where to put the string pointer
+</PRE>
+</P>
+<P>
+The yield is the length of the extracted substring, PCRE_ERROR_NOMEMORY if
+sufficient memory could not be obtained, or PCRE_ERROR_NOSUBSTRING if the
+string name is invalid.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_get_stringnumber.html b/doc/html/pcre_get_stringnumber.html
new file mode 100644
index 0000000..ee1c0a9
--- /dev/null
+++ b/doc/html/pcre_get_stringnumber.html
@@ -0,0 +1,39 @@
+<html>
+<head>
+<title>pcre_get_stringnumber specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_get_stringnumber(const pcre *<i>code</i>,</b>
+<b>const char *<i>name</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This convenience function finds the number of a named substring capturing
+parenthesis in a compiled pattern. Its arguments are:
+</P>
+<P>
+<pre>
+ <i>code</i> Compiled regular expression
+ <i>name</i> Name whose number is required
+</PRE>
+</P>
+<P>
+The yield of the function is the number of the parenthesis if the name is
+found, or PCRE_ERROR_NOSUBSTRING otherwise.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_get_substring.html b/doc/html/pcre_get_substring.html
new file mode 100644
index 0000000..2a55c10
--- /dev/null
+++ b/doc/html/pcre_get_substring.html
@@ -0,0 +1,44 @@
+<html>
+<head>
+<title>pcre_get_substring specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_get_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for extracting a captured substring. The
+arguments are:
+</P>
+<P>
+<pre>
+ <i>subject</i> Subject that has been successfully matched
+ <i>ovector</i> Offset vector that <b>pcre_exec()</b> used
+ <i>stringcount</i> Value returned by <b>pcre_exec()</b>
+ <i>stringnumber</i> Number of the required substring
+ <i>stringptr</i> Where to put the string pointer
+</PRE>
+</P>
+<P>
+The yield is the length of the substring, PCRE_ERROR_NOMEMORY if sufficient
+memory could not be obtained, or PCRE_ERROR_NOSUBSTRING if the string number is
+invalid.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_get_substring_list.html b/doc/html/pcre_get_substring_list.html
new file mode 100644
index 0000000..7e91f56
--- /dev/null
+++ b/doc/html/pcre_get_substring_list.html
@@ -0,0 +1,41 @@
+<html>
+<head>
+<title>pcre_get_substring_list specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_get_substring_list(const char *<i>subject</i>,</b>
+<b>int *<i>ovector</i>, int <i>stringcount</i>, const char ***<i>listptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for extracting a list of all the captured
+substrings. The arguments are:
+</P>
+<P>
+<pre>
+ <i>subject</i> Subject that has been successfully matched
+ <i>ovector</i> Offset vector that <b>pcre_exec</b> used
+ <i>stringcount</i> Value returned by <b>pcre_exec</b>
+ <i>listptr</i> Where to put a pointer to the list
+</PRE>
+</P>
+<P>
+The yield is zero on success or PCRE_ERROR_NOMEMORY if sufficient memory could
+not be obtained.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_info.html b/doc/html/pcre_info.html
new file mode 100644
index 0000000..97fc59b
--- /dev/null
+++ b/doc/html/pcre_info.html
@@ -0,0 +1,28 @@
+<html>
+<head>
+<title>pcre_info specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
+<b>*<i>firstcharptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function is obsolete. You should be using <b>pcre_fullinfo()</b> instead.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_maketables.html b/doc/html/pcre_maketables.html
new file mode 100644
index 0000000..ba3e026
--- /dev/null
+++ b/doc/html/pcre_maketables.html
@@ -0,0 +1,31 @@
+<html>
+<head>
+<title>pcre_maketables specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>const unsigned char *pcre_maketables(void);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function builds a set of character tables which can be passed to
+<b>pcre_compile()</b> to override PCRE's internal, built-in tables (which were
+made by <b>pcre_maketables()</b> when PCRE was compiled). You might want to do
+this if you are using a non-standard locale. The function yields a pointer to
+the tables.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_study.html b/doc/html/pcre_study.html
new file mode 100644
index 0000000..f3727d1
--- /dev/null
+++ b/doc/html/pcre_study.html
@@ -0,0 +1,45 @@
+<html>
+<head>
+<title>pcre_study specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>pcre_extra *pcre_study(const pcre *<i>code</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function studies a compiled pattern, to see if additional information can
+be extracted that might speed up matching. Its arguments are:
+</P>
+<P>
+<pre>
+ <i>code</i> A compiled regular expression
+ <i>options</i> Options for <b>pcre_study()</b>
+ <i>errptr</i> Where to put an error message
+</PRE>
+</P>
+<P>
+If the function returns NULL, either it could not find any additional
+information, or there was an error. You can tell the difference by looking at
+the error value. It is NULL in first case.
+</P>
+<P>
+There are currently no options defined; the value of the second argument should
+always be zero.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcre_version.html b/doc/html/pcre_version.html
new file mode 100644
index 0000000..35c47cd
--- /dev/null
+++ b/doc/html/pcre_version.html
@@ -0,0 +1,28 @@
+<html>
+<head>
+<title>pcre_version specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>char *pcre_version(void);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function returns a character string that gives the version number of the
+PCRE library, and its date of release.
+</P>
+<P>
+There is a complete description of the PCRE API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page.
diff --git a/doc/html/pcreapi.html b/doc/html/pcreapi.html
new file mode 100644
index 0000000..3bc71b1
--- /dev/null
+++ b/doc/html/pcreapi.html
@@ -0,0 +1,1260 @@
+<html>
+<head>
+<title>pcreapi specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">SYNOPSIS OF PCRE API</a>
+<li><a name="TOC2" href="#SEC2">PCRE API</a>
+<li><a name="TOC3" href="#SEC3">MULTITHREADING</a>
+<li><a name="TOC4" href="#SEC4">CHECKING BUILD-TIME OPTIONS</a>
+<li><a name="TOC5" href="#SEC5">COMPILING A PATTERN</a>
+<li><a name="TOC6" href="#SEC6">STUDYING A PATTERN</a>
+<li><a name="TOC7" href="#SEC7">LOCALE SUPPORT</a>
+<li><a name="TOC8" href="#SEC8">INFORMATION ABOUT A PATTERN</a>
+<li><a name="TOC9" href="#SEC9">OBSOLETE INFO FUNCTION</a>
+<li><a name="TOC10" href="#SEC10">MATCHING A PATTERN</a>
+<li><a name="TOC11" href="#SEC11">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a>
+<li><a name="TOC12" href="#SEC12">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">SYNOPSIS OF PCRE API</a><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>pcre *pcre_compile(const char *<i>pattern</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
+<P>
+<b>pcre_extra *pcre_study(const pcre *<i>code</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>);</b>
+</P>
+<P>
+<b>int pcre_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
+</P>
+<P>
+<b>int pcre_copy_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>char *<i>buffer</i>, int <i>buffersize</i>);</b>
+</P>
+<P>
+<b>int pcre_copy_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>, char *<i>buffer</i>,</b>
+<b>int <i>buffersize</i>);</b>
+</P>
+<P>
+<b>int pcre_get_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<P>
+<b>int pcre_get_stringnumber(const pcre *<i>code</i>,</b>
+<b>const char *<i>name</i>);</b>
+</P>
+<P>
+<b>int pcre_get_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<P>
+<b>int pcre_get_substring_list(const char *<i>subject</i>,</b>
+<b>int *<i>ovector</i>, int <i>stringcount</i>, const char ***<i>listptr</i>);</b>
+</P>
+<P>
+<b>void pcre_free_substring(const char *<i>stringptr</i>);</b>
+</P>
+<P>
+<b>void pcre_free_substring_list(const char **<i>stringptr</i>);</b>
+</P>
+<P>
+<b>const unsigned char *pcre_maketables(void);</b>
+</P>
+<P>
+<b>int pcre_fullinfo(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<P>
+<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
+<b>*<i>firstcharptr</i>);</b>
+</P>
+<P>
+<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<P>
+<b>char *pcre_version(void);</b>
+</P>
+<P>
+<b>void *(*pcre_malloc)(size_t);</b>
+</P>
+<P>
+<b>void (*pcre_free)(void *);</b>
+</P>
+<P>
+<b>int (*pcre_callout)(pcre_callout_block *);</b>
+</P>
+<br><a name="SEC2" href="#TOC1">PCRE API</a><br>
+<P>
+PCRE has its own native API, which is described in this document. There is also
+a set of wrapper functions that correspond to the POSIX regular expression API.
+These are described in the <b>pcreposix</b> documentation.
+</P>
+<P>
+The native API function prototypes are defined in the header file <b>pcre.h</b>,
+and on Unix systems the library itself is called <b>libpcre.a</b>, so can be
+accessed by adding <b>-lpcre</b> to the command for linking an application which
+calls it. The header file defines the macros PCRE_MAJOR and PCRE_MINOR to
+contain the major and minor release numbers for the library. Applications can
+use these to include support for different releases.
+</P>
+<P>
+The functions <b>pcre_compile()</b>, <b>pcre_study()</b>, and <b>pcre_exec()</b>
+are used for compiling and matching regular expressions. A sample program that
+demonstrates the simplest way of using them is given in the file
+<i>pcredemo.c</i>. The <b>pcresample</b> documentation describes how to run it.
+</P>
+<P>
+There are convenience functions for extracting captured substrings from a
+matched subject string. They are:
+</P>
+<P>
+<pre>
+ <b>pcre_copy_substring()</b>
+ <b>pcre_copy_named_substring()</b>
+ <b>pcre_get_substring()</b>
+ <b>pcre_get_named_substring()</b>
+ <b>pcre_get_substring_list()</b>
+</PRE>
+</P>
+<P>
+<b>pcre_free_substring()</b> and <b>pcre_free_substring_list()</b> are also
+provided, to free the memory used for extracted strings.
+</P>
+<P>
+The function <b>pcre_maketables()</b> is used (optionally) to build a set of
+character tables in the current locale for passing to <b>pcre_compile()</b>.
+</P>
+<P>
+The function <b>pcre_fullinfo()</b> is used to find out information about a
+compiled pattern; <b>pcre_info()</b> is an obsolete version which returns only
+some of the available information, but is retained for backwards compatibility.
+The function <b>pcre_version()</b> returns a pointer to a string containing the
+version of PCRE and its date of release.
+</P>
+<P>
+The global variables <b>pcre_malloc</b> and <b>pcre_free</b> initially contain
+the entry points of the standard <b>malloc()</b> and <b>free()</b> functions
+respectively. PCRE calls the memory management functions via these variables,
+so a calling program can replace them if it wishes to intercept the calls. This
+should be done before calling any PCRE functions.
+</P>
+<P>
+The global variable <b>pcre_callout</b> initially contains NULL. It can be set
+by the caller to a "callout" function, which PCRE will then call at specified
+points during a matching operation. Details are given in the <b>pcrecallout</b>
+documentation.
+</P>
+<br><a name="SEC3" href="#TOC1">MULTITHREADING</a><br>
+<P>
+The PCRE functions can be used in multi-threading applications, with the
+proviso that the memory management functions pointed to by <b>pcre_malloc</b>
+and <b>pcre_free</b>, and the callout function pointed to by <b>pcre_callout</b>,
+are shared by all threads.
+</P>
+<P>
+The compiled form of a regular expression is not altered during matching, so
+the same compiled pattern can safely be used by several threads at once.
+</P>
+<br><a name="SEC4" href="#TOC1">CHECKING BUILD-TIME OPTIONS</a><br>
+<P>
+<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<P>
+The function <b>pcre_config()</b> makes it possible for a PCRE client to
+discover which optional features have been compiled into the PCRE library. The
+<a href="pcrebuild.html"><b>pcrebuild</b></a>
+documentation has more details about these optional features.
+</P>
+<P>
+The first argument for <b>pcre_config()</b> is an integer, specifying which
+information is required; the second argument is a pointer to a variable into
+which the information is placed. The following information is available:
+</P>
+<P>
+<pre>
+ PCRE_CONFIG_UTF8
+</PRE>
+</P>
+<P>
+The output is an integer that is set to one if UTF-8 support is available;
+otherwise it is set to zero.
+</P>
+<P>
+<pre>
+ PCRE_CONFIG_NEWLINE
+</PRE>
+</P>
+<P>
+The output is an integer that is set to the value of the code that is used for
+the newline character. It is either linefeed (10) or carriage return (13), and
+should normally be the standard character for your operating system.
+</P>
+<P>
+<pre>
+ PCRE_CONFIG_LINK_SIZE
+</PRE>
+</P>
+<P>
+The output is an integer that contains the number of bytes used for internal
+linkage in compiled regular expressions. The value is 2, 3, or 4. Larger values
+allow larger regular expressions to be compiled, at the expense of slower
+matching. The default value of 2 is sufficient for all but the most massive
+patterns, since it allows the compiled pattern to be up to 64K in size.
+</P>
+<P>
+<pre>
+ PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+</PRE>
+</P>
+<P>
+The output is an integer that contains the threshold above which the POSIX
+interface uses <b>malloc()</b> for output vectors. Further details are given in
+the <b>pcreposix</b> documentation.
+</P>
+<P>
+<pre>
+ PCRE_CONFIG_MATCH_LIMIT
+</PRE>
+</P>
+<P>
+The output is an integer that gives the default limit for the number of
+internal matching function calls in a <b>pcre_exec()</b> execution. Further
+details are given with <b>pcre_exec()</b> below.
+</P>
+<br><a name="SEC5" href="#TOC1">COMPILING A PATTERN</a><br>
+<P>
+<b>pcre *pcre_compile(const char *<i>pattern</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
+<P>
+The function <b>pcre_compile()</b> is called to compile a pattern into an
+internal form. The pattern is a C string terminated by a binary zero, and
+is passed in the argument <i>pattern</i>. A pointer to a single block of memory
+that is obtained via <b>pcre_malloc</b> is returned. This contains the compiled
+code and related data. The <b>pcre</b> type is defined for the returned block;
+this is a typedef for a structure whose contents are not externally defined. It
+is up to the caller to free the memory when it is no longer required.
+</P>
+<P>
+Although the compiled code of a PCRE regex is relocatable, that is, it does not
+depend on memory location, the complete <b>pcre</b> data block is not
+fully relocatable, because it contains a copy of the <i>tableptr</i> argument,
+which is an address (see below).
+</P>
+<P>
+The <i>options</i> argument contains independent bits that affect the
+compilation. It should be zero if no options are required. Some of the options,
+in particular, those that are compatible with Perl, can also be set and unset
+from within the pattern (see the detailed description of regular expressions
+in the <b>pcrepattern</b> documentation). For these options, the contents of the
+<i>options</i> argument specifies their initial settings at the start of
+compilation and execution. The PCRE_ANCHORED option can be set at the time of
+matching as well as at compile time.
+</P>
+<P>
+If <i>errptr</i> is NULL, <b>pcre_compile()</b> returns NULL immediately.
+Otherwise, if compilation of a pattern fails, <b>pcre_compile()</b> returns
+NULL, and sets the variable pointed to by <i>errptr</i> to point to a textual
+error message. The offset from the start of the pattern to the character where
+the error was discovered is placed in the variable pointed to by
+<i>erroffset</i>, which must not be NULL. If it is, an immediate error is given.
+</P>
+<P>
+If the final argument, <i>tableptr</i>, is NULL, PCRE uses a default set of
+character tables which are built when it is compiled, using the default C
+locale. Otherwise, <i>tableptr</i> must be the result of a call to
+<b>pcre_maketables()</b>. See the section on locale support below.
+</P>
+<P>
+This code fragment shows a typical straightforward call to <b>pcre_compile()</b>:
+</P>
+<P>
+<pre>
+ pcre *re;
+ const char *error;
+ int erroffset;
+ re = pcre_compile(
+ "^A.*Z", /* the pattern */
+ 0, /* default options */
+ &error, /* for error message */
+ &erroffset, /* for error offset */
+ NULL); /* use default character tables */
+</PRE>
+</P>
+<P>
+The following option bits are defined:
+</P>
+<P>
+<pre>
+ PCRE_ANCHORED
+</PRE>
+</P>
+<P>
+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 which 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.
+</P>
+<P>
+<pre>
+ PCRE_CASELESS
+</PRE>
+</P>
+<P>
+If this bit is set, letters in the pattern match both upper and lower case
+letters. It is equivalent to Perl's /i option, and it can be changed within a
+pattern by a (?i) option setting.
+</P>
+<P>
+<pre>
+ PCRE_DOLLAR_ENDONLY
+</PRE>
+</P>
+<P>
+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 the final character if it is a newline (but not before any
+other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is
+set. There is no equivalent to this option in Perl, and no way to set it within
+a pattern.
+</P>
+<P>
+<pre>
+ PCRE_DOTALL
+</PRE>
+</P>
+<P>
+If this bit is set, a dot metacharater in the pattern matches all characters,
+including newlines. Without it, newlines are excluded. This option is
+equivalent to Perl's /s option, and it can be changed within a pattern by a
+(?s) option setting. A negative class such as [^a] always matches a newline
+character, independent of the setting of this option.
+</P>
+<P>
+<pre>
+ PCRE_EXTENDED
+</PRE>
+</P>
+<P>
+If this bit is set, whitespace data characters in the pattern are totally
+ignored except when escaped or inside a character class. Whitespace does not
+include the VT character (code 11). In addition, characters between an
+unescaped # outside a character class and the next newline character,
+inclusive, are also ignored. This is equivalent to Perl's /x option, and it can
+be changed within a pattern by a (?x) option setting.
+</P>
+<P>
+This option makes it possible to include comments inside complicated patterns.
+Note, however, that this applies only to data characters. Whitespace characters
+may never appear within special character sequences in a pattern, for example
+within the sequence (?( which introduces a conditional subpattern.
+</P>
+<P>
+<pre>
+ PCRE_EXTRA
+</PRE>
+</P>
+<P>
+This option was invented in order to turn on additional functionality of PCRE
+that is incompatible with Perl, but it is currently of very little use. When
+set, any backslash in a pattern that is followed by a letter that has no
+special meaning causes an error, thus reserving these combinations for future
+expansion. By default, as in Perl, a backslash followed by a letter with no
+special meaning is treated as a literal. There are at present no other features
+controlled by this option. It can also be set by a (?X) option setting within a
+pattern.
+</P>
+<P>
+<pre>
+ PCRE_MULTILINE
+</PRE>
+</P>
+<P>
+By default, PCRE treats the subject string as consisting of a single "line" of
+characters (even if it actually contains several newlines). The "start of line"
+metacharacter (^) matches only at the start of the string, while the "end of
+line" metacharacter ($) matches only at the end of the string, or before a
+terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as
+Perl.
+</P>
+<P>
+When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs
+match immediately following or immediately before any newline in the subject
+string, respectively, as well as at the very start and end. This is equivalent
+to Perl's /m option, and it can be changed within a pattern by a (?m) option
+setting. If there are no "\n" characters in a subject string, or no
+occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect.
+</P>
+<P>
+<pre>
+ PCRE_NO_AUTO_CAPTURE
+</PRE>
+</P>
+<P>
+If this option is set, it disables the use of numbered capturing parentheses in
+the pattern. Any opening parenthesis that is not followed by ? behaves as if it
+were followed by ?: but named parentheses can still be used for capturing (and
+they acquire numbers in the usual way). There is no equivalent of this option
+in Perl.
+</P>
+<P>
+<pre>
+ PCRE_UNGREEDY
+</PRE>
+</P>
+<P>
+This option inverts the "greediness" of the quantifiers so that they are not
+greedy by default, but become greedy if followed by "?". It is not compatible
+with Perl. It can also be set by a (?U) option setting within the pattern.
+</P>
+<P>
+<pre>
+ PCRE_UTF8
+</PRE>
+</P>
+<P>
+This option causes PCRE to regard both the pattern and the subject as strings
+of UTF-8 characters instead of single-byte character strings. However, it is
+available only if PCRE has been built to include UTF-8 support. If not, the use
+of this option provokes an error. Details of how this option changes the
+behaviour of PCRE are given in the
+<a href="pcre.html#utf8support">section on UTF-8 support</a>
+in the main
+<a href="pcre.html"><b>pcre</b></a>
+page.
+</P>
+<br><a name="SEC6" href="#TOC1">STUDYING A PATTERN</a><br>
+<P>
+<b>pcre_extra *pcre_study(const pcre *<i>code</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>);</b>
+</P>
+<P>
+When a pattern is going to be used several times, it is worth spending more
+time analyzing it in order to speed up the time taken for matching. The
+function <b>pcre_study()</b> takes a pointer to a compiled pattern as its first
+argument. If studing the pattern produces additional information that will help
+speed up matching, <b>pcre_study()</b> returns a pointer to a <b>pcre_extra</b>
+block, in which the <i>study_data</i> field points to the results of the study.
+</P>
+<P>
+The returned value from a <b>pcre_study()</b> can be passed directly to
+<b>pcre_exec()</b>. However, the <b>pcre_extra</b> block also contains other
+fields that can be set by the caller before the block is passed; these are
+described below. If studying the pattern does not produce any additional
+information, <b>pcre_study()</b> returns NULL. In that circumstance, if the
+calling program wants to pass some of the other fields to <b>pcre_exec()</b>, it
+must set up its own <b>pcre_extra</b> block.
+</P>
+<P>
+The second argument contains option bits. At present, no options are defined
+for <b>pcre_study()</b>, and this argument should always be zero.
+</P>
+<P>
+The third argument for <b>pcre_study()</b> is a pointer for an error message. If
+studying succeeds (even if no data is returned), the variable it points to is
+set to NULL. Otherwise it points to a textual error message. You should
+therefore test the error pointer for NULL after calling <b>pcre_study()</b>, to
+be sure that it has run successfully.
+</P>
+<P>
+This is a typical call to <b>pcre_study</b>():
+</P>
+<P>
+<pre>
+ pcre_extra *pe;
+ pe = pcre_study(
+ re, /* result of pcre_compile() */
+ 0, /* no options exist */
+ &error); /* set to NULL or points to a message */
+</PRE>
+</P>
+<P>
+At present, studying a pattern is useful only for non-anchored patterns that do
+not have a single fixed starting character. A bitmap of possible starting
+characters is created.
+</P>
+<a name="localesupport"></a><br><a name="SEC7" href="#TOC1">LOCALE SUPPORT</a><br>
+<P>
+PCRE handles caseless matching, and determines whether characters are letters,
+digits, or whatever, by reference to a set of tables. When running in UTF-8
+mode, this applies only to characters with codes less than 256. The library
+contains a default set of tables that is created in the default C locale when
+PCRE is compiled. This is used when the final argument of <b>pcre_compile()</b>
+is NULL, and is sufficient for many applications.
+</P>
+<P>
+An alternative set of tables can, however, be supplied. Such tables are built
+by calling the <b>pcre_maketables()</b> function, which has no arguments, in the
+relevant locale. The result can then be passed to <b>pcre_compile()</b> as often
+as necessary. For example, to build and use tables that are appropriate for the
+French locale (where accented characters with codes greater than 128 are
+treated as letters), the following code could be used:
+</P>
+<P>
+<pre>
+ setlocale(LC_CTYPE, "fr");
+ tables = pcre_maketables();
+ re = pcre_compile(..., tables);
+</PRE>
+</P>
+<P>
+The tables are built in memory that is obtained via <b>pcre_malloc</b>. The
+pointer that is passed to <b>pcre_compile</b> is saved with the compiled
+pattern, and the same tables are used via this pointer by <b>pcre_study()</b>
+and <b>pcre_exec()</b>. Thus, for any single pattern, compilation, studying and
+matching all happen in the same locale, but different patterns can be compiled
+in different locales. It is the caller's responsibility to ensure that the
+memory containing the tables remains available for as long as it is needed.
+</P>
+<br><a name="SEC8" href="#TOC1">INFORMATION ABOUT A PATTERN</a><br>
+<P>
+<b>int pcre_fullinfo(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<P>
+The <b>pcre_fullinfo()</b> function returns information about a compiled
+pattern. It replaces the obsolete <b>pcre_info()</b> function, which is
+nevertheless retained for backwards compability (and is documented below).
+</P>
+<P>
+The first argument for <b>pcre_fullinfo()</b> is a pointer to the compiled
+pattern. The second argument is the result of <b>pcre_study()</b>, or NULL if
+the pattern was not studied. The third argument specifies which piece of
+information is required, and the fourth argument is a pointer to a variable
+to receive the data. The yield of the function is zero for success, or one of
+the following negative numbers:
+</P>
+<P>
+<pre>
+ PCRE_ERROR_NULL the argument <i>code</i> was NULL
+ the argument <i>where</i> was NULL
+ PCRE_ERROR_BADMAGIC the "magic number" was not found
+ PCRE_ERROR_BADOPTION the value of <i>what</i> was invalid
+</PRE>
+</P>
+<P>
+Here is a typical call of <b>pcre_fullinfo()</b>, to obtain the length of the
+compiled pattern:
+</P>
+<P>
+<pre>
+ int rc;
+ unsigned long int length;
+ rc = pcre_fullinfo(
+ re, /* result of pcre_compile() */
+ pe, /* result of pcre_study(), or NULL */
+ PCRE_INFO_SIZE, /* what is required */
+ &length); /* where to put the data */
+</PRE>
+</P>
+<P>
+The possible values for the third argument are defined in <b>pcre.h</b>, and are
+as follows:
+</P>
+<P>
+<pre>
+ PCRE_INFO_BACKREFMAX
+</PRE>
+</P>
+<P>
+Return the number of the highest back reference in the pattern. The fourth
+argument should point to an <b>int</b> variable. Zero is returned if there are
+no back references.
+</P>
+<P>
+<pre>
+ PCRE_INFO_CAPTURECOUNT
+</PRE>
+</P>
+<P>
+Return the number of capturing subpatterns in the pattern. The fourth argument
+should point to an \fbint\fR variable.
+</P>
+<P>
+<pre>
+ PCRE_INFO_FIRSTBYTE
+</PRE>
+</P>
+<P>
+Return information about the first byte of any matched string, for a
+non-anchored pattern. (This option used to be called PCRE_INFO_FIRSTCHAR; the
+old name is still recognized for backwards compatibility.)
+</P>
+<P>
+If there is a fixed first byte, e.g. from a pattern such as (cat|cow|coyote),
+it is returned in the integer pointed to by <i>where</i>. Otherwise, if either
+</P>
+<P>
+(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
+starts with "^", or
+</P>
+<P>
+(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set
+(if it were set, the pattern would be anchored),
+</P>
+<P>
+-1 is returned, indicating that the pattern matches only at the start of a
+subject string or after any newline within the string. Otherwise -2 is
+returned. For anchored patterns, -2 is returned.
+</P>
+<P>
+<pre>
+ PCRE_INFO_FIRSTTABLE
+</PRE>
+</P>
+<P>
+If the pattern was studied, and this resulted in the construction of a 256-bit
+table indicating a fixed set of bytes for the first byte in any matching
+string, a pointer to the table is returned. Otherwise NULL is returned. The
+fourth argument should point to an <b>unsigned char *</b> variable.
+</P>
+<P>
+<pre>
+ PCRE_INFO_LASTLITERAL
+</PRE>
+</P>
+<P>
+For a non-anchored pattern, return the value of the rightmost literal byte
+which must exist in any matched string, other than at its start. The fourth
+argument should point to an <b>int</b> variable. If there is no such byte, or if
+the pattern is anchored, -1 is returned. For example, for the pattern
+/a\d+z\d+/ the returned value is 'z'.
+</P>
+<P>
+<pre>
+ PCRE_INFO_NAMECOUNT
+ PCRE_INFO_NAMEENTRYSIZE
+ PCRE_INFO_NAMETABLE
+</PRE>
+</P>
+<P>
+PCRE supports the use of named as well as numbered capturing parentheses. The
+names are just an additional way of identifying the parentheses, which still
+acquire a number. A caller that wants to extract data from a named subpattern
+must convert the name to a number in order to access the correct pointers in
+the output vector (described with <b>pcre_exec()</b> below). In order to do
+this, it must first use these three values to obtain the name-to-number mapping
+table for the pattern.
+</P>
+<P>
+The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT gives
+the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size of each
+entry; both of these return an <b>int</b> value. The entry size depends on the
+length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first
+entry of the table (a pointer to <b>char</b>). The first two bytes of each entry
+are the number of the capturing parenthesis, most significant byte first. The
+rest of the entry is the corresponding name, zero terminated. The names are in
+alphabetical order. For example, consider the following pattern (assume
+PCRE_EXTENDED is set, so white space - including newlines - is ignored):
+</P>
+<P>
+<pre>
+ (?P&#60;date&#62; (?P&#60;year&#62;(\d\d)?\d\d) -
+ (?P&#60;month&#62;\d\d) - (?P&#60;day&#62;\d\d) )
+</PRE>
+</P>
+<P>
+There are four named subpatterns, so the table has four entries, and each entry
+in the table is eight bytes long. The table is as follows, with non-printing
+bytes shows in hex, and undefined bytes shown as ??:
+</P>
+<P>
+<pre>
+ 00 01 d a t e 00 ??
+ 00 05 d a y 00 ?? ??
+ 00 04 m o n t h 00
+ 00 02 y e a r 00 ??
+</PRE>
+</P>
+<P>
+When writing code to extract data from named subpatterns, remember that the
+length of each entry may be different for each compiled pattern.
+</P>
+<P>
+<pre>
+ PCRE_INFO_OPTIONS
+</PRE>
+</P>
+<P>
+Return a copy of the options with which the pattern was compiled. The fourth
+argument should point to an <b>unsigned long int</b> variable. These option bits
+are those specified in the call to <b>pcre_compile()</b>, modified by any
+top-level option settings within the pattern itself.
+</P>
+<P>
+A pattern is automatically anchored by PCRE if all of its top-level
+alternatives begin with one of the following:
+</P>
+<P>
+<pre>
+ ^ unless PCRE_MULTILINE is set
+ \A always
+ \G always
+ .* if PCRE_DOTALL is set and there are no back
+ references to the subpattern in which .* appears
+</PRE>
+</P>
+<P>
+For such patterns, the PCRE_ANCHORED bit is set in the options returned by
+<b>pcre_fullinfo()</b>.
+</P>
+<P>
+<pre>
+ PCRE_INFO_SIZE
+</PRE>
+</P>
+<P>
+Return the size of the compiled pattern, that is, the value that was passed as
+the argument to <b>pcre_malloc()</b> when PCRE was getting memory in which to
+place the compiled data. The fourth argument should point to a <b>size_t</b>
+variable.
+</P>
+<P>
+<pre>
+ PCRE_INFO_STUDYSIZE
+</PRE>
+</P>
+<P>
+Returns the size of the data block pointed to by the <i>study_data</i> field in
+a <b>pcre_extra</b> block. That is, it is the value that was passed to
+<b>pcre_malloc()</b> when PCRE was getting memory into which to place the data
+created by <b>pcre_study()</b>. The fourth argument should point to a
+<b>size_t</b> variable.
+</P>
+<br><a name="SEC9" href="#TOC1">OBSOLETE INFO FUNCTION</a><br>
+<P>
+<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
+<b>*<i>firstcharptr</i>);</b>
+</P>
+<P>
+The <b>pcre_info()</b> function is now obsolete because its interface is too
+restrictive to return all the available data about a compiled pattern. New
+programs should use <b>pcre_fullinfo()</b> instead. The yield of
+<b>pcre_info()</b> is the number of capturing subpatterns, or one of the
+following negative numbers:
+</P>
+<P>
+<pre>
+ PCRE_ERROR_NULL the argument <i>code</i> was NULL
+ PCRE_ERROR_BADMAGIC the "magic number" was not found
+</PRE>
+</P>
+<P>
+If the <i>optptr</i> argument is not NULL, a copy of the options with which the
+pattern was compiled is placed in the integer it points to (see
+PCRE_INFO_OPTIONS above).
+</P>
+<P>
+If the pattern is not anchored and the <i>firstcharptr</i> argument is not NULL,
+it is used to pass back information about the first character of any matched
+string (see PCRE_INFO_FIRSTBYTE above).
+</P>
+<br><a name="SEC10" href="#TOC1">MATCHING A PATTERN</a><br>
+<P>
+<b>int pcre_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
+</P>
+<P>
+The function <b>pcre_exec()</b> is called to match a subject string against a
+pre-compiled pattern, which is passed in the <i>code</i> argument. If the
+pattern has been studied, the result of the study should be passed in the
+<i>extra</i> argument.
+</P>
+<P>
+Here is an example of a simple call to <b>pcre_exec()</b>:
+</P>
+<P>
+<pre>
+ int rc;
+ int ovector[30];
+ rc = pcre_exec(
+ re, /* result of pcre_compile() */
+ NULL, /* we didn't study the pattern */
+ "some string", /* the subject string */
+ 11, /* the length of the subject string */
+ 0, /* start at offset 0 in the subject */
+ 0, /* default options */
+ ovector, /* vector for substring information */
+ 30); /* number of elements in the vector */
+</PRE>
+</P>
+<P>
+If the <i>extra</i> argument is not NULL, it must point to a <b>pcre_extra</b>
+data block. The <b>pcre_study()</b> function returns such a block (when it
+doesn't return NULL), but you can also create one for yourself, and pass
+additional information in it. The fields in the block are as follows:
+</P>
+<P>
+<pre>
+ unsigned long int <i>flags</i>;
+ void *<i>study_data</i>;
+ unsigned long int <i>match_limit</i>;
+ void *<i>callout_data</i>;
+</PRE>
+</P>
+<P>
+The <i>flags</i> field is a bitmap that specifies which of the other fields
+are set. The flag bits are:
+</P>
+<P>
+<pre>
+ PCRE_EXTRA_STUDY_DATA
+ PCRE_EXTRA_MATCH_LIMIT
+ PCRE_EXTRA_CALLOUT_DATA
+</PRE>
+</P>
+<P>
+Other flag bits should be set to zero. The <i>study_data</i> field is set in the
+<b>pcre_extra</b> block that is returned by <b>pcre_study()</b>, together with
+the appropriate flag bit. You should not set this yourself, but you can add to
+the block by setting the other fields.
+</P>
+<P>
+The <i>match_limit</i> field provides a means of preventing PCRE from using up a
+vast amount of resources when running patterns that are not going to match,
+but which have a very large number of possibilities in their search trees. The
+classic example is the use of nested unlimited repeats. Internally, PCRE uses a
+function called <b>match()</b> which it calls repeatedly (sometimes
+recursively). The limit is imposed on the number of times this function is
+called during a match, which has the effect of limiting the amount of recursion
+and backtracking that can take place. For patterns that are not anchored, the
+count starts from zero for each position in the subject string.
+</P>
+<P>
+The default limit for the library can be set when PCRE is built; the default
+default is 10 million, which handles all but the most extreme cases. You can
+reduce the default by suppling <b>pcre_exec()</b> with a \fRpcre_extra\fR block
+in which <i>match_limit</i> is set to a smaller value, and
+PCRE_EXTRA_MATCH_LIMIT is set in the <i>flags</i> field. If the limit is
+exceeded, <b>pcre_exec()</b> returns PCRE_ERROR_MATCHLIMIT.
+</P>
+<P>
+The <i>pcre_callout</i> field is used in conjunction with the "callout" feature,
+which is described in the <b>pcrecallout</b> documentation.
+</P>
+<P>
+The PCRE_ANCHORED option can be passed in the <i>options</i> argument, whose
+unused bits must be zero. This limits <b>pcre_exec()</b> to matching at the
+first matching position. However, if a pattern was compiled with PCRE_ANCHORED,
+or turned out to be anchored by virtue of its contents, it cannot be made
+unachored at matching time.
+</P>
+<P>
+There are also three further options that can be set only at matching time:
+</P>
+<P>
+<pre>
+ PCRE_NOTBOL
+</PRE>
+</P>
+<P>
+The first character of the string is not the beginning of a line, so the
+circumflex metacharacter should not match before it. Setting this without
+PCRE_MULTILINE (at compile time) causes circumflex never to match.
+</P>
+<P>
+<pre>
+ PCRE_NOTEOL
+</PRE>
+</P>
+<P>
+The end of the string is not the end of a line, so the dollar metacharacter
+should not match it nor (except in multiline mode) a newline immediately before
+it. Setting this without PCRE_MULTILINE (at compile time) causes dollar never
+to match.
+</P>
+<P>
+<pre>
+ PCRE_NOTEMPTY
+</PRE>
+</P>
+<P>
+An empty string is not considered to be a valid match if this option is set. If
+there are alternatives in the pattern, they are tried. If all the alternatives
+match the empty string, the entire match fails. For example, if the pattern
+</P>
+<P>
+<pre>
+ a?b?
+</PRE>
+</P>
+<P>
+is applied to a string not beginning with "a" or "b", it matches the empty
+string at the start of the subject. With PCRE_NOTEMPTY set, this match is not
+valid, so PCRE searches further into the string for occurrences of "a" or "b".
+</P>
+<P>
+Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a special case
+of a pattern match of the empty string within its <b>split()</b> function, and
+when using the /g modifier. It is possible to emulate Perl's behaviour after
+matching a null string by first trying the match again at the same offset with
+PCRE_NOTEMPTY set, and then if that fails by advancing the starting offset (see
+below) and trying an ordinary match again.
+</P>
+<P>
+The subject string is passed to <b>pcre_exec()</b> as a pointer in
+<i>subject</i>, a length in <i>length</i>, and a starting offset in
+<i>startoffset</i>. Unlike the pattern string, the subject may contain binary
+zero bytes. When the starting offset is zero, the search for a match starts at
+the beginning of the subject, and this is by far the most common case.
+</P>
+<P>
+If the pattern was compiled with the PCRE_UTF8 option, the subject must be a
+sequence of bytes that is a valid UTF-8 string. If an invalid UTF-8 string is
+passed, PCRE's behaviour is not defined.
+</P>
+<P>
+A non-zero starting offset is useful when searching for another match in the
+same subject by calling <b>pcre_exec()</b> again after a previous success.
+Setting <i>startoffset</i> differs from just passing over a shortened string and
+setting PCRE_NOTBOL in the case of a pattern that begins with any kind of
+lookbehind. For example, consider the pattern
+</P>
+<P>
+<pre>
+ \Biss\B
+</PRE>
+</P>
+<P>
+which finds occurrences of "iss" in the middle of words. (\B matches only if
+the current position in the subject is not a word boundary.) When applied to
+the string "Mississipi" the first call to <b>pcre_exec()</b> finds the first
+occurrence. If <b>pcre_exec()</b> is called again with just the remainder of the
+subject, namely "issipi", it does not match, because \B is always false at the
+start of the subject, which is deemed to be a word boundary. However, if
+<b>pcre_exec()</b> is passed the entire string again, but with <i>startoffset</i>
+set to 4, it finds the second occurrence of "iss" because it is able to look
+behind the starting point to discover that it is preceded by a letter.
+</P>
+<P>
+If a non-zero starting offset is passed when the pattern is anchored, one
+attempt to match at the given offset is tried. This can only succeed if the
+pattern does not require the match to be at the start of the subject.
+</P>
+<P>
+In general, a pattern matches a certain portion of the subject, and in
+addition, further substrings from the subject may be picked out by parts of the
+pattern. Following the usage in Jeffrey Friedl's book, this is called
+"capturing" in what follows, and the phrase "capturing subpattern" is used for
+a fragment of a pattern that picks out a substring. PCRE supports several other
+kinds of parenthesized subpattern that do not cause substrings to be captured.
+</P>
+<P>
+Captured substrings are returned to the caller via a vector of integer offsets
+whose address is passed in <i>ovector</i>. The number of elements in the vector
+is passed in <i>ovecsize</i>. The first two-thirds of the vector is used to pass
+back captured substrings, each substring using a pair of integers. The
+remaining third of the vector is used as workspace by <b>pcre_exec()</b> while
+matching capturing subpatterns, and is not available for passing back
+information. The length passed in <i>ovecsize</i> should always be a multiple of
+three. If it is not, it is rounded down.
+</P>
+<P>
+When a match has been successful, information about captured substrings is
+returned in pairs of integers, starting at the beginning of <i>ovector</i>, and
+continuing up to two-thirds of its length at the most. The first element of a
+pair is set to the offset of the first character in a substring, and the second
+is set to the offset of the first character after the end of a substring. The
+first pair, <i>ovector[0]</i> and <i>ovector[1]</i>, identify the portion of the
+subject string matched by the entire pattern. The next pair is used for the
+first capturing subpattern, and so on. The value returned by <b>pcre_exec()</b>
+is the number of pairs that have been set. If there are no capturing
+subpatterns, the return value from a successful match is 1, indicating that
+just the first pair of offsets has been set.
+</P>
+<P>
+Some convenience functions are provided for extracting the captured substrings
+as separate strings. These are described in the following section.
+</P>
+<P>
+It is possible for an capturing subpattern number <i>n+1</i> to match some
+part of the subject when subpattern <i>n</i> has not been used at all. For
+example, if the string "abc" is matched against the pattern (a|(z))(bc)
+subpatterns 1 and 3 are matched, but 2 is not. When this happens, both offset
+values corresponding to the unused subpattern are set to -1.
+</P>
+<P>
+If a capturing subpattern is matched repeatedly, it is the last portion of the
+string that it matched that gets returned.
+</P>
+<P>
+If the vector is too small to hold all the captured substrings, it is used as
+far as possible (up to two-thirds of its length), and the function returns a
+value of zero. In particular, if the substring offsets are not of interest,
+<b>pcre_exec()</b> may be called with <i>ovector</i> passed as NULL and
+<i>ovecsize</i> as zero. However, if the pattern contains back references and
+the <i>ovector</i> isn't big enough to remember the related substrings, PCRE has
+to get additional memory for use during matching. Thus it is usually advisable
+to supply an <i>ovector</i>.
+</P>
+<P>
+Note that <b>pcre_info()</b> can be used to find out how many capturing
+subpatterns there are in a compiled pattern. The smallest size for
+<i>ovector</i> that will allow for <i>n</i> captured substrings, in addition to
+the offsets of the substring matched by the whole pattern, is (<i>n</i>+1)*3.
+</P>
+<P>
+If <b>pcre_exec()</b> fails, it returns a negative number. The following are
+defined in the header file:
+</P>
+<P>
+<pre>
+ PCRE_ERROR_NOMATCH (-1)
+</PRE>
+</P>
+<P>
+The subject string did not match the pattern.
+</P>
+<P>
+<pre>
+ PCRE_ERROR_NULL (-2)
+</PRE>
+</P>
+<P>
+Either <i>code</i> or <i>subject</i> was passed as NULL, or <i>ovector</i> was
+NULL and <i>ovecsize</i> was not zero.
+</P>
+<P>
+<pre>
+ PCRE_ERROR_BADOPTION (-3)
+</PRE>
+</P>
+<P>
+An unrecognized bit was set in the <i>options</i> argument.
+</P>
+<P>
+<pre>
+ PCRE_ERROR_BADMAGIC (-4)
+</PRE>
+</P>
+<P>
+PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch
+the case when it is passed a junk pointer. This is the error it gives when the
+magic number isn't present.
+</P>
+<P>
+<pre>
+ PCRE_ERROR_UNKNOWN_NODE (-5)
+</PRE>
+</P>
+<P>
+While running the pattern match, an unknown item was encountered in the
+compiled pattern. This error could be caused by a bug in PCRE or by overwriting
+of the compiled pattern.
+</P>
+<P>
+<pre>
+ PCRE_ERROR_NOMEMORY (-6)
+</PRE>
+</P>
+<P>
+If a pattern contains back references, but the <i>ovector</i> that is passed to
+<b>pcre_exec()</b> is not big enough to remember the referenced substrings, PCRE
+gets a block of memory at the start of matching to use for this purpose. If the
+call via <b>pcre_malloc()</b> fails, this error is given. The memory is freed at
+the end of matching.
+</P>
+<P>
+<pre>
+ PCRE_ERROR_NOSUBSTRING (-7)
+</PRE>
+</P>
+<P>
+This error is used by the <b>pcre_copy_substring()</b>,
+<b>pcre_get_substring()</b>, and <b>pcre_get_substring_list()</b> functions (see
+below). It is never returned by <b>pcre_exec()</b>.
+</P>
+<P>
+<pre>
+ PCRE_ERROR_MATCHLIMIT (-8)
+</PRE>
+</P>
+<P>
+The recursion and backtracking limit, as specified by the <i>match_limit</i>
+field in a <b>pcre_extra</b> structure (or defaulted) was reached. See the
+description above.
+</P>
+<P>
+<pre>
+ PCRE_ERROR_CALLOUT (-9)
+</PRE>
+</P>
+<P>
+This error is never generated by <b>pcre_exec()</b> itself. It is provided for
+use by callout functions that want to yield a distinctive error code. See the
+<b>pcrecallout</b> documentation for details.
+</P>
+<br><a name="SEC11" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a><br>
+<P>
+<b>int pcre_copy_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>, char *<i>buffer</i>,</b>
+<b>int <i>buffersize</i>);</b>
+</P>
+<P>
+<b>int pcre_get_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<P>
+<b>int pcre_get_substring_list(const char *<i>subject</i>,</b>
+<b>int *<i>ovector</i>, int <i>stringcount</i>, const char ***<i>listptr</i>);</b>
+</P>
+<P>
+Captured substrings can be accessed directly by using the offsets returned by
+<b>pcre_exec()</b> in <i>ovector</i>. For convenience, the functions
+<b>pcre_copy_substring()</b>, <b>pcre_get_substring()</b>, and
+<b>pcre_get_substring_list()</b> are provided for extracting captured substrings
+as new, separate, zero-terminated strings. These functions identify substrings
+by number. The next section describes functions for extracting named
+substrings. A substring that contains a binary zero is correctly extracted and
+has a further zero added on the end, but the result is not, of course,
+a C string.
+</P>
+<P>
+The first three arguments are the same for all three of these functions:
+<i>subject</i> is the subject string which has just been successfully matched,
+<i>ovector</i> is a pointer to the vector of integer offsets that was passed to
+<b>pcre_exec()</b>, and <i>stringcount</i> is the number of substrings that were
+captured by the match, including the substring that matched the entire regular
+expression. This is the value returned by <b>pcre_exec</b> if it is greater than
+zero. If <b>pcre_exec()</b> returned zero, indicating that it ran out of space
+in <i>ovector</i>, the value passed as <i>stringcount</i> should be the size of
+the vector divided by three.
+</P>
+<P>
+The functions <b>pcre_copy_substring()</b> and <b>pcre_get_substring()</b>
+extract a single substring, whose number is given as <i>stringnumber</i>. A
+value of zero extracts the substring that matched the entire pattern, while
+higher values extract the captured substrings. For <b>pcre_copy_substring()</b>,
+the string is placed in <i>buffer</i>, whose length is given by
+<i>buffersize</i>, while for <b>pcre_get_substring()</b> a new block of memory is
+obtained via <b>pcre_malloc</b>, and its address is returned via
+<i>stringptr</i>. The yield of the function is the length of the string, not
+including the terminating zero, or one of
+</P>
+<P>
+<pre>
+ PCRE_ERROR_NOMEMORY (-6)
+</PRE>
+</P>
+<P>
+The buffer was too small for <b>pcre_copy_substring()</b>, or the attempt to get
+memory failed for <b>pcre_get_substring()</b>.
+</P>
+<P>
+<pre>
+ PCRE_ERROR_NOSUBSTRING (-7)
+</PRE>
+</P>
+<P>
+There is no substring whose number is <i>stringnumber</i>.
+</P>
+<P>
+The <b>pcre_get_substring_list()</b> function extracts all available substrings
+and builds a list of pointers to them. All this is done in a single block of
+memory which is obtained via <b>pcre_malloc</b>. The address of the memory block
+is returned via <i>listptr</i>, which is also the start of the list of string
+pointers. The end of the list is marked by a NULL pointer. The yield of the
+function is zero if all went well, or
+</P>
+<P>
+<pre>
+ PCRE_ERROR_NOMEMORY (-6)
+</PRE>
+</P>
+<P>
+if the attempt to get the memory block failed.
+</P>
+<P>
+When any of these functions encounter a substring that is unset, which can
+happen when capturing subpattern number <i>n+1</i> matches some part of the
+subject, but subpattern <i>n</i> has not been used at all, they return an empty
+string. This can be distinguished from a genuine zero-length substring by
+inspecting the appropriate offset in <i>ovector</i>, which is negative for unset
+substrings.
+</P>
+<P>
+The two convenience functions <b>pcre_free_substring()</b> and
+<b>pcre_free_substring_list()</b> can be used to free the memory returned by
+a previous call of <b>pcre_get_substring()</b> or
+<b>pcre_get_substring_list()</b>, respectively. They do nothing more than call
+the function pointed to by <b>pcre_free</b>, which of course could be called
+directly from a C program. However, PCRE is used in some situations where it is
+linked via a special interface to another programming language which cannot use
+<b>pcre_free</b> directly; it is for these cases that the functions are
+provided.
+</P>
+<br><a name="SEC12" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a><br>
+<P>
+<b>int pcre_copy_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>char *<i>buffer</i>, int <i>buffersize</i>);</b>
+</P>
+<P>
+<b>int pcre_get_stringnumber(const pcre *<i>code</i>,</b>
+<b>const char *<i>name</i>);</b>
+</P>
+<P>
+<b>int pcre_get_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<P>
+To extract a substring by name, you first have to find associated number. This
+can be done by calling <b>pcre_get_stringnumber()</b>. The first argument is the
+compiled pattern, and the second is the name. For example, for this pattern
+</P>
+<P>
+<pre>
+ ab(?&#60;xxx&#62;\d+)...
+</PRE>
+</P>
+<P>
+the number of the subpattern called "xxx" is 1. Given the number, you can then
+extract the substring directly, or use one of the functions described in the
+previous section. For convenience, there are also two functions that do the
+whole job.
+</P>
+<P>
+Most of the arguments of <i>pcre_copy_named_substring()</i> and
+<i>pcre_get_named_substring()</i> are the same as those for the functions that
+extract by number, and so are not re-described here. There are just two
+differences.
+</P>
+<P>
+First, instead of a substring number, a substring name is given. Second, there
+is an extra argument, given at the start, which is a pointer to the compiled
+pattern. This is needed in order to gain access to the name-to-number
+translation table.
+</P>
+<P>
+These functions call <b>pcre_get_stringnumber()</b>, and if it succeeds, they
+then call <i>pcre_copy_substring()</i> or <i>pcre_get_substring()</i>, as
+appropriate.
+</P>
+<P>
+Last updated: 03 February 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/html/pcrebuild.html b/doc/html/pcrebuild.html
new file mode 100644
index 0000000..ff3e08e
--- /dev/null
+++ b/doc/html/pcrebuild.html
@@ -0,0 +1,148 @@
+<html>
+<head>
+<title>pcrebuild specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE BUILD-TIME OPTIONS</a>
+<li><a name="TOC2" href="#SEC2">UTF-8 SUPPORT</a>
+<li><a name="TOC3" href="#SEC3">CODE VALUE OF NEWLINE</a>
+<li><a name="TOC4" href="#SEC4">BUILDING SHARED AND STATIC LIBRARIES</a>
+<li><a name="TOC5" href="#SEC5">POSIX MALLOC USAGE</a>
+<li><a name="TOC6" href="#SEC6">LIMITING PCRE RESOURCE USAGE</a>
+<li><a name="TOC7" href="#SEC7">HANDLING VERY LARGE PATTERNS</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE BUILD-TIME OPTIONS</a><br>
+<P>
+This document describes the optional features of PCRE that can be selected when
+the library is compiled. They are all selected, or deselected, by providing
+options to the <b>configure</b> script which is run before the <b>make</b>
+command. The complete list of options for <b>configure</b> (which includes the
+standard ones such as the selection of the installation directory) can be
+obtained by running
+</P>
+<P>
+<pre>
+ ./configure --help
+</PRE>
+</P>
+<P>
+The following sections describe certain options whose names begin with --enable
+or --disable. These settings specify changes to the defaults for the
+<b>configure</b> command. Because of the way that <b>configure</b> works,
+--enable and --disable always come in pairs, so the complementary option always
+exists as well, but as it specifies the default, it is not described.
+</P>
+<br><a name="SEC2" href="#TOC1">UTF-8 SUPPORT</a><br>
+<P>
+To build PCRE with support for UTF-8 character strings, add
+</P>
+<P>
+<pre>
+ --enable-utf8
+</PRE>
+</P>
+<P>
+to the <b>configure</b> command. Of itself, this does not make PCRE treat
+strings as UTF-8. As well as compiling PCRE with this option, you also have
+have to set the PCRE_UTF8 option when you call the <b>pcre_compile()</b>
+function.
+</P>
+<br><a name="SEC3" href="#TOC1">CODE VALUE OF NEWLINE</a><br>
+<P>
+By default, PCRE treats character 10 (linefeed) as the newline character. This
+is the normal newline character on Unix-like systems. You can compile PCRE to
+use character 13 (carriage return) instead by adding
+</P>
+<P>
+<pre>
+ --enable-newline-is-cr
+</PRE>
+</P>
+<P>
+to the <b>configure</b> command. For completeness there is also a
+--enable-newline-is-lf option, which explicitly specifies linefeed as the
+newline character.
+</P>
+<br><a name="SEC4" href="#TOC1">BUILDING SHARED AND STATIC LIBRARIES</a><br>
+<P>
+The PCRE building process uses <b>libtool</b> to build both shared and static
+Unix libraries by default. You can suppress one of these by adding one of
+</P>
+<P>
+<pre>
+ --disable-shared
+ --disable-static
+</PRE>
+</P>
+<P>
+to the <b>configure</b> command, as required.
+</P>
+<br><a name="SEC5" href="#TOC1">POSIX MALLOC USAGE</a><br>
+<P>
+When PCRE is called through the POSIX interface (see the <b>pcreposix</b>
+documentation), additional working storage is required for holding the pointers
+to capturing substrings because PCRE requires three integers per substring,
+whereas the POSIX interface provides only two. If the number of expected
+substrings is small, the wrapper function uses space on the stack, because this
+is faster than using <b>malloc()</b> for each call. The default threshold above
+which the stack is no longer used is 10; it can be changed by adding a setting
+such as
+</P>
+<P>
+<pre>
+ --with-posix-malloc-threshold=20
+</PRE>
+</P>
+<P>
+to the <b>configure</b> command.
+</P>
+<br><a name="SEC6" href="#TOC1">LIMITING PCRE RESOURCE USAGE</a><br>
+<P>
+Internally, PCRE has a function called <b>match()</b> which it calls repeatedly
+(possibly recursively) when performing a matching operation. By limiting the
+number of times this function may be called, a limit can be placed on the
+resources used by a single call to <b>pcre_exec()</b>. The limit can be changed
+at run time, as described in the <b>pcreapi</b> documentation. The default is 10
+million, but this can be changed by adding a setting such as
+</P>
+<P>
+<pre>
+ --with-match-limit=500000
+</PRE>
+</P>
+<P>
+to the <b>configure</b> command.
+</P>
+<br><a name="SEC7" href="#TOC1">HANDLING VERY LARGE PATTERNS</a><br>
+<P>
+Within a compiled pattern, offset values are used to point from one part to
+another (for example, from an opening parenthesis to an alternation
+metacharacter). By default two-byte values are used for these offsets, leading
+to a maximum size for a compiled pattern of around 64K. This is sufficient to
+handle all but the most gigantic patterns. Nevertheless, some people do want to
+process enormous patterns, so it is possible to compile PCRE to use three-byte
+or four-byte offsets by adding a setting such as
+</P>
+<P>
+<pre>
+ --with-link-size=3
+</PRE>
+</P>
+<P>
+to the <b>configure</b> command. The value given must be 2, 3, or 4. Using
+longer offsets slows down the operation of PCRE because it has to load
+additional bytes when handling them.
+</P>
+<P>
+If you build PCRE with an increased link size, test 2 (and test 5 if you are
+using UTF-8) will fail. Part of the output of these tests is a representation
+of the compiled pattern, and this changes with the link size.
+</P>
+<P>
+Last updated: 21 January 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/html/pcrecallout.html b/doc/html/pcrecallout.html
new file mode 100644
index 0000000..5516c99
--- /dev/null
+++ b/doc/html/pcrecallout.html
@@ -0,0 +1,116 @@
+<html>
+<head>
+<title>pcrecallout specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE CALLOUTS</a>
+<li><a name="TOC2" href="#SEC2">RETURN VALUES</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE CALLOUTS</a><br>
+<P>
+<b>int (*pcre_callout)(pcre_callout_block *);</b>
+</P>
+<P>
+PCRE provides a feature called "callout", which is a means of temporarily
+passing control to the caller of PCRE in the middle of pattern matching. The
+caller of PCRE provides an external function by putting its entry point in the
+global variable <i>pcre_callout</i>. By default, this variable contains NULL,
+which disables all calling out.
+</P>
+<P>
+Within a regular expression, (?C) indicates the points at which the external
+function is to be called. Different callout points can be identified by putting
+a number less than 256 after the letter C. The default value is zero.
+For example, this pattern has two callout points:
+</P>
+<P>
+<pre>
+ (?C1)\dabc(?C2)def
+</PRE>
+</P>
+<P>
+During matching, when PCRE reaches a callout point (and <i>pcre_callout</i> is
+set), the external function is called. Its only argument is a pointer to a
+<b>pcre_callout</b> block. This contains the following variables:
+</P>
+<P>
+<pre>
+ int <i>version</i>;
+ int <i>callout_number</i>;
+ int *<i>offset_vector</i>;
+ const char *<i>subject</i>;
+ int <i>subject_length</i>;
+ int <i>start_match</i>;
+ int <i>current_position</i>;
+ int <i>capture_top</i>;
+ int <i>capture_last</i>;
+ void *<i>callout_data</i>;
+</PRE>
+</P>
+<P>
+The <i>version</i> field is an integer containing the version number of the
+block format. The current version is zero. The version number may change in
+future if additional fields are added, but the intention is never to remove any
+of the existing fields.
+</P>
+<P>
+The <i>callout_number</i> field contains the number of the callout, as compiled
+into the pattern (that is, the number after ?C).
+</P>
+<P>
+The <i>offset_vector</i> field is a pointer to the vector of offsets that was
+passed by the caller to <b>pcre_exec()</b>. The contents can be inspected in
+order to extract substrings that have been matched so far, in the same way as
+for extracting substrings after a match has completed.
+</P>
+<P>
+The <i>subject</i> and <i>subject_length</i> fields contain copies the values
+that were passed to <b>pcre_exec()</b>.
+</P>
+<P>
+The <i>start_match</i> field contains the offset within the subject at which the
+current match attempt started. If the pattern is not anchored, the callout
+function may be called several times for different starting points.
+</P>
+<P>
+The <i>current_position</i> field contains the offset within the subject of the
+current match pointer.
+</P>
+<P>
+The <i>capture_top</i> field contains the number of the highest captured
+substring so far.
+</P>
+<P>
+The <i>capture_last</i> field contains the number of the most recently captured
+substring.
+</P>
+<P>
+The <i>callout_data</i> field contains a value that is passed to
+<b>pcre_exec()</b> by the caller specifically so that it can be passed back in
+callouts. It is passed in the <i>pcre_callout</i> field of the <b>pcre_extra</b>
+data structure. If no such data was passed, the value of <i>callout_data</i> in
+a <b>pcre_callout</b> block is NULL. There is a description of the
+<b>pcre_extra</b> structure in the <b>pcreapi</b> documentation.
+</P>
+<br><a name="SEC2" href="#TOC1">RETURN VALUES</a><br>
+<P>
+The callout function returns an integer. If the value is zero, matching
+proceeds as normal. If the value is greater than zero, matching fails at the
+current point, but backtracking to test other possibilities goes ahead, just as
+if a lookahead assertion had failed. If the value is less than zero, the match
+is abandoned, and <b>pcre_exec()</b> returns the value.
+</P>
+<P>
+Negative values should normally be chosen from the set of PCRE_ERROR_xxx
+values. In particular, PCRE_ERROR_NOMATCH forces a standard "no match" failure.
+The error number PCRE_ERROR_CALLOUT is reserved for use by callout functions;
+it will never be used by PCRE itself.
+</P>
+<P>
+Last updated: 21 January 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/html/pcrecompat.html b/doc/html/pcrecompat.html
new file mode 100644
index 0000000..ecd4565
--- /dev/null
+++ b/doc/html/pcrecompat.html
@@ -0,0 +1,128 @@
+<html>
+<head>
+<title>pcrecompat specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">DIFFERENCES FROM PERL</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">DIFFERENCES FROM PERL</a><br>
+<P>
+This document describes the differences in the ways that PCRE and Perl handle
+regular expressions. The differences described here are with respect to Perl
+5.8.
+</P>
+<P>
+1. PCRE does not allow repeat quantifiers on lookahead assertions. Perl permits
+them, but they do not mean what you might think. For example, (?!a){3} does
+not assert that the next three characters are not "a". It just asserts that the
+next character is not "a" three times.
+</P>
+<P>
+2. Capturing subpatterns that occur inside negative lookahead assertions are
+counted, but their entries in the offsets vector are never set. Perl sets its
+numerical variables from any such patterns that are matched before the
+assertion fails to match something (thereby succeeding), but only if the
+negative lookahead assertion contains just one branch.
+</P>
+<P>
+3. Though binary zero characters are supported in the subject string, they are
+not allowed in a pattern string because it is passed as a normal C string,
+terminated by zero. The escape sequence "\0" can be used in the pattern to
+represent a binary zero.
+</P>
+<P>
+4. The following Perl escape sequences are not supported: \l, \u, \L,
+\U, \P, \p, \N, and \X. In fact these are implemented by Perl's general
+string-handling and are not part of its pattern matching engine. If any of
+these are encountered by PCRE, an error is generated.
+</P>
+<P>
+5. PCRE does support the \Q...\E escape for quoting substrings. Characters in
+between are treated as literals. This is slightly different from Perl in that $
+and @ are also handled as literals inside the quotes. In Perl, they cause
+variable interpolation (but of course PCRE does not have variables). Note the
+following examples:
+</P>
+<P>
+<pre>
+ Pattern PCRE matches Perl matches
+</PRE>
+</P>
+<P>
+<pre>
+ \Qabc$xyz\E abc$xyz abc followed by the
+ contents of $xyz
+ \Qabc\$xyz\E abc\$xyz abc\$xyz
+ \Qabc\E\$\Qxyz\E abc$xyz abc$xyz
+</PRE>
+</P>
+<P>
+In PCRE, the \Q...\E mechanism is not recognized inside a character class.
+</P>
+<P>
+8. Fairly obviously, PCRE does not support the (?{code}) and (?p{code})
+constructions. However, there is some experimental support for recursive
+patterns using the non-Perl items (?R), (?number) and (?P&#62;name). Also, the PCRE
+"callout" feature allows an external function to be called during pattern
+matching.
+</P>
+<P>
+9. There are some differences that are concerned with the settings of captured
+strings when part of a pattern is repeated. For example, matching "aba" against
+the pattern /^(a(b)?)+$/ in Perl leaves $2 unset, but in PCRE it is set to "b".
+</P>
+<P>
+10. PCRE provides some extensions to the Perl regular expression facilities:
+</P>
+<P>
+(a) Although lookbehind assertions must match fixed length strings, each
+alternative branch of a lookbehind assertion can match a different length of
+string. Perl requires them all to have the same length.
+</P>
+<P>
+(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $
+meta-character matches only at the very end of the string.
+</P>
+<P>
+&copy; If PCRE_EXTRA is set, a backslash followed by a letter with no special
+meaning is faulted.
+</P>
+<P>
+(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is
+inverted, that is, by default they are not greedy, but if followed by a
+question mark they are.
+</P>
+<P>
+(e) PCRE_ANCHORED can be used to force a pattern to be tried only at the first
+matching position in the subject string.
+</P>
+<P>
+(f) The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, and PCRE_NO_AUTO_CAPTURE
+options for <b>pcre_exec()</b> have no Perl equivalents.
+</P>
+<P>
+(g) The (?R), (?number), and (?P&#62;name) constructs allows for recursive pattern
+matching (Perl can do this using the (?p{code}) construct, which PCRE cannot
+support.)
+</P>
+<P>
+(h) PCRE supports named capturing substrings, using the Python syntax.
+</P>
+<P>
+(i) PCRE supports the possessive quantifier "++" syntax, taken from Sun's Java
+package.
+</P>
+<P>
+(j) The (R) condition, for testing recursion, is a PCRE extension.
+</P>
+<P>
+(k) The callout facility is PCRE-specific.
+</P>
+<P>
+Last updated: 03 February 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/html/pcregrep.html b/doc/html/pcregrep.html
new file mode 100644
index 0000000..a76cac2
--- /dev/null
+++ b/doc/html/pcregrep.html
@@ -0,0 +1,153 @@
+<html>
+<head>
+<title>pcregrep specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">SYNOPSIS</a>
+<li><a name="TOC2" href="#SEC2">DESCRIPTION</a>
+<li><a name="TOC3" href="#SEC3">OPTIONS</a>
+<li><a name="TOC4" href="#SEC4">LONG OPTIONS</a>
+<li><a name="TOC5" href="#SEC5">DIAGNOSTICS</a>
+<li><a name="TOC6" href="#SEC6">AUTHOR</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
+<P>
+<b>pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...]</b>
+</P>
+<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br>
+<P>
+<b>pcregrep</b> searches files for character patterns, in the same way as other
+grep commands do, but it uses the PCRE regular expression library to support
+patterns that are compatible with the regular expressions of Perl 5. See
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+for a full description of syntax and semantics of the regular expressions that
+PCRE supports.
+</P>
+<P>
+A pattern must be specified on the command line unless the <b>-f</b> option is
+used (see below).
+</P>
+<P>
+If no files are specified, <b>pcregrep</b> reads the standard input. By default,
+each line that matches the pattern is copied to the standard output, and if
+there is more than one file, the file name is printed before each line of
+output. However, there are options that can change how <b>pcregrep</b> behaves.
+</P>
+<P>
+Lines are limited to BUFSIZ characters. BUFSIZ is defined in <b>&#60;stdio.h&#62;</b>.
+The newline character is removed from the end of each line before it is matched
+against the pattern.
+</P>
+<br><a name="SEC3" href="#TOC1">OPTIONS</a><br>
+<P>
+<b>-V</b>
+Write the version number of the PCRE library being used to the standard error
+stream.
+</P>
+<P>
+<b>-c</b>
+Do not print individual lines; instead just print a count of the number of
+lines that would otherwise have been printed. If several files are given, a
+count is printed for each of them.
+</P>
+<P>
+<b>-f</b><i>filename</i>
+Read a number of patterns from the file, one per line, and match all of them
+against each line of input. A line is output if any of the patterns match it.
+When <b>-f</b> is used, no pattern is taken from the command line; all arguments
+are treated as file names. There is a maximum of 100 patterns. Trailing white
+space is removed, and blank lines are ignored. An empty file contains no
+patterns and therefore matches nothing.
+</P>
+<P>
+<b>-h</b>
+Suppress printing of filenames when searching multiple files.
+</P>
+<P>
+<b>-i</b>
+Ignore upper/lower case distinctions during comparisons.
+</P>
+<P>
+<b>-l</b>
+Instead of printing lines from the files, just print the names of the files
+containing lines that would have been printed. Each file name is printed
+once, on a separate line.
+</P>
+<P>
+<b>-n</b>
+Precede each line by its line number in the file.
+</P>
+<P>
+<b>-r</b>
+If any file is a directory, recursively scan the files it contains. Without
+<b>-r</b> a directory is scanned as a normal file.
+</P>
+<P>
+<b>-s</b>
+Work silently, that is, display nothing except error messages.
+The exit status indicates whether any matches were found.
+</P>
+<P>
+<b>-u</b>
+Operate in UTF-8 mode. This option is available only if PCRE has been compiled
+with UTF-8 support. Both the pattern and each subject line are assumed to be
+valid strings of UTF-8 characters.
+</P>
+<P>
+<b>-v</b>
+Invert the sense of the match, so that lines which do <i>not</i> match the
+pattern are now the ones that are found.
+</P>
+<P>
+<b>-x</b>
+Force the pattern to be anchored (it must start matching at the beginning of
+the line) and in addition, require it to match the entire line. This is
+equivalent to having ^ and $ characters at the start and end of each
+alternative branch in the regular expression.
+</P>
+<br><a name="SEC4" href="#TOC1">LONG OPTIONS</a><br>
+<P>
+Long forms of all the options are available, as in GNU grep. They are shown in
+the following table:
+</P>
+<P>
+<pre>
+ -c --count
+ -h --no-filename
+ -i --ignore-case
+ -l --files-with-matches
+ -n --line-number
+ -r --recursive
+ -s --no-messages
+ -u --utf-8
+ -V --version
+ -v --invert-match
+ -x --line-regex
+ -x --line-regexp
+</PRE>
+</P>
+<P>
+In addition, --file=<i>filename</i> is equivalent to -f<i>filename</i>, and
+--help shows the list of options and then exits.
+</P>
+<br><a name="SEC5" href="#TOC1">DIAGNOSTICS</a><br>
+<P>
+Exit status is 0 if any matches were found, 1 if no matches were found, and 2
+for syntax errors or inacessible files (even if matches were found).
+</P>
+<br><a name="SEC6" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel &#60;ph10@cam.ac.uk&#62;
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QG, England.
+</P>
+<P>
+Last updated: 03 February 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/html/pcrepattern.html b/doc/html/pcrepattern.html
new file mode 100644
index 0000000..0a42bf2
--- /dev/null
+++ b/doc/html/pcrepattern.html
@@ -0,0 +1,1607 @@
+<html>
+<head>
+<title>pcrepattern specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE REGULAR EXPRESSION DETAILS</a>
+<li><a name="TOC2" href="#SEC2">BACKSLASH</a>
+<li><a name="TOC3" href="#SEC3">CIRCUMFLEX AND DOLLAR</a>
+<li><a name="TOC4" href="#SEC4">FULL STOP (PERIOD, DOT)</a>
+<li><a name="TOC5" href="#SEC5">MATCHING A SINGLE BYTE</a>
+<li><a name="TOC6" href="#SEC6">SQUARE BRACKETS</a>
+<li><a name="TOC7" href="#SEC7">POSIX CHARACTER CLASSES</a>
+<li><a name="TOC8" href="#SEC8">VERTICAL BAR</a>
+<li><a name="TOC9" href="#SEC9">INTERNAL OPTION SETTING</a>
+<li><a name="TOC10" href="#SEC10">SUBPATTERNS</a>
+<li><a name="TOC11" href="#SEC11">NAMED SUBPATTERNS</a>
+<li><a name="TOC12" href="#SEC12">REPETITION</a>
+<li><a name="TOC13" href="#SEC13">ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS</a>
+<li><a name="TOC14" href="#SEC14">BACK REFERENCES</a>
+<li><a name="TOC15" href="#SEC15">ASSERTIONS</a>
+<li><a name="TOC16" href="#SEC16">CONDITIONAL SUBPATTERNS</a>
+<li><a name="TOC17" href="#SEC17">COMMENTS</a>
+<li><a name="TOC18" href="#SEC18">RECURSIVE PATTERNS</a>
+<li><a name="TOC19" href="#SEC19">SUBPATTERNS AS SUBROUTINES</a>
+<li><a name="TOC20" href="#SEC20">CALLOUTS</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE REGULAR EXPRESSION DETAILS</a><br>
+<P>
+The syntax and semantics of the regular expressions supported by PCRE are
+described below. Regular expressions are also described in the Perl
+documentation and in a number of other books, some of which have copious
+examples. Jeffrey Friedl's "Mastering Regular Expressions", published by
+O'Reilly, covers them in great detail. The description here is intended as
+reference documentation.
+</P>
+<P>
+The basic operation of PCRE is on strings of bytes. However, there is also
+support for UTF-8 character strings. To use this support you must build PCRE to
+include UTF-8 support, and then call <b>pcre_compile()</b> with the PCRE_UTF8
+option. How this affects the pattern matching is mentioned in several places
+below. There is also a summary of UTF-8 features in the
+<a href="pcre.html#utf8support">section on UTF-8 support</a>
+in the main
+<a href="pcre.html"><b>pcre</b></a>
+page.
+</P>
+<P>
+A regular expression is a pattern that is matched against a subject string from
+left to right. Most characters stand for themselves in a pattern, and match the
+corresponding characters in the subject. As a trivial example, the pattern
+</P>
+<P>
+<pre>
+ The quick brown fox
+</PRE>
+</P>
+<P>
+matches a portion of a subject string that is identical to itself. The power of
+regular expressions comes from the ability to include alternatives and
+repetitions in the pattern. These are encoded in the pattern by the use of
+<i>meta-characters</i>, which do not stand for themselves but instead are
+interpreted in some special way.
+</P>
+<P>
+There are two different sets of meta-characters: those that are recognized
+anywhere in the pattern except within square brackets, and those that are
+recognized in square brackets. Outside square brackets, the meta-characters are
+as follows:
+</P>
+<P>
+<pre>
+ \ general escape character with several uses
+ ^ assert start of string (or line, in multiline mode)
+ $ assert end of string (or line, in multiline mode)
+ . match any character except newline (by default)
+ [ start character class definition
+ | start of alternative branch
+ ( start subpattern
+ ) end subpattern
+ ? extends the meaning of (
+ also 0 or 1 quantifier
+ also quantifier minimizer
+ * 0 or more quantifier
+ + 1 or more quantifier
+ also "possessive quantifier"
+ { start min/max quantifier
+</PRE>
+</P>
+<P>
+Part of a pattern that is in square brackets is called a "character class". In
+a character class the only meta-characters are:
+</P>
+<P>
+<pre>
+ \ general escape character
+ ^ negate the class, but only if the first character
+ - indicates character range
+ [ POSIX character class (only if followed by POSIX
+ syntax)
+ ] terminates the character class
+</PRE>
+</P>
+<P>
+The following sections describe the use of each of the meta-characters.
+</P>
+<br><a name="SEC2" href="#TOC1">BACKSLASH</a><br>
+<P>
+The backslash character has several uses. Firstly, if it is followed by a
+non-alphameric character, it takes away any special meaning that character may
+have. This use of backslash as an escape character applies both inside and
+outside character classes.
+</P>
+<P>
+For example, if you want to match a * character, you write \* in the pattern.
+This escaping action applies whether or not the following character would
+otherwise be interpreted as a meta-character, so it is always safe to precede a
+non-alphameric with backslash to specify that it stands for itself. In
+particular, if you want to match a backslash, you write \\.
+</P>
+<P>
+If a pattern is compiled with the PCRE_EXTENDED option, whitespace in the
+pattern (other than in a character class) and characters between a # outside
+a character class and the next newline character are ignored. An escaping
+backslash can be used to include a whitespace or # character as part of the
+pattern.
+</P>
+<P>
+If you want to remove the special meaning from a sequence of characters, you
+can do so by putting them between \Q and \E. This is different from Perl in
+that $ and @ are handled as literals in \Q...\E sequences in PCRE, whereas in
+Perl, $ and @ cause variable interpolation. Note the following examples:
+</P>
+<P>
+<pre>
+ Pattern PCRE matches Perl matches
+</PRE>
+</P>
+<P>
+<pre>
+ \Qabc$xyz\E abc$xyz abc followed by the
+ contents of $xyz
+ \Qabc\$xyz\E abc\$xyz abc\$xyz
+ \Qabc\E\$\Qxyz\E abc$xyz abc$xyz
+</PRE>
+</P>
+<P>
+The \Q...\E sequence is recognized both inside and outside character classes.
+</P>
+<P>
+A second use of backslash provides a way of encoding non-printing characters
+in patterns in a visible manner. There is no restriction on the appearance of
+non-printing characters, apart from the binary zero that terminates a pattern,
+but when a pattern is being prepared by text editing, it is usually easier to
+use one of the following escape sequences than the binary character it
+represents:
+</P>
+<P>
+<pre>
+ \a alarm, that is, the BEL character (hex 07)
+ \cx "control-x", where x is any character
+ \e escape (hex 1B)
+ \f formfeed (hex 0C)
+ \n newline (hex 0A)
+ \r carriage return (hex 0D)
+ \t tab (hex 09)
+ \ddd character with octal code ddd, or backreference
+ \xhh character with hex code hh
+ \x{hhh..} character with hex code hhh... (UTF-8 mode only)
+</PRE>
+</P>
+<P>
+The precise effect of \cx is as follows: if x is a lower case letter, it
+is converted to upper case. Then bit 6 of the character (hex 40) is inverted.
+Thus \cz becomes hex 1A, but \c{ becomes hex 3B, while \c; becomes hex
+7B.
+</P>
+<P>
+After \x, from zero to two hexadecimal digits are read (letters can be in
+upper or lower case). In UTF-8 mode, any number of hexadecimal digits may
+appear between \x{ and }, but the value of the character code must be less
+than 2**31 (that is, the maximum hexadecimal value is 7FFFFFFF). If characters
+other than hexadecimal digits appear between \x{ and }, or if there is no
+terminating }, this form of escape is not recognized. Instead, the initial
+\x will be interpreted as a basic hexadecimal escape, with no following
+digits, giving a byte whose value is zero.
+</P>
+<P>
+Characters whose value is less than 256 can be defined by either of the two
+syntaxes for \x when PCRE is in UTF-8 mode. There is no difference in the
+way they are handled. For example, \xdc is exactly the same as \x{dc}.
+</P>
+<P>
+After \0 up to two further octal digits are read. In both cases, if there
+are fewer than two digits, just those that are present are used. Thus the
+sequence \0\x\07 specifies two binary zeros followed by a BEL character
+(code value 7). Make sure you supply two digits after the initial zero if the
+character that follows is itself an octal digit.
+</P>
+<P>
+The handling of a backslash followed by a digit other than 0 is complicated.
+Outside a character class, PCRE reads it and any following digits as a decimal
+number. If the number is less than 10, or if there have been at least that many
+previous capturing left parentheses in the expression, the entire sequence is
+taken as a <i>back reference</i>. A description of how this works is given
+later, following the discussion of parenthesized subpatterns.
+</P>
+<P>
+Inside a character class, or if the decimal number is greater than 9 and there
+have not been that many capturing subpatterns, PCRE re-reads up to three octal
+digits following the backslash, and generates a single byte from the least
+significant 8 bits of the value. Any subsequent digits stand for themselves.
+For example:
+</P>
+<P>
+<pre>
+ \040 is another way of writing a space
+ \40 is the same, provided there are fewer than 40
+ previous capturing subpatterns
+ \7 is always a back reference
+ \11 might be a back reference, or another way of
+ writing a tab
+ \011 is always a tab
+ \0113 is a tab followed by the character "3"
+ \113 might be a back reference, otherwise the
+ character with octal code 113
+ \377 might be a back reference, otherwise
+ the byte consisting entirely of 1 bits
+ \81 is either a back reference, or a binary zero
+ followed by the two characters "8" and "1"
+</PRE>
+</P>
+<P>
+Note that octal values of 100 or greater must not be introduced by a leading
+zero, because no more than three octal digits are ever read.
+</P>
+<P>
+All the sequences that define a single byte value or a single UTF-8 character
+(in UTF-8 mode) can be used both inside and outside character classes. In
+addition, inside a character class, the sequence \b is interpreted as the
+backspace character (hex 08). Outside a character class it has a different
+meaning (see below).
+</P>
+<P>
+The third use of backslash is for specifying generic character types:
+</P>
+<P>
+<pre>
+ \d any decimal digit
+ \D any character that is not a decimal digit
+ \s any whitespace character
+ \S any character that is not a whitespace character
+ \w any "word" character
+ \W any "non-word" character
+</PRE>
+</P>
+<P>
+Each pair of escape sequences partitions the complete set of characters into
+two disjoint sets. Any given character matches one, and only one, of each pair.
+</P>
+<P>
+In UTF-8 mode, characters with values greater than 255 never match \d, \s, or
+\w, and always match \D, \S, and \W.
+</P>
+<P>
+For compatibility with Perl, \s does not match the VT character (code 11).
+This makes it different from the the POSIX "space" class. The \s characters
+are HT (9), LF (10), FF (12), CR (13), and space (32).
+</P>
+<P>
+A "word" character is any letter or digit or the underscore character, that is,
+any character which can be part of a Perl "word". The definition of letters and
+digits is controlled by PCRE's character tables, and may vary if locale-
+specific matching is taking place (see
+<a href="pcreapi.html#localesupport">"Locale support"</a>
+in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page). For example, in the "fr" (French) locale, some character codes greater
+than 128 are used for accented letters, and these are matched by \w.
+</P>
+<P>
+These character type sequences can appear both inside and outside character
+classes. They each match one character of the appropriate type. If the current
+matching point is at the end of the subject string, all of them fail, since
+there is no character to match.
+</P>
+<P>
+The fourth use of backslash is for certain simple assertions. An assertion
+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
+</P>
+<P>
+<pre>
+ \b matches at a word boundary
+ \B matches when not at a word boundary
+ \A matches at start of subject
+ \Z matches at end of subject or before newline at end
+ \z matches at end of subject
+ \G matches at first matching position in subject
+</PRE>
+</P>
+<P>
+These assertions may not appear in character classes (but note that \b has a
+different meaning, namely the backspace character, inside a character class).
+</P>
+<P>
+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.
+</P>
+<P>
+The \A, \Z, and \z assertions differ from the traditional circumflex and
+dollar (described below) 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.
+</P>
+<P>
+They are not affected by the PCRE_NOTBOL or PCRE_NOTEOL options. If the
+<i>startoffset</i> argument of <b>pcre_exec()</b> 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 that is the last character of the string as well as at the end of the
+string, whereas \z matches only at the end.
+</P>
+<P>
+The \G assertion is true only when the current matching position is at the
+start point of the match, as specified by the <i>startoffset</i> argument of
+<b>pcre_exec()</b>. It differs from \A when the value of <i>startoffset</i> is
+non-zero. By calling <b>pcre_exec()</b> 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.
+</P>
+<P>
+Note, however, that PCRE'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 PCRE does just one match at a time, it cannot
+reproduce this behaviour.
+</P>
+<P>
+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.
+</P>
+<br><a name="SEC3" href="#TOC1">CIRCUMFLEX AND DOLLAR</a><br>
+<P>
+Outside a character class, in the default matching mode, the circumflex
+character is an assertion which is true only if the current matching point is
+at the start of the subject string. If the <i>startoffset</i> argument of
+<b>pcre_exec()</b> is non-zero, circumflex can never match if the PCRE_MULTILINE
+option is unset. Inside a character class, circumflex has an entirely different
+meaning (see below).
+</P>
+<P>
+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 subject, it is said to be an
+"anchored" pattern. (There are also other constructs that can cause a pattern
+to be anchored.)
+</P>
+<P>
+A dollar character is an assertion which is true only if the current matching
+point is at the end of the subject string, or immediately before a newline
+character that is the last character in the string (by default). Dollar need
+not be the last character of the pattern if a number 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 character class.
+</P>
+<P>
+The meaning of dollar can be changed so that it matches only at the very end of
+the string, by setting the PCRE_DOLLAR_ENDONLY option at compile time. This
+does not affect the \Z assertion.
+</P>
+<P>
+The meanings of the circumflex and dollar characters are changed if the
+PCRE_MULTILINE option is set. When this is the case, they match immediately
+after and immediately before an internal newline character, respectively, in
+addition to matching at the start and end of the subject string. For example,
+the pattern /^abc$/ matches the subject string "def\nabc" 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 <i>startoffset</i> argument of
+<b>pcre_exec()</b> is non-zero. The PCRE_DOLLAR_ENDONLY option is ignored if
+PCRE_MULTILINE is set.
+</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 PCRE_MULTILINE is set or not.
+</P>
+<br><a name="SEC4" href="#TOC1">FULL STOP (PERIOD, DOT)</a><br>
+<P>
+Outside a character class, a dot in the pattern matches any one character in
+the subject, including a non-printing character, but not (by default) newline.
+In UTF-8 mode, a dot matches any UTF-8 character, which might be more than one
+byte long, except (by default) for newline. If the PCRE_DOTALL option is set,
+dots match newlines as well. The handling of dot is entirely independent of the
+handling of circumflex and dollar, the only relationship being that they both
+involve newline characters. Dot has no special meaning in a character class.
+</P>
+<br><a name="SEC5" href="#TOC1">MATCHING A SINGLE BYTE</a><br>
+<P>
+Outside a character class, the escape sequence \C matches any one byte, both
+in and out of UTF-8 mode. Unlike a dot, it always matches a newline. The
+feature is provided in Perl in order to match individual bytes in UTF-8 mode.
+Because it breaks up UTF-8 characters into individual bytes, what remains in
+the string may be a malformed UTF-8 string. For this reason it is best avoided.
+</P>
+<P>
+PCRE does not allow \C to appear in lookbehind assertions (see below), because
+in UTF-8 mode it makes it impossible to calculate the length of the lookbehind.
+</P>
+<br><a name="SEC6" href="#TOC1">SQUARE BRACKETS</a><br>
+<P>
+An opening square bracket introduces a character class, terminated by a closing
+square bracket. A closing square bracket on its own is not special. 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.
+</P>
+<P>
+A character class matches a single character in the subject. In UTF-8 mode, the
+character may occupy more than one byte. 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 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 it is not the first character, or escape it with a
+backslash.
+</P>
+<P>
+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 which
+are in the class by enumerating those that are not. It is not an assertion: it
+still consumes a character from the subject string, and fails if the current
+pointer is at the end of the string.
+</P>
+<P>
+In UTF-8 mode, characters with values greater than 255 can be included in a
+class as a literal string of bytes, or by using the \x{ escaping mechanism.
+</P>
+<P>
+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. PCRE does not support the concept of case for characters
+with values greater than 255.
+</P>
+<P>
+The newline character is never treated in any special way in character classes,
+whatever the setting of the PCRE_DOTALL or PCRE_MULTILINE options is. A class
+such as [^a] will always match a newline.
+</P>
+<P>
+The minus (hyphen) character can be used to specify a range of characters 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.
+</P>
+<P>
+It is not possible to have the literal character "]" as the end character 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 interpreted as a single class containing a
+range followed by two separate characters. The octal or hexadecimal
+representation of "]" can also be used to end a range.
+</P>
+<P>
+Ranges operate in the collating sequence of character values. They can also be
+used for characters specified numerically, for example [\000-\037]. In UTF-8
+mode, ranges can include characters whose values are greater than 255, for
+example [\x{100}-\x{2ff}].
+</P>
+<P>
+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 if character tables for the "fr"
+locale are in use, [\xc8-\xcb] matches accented E characters in both cases.
+</P>
+<P>
+The character types \d, \D, \s, \S, \w, and \W may also appear in a
+character class, and add the characters that they match to the class. For
+example, [\dABCDEF] matches any hexadecimal digit. 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.
+</P>
+<P>
+All non-alphameric characters other than \, -, ^ (at the start) and the
+terminating ] are non-special in character classes, but it does no harm if they
+are escaped.
+</P>
+<br><a name="SEC7" href="#TOC1">POSIX CHARACTER CLASSES</a><br>
+<P>
+Perl supports the POSIX notation for character classes, which uses names
+enclosed by [: and :] within the enclosing square brackets. PCRE also supports
+this notation. For example,
+</P>
+<P>
+<pre>
+ [01[:alpha:]%]
+</PRE>
+</P>
+<P>
+matches "0", "1", any alphabetic character, or "%". The supported class names
+are
+</P>
+<P>
+<pre>
+ alnum letters and digits
+ alpha letters
+ ascii character codes 0 - 127
+ blank space or tab only
+ cntrl control characters
+ digit decimal digits (same as \d)
+ graph printing characters, excluding space
+ lower lower case letters
+ print printing characters, including space
+ punct printing characters, excluding letters and digits
+ space white space (not quite the same as \s)
+ upper upper case letters
+ word "word" characters (same as \w)
+ xdigit hexadecimal digits
+</PRE>
+</P>
+<P>
+The "space" characters are HT (9), LF (10), VT (11), FF (12), CR (13), and
+space (32). Notice that this list includes the VT character (code 11). This
+makes "space" different to \s, which does not include VT (for Perl
+compatibility).
+</P>
+<P>
+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,
+</P>
+<P>
+<pre>
+ [12[:^digit:]]
+</PRE>
+</P>
+<P>
+matches "1", "2", or any non-digit. PCRE (and Perl) also recognize the POSIX
+syntax [.ch.] and [=ch=] where "ch" is a "collating element", but these are not
+supported, and an error is given if they are encountered.
+</P>
+<P>
+In UTF-8 mode, characters with values greater than 255 do not match any of
+the POSIX character classes.
+</P>
+<br><a name="SEC8" href="#TOC1">VERTICAL BAR</a><br>
+<P>
+Vertical bar characters are used to separate alternative patterns. For example,
+the pattern
+</P>
+<P>
+<pre>
+ gilbert|sullivan
+</PRE>
+</P>
+<P>
+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 rest of the main
+pattern as well as the alternative in the subpattern.
+</P>
+<br><a name="SEC9" href="#TOC1">INTERNAL OPTION SETTING</a><br>
+<P>
+The settings of the PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and
+PCRE_EXTENDED options can be changed from within the pattern by a sequence of
+Perl option letters enclosed between "(?" and ")". The option letters are
+</P>
+<P>
+<pre>
+ i for PCRE_CASELESS
+ m for PCRE_MULTILINE
+ s for PCRE_DOTALL
+ x for PCRE_EXTENDED
+</PRE>
+</P>
+<P>
+For example, (?im) sets caseless, multiline matching. It is also possible to
+unset these options by preceding the letter with a hyphen, and a combined
+setting and unsetting such as (?im-sx), which sets PCRE_CASELESS and
+PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED, is also
+permitted. If a letter appears both before and after the hyphen, the option is
+unset.
+</P>
+<P>
+When an option change 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, PCRE extracts it into
+the global options (and it will therefore show up in data extracted by the
+<b>pcre_fullinfo()</b> function).
+</P>
+<P>
+An option change within a subpattern affects only that part of the current
+pattern that follows it, so
+</P>
+<P>
+<pre>
+ (a(?i)b)c
+</PRE>
+</P>
+<P>
+matches abc and aBc and no other strings (assuming PCRE_CASELESS is not used).
+By this means, options can be made to have different settings in different
+parts of the pattern. Any changes made in one alternative do carry on
+into subsequent branches within the same subpattern. For example,
+</P>
+<P>
+<pre>
+ (a(?i)b|c)
+</PRE>
+</P>
+<P>
+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.
+</P>
+<P>
+The PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can be changed in the
+same way as the Perl-compatible options by using the characters U and X
+respectively. The (?X) flag setting is special in that it must always occur
+earlier in the pattern than any of the additional features it turns on, even
+when it is at top level. It is best put at the start.
+</P>
+<br><a name="SEC10" href="#TOC1">SUBPATTERNS</a><br>
+<P>
+Subpatterns are delimited by parentheses (round brackets), which can be nested.
+Marking part of a pattern as a subpattern does two things:
+</P>
+<P>
+1. It localizes a set of alternatives. For example, the pattern
+</P>
+<P>
+<pre>
+ cat(aract|erpillar|)
+</PRE>
+</P>
+<P>
+matches one of the words "cat", "cataract", or "caterpillar". Without the
+parentheses, it would match "cataract", "erpillar" or the empty string.
+</P>
+<P>
+2. It sets up the subpattern as a capturing subpattern (as defined above).
+When the whole pattern matches, that portion of the subject string that matched
+the subpattern is passed back to the caller via the <i>ovector</i> argument of
+<b>pcre_exec()</b>. Opening parentheses are counted from left to right (starting
+from 1) to obtain the numbers of the capturing subpatterns.
+</P>
+<P>
+For example, if the string "the red king" is matched against the pattern
+</P>
+<P>
+<pre>
+ the ((red|white) (king|queen))
+</PRE>
+</P>
+<P>
+the captured substrings are "red king", "red", and "king", and are numbered 1,
+2, and 3, respectively.
+</P>
+<P>
+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 capturing, 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
+</P>
+<P>
+<pre>
+ the ((?:red|white) (king|queen))
+</PRE>
+</P>
+<P>
+the captured substrings are "white queen" and "queen", and are numbered 1 and
+2. The maximum number of capturing subpatterns is 65535, and the maximum depth
+of nesting of all subpatterns, both capturing and non-capturing, is 200.
+</P>
+<P>
+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
+</P>
+<P>
+<pre>
+ (?i:saturday|sunday)
+ (?:(?i)saturday|sunday)
+</PRE>
+</P>
+<P>
+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 "Saturday".
+</P>
+<br><a name="SEC11" href="#TOC1">NAMED SUBPATTERNS</a><br>
+<P>
+Identifying capturing parentheses by number is simple, but it can be very hard
+to keep track of the numbers in complicated regular expressions. Furthermore,
+if an expression is modified, the numbers may change. To help with the
+difficulty, PCRE supports the naming of subpatterns, something that Perl does
+not provide. The Python syntax (?P&#60;name&#62;...) is used. Names consist of
+alphanumeric characters and underscores, and must be unique within a pattern.
+</P>
+<P>
+Named capturing parentheses are still allocated numbers as well as names. The
+PCRE API provides function calls for extracting the name-to-number translation
+table from a compiled pattern. For further details see the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation.
+</P>
+<br><a name="SEC12" href="#TOC1">REPETITION</a><br>
+<P>
+Repetition is specified by quantifiers, which can follow any of the following
+items:
+</P>
+<P>
+<pre>
+ a literal data character
+ the . metacharacter
+ the \C escape sequence
+ escapes such as \d that match single characters
+ a character class
+ a back reference (see next section)
+ a parenthesized subpattern (unless it is an assertion)
+</PRE>
+</P>
+<P>
+The general repetition quantifier specifies a minimum and maximum number of
+permitted matches, by giving the two numbers in curly brackets (braces),
+separated by a comma. The numbers must be less than 65536, and the first must
+be less than or equal to the second. For example:
+</P>
+<P>
+<pre>
+ z{2,4}
+</PRE>
+</P>
+<P>
+matches "zz", "zzz", or "zzzz". A closing brace on its own is not a special
+character. If the second number is omitted, but the comma is present, there is
+no upper limit; if the second number and the comma are both omitted, the
+quantifier specifies an exact number of required matches. Thus
+</P>
+<P>
+<pre>
+ [aeiou]{3,}
+</PRE>
+</P>
+<P>
+matches at least 3 successive vowels, but may match many more, while
+</P>
+<P>
+<pre>
+ \d{8}
+</PRE>
+</P>
+<P>
+matches exactly 8 digits. An opening curly bracket that appears in a position
+where a quantifier is not allowed, or one that does not match the syntax of a
+quantifier, is taken as a literal character. For example, {,6} is not a
+quantifier, but a literal string of four characters.
+</P>
+<P>
+In UTF-8 mode, quantifiers apply to UTF-8 characters rather than to individual
+bytes. Thus, for example, \x{100}{2} matches two UTF-8 characters, each of
+which is represented by a two-byte sequence.
+</P>
+<P>
+The quantifier {0} is permitted, causing the expression to behave as if the
+previous item and the quantifier were not present.
+</P>
+<P>
+For convenience (and historical compatibility) the three most common
+quantifiers have single-character abbreviations:
+</P>
+<P>
+<pre>
+ * is equivalent to {0,}
+ + is equivalent to {1,}
+ ? is equivalent to {0,1}
+</PRE>
+</P>
+<P>
+It is possible to construct infinite loops by following a subpattern that can
+match no characters with a quantifier that has no upper limit, for example:
+</P>
+<P>
+<pre>
+ (a?)*
+</PRE>
+</P>
+<P>
+Earlier versions of Perl and PCRE used to give an error at compile time for
+such patterns. However, because there are cases where this can be useful, such
+patterns are now accepted, but if any repetition of the subpattern does in fact
+match no characters, the loop is forcibly broken.
+</P>
+<P>
+By default, the quantifiers are "greedy", that is, they match as much as
+possible (up to the maximum number of permitted times), without causing the
+rest of the pattern to fail. The classic example of where this gives problems
+is in trying to match comments in C programs. These appear between the
+sequences /* and */ and within the sequence, individual * and / characters may
+appear. An attempt to match C comments by applying the pattern
+</P>
+<P>
+<pre>
+ /\*.*\*/
+</PRE>
+</P>
+<P>
+to the string
+</P>
+<P>
+<pre>
+ /* first command */ not comment /* second comment */
+</PRE>
+</P>
+<P>
+fails, because it matches the entire string owing to the greediness of the .*
+item.
+</P>
+<P>
+However, if a quantifier is followed by a question mark, it ceases to be
+greedy, and instead matches the minimum number of times possible, so the
+pattern
+</P>
+<P>
+<pre>
+ /\*.*?\*/
+</PRE>
+</P>
+<P>
+does the right thing with the C comments. The meaning of the various
+quantifiers is not otherwise changed, just the preferred number of matches.
+Do not confuse this use of question mark with its use as a quantifier in its
+own right. Because it has two uses, it can sometimes appear doubled, as in
+</P>
+<P>
+<pre>
+ \d??\d
+</PRE>
+</P>
+<P>
+which matches one digit by preference, but can match two if that is the only
+way the rest of the pattern matches.
+</P>
+<P>
+If the PCRE_UNGREEDY option is set (an option which is not available in Perl),
+the quantifiers are not greedy by default, but individual ones can be made
+greedy by following them with a question mark. In other words, it inverts the
+default behaviour.
+</P>
+<P>
+When a parenthesized subpattern is quantified with a minimum repeat count that
+is greater than 1 or with a limited maximum, more store is required for the
+compiled pattern, in proportion to the size of the minimum or maximum.
+</P>
+<P>
+If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equivalent
+to Perl's /s) is set, thus allowing the . to match newlines, the pattern is
+implicitly anchored, because whatever follows will be tried against every
+character position in the subject string, so there is no point in retrying the
+overall match at any position after the first. PCRE normally treats such a
+pattern as though it were preceded by \A.
+</P>
+<P>
+In cases where it is known that the subject string contains no newlines, it is
+worth setting PCRE_DOTALL in order to obtain this optimization, or
+alternatively using ^ to indicate anchoring explicitly.
+</P>
+<P>
+However, there is one situation where the optimization cannot be used. When .*
+is inside capturing parentheses that are the subject of a backreference
+elsewhere in the pattern, a match at the start may fail, and a later one
+succeed. Consider, for example:
+</P>
+<P>
+<pre>
+ (.*)abc\1
+</PRE>
+</P>
+<P>
+If the subject is "xyz123abc123" the match point is the fourth character. For
+this reason, such a pattern is not implicitly anchored.
+</P>
+<P>
+When a capturing subpattern is repeated, the value captured is the substring
+that matched the final iteration. For example, after
+</P>
+<P>
+<pre>
+ (tweedle[dume]{3}\s*)+
+</PRE>
+</P>
+<P>
+has matched "tweedledum tweedledee" the value of the captured substring is
+"tweedledee". However, if there are nested capturing subpatterns, the
+corresponding captured values may have been set in previous iterations. For
+example, after
+</P>
+<P>
+<pre>
+ /(a|(b))+/
+</PRE>
+</P>
+<P>
+matches "aba" the value of the second captured substring is "b".
+</P>
+<br><a name="SEC13" href="#TOC1">ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS</a><br>
+<P>
+With both maximizing and minimizing repetition, failure of what follows
+normally causes the repeated item to be re-evaluated to see if a different
+number of repeats allows the rest of the pattern to match. Sometimes it is
+useful to prevent this, either to change the nature of the match, or to cause
+it fail earlier than it otherwise might, when the author of the pattern knows
+there is no point in carrying on.
+</P>
+<P>
+Consider, for example, the pattern \d+foo when applied to the subject line
+</P>
+<P>
+<pre>
+ 123456bar
+</PRE>
+</P>
+<P>
+After matching all 6 digits and then failing to match "foo", the normal
+action of the matcher is to try again with only 5 digits matching the \d+
+item, and then with 4, and so on, before ultimately failing. "Atomic grouping"
+(a term taken from Jeffrey Friedl's book) provides the means for specifying
+that once a subpattern has matched, it is not to be re-evaluated in this way.
+</P>
+<P>
+If we use atomic grouping for the previous example, the matcher would give up
+immediately on failing to match "foo" the first time. The notation is a kind of
+special parenthesis, starting with (?&#62; as in this example:
+</P>
+<P>
+<pre>
+ (?&#62;\d+)bar
+</PRE>
+</P>
+<P>
+This kind of parenthesis "locks up" the part of the pattern it contains once
+it has matched, and a failure further into the pattern is prevented from
+backtracking into it. Backtracking past it to previous items, however, works as
+normal.
+</P>
+<P>
+An alternative description is that a subpattern of this type matches the string
+of characters that an identical standalone pattern would match, if anchored at
+the current point in the subject string.
+</P>
+<P>
+Atomic grouping subpatterns are not capturing subpatterns. Simple cases such as
+the above example can be thought of as a maximizing repeat that must swallow
+everything it can. So, while both \d+ and \d+? are prepared to adjust the
+number of digits they match in order to make the rest of the pattern match,
+(?&#62;\d+) can only match an entire sequence of digits.
+</P>
+<P>
+Atomic groups in general can of course contain arbitrarily complicated
+subpatterns, and can be nested. However, when the subpattern for an atomic
+group is just a single repeated item, as in the example above, a simpler
+notation, called a "possessive quantifier" can be used. This consists of an
+additional + character following a quantifier. Using this notation, the
+previous example can be rewritten as
+</P>
+<P>
+<pre>
+ \d++bar
+</PRE>
+</P>
+<P>
+Possessive quantifiers are always greedy; the setting of the PCRE_UNGREEDY
+option is ignored. They are a convenient notation for the simpler forms of
+atomic group. However, there is no difference in the meaning or processing of a
+possessive quantifier and the equivalent atomic group.
+</P>
+<P>
+The possessive quantifier syntax is an extension to the Perl syntax. It
+originates in Sun's Java package.
+</P>
+<P>
+When a pattern contains an unlimited repeat inside a subpattern that can itself
+be repeated an unlimited number of times, the use of an atomic group is the
+only way to avoid some failing matches taking a very long time indeed. The
+pattern
+</P>
+<P>
+<pre>
+ (\D+|&#60;\d+&#62;)*[!?]
+</PRE>
+</P>
+<P>
+matches an unlimited number of substrings that either consist of non-digits, or
+digits enclosed in &#60;&#62;, followed by either ! or ?. When it matches, it runs
+quickly. However, if it is applied to
+</P>
+<P>
+<pre>
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+</PRE>
+</P>
+<P>
+it takes a long time before reporting failure. This is because the string can
+be divided between the two repeats in a large number of ways, and all have to
+be tried. (The example used [!?] rather than a single character at the end,
+because both PCRE and Perl have an optimization that allows for fast failure
+when a single character is used. They remember the last single character that
+is required for a match, and fail early if it is not present in the string.)
+If the pattern is changed to
+</P>
+<P>
+<pre>
+ ((?&#62;\D+)|&#60;\d+&#62;)*[!?]
+</PRE>
+</P>
+<P>
+sequences of non-digits cannot be broken, and failure happens quickly.
+</P>
+<br><a name="SEC14" href="#TOC1">BACK REFERENCES</a><br>
+<P>
+Outside a character class, a backslash followed by a digit greater than 0 (and
+possibly further digits) is a back reference to a capturing subpattern earlier
+(that is, to its left) in the pattern, provided there have been that many
+previous capturing left parentheses.
+</P>
+<P>
+However, if the decimal number following the backslash is less than 10, it is
+always taken as a back reference, and causes an error only if there are not
+that many capturing left parentheses in the entire pattern. In other words, the
+parentheses that are referenced need not be to the left of the reference for
+numbers less than 10. See the section entitled "Backslash" above for further
+details of the handling of digits following a backslash.
+</P>
+<P>
+A back reference matches whatever actually matched the capturing subpattern in
+the current subject string, rather than anything matching the subpattern
+itself (see
+<a href="#subpatternsassubroutines">"Subpatterns as subroutines"</a>
+below for a way of doing that). So the pattern
+</P>
+<P>
+<pre>
+ (sens|respons)e and \1ibility
+</PRE>
+</P>
+<P>
+matches "sense and sensibility" and "response and responsibility", but not
+"sense and responsibility". If caseful matching is in force at the time of the
+back reference, the case of letters is relevant. For example,
+</P>
+<P>
+<pre>
+ ((?i)rah)\s+\1
+</PRE>
+</P>
+<P>
+matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original
+capturing subpattern is matched caselessly.
+</P>
+<P>
+Back references to named subpatterns use the Python syntax (?P=name). We could
+rewrite the above example as follows:
+</P>
+<P>
+<pre>
+ (?&#60;p1&#62;(?i)rah)\s+(?P=p1)
+</PRE>
+</P>
+<P>
+There may be more than one back reference to the same subpattern. If a
+subpattern has not actually been used in a particular match, any back
+references to it always fail. For example, the pattern
+</P>
+<P>
+<pre>
+ (a|(bc))\2
+</PRE>
+</P>
+<P>
+always fails if it starts to match "a" rather than "bc". Because there may be
+many capturing parentheses in a pattern, all digits following the backslash are
+taken as part of a potential back reference number. If the pattern continues
+with a digit character, some delimiter must be used to terminate the back
+reference. If the PCRE_EXTENDED option is set, this can be whitespace.
+Otherwise an empty comment can be used.
+</P>
+<P>
+A back reference that occurs inside the parentheses to which it refers fails
+when the subpattern is first used, so, for example, (a\1) never matches.
+However, such references can be useful inside repeated subpatterns. For
+example, the pattern
+</P>
+<P>
+<pre>
+ (a|b\1)+
+</PRE>
+</P>
+<P>
+matches any number of "a"s and also "aba", "ababbaa" etc. At each iteration of
+the subpattern, the back reference matches the character string corresponding
+to the previous iteration. In order for this to work, the pattern must be such
+that the first iteration does not need to match the back reference. This can be
+done using alternation, as in the example above, or by a quantifier with a
+minimum of zero.
+</P>
+<br><a name="SEC15" href="#TOC1">ASSERTIONS</a><br>
+<P>
+An assertion is a test on the characters following or preceding the current
+matching point that does not actually consume any characters. The simple
+assertions coded as \b, \B, \A, \G, \Z, \z, ^ and $ are described above.
+More complicated assertions are coded as subpatterns. There are two kinds:
+those that look ahead of the current position in the subject string, and those
+that look behind it.
+</P>
+<P>
+An assertion subpattern is matched in the normal way, except that it does not
+cause the current matching position to be changed. Lookahead assertions start
+with (?= for positive assertions and (?! for negative assertions. For example,
+</P>
+<P>
+<pre>
+ \w+(?=;)
+</PRE>
+</P>
+<P>
+matches a word followed by a semicolon, but does not include the semicolon in
+the match, and
+</P>
+<P>
+<pre>
+ foo(?!bar)
+</PRE>
+</P>
+<P>
+matches any occurrence of "foo" that is not followed by "bar". Note that the
+apparently similar pattern
+</P>
+<P>
+<pre>
+ (?!foo)bar
+</PRE>
+</P>
+<P>
+does not find an occurrence of "bar" that is preceded by something other than
+"foo"; it finds any occurrence of "bar" whatsoever, because the assertion
+(?!foo) is always true when the next three characters are "bar". A
+lookbehind assertion is needed to achieve this effect.
+</P>
+<P>
+If you want to force a matching failure at some point in a pattern, the most
+convenient way to do it is with (?!) because an empty string always matches, so
+an assertion that requires there not to be an empty string must always fail.
+</P>
+<P>
+Lookbehind assertions start with (?&#60;= for positive assertions and (?&#60;! for
+negative assertions. For example,
+</P>
+<P>
+<pre>
+ (?&#60;!foo)bar
+</PRE>
+</P>
+<P>
+does find an occurrence of "bar" that is not preceded by "foo". The contents of
+a lookbehind assertion are restricted such that all the strings it matches must
+have a fixed length. However, if there are several alternatives, they do not
+all have to have the same fixed length. Thus
+</P>
+<P>
+<pre>
+ (?&#60;=bullock|donkey)
+</PRE>
+</P>
+<P>
+is permitted, but
+</P>
+<P>
+<pre>
+ (?&#60;!dogs?|cats?)
+</PRE>
+</P>
+<P>
+causes an error at compile time. Branches that match different length strings
+are permitted only at the top level of a lookbehind assertion. This is an
+extension compared with Perl (at least for 5.8), which requires all branches to
+match the same length of string. An assertion such as
+</P>
+<P>
+<pre>
+ (?&#60;=ab(c|de))
+</PRE>
+</P>
+<P>
+is not permitted, because its single top-level branch can match two different
+lengths, but it is acceptable if rewritten to use two top-level branches:
+</P>
+<P>
+<pre>
+ (?&#60;=abc|abde)
+</PRE>
+</P>
+<P>
+The implementation of lookbehind assertions is, for each alternative, to
+temporarily move the current position back by the fixed width and then try to
+match. If there are insufficient characters before the current position, the
+match is deemed to fail.
+</P>
+<P>
+PCRE does not allow the \C escape (which matches a single byte in UTF-8 mode)
+to appear in lookbehind assertions, because it makes it impossible to calculate
+the length of the lookbehind.
+</P>
+<P>
+Atomic groups can be used in conjunction with lookbehind assertions to specify
+efficient matching at the end of the subject string. Consider a simple pattern
+such as
+</P>
+<P>
+<pre>
+ abcd$
+</PRE>
+</P>
+<P>
+when applied to a long string that does not match. Because matching proceeds
+from left to right, PCRE will look for each "a" in the subject and then see if
+what follows matches the rest of the pattern. If the pattern is specified as
+</P>
+<P>
+<pre>
+ ^.*abcd$
+</PRE>
+</P>
+<P>
+the initial .* matches the entire string at first, but when this fails (because
+there is no following "a"), it backtracks to match all but the last character,
+then all but the last two characters, and so on. Once again the search for "a"
+covers the entire string, from right to left, so we are no better off. However,
+if the pattern is written as
+</P>
+<P>
+<pre>
+ ^(?&#62;.*)(?&#60;=abcd)
+</PRE>
+</P>
+<P>
+or, equivalently,
+</P>
+<P>
+<pre>
+ ^.*+(?&#60;=abcd)
+</PRE>
+</P>
+<P>
+there can be no backtracking for the .* item; it can match only the entire
+string. The subsequent lookbehind assertion does a single test on the last four
+characters. If it fails, the match fails immediately. For long strings, this
+approach makes a significant difference to the processing time.
+</P>
+<P>
+Several assertions (of any sort) may occur in succession. For example,
+</P>
+<P>
+<pre>
+ (?&#60;=\d{3})(?&#60;!999)foo
+</PRE>
+</P>
+<P>
+matches "foo" preceded by three digits that are not "999". Notice that each of
+the assertions is applied independently at the same point in the subject
+string. First there is a check that the previous three characters are all
+digits, and then there is a check that the same three characters are not "999".
+This pattern does <i>not</i> match "foo" preceded by six characters, the first
+of which are digits and the last three of which are not "999". For example, it
+doesn't match "123abcfoo". A pattern to do that is
+</P>
+<P>
+<pre>
+ (?&#60;=\d{3}...)(?&#60;!999)foo
+</PRE>
+</P>
+<P>
+This time the first assertion looks at the preceding six characters, checking
+that the first three are digits, and then the second assertion checks that the
+preceding three characters are not "999".
+</P>
+<P>
+Assertions can be nested in any combination. For example,
+</P>
+<P>
+<pre>
+ (?&#60;=(?&#60;!foo)bar)baz
+</PRE>
+</P>
+<P>
+matches an occurrence of "baz" that is preceded by "bar" which in turn is not
+preceded by "foo", while
+</P>
+<P>
+<pre>
+ (?&#60;=\d{3}(?!999)...)foo
+</PRE>
+</P>
+<P>
+is another pattern which matches "foo" preceded by three digits and any three
+characters that are not "999".
+</P>
+<P>
+Assertion subpatterns are not capturing subpatterns, and may not be repeated,
+because it makes no sense to assert the same thing several times. If any kind
+of assertion contains capturing subpatterns within it, these are counted for
+the purposes of numbering the capturing subpatterns in the whole pattern.
+However, substring capturing is carried out only for positive assertions,
+because it does not make sense for negative assertions.
+</P>
+<br><a name="SEC16" href="#TOC1">CONDITIONAL SUBPATTERNS</a><br>
+<P>
+It is possible to cause the matching process to obey a subpattern
+conditionally or to choose between two alternative subpatterns, depending on
+the result of an assertion, or whether a previous capturing subpattern matched
+or not. The two possible forms of conditional subpattern are
+</P>
+<P>
+<pre>
+ (?(condition)yes-pattern)
+ (?(condition)yes-pattern|no-pattern)
+</PRE>
+</P>
+<P>
+If the condition is satisfied, the yes-pattern is used; otherwise the
+no-pattern (if present) is used. If there are more than two alternatives in the
+subpattern, a compile-time error occurs.
+</P>
+<P>
+There are three kinds of condition. If the text between the parentheses
+consists of a sequence of digits, the condition is satisfied if the capturing
+subpattern of that number has previously matched. The number must be greater
+than zero. Consider the following pattern, which contains non-significant white
+space to make it more readable (assume the PCRE_EXTENDED option) and to divide
+it into three parts for ease of discussion:
+</P>
+<P>
+<pre>
+ ( \( )? [^()]+ (?(1) \) )
+</PRE>
+</P>
+<P>
+The first part matches an optional opening parenthesis, and if that
+character is present, sets it as the first captured substring. The second part
+matches one or more characters that are not parentheses. The third part is a
+conditional subpattern that tests whether the first set of parentheses matched
+or not. If they did, that is, if subject started with an opening parenthesis,
+the condition is true, and so the yes-pattern is executed and a closing
+parenthesis is required. Otherwise, since no-pattern is not present, the
+subpattern matches nothing. In other words, this pattern matches a sequence of
+non-parentheses, optionally enclosed in parentheses.
+</P>
+<P>
+If the condition is the string (R), it is satisfied if a recursive call to the
+pattern or subpattern has been made. At "top level", the condition is false.
+This is a PCRE extension. Recursive patterns are described in the next section.
+</P>
+<P>
+If the condition is not a sequence of digits or (R), it must be an assertion.
+This may be a positive or negative lookahead or lookbehind assertion. Consider
+this pattern, again containing non-significant white space, and with the two
+alternatives on the second line:
+</P>
+<P>
+<pre>
+ (?(?=[^a-z]*[a-z])
+ \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} )
+</PRE>
+</P>
+<P>
+The condition is a positive lookahead assertion that matches an optional
+sequence of non-letters followed by a letter. In other words, it tests for the
+presence of at least one letter in the subject. If a letter is found, the
+subject is matched against the first alternative; otherwise it is matched
+against the second. This pattern matches strings in one of the two forms
+dd-aaa-dd or dd-dd-dd, where aaa are letters and dd are digits.
+</P>
+<br><a name="SEC17" href="#TOC1">COMMENTS</a><br>
+<P>
+The sequence (?# marks the start of a comment which continues up to the next
+closing parenthesis. Nested parentheses are not permitted. The characters
+that make up a comment play no part in the pattern matching at all.
+</P>
+<P>
+If the PCRE_EXTENDED option is set, an unescaped # character outside a
+character class introduces a comment that continues up to the next newline
+character in the pattern.
+</P>
+<br><a name="SEC18" href="#TOC1">RECURSIVE PATTERNS</a><br>
+<P>
+Consider the problem of matching a string in parentheses, allowing for
+unlimited nested parentheses. Without the use of recursion, the best that can
+be done is to use a pattern that matches up to some fixed depth of nesting. It
+is not possible to handle an arbitrary nesting depth. Perl has provided an
+experimental facility that allows regular expressions to recurse (amongst other
+things). It does this by interpolating Perl code in the expression at run time,
+and the code can refer to the expression itself. A Perl pattern to solve the
+parentheses problem can be created like this:
+</P>
+<P>
+<pre>
+ $re = qr{\( (?: (?&#62;[^()]+) | (?p{$re}) )* \)}x;
+</PRE>
+</P>
+<P>
+The (?p{...}) item interpolates Perl code at run time, and in this case refers
+recursively to the pattern in which it appears. Obviously, PCRE cannot support
+the interpolation of Perl code. Instead, it supports some special syntax for
+recursion of the entire pattern, and also for individual subpattern recursion.
+</P>
+<P>
+The special item that consists of (? followed by a number greater than zero and
+a closing parenthesis is a recursive call of the subpattern of the given
+number, provided that it occurs inside that subpattern. (If not, it is a
+"subroutine" call, which is described in the next section.) The special item
+(?R) is a recursive call of the entire regular expression.
+</P>
+<P>
+For example, this PCRE pattern solves the nested parentheses problem (assume
+the PCRE_EXTENDED option is set so that white space is ignored):
+</P>
+<P>
+<pre>
+ \( ( (?&#62;[^()]+) | (?R) )* \)
+</PRE>
+</P>
+<P>
+First it matches an opening parenthesis. Then it matches any number of
+substrings which can either be a sequence of non-parentheses, or a recursive
+match of the pattern itself (that is a correctly parenthesized substring).
+Finally there is a closing parenthesis.
+</P>
+<P>
+If this were part of a larger pattern, you would not want to recurse the entire
+pattern, so instead you could use this:
+</P>
+<P>
+<pre>
+ ( \( ( (?&#62;[^()]+) | (?1) )* \) )
+</PRE>
+</P>
+<P>
+We have put the pattern into parentheses, and caused the recursion to refer to
+them instead of the whole pattern. In a larger pattern, keeping track of
+parenthesis numbers can be tricky. It may be more convenient to use named
+parentheses instead. For this, PCRE uses (?P&#62;name), which is an extension to
+the Python syntax that PCRE uses for named parentheses (Perl does not provide
+named parentheses). We could rewrite the above example as follows:
+</P>
+<P>
+<pre>
+ (?&#60;pn&#62; \( ( (?&#62;[^()]+) | (?P&#62;pn) )* \) )
+</PRE>
+</P>
+<P>
+This particular example pattern contains nested unlimited repeats, and so the
+use of atomic grouping for matching strings of non-parentheses is important
+when applying the pattern to strings that do not match. For example, when this
+pattern is applied to
+</P>
+<P>
+<pre>
+ (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
+</PRE>
+</P>
+<P>
+it yields "no match" quickly. However, if atomic grouping is not used,
+the match runs for a very long time indeed because there are so many different
+ways the + and * repeats can carve up the subject, and all have to be tested
+before failure can be reported.
+</P>
+<P>
+At the end of a match, the values set for any capturing subpatterns are those
+from the outermost level of the recursion at which the subpattern value is set.
+If you want to obtain intermediate values, a callout function can be used (see
+below and the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation). If the pattern above is matched against
+</P>
+<P>
+<pre>
+ (ab(cd)ef)
+</PRE>
+</P>
+<P>
+the value for the capturing parentheses is "ef", which is the last value taken
+on at the top level. If additional parentheses are added, giving
+</P>
+<P>
+<pre>
+ \( ( ( (?&#62;[^()]+) | (?R) )* ) \)
+ ^ ^
+ ^ ^
+</PRE>
+</P>
+<P>
+the string they capture is "ab(cd)ef", the contents of the top level
+parentheses. If there are more than 15 capturing parentheses in a pattern, PCRE
+has to obtain extra memory to store data during a recursion, which it does by
+using <b>pcre_malloc</b>, freeing it via <b>pcre_free</b> afterwards. If no
+memory can be obtained, the match fails with the PCRE_ERROR_NOMEMORY error.
+</P>
+<P>
+Do not confuse the (?R) item with the condition (R), which tests for recursion.
+Consider this pattern, which matches text in angle brackets, allowing for
+arbitrary nesting. Only digits are allowed in nested brackets (that is, when
+recursing), whereas any characters are permitted at the outer level.
+</P>
+<P>
+<pre>
+ &#60; (?: (?(R) \d++ | [^&#60;&#62;]*+) | (?R)) * &#62;
+</PRE>
+</P>
+<P>
+In this pattern, (?(R) is the start of a conditional subpattern, with two
+different alternatives for the recursive and non-recursive cases. The (?R) item
+is the actual recursive call.
+</P>
+<a name="subpatternsassubroutines"></a><br><a name="SEC19" href="#TOC1">SUBPATTERNS AS SUBROUTINES</a><br>
+<P>
+If the syntax for a recursive subpattern reference (either by number or by
+name) is used outside the parentheses to which it refers, it operates like a
+subroutine in a programming language. An earlier example pointed out that the
+pattern
+</P>
+<P>
+<pre>
+ (sens|respons)e and \1ibility
+</PRE>
+</P>
+<P>
+matches "sense and sensibility" and "response and responsibility", but not
+"sense and responsibility". If instead the pattern
+</P>
+<P>
+<pre>
+ (sens|respons)e and (?1)ibility
+</PRE>
+</P>
+<P>
+is used, it does match "sense and responsibility" as well as the other two
+strings. Such references must, however, follow the subpattern to which they
+refer.
+</P>
+<br><a name="SEC20" href="#TOC1">CALLOUTS</a><br>
+<P>
+Perl has a feature whereby using the sequence (?{...}) causes arbitrary Perl
+code to be obeyed in the middle of matching a regular expression. This makes it
+possible, amongst other things, to extract different substrings that match the
+same pair of parentheses when there is a repetition.
+</P>
+<P>
+PCRE provides a similar feature, but of course it cannot obey arbitrary Perl
+code. The feature is called "callout". The caller of PCRE provides an external
+function by putting its entry point in the global variable <i>pcre_callout</i>.
+By default, this variable contains NULL, which disables all calling out.
+</P>
+<P>
+Within a regular expression, (?C) indicates the points at which the external
+function is to be called. If you want to identify different callout points, you
+can put a number less than 256 after the letter C. The default value is zero.
+For example, this pattern has two callout points:
+</P>
+<P>
+<pre>
+ (?C1)\dabc(?C2)def
+</PRE>
+</P>
+<P>
+During matching, when PCRE reaches a callout point (and <i>pcre_callout</i> is
+set), the external function is called. It is provided with the number of the
+callout, and, optionally, one item of data originally supplied by the caller of
+<b>pcre_exec()</b>. The callout function may cause matching to backtrack, or to
+fail altogether. A complete description of the interface to the callout
+function is given in the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation.
+</P>
+<P>
+Last updated: 03 February 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/html/pcreperform.html b/doc/html/pcreperform.html
new file mode 100644
index 0000000..418ac6d
--- /dev/null
+++ b/doc/html/pcreperform.html
@@ -0,0 +1,93 @@
+<html>
+<head>
+<title>pcreperform specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE PERFORMANCE</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE PERFORMANCE</a><br>
+<P>
+Certain items that may appear in regular expression patterns are more efficient
+than others. It is more efficient to use a character class like [aeiou] than a
+set of alternatives such as (a|e|i|o|u). In general, the simplest construction
+that provides the required behaviour is usually the most efficient. Jeffrey
+Friedl's book contains a lot of discussion about optimizing regular expressions
+for efficient performance.
+</P>
+<P>
+When a pattern begins with .* not in parentheses, or in parentheses that are
+not the subject of a backreference, and the PCRE_DOTALL option is set, the
+pattern is implicitly anchored by PCRE, since it can match only at the start of
+a subject string. However, if PCRE_DOTALL is not set, PCRE cannot make this
+optimization, because the . metacharacter does not then match a newline, and if
+the subject string contains newlines, the pattern may match from the character
+immediately following one of them instead of from the very start. For example,
+the pattern
+</P>
+<P>
+<pre>
+ .*second
+</PRE>
+</P>
+<P>
+matches the subject "first\nand second" (where \n stands for a newline
+character), with the match starting at the seventh character. In order to do
+this, PCRE has to retry the match starting after every newline in the subject.
+</P>
+<P>
+If you are using such a pattern with subject strings that do not contain
+newlines, the best performance is obtained by setting PCRE_DOTALL, or starting
+the pattern with ^.* to indicate explicit anchoring. That saves PCRE from
+having to scan along the subject looking for a newline to restart at.
+</P>
+<P>
+Beware of patterns that contain nested indefinite repeats. These can take a
+long time to run when applied to a string that does not match. Consider the
+pattern fragment
+</P>
+<P>
+<pre>
+ (a+)*
+</PRE>
+</P>
+<P>
+This can match "aaaa" in 33 different ways, and this number increases very
+rapidly as the string gets longer. (The * repeat can match 0, 1, 2, 3, or 4
+times, and for each of those cases other than 0, the + repeats can match
+different numbers of times.) When the remainder of the pattern is such that the
+entire match is going to fail, PCRE has in principle to try every possible
+variation, and this can take an extremely long time.
+</P>
+<P>
+An optimization catches some of the more simple cases such as
+</P>
+<P>
+<pre>
+ (a+)*b
+</PRE>
+</P>
+<P>
+where a literal character follows. Before embarking on the standard matching
+procedure, PCRE checks that there is a "b" later in the subject string, and if
+there is not, it fails the match immediately. However, when there is no
+following literal this optimization cannot be used. You can see the difference
+by comparing the behaviour of
+</P>
+<P>
+<pre>
+ (a+)*\d
+</PRE>
+</P>
+<P>
+with the pattern above. The former gives a failure almost instantly when
+applied to a whole line of "a" characters, whereas the latter takes an
+appreciable time with strings longer than about 20 characters.
+</P>
+<P>
+Last updated: 03 February 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/html/pcreposix.html b/doc/html/pcreposix.html
new file mode 100644
index 0000000..bdd9f3f
--- /dev/null
+++ b/doc/html/pcreposix.html
@@ -0,0 +1,235 @@
+<html>
+<head>
+<title>pcreposix specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">SYNOPSIS OF POSIX API</a>
+<li><a name="TOC2" href="#SEC2">DESCRIPTION</a>
+<li><a name="TOC3" href="#SEC3">COMPILING A PATTERN</a>
+<li><a name="TOC4" href="#SEC4">MATCHING NEWLINE CHARACTERS</a>
+<li><a name="TOC5" href="#SEC5">MATCHING A PATTERN</a>
+<li><a name="TOC6" href="#SEC6">ERROR MESSAGES</a>
+<li><a name="TOC7" href="#SEC7">STORAGE</a>
+<li><a name="TOC8" href="#SEC8">AUTHOR</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">SYNOPSIS OF POSIX API</a><br>
+<P>
+<b>#include &#60;pcreposix.h&#62;</b>
+</P>
+<P>
+<b>int regcomp(regex_t *<i>preg</i>, const char *<i>pattern</i>,</b>
+<b>int <i>cflags</i>);</b>
+</P>
+<P>
+<b>int regexec(regex_t *<i>preg</i>, const char *<i>string</i>,</b>
+<b>size_t <i>nmatch</i>, regmatch_t <i>pmatch</i>[], int <i>eflags</i>);</b>
+</P>
+<P>
+<b>size_t regerror(int <i>errcode</i>, const regex_t *<i>preg</i>,</b>
+<b>char *<i>errbuf</i>, size_t <i>errbuf_size</i>);</b>
+</P>
+<P>
+<b>void regfree(regex_t *<i>preg</i>);</b>
+</P>
+<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br>
+<P>
+This set of functions provides a POSIX-style API to the PCRE regular expression
+package. See the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation for a description of the native API, which contains additional
+functionality.
+</P>
+<P>
+The functions described here are just wrapper functions that ultimately call
+the PCRE native API. Their prototypes are defined in the <b>pcreposix.h</b>
+header file, and on Unix systems the library itself is called
+<b>pcreposix.a</b>, so can be accessed by adding <b>-lpcreposix</b> to the
+command for linking an application which uses them. Because the POSIX functions
+call the native ones, it is also necessary to add \fR-lpcre\fR.
+</P>
+<P>
+I have implemented only those option bits that can be reasonably mapped to PCRE
+native options. In addition, the options REG_EXTENDED and REG_NOSUB are defined
+with the value zero. They have no effect, but since programs that are written
+to the POSIX interface often use them, this makes it easier to slot in PCRE as
+a replacement library. Other POSIX options are not even defined.
+</P>
+<P>
+When PCRE is called via these functions, it is only the API that is POSIX-like
+in style. The syntax and semantics of the regular expressions themselves are
+still those of Perl, subject to the setting of various PCRE options, as
+described below.
+</P>
+<P>
+The header for these functions is supplied as <b>pcreposix.h</b> to avoid any
+potential clash with other POSIX libraries. It can, of course, be renamed or
+aliased as <b>regex.h</b>, which is the "correct" name. It provides two
+structure types, <i>regex_t</i> for compiled internal forms, and
+<i>regmatch_t</i> for returning captured substrings. It also defines some
+constants whose names start with "REG_"; these are used for setting options and
+identifying error codes.
+</P>
+<br><a name="SEC3" href="#TOC1">COMPILING A PATTERN</a><br>
+<P>
+The function <b>regcomp()</b> is called to compile a pattern into an
+internal form. The pattern is a C string terminated by a binary zero, and
+is passed in the argument <i>pattern</i>. The <i>preg</i> argument is a pointer
+to a regex_t structure which is used as a base for storing information about
+the compiled expression.
+</P>
+<P>
+The argument <i>cflags</i> is either zero, or contains one or more of the bits
+defined by the following macros:
+</P>
+<P>
+<pre>
+ REG_ICASE
+</PRE>
+</P>
+<P>
+The PCRE_CASELESS option is set when the expression is passed for compilation
+to the native function.
+</P>
+<P>
+<pre>
+ REG_NEWLINE
+</PRE>
+</P>
+<P>
+The PCRE_MULTILINE option is set when the expression is passed for compilation
+to the native function. Note that this does <i>not</i> mimic the defined POSIX
+behaviour for REG_NEWLINE (see the following section).
+</P>
+<P>
+In the absence of these flags, no options are passed to the native function.
+This means the the regex is compiled with PCRE default semantics. In
+particular, the way it handles newline characters in the subject string is the
+Perl way, not the POSIX way. Note that setting PCRE_MULTILINE has only
+<i>some</i> of the effects specified for REG_NEWLINE. It does not affect the way
+newlines are matched by . (they aren't) or by a negative class such as [^a]
+(they are).
+</P>
+<P>
+The yield of <b>regcomp()</b> is zero on success, and non-zero otherwise. The
+<i>preg</i> structure is filled in on success, and one member of the structure
+is public: <i>re_nsub</i> contains the number of capturing subpatterns in
+the regular expression. Various error codes are defined in the header file.
+</P>
+<br><a name="SEC4" href="#TOC1">MATCHING NEWLINE CHARACTERS</a><br>
+<P>
+This area is not simple, because POSIX and Perl take different views of things.
+It is not possible to get PCRE to obey POSIX semantics, but then PCRE was never
+intended to be a POSIX engine. The following table lists the different
+possibilities for matching newline characters in PCRE:
+</P>
+<P>
+<pre>
+ Default Change with
+</PRE>
+</P>
+<P>
+<pre>
+ . matches newline no PCRE_DOTALL
+ newline matches [^a] yes not changeable
+ $ matches \n at end yes PCRE_DOLLARENDONLY
+ $ matches \n in middle no PCRE_MULTILINE
+ ^ matches \n in middle no PCRE_MULTILINE
+</PRE>
+</P>
+<P>
+This is the equivalent table for POSIX:
+</P>
+<P>
+<pre>
+ Default Change with
+</PRE>
+</P>
+<P>
+<pre>
+ . matches newline yes REG_NEWLINE
+ newline matches [^a] yes REG_NEWLINE
+ $ matches \n at end no REG_NEWLINE
+ $ matches \n in middle no REG_NEWLINE
+ ^ matches \n in middle no REG_NEWLINE
+</PRE>
+</P>
+<P>
+PCRE's behaviour is the same as Perl's, except that there is no equivalent for
+PCRE_DOLLARENDONLY in Perl. In both PCRE and Perl, there is no way to stop
+newline from matching [^a].
+</P>
+<P>
+The default POSIX newline handling can be obtained by setting PCRE_DOTALL and
+PCRE_DOLLARENDONLY, but there is no way to make PCRE behave exactly as for the
+REG_NEWLINE action.
+</P>
+<br><a name="SEC5" href="#TOC1">MATCHING A PATTERN</a><br>
+<P>
+The function <b>regexec()</b> is called to match a pre-compiled pattern
+<i>preg</i> against a given <i>string</i>, which is terminated by a zero byte,
+subject to the options in <i>eflags</i>. These can be:
+</P>
+<P>
+<pre>
+ REG_NOTBOL
+</PRE>
+</P>
+<P>
+The PCRE_NOTBOL option is set when calling the underlying PCRE matching
+function.
+</P>
+<P>
+<pre>
+ REG_NOTEOL
+</PRE>
+</P>
+<P>
+The PCRE_NOTEOL option is set when calling the underlying PCRE matching
+function.
+</P>
+<P>
+The portion of the string that was matched, and also any captured substrings,
+are returned via the <i>pmatch</i> argument, which points to an array of
+<i>nmatch</i> structures of type <i>regmatch_t</i>, containing the members
+<i>rm_so</i> and <i>rm_eo</i>. These contain the offset to the first character of
+each substring and the offset to the first character after the end of each
+substring, respectively. The 0th element of the vector relates to the entire
+portion of <i>string</i> that was matched; subsequent elements relate to the
+capturing subpatterns of the regular expression. Unused entries in the array
+have both structure members set to -1.
+</P>
+<P>
+A successful match yields a zero return; various error codes are defined in the
+header file, of which REG_NOMATCH is the "expected" failure code.
+</P>
+<br><a name="SEC6" href="#TOC1">ERROR MESSAGES</a><br>
+<P>
+The <b>regerror()</b> function maps a non-zero errorcode from either
+<b>regcomp()</b> or <b>regexec()</b> to a printable message. If <i>preg</i> is not
+NULL, the error should have arisen from the use of that structure. A message
+terminated by a binary zero is placed in <i>errbuf</i>. The length of the
+message, including the zero, is limited to <i>errbuf_size</i>. The yield of the
+function is the size of buffer needed to hold the whole message.
+</P>
+<br><a name="SEC7" href="#TOC1">STORAGE</a><br>
+<P>
+Compiling a regular expression causes memory to be allocated and associated
+with the <i>preg</i> structure. The function <b>regfree()</b> frees all such
+memory, after which <i>preg</i> may no longer be used as a compiled expression.
+</P>
+<br><a name="SEC8" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel &#60;ph10@cam.ac.uk&#62;
+<br>
+University Computing Service,
+<br>
+Cambridge CB2 3QG, England.
+</P>
+<P>
+Last updated: 03 February 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/html/pcresample.html b/doc/html/pcresample.html
new file mode 100644
index 0000000..fed41f6
--- /dev/null
+++ b/doc/html/pcresample.html
@@ -0,0 +1,79 @@
+<html>
+<head>
+<title>pcresample specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE SAMPLE PROGRAM</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE SAMPLE PROGRAM</a><br>
+<P>
+A simple, complete demonstration program, to get you started with using PCRE,
+is supplied in the file <i>pcredemo.c</i> in the PCRE distribution.
+</P>
+<P>
+The program compiles the regular expression that is its first argument, and
+matches it against the subject string in its second argument. No PCRE options
+are set, and default character tables are used. If matching succeeds, the
+program outputs the portion of the subject that matched, together with the
+contents of any captured substrings.
+</P>
+<P>
+If the -g option is given on the command line, the program then goes on to
+check for further matches of the same regular expression in the same subject
+string. The logic is a little bit tricky because of the possibility of matching
+an empty string. Comments in the code explain what is going on.
+</P>
+<P>
+On a Unix system that has PCRE installed in <i>/usr/local</i>, you can compile
+the demonstration program using a command like this:
+</P>
+<P>
+<pre>
+ gcc -o pcredemo pcredemo.c -I/usr/local/include \
+ -L/usr/local/lib -lpcre
+</PRE>
+</P>
+<P>
+Then you can run simple tests like this:
+</P>
+<P>
+<pre>
+ ./pcredemo 'cat|dog' 'the cat sat on the mat'
+ ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
+</PRE>
+</P>
+<P>
+Note that there is a much more comprehensive test program, called
+<b>pcretest</b>, which supports many more facilities for testing regular
+expressions and the PCRE library. The <b>pcredemo</b> program is provided as a
+simple coding example.
+</P>
+<P>
+On some operating systems (e.g. Solaris) you may get an error like this when
+you try to run <b>pcredemo</b>:
+</P>
+<P>
+<pre>
+ ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
+</PRE>
+</P>
+<P>
+This is caused by the way shared library support works on those systems. You
+need to add
+</P>
+<P>
+<pre>
+ -R/usr/local/lib
+</PRE>
+</P>
+<P>
+to the compile command to get round this problem.
+</P>
+<P>
+Last updated: 28 January 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/html/pcretest.html b/doc/html/pcretest.html
new file mode 100644
index 0000000..25b03d3
--- /dev/null
+++ b/doc/html/pcretest.html
@@ -0,0 +1,434 @@
+<html>
+<head>
+<title>pcretest specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+This HTML document has been generated automatically from the original man page.
+If there is any nonsense in it, please consult the man page, in case the
+conversion went wrong.<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">SYNOPSIS</a>
+<li><a name="TOC2" href="#SEC2">OPTIONS</a>
+<li><a name="TOC3" href="#SEC3">DESCRIPTION</a>
+<li><a name="TOC4" href="#SEC4">PATTERN MODIFIERS</a>
+<li><a name="TOC5" href="#SEC5">CALLOUTS</a>
+<li><a name="TOC6" href="#SEC6">DATA LINES</a>
+<li><a name="TOC7" href="#SEC7">OUTPUT FROM PCRETEST</a>
+<li><a name="TOC8" href="#SEC8">AUTHOR</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
+<P>
+<b>pcretest [-d] [-i] [-m] [-o osize] [-p] [-t] [source] [destination]</b>
+</P>
+<P>
+<b>pcretest</b> was written as a test program for the PCRE regular expression
+library itself, but it can also be used for experimenting with regular
+expressions. This document describes the features of the test program; for
+details of the regular expressions themselves, see the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+documentation. For details of PCRE and its options, see the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation.
+</P>
+<br><a name="SEC2" href="#TOC1">OPTIONS</a><br>
+<P>
+<b>-C</b>
+Output the version number of the PCRE library, and all available information
+about the optional features that are included, and then exit.
+</P>
+<P>
+<b>-d</b>
+Behave as if each regex had the <b>/D</b> modifier (see below); the internal
+form is output after compilation.
+</P>
+<P>
+<b>-i</b>
+Behave as if each regex had the <b>/I</b> modifier; information about the
+compiled pattern is given after compilation.
+</P>
+<P>
+<b>-m</b>
+Output the size of each compiled pattern after it has been compiled. This is
+equivalent to adding /M to each regular expression. For compatibility with
+earlier versions of pcretest, <b>-s</b> is a synonym for <b>-m</b>.
+</P>
+<P>
+<b>-o</b> <i>osize</i>
+Set the number of elements in the output vector that is used when calling PCRE
+to be <i>osize</i>. The default value is 45, which is enough for 14 capturing
+subexpressions. The vector size can be changed for individual matching calls by
+including \O in the data line (see below).
+</P>
+<P>
+<b>-p</b>
+Behave as if each regex has <b>/P</b> modifier; the POSIX wrapper API is used
+to call PCRE. None of the other options has any effect when <b>-p</b> is set.
+</P>
+<P>
+<b>-t</b>
+Run each compile, study, and match many times with a timer, and output
+resulting time per compile or match (in milliseconds). Do not set <b>-t</b> with
+<b>-m</b>, because you will then get the size output 20000 times and the timing
+will be distorted.
+</P>
+<br><a name="SEC3" href="#TOC1">DESCRIPTION</a><br>
+<P>
+If <b>pcretest</b> is given two filename arguments, it reads from the first and
+writes to the second. If it is given only one filename argument, it reads from
+that file and writes to stdout. Otherwise, it reads from stdin and writes to
+stdout, and prompts for each line of input, using "re&#62;" to prompt for regular
+expressions, and "data&#62;" to prompt for data lines.
+</P>
+<P>
+The program handles any number of sets of input on a single input file. Each
+set starts with a regular expression, and continues with any number of data
+lines to be matched against the pattern.
+</P>
+<P>
+Each line is matched separately and independently. If you want to do
+multiple-line matches, you have to use the \n escape sequence in a single line
+of input to encode the newline characters. The maximum length of data line is
+30,000 characters.
+</P>
+<P>
+An empty line signals the end of the data lines, at which point a new regular
+expression is read. The regular expressions are given enclosed in any
+non-alphameric delimiters other than backslash, for example
+</P>
+<P>
+<pre>
+ /(a|bc)x+yz/
+</PRE>
+</P>
+<P>
+White space before the initial delimiter is ignored. A regular expression may
+be continued over several input lines, in which case the newline characters are
+included within it. It is possible to include the delimiter within the pattern
+by escaping it, for example
+</P>
+<P>
+<pre>
+ /abc\/def/
+</PRE>
+</P>
+<P>
+If you do so, the escape and the delimiter form part of the pattern, but since
+delimiters are always non-alphameric, this does not affect its interpretation.
+If the terminating delimiter is immediately followed by a backslash, for
+example,
+</P>
+<P>
+<pre>
+ /abc/\
+</PRE>
+</P>
+<P>
+then a backslash is added to the end of the pattern. This is done to provide a
+way of testing the error condition that arises if a pattern finishes with a
+backslash, because
+</P>
+<P>
+<pre>
+ /abc\/
+</PRE>
+</P>
+<P>
+is interpreted as the first line of a pattern that starts with "abc/", causing
+pcretest to read the next line as a continuation of the regular expression.
+</P>
+<br><a name="SEC4" href="#TOC1">PATTERN MODIFIERS</a><br>
+<P>
+The pattern may be followed by <b>i</b>, <b>m</b>, <b>s</b>, or <b>x</b> to set the
+PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options,
+respectively. For example:
+</P>
+<P>
+<pre>
+ /caseless/i
+</PRE>
+</P>
+<P>
+These modifier letters have the same effect as they do in Perl. There are
+others which set PCRE options that do not correspond to anything in Perl:
+<b>/A</b>, <b>/E</b>, and <b>/X</b> set PCRE_ANCHORED, PCRE_DOLLAR_ENDONLY, and
+PCRE_EXTRA respectively.
+</P>
+<P>
+Searching for all possible matches within each subject string can be requested
+by the <b>/g</b> or <b>/G</b> modifier. After finding a match, PCRE is called
+again to search the remainder of the subject string. The difference between
+<b>/g</b> and <b>/G</b> is that the former uses the <i>startoffset</i> argument to
+<b>pcre_exec()</b> to start searching at a new point within the entire string
+(which is in effect what Perl does), whereas the latter passes over a shortened
+substring. This makes a difference to the matching process if the pattern
+begins with a lookbehind assertion (including \b or \B).
+</P>
+<P>
+If any call to <b>pcre_exec()</b> in a <b>/g</b> or <b>/G</b> sequence matches an
+empty string, the next call is done with the PCRE_NOTEMPTY and PCRE_ANCHORED
+flags set in order to search for another, non-empty, match at the same point.
+If this second match fails, the start offset is advanced by one, and the normal
+match is retried. This imitates the way Perl handles such cases when using the
+<b>/g</b> modifier or the <b>split()</b> function.
+</P>
+<P>
+There are a number of other modifiers for controlling the way <b>pcretest</b>
+operates.
+</P>
+<P>
+The <b>/+</b> modifier requests that as well as outputting the substring that
+matched the entire pattern, pcretest should in addition output the remainder of
+the subject string. This is useful for tests where the subject contains
+multiple copies of the same substring.
+</P>
+<P>
+The <b>/L</b> modifier must be followed directly by the name of a locale, for
+example,
+</P>
+<P>
+<pre>
+ /pattern/Lfr
+</PRE>
+</P>
+<P>
+For this reason, it must be the last modifier letter. The given locale is set,
+<b>pcre_maketables()</b> is called to build a set of character tables for the
+locale, and this is then passed to <b>pcre_compile()</b> when compiling the
+regular expression. Without an <b>/L</b> modifier, NULL is passed as the tables
+pointer; that is, <b>/L</b> applies only to the expression on which it appears.
+</P>
+<P>
+The <b>/I</b> modifier requests that <b>pcretest</b> output information about the
+compiled expression (whether it is anchored, has a fixed first character, and
+so on). It does this by calling <b>pcre_fullinfo()</b> after compiling an
+expression, and outputting the information it gets back. If the pattern is
+studied, the results of that are also output.
+</P>
+<P>
+The <b>/D</b> modifier is a PCRE debugging feature, which also assumes <b>/I</b>.
+It causes the internal form of compiled regular expressions to be output after
+compilation. If the pattern was studied, the information returned is also
+output.
+</P>
+<P>
+The <b>/S</b> modifier causes <b>pcre_study()</b> to be called after the
+expression has been compiled, and the results used when the expression is
+matched.
+</P>
+<P>
+The <b>/M</b> modifier causes the size of memory block used to hold the compiled
+pattern to be output.
+</P>
+<P>
+The <b>/P</b> modifier causes <b>pcretest</b> to call PCRE via the POSIX wrapper
+API rather than its native API. When this is done, all other modifiers except
+<b>/i</b>, <b>/m</b>, and <b>/+</b> are ignored. REG_ICASE is set if <b>/i</b> is
+present, and REG_NEWLINE is set if <b>/m</b> is present. The wrapper functions
+force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.
+</P>
+<P>
+The <b>/8</b> modifier causes <b>pcretest</b> to call PCRE with the PCRE_UTF8
+option set. This turns on support for UTF-8 character handling in PCRE,
+provided that it was compiled with this support enabled. This modifier also
+causes any non-printing characters in output strings to be printed using the
+\x{hh...} notation if they are valid UTF-8 sequences.
+</P>
+<br><a name="SEC5" href="#TOC1">CALLOUTS</a><br>
+<P>
+If the pattern contains any callout requests, <b>pcretest</b>'s callout function
+will be called. By default, it displays the callout number, and the start and
+current positions in the text at the callout time. For example, the output
+</P>
+<P>
+<pre>
+ ---&#62;pqrabcdef
+ 0 ^ ^
+</PRE>
+</P>
+<P>
+indicates that callout number 0 occurred for a match attempt starting at the
+fourth character of the subject string, when the pointer was at the seventh
+character. The callout function returns zero (carry on matching) by default.
+</P>
+<P>
+Inserting callouts may be helpful when using <b>pcretest</b> to check
+complicated regular expressions. For further information about callouts, see
+the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation.
+</P>
+<P>
+For testing the PCRE library, additional control of callout behaviour is
+available via escape sequences in the data, as described in the following
+section. In particular, it is possible to pass in a number as callout data (the
+default is zero). If the callout function receives a non-zero number, it
+returns that value instead of zero.
+</P>
+<br><a name="SEC6" href="#TOC1">DATA LINES</a><br>
+<P>
+Before each data line is passed to <b>pcre_exec()</b>, leading and trailing
+whitespace is removed, and it is then scanned for \ escapes. Some of these are
+pretty esoteric features, intended for checking out some of the more
+complicated features of PCRE. If you are just testing "ordinary" regular
+expressions, you probably don't need any of these. The following escapes are
+recognized:
+</P>
+<P>
+<pre>
+ \a alarm (= BEL)
+ \b backspace
+ \e escape
+ \f formfeed
+ \n newline
+ \r carriage return
+ \t tab
+ \v vertical tab
+ \nnn octal character (up to 3 octal digits)
+ \xhh hexadecimal character (up to 2 hex digits)
+ \x{hh...} hexadecimal character, any number of digits
+ in UTF-8 mode
+ \A pass the PCRE_ANCHORED option to <b>pcre_exec()</b>
+ \B pass the PCRE_NOTBOL option to <b>pcre_exec()</b>
+ \Cdd call pcre_copy_substring() for substring dd
+ after a successful match (any decimal number
+ less than 32)
+ \Cname call pcre_copy_named_substring() for substring
+ "name" after a successful match (name termin-
+ ated by next non alphanumeric character)
+ \C+ show the current captured substrings at callout
+ time
+ \C- do not supply a callout function
+ \C!n return 1 instead of 0 when callout number n is
+ reached
+ \C!n!m return 1 instead of 0 when callout number n is
+ reached for the nth time
+ \C*n pass the number n (may be negative) as callout
+ data
+ \Gdd call pcre_get_substring() for substring dd
+ after a successful match (any decimal number
+ less than 32)
+ \Gname call pcre_get_named_substring() for substring
+ "name" after a successful match (name termin-
+ ated by next non-alphanumeric character)
+ \L call pcre_get_substringlist() after a
+ successful match
+ \M discover the minimum MATCH_LIMIT setting
+ \N pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b>
+ \Odd set the size of the output vector passed to
+ <b>pcre_exec()</b> to dd (any number of decimal
+ digits)
+ \Z pass the PCRE_NOTEOL option to <b>pcre_exec()</b>
+</PRE>
+</P>
+<P>
+If \M is present, <b>pcretest</b> calls <b>pcre_exec()</b> several times, with
+different values in the <i>match_limit</i> field of the <b>pcre_extra</b> data
+structure, until it finds the minimum number that is needed for
+<b>pcre_exec()</b> to complete. This number is a measure of the amount of
+recursion and backtracking that takes place, and checking it out can be
+instructive. For most simple matches, the number is quite small, but for
+patterns with very large numbers of matching possibilities, it can become large
+very quickly with increasing length of subject string.
+</P>
+<P>
+When \O is used, it may be higher or lower than the size set by the <b>-O</b>
+option (or defaulted to 45); \O applies only to the call of <b>pcre_exec()</b>
+for the line in which it appears.
+</P>
+<P>
+A backslash followed by anything else just escapes the anything else. If the
+very last character is a backslash, it is ignored. This gives a way of passing
+an empty line as data, since a real empty line terminates the data input.
+</P>
+<P>
+If <b>/P</b> was present on the regex, causing the POSIX wrapper API to be used,
+only <b>\B</b>, and <b>\Z</b> have any effect, causing REG_NOTBOL and REG_NOTEOL
+to be passed to <b>regexec()</b> respectively.
+</P>
+<P>
+The use of \x{hh...} to represent UTF-8 characters is not dependent on the use
+of the <b>/8</b> modifier on the pattern. It is recognized always. There may be
+any number of hexadecimal digits inside the braces. The result is from one to
+six bytes, encoded according to the UTF-8 rules.
+</P>
+<br><a name="SEC7" href="#TOC1">OUTPUT FROM PCRETEST</a><br>
+<P>
+When a match succeeds, pcretest outputs the list of captured substrings that
+<b>pcre_exec()</b> returns, starting with number 0 for the string that matched
+the whole pattern. Here is an example of an interactive pcretest run.
+</P>
+<P>
+<pre>
+ $ pcretest
+ PCRE version 4.00 08-Jan-2003
+</PRE>
+</P>
+<P>
+<pre>
+ re&#62; /^abc(\d+)/
+ data&#62; abc123
+ 0: abc123
+ 1: 123
+ data&#62; xyz
+ No match
+</PRE>
+</P>
+<P>
+If the strings contain any non-printing characters, they are output as \0x
+escapes, or as \x{...} escapes if the <b>/8</b> modifier was present on the
+pattern. If the pattern has the <b>/+</b> modifier, then the output for
+substring 0 is followed by the the rest of the subject string, identified by
+"0+" like this:
+</P>
+<P>
+<pre>
+ re&#62; /cat/+
+ data&#62; cataract
+ 0: cat
+ 0+ aract
+</PRE>
+</P>
+<P>
+If the pattern has the <b>/g</b> or <b>/G</b> modifier, the results of successive
+matching attempts are output in sequence, like this:
+</P>
+<P>
+<pre>
+ re&#62; /\Bi(\w\w)/g
+ data&#62; Mississippi
+ 0: iss
+ 1: ss
+ 0: iss
+ 1: ss
+ 0: ipp
+ 1: pp
+</PRE>
+</P>
+<P>
+"No match" is output only if the first match attempt fails.
+</P>
+<P>
+If any of the sequences <b>\C</b>, <b>\G</b>, or <b>\L</b> are present in a
+data line that is successfully matched, the substrings extracted by the
+convenience functions are output with C, G, or L after the string number
+instead of a colon. This is in addition to the normal full list. The string
+length (that is, the return from the extraction function) is given in
+parentheses after each string for <b>\C</b> and <b>\G</b>.
+</P>
+<P>
+Note that while patterns can be continued over several lines (a plain "&#62;"
+prompt is used for continuations), data lines may not. However newlines can be
+included in data by means of the \n escape.
+</P>
+<br><a name="SEC8" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel &#60;ph10@cam.ac.uk&#62;
+<br>
+University Computing Service,
+<br>
+Cambridge CB2 3QG, England.
+</P>
+<P>
+Last updated: 03 February 2003
+<br>
+Copyright &copy; 1997-2003 University of Cambridge.
diff --git a/doc/pcre.3 b/doc/pcre.3
index 738f76b..7fd9851 100644
--- a/doc/pcre.3
+++ b/doc/pcre.3
@@ -1,683 +1,89 @@
.TH PCRE 3
.SH NAME
-pcre - Perl-compatible regular expressions.
-.SH SYNOPSIS
-.B #include <pcre.h>
-.PP
-.SM
-.br
-.B pcre *pcre_compile(const char *\fIpattern\fR, int \fIoptions\fR,
-.ti +5n
-.B const char **\fIerrptr\fR, int *\fIerroffset\fR,
-.ti +5n
-.B const unsigned char *\fItableptr\fR);
-.PP
-.br
-.B pcre_extra *pcre_study(const pcre *\fIcode\fR, int \fIoptions\fR,
-.ti +5n
-.B const char **\fIerrptr\fR);
-.PP
-.br
-.B int pcre_exec(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"
-.ti +5n
-.B "const char *\fIsubject\fR," int \fIlength\fR, int \fIstartoffset\fR,
-.ti +5n
-.B int \fIoptions\fR, int *\fIovector\fR, int \fIovecsize\fR);
-.PP
-.br
-.B int pcre_copy_substring(const char *\fIsubject\fR, int *\fIovector\fR,
-.ti +5n
-.B int \fIstringcount\fR, int \fIstringnumber\fR, char *\fIbuffer\fR,
-.ti +5n
-.B int \fIbuffersize\fR);
-.PP
-.br
-.B int pcre_get_substring(const char *\fIsubject\fR, int *\fIovector\fR,
-.ti +5n
-.B int \fIstringcount\fR, int \fIstringnumber\fR,
-.ti +5n
-.B const char **\fIstringptr\fR);
-.PP
-.br
-.B int pcre_get_substring_list(const char *\fIsubject\fR,
-.ti +5n
-.B int *\fIovector\fR, int \fIstringcount\fR, "const char ***\fIlistptr\fR);"
-.PP
-.br
-.B void pcre_free_substring(const char *\fIstringptr\fR);
-.PP
-.br
-.B void pcre_free_substring_list(const char **\fIstringptr\fR);
-.PP
-.br
-.B const unsigned char *pcre_maketables(void);
-.PP
-.br
-.B int pcre_fullinfo(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"
-.ti +5n
-.B int \fIwhat\fR, void *\fIwhere\fR);
-.PP
-.br
-.B int pcre_info(const pcre *\fIcode\fR, int *\fIoptptr\fR, int
-.B *\fIfirstcharptr\fR);
-.PP
-.br
-.B char *pcre_version(void);
-.PP
-.br
-.B void *(*pcre_malloc)(size_t);
-.PP
-.br
-.B void (*pcre_free)(void *);
-
-
-
+PCRE - Perl-compatible regular expressions
.SH DESCRIPTION
+.rs
+.sp
The PCRE library is a set of functions that implement regular expression
-pattern matching using the same syntax and semantics as Perl 5, with just a few
-differences (see below). The current implementation corresponds to Perl 5.005,
-with some additional features from later versions. This includes some
-experimental, incomplete support for UTF-8 encoded strings. Details of exactly
-what is and what is not supported are given below.
-
-PCRE has its own native API, which is described in this document. There is also
-a set of wrapper functions that correspond to the POSIX regular expression API.
-These are described in the \fBpcreposix\fR documentation.
-
-The native API function prototypes are defined in the header file \fBpcre.h\fR,
-and on Unix systems the library itself is called \fBlibpcre.a\fR, so can be
-accessed by adding \fB-lpcre\fR to the command for linking an application which
-calls it. The header file defines the macros PCRE_MAJOR and PCRE_MINOR to
-contain the major and minor release numbers for the library. Applications can
-use these to include support for different releases.
-
-The functions \fBpcre_compile()\fR, \fBpcre_study()\fR, and \fBpcre_exec()\fR
-are used for compiling and matching regular expressions. A sample program that
-demonstrates the simplest way of using them is given in the file
-\fIpcredemo.c\fR. The last section of this man page describes how to run it.
-
-The functions \fBpcre_copy_substring()\fR, \fBpcre_get_substring()\fR, and
-\fBpcre_get_substring_list()\fR are convenience functions for extracting
-captured substrings from a matched subject string; \fBpcre_free_substring()\fR
-and \fBpcre_free_substring_list()\fR are also provided, to free the memory used
-for extracted strings.
-
-The function \fBpcre_maketables()\fR is used (optionally) to build a set of
-character tables in the current locale for passing to \fBpcre_compile()\fR.
-
-The function \fBpcre_fullinfo()\fR is used to find out information about a
-compiled pattern; \fBpcre_info()\fR is an obsolete version which returns only
-some of the available information, but is retained for backwards compatibility.
-The function \fBpcre_version()\fR returns a pointer to a string containing the
-version of PCRE and its date of release.
-
-The global variables \fBpcre_malloc\fR and \fBpcre_free\fR initially contain
-the entry points of the standard \fBmalloc()\fR and \fBfree()\fR functions
-respectively. PCRE calls the memory management functions via these variables,
-so a calling program can replace them if it wishes to intercept the calls. This
-should be done before calling any PCRE functions.
-
-
-.SH MULTI-THREADING
-The PCRE functions can be used in multi-threading applications, with the
-proviso that the memory management functions pointed to by \fBpcre_malloc\fR
-and \fBpcre_free\fR are shared by all threads.
-
-The compiled form of a regular expression is not altered during matching, so
-the same compiled pattern can safely be used by several threads at once.
-
-
-.SH COMPILING A PATTERN
-The function \fBpcre_compile()\fR is called to compile a pattern into an
-internal form. The pattern is a C string terminated by a binary zero, and
-is passed in the argument \fIpattern\fR. A pointer to a single block of memory
-that is obtained via \fBpcre_malloc\fR is returned. This contains the compiled
-code and related data. The \fBpcre\fR type is defined for the returned block;
-this is a typedef for a structure whose contents are not externally defined. It
-is up to the caller to free the memory when it is no longer required.
-
-Although the compiled code of a PCRE regex is relocatable, that is, it does not
-depend on memory location, the complete \fBpcre\fR data block is not
-fully relocatable, because it contains a copy of the \fItableptr\fR argument,
-which is an address (see below).
-
-The size of a compiled pattern is roughly proportional to the length of the
-pattern string, except that each character class (other than those containing
-just a single character, negated or not) requires 33 bytes, and repeat
-quantifiers with a minimum greater than one or a bounded maximum cause the
-relevant portions of the compiled pattern to be replicated.
-
-The \fIoptions\fR argument contains independent bits that affect the
-compilation. It should be zero if no options are required. Some of the options,
-in particular, those that are compatible with Perl, can also be set and unset
-from within the pattern (see the detailed description of regular expressions
-below). For these options, the contents of the \fIoptions\fR argument specifies
-their initial settings at the start of compilation and execution. The
-PCRE_ANCHORED option can be set at the time of matching as well as at compile
-time.
-
-If \fIerrptr\fR is NULL, \fBpcre_compile()\fR returns NULL immediately.
-Otherwise, if compilation of a pattern fails, \fBpcre_compile()\fR returns
-NULL, and sets the variable pointed to by \fIerrptr\fR to point to a textual
-error message. The offset from the start of the pattern to the character where
-the error was discovered is placed in the variable pointed to by
-\fIerroffset\fR, which must not be NULL. If it is, an immediate error is given.
-
-If the final argument, \fItableptr\fR, is NULL, PCRE uses a default set of
-character tables which are built when it is compiled, using the default C
-locale. Otherwise, \fItableptr\fR must be the result of a call to
-\fBpcre_maketables()\fR. See the section on locale support below.
-
-This code fragment shows a typical straightforward call to \fBpcre_compile()\fR:
-
- pcre *re;
- const char *error;
- int erroffset;
- re = pcre_compile(
- "^A.*Z", /* the pattern */
- 0, /* default options */
- &error, /* for error message */
- &erroffset, /* for error offset */
- NULL); /* use default character tables */
-
-The following option bits are defined in the header file:
-
- PCRE_ANCHORED
-
-If this bit is set, the pattern is forced to be "anchored", that is, it is
-constrained to match only at the start of the string which 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.
-
- PCRE_CASELESS
-
-If this bit is set, letters in the pattern match both upper and lower case
-letters. It is equivalent to Perl's /i option.
-
- PCRE_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 the final character if it is a newline (but not before any
-other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is
-set. There is no equivalent to this option in Perl.
-
- PCRE_DOTALL
-
-If this bit is set, a dot metacharater in the pattern matches all characters,
-including newlines. Without it, newlines are excluded. This option is
-equivalent to Perl's /s option. A negative class such as [^a] always matches a
-newline character, independent of the setting of this option.
-
- PCRE_EXTENDED
-
-If this bit is set, whitespace data characters in the pattern are totally
-ignored except when escaped or inside a character class, and characters between
-an unescaped # outside a character class and the next newline character,
-inclusive, are also ignored. This is equivalent to Perl's /x option, and makes
-it possible to include comments inside complicated patterns. Note, however,
-that this applies only to data characters. Whitespace characters may never
-appear within special character sequences in a pattern, for example within the
-sequence (?( which introduces a conditional subpattern.
-
- PCRE_EXTRA
-
-This option was invented in order to turn on additional functionality of PCRE
-that is incompatible with Perl, but it is currently of very little use. When
-set, any backslash in a pattern that is followed by a letter that has no
-special meaning causes an error, thus reserving these combinations for future
-expansion. By default, as in Perl, a backslash followed by a letter with no
-special meaning is treated as a literal. There are at present no other features
-controlled by this option. It can also be set by a (?X) option setting within a
-pattern.
-
- PCRE_MULTILINE
-
-By default, PCRE treats the subject string as consisting of a single "line" of
-characters (even if it actually contains several newlines). The "start of line"
-metacharacter (^) matches only at the start of the string, while the "end of
-line" metacharacter ($) matches only at the end of the string, or before a
-terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as
-Perl.
-
-When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs
-match immediately following or immediately before any newline in the subject
-string, respectively, as well as at the very start and end. This is equivalent
-to Perl's /m option. If there are no "\\n" characters in a subject string, or
-no occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no
-effect.
-
- PCRE_UNGREEDY
-
-This option inverts the "greediness" of the quantifiers so that they are not
-greedy by default, but become greedy if followed by "?". It is not compatible
-with Perl. It can also be set by a (?U) option setting within the pattern.
-
- PCRE_UTF8
-
-This option causes PCRE to regard both the pattern and the subject as strings
-of UTF-8 characters instead of just byte strings. However, it is available only
-if PCRE has been built to include UTF-8 support. If not, the use of this option
-provokes an error. Support for UTF-8 is new, experimental, and incomplete.
-Details of exactly what it entails are given below.
-
-
-.SH STUDYING A PATTERN
-When a pattern is going to be used several times, it is worth spending more
-time analyzing it in order to speed up the time taken for matching. The
-function \fBpcre_study()\fR takes a pointer to a compiled pattern as its first
-argument, and returns a pointer to a \fBpcre_extra\fR block (another typedef
-for a structure with hidden contents) containing additional information about
-the pattern; this can be passed to \fBpcre_exec()\fR. If no additional
-information is available, NULL is returned.
-
-The second argument contains option bits. At present, no options are defined
-for \fBpcre_study()\fR, and this argument should always be zero.
-
-The third argument for \fBpcre_study()\fR is a pointer to an error message. If
-studying succeeds (even if no data is returned), the variable it points to is
-set to NULL. Otherwise it points to a textual error message.
-
-This is a typical call to \fBpcre_study\fR():
-
- pcre_extra *pe;
- pe = pcre_study(
- re, /* result of pcre_compile() */
- 0, /* no options exist */
- &error); /* set to NULL or points to a message */
-
-At present, studying a pattern is useful only for non-anchored patterns that do
-not have a single fixed starting character. A bitmap of possible starting
-characters is created.
-
-
-.SH LOCALE SUPPORT
-PCRE handles caseless matching, and determines whether characters are letters,
-digits, or whatever, by reference to a set of tables. The library contains a
-default set of tables which is created in the default C locale when PCRE is
-compiled. This is used when the final argument of \fBpcre_compile()\fR is NULL,
-and is sufficient for many applications.
-
-An alternative set of tables can, however, be supplied. Such tables are built
-by calling the \fBpcre_maketables()\fR function, which has no arguments, in the
-relevant locale. The result can then be passed to \fBpcre_compile()\fR as often
-as necessary. For example, to build and use tables that are appropriate for the
-French locale (where accented characters with codes greater than 128 are
-treated as letters), the following code could be used:
-
- setlocale(LC_CTYPE, "fr");
- tables = pcre_maketables();
- re = pcre_compile(..., tables);
-
-The tables are built in memory that is obtained via \fBpcre_malloc\fR. The
-pointer that is passed to \fBpcre_compile\fR is saved with the compiled
-pattern, and the same tables are used via this pointer by \fBpcre_study()\fR
-and \fBpcre_exec()\fR. Thus for any single pattern, compilation, studying and
-matching all happen in the same locale, but different patterns can be compiled
-in different locales. It is the caller's responsibility to ensure that the
-memory containing the tables remains available for as long as it is needed.
-
-
-.SH INFORMATION ABOUT A PATTERN
-The \fBpcre_fullinfo()\fR function returns information about a compiled
-pattern. It replaces the obsolete \fBpcre_info()\fR function, which is
-nevertheless retained for backwards compability (and is documented below).
-
-The first argument for \fBpcre_fullinfo()\fR is a pointer to the compiled
-pattern. The second argument is the result of \fBpcre_study()\fR, or NULL if
-the pattern was not studied. The third argument specifies which piece of
-information is required, while the fourth argument is a pointer to a variable
-to receive the data. The yield of the function is zero for success, or one of
-the following negative numbers:
-
- PCRE_ERROR_NULL the argument \fIcode\fR was NULL
- the argument \fIwhere\fR was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
- PCRE_ERROR_BADOPTION the value of \fIwhat\fR was invalid
-
-Here is a typical call of \fBpcre_fullinfo()\fR, to obtain the length of the
-compiled pattern:
-
- int rc;
- unsigned long int length;
- rc = pcre_fullinfo(
- re, /* result of pcre_compile() */
- pe, /* result of pcre_study(), or NULL */
- PCRE_INFO_SIZE, /* what is required */
- &length); /* where to put the data */
-
-The possible values for the third argument are defined in \fBpcre.h\fR, and are
-as follows:
-
- PCRE_INFO_OPTIONS
-
-Return a copy of the options with which the pattern was compiled. The fourth
-argument should point to an \fBunsigned long int\fR variable. These option bits
-are those specified in the call to \fBpcre_compile()\fR, modified by any
-top-level option settings within the pattern itself, and with the PCRE_ANCHORED
-bit forcibly set if the form of the pattern implies that it can match only at
-the start of a subject string.
-
- PCRE_INFO_SIZE
-
-Return the size of the compiled pattern, that is, the value that was passed as
-the argument to \fBpcre_malloc()\fR when PCRE was getting memory in which to
-place the compiled data. The fourth argument should point to a \fBsize_t\fR
-variable.
-
- PCRE_INFO_CAPTURECOUNT
-
-Return the number of capturing subpatterns in the pattern. The fourth argument
-should point to an \fbint\fR variable.
-
- PCRE_INFO_BACKREFMAX
-
-Return the number of the highest back reference in the pattern. The fourth
-argument should point to an \fBint\fR variable. Zero is returned if there are
-no back references.
-
- PCRE_INFO_FIRSTCHAR
-
-Return information about the first character of any matched string, for a
-non-anchored pattern. If there is a fixed first character, e.g. from a pattern
-such as (cat|cow|coyote), it is returned in the integer pointed to by
-\fIwhere\fR. Otherwise, if either
-
-(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
-starts with "^", or
-
-(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set
-(if it were set, the pattern would be anchored),
-
--1 is returned, indicating that the pattern matches only at the start of a
-subject string or after any "\\n" within the string. Otherwise -2 is returned.
-For anchored patterns, -2 is returned.
-
- PCRE_INFO_FIRSTTABLE
-
-If the pattern was studied, and this resulted in the construction of a 256-bit
-table indicating a fixed set of characters for the first character in any
-matching string, a pointer to the table is returned. Otherwise NULL is
-returned. The fourth argument should point to an \fBunsigned char *\fR
-variable.
-
- PCRE_INFO_LASTLITERAL
-
-For a non-anchored pattern, return the value of the rightmost literal character
-which must exist in any matched string, other than at its start. The fourth
-argument should point to an \fBint\fR variable. If there is no such character,
-or if the pattern is anchored, -1 is returned. For example, for the pattern
-/a\\d+z\\d+/ the returned value is 'z'.
-
-The \fBpcre_info()\fR function is now obsolete because its interface is too
-restrictive to return all the available data about a compiled pattern. New
-programs should use \fBpcre_fullinfo()\fR instead. The yield of
-\fBpcre_info()\fR is the number of capturing subpatterns, or one of the
-following negative numbers:
-
- PCRE_ERROR_NULL the argument \fIcode\fR was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
-
-If the \fIoptptr\fR argument is not NULL, a copy of the options with which the
-pattern was compiled is placed in the integer it points to (see
-PCRE_INFO_OPTIONS above).
-
-If the pattern is not anchored and the \fIfirstcharptr\fR argument is not NULL,
-it is used to pass back information about the first character of any matched
-string (see PCRE_INFO_FIRSTCHAR above).
-
-
-.SH MATCHING A PATTERN
-The function \fBpcre_exec()\fR is called to match a subject string against a
-pre-compiled pattern, which is passed in the \fIcode\fR argument. If the
-pattern has been studied, the result of the study should be passed in the
-\fIextra\fR argument. Otherwise this must be NULL.
-
-Here is an example of a simple call to \fBpcre_exec()\fR:
-
- int rc;
- int ovector[30];
- rc = pcre_exec(
- re, /* result of pcre_compile() */
- NULL, /* we didn't study the pattern */
- "some string", /* the subject string */
- 11, /* the length of the subject string */
- 0, /* start at offset 0 in the subject */
- 0, /* default options */
- ovector, /* vector for substring information */
- 30); /* number of elements in the vector */
-
-The PCRE_ANCHORED option can be passed in the \fIoptions\fR argument, whose
-unused bits must be zero. However, if a pattern was compiled with
-PCRE_ANCHORED, or turned out to be anchored by virtue of its contents, it
-cannot be made unachored at matching time.
-
-There are also three further options that can be set only at matching time:
-
- PCRE_NOTBOL
-
-The first character of the string is not the beginning of a line, so the
-circumflex metacharacter should not match before it. Setting this without
-PCRE_MULTILINE (at compile time) causes circumflex never to match.
-
- PCRE_NOTEOL
-
-The end of the string is not the end of a line, so the dollar metacharacter
-should not match it nor (except in multiline mode) a newline immediately before
-it. Setting this without PCRE_MULTILINE (at compile time) causes dollar never
-to match.
-
- PCRE_NOTEMPTY
-
-An empty string is not considered to be a valid match if this option is set. If
-there are alternatives in the pattern, they are tried. If all the alternatives
-match the empty string, the entire match fails. For example, if the pattern
-
- a?b?
-
-is applied to a string not beginning with "a" or "b", it matches the empty
-string at the start of the subject. With PCRE_NOTEMPTY set, this match is not
-valid, so PCRE searches further into the string for occurrences of "a" or "b".
-
-Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a special case
-of a pattern match of the empty string within its \fBsplit()\fR function, and
-when using the /g modifier. It is possible to emulate Perl's behaviour after
-matching a null string by first trying the match again at the same offset with
-PCRE_NOTEMPTY set, and then if that fails by advancing the starting offset (see
-below) and trying an ordinary match again.
-
-The subject string is passed as a pointer in \fIsubject\fR, a length in
-\fIlength\fR, and a starting offset in \fIstartoffset\fR. Unlike the pattern
-string, the subject may contain binary zero characters. When the starting
-offset is zero, the search for a match starts at the beginning of the subject,
-and this is by far the most common case.
-
-A non-zero starting offset is useful when searching for another match in the
-same subject by calling \fBpcre_exec()\fR again after a previous success.
-Setting \fIstartoffset\fR differs from just passing over a shortened string and
-setting PCRE_NOTBOL in the case of a pattern that begins with any kind of
-lookbehind. For example, consider the pattern
-
- \\Biss\\B
-
-which finds occurrences of "iss" in the middle of words. (\\B matches only if
-the current position in the subject is not a word boundary.) When applied to
-the string "Mississipi" the first call to \fBpcre_exec()\fR finds the first
-occurrence. If \fBpcre_exec()\fR is called again with just the remainder of the
-subject, namely "issipi", it does not match, because \\B is always false at the
-start of the subject, which is deemed to be a word boundary. However, if
-\fBpcre_exec()\fR is passed the entire string again, but with \fIstartoffset\fR
-set to 4, it finds the second occurrence of "iss" because it is able to look
-behind the starting point to discover that it is preceded by a letter.
-
-If a non-zero starting offset is passed when the pattern is anchored, one
-attempt to match at the given offset is tried. This can only succeed if the
-pattern does not require the match to be at the start of the subject.
-
-In general, a pattern matches a certain portion of the subject, and in
-addition, further substrings from the subject may be picked out by parts of the
-pattern. Following the usage in Jeffrey Friedl's book, this is called
-"capturing" in what follows, and the phrase "capturing subpattern" is used for
-a fragment of a pattern that picks out a substring. PCRE supports several other
-kinds of parenthesized subpattern that do not cause substrings to be captured.
-
-Captured substrings are returned to the caller via a vector of integer offsets
-whose address is passed in \fIovector\fR. The number of elements in the vector
-is passed in \fIovecsize\fR. The first two-thirds of the vector is used to pass
-back captured substrings, each substring using a pair of integers. The
-remaining third of the vector is used as workspace by \fBpcre_exec()\fR while
-matching capturing subpatterns, and is not available for passing back
-information. The length passed in \fIovecsize\fR should always be a multiple of
-three. If it is not, it is rounded down.
-
-When a match has been successful, information about captured substrings is
-returned in pairs of integers, starting at the beginning of \fIovector\fR, and
-continuing up to two-thirds of its length at the most. The first element of a
-pair is set to the offset of the first character in a substring, and the second
-is set to the offset of the first character after the end of a substring. The
-first pair, \fIovector[0]\fR and \fIovector[1]\fR, identify the portion of the
-subject string matched by the entire pattern. The next pair is used for the
-first capturing subpattern, and so on. The value returned by \fBpcre_exec()\fR
-is the number of pairs that have been set. If there are no capturing
-subpatterns, the return value from a successful match is 1, indicating that
-just the first pair of offsets has been set.
-
-Some convenience functions are provided for extracting the captured substrings
-as separate strings. These are described in the following section.
-
-It is possible for an capturing subpattern number \fIn+1\fR to match some
-part of the subject when subpattern \fIn\fR has not been used at all. For
-example, if the string "abc" is matched against the pattern (a|(z))(bc)
-subpatterns 1 and 3 are matched, but 2 is not. When this happens, both offset
-values corresponding to the unused subpattern are set to -1.
-
-If a capturing subpattern is matched repeatedly, it is the last portion of the
-string that it matched that gets returned.
-
-If the vector is too small to hold all the captured substrings, it is used as
-far as possible (up to two-thirds of its length), and the function returns a
-value of zero. In particular, if the substring offsets are not of interest,
-\fBpcre_exec()\fR may be called with \fIovector\fR passed as NULL and
-\fIovecsize\fR as zero. However, if the pattern contains back references and
-the \fIovector\fR isn't big enough to remember the related substrings, PCRE has
-to get additional memory for use during matching. Thus it is usually advisable
-to supply an \fIovector\fR.
-
-Note that \fBpcre_info()\fR can be used to find out how many capturing
-subpatterns there are in a compiled pattern. The smallest size for
-\fIovector\fR that will allow for \fIn\fR captured substrings in addition to
-the offsets of the substring matched by the whole pattern is (\fIn\fR+1)*3.
-
-If \fBpcre_exec()\fR fails, it returns a negative number. The following are
-defined in the header file:
-
- PCRE_ERROR_NOMATCH (-1)
-
-The subject string did not match the pattern.
-
- PCRE_ERROR_NULL (-2)
-
-Either \fIcode\fR or \fIsubject\fR was passed as NULL, or \fIovector\fR was
-NULL and \fIovecsize\fR was not zero.
-
- PCRE_ERROR_BADOPTION (-3)
-
-An unrecognized bit was set in the \fIoptions\fR argument.
-
- PCRE_ERROR_BADMAGIC (-4)
-
-PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch
-the case when it is passed a junk pointer. This is the error it gives when the
-magic number isn't present.
-
- PCRE_ERROR_UNKNOWN_NODE (-5)
-
-While running the pattern match, an unknown item was encountered in the
-compiled pattern. This error could be caused by a bug in PCRE or by overwriting
-of the compiled pattern.
-
- PCRE_ERROR_NOMEMORY (-6)
-
-If a pattern contains back references, but the \fIovector\fR that is passed to
-\fBpcre_exec()\fR is not big enough to remember the referenced substrings, PCRE
-gets a block of memory at the start of matching to use for this purpose. If the
-call via \fBpcre_malloc()\fR fails, this error is given. The memory is freed at
-the end of matching.
-
-
-.SH EXTRACTING CAPTURED SUBSTRINGS
-Captured substrings can be accessed directly by using the offsets returned by
-\fBpcre_exec()\fR in \fIovector\fR. For convenience, the functions
-\fBpcre_copy_substring()\fR, \fBpcre_get_substring()\fR, and
-\fBpcre_get_substring_list()\fR are provided for 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 does not, of course, function as a C string.
-
-The first three arguments are the same for all three functions: \fIsubject\fR
-is the subject string which has just been successfully matched, \fIovector\fR
-is a pointer to the vector of integer offsets that was passed to
-\fBpcre_exec()\fR, and \fIstringcount\fR is the number of substrings that
-were captured by the match, including the substring that matched the entire
-regular expression. This is the value returned by \fBpcre_exec\fR if it
-is greater than zero. If \fBpcre_exec()\fR returned zero, indicating that it
-ran out of space in \fIovector\fR, the value passed as \fIstringcount\fR should
-be the size of the vector divided by three.
-
-The functions \fBpcre_copy_substring()\fR and \fBpcre_get_substring()\fR
-extract a single substring, whose number is given as \fIstringnumber\fR. A
-value of zero extracts the substring that matched the entire pattern, while
-higher values extract the captured substrings. For \fBpcre_copy_substring()\fR,
-the string is placed in \fIbuffer\fR, whose length is given by
-\fIbuffersize\fR, while for \fBpcre_get_substring()\fR a new block of memory is
-obtained via \fBpcre_malloc\fR, and its address is returned via
-\fIstringptr\fR. The yield of the function is the length of the string, not
-including the terminating zero, or one of
-
- PCRE_ERROR_NOMEMORY (-6)
-
-The buffer was too small for \fBpcre_copy_substring()\fR, or the attempt to get
-memory failed for \fBpcre_get_substring()\fR.
-
- PCRE_ERROR_NOSUBSTRING (-7)
-
-There is no substring whose number is \fIstringnumber\fR.
-
-The \fBpcre_get_substring_list()\fR function extracts all available substrings
-and builds a list of pointers to them. All this is done in a single block of
-memory which is obtained via \fBpcre_malloc\fR. The address of the memory block
-is returned via \fIlistptr\fR, which is also the start of the list of string
-pointers. The end of the list is marked by a NULL pointer. The yield of the
-function is zero if all went well, or
-
- PCRE_ERROR_NOMEMORY (-6)
-
-if the attempt to get the memory block failed.
-
-When any of these functions encounter a substring that is unset, which can
-happen when capturing subpattern number \fIn+1\fR matches some part of the
-subject, but subpattern \fIn\fR has not been used at all, they return an empty
-string. This can be distinguished from a genuine zero-length substring by
-inspecting the appropriate offset in \fIovector\fR, which is negative for unset
-substrings.
-
-The two convenience functions \fBpcre_free_substring()\fR and
-\fBpcre_free_substring_list()\fR can be used to free the memory returned by
-a previous call of \fBpcre_get_substring()\fR or
-\fBpcre_get_substring_list()\fR, respectively. They do nothing more than call
-the function pointed to by \fBpcre_free\fR, which of course could be called
-directly from a C program. However, PCRE is used in some situations where it is
-linked via a special interface to another programming language which cannot use
-\fBpcre_free\fR directly; it is for these cases that the functions are
-provided.
-
+pattern matching using the same syntax and semantics as Perl, with just a few
+differences. The current implementation of PCRE (release 4.x) corresponds
+approximately with Perl 5.8, including support for UTF-8 encoded strings.
+However, this support has to be explicitly enabled; it is not the default.
+
+PCRE is written in C and released as a C library. However, a number of people
+have written wrappers and interfaces of various kinds. A C++ class is included
+in these contributions, which can be found in the \fIContrib\fR directory at
+the primary FTP site, which is:
+
+.\" HTML <a href="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre">
+.\" </a>
+ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre
+
+Details of exactly which Perl regular expression features are and are not
+supported by PCRE are given in separate documents. See the
+.\" HREF
+\fBpcrepattern\fR
+.\"
+and
+.\" HREF
+\fBpcrecompat\fR
+.\"
+pages.
+
+Some features of PCRE can be included, excluded, or changed when the library is
+built. The
+.\" HREF
+\fBpcre_config()\fR
+.\"
+function makes it possible for a client to discover which features are
+available. Documentation about building PCRE for various operating systems can
+be found in the \fBREADME\fR file in the source distribution.
+
+.SH USER DOCUMENTATION
+.rs
+.sp
+The user documentation for PCRE has been split up into a number of different
+sections. In the "man" format, each of these is a separate "man page". In the
+HTML format, each is a separate page, linked from the index page. In the plain
+text format, all the sections are concatenated, for ease of searching. The
+sections are as follows:
+
+ pcre this document
+ pcreapi details of PCRE's native API
+ pcrebuild options for building PCRE
+ pcrecallout details of the callout feature
+ pcrecompat discussion of Perl compatibility
+ pcregrep description of the \fBpcregrep\fR command
+ pcrepattern syntax and semantics of supported
+ regular expressions
+ pcreperform discussion of performance issues
+ pcreposix the POSIX-compatible API
+ pcresample discussion of the sample program
+ pcretest the \fBpcretest\fR testing command
+
+In addition, in the "man" and HTML formats, there is a short page for each
+library function, listing its arguments and results.
.SH LIMITATIONS
+.rs
+.sp
There are some size limitations in PCRE but it is hoped that they will never in
practice be relevant.
-The maximum length of a compiled pattern is 65539 (sic) bytes.
+
+The maximum length of a compiled pattern is 65539 (sic) bytes if PCRE is
+compiled with the default internal linkage size of 2. If you want to process
+regular expressions that are truly enormous, you can compile PCRE with an
+internal linkage size of 3 or 4 (see the \fBREADME\fR file in the source
+distribution and the
+.\" HREF
+\fBpcrebuild\fR
+.\"
+documentation for details). If these cases the limit is substantially larger.
+However, the speed of execution will be slower.
+
All values in repeating quantifiers must be less than 65536.
-There maximum number of capturing subpatterns is 65535.
+The maximum number of capturing subpatterns is 65535.
+
There is no limit to the number of non-capturing subpatterns, but the maximum
depth of nesting of all kinds of parenthesized subpattern, including capturing
subpatterns, assertions, and other types of subpattern, is 200.
@@ -687,1305 +93,75 @@ integer variable can hold. However, PCRE uses recursion to handle subpatterns
and indefinite repetition. This means that the available stack space may limit
the size of a subject string that can be processed by certain patterns.
-
-.SH DIFFERENCES FROM PERL
-The differences described here are with respect to Perl 5.005.
-
-1. By default, a whitespace character is any character that the C library
-function \fBisspace()\fR recognizes, though it is possible to compile PCRE with
-alternative character type tables. Normally \fBisspace()\fR matches space,
-formfeed, newline, carriage return, horizontal tab, and vertical tab. Perl 5
-no longer includes vertical tab in its set of whitespace characters. The \\v
-escape that was in the Perl documentation for a long time was never in fact
-recognized. However, the character itself was treated as whitespace at least
-up to 5.002. In 5.004 and 5.005 it does not match \\s.
-
-2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl permits
-them, but they do not mean what you might think. For example, (?!a){3} does
-not assert that the next three characters are not "a". It just asserts that the
-next character is not "a" three times.
-
-3. Capturing subpatterns that occur inside negative lookahead assertions are
-counted, but their entries in the offsets vector are never set. Perl sets its
-numerical variables from any such patterns that are matched before the
-assertion fails to match something (thereby succeeding), but only if the
-negative lookahead assertion contains just one branch.
-
-4. Though binary zero characters are supported in the subject string, they are
-not allowed in a pattern string because it is passed as a normal C string,
-terminated by zero. The escape sequence "\\0" can be used in the pattern to
-represent a binary zero.
-
-5. The following Perl escape sequences are not supported: \\l, \\u, \\L, \\U,
-\\E, \\Q. In fact these are implemented by Perl's general string-handling and
-are not part of its pattern matching engine.
-
-6. The Perl \\G assertion is not supported as it is not relevant to single
-pattern matches.
-
-7. Fairly obviously, PCRE does not support the (?{code}) and (?p{code})
-constructions. However, there is some experimental support for recursive
-patterns using the non-Perl item (?R).
-
-8. There are at the time of writing some oddities in Perl 5.005_02 concerned
-with the settings of captured strings when part of a pattern is repeated. For
-example, matching "aba" against the pattern /^(a(b)?)+$/ sets $2 to the value
-"b", but matching "aabbaa" against /^(aa(bb)?)+$/ leaves $2 unset. However, if
-the pattern is changed to /^(aa(b(b))?)+$/ then $2 (and $3) are set.
-
-In Perl 5.004 $2 is set in both cases, and that is also true of PCRE. If in the
-future Perl changes to a consistent state that is different, PCRE may change to
-follow.
-
-9. Another as yet unresolved discrepancy is that in Perl 5.005_02 the pattern
-/^(a)?(?(1)a|b)+$/ matches the string "a", whereas in PCRE it does not.
-However, in both Perl and PCRE /^(a)?a/ matched against "a" leaves $1 unset.
-
-10. PCRE provides some extensions to the Perl regular expression facilities:
-
-(a) Although lookbehind assertions must match fixed length strings, each
-alternative branch of a lookbehind assertion can match a different length of
-string. Perl 5.005 requires them all to have the same length.
-
-(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $ meta-
-character matches only at the very end of the string.
-
-(c) If PCRE_EXTRA is set, a backslash followed by a letter with no special
-meaning is faulted.
-
-(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is
-inverted, that is, by default they are not greedy, but if followed by a
-question mark they are.
-
-(e) PCRE_ANCHORED can be used to force a pattern to be tried only at the start
-of the subject.
-
-(f) The PCRE_NOTBOL, PCRE_NOTEOL, and PCRE_NOTEMPTY options for
-\fBpcre_exec()\fR have no Perl equivalents.
-
-(g) The (?R) construct allows for recursive pattern matching (Perl 5.6 can do
-this using the (?p{code}) construct, which PCRE cannot of course support.)
-
-
-.SH REGULAR EXPRESSION DETAILS
-The syntax and semantics of the regular expressions supported by PCRE are
-described below. Regular expressions are also described in the Perl
-documentation and in a number of other books, some of which have copious
-examples. Jeffrey Friedl's "Mastering Regular Expressions", published by
-O'Reilly (ISBN 1-56592-257), covers them in great detail.
-
-The description here is intended as reference documentation. The basic
-operation of PCRE is on strings of bytes. However, there is the beginnings of
-some support for UTF-8 character strings. To use this support you must
-configure PCRE to include it, and then call \fBpcre_compile()\fR with the
-PCRE_UTF8 option. How this affects the pattern matching is described in the
-final section of this document.
-
-A regular expression is a pattern that is matched against a subject string from
-left to right. Most characters stand for themselves in a pattern, and match the
-corresponding characters in the subject. As a trivial example, the pattern
-
- The quick brown fox
-
-matches a portion of a subject string that is identical to itself. The power of
-regular expressions comes from the ability to include alternatives and
-repetitions in the pattern. These are encoded in the pattern by the use of
-\fImeta-characters\fR, which do not stand for themselves but instead are
-interpreted in some special way.
-
-There are two different sets of meta-characters: those that are recognized
-anywhere in the pattern except within square brackets, and those that are
-recognized in square brackets. Outside square brackets, the meta-characters are
-as follows:
-
- \\ general escape character with several uses
- ^ assert start of subject (or line, in multiline mode)
- $ assert end of subject (or line, in multiline mode)
- . match any character except newline (by default)
- [ start character class definition
- | start of alternative branch
- ( start subpattern
- ) end subpattern
- ? extends the meaning of (
- also 0 or 1 quantifier
- also quantifier minimizer
- * 0 or more quantifier
- + 1 or more quantifier
- { start min/max quantifier
-
-Part of a pattern that is in square brackets is called a "character class". In
-a character class the only meta-characters are:
-
- \\ general escape character
- ^ negate the class, but only if the first character
- - indicates character range
- ] terminates the character class
-
-The following sections describe the use of each of the meta-characters.
-
-
-.SH BACKSLASH
-The backslash character has several uses. Firstly, if it is followed by a
-non-alphameric character, it takes away any special meaning that character may
-have. This use of backslash as an escape character applies both inside and
-outside character classes.
-
-For example, if you want to match a "*" character, you write "\\*" in the
-pattern. This applies whether or not the following character would otherwise be
-interpreted as a meta-character, so it is always safe to precede a
-non-alphameric with "\\" to specify that it stands for itself. In particular,
-if you want to match a backslash, you write "\\\\".
-
-If a pattern is compiled with the PCRE_EXTENDED option, whitespace in the
-pattern (other than in a character class) and characters between a "#" outside
-a character class and the next newline character are ignored. An escaping
-backslash can be used to include a whitespace or "#" character as part of the
-pattern.
-
-A second use of backslash provides a way of encoding non-printing characters
-in patterns in a visible manner. There is no restriction on the appearance of
-non-printing characters, apart from the binary zero that terminates a pattern,
-but when a pattern is being prepared by text editing, it is usually easier to
-use one of the following escape sequences than the binary character it
-represents:
-
- \\a alarm, that is, the BEL character (hex 07)
- \\cx "control-x", where x is any character
- \\e escape (hex 1B)
- \\f formfeed (hex 0C)
- \\n newline (hex 0A)
- \\r carriage return (hex 0D)
- \\t tab (hex 09)
- \\xhh character with hex code hh
- \\ddd character with octal code ddd, or backreference
-
-The precise effect of "\\cx" is as follows: if "x" is a lower case letter, it
-is converted to upper case. Then bit 6 of the character (hex 40) is inverted.
-Thus "\\cz" becomes hex 1A, but "\\c{" becomes hex 3B, while "\\c;" becomes hex
-7B.
-
-After "\\x", up to two hexadecimal digits are read (letters can be in upper or
-lower case).
-
-After "\\0" up to two further octal digits are read. In both cases, if there
-are fewer than two digits, just those that are present are used. Thus the
-sequence "\\0\\x\\07" specifies two binary zeros followed by a BEL character.
-Make sure you supply two digits after the initial zero if the character that
-follows is itself an octal digit.
-
-The handling of a backslash followed by a digit other than 0 is complicated.
-Outside a character class, PCRE reads it and any following digits as a decimal
-number. If the number is less than 10, or if there have been at least that many
-previous capturing left parentheses in the expression, the entire sequence is
-taken as a \fIback reference\fR. A description of how this works is given
-later, following the discussion of parenthesized subpatterns.
-
-Inside a character class, or if the decimal number is greater than 9 and there
-have not been that many capturing subpatterns, PCRE re-reads up to three octal
-digits following the backslash, and generates a single byte from the least
-significant 8 bits of the value. Any subsequent digits stand for themselves.
-For example:
-
- \\040 is another way of writing a space
- \\40 is the same, provided there are fewer than 40
- previous capturing subpatterns
- \\7 is always a back reference
- \\11 might be a back reference, or another way of
- writing a tab
- \\011 is always a tab
- \\0113 is a tab followed by the character "3"
- \\113 is the character with octal code 113 (since there
- can be no more than 99 back references)
- \\377 is a byte consisting entirely of 1 bits
- \\81 is either a back reference, or a binary zero
- followed by the two characters "8" and "1"
-
-Note that octal values of 100 or greater must not be introduced by a leading
-zero, because no more than three octal digits are ever read.
-
-All the sequences that define a single byte value can be used both inside and
-outside character classes. In addition, inside a character class, the sequence
-"\\b" is interpreted as the backspace character (hex 08). Outside a character
-class it has a different meaning (see below).
-
-The third use of backslash is for specifying generic character types:
-
- \\d any decimal digit
- \\D any character that is not a decimal digit
- \\s any whitespace character
- \\S any character that is not a whitespace character
- \\w any "word" character
- \\W any "non-word" character
-
-Each pair of escape sequences partitions the complete set of characters into
-two disjoint sets. Any given character matches one, and only one, of each pair.
-
-A "word" character is any letter or digit or the underscore character, that is,
-any character which can be part of a Perl "word". The definition of letters and
-digits is controlled by PCRE's character tables, and may vary if locale-
-specific matching is taking place (see "Locale support" above). For example, in
-the "fr" (French) locale, some character codes greater than 128 are used for
-accented letters, and these are matched by \\w.
-
-These character type sequences can appear both inside and outside character
-classes. They each match one character of the appropriate type. If the current
-matching point is at the end of the subject string, all of them fail, since
-there is no character to match.
-
-The fourth use of backslash is for certain simple assertions. An assertion
-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 word boundary
- \\B not a word boundary
- \\A start of subject (independent of multiline mode)
- \\Z end of subject or newline at end (independent of multiline mode)
- \\z end of subject (independent of multiline mode)
-
-These assertions may not appear in character classes (but note that "\\b" has a
-different meaning, namely the backspace character, inside a character class).
-
-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.
-
-The \\A, \\Z, and \\z assertions differ from the traditional circumflex and
-dollar (described below) in that they only ever match at the very start and end
-of the subject string, whatever options are set. They are not affected by the
-PCRE_NOTBOL or PCRE_NOTEOL options. If the \fIstartoffset\fR argument of
-\fBpcre_exec()\fR is non-zero, \\A can never match. The difference between \\Z
-and \\z is that \\Z matches before a newline that is the last character of the
-string as well as at the end of the string, whereas \\z matches only at the
-end.
-
-
-.SH CIRCUMFLEX AND DOLLAR
-Outside a character class, in the default matching mode, the circumflex
-character is an assertion which is true only if the current matching point is
-at the start of the subject string. If the \fIstartoffset\fR argument of
-\fBpcre_exec()\fR is non-zero, circumflex can never match. 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 subject, it is said to be an
-"anchored" pattern. (There are also other constructs that can cause a pattern
-to be anchored.)
-
-A dollar character is an assertion which is true only if the current matching
-point is at the end of the subject string, or immediately before a newline
-character that is the last character in the string (by default). Dollar need
-not be the last character of the pattern if a number 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 character class.
-
-The meaning of dollar can be changed so that it matches only at the very end of
-the string, by setting the PCRE_DOLLAR_ENDONLY option at compile or matching
-time. This does not affect the \\Z assertion.
-
-The meanings of the circumflex and dollar characters are changed if the
-PCRE_MULTILINE option is set. When this is the case, they match immediately
-after and immediately before an internal "\\n" character, respectively, in
-addition to matching at the start and end of the subject string. For example,
-the pattern /^abc$/ matches the subject string "def\\nabc" 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 \fIstartoffset\fR argument of
-\fBpcre_exec()\fR is non-zero. The PCRE_DOLLAR_ENDONLY option is ignored if
-PCRE_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 PCRE_MULTILINE is set or not.
-
-
-.SH FULL STOP (PERIOD, DOT)
-Outside a character class, a dot in the pattern matches any one character in
-the subject, including a non-printing character, but not (by default) newline.
-If the PCRE_DOTALL option is set, dots match newlines as well. The handling of
-dot is entirely independent of the handling of circumflex and dollar, the only
-relationship being that they both involve newline characters. Dot has no
-special meaning in a character class.
-
-
-.SH SQUARE BRACKETS
-An opening square bracket introduces a character class, terminated by a closing
-square bracket. A closing square bracket on its own is not special. 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.
-
-A character class matches a single character in the subject; the character must
-be in the set of characters defined by the class, unless the first character in
-the class 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 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. Note that a
-circumflex is just a convenient notation for specifying the characters which
-are in the class by enumerating those that are not. It is not an assertion: it
-still consumes a character from the subject string, and 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 match "A", whereas a
-caseful version would.
-
-The newline character is never treated in any special way in character classes,
-whatever the setting of the PCRE_DOTALL or PCRE_MULTILINE options is. A class
-such as [^a] will always match a newline.
-
-The minus (hyphen) character can be used to specify a range of characters 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.
-
-It is not possible to have the literal character "]" as the end character 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 interpreted as a single class containing a
-range followed by two separate characters. The octal or hexadecimal
-representation of "]" can also be used to end a range.
-
-Ranges operate in ASCII collating sequence. They can also be used for
-characters specified numerically, for example [\\000-\\037]. 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 if character tables for the "fr" locale are in use,
-[\\xc8-\\xcb] matches accented E characters in both cases.
-
-The character types \\d, \\D, \\s, \\S, \\w, and \\W may also appear in a
-character class, and add the characters that they match to the class. For
-example, [\\dABCDEF] matches any hexadecimal digit. 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.
-
-All non-alphameric characters other than \\, -, ^ (at the start) and the
-terminating ] are non-special in character classes, but it does no harm if they
-are escaped.
-
-
-.SH POSIX CHARACTER CLASSES
-Perl 5.6 (not yet released at the time of writing) is going to support the
-POSIX notation for character classes, which uses names enclosed by [: and :]
-within the enclosing square brackets. PCRE supports this notation. For example,
-
- [01[:alpha:]%]
-
-matches "0", "1", any alphabetic character, or "%". The supported class names
-are
-
- alnum letters and digits
- alpha letters
- ascii character codes 0 - 127
- cntrl control characters
- digit decimal digits (same as \\d)
- graph printing characters, excluding space
- lower lower case letters
- print printing characters, including space
- punct printing characters, excluding letters and digits
- space white space (same as \\s)
- upper upper case letters
- word "word" characters (same as \\w)
- xdigit hexadecimal digits
-
-The names "ascii" and "word" are Perl extensions. Another Perl extension is
-negation, which is indicated by a ^ character after the colon. For example,
-
- [12[:^digit:]]
-
-matches "1", "2", or any non-digit. PCRE (and Perl) also recognize the POSIX
-syntax [.ch.] and [=ch=] where "ch" is a "collating element", but these are not
-supported, and an error is given if they are encountered.
-
-
-.SH VERTICAL BAR
-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 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 rest of the main
-pattern as well as the alternative in the subpattern.
-
-
-.SH INTERNAL OPTION SETTING
-The settings of PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and PCRE_EXTENDED
-can be changed from within the pattern by a sequence of Perl option letters
-enclosed between "(?" and ")". The option letters are
-
- i for PCRE_CASELESS
- m for PCRE_MULTILINE
- s for PCRE_DOTALL
- x for PCRE_EXTENDED
-
-For example, (?im) sets caseless, multiline matching. It is also possible to
-unset these options by preceding the letter with a hyphen, and a combined
-setting and unsetting such as (?im-sx), which sets PCRE_CASELESS and
-PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED, is also
-permitted. If a letter appears both before and after the hyphen, the option is
-unset.
-
-The scope of these option changes depends on where in the pattern the setting
-occurs. For settings that are outside any subpattern (defined below), the
-effect is the same as if the options were set or unset at the start of
-matching. The following patterns all behave in exactly the same way:
-
- (?i)abc
- a(?i)bc
- ab(?i)c
- abc(?i)
-
-which in turn is the same as compiling the pattern abc with PCRE_CASELESS set.
-In other words, such "top level" settings apply to the whole pattern (unless
-there are other changes inside subpatterns). If there is more than one setting
-of the same option at top level, the rightmost setting is used.
-
-If an option change occurs inside a subpattern, the effect is different. This
-is a change of behaviour in Perl 5.005. An option change inside a subpattern
-affects only that part of the subpattern that follows it, so
-
- (a(?i)b)c
-
-matches abc and aBc and no other strings (assuming PCRE_CASELESS is not used).
-By this means, options can be made to have different settings in different
-parts of the pattern. Any changes made in one alternative do carry on
-into subsequent branches within the same subpattern. For example,
-
- (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 some very weird
-behaviour otherwise.
-
-The PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can be changed in the
-same way as the Perl-compatible options by using the characters U and X
-respectively. The (?X) flag setting is special in that it must always occur
-earlier in the pattern than any of the additional features it turns on, even
-when it is at top level. It is best put at the start.
-
-
-.SH SUBPATTERNS
-Subpatterns are delimited by parentheses (round brackets), which can be nested.
-Marking part of a pattern as a subpattern does two things:
-
-1. It localizes a set of alternatives. For example, the pattern
-
- cat(aract|erpillar|)
-
-matches one of the words "cat", "cataract", or "caterpillar". Without the
-parentheses, it would match "cataract", "erpillar" or the empty string.
-
-2. It sets up the subpattern as a capturing subpattern (as defined above).
-When the whole pattern matches, that portion of the subject string that matched
-the subpattern is passed back to the caller via the \fIovector\fR argument of
-\fBpcre_exec()\fR. Opening parentheses are counted from left to right (starting
-from 1) to obtain the numbers of the capturing subpatterns.
-
-For example, if the string "the red king" is matched against the pattern
-
- the ((red|white) (king|queen))
-
-the captured substrings are "red king", "red", and "king", and are numbered 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 "?:", the
-subpattern does not do any capturing, 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))
-
-the captured substrings are "white queen" and "queen", and are numbered 1 and
-2. The maximum number of captured substrings is 99, and the maximum number of
-all subpatterns, both capturing and non-capturing, is 200.
-
-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)
- (?:(?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 "Saturday".
-
-
-.SH REPETITION
-Repetition is specified by quantifiers, which can follow any of the following
-items:
-
- a single character, possibly escaped
- the . metacharacter
- a character class
- a back reference (see next section)
- a parenthesized subpattern (unless it is an assertion - see below)
-
-The general repetition quantifier specifies a minimum and maximum number of
-permitted matches, by giving the two numbers in curly brackets (braces),
-separated by a comma. The numbers must be less than 65536, and the first must
-be less than or equal to the second. For example:
-
- z{2,4}
-
-matches "zz", "zzz", or "zzzz". A closing brace on its own is not a special
-character. If the second number is omitted, but the comma is present, there is
-no upper limit; if the second number and the comma are both omitted, the
-quantifier specifies an exact number of required matches. Thus
-
- [aeiou]{3,}
-
-matches at least 3 successive vowels, but may match many more, while
-
- \\d{8}
-
-matches exactly 8 digits. An opening curly bracket that appears in a position
-where a quantifier is not allowed, or one that does not match the syntax of a
-quantifier, is taken as a literal character. For example, {,6} is not a
-quantifier, but a literal string of four characters.
-
-The quantifier {0} is permitted, causing the expression to behave as if the
-previous item and the quantifier were not present.
-
-For convenience (and historical compatibility) the three most common
-quantifiers have single-character abbreviations:
-
- * is equivalent to {0,}
- + is equivalent to {1,}
- ? is equivalent to {0,1}
-
-It is possible to construct infinite loops by following a subpattern that can
-match no characters with a quantifier that has no upper limit, for example:
-
- (a?)*
-
-Earlier versions of Perl and PCRE used to give an error at compile time for
-such patterns. However, because there are cases where this can be useful, such
-patterns are now accepted, but if any repetition of the subpattern does in fact
-match no characters, the loop is forcibly broken.
-
-By default, the quantifiers are "greedy", that is, they match as much as
-possible (up to the maximum number of permitted times), without causing the
-rest of the pattern to fail. The classic example of where this gives problems
-is in trying to match comments in C programs. These appear between the
-sequences /* and */ and within the sequence, individual * and / characters may
-appear. An attempt to match C comments by applying the pattern
-
- /\\*.*\\*/
-
-to the string
-
- /* first command */ not comment /* second comment */
-
-fails, because it matches the entire string owing to the greediness of the .*
-item.
-
-However, if a quantifier is followed by a question mark, it ceases to be
-greedy, and instead matches the minimum number of times possible, so the
-pattern
-
- /\\*.*?\\*/
-
-does the right thing with the C comments. The meaning of the various
-quantifiers is not otherwise changed, just the preferred number of matches.
-Do not confuse this use of question mark with its use as a quantifier in its
-own right. Because it has two uses, it can sometimes appear doubled, as in
-
- \\d??\\d
-
-which matches one digit by preference, but can match two if that is the only
-way the rest of the pattern matches.
-
-If the PCRE_UNGREEDY option is set (an option which is not available in Perl),
-the quantifiers are not greedy by default, but individual ones can be made
-greedy by following them with a question mark. In other words, it inverts the
-default behaviour.
-
-When a parenthesized subpattern is quantified with a minimum repeat count that
-is greater than 1 or with a limited maximum, more store is required for the
-compiled pattern, in proportion to the size of the minimum or maximum.
-
-If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equivalent
-to Perl's /s) is set, thus allowing the . to match newlines, the pattern is
-implicitly anchored, because whatever follows will be tried against every
-character position in the subject string, so there is no point in retrying the
-overall match at any position after the first. PCRE treats such a pattern as
-though it were preceded by \\A. In cases where it is known that the subject
-string contains no newlines, it is worth setting PCRE_DOTALL when the pattern
-begins with .* in order to obtain this optimization, or alternatively using ^
-to indicate anchoring explicitly.
-
-When a capturing subpattern is repeated, the value captured is the substring
-that matched the final iteration. For example, after
-
- (tweedle[dume]{3}\\s*)+
-
-has matched "tweedledum tweedledee" the value of the captured substring is
-"tweedledee". However, if there are nested capturing subpatterns, the
-corresponding captured values may have been set in previous iterations. For
-example, after
-
- /(a|(b))+/
-
-matches "aba" the value of the second captured substring is "b".
-
-
-.SH BACK REFERENCES
-Outside a character class, a backslash followed by a digit greater than 0 (and
-possibly further digits) is a back reference to a capturing subpattern earlier
-(i.e. to its left) in the pattern, provided there have been that many previous
-capturing left parentheses.
-
-However, if the decimal number following the backslash is less than 10, it is
-always taken as a back reference, and causes an error only if there are not
-that many capturing left parentheses in the entire pattern. In other words, the
-parentheses that are referenced need not be to the left of the reference for
-numbers less than 10. See the section entitled "Backslash" above for further
-details of the handling of digits following a backslash.
-
-A back reference matches whatever actually matched the capturing subpattern in
-the current subject string, rather than anything matching the subpattern
-itself. So the pattern
-
- (sens|respons)e and \\1ibility
-
-matches "sense and sensibility" and "response and responsibility", but not
-"sense and responsibility". If caseful matching is in force at the time of the
-back reference, the case of letters is relevant. For example,
-
- ((?i)rah)\\s+\\1
-
-matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original
-capturing subpattern is matched caselessly.
-
-There may be more than one back reference to the same subpattern. If a
-subpattern has not actually been used in a particular match, any back
-references to it always fail. For example, the pattern
-
- (a|(bc))\\2
-
-always fails if it starts to match "a" rather than "bc". Because there may be
-up to 99 back references, all digits following the backslash are taken
-as part of a potential back reference number. If the pattern continues with a
-digit character, some delimiter must be used to terminate the back reference.
-If the PCRE_EXTENDED option is set, this can be whitespace. Otherwise an empty
-comment can be used.
-
-A back reference that occurs inside the parentheses to which it refers fails
-when the subpattern is first used, so, for example, (a\\1) never matches.
-However, such references can be useful inside repeated subpatterns. For
-example, the pattern
-
- (a|b\\1)+
-
-matches any number of "a"s and also "aba", "ababbaa" etc. At each iteration of
-the subpattern, the back reference matches the character string corresponding
-to the previous iteration. In order for this to work, the pattern must be such
-that the first iteration does not need to match the back reference. This can be
-done using alternation, as in the example above, or by a quantifier with a
-minimum of zero.
-
-
-.SH ASSERTIONS
-An assertion is a test on the characters following or preceding the current
-matching point that does not actually consume any characters. The simple
-assertions coded as \\b, \\B, \\A, \\Z, \\z, ^ and $ are described above. More
-complicated assertions are coded as subpatterns. There are two kinds: those
-that look ahead of the current position in the subject string, and those that
-look behind it.
-
-An assertion subpattern is matched in the normal way, except that it does not
-cause the current matching position to be changed. Lookahead assertions start
-with (?= for positive assertions and (?! for negative assertions. For example,
-
- \\w+(?=;)
-
-matches a word followed by a semicolon, but does not include the semicolon in
-the match, and
-
- foo(?!bar)
-
-matches any occurrence of "foo" that is not followed by "bar". Note that the
-apparently similar pattern
-
- (?!foo)bar
-
-does not find an occurrence of "bar" that is preceded by something other than
-"foo"; it finds any occurrence of "bar" whatsoever, because the assertion
-(?!foo) is always true when the next three characters are "bar". A
-lookbehind assertion is needed to achieve this effect.
-
-Lookbehind assertions start with (?<= for positive assertions and (?<! for
-negative assertions. For example,
-
- (?<!foo)bar
-
-does find an occurrence of "bar" that is not preceded by "foo". The contents of
-a lookbehind assertion are restricted such that all the strings it matches must
-have a fixed length. However, if there are several alternatives, they do not
-all have to have the same fixed length. Thus
-
- (?<=bullock|donkey)
-
-is permitted, but
-
- (?<!dogs?|cats?)
-
-causes an error at compile time. Branches that match different length strings
-are permitted only at the top level of a lookbehind assertion. This is an
-extension compared with Perl 5.005, which requires all branches to match the
-same length of string. An assertion such as
-
- (?<=ab(c|de))
-
-is not permitted, because its single top-level branch can match two different
-lengths, but it is acceptable if rewritten to use two top-level branches:
-
- (?<=abc|abde)
-
-The implementation of lookbehind assertions is, for each alternative, to
-temporarily move the current position back by the fixed width and then try to
-match. If there are insufficient characters before the current position, the
-match is deemed to fail. Lookbehinds in conjunction with once-only subpatterns
-can be particularly useful for matching at the ends of strings; an example is
-given at the end of the section on once-only subpatterns.
-
-Several assertions (of any sort) may occur in succession. For example,
-
- (?<=\\d{3})(?<!999)foo
-
-matches "foo" preceded by three digits that are not "999". Notice that each of
-the assertions is applied independently at the same point in the subject
-string. First there is a check that the previous three characters are all
-digits, and then there is a check that the same three characters are not "999".
-This pattern does \fInot\fR match "foo" preceded by six characters, the first
-of which are digits and the last three of which are not "999". For example, it
-doesn't match "123abcfoo". A pattern to do that is
-
- (?<=\\d{3}...)(?<!999)foo
-
-This time the first assertion looks at the preceding six characters, checking
-that the first three are digits, and then the second assertion checks that the
-preceding three characters are not "999".
-
-Assertions can be nested in any combination. For example,
-
- (?<=(?<!foo)bar)baz
-
-matches an occurrence of "baz" that is preceded by "bar" which in turn is not
-preceded by "foo", while
-
- (?<=\\d{3}(?!999)...)foo
-
-is another pattern which matches "foo" preceded by three digits and any three
-characters that are not "999".
-
-Assertion subpatterns are not capturing subpatterns, and may not be repeated,
-because it makes no sense to assert the same thing several times. If any kind
-of assertion contains capturing subpatterns within it, these are counted for
-the purposes of numbering the capturing subpatterns in the whole pattern.
-However, substring capturing is carried out only for positive assertions,
-because it does not make sense for negative assertions.
-
-Assertions count towards the maximum of 200 parenthesized subpatterns.
-
-
-.SH ONCE-ONLY SUBPATTERNS
-With both maximizing and minimizing repetition, failure of what follows
-normally causes the repeated item to be re-evaluated to see if a different
-number of repeats allows the rest of the pattern to match. Sometimes it is
-useful to prevent this, either to change the nature of the match, or to cause
-it fail earlier than it otherwise might, when the author of the pattern knows
-there is no point in carrying on.
-
-Consider, for example, the pattern \\d+foo when applied to the subject line
-
- 123456bar
-
-After matching all 6 digits and then failing to match "foo", the normal
-action of the matcher is to try again with only 5 digits matching the \\d+
-item, and then with 4, and so on, before ultimately failing. Once-only
-subpatterns provide the means for specifying that once a portion of the pattern
-has matched, it is not to be re-evaluated in this way, so the matcher would
-give up immediately on failing to match "foo" the first time. The notation is
-another kind of special parenthesis, starting with (?> as in this example:
-
- (?>\\d+)bar
-
-This kind of parenthesis "locks up" the part of the pattern it contains once
-it has matched, and a failure further into the pattern is prevented from
-backtracking into it. Backtracking past it to previous items, however, works as
-normal.
-
-An alternative description is that a subpattern of this type matches the string
-of characters that an identical standalone pattern would match, if anchored at
-the current point in the subject string.
-
-Once-only subpatterns are not capturing subpatterns. Simple cases such as the
-above example can be thought of as a maximizing repeat that must swallow
-everything it can. So, while both \\d+ and \\d+? are prepared to adjust the
-number of digits they match in order to make the rest of the pattern match,
-(?>\\d+) can only match an entire sequence of digits.
-
-This construction can of course contain arbitrarily complicated subpatterns,
-and it can be nested.
-
-Once-only subpatterns can be used in conjunction with lookbehind assertions to
-specify efficient matching at the end of the subject string. Consider a simple
-pattern such as
-
- abcd$
-
-when applied to a long string which does not match. Because matching proceeds
-from left to right, PCRE will look for each "a" in the subject and then see if
-what follows matches the rest of the pattern. If the pattern is specified as
-
- ^.*abcd$
-
-the initial .* matches the entire string at first, but when this fails (because
-there is no following "a"), it backtracks to match all but the last character,
-then all but the last two characters, and so on. Once again the search for "a"
-covers the entire string, from right to left, so we are no better off. However,
-if the pattern is written as
-
- ^(?>.*)(?<=abcd)
-
-there can be no backtracking for the .* item; it can match only the entire
-string. The subsequent lookbehind assertion does a single test on the last four
-characters. If it fails, the match fails immediately. For long strings, this
-approach makes a significant difference to the processing time.
-
-When a pattern contains an unlimited repeat inside a subpattern that can itself
-be repeated an unlimited number of times, the use of a once-only subpattern is
-the only way to avoid some failing matches taking a very long time indeed.
-The pattern
-
- (\\D+|<\\d+>)*[!?]
-
-matches an unlimited number of substrings that either consist of non-digits, or
-digits enclosed in <>, followed by either ! or ?. When it matches, it runs
-quickly. However, if it is applied to
-
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-
-it takes a long time before reporting failure. This is because the string can
-be divided between the two repeats in a large number of ways, and all have to
-be tried. (The example used [!?] rather than a single character at the end,
-because both PCRE and Perl have an optimization that allows for fast failure
-when a single character is used. They remember the last single character that
-is required for a match, and fail early if it is not present in the string.)
-If the pattern is changed to
-
- ((?>\\D+)|<\\d+>)*[!?]
-
-sequences of non-digits cannot be broken, and failure happens quickly.
-
-
-.SH CONDITIONAL SUBPATTERNS
-It is possible to cause the matching process to obey a subpattern
-conditionally or to choose between two alternative subpatterns, depending on
-the result of an assertion, or whether a previous capturing subpattern matched
-or not. The two possible forms of conditional subpattern are
-
- (?(condition)yes-pattern)
- (?(condition)yes-pattern|no-pattern)
-
-If the condition is satisfied, the yes-pattern is used; otherwise the
-no-pattern (if present) is used. If there are more than two alternatives in the
-subpattern, a compile-time error occurs.
-
-There are two kinds of condition. If the text between the parentheses consists
-of a sequence of digits, the condition is satisfied if the capturing subpattern
-of that number has previously matched. The number must be greater than zero.
-Consider the following pattern, which contains non-significant white space to
-make it more readable (assume the PCRE_EXTENDED option) and to divide it into
-three parts for ease of discussion:
-
- ( \\( )? [^()]+ (?(1) \\) )
-
-The first part matches an optional opening parenthesis, and if that
-character is present, sets it as the first captured substring. The second part
-matches one or more characters that are not parentheses. The third part is a
-conditional subpattern that tests whether the first set of parentheses matched
-or not. If they did, that is, if subject started with an opening parenthesis,
-the condition is true, and so the yes-pattern is executed and a closing
-parenthesis is required. Otherwise, since no-pattern is not present, the
-subpattern matches nothing. In other words, this pattern matches a sequence of
-non-parentheses, optionally enclosed in parentheses.
-
-If the condition is not a sequence of digits, it must be an assertion. This may
-be a positive or negative lookahead or lookbehind assertion. Consider this
-pattern, again containing non-significant white space, and with the two
-alternatives on the second line:
-
- (?(?=[^a-z]*[a-z])
- \\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} )
-
-The condition is a positive lookahead assertion that matches an optional
-sequence of non-letters followed by a letter. In other words, it tests for the
-presence of at least one letter in the subject. If a letter is found, the
-subject is matched against the first alternative; otherwise it is matched
-against the second. This pattern matches strings in one of the two forms
-dd-aaa-dd or dd-dd-dd, where aaa are letters and dd are digits.
-
-
-.SH COMMENTS
-The sequence (?# marks the start of a comment which continues up to the next
-closing parenthesis. Nested parentheses are not permitted. The characters
-that make up a comment play no part in the pattern matching at all.
-
-If the PCRE_EXTENDED option is set, an unescaped # character outside a
-character class introduces a comment that continues up to the next newline
-character in the pattern.
-
-
-.SH RECURSIVE PATTERNS
-Consider the problem of matching a string in parentheses, allowing for
-unlimited nested parentheses. Without the use of recursion, the best that can
-be done is to use a pattern that matches up to some fixed depth of nesting. It
-is not possible to handle an arbitrary nesting depth. Perl 5.6 has provided an
-experimental facility that allows regular expressions to recurse (amongst other
-things). It does this by interpolating Perl code in the expression at run time,
-and the code can refer to the expression itself. A Perl pattern to solve the
-parentheses problem can be created like this:
-
- $re = qr{\\( (?: (?>[^()]+) | (?p{$re}) )* \\)}x;
-
-The (?p{...}) item interpolates Perl code at run time, and in this case refers
-recursively to the pattern in which it appears. Obviously, PCRE cannot support
-the interpolation of Perl code. Instead, the special item (?R) is provided for
-the specific case of recursion. This PCRE pattern solves the parentheses
-problem (assume the PCRE_EXTENDED option is set so that white space is
-ignored):
-
- \\( ( (?>[^()]+) | (?R) )* \\)
-
-First it matches an opening parenthesis. Then it matches any number of
-substrings which can either be a sequence of non-parentheses, or a recursive
-match of the pattern itself (i.e. a correctly parenthesized substring). Finally
-there is a closing parenthesis.
-
-This particular example pattern contains nested unlimited repeats, and so the
-use of a once-only subpattern for matching strings of non-parentheses is
-important when applying the pattern to strings that do not match. For example,
-when it is applied to
-
- (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
-
-it yields "no match" quickly. However, if a once-only subpattern is not used,
-the match runs for a very long time indeed because there are so many different
-ways the + and * repeats can carve up the subject, and all have to be tested
-before failure can be reported.
-
-The values set for any capturing subpatterns are those from the outermost level
-of the recursion at which the subpattern value is set. If the pattern above is
-matched against
-
- (ab(cd)ef)
-
-the value for the capturing parentheses is "ef", which is the last value taken
-on at the top level. If additional parentheses are added, giving
-
- \\( ( ( (?>[^()]+) | (?R) )* ) \\)
- ^ ^
- ^ ^
-the string they capture is "ab(cd)ef", the contents of the top level
-parentheses. If there are more than 15 capturing parentheses in a pattern, PCRE
-has to obtain extra memory to store data during a recursion, which it does by
-using \fBpcre_malloc\fR, freeing it via \fBpcre_free\fR afterwards. If no
-memory can be obtained, it saves data for the first 15 capturing parentheses
-only, as there is no way to give an out-of-memory error from within a
-recursion.
-
-
-.SH PERFORMANCE
-Certain items that may appear in patterns are more efficient than others. It is
-more efficient to use a character class like [aeiou] than a set of alternatives
-such as (a|e|i|o|u). In general, the simplest construction that provides the
-required behaviour is usually the most efficient. Jeffrey Friedl's book
-contains a lot of discussion about optimizing regular expressions for efficient
-performance.
-
-When a pattern begins with .* and the PCRE_DOTALL option is set, the pattern is
-implicitly anchored by PCRE, since it can match only at the start of a subject
-string. However, if PCRE_DOTALL is not set, PCRE cannot make this optimization,
-because the . metacharacter does not then match a newline, and if the subject
-string contains newlines, the pattern may match from the character immediately
-following one of them instead of from the very start. For example, the pattern
-
- (.*) second
-
-matches the subject "first\\nand second" (where \\n stands for a newline
-character) with the first captured substring being "and". In order to do this,
-PCRE has to retry the match starting after every newline in the subject.
-
-If you are using such a pattern with subject strings that do not contain
-newlines, the best performance is obtained by setting PCRE_DOTALL, or starting
-the pattern with ^.* to indicate explicit anchoring. That saves PCRE from
-having to scan along the subject looking for a newline to restart at.
-
-Beware of patterns that contain nested indefinite repeats. These can take a
-long time to run when applied to a string that does not match. Consider the
-pattern fragment
-
- (a+)*
-
-This can match "aaaa" in 33 different ways, and this number increases very
-rapidly as the string gets longer. (The * repeat can match 0, 1, 2, 3, or 4
-times, and for each of those cases other than 0, the + repeats can match
-different numbers of times.) When the remainder of the pattern is such that the
-entire match is going to fail, PCRE has in principle to try every possible
-variation, and this can take an extremely long time.
-
-An optimization catches some of the more simple cases such as
-
- (a+)*b
-
-where a literal character follows. Before embarking on the standard matching
-procedure, PCRE checks that there is a "b" later in the subject string, and if
-there is not, it fails the match immediately. However, when there is no
-following literal this optimization cannot be used. You can see the difference
-by comparing the behaviour of
-
- (a+)*\\d
-
-with the pattern above. The former gives a failure almost instantly when
-applied to a whole line of "a" characters, whereas the latter takes an
-appreciable time with strings longer than about 20 characters.
-
-
+.\" HTML <a name="utf8support"></a>
.SH UTF-8 SUPPORT
-Starting at release 3.3, PCRE has some support for character strings encoded
-in the UTF-8 format. This is incomplete, and is regarded as experimental. In
-order to use it, you must configure PCRE to include UTF-8 support in the code,
-and, in addition, you must call \fBpcre_compile()\fR with the PCRE_UTF8 option
-flag. When you do this, both the pattern and any subject strings that are
-matched against it are treated as UTF-8 strings instead of just strings of
-bytes, but only in the cases that are mentioned below.
+.rs
+.sp
+Starting at release 3.3, PCRE has had some support for character strings
+encoded in the UTF-8 format. For release 4.0 this has been greatly extended to
+cover most common requirements.
+
+In order process UTF-8 strings, you must build PCRE to include UTF-8 support in
+the code, and, in addition, you must call
+.\" HREF
+\fBpcre_compile()\fR
+.\"
+with the PCRE_UTF8 option flag. When you do this, both the pattern and any
+subject strings that are matched against it are treated as UTF-8 strings
+instead of just strings of bytes.
If you compile PCRE with UTF-8 support, but do not use it at run time, the
library will be a bit bigger, but the additional run time overhead is limited
to testing the PCRE_UTF8 flag in several places, so should not be very large.
-PCRE assumes that the strings it is given contain valid UTF-8 codes. It does
+The following comments apply when PCRE is running in UTF-8 mode:
+
+1. PCRE assumes that the strings it is given contain valid UTF-8 codes. It does
not diagnose invalid UTF-8 strings. If you pass invalid UTF-8 strings to PCRE,
the results are undefined.
-Running with PCRE_UTF8 set causes these changes in the way PCRE works:
-
-1. In a pattern, the escape sequence \\x{...}, where the contents of the braces
+2. In a pattern, the escape sequence \\x{...}, where the contents of the braces
is a string of hexadecimal digits, is interpreted as a UTF-8 character whose
-code number is the given hexadecimal number, for example: \\x{1234}. This
-inserts from one to six literal bytes into the pattern, using the UTF-8
-encoding. If a non-hexadecimal digit appears between the braces, the item is
-not recognized.
-
-2. The original hexadecimal escape sequence, \\xhh, generates a two-byte UTF-8
-character if its value is greater than 127.
-
-3. Repeat quantifiers are NOT correctly handled if they follow a multibyte
-character. For example, \\x{100}* and \\xc3+ do not work. If you want to
-repeat such characters, you must enclose them in non-capturing parentheses,
-for example (?:\\x{100}), at present.
-
-4. The dot metacharacter matches one UTF-8 character instead of a single byte.
-
-5. Unlike literal UTF-8 characters, the dot metacharacter followed by a
-repeat quantifier does operate correctly on UTF-8 characters instead of
-single bytes.
-
-4. Although the \\x{...} escape is permitted in a character class, characters
-whose values are greater than 255 cannot be included in a class.
-
-5. A class is matched against a UTF-8 character instead of just a single byte,
-but it can match only characters whose values are less than 256. Characters
-with greater values always fail to match a class.
-
-6. Repeated classes work correctly on multiple characters.
-
-7. Classes containing just a single character whose value is greater than 127
-(but less than 256), for example, [\\x80] or [^\\x{93}], do not work because
-these are optimized into single byte matches. In the first case, of course,
-the class brackets are just redundant.
-
-8. Lookbehind assertions move backwards in the subject by a fixed number of
-characters instead of a fixed number of bytes. Simple cases have been tested
-to work correctly, but there may be hidden gotchas herein.
-
-9. The character types such as \\d and \\w do not work correctly with UTF-8
-characters. They continue to test a single byte.
-
-10. Anything not explicitly mentioned here continues to work in bytes rather
-than in characters.
-
-The following UTF-8 features of Perl 5.6 are not implemented:
-
-1. The escape sequence \\C to match a single byte.
+code number is the given hexadecimal number, for example: \\x{1234}. If a
+non-hexadecimal digit appears between the braces, the item is not recognized.
+This escape sequence can be used either as a literal, or within a character
+class.
-2. The use of Unicode tables and properties and escapes \\p, \\P, and \\X.
+3. The original hexadecimal escape sequence, \\xhh, matches a two-byte UTF-8
+character if the value is greater than 127.
+4. Repeat quantifiers apply to complete UTF-8 characters, not to individual
+bytes, for example: \\x{100}{3}.
-.SH SAMPLE PROGRAM
-The code below is a simple, complete demonstration program, to get you started
-with using PCRE. This code is also supplied in the file \fIpcredemo.c\fR in the
-PCRE distribution.
+5. The dot metacharacter matches one UTF-8 character instead of a single byte.
-The program compiles the regular expression that is its first argument, and
-matches it against the subject string in its second argument. No options are
-set, and default character tables are used. If matching succeeds, the program
-outputs the portion of the subject that matched, together with the contents of
-any captured substrings.
+6. The escape sequence \\C can be used to match a single byte in UTF-8 mode,
+but its use can lead to some strange effects.
-On a Unix system that has PCRE installed in \fI/usr/local\fR, you can compile
-the demonstration program using a command like this:
+7. The character escapes \\b, \\B, \\d, \\D, \\s, \\S, \\w, and \\W correctly
+test characters of any code value, but the characters that PCRE recognizes as
+digits, spaces, or word characters remain the same set as before, all with
+values less than 256.
- gcc -o pcredemo pcredemo.c -I/usr/local/include -L/usr/local/lib -lpcre
-
-Then you can run simple tests like this:
-
- ./pcredemo 'cat|dog' 'the cat sat on the mat'
-
-Note that there is a much more comprehensive test program, called
-\fBpcretest\fR, which supports many more facilities for testing regular
-expressions. The \fBpcredemo\fR program is provided as a simple coding example.
-
-On some operating systems (e.g. Solaris) you may get an error like this when
-you try to run \fBpcredemo\fR:
-
- ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
-
-This is caused by the way shared library support works on those systems. You
-need to add
-
- -R/usr/local/lib
-
-to the compile command to get round this problem. Here's the code:
-
- #include <stdio.h>
- #include <string.h>
- #include <pcre.h>
-
- #define OVECCOUNT 30 /* should be a multiple of 3 */
-
- int main(int argc, char **argv)
- {
- pcre *re;
- const char *error;
- int erroffset;
- int ovector[OVECCOUNT];
- int rc, i;
-
- if (argc != 3)
- {
- printf("Two arguments required: a regex and a "
- "subject string\\n");
- return 1;
- }
-
- /* Compile the regular expression in the first argument */
-
- re = pcre_compile(
- argv[1], /* the pattern */
- 0, /* default options */
- &error, /* for error message */
- &erroffset, /* for error offset */
- NULL); /* use default character tables */
-
- /* Compilation failed: print the error message and exit */
-
- if (re == NULL)
- {
- printf("PCRE compilation failed at offset %d: %s\\n",
- erroffset, error);
- return 1;
- }
-
- /* Compilation succeeded: match the subject in the second
- argument */
-
- rc = pcre_exec(
- re, /* the compiled pattern */
- NULL, /* we didn't study the pattern */
- argv[2], /* the subject string */
- (int)strlen(argv[2]), /* the length of the subject */
- 0, /* start at offset 0 in the subject */
- 0, /* default options */
- ovector, /* vector for substring information */
- OVECCOUNT); /* number of elements in the vector */
-
- /* Matching failed: handle error cases */
-
- if (rc < 0)
- {
- switch(rc)
- {
- case PCRE_ERROR_NOMATCH: printf("No match\\n"); break;
- /*
- Handle other special cases if you like
- */
- default: printf("Matching error %d\\n", rc); break;
- }
- return 1;
- }
-
- /* Match succeded */
-
- printf("Match succeeded\\n");
-
- /* The output vector wasn't big enough */
-
- if (rc == 0)
- {
- rc = OVECCOUNT/3;
- printf("ovector only has room for %d captured "
- substrings\\n", rc - 1);
- }
-
- /* Show substrings stored in the output vector */
-
- for (i = 0; i < rc; i++)
- {
- char *substring_start = argv[2] + ovector[2*i];
- int substring_length = ovector[2*i+1] - ovector[2*i];
- printf("%2d: %.*s\\n", i, substring_length,
- substring_start);
- }
-
- return 0;
- }
+8. Case-insensitive matching applies only to characters whose values are less
+than 256. PCRE does not support the notion of "case" for higher-valued
+characters.
+9. PCRE does not support the use of Unicode tables and properties or the Perl
+escapes \\p, \\P, and \\X.
.SH AUTHOR
+.rs
+.sp
Philip Hazel <ph10@cam.ac.uk>
.br
University Computing Service,
.br
-New Museums Site,
-.br
Cambridge CB2 3QG, England.
.br
Phone: +44 1223 334714
-Last updated: 15 August 2001
+.in 0
+Last updated: 04 February 2003
.br
-Copyright (c) 1997-2001 University of Cambridge.
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcre.html b/doc/pcre.html
deleted file mode 100644
index 3e9eb36..0000000
--- a/doc/pcre.html
+++ /dev/null
@@ -1,2669 +0,0 @@
-<HTML>
-<HEAD>
-<TITLE>pcre specification</TITLE>
-</HEAD>
-<body bgcolor="#FFFFFF" text="#00005A">
-<H1>pcre specification</H1>
-This HTML document has been generated automatically from the original man page.
-If there is any nonsense in it, please consult the man page in case the
-conversion went wrong.
-<UL>
-<LI><A NAME="TOC1" HREF="#SEC1">NAME</A>
-<LI><A NAME="TOC2" HREF="#SEC2">SYNOPSIS</A>
-<LI><A NAME="TOC3" HREF="#SEC3">DESCRIPTION</A>
-<LI><A NAME="TOC4" HREF="#SEC4">MULTI-THREADING</A>
-<LI><A NAME="TOC5" HREF="#SEC5">COMPILING A PATTERN</A>
-<LI><A NAME="TOC6" HREF="#SEC6">STUDYING A PATTERN</A>
-<LI><A NAME="TOC7" HREF="#SEC7">LOCALE SUPPORT</A>
-<LI><A NAME="TOC8" HREF="#SEC8">INFORMATION ABOUT A PATTERN</A>
-<LI><A NAME="TOC9" HREF="#SEC9">MATCHING A PATTERN</A>
-<LI><A NAME="TOC10" HREF="#SEC10">EXTRACTING CAPTURED SUBSTRINGS</A>
-<LI><A NAME="TOC11" HREF="#SEC11">LIMITATIONS</A>
-<LI><A NAME="TOC12" HREF="#SEC12">DIFFERENCES FROM PERL</A>
-<LI><A NAME="TOC13" HREF="#SEC13">REGULAR EXPRESSION DETAILS</A>
-<LI><A NAME="TOC14" HREF="#SEC14">BACKSLASH</A>
-<LI><A NAME="TOC15" HREF="#SEC15">CIRCUMFLEX AND DOLLAR</A>
-<LI><A NAME="TOC16" HREF="#SEC16">FULL STOP (PERIOD, DOT)</A>
-<LI><A NAME="TOC17" HREF="#SEC17">SQUARE BRACKETS</A>
-<LI><A NAME="TOC18" HREF="#SEC18">POSIX CHARACTER CLASSES</A>
-<LI><A NAME="TOC19" HREF="#SEC19">VERTICAL BAR</A>
-<LI><A NAME="TOC20" HREF="#SEC20">INTERNAL OPTION SETTING</A>
-<LI><A NAME="TOC21" HREF="#SEC21">SUBPATTERNS</A>
-<LI><A NAME="TOC22" HREF="#SEC22">REPETITION</A>
-<LI><A NAME="TOC23" HREF="#SEC23">BACK REFERENCES</A>
-<LI><A NAME="TOC24" HREF="#SEC24">ASSERTIONS</A>
-<LI><A NAME="TOC25" HREF="#SEC25">ONCE-ONLY SUBPATTERNS</A>
-<LI><A NAME="TOC26" HREF="#SEC26">CONDITIONAL SUBPATTERNS</A>
-<LI><A NAME="TOC27" HREF="#SEC27">COMMENTS</A>
-<LI><A NAME="TOC28" HREF="#SEC28">RECURSIVE PATTERNS</A>
-<LI><A NAME="TOC29" HREF="#SEC29">PERFORMANCE</A>
-<LI><A NAME="TOC30" HREF="#SEC30">UTF-8 SUPPORT</A>
-<LI><A NAME="TOC31" HREF="#SEC31">SAMPLE PROGRAM</A>
-<LI><A NAME="TOC32" HREF="#SEC32">AUTHOR</A>
-</UL>
-<LI><A NAME="SEC1" HREF="#TOC1">NAME</A>
-<P>
-pcre - Perl-compatible regular expressions.
-</P>
-<LI><A NAME="SEC2" HREF="#TOC1">SYNOPSIS</A>
-<P>
-<B>#include &#60;pcre.h&#62;</B>
-</P>
-<P>
-<B>pcre *pcre_compile(const char *<I>pattern</I>, int <I>options</I>,</B>
-<B>const char **<I>errptr</I>, int *<I>erroffset</I>,</B>
-<B>const unsigned char *<I>tableptr</I>);</B>
-</P>
-<P>
-<B>pcre_extra *pcre_study(const pcre *<I>code</I>, int <I>options</I>,</B>
-<B>const char **<I>errptr</I>);</B>
-</P>
-<P>
-<B>int pcre_exec(const pcre *<I>code</I>, const pcre_extra *<I>extra</I>,</B>
-<B>const char *<I>subject</I>, int <I>length</I>, int <I>startoffset</I>,</B>
-<B>int <I>options</I>, int *<I>ovector</I>, int <I>ovecsize</I>);</B>
-</P>
-<P>
-<B>int pcre_copy_substring(const char *<I>subject</I>, int *<I>ovector</I>,</B>
-<B>int <I>stringcount</I>, int <I>stringnumber</I>, char *<I>buffer</I>,</B>
-<B>int <I>buffersize</I>);</B>
-</P>
-<P>
-<B>int pcre_get_substring(const char *<I>subject</I>, int *<I>ovector</I>,</B>
-<B>int <I>stringcount</I>, int <I>stringnumber</I>,</B>
-<B>const char **<I>stringptr</I>);</B>
-</P>
-<P>
-<B>int pcre_get_substring_list(const char *<I>subject</I>,</B>
-<B>int *<I>ovector</I>, int <I>stringcount</I>, const char ***<I>listptr</I>);</B>
-</P>
-<P>
-<B>void pcre_free_substring(const char *<I>stringptr</I>);</B>
-</P>
-<P>
-<B>void pcre_free_substring_list(const char **<I>stringptr</I>);</B>
-</P>
-<P>
-<B>const unsigned char *pcre_maketables(void);</B>
-</P>
-<P>
-<B>int pcre_fullinfo(const pcre *<I>code</I>, const pcre_extra *<I>extra</I>,</B>
-<B>int <I>what</I>, void *<I>where</I>);</B>
-</P>
-<P>
-<B>int pcre_info(const pcre *<I>code</I>, int *<I>optptr</I>, int</B>
-<B>*<I>firstcharptr</I>);</B>
-</P>
-<P>
-<B>char *pcre_version(void);</B>
-</P>
-<P>
-<B>void *(*pcre_malloc)(size_t);</B>
-</P>
-<P>
-<B>void (*pcre_free)(void *);</B>
-</P>
-<LI><A NAME="SEC3" HREF="#TOC1">DESCRIPTION</A>
-<P>
-The PCRE library is a set of functions that implement regular expression
-pattern matching using the same syntax and semantics as Perl 5, with just a few
-differences (see below). The current implementation corresponds to Perl 5.005,
-with some additional features from later versions. This includes some
-experimental, incomplete support for UTF-8 encoded strings. Details of exactly
-what is and what is not supported are given below.
-</P>
-<P>
-PCRE has its own native API, which is described in this document. There is also
-a set of wrapper functions that correspond to the POSIX regular expression API.
-These are described in the <B>pcreposix</B> documentation.
-</P>
-<P>
-The native API function prototypes are defined in the header file <B>pcre.h</B>,
-and on Unix systems the library itself is called <B>libpcre.a</B>, so can be
-accessed by adding <B>-lpcre</B> to the command for linking an application which
-calls it. The header file defines the macros PCRE_MAJOR and PCRE_MINOR to
-contain the major and minor release numbers for the library. Applications can
-use these to include support for different releases.
-</P>
-<P>
-The functions <B>pcre_compile()</B>, <B>pcre_study()</B>, and <B>pcre_exec()</B>
-are used for compiling and matching regular expressions. A sample program that
-demonstrates the simplest way of using them is given in the file
-<I>pcredemo.c</I>. The last section of this man page describes how to run it.
-</P>
-<P>
-The functions <B>pcre_copy_substring()</B>, <B>pcre_get_substring()</B>, and
-<B>pcre_get_substring_list()</B> are convenience functions for extracting
-captured substrings from a matched subject string; <B>pcre_free_substring()</B>
-and <B>pcre_free_substring_list()</B> are also provided, to free the memory used
-for extracted strings.
-</P>
-<P>
-The function <B>pcre_maketables()</B> is used (optionally) to build a set of
-character tables in the current locale for passing to <B>pcre_compile()</B>.
-</P>
-<P>
-The function <B>pcre_fullinfo()</B> is used to find out information about a
-compiled pattern; <B>pcre_info()</B> is an obsolete version which returns only
-some of the available information, but is retained for backwards compatibility.
-The function <B>pcre_version()</B> returns a pointer to a string containing the
-version of PCRE and its date of release.
-</P>
-<P>
-The global variables <B>pcre_malloc</B> and <B>pcre_free</B> initially contain
-the entry points of the standard <B>malloc()</B> and <B>free()</B> functions
-respectively. PCRE calls the memory management functions via these variables,
-so a calling program can replace them if it wishes to intercept the calls. This
-should be done before calling any PCRE functions.
-</P>
-<LI><A NAME="SEC4" HREF="#TOC1">MULTI-THREADING</A>
-<P>
-The PCRE functions can be used in multi-threading applications, with the
-proviso that the memory management functions pointed to by <B>pcre_malloc</B>
-and <B>pcre_free</B> are shared by all threads.
-</P>
-<P>
-The compiled form of a regular expression is not altered during matching, so
-the same compiled pattern can safely be used by several threads at once.
-</P>
-<LI><A NAME="SEC5" HREF="#TOC1">COMPILING A PATTERN</A>
-<P>
-The function <B>pcre_compile()</B> is called to compile a pattern into an
-internal form. The pattern is a C string terminated by a binary zero, and
-is passed in the argument <I>pattern</I>. A pointer to a single block of memory
-that is obtained via <B>pcre_malloc</B> is returned. This contains the compiled
-code and related data. The <B>pcre</B> type is defined for the returned block;
-this is a typedef for a structure whose contents are not externally defined. It
-is up to the caller to free the memory when it is no longer required.
-</P>
-<P>
-Although the compiled code of a PCRE regex is relocatable, that is, it does not
-depend on memory location, the complete <B>pcre</B> data block is not
-fully relocatable, because it contains a copy of the <I>tableptr</I> argument,
-which is an address (see below).
-</P>
-<P>
-The size of a compiled pattern is roughly proportional to the length of the
-pattern string, except that each character class (other than those containing
-just a single character, negated or not) requires 33 bytes, and repeat
-quantifiers with a minimum greater than one or a bounded maximum cause the
-relevant portions of the compiled pattern to be replicated.
-</P>
-<P>
-The <I>options</I> argument contains independent bits that affect the
-compilation. It should be zero if no options are required. Some of the options,
-in particular, those that are compatible with Perl, can also be set and unset
-from within the pattern (see the detailed description of regular expressions
-below). For these options, the contents of the <I>options</I> argument specifies
-their initial settings at the start of compilation and execution. The
-PCRE_ANCHORED option can be set at the time of matching as well as at compile
-time.
-</P>
-<P>
-If <I>errptr</I> is NULL, <B>pcre_compile()</B> returns NULL immediately.
-Otherwise, if compilation of a pattern fails, <B>pcre_compile()</B> returns
-NULL, and sets the variable pointed to by <I>errptr</I> to point to a textual
-error message. The offset from the start of the pattern to the character where
-the error was discovered is placed in the variable pointed to by
-<I>erroffset</I>, which must not be NULL. If it is, an immediate error is given.
-</P>
-<P>
-If the final argument, <I>tableptr</I>, is NULL, PCRE uses a default set of
-character tables which are built when it is compiled, using the default C
-locale. Otherwise, <I>tableptr</I> must be the result of a call to
-<B>pcre_maketables()</B>. See the section on locale support below.
-</P>
-<P>
-This code fragment shows a typical straightforward call to <B>pcre_compile()</B>:
-</P>
-<P>
-<PRE>
- pcre *re;
- const char *error;
- int erroffset;
- re = pcre_compile(
- "^A.*Z", /* the pattern */
- 0, /* default options */
- &error, /* for error message */
- &erroffset, /* for error offset */
- NULL); /* use default character tables */
-</PRE>
-</P>
-<P>
-The following option bits are defined in the header file:
-</P>
-<P>
-<PRE>
- PCRE_ANCHORED
-</PRE>
-</P>
-<P>
-If this bit is set, the pattern is forced to be "anchored", that is, it is
-constrained to match only at the start of the string which 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.
-</P>
-<P>
-<PRE>
- PCRE_CASELESS
-</PRE>
-</P>
-<P>
-If this bit is set, letters in the pattern match both upper and lower case
-letters. It is equivalent to Perl's /i option.
-</P>
-<P>
-<PRE>
- PCRE_DOLLAR_ENDONLY
-</PRE>
-</P>
-<P>
-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 the final character if it is a newline (but not before any
-other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is
-set. There is no equivalent to this option in Perl.
-</P>
-<P>
-<PRE>
- PCRE_DOTALL
-</PRE>
-</P>
-<P>
-If this bit is set, a dot metacharater in the pattern matches all characters,
-including newlines. Without it, newlines are excluded. This option is
-equivalent to Perl's /s option. A negative class such as [^a] always matches a
-newline character, independent of the setting of this option.
-</P>
-<P>
-<PRE>
- PCRE_EXTENDED
-</PRE>
-</P>
-<P>
-If this bit is set, whitespace data characters in the pattern are totally
-ignored except when escaped or inside a character class, and characters between
-an unescaped # outside a character class and the next newline character,
-inclusive, are also ignored. This is equivalent to Perl's /x option, and makes
-it possible to include comments inside complicated patterns. Note, however,
-that this applies only to data characters. Whitespace characters may never
-appear within special character sequences in a pattern, for example within the
-sequence (?( which introduces a conditional subpattern.
-</P>
-<P>
-<PRE>
- PCRE_EXTRA
-</PRE>
-</P>
-<P>
-This option was invented in order to turn on additional functionality of PCRE
-that is incompatible with Perl, but it is currently of very little use. When
-set, any backslash in a pattern that is followed by a letter that has no
-special meaning causes an error, thus reserving these combinations for future
-expansion. By default, as in Perl, a backslash followed by a letter with no
-special meaning is treated as a literal. There are at present no other features
-controlled by this option. It can also be set by a (?X) option setting within a
-pattern.
-</P>
-<P>
-<PRE>
- PCRE_MULTILINE
-</PRE>
-</P>
-<P>
-By default, PCRE treats the subject string as consisting of a single "line" of
-characters (even if it actually contains several newlines). The "start of line"
-metacharacter (^) matches only at the start of the string, while the "end of
-line" metacharacter ($) matches only at the end of the string, or before a
-terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as
-Perl.
-</P>
-<P>
-When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs
-match immediately following or immediately before any newline in the subject
-string, respectively, as well as at the very start and end. This is equivalent
-to Perl's /m option. If there are no "\n" characters in a subject string, or
-no occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no
-effect.
-</P>
-<P>
-<PRE>
- PCRE_UNGREEDY
-</PRE>
-</P>
-<P>
-This option inverts the "greediness" of the quantifiers so that they are not
-greedy by default, but become greedy if followed by "?". It is not compatible
-with Perl. It can also be set by a (?U) option setting within the pattern.
-</P>
-<P>
-<PRE>
- PCRE_UTF8
-</PRE>
-</P>
-<P>
-This option causes PCRE to regard both the pattern and the subject as strings
-of UTF-8 characters instead of just byte strings. However, it is available only
-if PCRE has been built to include UTF-8 support. If not, the use of this option
-provokes an error. Support for UTF-8 is new, experimental, and incomplete.
-Details of exactly what it entails are given below.
-</P>
-<LI><A NAME="SEC6" HREF="#TOC1">STUDYING A PATTERN</A>
-<P>
-When a pattern is going to be used several times, it is worth spending more
-time analyzing it in order to speed up the time taken for matching. The
-function <B>pcre_study()</B> takes a pointer to a compiled pattern as its first
-argument, and returns a pointer to a <B>pcre_extra</B> block (another typedef
-for a structure with hidden contents) containing additional information about
-the pattern; this can be passed to <B>pcre_exec()</B>. If no additional
-information is available, NULL is returned.
-</P>
-<P>
-The second argument contains option bits. At present, no options are defined
-for <B>pcre_study()</B>, and this argument should always be zero.
-</P>
-<P>
-The third argument for <B>pcre_study()</B> is a pointer to an error message. If
-studying succeeds (even if no data is returned), the variable it points to is
-set to NULL. Otherwise it points to a textual error message.
-</P>
-<P>
-This is a typical call to <B>pcre_study</B>():
-</P>
-<P>
-<PRE>
- pcre_extra *pe;
- pe = pcre_study(
- re, /* result of pcre_compile() */
- 0, /* no options exist */
- &error); /* set to NULL or points to a message */
-</PRE>
-</P>
-<P>
-At present, studying a pattern is useful only for non-anchored patterns that do
-not have a single fixed starting character. A bitmap of possible starting
-characters is created.
-</P>
-<LI><A NAME="SEC7" HREF="#TOC1">LOCALE SUPPORT</A>
-<P>
-PCRE handles caseless matching, and determines whether characters are letters,
-digits, or whatever, by reference to a set of tables. The library contains a
-default set of tables which is created in the default C locale when PCRE is
-compiled. This is used when the final argument of <B>pcre_compile()</B> is NULL,
-and is sufficient for many applications.
-</P>
-<P>
-An alternative set of tables can, however, be supplied. Such tables are built
-by calling the <B>pcre_maketables()</B> function, which has no arguments, in the
-relevant locale. The result can then be passed to <B>pcre_compile()</B> as often
-as necessary. For example, to build and use tables that are appropriate for the
-French locale (where accented characters with codes greater than 128 are
-treated as letters), the following code could be used:
-</P>
-<P>
-<PRE>
- setlocale(LC_CTYPE, "fr");
- tables = pcre_maketables();
- re = pcre_compile(..., tables);
-</PRE>
-</P>
-<P>
-The tables are built in memory that is obtained via <B>pcre_malloc</B>. The
-pointer that is passed to <B>pcre_compile</B> is saved with the compiled
-pattern, and the same tables are used via this pointer by <B>pcre_study()</B>
-and <B>pcre_exec()</B>. Thus for any single pattern, compilation, studying and
-matching all happen in the same locale, but different patterns can be compiled
-in different locales. It is the caller's responsibility to ensure that the
-memory containing the tables remains available for as long as it is needed.
-</P>
-<LI><A NAME="SEC8" HREF="#TOC1">INFORMATION ABOUT A PATTERN</A>
-<P>
-The <B>pcre_fullinfo()</B> function returns information about a compiled
-pattern. It replaces the obsolete <B>pcre_info()</B> function, which is
-nevertheless retained for backwards compability (and is documented below).
-</P>
-<P>
-The first argument for <B>pcre_fullinfo()</B> is a pointer to the compiled
-pattern. The second argument is the result of <B>pcre_study()</B>, or NULL if
-the pattern was not studied. The third argument specifies which piece of
-information is required, while the fourth argument is a pointer to a variable
-to receive the data. The yield of the function is zero for success, or one of
-the following negative numbers:
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NULL the argument <I>code</I> was NULL
- the argument <I>where</I> was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
- PCRE_ERROR_BADOPTION the value of <I>what</I> was invalid
-</PRE>
-</P>
-<P>
-Here is a typical call of <B>pcre_fullinfo()</B>, to obtain the length of the
-compiled pattern:
-</P>
-<P>
-<PRE>
- int rc;
- unsigned long int length;
- rc = pcre_fullinfo(
- re, /* result of pcre_compile() */
- pe, /* result of pcre_study(), or NULL */
- PCRE_INFO_SIZE, /* what is required */
- &length); /* where to put the data */
-</PRE>
-</P>
-<P>
-The possible values for the third argument are defined in <B>pcre.h</B>, and are
-as follows:
-</P>
-<P>
-<PRE>
- PCRE_INFO_OPTIONS
-</PRE>
-</P>
-<P>
-Return a copy of the options with which the pattern was compiled. The fourth
-argument should point to an <B>unsigned long int</B> variable. These option bits
-are those specified in the call to <B>pcre_compile()</B>, modified by any
-top-level option settings within the pattern itself, and with the PCRE_ANCHORED
-bit forcibly set if the form of the pattern implies that it can match only at
-the start of a subject string.
-</P>
-<P>
-<PRE>
- PCRE_INFO_SIZE
-</PRE>
-</P>
-<P>
-Return the size of the compiled pattern, that is, the value that was passed as
-the argument to <B>pcre_malloc()</B> when PCRE was getting memory in which to
-place the compiled data. The fourth argument should point to a <B>size_t</B>
-variable.
-</P>
-<P>
-<PRE>
- PCRE_INFO_CAPTURECOUNT
-</PRE>
-</P>
-<P>
-Return the number of capturing subpatterns in the pattern. The fourth argument
-should point to an \fbint\fR variable.
-</P>
-<P>
-<PRE>
- PCRE_INFO_BACKREFMAX
-</PRE>
-</P>
-<P>
-Return the number of the highest back reference in the pattern. The fourth
-argument should point to an <B>int</B> variable. Zero is returned if there are
-no back references.
-</P>
-<P>
-<PRE>
- PCRE_INFO_FIRSTCHAR
-</PRE>
-</P>
-<P>
-Return information about the first character of any matched string, for a
-non-anchored pattern. If there is a fixed first character, e.g. from a pattern
-such as (cat|cow|coyote), it is returned in the integer pointed to by
-<I>where</I>. Otherwise, if either
-</P>
-<P>
-(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
-starts with "^", or
-</P>
-<P>
-(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set
-(if it were set, the pattern would be anchored),
-</P>
-<P>
--1 is returned, indicating that the pattern matches only at the start of a
-subject string or after any "\n" within the string. Otherwise -2 is returned.
-For anchored patterns, -2 is returned.
-</P>
-<P>
-<PRE>
- PCRE_INFO_FIRSTTABLE
-</PRE>
-</P>
-<P>
-If the pattern was studied, and this resulted in the construction of a 256-bit
-table indicating a fixed set of characters for the first character in any
-matching string, a pointer to the table is returned. Otherwise NULL is
-returned. The fourth argument should point to an <B>unsigned char *</B>
-variable.
-</P>
-<P>
-<PRE>
- PCRE_INFO_LASTLITERAL
-</PRE>
-</P>
-<P>
-For a non-anchored pattern, return the value of the rightmost literal character
-which must exist in any matched string, other than at its start. The fourth
-argument should point to an <B>int</B> variable. If there is no such character,
-or if the pattern is anchored, -1 is returned. For example, for the pattern
-/a\d+z\d+/ the returned value is 'z'.
-</P>
-<P>
-The <B>pcre_info()</B> function is now obsolete because its interface is too
-restrictive to return all the available data about a compiled pattern. New
-programs should use <B>pcre_fullinfo()</B> instead. The yield of
-<B>pcre_info()</B> is the number of capturing subpatterns, or one of the
-following negative numbers:
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NULL the argument <I>code</I> was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
-</PRE>
-</P>
-<P>
-If the <I>optptr</I> argument is not NULL, a copy of the options with which the
-pattern was compiled is placed in the integer it points to (see
-PCRE_INFO_OPTIONS above).
-</P>
-<P>
-If the pattern is not anchored and the <I>firstcharptr</I> argument is not NULL,
-it is used to pass back information about the first character of any matched
-string (see PCRE_INFO_FIRSTCHAR above).
-</P>
-<LI><A NAME="SEC9" HREF="#TOC1">MATCHING A PATTERN</A>
-<P>
-The function <B>pcre_exec()</B> is called to match a subject string against a
-pre-compiled pattern, which is passed in the <I>code</I> argument. If the
-pattern has been studied, the result of the study should be passed in the
-<I>extra</I> argument. Otherwise this must be NULL.
-</P>
-<P>
-Here is an example of a simple call to <B>pcre_exec()</B>:
-</P>
-<P>
-<PRE>
- int rc;
- int ovector[30];
- rc = pcre_exec(
- re, /* result of pcre_compile() */
- NULL, /* we didn't study the pattern */
- "some string", /* the subject string */
- 11, /* the length of the subject string */
- 0, /* start at offset 0 in the subject */
- 0, /* default options */
- ovector, /* vector for substring information */
- 30); /* number of elements in the vector */
-</PRE>
-</P>
-<P>
-The PCRE_ANCHORED option can be passed in the <I>options</I> argument, whose
-unused bits must be zero. However, if a pattern was compiled with
-PCRE_ANCHORED, or turned out to be anchored by virtue of its contents, it
-cannot be made unachored at matching time.
-</P>
-<P>
-There are also three further options that can be set only at matching time:
-</P>
-<P>
-<PRE>
- PCRE_NOTBOL
-</PRE>
-</P>
-<P>
-The first character of the string is not the beginning of a line, so the
-circumflex metacharacter should not match before it. Setting this without
-PCRE_MULTILINE (at compile time) causes circumflex never to match.
-</P>
-<P>
-<PRE>
- PCRE_NOTEOL
-</PRE>
-</P>
-<P>
-The end of the string is not the end of a line, so the dollar metacharacter
-should not match it nor (except in multiline mode) a newline immediately before
-it. Setting this without PCRE_MULTILINE (at compile time) causes dollar never
-to match.
-</P>
-<P>
-<PRE>
- PCRE_NOTEMPTY
-</PRE>
-</P>
-<P>
-An empty string is not considered to be a valid match if this option is set. If
-there are alternatives in the pattern, they are tried. If all the alternatives
-match the empty string, the entire match fails. For example, if the pattern
-</P>
-<P>
-<PRE>
- a?b?
-</PRE>
-</P>
-<P>
-is applied to a string not beginning with "a" or "b", it matches the empty
-string at the start of the subject. With PCRE_NOTEMPTY set, this match is not
-valid, so PCRE searches further into the string for occurrences of "a" or "b".
-</P>
-<P>
-Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a special case
-of a pattern match of the empty string within its <B>split()</B> function, and
-when using the /g modifier. It is possible to emulate Perl's behaviour after
-matching a null string by first trying the match again at the same offset with
-PCRE_NOTEMPTY set, and then if that fails by advancing the starting offset (see
-below) and trying an ordinary match again.
-</P>
-<P>
-The subject string is passed as a pointer in <I>subject</I>, a length in
-<I>length</I>, and a starting offset in <I>startoffset</I>. Unlike the pattern
-string, the subject may contain binary zero characters. When the starting
-offset is zero, the search for a match starts at the beginning of the subject,
-and this is by far the most common case.
-</P>
-<P>
-A non-zero starting offset is useful when searching for another match in the
-same subject by calling <B>pcre_exec()</B> again after a previous success.
-Setting <I>startoffset</I> differs from just passing over a shortened string and
-setting PCRE_NOTBOL in the case of a pattern that begins with any kind of
-lookbehind. For example, consider the pattern
-</P>
-<P>
-<PRE>
- \Biss\B
-</PRE>
-</P>
-<P>
-which finds occurrences of "iss" in the middle of words. (\B matches only if
-the current position in the subject is not a word boundary.) When applied to
-the string "Mississipi" the first call to <B>pcre_exec()</B> finds the first
-occurrence. If <B>pcre_exec()</B> is called again with just the remainder of the
-subject, namely "issipi", it does not match, because \B is always false at the
-start of the subject, which is deemed to be a word boundary. However, if
-<B>pcre_exec()</B> is passed the entire string again, but with <I>startoffset</I>
-set to 4, it finds the second occurrence of "iss" because it is able to look
-behind the starting point to discover that it is preceded by a letter.
-</P>
-<P>
-If a non-zero starting offset is passed when the pattern is anchored, one
-attempt to match at the given offset is tried. This can only succeed if the
-pattern does not require the match to be at the start of the subject.
-</P>
-<P>
-In general, a pattern matches a certain portion of the subject, and in
-addition, further substrings from the subject may be picked out by parts of the
-pattern. Following the usage in Jeffrey Friedl's book, this is called
-"capturing" in what follows, and the phrase "capturing subpattern" is used for
-a fragment of a pattern that picks out a substring. PCRE supports several other
-kinds of parenthesized subpattern that do not cause substrings to be captured.
-</P>
-<P>
-Captured substrings are returned to the caller via a vector of integer offsets
-whose address is passed in <I>ovector</I>. The number of elements in the vector
-is passed in <I>ovecsize</I>. The first two-thirds of the vector is used to pass
-back captured substrings, each substring using a pair of integers. The
-remaining third of the vector is used as workspace by <B>pcre_exec()</B> while
-matching capturing subpatterns, and is not available for passing back
-information. The length passed in <I>ovecsize</I> should always be a multiple of
-three. If it is not, it is rounded down.
-</P>
-<P>
-When a match has been successful, information about captured substrings is
-returned in pairs of integers, starting at the beginning of <I>ovector</I>, and
-continuing up to two-thirds of its length at the most. The first element of a
-pair is set to the offset of the first character in a substring, and the second
-is set to the offset of the first character after the end of a substring. The
-first pair, <I>ovector[0]</I> and <I>ovector[1]</I>, identify the portion of the
-subject string matched by the entire pattern. The next pair is used for the
-first capturing subpattern, and so on. The value returned by <B>pcre_exec()</B>
-is the number of pairs that have been set. If there are no capturing
-subpatterns, the return value from a successful match is 1, indicating that
-just the first pair of offsets has been set.
-</P>
-<P>
-Some convenience functions are provided for extracting the captured substrings
-as separate strings. These are described in the following section.
-</P>
-<P>
-It is possible for an capturing subpattern number <I>n+1</I> to match some
-part of the subject when subpattern <I>n</I> has not been used at all. For
-example, if the string "abc" is matched against the pattern (a|(z))(bc)
-subpatterns 1 and 3 are matched, but 2 is not. When this happens, both offset
-values corresponding to the unused subpattern are set to -1.
-</P>
-<P>
-If a capturing subpattern is matched repeatedly, it is the last portion of the
-string that it matched that gets returned.
-</P>
-<P>
-If the vector is too small to hold all the captured substrings, it is used as
-far as possible (up to two-thirds of its length), and the function returns a
-value of zero. In particular, if the substring offsets are not of interest,
-<B>pcre_exec()</B> may be called with <I>ovector</I> passed as NULL and
-<I>ovecsize</I> as zero. However, if the pattern contains back references and
-the <I>ovector</I> isn't big enough to remember the related substrings, PCRE has
-to get additional memory for use during matching. Thus it is usually advisable
-to supply an <I>ovector</I>.
-</P>
-<P>
-Note that <B>pcre_info()</B> can be used to find out how many capturing
-subpatterns there are in a compiled pattern. The smallest size for
-<I>ovector</I> that will allow for <I>n</I> captured substrings in addition to
-the offsets of the substring matched by the whole pattern is (<I>n</I>+1)*3.
-</P>
-<P>
-If <B>pcre_exec()</B> fails, it returns a negative number. The following are
-defined in the header file:
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NOMATCH (-1)
-</PRE>
-</P>
-<P>
-The subject string did not match the pattern.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NULL (-2)
-</PRE>
-</P>
-<P>
-Either <I>code</I> or <I>subject</I> was passed as NULL, or <I>ovector</I> was
-NULL and <I>ovecsize</I> was not zero.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_BADOPTION (-3)
-</PRE>
-</P>
-<P>
-An unrecognized bit was set in the <I>options</I> argument.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_BADMAGIC (-4)
-</PRE>
-</P>
-<P>
-PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch
-the case when it is passed a junk pointer. This is the error it gives when the
-magic number isn't present.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_UNKNOWN_NODE (-5)
-</PRE>
-</P>
-<P>
-While running the pattern match, an unknown item was encountered in the
-compiled pattern. This error could be caused by a bug in PCRE or by overwriting
-of the compiled pattern.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NOMEMORY (-6)
-</PRE>
-</P>
-<P>
-If a pattern contains back references, but the <I>ovector</I> that is passed to
-<B>pcre_exec()</B> is not big enough to remember the referenced substrings, PCRE
-gets a block of memory at the start of matching to use for this purpose. If the
-call via <B>pcre_malloc()</B> fails, this error is given. The memory is freed at
-the end of matching.
-</P>
-<LI><A NAME="SEC10" HREF="#TOC1">EXTRACTING CAPTURED SUBSTRINGS</A>
-<P>
-Captured substrings can be accessed directly by using the offsets returned by
-<B>pcre_exec()</B> in <I>ovector</I>. For convenience, the functions
-<B>pcre_copy_substring()</B>, <B>pcre_get_substring()</B>, and
-<B>pcre_get_substring_list()</B> are provided for 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 does not, of course, function as a C string.
-</P>
-<P>
-The first three arguments are the same for all three functions: <I>subject</I>
-is the subject string which has just been successfully matched, <I>ovector</I>
-is a pointer to the vector of integer offsets that was passed to
-<B>pcre_exec()</B>, and <I>stringcount</I> is the number of substrings that
-were captured by the match, including the substring that matched the entire
-regular expression. This is the value returned by <B>pcre_exec</B> if it
-is greater than zero. If <B>pcre_exec()</B> returned zero, indicating that it
-ran out of space in <I>ovector</I>, the value passed as <I>stringcount</I> should
-be the size of the vector divided by three.
-</P>
-<P>
-The functions <B>pcre_copy_substring()</B> and <B>pcre_get_substring()</B>
-extract a single substring, whose number is given as <I>stringnumber</I>. A
-value of zero extracts the substring that matched the entire pattern, while
-higher values extract the captured substrings. For <B>pcre_copy_substring()</B>,
-the string is placed in <I>buffer</I>, whose length is given by
-<I>buffersize</I>, while for <B>pcre_get_substring()</B> a new block of memory is
-obtained via <B>pcre_malloc</B>, and its address is returned via
-<I>stringptr</I>. The yield of the function is the length of the string, not
-including the terminating zero, or one of
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NOMEMORY (-6)
-</PRE>
-</P>
-<P>
-The buffer was too small for <B>pcre_copy_substring()</B>, or the attempt to get
-memory failed for <B>pcre_get_substring()</B>.
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NOSUBSTRING (-7)
-</PRE>
-</P>
-<P>
-There is no substring whose number is <I>stringnumber</I>.
-</P>
-<P>
-The <B>pcre_get_substring_list()</B> function extracts all available substrings
-and builds a list of pointers to them. All this is done in a single block of
-memory which is obtained via <B>pcre_malloc</B>. The address of the memory block
-is returned via <I>listptr</I>, which is also the start of the list of string
-pointers. The end of the list is marked by a NULL pointer. The yield of the
-function is zero if all went well, or
-</P>
-<P>
-<PRE>
- PCRE_ERROR_NOMEMORY (-6)
-</PRE>
-</P>
-<P>
-if the attempt to get the memory block failed.
-</P>
-<P>
-When any of these functions encounter a substring that is unset, which can
-happen when capturing subpattern number <I>n+1</I> matches some part of the
-subject, but subpattern <I>n</I> has not been used at all, they return an empty
-string. This can be distinguished from a genuine zero-length substring by
-inspecting the appropriate offset in <I>ovector</I>, which is negative for unset
-substrings.
-</P>
-<P>
-The two convenience functions <B>pcre_free_substring()</B> and
-<B>pcre_free_substring_list()</B> can be used to free the memory returned by
-a previous call of <B>pcre_get_substring()</B> or
-<B>pcre_get_substring_list()</B>, respectively. They do nothing more than call
-the function pointed to by <B>pcre_free</B>, which of course could be called
-directly from a C program. However, PCRE is used in some situations where it is
-linked via a special interface to another programming language which cannot use
-<B>pcre_free</B> directly; it is for these cases that the functions are
-provided.
-</P>
-<LI><A NAME="SEC11" HREF="#TOC1">LIMITATIONS</A>
-<P>
-There are some size limitations in PCRE but it is hoped that they will never in
-practice be relevant.
-The maximum length of a compiled pattern is 65539 (sic) bytes.
-All values in repeating quantifiers must be less than 65536.
-There maximum number of capturing subpatterns is 65535.
-There is no limit to the number of non-capturing subpatterns, but the maximum
-depth of nesting of all kinds of parenthesized subpattern, including capturing
-subpatterns, assertions, and other types of subpattern, is 200.
-</P>
-<P>
-The maximum length of a subject string is the largest positive number that an
-integer variable can hold. However, PCRE uses recursion to handle subpatterns
-and indefinite repetition. This means that the available stack space may limit
-the size of a subject string that can be processed by certain patterns.
-</P>
-<LI><A NAME="SEC12" HREF="#TOC1">DIFFERENCES FROM PERL</A>
-<P>
-The differences described here are with respect to Perl 5.005.
-</P>
-<P>
-1. By default, a whitespace character is any character that the C library
-function <B>isspace()</B> recognizes, though it is possible to compile PCRE with
-alternative character type tables. Normally <B>isspace()</B> matches space,
-formfeed, newline, carriage return, horizontal tab, and vertical tab. Perl 5
-no longer includes vertical tab in its set of whitespace characters. The \v
-escape that was in the Perl documentation for a long time was never in fact
-recognized. However, the character itself was treated as whitespace at least
-up to 5.002. In 5.004 and 5.005 it does not match \s.
-</P>
-<P>
-2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl permits
-them, but they do not mean what you might think. For example, (?!a){3} does
-not assert that the next three characters are not "a". It just asserts that the
-next character is not "a" three times.
-</P>
-<P>
-3. Capturing subpatterns that occur inside negative lookahead assertions are
-counted, but their entries in the offsets vector are never set. Perl sets its
-numerical variables from any such patterns that are matched before the
-assertion fails to match something (thereby succeeding), but only if the
-negative lookahead assertion contains just one branch.
-</P>
-<P>
-4. Though binary zero characters are supported in the subject string, they are
-not allowed in a pattern string because it is passed as a normal C string,
-terminated by zero. The escape sequence "\0" can be used in the pattern to
-represent a binary zero.
-</P>
-<P>
-5. The following Perl escape sequences are not supported: \l, \u, \L, \U,
-\E, \Q. In fact these are implemented by Perl's general string-handling and
-are not part of its pattern matching engine.
-</P>
-<P>
-6. The Perl \G assertion is not supported as it is not relevant to single
-pattern matches.
-</P>
-<P>
-7. Fairly obviously, PCRE does not support the (?{code}) and (?p{code})
-constructions. However, there is some experimental support for recursive
-patterns using the non-Perl item (?R).
-</P>
-<P>
-8. There are at the time of writing some oddities in Perl 5.005_02 concerned
-with the settings of captured strings when part of a pattern is repeated. For
-example, matching "aba" against the pattern /^(a(b)?)+$/ sets $2 to the value
-"b", but matching "aabbaa" against /^(aa(bb)?)+$/ leaves $2 unset. However, if
-the pattern is changed to /^(aa(b(b))?)+$/ then $2 (and $3) are set.
-</P>
-<P>
-In Perl 5.004 $2 is set in both cases, and that is also true of PCRE. If in the
-future Perl changes to a consistent state that is different, PCRE may change to
-follow.
-</P>
-<P>
-9. Another as yet unresolved discrepancy is that in Perl 5.005_02 the pattern
-/^(a)?(?(1)a|b)+$/ matches the string "a", whereas in PCRE it does not.
-However, in both Perl and PCRE /^(a)?a/ matched against "a" leaves $1 unset.
-</P>
-<P>
-10. PCRE provides some extensions to the Perl regular expression facilities:
-</P>
-<P>
-(a) Although lookbehind assertions must match fixed length strings, each
-alternative branch of a lookbehind assertion can match a different length of
-string. Perl 5.005 requires them all to have the same length.
-</P>
-<P>
-(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $ meta-
-character matches only at the very end of the string.
-</P>
-<P>
-(c) If PCRE_EXTRA is set, a backslash followed by a letter with no special
-meaning is faulted.
-</P>
-<P>
-(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is
-inverted, that is, by default they are not greedy, but if followed by a
-question mark they are.
-</P>
-<P>
-(e) PCRE_ANCHORED can be used to force a pattern to be tried only at the start
-of the subject.
-</P>
-<P>
-(f) The PCRE_NOTBOL, PCRE_NOTEOL, and PCRE_NOTEMPTY options for
-<B>pcre_exec()</B> have no Perl equivalents.
-</P>
-<P>
-(g) The (?R) construct allows for recursive pattern matching (Perl 5.6 can do
-this using the (?p{code}) construct, which PCRE cannot of course support.)
-</P>
-<LI><A NAME="SEC13" HREF="#TOC1">REGULAR EXPRESSION DETAILS</A>
-<P>
-The syntax and semantics of the regular expressions supported by PCRE are
-described below. Regular expressions are also described in the Perl
-documentation and in a number of other books, some of which have copious
-examples. Jeffrey Friedl's "Mastering Regular Expressions", published by
-O'Reilly (ISBN 1-56592-257), covers them in great detail.
-</P>
-<P>
-The description here is intended as reference documentation. The basic
-operation of PCRE is on strings of bytes. However, there is the beginnings of
-some support for UTF-8 character strings. To use this support you must
-configure PCRE to include it, and then call <B>pcre_compile()</B> with the
-PCRE_UTF8 option. How this affects the pattern matching is described in the
-final section of this document.
-</P>
-<P>
-A regular expression is a pattern that is matched against a subject string from
-left to right. Most characters stand for themselves in a pattern, and match the
-corresponding characters in the subject. As a trivial example, the pattern
-</P>
-<P>
-<PRE>
- The quick brown fox
-</PRE>
-</P>
-<P>
-matches a portion of a subject string that is identical to itself. The power of
-regular expressions comes from the ability to include alternatives and
-repetitions in the pattern. These are encoded in the pattern by the use of
-<I>meta-characters</I>, which do not stand for themselves but instead are
-interpreted in some special way.
-</P>
-<P>
-There are two different sets of meta-characters: those that are recognized
-anywhere in the pattern except within square brackets, and those that are
-recognized in square brackets. Outside square brackets, the meta-characters are
-as follows:
-</P>
-<P>
-<PRE>
- \ general escape character with several uses
- ^ assert start of subject (or line, in multiline mode)
- $ assert end of subject (or line, in multiline mode)
- . match any character except newline (by default)
- [ start character class definition
- | start of alternative branch
- ( start subpattern
- ) end subpattern
- ? extends the meaning of (
- also 0 or 1 quantifier
- also quantifier minimizer
- * 0 or more quantifier
- + 1 or more quantifier
- { start min/max quantifier
-</PRE>
-</P>
-<P>
-Part of a pattern that is in square brackets is called a "character class". In
-a character class the only meta-characters are:
-</P>
-<P>
-<PRE>
- \ general escape character
- ^ negate the class, but only if the first character
- - indicates character range
- ] terminates the character class
-</PRE>
-</P>
-<P>
-The following sections describe the use of each of the meta-characters.
-</P>
-<LI><A NAME="SEC14" HREF="#TOC1">BACKSLASH</A>
-<P>
-The backslash character has several uses. Firstly, if it is followed by a
-non-alphameric character, it takes away any special meaning that character may
-have. This use of backslash as an escape character applies both inside and
-outside character classes.
-</P>
-<P>
-For example, if you want to match a "*" character, you write "\*" in the
-pattern. This applies whether or not the following character would otherwise be
-interpreted as a meta-character, so it is always safe to precede a
-non-alphameric with "\" to specify that it stands for itself. In particular,
-if you want to match a backslash, you write "\\".
-</P>
-<P>
-If a pattern is compiled with the PCRE_EXTENDED option, whitespace in the
-pattern (other than in a character class) and characters between a "#" outside
-a character class and the next newline character are ignored. An escaping
-backslash can be used to include a whitespace or "#" character as part of the
-pattern.
-</P>
-<P>
-A second use of backslash provides a way of encoding non-printing characters
-in patterns in a visible manner. There is no restriction on the appearance of
-non-printing characters, apart from the binary zero that terminates a pattern,
-but when a pattern is being prepared by text editing, it is usually easier to
-use one of the following escape sequences than the binary character it
-represents:
-</P>
-<P>
-<PRE>
- \a alarm, that is, the BEL character (hex 07)
- \cx "control-x", where x is any character
- \e escape (hex 1B)
- \f formfeed (hex 0C)
- \n newline (hex 0A)
- \r carriage return (hex 0D)
- \t tab (hex 09)
- \xhh character with hex code hh
- \ddd character with octal code ddd, or backreference
-</PRE>
-</P>
-<P>
-The precise effect of "\cx" is as follows: if "x" is a lower case letter, it
-is converted to upper case. Then bit 6 of the character (hex 40) is inverted.
-Thus "\cz" becomes hex 1A, but "\c{" becomes hex 3B, while "\c;" becomes hex
-7B.
-</P>
-<P>
-After "\x", up to two hexadecimal digits are read (letters can be in upper or
-lower case).
-</P>
-<P>
-After "\0" up to two further octal digits are read. In both cases, if there
-are fewer than two digits, just those that are present are used. Thus the
-sequence "\0\x\07" specifies two binary zeros followed by a BEL character.
-Make sure you supply two digits after the initial zero if the character that
-follows is itself an octal digit.
-</P>
-<P>
-The handling of a backslash followed by a digit other than 0 is complicated.
-Outside a character class, PCRE reads it and any following digits as a decimal
-number. If the number is less than 10, or if there have been at least that many
-previous capturing left parentheses in the expression, the entire sequence is
-taken as a <I>back reference</I>. A description of how this works is given
-later, following the discussion of parenthesized subpatterns.
-</P>
-<P>
-Inside a character class, or if the decimal number is greater than 9 and there
-have not been that many capturing subpatterns, PCRE re-reads up to three octal
-digits following the backslash, and generates a single byte from the least
-significant 8 bits of the value. Any subsequent digits stand for themselves.
-For example:
-</P>
-<P>
-<PRE>
- \040 is another way of writing a space
- \40 is the same, provided there are fewer than 40
- previous capturing subpatterns
- \7 is always a back reference
- \11 might be a back reference, or another way of
- writing a tab
- \011 is always a tab
- \0113 is a tab followed by the character "3"
- \113 is the character with octal code 113 (since there
- can be no more than 99 back references)
- \377 is a byte consisting entirely of 1 bits
- \81 is either a back reference, or a binary zero
- followed by the two characters "8" and "1"
-</PRE>
-</P>
-<P>
-Note that octal values of 100 or greater must not be introduced by a leading
-zero, because no more than three octal digits are ever read.
-</P>
-<P>
-All the sequences that define a single byte value can be used both inside and
-outside character classes. In addition, inside a character class, the sequence
-"\b" is interpreted as the backspace character (hex 08). Outside a character
-class it has a different meaning (see below).
-</P>
-<P>
-The third use of backslash is for specifying generic character types:
-</P>
-<P>
-<PRE>
- \d any decimal digit
- \D any character that is not a decimal digit
- \s any whitespace character
- \S any character that is not a whitespace character
- \w any "word" character
- \W any "non-word" character
-</PRE>
-</P>
-<P>
-Each pair of escape sequences partitions the complete set of characters into
-two disjoint sets. Any given character matches one, and only one, of each pair.
-</P>
-<P>
-A "word" character is any letter or digit or the underscore character, that is,
-any character which can be part of a Perl "word". The definition of letters and
-digits is controlled by PCRE's character tables, and may vary if locale-
-specific matching is taking place (see "Locale support" above). For example, in
-the "fr" (French) locale, some character codes greater than 128 are used for
-accented letters, and these are matched by \w.
-</P>
-<P>
-These character type sequences can appear both inside and outside character
-classes. They each match one character of the appropriate type. If the current
-matching point is at the end of the subject string, all of them fail, since
-there is no character to match.
-</P>
-<P>
-The fourth use of backslash is for certain simple assertions. An assertion
-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
-</P>
-<P>
-<PRE>
- \b word boundary
- \B not a word boundary
- \A start of subject (independent of multiline mode)
- \Z end of subject or newline at end (independent of multiline mode)
- \z end of subject (independent of multiline mode)
-</PRE>
-</P>
-<P>
-These assertions may not appear in character classes (but note that "\b" has a
-different meaning, namely the backspace character, inside a character class).
-</P>
-<P>
-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.
-</P>
-<P>
-The \A, \Z, and \z assertions differ from the traditional circumflex and
-dollar (described below) in that they only ever match at the very start and end
-of the subject string, whatever options are set. They are not affected by the
-PCRE_NOTBOL or PCRE_NOTEOL options. If the <I>startoffset</I> argument of
-<B>pcre_exec()</B> is non-zero, \A can never match. The difference between \Z
-and \z is that \Z matches before a newline that is the last character of the
-string as well as at the end of the string, whereas \z matches only at the
-end.
-</P>
-<LI><A NAME="SEC15" HREF="#TOC1">CIRCUMFLEX AND DOLLAR</A>
-<P>
-Outside a character class, in the default matching mode, the circumflex
-character is an assertion which is true only if the current matching point is
-at the start of the subject string. If the <I>startoffset</I> argument of
-<B>pcre_exec()</B> is non-zero, circumflex can never match. Inside a character
-class, circumflex has an entirely different meaning (see below).
-</P>
-<P>
-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 subject, it is said to be an
-"anchored" pattern. (There are also other constructs that can cause a pattern
-to be anchored.)
-</P>
-<P>
-A dollar character is an assertion which is true only if the current matching
-point is at the end of the subject string, or immediately before a newline
-character that is the last character in the string (by default). Dollar need
-not be the last character of the pattern if a number 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 character class.
-</P>
-<P>
-The meaning of dollar can be changed so that it matches only at the very end of
-the string, by setting the PCRE_DOLLAR_ENDONLY option at compile or matching
-time. This does not affect the \Z assertion.
-</P>
-<P>
-The meanings of the circumflex and dollar characters are changed if the
-PCRE_MULTILINE option is set. When this is the case, they match immediately
-after and immediately before an internal "\n" character, respectively, in
-addition to matching at the start and end of the subject string. For example,
-the pattern /^abc$/ matches the subject string "def\nabc" 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 <I>startoffset</I> argument of
-<B>pcre_exec()</B> is non-zero. The PCRE_DOLLAR_ENDONLY option is ignored if
-PCRE_MULTILINE is set.
-</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 PCRE_MULTILINE is set or not.
-</P>
-<LI><A NAME="SEC16" HREF="#TOC1">FULL STOP (PERIOD, DOT)</A>
-<P>
-Outside a character class, a dot in the pattern matches any one character in
-the subject, including a non-printing character, but not (by default) newline.
-If the PCRE_DOTALL option is set, dots match newlines as well. The handling of
-dot is entirely independent of the handling of circumflex and dollar, the only
-relationship being that they both involve newline characters. Dot has no
-special meaning in a character class.
-</P>
-<LI><A NAME="SEC17" HREF="#TOC1">SQUARE BRACKETS</A>
-<P>
-An opening square bracket introduces a character class, terminated by a closing
-square bracket. A closing square bracket on its own is not special. 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.
-</P>
-<P>
-A character class matches a single character in the subject; the character must
-be in the set of characters defined by the class, unless the first character in
-the class 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 it is not the first character, or escape it with a
-backslash.
-</P>
-<P>
-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 which
-are in the class by enumerating those that are not. It is not an assertion: it
-still consumes a character from the subject string, and fails if the current
-pointer is at the end of the string.
-</P>
-<P>
-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.
-</P>
-<P>
-The newline character is never treated in any special way in character classes,
-whatever the setting of the PCRE_DOTALL or PCRE_MULTILINE options is. A class
-such as [^a] will always match a newline.
-</P>
-<P>
-The minus (hyphen) character can be used to specify a range of characters 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.
-</P>
-<P>
-It is not possible to have the literal character "]" as the end character 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 interpreted as a single class containing a
-range followed by two separate characters. The octal or hexadecimal
-representation of "]" can also be used to end a range.
-</P>
-<P>
-Ranges operate in ASCII collating sequence. They can also be used for
-characters specified numerically, for example [\000-\037]. 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 if character tables for the "fr" locale are in use,
-[\xc8-\xcb] matches accented E characters in both cases.
-</P>
-<P>
-The character types \d, \D, \s, \S, \w, and \W may also appear in a
-character class, and add the characters that they match to the class. For
-example, [\dABCDEF] matches any hexadecimal digit. 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.
-</P>
-<P>
-All non-alphameric characters other than \, -, ^ (at the start) and the
-terminating ] are non-special in character classes, but it does no harm if they
-are escaped.
-</P>
-<LI><A NAME="SEC18" HREF="#TOC1">POSIX CHARACTER CLASSES</A>
-<P>
-Perl 5.6 (not yet released at the time of writing) is going to support the
-POSIX notation for character classes, which uses names enclosed by [: and :]
-within the enclosing square brackets. PCRE supports this notation. For example,
-</P>
-<P>
-<PRE>
- [01[:alpha:]%]
-</PRE>
-</P>
-<P>
-matches "0", "1", any alphabetic character, or "%". The supported class names
-are
-</P>
-<P>
-<PRE>
- alnum letters and digits
- alpha letters
- ascii character codes 0 - 127
- cntrl control characters
- digit decimal digits (same as \d)
- graph printing characters, excluding space
- lower lower case letters
- print printing characters, including space
- punct printing characters, excluding letters and digits
- space white space (same as \s)
- upper upper case letters
- word "word" characters (same as \w)
- xdigit hexadecimal digits
-</PRE>
-</P>
-<P>
-The names "ascii" and "word" are Perl extensions. Another Perl extension is
-negation, which is indicated by a ^ character after the colon. For example,
-</P>
-<P>
-<PRE>
- [12[:^digit:]]
-</PRE>
-</P>
-<P>
-matches "1", "2", or any non-digit. PCRE (and Perl) also recognize the POSIX
-syntax [.ch.] and [=ch=] where "ch" is a "collating element", but these are not
-supported, and an error is given if they are encountered.
-</P>
-<LI><A NAME="SEC19" HREF="#TOC1">VERTICAL BAR</A>
-<P>
-Vertical bar characters are used to separate alternative patterns. For example,
-the pattern
-</P>
-<P>
-<PRE>
- gilbert|sullivan
-</PRE>
-</P>
-<P>
-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 rest of the main
-pattern as well as the alternative in the subpattern.
-</P>
-<LI><A NAME="SEC20" HREF="#TOC1">INTERNAL OPTION SETTING</A>
-<P>
-The settings of PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and PCRE_EXTENDED
-can be changed from within the pattern by a sequence of Perl option letters
-enclosed between "(?" and ")". The option letters are
-</P>
-<P>
-<PRE>
- i for PCRE_CASELESS
- m for PCRE_MULTILINE
- s for PCRE_DOTALL
- x for PCRE_EXTENDED
-</PRE>
-</P>
-<P>
-For example, (?im) sets caseless, multiline matching. It is also possible to
-unset these options by preceding the letter with a hyphen, and a combined
-setting and unsetting such as (?im-sx), which sets PCRE_CASELESS and
-PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED, is also
-permitted. If a letter appears both before and after the hyphen, the option is
-unset.
-</P>
-<P>
-The scope of these option changes depends on where in the pattern the setting
-occurs. For settings that are outside any subpattern (defined below), the
-effect is the same as if the options were set or unset at the start of
-matching. The following patterns all behave in exactly the same way:
-</P>
-<P>
-<PRE>
- (?i)abc
- a(?i)bc
- ab(?i)c
- abc(?i)
-</PRE>
-</P>
-<P>
-which in turn is the same as compiling the pattern abc with PCRE_CASELESS set.
-In other words, such "top level" settings apply to the whole pattern (unless
-there are other changes inside subpatterns). If there is more than one setting
-of the same option at top level, the rightmost setting is used.
-</P>
-<P>
-If an option change occurs inside a subpattern, the effect is different. This
-is a change of behaviour in Perl 5.005. An option change inside a subpattern
-affects only that part of the subpattern that follows it, so
-</P>
-<P>
-<PRE>
- (a(?i)b)c
-</PRE>
-</P>
-<P>
-matches abc and aBc and no other strings (assuming PCRE_CASELESS is not used).
-By this means, options can be made to have different settings in different
-parts of the pattern. Any changes made in one alternative do carry on
-into subsequent branches within the same subpattern. For example,
-</P>
-<P>
-<PRE>
- (a(?i)b|c)
-</PRE>
-</P>
-<P>
-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.
-</P>
-<P>
-The PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can be changed in the
-same way as the Perl-compatible options by using the characters U and X
-respectively. The (?X) flag setting is special in that it must always occur
-earlier in the pattern than any of the additional features it turns on, even
-when it is at top level. It is best put at the start.
-</P>
-<LI><A NAME="SEC21" HREF="#TOC1">SUBPATTERNS</A>
-<P>
-Subpatterns are delimited by parentheses (round brackets), which can be nested.
-Marking part of a pattern as a subpattern does two things:
-</P>
-<P>
-1. It localizes a set of alternatives. For example, the pattern
-</P>
-<P>
-<PRE>
- cat(aract|erpillar|)
-</PRE>
-</P>
-<P>
-matches one of the words "cat", "cataract", or "caterpillar". Without the
-parentheses, it would match "cataract", "erpillar" or the empty string.
-</P>
-<P>
-2. It sets up the subpattern as a capturing subpattern (as defined above).
-When the whole pattern matches, that portion of the subject string that matched
-the subpattern is passed back to the caller via the <I>ovector</I> argument of
-<B>pcre_exec()</B>. Opening parentheses are counted from left to right (starting
-from 1) to obtain the numbers of the capturing subpatterns.
-</P>
-<P>
-For example, if the string "the red king" is matched against the pattern
-</P>
-<P>
-<PRE>
- the ((red|white) (king|queen))
-</PRE>
-</P>
-<P>
-the captured substrings are "red king", "red", and "king", and are numbered 1,
-2, and 3, respectively.
-</P>
-<P>
-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 "?:", the
-subpattern does not do any capturing, 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
-</P>
-<P>
-<PRE>
- the ((?:red|white) (king|queen))
-</PRE>
-</P>
-<P>
-the captured substrings are "white queen" and "queen", and are numbered 1 and
-2. The maximum number of captured substrings is 99, and the maximum number of
-all subpatterns, both capturing and non-capturing, is 200.
-</P>
-<P>
-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
-</P>
-<P>
-<PRE>
- (?i:saturday|sunday)
- (?:(?i)saturday|sunday)
-</PRE>
-</P>
-<P>
-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 "Saturday".
-</P>
-<LI><A NAME="SEC22" HREF="#TOC1">REPETITION</A>
-<P>
-Repetition is specified by quantifiers, which can follow any of the following
-items:
-</P>
-<P>
-<PRE>
- a single character, possibly escaped
- the . metacharacter
- a character class
- a back reference (see next section)
- a parenthesized subpattern (unless it is an assertion - see below)
-</PRE>
-</P>
-<P>
-The general repetition quantifier specifies a minimum and maximum number of
-permitted matches, by giving the two numbers in curly brackets (braces),
-separated by a comma. The numbers must be less than 65536, and the first must
-be less than or equal to the second. For example:
-</P>
-<P>
-<PRE>
- z{2,4}
-</PRE>
-</P>
-<P>
-matches "zz", "zzz", or "zzzz". A closing brace on its own is not a special
-character. If the second number is omitted, but the comma is present, there is
-no upper limit; if the second number and the comma are both omitted, the
-quantifier specifies an exact number of required matches. Thus
-</P>
-<P>
-<PRE>
- [aeiou]{3,}
-</PRE>
-</P>
-<P>
-matches at least 3 successive vowels, but may match many more, while
-</P>
-<P>
-<PRE>
- \d{8}
-</PRE>
-</P>
-<P>
-matches exactly 8 digits. An opening curly bracket that appears in a position
-where a quantifier is not allowed, or one that does not match the syntax of a
-quantifier, is taken as a literal character. For example, {,6} is not a
-quantifier, but a literal string of four characters.
-</P>
-<P>
-The quantifier {0} is permitted, causing the expression to behave as if the
-previous item and the quantifier were not present.
-</P>
-<P>
-For convenience (and historical compatibility) the three most common
-quantifiers have single-character abbreviations:
-</P>
-<P>
-<PRE>
- * is equivalent to {0,}
- + is equivalent to {1,}
- ? is equivalent to {0,1}
-</PRE>
-</P>
-<P>
-It is possible to construct infinite loops by following a subpattern that can
-match no characters with a quantifier that has no upper limit, for example:
-</P>
-<P>
-<PRE>
- (a?)*
-</PRE>
-</P>
-<P>
-Earlier versions of Perl and PCRE used to give an error at compile time for
-such patterns. However, because there are cases where this can be useful, such
-patterns are now accepted, but if any repetition of the subpattern does in fact
-match no characters, the loop is forcibly broken.
-</P>
-<P>
-By default, the quantifiers are "greedy", that is, they match as much as
-possible (up to the maximum number of permitted times), without causing the
-rest of the pattern to fail. The classic example of where this gives problems
-is in trying to match comments in C programs. These appear between the
-sequences /* and */ and within the sequence, individual * and / characters may
-appear. An attempt to match C comments by applying the pattern
-</P>
-<P>
-<PRE>
- /\*.*\*/
-</PRE>
-</P>
-<P>
-to the string
-</P>
-<P>
-<PRE>
- /* first command */ not comment /* second comment */
-</PRE>
-</P>
-<P>
-fails, because it matches the entire string owing to the greediness of the .*
-item.
-</P>
-<P>
-However, if a quantifier is followed by a question mark, it ceases to be
-greedy, and instead matches the minimum number of times possible, so the
-pattern
-</P>
-<P>
-<PRE>
- /\*.*?\*/
-</PRE>
-</P>
-<P>
-does the right thing with the C comments. The meaning of the various
-quantifiers is not otherwise changed, just the preferred number of matches.
-Do not confuse this use of question mark with its use as a quantifier in its
-own right. Because it has two uses, it can sometimes appear doubled, as in
-</P>
-<P>
-<PRE>
- \d??\d
-</PRE>
-</P>
-<P>
-which matches one digit by preference, but can match two if that is the only
-way the rest of the pattern matches.
-</P>
-<P>
-If the PCRE_UNGREEDY option is set (an option which is not available in Perl),
-the quantifiers are not greedy by default, but individual ones can be made
-greedy by following them with a question mark. In other words, it inverts the
-default behaviour.
-</P>
-<P>
-When a parenthesized subpattern is quantified with a minimum repeat count that
-is greater than 1 or with a limited maximum, more store is required for the
-compiled pattern, in proportion to the size of the minimum or maximum.
-</P>
-<P>
-If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equivalent
-to Perl's /s) is set, thus allowing the . to match newlines, the pattern is
-implicitly anchored, because whatever follows will be tried against every
-character position in the subject string, so there is no point in retrying the
-overall match at any position after the first. PCRE treats such a pattern as
-though it were preceded by \A. In cases where it is known that the subject
-string contains no newlines, it is worth setting PCRE_DOTALL when the pattern
-begins with .* in order to obtain this optimization, or alternatively using ^
-to indicate anchoring explicitly.
-</P>
-<P>
-When a capturing subpattern is repeated, the value captured is the substring
-that matched the final iteration. For example, after
-</P>
-<P>
-<PRE>
- (tweedle[dume]{3}\s*)+
-</PRE>
-</P>
-<P>
-has matched "tweedledum tweedledee" the value of the captured substring is
-"tweedledee". However, if there are nested capturing subpatterns, the
-corresponding captured values may have been set in previous iterations. For
-example, after
-</P>
-<P>
-<PRE>
- /(a|(b))+/
-</PRE>
-</P>
-<P>
-matches "aba" the value of the second captured substring is "b".
-</P>
-<LI><A NAME="SEC23" HREF="#TOC1">BACK REFERENCES</A>
-<P>
-Outside a character class, a backslash followed by a digit greater than 0 (and
-possibly further digits) is a back reference to a capturing subpattern earlier
-(i.e. to its left) in the pattern, provided there have been that many previous
-capturing left parentheses.
-</P>
-<P>
-However, if the decimal number following the backslash is less than 10, it is
-always taken as a back reference, and causes an error only if there are not
-that many capturing left parentheses in the entire pattern. In other words, the
-parentheses that are referenced need not be to the left of the reference for
-numbers less than 10. See the section entitled "Backslash" above for further
-details of the handling of digits following a backslash.
-</P>
-<P>
-A back reference matches whatever actually matched the capturing subpattern in
-the current subject string, rather than anything matching the subpattern
-itself. So the pattern
-</P>
-<P>
-<PRE>
- (sens|respons)e and \1ibility
-</PRE>
-</P>
-<P>
-matches "sense and sensibility" and "response and responsibility", but not
-"sense and responsibility". If caseful matching is in force at the time of the
-back reference, the case of letters is relevant. For example,
-</P>
-<P>
-<PRE>
- ((?i)rah)\s+\1
-</PRE>
-</P>
-<P>
-matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original
-capturing subpattern is matched caselessly.
-</P>
-<P>
-There may be more than one back reference to the same subpattern. If a
-subpattern has not actually been used in a particular match, any back
-references to it always fail. For example, the pattern
-</P>
-<P>
-<PRE>
- (a|(bc))\2
-</PRE>
-</P>
-<P>
-always fails if it starts to match "a" rather than "bc". Because there may be
-up to 99 back references, all digits following the backslash are taken
-as part of a potential back reference number. If the pattern continues with a
-digit character, some delimiter must be used to terminate the back reference.
-If the PCRE_EXTENDED option is set, this can be whitespace. Otherwise an empty
-comment can be used.
-</P>
-<P>
-A back reference that occurs inside the parentheses to which it refers fails
-when the subpattern is first used, so, for example, (a\1) never matches.
-However, such references can be useful inside repeated subpatterns. For
-example, the pattern
-</P>
-<P>
-<PRE>
- (a|b\1)+
-</PRE>
-</P>
-<P>
-matches any number of "a"s and also "aba", "ababbaa" etc. At each iteration of
-the subpattern, the back reference matches the character string corresponding
-to the previous iteration. In order for this to work, the pattern must be such
-that the first iteration does not need to match the back reference. This can be
-done using alternation, as in the example above, or by a quantifier with a
-minimum of zero.
-</P>
-<LI><A NAME="SEC24" HREF="#TOC1">ASSERTIONS</A>
-<P>
-An assertion is a test on the characters following or preceding the current
-matching point that does not actually consume any characters. The simple
-assertions coded as \b, \B, \A, \Z, \z, ^ and $ are described above. More
-complicated assertions are coded as subpatterns. There are two kinds: those
-that look ahead of the current position in the subject string, and those that
-look behind it.
-</P>
-<P>
-An assertion subpattern is matched in the normal way, except that it does not
-cause the current matching position to be changed. Lookahead assertions start
-with (?= for positive assertions and (?! for negative assertions. For example,
-</P>
-<P>
-<PRE>
- \w+(?=;)
-</PRE>
-</P>
-<P>
-matches a word followed by a semicolon, but does not include the semicolon in
-the match, and
-</P>
-<P>
-<PRE>
- foo(?!bar)
-</PRE>
-</P>
-<P>
-matches any occurrence of "foo" that is not followed by "bar". Note that the
-apparently similar pattern
-</P>
-<P>
-<PRE>
- (?!foo)bar
-</PRE>
-</P>
-<P>
-does not find an occurrence of "bar" that is preceded by something other than
-"foo"; it finds any occurrence of "bar" whatsoever, because the assertion
-(?!foo) is always true when the next three characters are "bar". A
-lookbehind assertion is needed to achieve this effect.
-</P>
-<P>
-Lookbehind assertions start with (?&#60;= for positive assertions and (?&#60;! for
-negative assertions. For example,
-</P>
-<P>
-<PRE>
- (?&#60;!foo)bar
-</PRE>
-</P>
-<P>
-does find an occurrence of "bar" that is not preceded by "foo". The contents of
-a lookbehind assertion are restricted such that all the strings it matches must
-have a fixed length. However, if there are several alternatives, they do not
-all have to have the same fixed length. Thus
-</P>
-<P>
-<PRE>
- (?&#60;=bullock|donkey)
-</PRE>
-</P>
-<P>
-is permitted, but
-</P>
-<P>
-<PRE>
- (?&#60;!dogs?|cats?)
-</PRE>
-</P>
-<P>
-causes an error at compile time. Branches that match different length strings
-are permitted only at the top level of a lookbehind assertion. This is an
-extension compared with Perl 5.005, which requires all branches to match the
-same length of string. An assertion such as
-</P>
-<P>
-<PRE>
- (?&#60;=ab(c|de))
-</PRE>
-</P>
-<P>
-is not permitted, because its single top-level branch can match two different
-lengths, but it is acceptable if rewritten to use two top-level branches:
-</P>
-<P>
-<PRE>
- (?&#60;=abc|abde)
-</PRE>
-</P>
-<P>
-The implementation of lookbehind assertions is, for each alternative, to
-temporarily move the current position back by the fixed width and then try to
-match. If there are insufficient characters before the current position, the
-match is deemed to fail. Lookbehinds in conjunction with once-only subpatterns
-can be particularly useful for matching at the ends of strings; an example is
-given at the end of the section on once-only subpatterns.
-</P>
-<P>
-Several assertions (of any sort) may occur in succession. For example,
-</P>
-<P>
-<PRE>
- (?&#60;=\d{3})(?&#60;!999)foo
-</PRE>
-</P>
-<P>
-matches "foo" preceded by three digits that are not "999". Notice that each of
-the assertions is applied independently at the same point in the subject
-string. First there is a check that the previous three characters are all
-digits, and then there is a check that the same three characters are not "999".
-This pattern does <I>not</I> match "foo" preceded by six characters, the first
-of which are digits and the last three of which are not "999". For example, it
-doesn't match "123abcfoo". A pattern to do that is
-</P>
-<P>
-<PRE>
- (?&#60;=\d{3}...)(?&#60;!999)foo
-</PRE>
-</P>
-<P>
-This time the first assertion looks at the preceding six characters, checking
-that the first three are digits, and then the second assertion checks that the
-preceding three characters are not "999".
-</P>
-<P>
-Assertions can be nested in any combination. For example,
-</P>
-<P>
-<PRE>
- (?&#60;=(?&#60;!foo)bar)baz
-</PRE>
-</P>
-<P>
-matches an occurrence of "baz" that is preceded by "bar" which in turn is not
-preceded by "foo", while
-</P>
-<P>
-<PRE>
- (?&#60;=\d{3}(?!999)...)foo
-</PRE>
-</P>
-<P>
-is another pattern which matches "foo" preceded by three digits and any three
-characters that are not "999".
-</P>
-<P>
-Assertion subpatterns are not capturing subpatterns, and may not be repeated,
-because it makes no sense to assert the same thing several times. If any kind
-of assertion contains capturing subpatterns within it, these are counted for
-the purposes of numbering the capturing subpatterns in the whole pattern.
-However, substring capturing is carried out only for positive assertions,
-because it does not make sense for negative assertions.
-</P>
-<P>
-Assertions count towards the maximum of 200 parenthesized subpatterns.
-</P>
-<LI><A NAME="SEC25" HREF="#TOC1">ONCE-ONLY SUBPATTERNS</A>
-<P>
-With both maximizing and minimizing repetition, failure of what follows
-normally causes the repeated item to be re-evaluated to see if a different
-number of repeats allows the rest of the pattern to match. Sometimes it is
-useful to prevent this, either to change the nature of the match, or to cause
-it fail earlier than it otherwise might, when the author of the pattern knows
-there is no point in carrying on.
-</P>
-<P>
-Consider, for example, the pattern \d+foo when applied to the subject line
-</P>
-<P>
-<PRE>
- 123456bar
-</PRE>
-</P>
-<P>
-After matching all 6 digits and then failing to match "foo", the normal
-action of the matcher is to try again with only 5 digits matching the \d+
-item, and then with 4, and so on, before ultimately failing. Once-only
-subpatterns provide the means for specifying that once a portion of the pattern
-has matched, it is not to be re-evaluated in this way, so the matcher would
-give up immediately on failing to match "foo" the first time. The notation is
-another kind of special parenthesis, starting with (?&#62; as in this example:
-</P>
-<P>
-<PRE>
- (?&#62;\d+)bar
-</PRE>
-</P>
-<P>
-This kind of parenthesis "locks up" the part of the pattern it contains once
-it has matched, and a failure further into the pattern is prevented from
-backtracking into it. Backtracking past it to previous items, however, works as
-normal.
-</P>
-<P>
-An alternative description is that a subpattern of this type matches the string
-of characters that an identical standalone pattern would match, if anchored at
-the current point in the subject string.
-</P>
-<P>
-Once-only subpatterns are not capturing subpatterns. Simple cases such as the
-above example can be thought of as a maximizing repeat that must swallow
-everything it can. So, while both \d+ and \d+? are prepared to adjust the
-number of digits they match in order to make the rest of the pattern match,
-(?&#62;\d+) can only match an entire sequence of digits.
-</P>
-<P>
-This construction can of course contain arbitrarily complicated subpatterns,
-and it can be nested.
-</P>
-<P>
-Once-only subpatterns can be used in conjunction with lookbehind assertions to
-specify efficient matching at the end of the subject string. Consider a simple
-pattern such as
-</P>
-<P>
-<PRE>
- abcd$
-</PRE>
-</P>
-<P>
-when applied to a long string which does not match. Because matching proceeds
-from left to right, PCRE will look for each "a" in the subject and then see if
-what follows matches the rest of the pattern. If the pattern is specified as
-</P>
-<P>
-<PRE>
- ^.*abcd$
-</PRE>
-</P>
-<P>
-the initial .* matches the entire string at first, but when this fails (because
-there is no following "a"), it backtracks to match all but the last character,
-then all but the last two characters, and so on. Once again the search for "a"
-covers the entire string, from right to left, so we are no better off. However,
-if the pattern is written as
-</P>
-<P>
-<PRE>
- ^(?&#62;.*)(?&#60;=abcd)
-</PRE>
-</P>
-<P>
-there can be no backtracking for the .* item; it can match only the entire
-string. The subsequent lookbehind assertion does a single test on the last four
-characters. If it fails, the match fails immediately. For long strings, this
-approach makes a significant difference to the processing time.
-</P>
-<P>
-When a pattern contains an unlimited repeat inside a subpattern that can itself
-be repeated an unlimited number of times, the use of a once-only subpattern is
-the only way to avoid some failing matches taking a very long time indeed.
-The pattern
-</P>
-<P>
-<PRE>
- (\D+|&#60;\d+&#62;)*[!?]
-</PRE>
-</P>
-<P>
-matches an unlimited number of substrings that either consist of non-digits, or
-digits enclosed in &#60;&#62;, followed by either ! or ?. When it matches, it runs
-quickly. However, if it is applied to
-</P>
-<P>
-<PRE>
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-</PRE>
-</P>
-<P>
-it takes a long time before reporting failure. This is because the string can
-be divided between the two repeats in a large number of ways, and all have to
-be tried. (The example used [!?] rather than a single character at the end,
-because both PCRE and Perl have an optimization that allows for fast failure
-when a single character is used. They remember the last single character that
-is required for a match, and fail early if it is not present in the string.)
-If the pattern is changed to
-</P>
-<P>
-<PRE>
- ((?&#62;\D+)|&#60;\d+&#62;)*[!?]
-</PRE>
-</P>
-<P>
-sequences of non-digits cannot be broken, and failure happens quickly.
-</P>
-<LI><A NAME="SEC26" HREF="#TOC1">CONDITIONAL SUBPATTERNS</A>
-<P>
-It is possible to cause the matching process to obey a subpattern
-conditionally or to choose between two alternative subpatterns, depending on
-the result of an assertion, or whether a previous capturing subpattern matched
-or not. The two possible forms of conditional subpattern are
-</P>
-<P>
-<PRE>
- (?(condition)yes-pattern)
- (?(condition)yes-pattern|no-pattern)
-</PRE>
-</P>
-<P>
-If the condition is satisfied, the yes-pattern is used; otherwise the
-no-pattern (if present) is used. If there are more than two alternatives in the
-subpattern, a compile-time error occurs.
-</P>
-<P>
-There are two kinds of condition. If the text between the parentheses consists
-of a sequence of digits, the condition is satisfied if the capturing subpattern
-of that number has previously matched. The number must be greater than zero.
-Consider the following pattern, which contains non-significant white space to
-make it more readable (assume the PCRE_EXTENDED option) and to divide it into
-three parts for ease of discussion:
-</P>
-<P>
-<PRE>
- ( \( )? [^()]+ (?(1) \) )
-</PRE>
-</P>
-<P>
-The first part matches an optional opening parenthesis, and if that
-character is present, sets it as the first captured substring. The second part
-matches one or more characters that are not parentheses. The third part is a
-conditional subpattern that tests whether the first set of parentheses matched
-or not. If they did, that is, if subject started with an opening parenthesis,
-the condition is true, and so the yes-pattern is executed and a closing
-parenthesis is required. Otherwise, since no-pattern is not present, the
-subpattern matches nothing. In other words, this pattern matches a sequence of
-non-parentheses, optionally enclosed in parentheses.
-</P>
-<P>
-If the condition is not a sequence of digits, it must be an assertion. This may
-be a positive or negative lookahead or lookbehind assertion. Consider this
-pattern, again containing non-significant white space, and with the two
-alternatives on the second line:
-</P>
-<P>
-<PRE>
- (?(?=[^a-z]*[a-z])
- \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} )
-</PRE>
-</P>
-<P>
-The condition is a positive lookahead assertion that matches an optional
-sequence of non-letters followed by a letter. In other words, it tests for the
-presence of at least one letter in the subject. If a letter is found, the
-subject is matched against the first alternative; otherwise it is matched
-against the second. This pattern matches strings in one of the two forms
-dd-aaa-dd or dd-dd-dd, where aaa are letters and dd are digits.
-</P>
-<LI><A NAME="SEC27" HREF="#TOC1">COMMENTS</A>
-<P>
-The sequence (?# marks the start of a comment which continues up to the next
-closing parenthesis. Nested parentheses are not permitted. The characters
-that make up a comment play no part in the pattern matching at all.
-</P>
-<P>
-If the PCRE_EXTENDED option is set, an unescaped # character outside a
-character class introduces a comment that continues up to the next newline
-character in the pattern.
-</P>
-<LI><A NAME="SEC28" HREF="#TOC1">RECURSIVE PATTERNS</A>
-<P>
-Consider the problem of matching a string in parentheses, allowing for
-unlimited nested parentheses. Without the use of recursion, the best that can
-be done is to use a pattern that matches up to some fixed depth of nesting. It
-is not possible to handle an arbitrary nesting depth. Perl 5.6 has provided an
-experimental facility that allows regular expressions to recurse (amongst other
-things). It does this by interpolating Perl code in the expression at run time,
-and the code can refer to the expression itself. A Perl pattern to solve the
-parentheses problem can be created like this:
-</P>
-<P>
-<PRE>
- $re = qr{\( (?: (?&#62;[^()]+) | (?p{$re}) )* \)}x;
-</PRE>
-</P>
-<P>
-The (?p{...}) item interpolates Perl code at run time, and in this case refers
-recursively to the pattern in which it appears. Obviously, PCRE cannot support
-the interpolation of Perl code. Instead, the special item (?R) is provided for
-the specific case of recursion. This PCRE pattern solves the parentheses
-problem (assume the PCRE_EXTENDED option is set so that white space is
-ignored):
-</P>
-<P>
-<PRE>
- \( ( (?&#62;[^()]+) | (?R) )* \)
-</PRE>
-</P>
-<P>
-First it matches an opening parenthesis. Then it matches any number of
-substrings which can either be a sequence of non-parentheses, or a recursive
-match of the pattern itself (i.e. a correctly parenthesized substring). Finally
-there is a closing parenthesis.
-</P>
-<P>
-This particular example pattern contains nested unlimited repeats, and so the
-use of a once-only subpattern for matching strings of non-parentheses is
-important when applying the pattern to strings that do not match. For example,
-when it is applied to
-</P>
-<P>
-<PRE>
- (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
-</PRE>
-</P>
-<P>
-it yields "no match" quickly. However, if a once-only subpattern is not used,
-the match runs for a very long time indeed because there are so many different
-ways the + and * repeats can carve up the subject, and all have to be tested
-before failure can be reported.
-</P>
-<P>
-The values set for any capturing subpatterns are those from the outermost level
-of the recursion at which the subpattern value is set. If the pattern above is
-matched against
-</P>
-<P>
-<PRE>
- (ab(cd)ef)
-</PRE>
-</P>
-<P>
-the value for the capturing parentheses is "ef", which is the last value taken
-on at the top level. If additional parentheses are added, giving
-</P>
-<P>
-<PRE>
- \( ( ( (?&#62;[^()]+) | (?R) )* ) \)
- ^ ^
- ^ ^
-</PRE>
-the string they capture is "ab(cd)ef", the contents of the top level
-parentheses. If there are more than 15 capturing parentheses in a pattern, PCRE
-has to obtain extra memory to store data during a recursion, which it does by
-using <B>pcre_malloc</B>, freeing it via <B>pcre_free</B> afterwards. If no
-memory can be obtained, it saves data for the first 15 capturing parentheses
-only, as there is no way to give an out-of-memory error from within a
-recursion.
-</P>
-<LI><A NAME="SEC29" HREF="#TOC1">PERFORMANCE</A>
-<P>
-Certain items that may appear in patterns are more efficient than others. It is
-more efficient to use a character class like [aeiou] than a set of alternatives
-such as (a|e|i|o|u). In general, the simplest construction that provides the
-required behaviour is usually the most efficient. Jeffrey Friedl's book
-contains a lot of discussion about optimizing regular expressions for efficient
-performance.
-</P>
-<P>
-When a pattern begins with .* and the PCRE_DOTALL option is set, the pattern is
-implicitly anchored by PCRE, since it can match only at the start of a subject
-string. However, if PCRE_DOTALL is not set, PCRE cannot make this optimization,
-because the . metacharacter does not then match a newline, and if the subject
-string contains newlines, the pattern may match from the character immediately
-following one of them instead of from the very start. For example, the pattern
-</P>
-<P>
-<PRE>
- (.*) second
-</PRE>
-</P>
-<P>
-matches the subject "first\nand second" (where \n stands for a newline
-character) with the first captured substring being "and". In order to do this,
-PCRE has to retry the match starting after every newline in the subject.
-</P>
-<P>
-If you are using such a pattern with subject strings that do not contain
-newlines, the best performance is obtained by setting PCRE_DOTALL, or starting
-the pattern with ^.* to indicate explicit anchoring. That saves PCRE from
-having to scan along the subject looking for a newline to restart at.
-</P>
-<P>
-Beware of patterns that contain nested indefinite repeats. These can take a
-long time to run when applied to a string that does not match. Consider the
-pattern fragment
-</P>
-<P>
-<PRE>
- (a+)*
-</PRE>
-</P>
-<P>
-This can match "aaaa" in 33 different ways, and this number increases very
-rapidly as the string gets longer. (The * repeat can match 0, 1, 2, 3, or 4
-times, and for each of those cases other than 0, the + repeats can match
-different numbers of times.) When the remainder of the pattern is such that the
-entire match is going to fail, PCRE has in principle to try every possible
-variation, and this can take an extremely long time.
-</P>
-<P>
-An optimization catches some of the more simple cases such as
-</P>
-<P>
-<PRE>
- (a+)*b
-</PRE>
-</P>
-<P>
-where a literal character follows. Before embarking on the standard matching
-procedure, PCRE checks that there is a "b" later in the subject string, and if
-there is not, it fails the match immediately. However, when there is no
-following literal this optimization cannot be used. You can see the difference
-by comparing the behaviour of
-</P>
-<P>
-<PRE>
- (a+)*\d
-</PRE>
-</P>
-<P>
-with the pattern above. The former gives a failure almost instantly when
-applied to a whole line of "a" characters, whereas the latter takes an
-appreciable time with strings longer than about 20 characters.
-</P>
-<LI><A NAME="SEC30" HREF="#TOC1">UTF-8 SUPPORT</A>
-<P>
-Starting at release 3.3, PCRE has some support for character strings encoded
-in the UTF-8 format. This is incomplete, and is regarded as experimental. In
-order to use it, you must configure PCRE to include UTF-8 support in the code,
-and, in addition, you must call <B>pcre_compile()</B> with the PCRE_UTF8 option
-flag. When you do this, both the pattern and any subject strings that are
-matched against it are treated as UTF-8 strings instead of just strings of
-bytes, but only in the cases that are mentioned below.
-</P>
-<P>
-If you compile PCRE with UTF-8 support, but do not use it at run time, the
-library will be a bit bigger, but the additional run time overhead is limited
-to testing the PCRE_UTF8 flag in several places, so should not be very large.
-</P>
-<P>
-PCRE assumes that the strings it is given contain valid UTF-8 codes. It does
-not diagnose invalid UTF-8 strings. If you pass invalid UTF-8 strings to PCRE,
-the results are undefined.
-</P>
-<P>
-Running with PCRE_UTF8 set causes these changes in the way PCRE works:
-</P>
-<P>
-1. In a pattern, the escape sequence \x{...}, where the contents of the braces
-is a string of hexadecimal digits, is interpreted as a UTF-8 character whose
-code number is the given hexadecimal number, for example: \x{1234}. This
-inserts from one to six literal bytes into the pattern, using the UTF-8
-encoding. If a non-hexadecimal digit appears between the braces, the item is
-not recognized.
-</P>
-<P>
-2. The original hexadecimal escape sequence, \xhh, generates a two-byte UTF-8
-character if its value is greater than 127.
-</P>
-<P>
-3. Repeat quantifiers are NOT correctly handled if they follow a multibyte
-character. For example, \x{100}* and \xc3+ do not work. If you want to
-repeat such characters, you must enclose them in non-capturing parentheses,
-for example (?:\x{100}), at present.
-</P>
-<P>
-4. The dot metacharacter matches one UTF-8 character instead of a single byte.
-</P>
-<P>
-5. Unlike literal UTF-8 characters, the dot metacharacter followed by a
-repeat quantifier does operate correctly on UTF-8 characters instead of
-single bytes.
-</P>
-<P>
-4. Although the \x{...} escape is permitted in a character class, characters
-whose values are greater than 255 cannot be included in a class.
-</P>
-<P>
-5. A class is matched against a UTF-8 character instead of just a single byte,
-but it can match only characters whose values are less than 256. Characters
-with greater values always fail to match a class.
-</P>
-<P>
-6. Repeated classes work correctly on multiple characters.
-</P>
-<P>
-7. Classes containing just a single character whose value is greater than 127
-(but less than 256), for example, [\x80] or [^\x{93}], do not work because
-these are optimized into single byte matches. In the first case, of course,
-the class brackets are just redundant.
-</P>
-<P>
-8. Lookbehind assertions move backwards in the subject by a fixed number of
-characters instead of a fixed number of bytes. Simple cases have been tested
-to work correctly, but there may be hidden gotchas herein.
-</P>
-<P>
-9. The character types such as \d and \w do not work correctly with UTF-8
-characters. They continue to test a single byte.
-</P>
-<P>
-10. Anything not explicitly mentioned here continues to work in bytes rather
-than in characters.
-</P>
-<P>
-The following UTF-8 features of Perl 5.6 are not implemented:
-</P>
-<P>
-1. The escape sequence \C to match a single byte.
-</P>
-<P>
-2. The use of Unicode tables and properties and escapes \p, \P, and \X.
-</P>
-<LI><A NAME="SEC31" HREF="#TOC1">SAMPLE PROGRAM</A>
-<P>
-The code below is a simple, complete demonstration program, to get you started
-with using PCRE. This code is also supplied in the file <I>pcredemo.c</I> in the
-PCRE distribution.
-</P>
-<P>
-The program compiles the regular expression that is its first argument, and
-matches it against the subject string in its second argument. No options are
-set, and default character tables are used. If matching succeeds, the program
-outputs the portion of the subject that matched, together with the contents of
-any captured substrings.
-</P>
-<P>
-On a Unix system that has PCRE installed in <I>/usr/local</I>, you can compile
-the demonstration program using a command like this:
-</P>
-<P>
-<PRE>
- gcc -o pcredemo pcredemo.c -I/usr/local/include -L/usr/local/lib -lpcre
-</PRE>
-</P>
-<P>
-Then you can run simple tests like this:
-</P>
-<P>
-<PRE>
- ./pcredemo 'cat|dog' 'the cat sat on the mat'
-</PRE>
-</P>
-<P>
-Note that there is a much more comprehensive test program, called
-<B>pcretest</B>, which supports many more facilities for testing regular
-expressions. The <B>pcredemo</B> program is provided as a simple coding example.
-</P>
-<P>
-On some operating systems (e.g. Solaris) you may get an error like this when
-you try to run <B>pcredemo</B>:
-</P>
-<P>
-<PRE>
- ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
-</PRE>
-</P>
-<P>
-This is caused by the way shared library support works on those systems. You
-need to add
-</P>
-<P>
-<PRE>
- -R/usr/local/lib
-</PRE>
-</P>
-<P>
-to the compile command to get round this problem. Here's the code:
-</P>
-<P>
-<PRE>
- #include &#60;stdio.h&#62;
- #include &#60;string.h&#62;
- #include &#60;pcre.h&#62;
-</PRE>
-</P>
-<P>
-<PRE>
- #define OVECCOUNT 30 /* should be a multiple of 3 */
-</PRE>
-</P>
-<P>
-<PRE>
- int main(int argc, char **argv)
- {
- pcre *re;
- const char *error;
- int erroffset;
- int ovector[OVECCOUNT];
- int rc, i;
-</PRE>
-</P>
-<P>
-<PRE>
- if (argc != 3)
- {
- printf("Two arguments required: a regex and a "
- "subject string\n");
- return 1;
- }
-</PRE>
-</P>
-<P>
-<PRE>
- /* Compile the regular expression in the first argument */
-</PRE>
-</P>
-<P>
-<PRE>
- re = pcre_compile(
- argv[1], /* the pattern */
- 0, /* default options */
- &error, /* for error message */
- &erroffset, /* for error offset */
- NULL); /* use default character tables */
-</PRE>
-</P>
-<P>
-<PRE>
- /* Compilation failed: print the error message and exit */
-</PRE>
-</P>
-<P>
-<PRE>
- if (re == NULL)
- {
- printf("PCRE compilation failed at offset %d: %s\n",
- erroffset, error);
- return 1;
- }
-</PRE>
-</P>
-<P>
-<PRE>
- /* Compilation succeeded: match the subject in the second
- argument */
-</PRE>
-</P>
-<P>
-<PRE>
- rc = pcre_exec(
- re, /* the compiled pattern */
- NULL, /* we didn't study the pattern */
- argv[2], /* the subject string */
- (int)strlen(argv[2]), /* the length of the subject */
- 0, /* start at offset 0 in the subject */
- 0, /* default options */
- ovector, /* vector for substring information */
- OVECCOUNT); /* number of elements in the vector */
-</PRE>
-</P>
-<P>
-<PRE>
- /* Matching failed: handle error cases */
-</PRE>
-</P>
-<P>
-<PRE>
- if (rc &#60; 0)
- {
- switch(rc)
- {
- case PCRE_ERROR_NOMATCH: printf("No match\n"); break;
- /*
- Handle other special cases if you like
- */
- default: printf("Matching error %d\n", rc); break;
- }
- return 1;
- }
-</PRE>
-</P>
-<P>
-<PRE>
- /* Match succeded */
-</PRE>
-</P>
-<P>
-<PRE>
- printf("Match succeeded\n");
-</PRE>
-</P>
-<P>
-<PRE>
- /* The output vector wasn't big enough */
-</PRE>
-</P>
-<P>
-<PRE>
- if (rc == 0)
- {
- rc = OVECCOUNT/3;
- printf("ovector only has room for %d captured "
- substrings\n", rc - 1);
- }
-</PRE>
-</P>
-<P>
-<PRE>
- /* Show substrings stored in the output vector */
-</PRE>
-</P>
-<P>
-<PRE>
- for (i = 0; i &#60; rc; i++)
- {
- char *substring_start = argv[2] + ovector[2*i];
- int substring_length = ovector[2*i+1] - ovector[2*i];
- printf("%2d: %.*s\n", i, substring_length,
- substring_start);
- }
-</PRE>
-</P>
-<P>
-<PRE>
- return 0;
- }
-</PRE>
-</P>
-<LI><A NAME="SEC32" HREF="#TOC1">AUTHOR</A>
-<P>
-Philip Hazel &#60;ph10@cam.ac.uk&#62;
-<BR>
-University Computing Service,
-<BR>
-New Museums Site,
-<BR>
-Cambridge CB2 3QG, England.
-<BR>
-Phone: +44 1223 334714
-</P>
-<P>
-Last updated: 15 August 2001
-<BR>
-Copyright (c) 1997-2001 University of Cambridge.
diff --git a/doc/pcre.txt b/doc/pcre.txt
index 95f148f..07a1dd7 100644
--- a/doc/pcre.txt
+++ b/doc/pcre.txt
@@ -1,9 +1,303 @@
+This file contains a concatenation of the PCRE man pages, converted to plain
+text format for ease of searching with a text editor, or for use on systems
+that do not have a man page processor. The small individual files that give
+synopses of each function in the library have not been included. There are
+separate text files for the pcregrep and pcretest commands.
+-----------------------------------------------------------------------------
+
+NAME
+ PCRE - Perl-compatible regular expressions
+
+
+DESCRIPTION
+
+ The PCRE library is a set of functions that implement regu-
+ lar expression pattern matching using the same syntax and
+ semantics as Perl, with just a few differences. The current
+ implementation of PCRE (release 4.x) corresponds approxi-
+ mately with Perl 5.8, including support for UTF-8 encoded
+ strings. However, this support has to be explicitly
+ enabled; it is not the default.
+
+ PCRE is written in C and released as a C library. However, a
+ number of people have written wrappers and interfaces of
+ various kinds. A C++ class is included in these contribu-
+ tions, which can be found in the Contrib directory at the
+ primary FTP site, which is:
+
+ ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre
+
+ Details of exactly which Perl regular expression features
+ are and are not supported by PCRE are given in separate
+ documents. See the pcrepattern and pcrecompat pages.
+
+ Some features of PCRE can be included, excluded, or changed
+ when the library is built. The pcre_config() function makes
+ it possible for a client to discover which features are
+ available. Documentation about building PCRE for various
+ operating systems can be found in the README file in the
+ source distribution.
+
+
+USER DOCUMENTATION
+
+ The user documentation for PCRE has been split up into a
+ number of different sections. In the "man" format, each of
+ these is a separate "man page". In the HTML format, each is
+ a separate page, linked from the index page. In the plain
+ text format, all the sections are concatenated, for ease of
+ searching. The sections are as follows:
+
+ pcre this document
+ pcreapi details of PCRE's native API
+ pcrebuild options for building PCRE
+ pcrecallout details of the callout feature
+ pcrecompat discussion of Perl compatibility
+ pcregrep description of the pcregrep command
+ pcrepattern syntax and semantics of supported
+ regular expressions
+ pcreperform discussion of performance issues
+ pcreposix the POSIX-compatible API
+ pcresample discussion of the sample program
+ pcretest the pcretest testing command
+
+ In addition, in the "man" and HTML formats, there is a short
+ page for each library function, listing its arguments and
+ results.
+
+
+LIMITATIONS
+
+ There are some size limitations in PCRE but it is hoped that
+ they will never in practice be relevant.
+
+ The maximum length of a compiled pattern is 65539 (sic)
+ bytes if PCRE is compiled with the default internal linkage
+ size of 2. If you want to process regular expressions that
+ are truly enormous, you can compile PCRE with an internal
+ linkage size of 3 or 4 (see the README file in the source
+ distribution and the pcrebuild documentation for details).
+ If these cases the limit is substantially larger. However,
+ the speed of execution will be slower.
+
+ All values in repeating quantifiers must be less than 65536.
+ The maximum number of capturing subpatterns is 65535.
+
+ There is no limit to the number of non-capturing subpat-
+ terns, but the maximum depth of nesting of all kinds of
+ parenthesized subpattern, including capturing subpatterns,
+ assertions, and other types of subpattern, is 200.
+
+ The maximum length of a subject string is the largest posi-
+ tive number that an integer variable can hold. However, PCRE
+ uses recursion to handle subpatterns and indefinite repeti-
+ tion. This means that the available stack space may limit
+ the size of a subject string that can be processed by cer-
+ tain patterns.
+
+
+UTF-8 SUPPORT
+
+ Starting at release 3.3, PCRE has had some support for char-
+ acter strings encoded in the UTF-8 format. For release 4.0
+ this has been greatly extended to cover most common require-
+ ments.
+
+ In order process UTF-8 strings, you must build PCRE to
+ include UTF-8 support in the code, and, in addition, you
+ must call pcre_compile() with the PCRE_UTF8 option flag.
+ When you do this, both the pattern and any subject strings
+ that are matched against it are treated as UTF-8 strings
+ instead of just strings of bytes.
+
+ If you compile PCRE with UTF-8 support, but do not use it at
+ run time, the library will be a bit bigger, but the addi-
+ tional run time overhead is limited to testing the PCRE_UTF8
+ flag in several places, so should not be very large.
+
+ The following comments apply when PCRE is running in UTF-8
+ mode:
+
+ 1. PCRE assumes that the strings it is given contain valid
+ UTF-8 codes. It does not diagnose invalid UTF-8 strings. If
+ you pass invalid UTF-8 strings to PCRE, the results are
+ undefined.
+
+ 2. In a pattern, the escape sequence \x{...}, where the con-
+ tents of the braces is a string of hexadecimal digits, is
+ interpreted as a UTF-8 character whose code number is the
+ given hexadecimal number, for example: \x{1234}. If a non-
+ hexadecimal digit appears between the braces, the item is
+ not recognized. This escape sequence can be used either as
+ a literal, or within a character class.
+
+ 3. The original hexadecimal escape sequence, \xhh, matches a
+ two-byte UTF-8 character if the value is greater than 127.
+
+ 4. Repeat quantifiers apply to complete UTF-8 characters,
+ not to individual bytes, for example: \x{100}{3}.
+
+ 5. The dot metacharacter matches one UTF-8 character instead
+ of a single byte.
+
+ 6. The escape sequence \C can be used to match a single byte
+ in UTF-8 mode, but its use can lead to some strange effects.
+
+ 7. The character escapes \b, \B, \d, \D, \s, \S, \w, and \W
+ correctly test characters of any code value, but the charac-
+ ters that PCRE recognizes as digits, spaces, or word charac-
+ ters remain the same set as before, all with values less
+ than 256.
+
+ 8. Case-insensitive matching applies only to characters
+ whose values are less than 256. PCRE does not support the
+ notion of "case" for higher-valued characters.
+
+ 9. PCRE does not support the use of Unicode tables and pro-
+ perties or the Perl escapes \p, \P, and \X.
+
+
+AUTHOR
+
+ Philip Hazel <ph10@cam.ac.uk>
+ University Computing Service,
+ Cambridge CB2 3QG, England.
+ Phone: +44 1223 334714
+
+Last updated: 04 February 2003
+Copyright (c) 1997-2003 University of Cambridge.
+-----------------------------------------------------------------------------
+
+NAME
+ PCRE - Perl-compatible regular expressions
+
+
+PCRE BUILD-TIME OPTIONS
+
+ This document describes the optional features of PCRE that
+ can be selected when the library is compiled. They are all
+ selected, or deselected, by providing options to the config-
+ ure script which is run before the make command. The com-
+ plete list of options for configure (which includes the
+ standard ones such as the selection of the installation
+ directory) can be obtained by running
+
+ ./configure --help
+
+ The following sections describe certain options whose names
+ begin with --enable or --disable. These settings specify
+ changes to the defaults for the configure command. Because
+ of the way that configure works, --enable and --disable
+ always come in pairs, so the complementary option always
+ exists as well, but as it specifies the default, it is not
+ described.
+
+
+UTF-8 SUPPORT
+
+ To build PCRE with support for UTF-8 character strings, add
+
+ --enable-utf8
+
+ to the configure command. Of itself, this does not make PCRE
+ treat strings as UTF-8. As well as compiling PCRE with this
+ option, you also have have to set the PCRE_UTF8 option when
+ you call the pcre_compile() function.
+
+
+CODE VALUE OF NEWLINE
+
+ By default, PCRE treats character 10 (linefeed) as the new-
+ line character. This is the normal newline character on
+ Unix-like systems. You can compile PCRE to use character 13
+ (carriage return) instead by adding
+
+ --enable-newline-is-cr
+
+ to the configure command. For completeness there is also a
+ --enable-newline-is-lf option, which explicitly specifies
+ linefeed as the newline character.
+
+
+BUILDING SHARED AND STATIC LIBRARIES
+
+ The PCRE building process uses libtool to build both shared
+ and static Unix libraries by default. You can suppress one
+ of these by adding one of
+
+ --disable-shared
+ --disable-static
+
+ to the configure command, as required.
+
+
+POSIX MALLOC USAGE
+
+ When PCRE is called through the POSIX interface (see the
+ pcreposix documentation), additional working storage is
+ required for holding the pointers to capturing substrings
+ because PCRE requires three integers per substring, whereas
+ the POSIX interface provides only two. If the number of
+ expected substrings is small, the wrapper function uses
+ space on the stack, because this is faster than using mal-
+ loc() for each call. The default threshold above which the
+ stack is no longer used is 10; it can be changed by adding a
+ setting such as
+
+ --with-posix-malloc-threshold=20
+
+ to the configure command.
+
+
+LIMITING PCRE RESOURCE USAGE
+
+ Internally, PCRE has a function called match() which it
+ calls repeatedly (possibly recursively) when performing a
+ matching operation. By limiting the number of times this
+ function may be called, a limit can be placed on the
+ resources used by a single call to pcre_exec(). The limit
+ can be changed at run time, as described in the pcreapi
+ documentation. The default is 10 million, but this can be
+ changed by adding a setting such as
+
+ --with-match-limit=500000
+
+ to the configure command.
+
+
+HANDLING VERY LARGE PATTERNS
+
+ Within a compiled pattern, offset values are used to point
+ from one part to another (for example, from an opening
+ parenthesis to an alternation metacharacter). By default
+ two-byte values are used for these offsets, leading to a
+ maximum size for a compiled pattern of around 64K. This is
+ sufficient to handle all but the most gigantic patterns.
+ Nevertheless, some people do want to process enormous pat-
+ terns, so it is possible to compile PCRE to use three-byte
+ or four-byte offsets by adding a setting such as
+
+ --with-link-size=3
+
+ to the configure command. The value given must be 2, 3, or
+ 4. Using longer offsets slows down the operation of PCRE
+ because it has to load additional bytes when handling them.
+
+ If you build PCRE with an increased link size, test 2 (and
+ test 5 if you are using UTF-8) will fail. Part of the output
+ of these tests is a representation of the compiled pattern,
+ and this changes with the link size.
+
+Last updated: 21 January 2003
+Copyright (c) 1997-2003 University of Cambridge.
+-----------------------------------------------------------------------------
+
NAME
- pcre - Perl-compatible regular expressions.
+ PCRE - Perl-compatible regular expressions
+SYNOPSIS OF PCRE API
-SYNOPSIS
#include <pcre.h>
pcre *pcre_compile(const char *pattern, int options,
@@ -17,10 +311,23 @@ SYNOPSIS
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize);
+ int pcre_copy_named_substring(const pcre *code,
+ const char *subject, int *ovector,
+ int stringcount, const char *stringname,
+ char *buffer, int buffersize);
+
int pcre_copy_substring(const char *subject, int *ovector,
int stringcount, int stringnumber, char *buffer,
int buffersize);
+ int pcre_get_named_substring(const pcre *code,
+ const char *subject, int *ovector,
+ int stringcount, const char *stringname,
+ const char **stringptr);
+
+ int pcre_get_stringnumber(const pcre *code,
+ const char *name);
+
int pcre_get_substring(const char *subject, int *ovector,
int stringcount, int stringnumber,
const char **stringptr);
@@ -37,27 +344,21 @@ SYNOPSIS
int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
int what, void *where);
+
int pcre_info(const pcre *code, int *optptr, *firstcharptr);
+ int pcre_config(int what, void *where);
+
char *pcre_version(void);
void *(*pcre_malloc)(size_t);
void (*pcre_free)(void *);
+ int (*pcre_callout)(pcre_callout_block *);
-
-DESCRIPTION
- The PCRE library is a set of functions that implement regu-
- lar expression pattern matching using the same syntax and
- semantics as Perl 5, with just a few differences (see
-
- below). The current implementation corresponds to Perl
- 5.005, with some additional features from later versions.
- This includes some experimental, incomplete support for
- UTF-8 encoded strings. Details of exactly what is and what
- is not supported are given below.
+PCRE API
PCRE has its own native API, which is described in this
document. There is also a set of wrapper functions that
@@ -76,14 +377,20 @@ DESCRIPTION
The functions pcre_compile(), pcre_study(), and pcre_exec()
are used for compiling and matching regular expressions. A
sample program that demonstrates the simplest way of using
- them is given in the file pcredemo.c. The last section of
- this man page describes how to run it.
-
- The functions pcre_copy_substring(), pcre_get_substring(),
- and pcre_get_substring_list() are convenience functions for
- extracting captured substrings from a matched subject
- string; pcre_free_substring() and pcre_free_substring_list()
- are also provided, to free the memory used for extracted
+ them is given in the file pcredemo.c. The pcresample docu-
+ mentation describes how to run it.
+
+ There are convenience functions for extracting captured sub-
+ strings from a matched subject string. They are:
+
+ pcre_copy_substring()
+ pcre_copy_named_substring()
+ pcre_get_substring()
+ pcre_get_named_substring()
+ pcre_get_substring_list()
+
+ pcre_free_substring() and pcre_free_substring_list() are
+ also provided, to free the memory used for extracted
strings.
The function pcre_maketables() is used (optionally) to build
@@ -104,12 +411,18 @@ DESCRIPTION
replace them if it wishes to intercept the calls. This
should be done before calling any PCRE functions.
+ The global variable pcre_callout initially contains NULL. It
+ can be set by the caller to a "callout" function, which PCRE
+ will then call at specified points during a matching opera-
+ tion. Details are given in the pcrecallout documentation.
+
+MULTITHREADING
-MULTI-THREADING
The PCRE functions can be used in multi-threading applica-
tions, with the proviso that the memory management functions
- pointed to by pcre_malloc and pcre_free are shared by all
+ pointed to by pcre_malloc and pcre_free, and the callout
+ function pointed to by pcre_callout, are shared by all
threads.
The compiled form of a regular expression is not altered
@@ -117,8 +430,62 @@ MULTI-THREADING
used by several threads at once.
+CHECKING BUILD-TIME OPTIONS
+
+ int pcre_config(int what, void *where);
+
+ The function pcre_config() makes it possible for a PCRE
+ client to discover which optional features have been com-
+ piled into the PCRE library. The pcrebuild documentation has
+ more details about these optional features.
+
+ The first argument for pcre_config() is an integer, specify-
+ ing which information is required; the second argument is a
+ pointer to a variable into which the information is placed.
+ The following information is available:
+
+ PCRE_CONFIG_UTF8
+
+ The output is an integer that is set to one if UTF-8 support
+ is available; otherwise it is set to zero.
+
+ PCRE_CONFIG_NEWLINE
+
+ The output is an integer that is set to the value of the
+ code that is used for the newline character. It is either
+ linefeed (10) or carriage return (13), and should normally
+ be the standard character for your operating system.
+
+ PCRE_CONFIG_LINK_SIZE
+
+ The output is an integer that contains the number of bytes
+ used for internal linkage in compiled regular expressions.
+ The value is 2, 3, or 4. Larger values allow larger regular
+ expressions to be compiled, at the expense of slower match-
+ ing. The default value of 2 is sufficient for all but the
+ most massive patterns, since it allows the compiled pattern
+ to be up to 64K in size.
+
+ PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+
+ The output is an integer that contains the threshold above
+ which the POSIX interface uses malloc() for output vectors.
+ Further details are given in the pcreposix documentation.
+
+ PCRE_CONFIG_MATCH_LIMIT
+
+ The output is an integer that gives the default limit for
+ the number of internal matching function calls in a
+ pcre_exec() execution. Further details are given with
+ pcre_exec() below.
+
COMPILING A PATTERN
+
+ pcre *pcre_compile(const char *pattern, int options,
+ const char **errptr, int *erroffset,
+ const unsigned char *tableptr);
+
The function pcre_compile() is called to compile a pattern
into an internal form. The pattern is a C string terminated
by a binary zero, and is passed in the argument pattern. A
@@ -134,24 +501,16 @@ COMPILING A PATTERN
pcre data block is not fully relocatable, because it con-
tains a copy of the tableptr argument, which is an address
(see below).
-
- The size of a compiled pattern is roughly proportional to
- the length of the pattern string, except that each character
- class (other than those containing just a single character,
- negated or not) requires 33 bytes, and repeat quantifiers
- with a minimum greater than one or a bounded maximum cause
- the relevant portions of the compiled pattern to be repli-
- cated.
-
The options argument contains independent bits that affect
the compilation. It should be zero if no options are
required. Some of the options, in particular, those that are
compatible with Perl, can also be set and unset from within
the pattern (see the detailed description of regular expres-
- sions below). For these options, the contents of the options
- argument specifies their initial settings at the start of
- compilation and execution. The PCRE_ANCHORED option can be
- set at the time of matching as well as at compile time.
+ sions in the pcrepattern documentation). For these options,
+ the contents of the options argument specifies their initial
+ settings at the start of compilation and execution. The
+ PCRE_ANCHORED option can be set at the time of matching as
+ well as at compile time.
If errptr is NULL, pcre_compile() returns NULL immediately.
Otherwise, if compilation of a pattern fails, pcre_compile()
@@ -181,21 +540,23 @@ COMPILING A PATTERN
&erroffset, /* for error offset */
NULL); /* use default character tables */
- The following option bits are defined in the header file:
+ The following option bits are defined:
PCRE_ANCHORED
If this bit is set, the pattern is forced to be "anchored",
- that is, it is constrained to match only at the start of the
- string which 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.
+ that is, it is constrained to match only at the first match-
+ ing point in the string which is being searched (the "sub-
+ ject string"). This effect can also be achieved by appropri-
+ ate constructs in the pattern itself, which is the only way
+ to do it in Perl.
PCRE_CASELESS
If this bit is set, letters in the pattern match both upper
and lower case letters. It is equivalent to Perl's /i
- option.
+ option, and it can be changed within a pattern by a (?i)
+ option setting.
PCRE_DOLLAR_ENDONLY
@@ -205,28 +566,34 @@ COMPILING A PATTERN
character if it is a newline (but not before any other new-
lines). The PCRE_DOLLAR_ENDONLY option is ignored if
PCRE_MULTILINE is set. There is no equivalent to this option
- in Perl.
+ in Perl, and no way to set it within a pattern.
PCRE_DOTALL
If this bit is set, a dot metacharater in the pattern
matches all characters, including newlines. Without it, new-
lines are excluded. This option is equivalent to Perl's /s
- option. A negative class such as [^a] always matches a new-
- line character, independent of the setting of this option.
+ option, and it can be changed within a pattern by a (?s)
+ option setting. A negative class such as [^a] always matches
+ a newline character, independent of the setting of this
+ option.
PCRE_EXTENDED
If this bit is set, whitespace data characters in the pat-
tern are totally ignored except when escaped or inside a
- character class, and characters between an unescaped # out-
- side a character class and the next newline character,
+ character class. Whitespace does not include the VT charac-
+ ter (code 11). In addition, characters between an unescaped
+ # outside a character class and the next newline character,
inclusive, are also ignored. This is equivalent to Perl's /x
- option, and makes it possible to include comments inside
- complicated patterns. Note, however, that this applies only
- to data characters. Whitespace characters may never appear
+ option, and it can be changed within a pattern by a (?x)
+ option setting.
+
+ This option makes it possible to include comments inside
+ complicated patterns. Note, however, that this applies only
+ to data characters. Whitespace characters may never appear
within special character sequences in a pattern, for example
- within the sequence (?( which introduces a conditional sub-
+ within the sequence (?( which introduces a conditional sub-
pattern.
PCRE_EXTRA
@@ -256,9 +623,19 @@ COMPILING A PATTERN
of line" constructs match immediately following or immedi-
ately before any newline in the subject string, respec-
tively, as well as at the very start and end. This is
- equivalent to Perl's /m option. If there are no "\n" charac-
- ters in a subject string, or no occurrences of ^ or $ in a
- pattern, setting PCRE_MULTILINE has no effect.
+ equivalent to Perl's /m option, and it can be changed within
+ a pattern by a (?m) option setting. If there are no "\n"
+ characters in a subject string, or no occurrences of ^ or $
+ in a pattern, setting PCRE_MULTILINE has no effect.
+
+ PCRE_NO_AUTO_CAPTURE
+
+ If this option is set, it disables the use of numbered cap-
+ turing parentheses in the pattern. Any opening parenthesis
+ that is not followed by ? behaves as if it were followed by
+ ?: but named parentheses can still be used for capturing
+ (and they acquire numbers in the usual way). There is no
+ equivalent of this option in Perl.
PCRE_UNGREEDY
@@ -270,34 +647,47 @@ COMPILING A PATTERN
PCRE_UTF8
This option causes PCRE to regard both the pattern and the
- subject as strings of UTF-8 characters instead of just byte
- strings. However, it is available only if PCRE has been
- built to include UTF-8 support. If not, the use of this
- option provokes an error. Support for UTF-8 is new, experi-
- mental, and incomplete. Details of exactly what it entails
- are given below.
-
+ subject as strings of UTF-8 characters instead of single-
+ byte character strings. However, it is available only if
+ PCRE has been built to include UTF-8 support. If not, the
+ use of this option provokes an error. Details of how this
+ option changes the behaviour of PCRE are given in the sec-
+ tion on UTF-8 support in the main pcre page.
STUDYING A PATTERN
+
+ pcre_extra *pcre_study(const pcre *code, int options,
+ const char **errptr);
+
When a pattern is going to be used several times, it is
worth spending more time analyzing it in order to speed up
the time taken for matching. The function pcre_study() takes
- a pointer to a compiled pattern as its first argument, and
- returns a pointer to a pcre_extra block (another typedef for
- a structure with hidden contents) containing additional
- information about the pattern; this can be passed to
- pcre_exec(). If no additional information is available, NULL
- is returned.
+ a pointer to a compiled pattern as its first argument. If
+ studing the pattern produces additional information that
+ will help speed up matching, pcre_study() returns a pointer
+ to a pcre_extra block, in which the study_data field points
+ to the results of the study.
+
+ The returned value from a pcre_study() can be passed
+ directly to pcre_exec(). However, the pcre_extra block also
+ contains other fields that can be set by the caller before
+ the block is passed; these are described below. If studying
+ the pattern does not produce any additional information,
+ pcre_study() returns NULL. In that circumstance, if the cal-
+ ling program wants to pass some of the other fields to
+ pcre_exec(), it must set up its own pcre_extra block.
The second argument contains option bits. At present, no
options are defined for pcre_study(), and this argument
should always be zero.
- The third argument for pcre_study() is a pointer to an error
- message. If studying succeeds (even if no data is returned),
- the variable it points to is set to NULL. Otherwise it
- points to a textual error message.
+ The third argument for pcre_study() is a pointer for an
+ error message. If studying succeeds (even if no data is
+ returned), the variable it points to is set to NULL. Other-
+ wise it points to a textual error message. You should there-
+ fore test the error pointer for NULL after calling
+ pcre_study(), to be sure that it has run successfully.
This is a typical call to pcre_study():
@@ -313,15 +703,16 @@ STUDYING A PATTERN
created.
-
LOCALE SUPPORT
+
PCRE handles caseless matching, and determines whether char-
acters are letters, digits, or whatever, by reference to a
- set of tables. The library contains a default set of tables
- which is created in the default C locale when PCRE is com-
- piled. This is used when the final argument of
- pcre_compile() is NULL, and is sufficient for many applica-
- tions.
+ set of tables. When running in UTF-8 mode, this applies only
+ to characters with codes less than 256. The library contains
+ a default set of tables that is created in the default C
+ locale when PCRE is compiled. This is used when the final
+ argument of pcre_compile() is NULL, and is sufficient for
+ many applications.
An alternative set of tables can, however, be supplied. Such
tables are built by calling the pcre_maketables() function,
@@ -339,7 +730,7 @@ LOCALE SUPPORT
The tables are built in memory that is obtained via
pcre_malloc. The pointer that is passed to pcre_compile is
saved with the compiled pattern, and the same tables are
- used via this pointer by pcre_study() and pcre_exec(). Thus
+ used via this pointer by pcre_study() and pcre_exec(). Thus,
for any single pattern, compilation, studying and matching
all happen in the same locale, but different patterns can be
compiled in different locales. It is the caller's responsi-
@@ -347,8 +738,11 @@ LOCALE SUPPORT
remains available for as long as it is needed.
-
INFORMATION ABOUT A PATTERN
+
+ int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
+ int what, void *where);
+
The pcre_fullinfo() function returns information about a
compiled pattern. It replaces the obsolete pcre_info() func-
tion, which is nevertheless retained for backwards compabil-
@@ -358,9 +752,9 @@ INFORMATION ABOUT A PATTERN
compiled pattern. The second argument is the result of
pcre_study(), or NULL if the pattern was not studied. The
third argument specifies which piece of information is
- required, while the fourth argument is a pointer to a vari-
- able to receive the data. The yield of the function is zero
- for success, or one of the following negative numbers:
+ required, and the fourth argument is a pointer to a variable
+ to receive the data. The yield of the function is zero for
+ success, or one of the following negative numbers:
PCRE_ERROR_NULL the argument code was NULL
the argument where was NULL
@@ -381,40 +775,25 @@ INFORMATION ABOUT A PATTERN
The possible values for the third argument are defined in
pcre.h, and are as follows:
- PCRE_INFO_OPTIONS
-
- Return a copy of the options with which the pattern was com-
- piled. The fourth argument should point to an unsigned long
- int variable. These option bits are those specified in the
- call to pcre_compile(), modified by any top-level option
- settings within the pattern itself, and with the
- PCRE_ANCHORED bit forcibly set if the form of the pattern
- implies that it can match only at the start of a subject
- string.
-
- PCRE_INFO_SIZE
+ PCRE_INFO_BACKREFMAX
- Return the size of the compiled pattern, that is, the value
- that was passed as the argument to pcre_malloc() when PCRE
- was getting memory in which to place the compiled data. The
- fourth argument should point to a size_t variable.
+ Return the number of the highest back reference in the pat-
+ tern. The fourth argument should point to an int variable.
+ Zero is returned if there are no back references.
PCRE_INFO_CAPTURECOUNT
Return the number of capturing subpatterns in the pattern.
The fourth argument should point to an int variable.
- PCRE_INFO_BACKREFMAX
-
- Return the number of the highest back reference in the pat-
- tern. The fourth argument should point to an int variable.
- Zero is returned if there are no back references.
+ PCRE_INFO_FIRSTBYTE
- PCRE_INFO_FIRSTCHAR
+ Return information about the first byte of any matched
+ string, for a non-anchored pattern. (This option used to be
+ called PCRE_INFO_FIRSTCHAR; the old name is still recognized
+ for backwards compatibility.)
- Return information about the first character of any matched
- string, for a non-anchored pattern. If there is a fixed
- first character, e.g. from a pattern such as
+ If there is a fixed first byte, e.g. from a pattern such as
(cat|cow|coyote), it is returned in the integer pointed to
by where. Otherwise, if either
@@ -426,27 +805,110 @@ INFORMATION ABOUT A PATTERN
anchored),
-1 is returned, indicating that the pattern matches only at
- the start of a subject string or after any "\n" within the
- string. Otherwise -2 is returned. For anchored patterns, -2
- is returned.
+ the start of a subject string or after any newline within
+ the string. Otherwise -2 is returned. For anchored patterns,
+ -2 is returned.
PCRE_INFO_FIRSTTABLE
If the pattern was studied, and this resulted in the con-
- struction of a 256-bit table indicating a fixed set of char-
- acters for the first character in any matching string, a
- pointer to the table is returned. Otherwise NULL is
- returned. The fourth argument should point to an unsigned
- char * variable.
+ struction of a 256-bit table indicating a fixed set of bytes
+ for the first byte in any matching string, a pointer to the
+ table is returned. Otherwise NULL is returned. The fourth
+ argument should point to an unsigned char * variable.
PCRE_INFO_LASTLITERAL
For a non-anchored pattern, return the value of the right-
- most literal character which must exist in any matched
- string, other than at its start. The fourth argument should
- point to an int variable. If there is no such character, or
- if the pattern is anchored, -1 is returned. For example, for
- the pattern /a\d+z\d+/ the returned value is 'z'.
+ most literal byte which must exist in any matched string,
+ other than at its start. The fourth argument should point to
+ an int variable. If there is no such byte, or if the pattern
+ is anchored, -1 is returned. For example, for the pattern
+ /a\d+z\d+/ the returned value is 'z'.
+
+ PCRE_INFO_NAMECOUNT
+ PCRE_INFO_NAMEENTRYSIZE
+ PCRE_INFO_NAMETABLE
+
+ PCRE supports the use of named as well as numbered capturing
+ parentheses. The names are just an additional way of identi-
+ fying the parentheses, which still acquire a number. A
+ caller that wants to extract data from a named subpattern
+ must convert the name to a number in order to access the
+ correct pointers in the output vector (described with
+ pcre_exec() below). In order to do this, it must first use
+ these three values to obtain the name-to-number mapping
+ table for the pattern.
+
+ The map consists of a number of fixed-size entries.
+ PCRE_INFO_NAMECOUNT gives the number of entries, and
+ PCRE_INFO_NAMEENTRYSIZE gives the size of each entry; both
+ of these return an int value. The entry size depends on the
+ length of the longest name. PCRE_INFO_NAMETABLE returns a
+ pointer to the first entry of the table (a pointer to char).
+ The first two bytes of each entry are the number of the cap-
+ turing parenthesis, most significant byte first. The rest of
+ the entry is the corresponding name, zero terminated. The
+ names are in alphabetical order. For example, consider the
+ following pattern (assume PCRE_EXTENDED is set, so white
+ space - including newlines - is ignored):
+
+ (?P<date> (?P<year>(\d\d)?\d\d) -
+ (?P<month>\d\d) - (?P<day>\d\d) )
+
+ There are four named subpatterns, so the table has four
+ entries, and each entry in the table is eight bytes long.
+ The table is as follows, with non-printing bytes shows in
+ hex, and undefined bytes shown as ??:
+
+ 00 01 d a t e 00 ??
+ 00 05 d a y 00 ?? ??
+ 00 04 m o n t h 00
+ 00 02 y e a r 00 ??
+
+ When writing code to extract data from named subpatterns,
+ remember that the length of each entry may be different for
+ each compiled pattern.
+
+ PCRE_INFO_OPTIONS
+
+ Return a copy of the options with which the pattern was com-
+ piled. The fourth argument should point to an unsigned long
+ int variable. These option bits are those specified in the
+ call to pcre_compile(), modified by any top-level option
+ settings within the pattern itself.
+
+ A pattern is automatically anchored by PCRE if all of its
+ top-level alternatives begin with one of the following:
+
+ ^ unless PCRE_MULTILINE is set
+ \A always
+ \G always
+ .* if PCRE_DOTALL is set and there are no back
+ references to the subpattern in which .* appears
+
+ For such patterns, the PCRE_ANCHORED bit is set in the
+ options returned by pcre_fullinfo().
+
+ PCRE_INFO_SIZE
+
+ Return the size of the compiled pattern, that is, the value
+ that was passed as the argument to pcre_malloc() when PCRE
+ was getting memory in which to place the compiled data. The
+ fourth argument should point to a size_t variable.
+
+ PCRE_INFO_STUDYSIZE
+
+ Returns the size of the data block pointed to by the
+ study_data field in a pcre_extra block. That is, it is the
+ value that was passed to pcre_malloc() when PCRE was getting
+ memory into which to place the data created by pcre_study().
+ The fourth argument should point to a size_t variable.
+
+
+OBSOLETE INFO FUNCTION
+
+ int pcre_info(const pcre *code, int *optptr, *firstcharptr);
The pcre_info() function is now obsolete because its inter-
face is too restrictive to return all the available data
@@ -465,25 +927,19 @@ INFORMATION ABOUT A PATTERN
If the pattern is not anchored and the firstcharptr argument
is not NULL, it is used to pass back information about the
first character of any matched string (see
- PCRE_INFO_FIRSTCHAR above).
-
+ PCRE_INFO_FIRSTBYTE above).
MATCHING A PATTERN
- The function pcre_exec() is called to match a subject string
-
-
-
-
-
-SunOS 5.8 Last change: 9
-
+ int pcre_exec(const pcre *code, const pcre_extra *extra,
+ const char *subject, int length, int startoffset,
+ int options, int *ovector, int ovecsize);
+ The function pcre_exec() is called to match a subject string
against a pre-compiled pattern, which is passed in the code
argument. If the pattern has been studied, the result of the
- study should be passed in the extra argument. Otherwise this
- must be NULL.
+ study should be passed in the extra argument.
Here is an example of a simple call to pcre_exec():
@@ -499,11 +955,62 @@ SunOS 5.8 Last change: 9
ovector, /* vector for substring information */
30); /* number of elements in the vector */
+ If the extra argument is not NULL, it must point to a
+ pcre_extra data block. The pcre_study() function returns
+ such a block (when it doesn't return NULL), but you can also
+ create one for yourself, and pass additional information in
+ it. The fields in the block are as follows:
+
+ unsigned long int flags;
+ void *study_data;
+ unsigned long int match_limit;
+ void *callout_data;
+
+ The flags field is a bitmap that specifies which of the
+ other fields are set. The flag bits are:
+
+ PCRE_EXTRA_STUDY_DATA
+ PCRE_EXTRA_MATCH_LIMIT
+ PCRE_EXTRA_CALLOUT_DATA
+
+ Other flag bits should be set to zero. The study_data field
+ is set in the pcre_extra block that is returned by
+ pcre_study(), together with the appropriate flag bit. You
+ should not set this yourself, but you can add to the block
+ by setting the other fields.
+
+ The match_limit field provides a means of preventing PCRE
+ from using up a vast amount of resources when running pat-
+ terns that are not going to match, but which have a very
+ large number of possibilities in their search trees. The
+ classic example is the use of nested unlimited repeats.
+ Internally, PCRE uses a function called match() which it
+ calls repeatedly (sometimes recursively). The limit is
+ imposed on the number of times this function is called dur-
+ ing a match, which has the effect of limiting the amount of
+ recursion and backtracking that can take place. For patterns
+ that are not anchored, the count starts from zero for each
+ position in the subject string.
+
+ The default limit for the library can be set when PCRE is
+ built; the default default is 10 million, which handles all
+ but the most extreme cases. You can reduce the default by
+ suppling pcre_exec() with a pcre_extra block in which
+ match_limit is set to a smaller value, and
+ PCRE_EXTRA_MATCH_LIMIT is set in the flags field. If the
+ limit is exceeded, pcre_exec() returns
+ PCRE_ERROR_MATCHLIMIT.
+
+ The pcre_callout field is used in conjunction with the "cal-
+ lout" feature, which is described in the pcrecallout docu-
+ mentation.
+
The PCRE_ANCHORED option can be passed in the options argu-
- ment, whose unused bits must be zero. However, if a pattern
- was compiled with PCRE_ANCHORED, or turned out to be
- anchored by virtue of its contents, it cannot be made
- unachored at matching time.
+ ment, whose unused bits must be zero. This limits
+ pcre_exec() to matching at the first matching position. How-
+ ever, if a pattern was compiled with PCRE_ANCHORED, or
+ turned out to be anchored by virtue of its contents, it can-
+ not be made unachored at matching time.
There are also three further options that can be set only at
matching time:
@@ -547,13 +1054,18 @@ SunOS 5.8 Last change: 9
advancing the starting offset (see below) and trying an
ordinary match again.
- The subject string is passed as a pointer in subject, a
- length in length, and a starting offset in startoffset.
- Unlike the pattern string, the subject may contain binary
- zero characters. When the starting offset is zero, the
+ The subject string is passed to pcre_exec() as a pointer in
+ subject, a length in length, and a starting offset in star-
+ toffset. Unlike the pattern string, the subject may contain
+ binary zero bytes. When the starting offset is zero, the
search for a match starts at the beginning of the subject,
and this is by far the most common case.
+ If the pattern was compiled with the PCRE_UTF8 option, the
+ subject must be a sequence of bytes that is a valid UTF-8
+ string. If an invalid UTF-8 string is passed, PCRE's
+ behaviour is not defined.
+
A non-zero starting offset is useful when searching for
another match in the same subject by calling pcre_exec()
again after a previous success. Setting startoffset differs
@@ -615,7 +1127,6 @@ SunOS 5.8 Last change: 9
there are no capturing subpatterns, the return value from a
successful match is 1, indicating that just the first pair
of offsets has been set.
-
Some convenience functions are provided for extracting the
captured substrings as separate strings. These are described
in the following section.
@@ -645,8 +1156,8 @@ SunOS 5.8 Last change: 9
Note that pcre_info() can be used to find out how many cap-
turing subpatterns there are in a compiled pattern. The
smallest size for ovector that will allow for n captured
- substrings in addition to the offsets of the substring
- matched by the whole pattern is (n+1)*3.
+ substrings, in addition to the offsets of the substring
+ matched by the whole pattern, is (n+1)*3.
If pcre_exec() fails, it returns a negative number. The fol-
lowing are defined in the header file:
@@ -686,25 +1197,57 @@ SunOS 5.8 Last change: 9
pcre_malloc() fails, this error is given. The memory is
freed at the end of matching.
+ PCRE_ERROR_NOSUBSTRING (-7)
+
+ This error is used by the pcre_copy_substring(),
+ pcre_get_substring(), and pcre_get_substring_list() func-
+ tions (see below). It is never returned by pcre_exec().
+
+ PCRE_ERROR_MATCHLIMIT (-8)
+
+ The recursion and backtracking limit, as specified by the
+ match_limit field in a pcre_extra structure (or defaulted)
+ was reached. See the description above.
+
+ PCRE_ERROR_CALLOUT (-9)
+ This error is never generated by pcre_exec() itself. It is
+ provided for use by callout functions that want to yield a
+ distinctive error code. See the pcrecallout documentation
+ for details.
+
+
+EXTRACTING CAPTURED SUBSTRINGS BY NUMBER
+
+ int pcre_copy_substring(const char *subject, int *ovector,
+ int stringcount, int stringnumber, char *buffer,
+ int buffersize);
+
+ int pcre_get_substring(const char *subject, int *ovector,
+ int stringcount, int stringnumber,
+ const char **stringptr);
+
+ int pcre_get_substring_list(const char *subject,
+ int *ovector, int stringcount, const char ***listptr);
-EXTRACTING CAPTURED SUBSTRINGS
Captured substrings can be accessed directly by using the
offsets returned by pcre_exec() in ovector. For convenience,
the functions pcre_copy_substring(), pcre_get_substring(),
and pcre_get_substring_list() are provided for extracting
captured substrings as new, separate, zero-terminated
+ strings. These functions identify substrings by number. The
+ next section describes functions for extracting named sub-
strings. A substring that contains a binary zero is
correctly extracted and has a further zero added on the end,
- but the result does not, of course, function as a C string.
-
- The first three arguments are the same for all three func-
- tions: subject is the subject string which has just been
- successfully matched, ovector is a pointer to the vector of
- integer offsets that was passed to pcre_exec(), and
- stringcount is the number of substrings that were captured
- by the match, including the substring that matched the
+ but the result is not, of course, a C string.
+
+ The first three arguments are the same for all three of
+ these functions: subject is the subject string which has
+ just been successfully matched, ovector is a pointer to the
+ vector of integer offsets that was passed to pcre_exec(),
+ and stringcount is the number of substrings that were cap-
+ tured by the match, including the substring that matched the
entire regular expression. This is the value returned by
pcre_exec if it is greater than zero. If pcre_exec()
returned zero, indicating that it ran out of space in ovec-
@@ -763,49 +1306,171 @@ EXTRACTING CAPTURED SUBSTRINGS
the functions are provided.
+EXTRACTING CAPTURED SUBSTRINGS BY NAME
-LIMITATIONS
- There are some size limitations in PCRE but it is hoped that
- they will never in practice be relevant. The maximum length
- of a compiled pattern is 65539 (sic) bytes. All values in
- repeating quantifiers must be less than 65536. There max-
- imum number of capturing subpatterns is 65535. There is no
- limit to the number of non-capturing subpatterns, but the
- maximum depth of nesting of all kinds of parenthesized sub-
- pattern, including capturing subpatterns, assertions, and
- other types of subpattern, is 200.
+ int pcre_copy_named_substring(const pcre *code,
+ const char *subject, int *ovector,
+ int stringcount, const char *stringname,
+ char *buffer, int buffersize);
- The maximum length of a subject string is the largest posi-
- tive number that an integer variable can hold. However, PCRE
- uses recursion to handle subpatterns and indefinite repeti-
- tion. This means that the available stack space may limit
- the size of a subject string that can be processed by cer-
- tain patterns.
+ int pcre_get_stringnumber(const pcre *code,
+ const char *name);
+
+ int pcre_get_named_substring(const pcre *code,
+ const char *subject, int *ovector,
+ int stringcount, const char *stringname,
+ const char **stringptr);
+
+ To extract a substring by name, you first have to find asso-
+ ciated number. This can be done by calling
+ pcre_get_stringnumber(). The first argument is the compiled
+ pattern, and the second is the name. For example, for this
+ pattern
+
+ ab(?<xxx>\d+)...
+
+ the number of the subpattern called "xxx" is 1. Given the
+ number, you can then extract the substring directly, or use
+ one of the functions described in the previous section. For
+ convenience, there are also two functions that do the whole
+ job.
+
+ Most of the arguments of pcre_copy_named_substring() and
+ pcre_get_named_substring() are the same as those for the
+ functions that extract by number, and so are not re-
+ described here. There are just two differences.
+
+ First, instead of a substring number, a substring name is
+ given. Second, there is an extra argument, given at the
+ start, which is a pointer to the compiled pattern. This is
+ needed in order to gain access to the name-to-number trans-
+ lation table.
+ These functions call pcre_get_stringnumber(), and if it
+ succeeds, they then call pcre_copy_substring() or
+ pcre_get_substring(), as appropriate.
+
+Last updated: 03 February 2003
+Copyright (c) 1997-2003 University of Cambridge.
+-----------------------------------------------------------------------------
+
+NAME
+ PCRE - Perl-compatible regular expressions
+
+
+PCRE CALLOUTS
+
+ int (*pcre_callout)(pcre_callout_block *);
+
+ PCRE provides a feature called "callout", which is a means
+ of temporarily passing control to the caller of PCRE in the
+ middle of pattern matching. The caller of PCRE provides an
+ external function by putting its entry point in the global
+ variable pcre_callout. By default, this variable contains
+ NULL, which disables all calling out.
+
+ Within a regular expression, (?C) indicates the points at
+ which the external function is to be called. Different cal-
+ lout points can be identified by putting a number less than
+ 256 after the letter C. The default value is zero. For
+ example, this pattern has two callout points:
+
+ (?C1)9abc(?C2)def
+
+ During matching, when PCRE reaches a callout point (and
+ pcre_callout is set), the external function is called. Its
+ only argument is a pointer to a pcre_callout block. This
+ contains the following variables:
+
+ int version;
+ int callout_number;
+ int *offset_vector;
+ const char *subject;
+ int subject_length;
+ int start_match;
+ int current_position;
+ int capture_top;
+ int capture_last;
+ void *callout_data;
+
+ The version field is an integer containing the version
+ number of the block format. The current version is zero. The
+ version number may change in future if additional fields are
+ added, but the intention is never to remove any of the
+ existing fields.
+
+ The callout_number field contains the number of the callout,
+ as compiled into the pattern (that is, the number after ?C).
+
+ The offset_vector field is a pointer to the vector of
+ offsets that was passed by the caller to pcre_exec(). The
+ contents can be inspected in order to extract substrings
+ that have been matched so far, in the same way as for
+ extracting substrings after a match has completed.
+ The subject and subject_length fields contain copies the
+ values that were passed to pcre_exec().
+
+ The start_match field contains the offset within the subject
+ at which the current match attempt started. If the pattern
+ is not anchored, the callout function may be called several
+ times for different starting points.
+
+ The current_position field contains the offset within the
+ subject of the current match pointer.
+
+ The capture_top field contains the number of the highest
+ captured substring so far.
+
+ The capture_last field contains the number of the most
+ recently captured substring.
+
+ The callout_data field contains a value that is passed to
+ pcre_exec() by the caller specifically so that it can be
+ passed back in callouts. It is passed in the pcre_callout
+ field of the pcre_extra data structure. If no such data was
+ passed, the value of callout_data in a pcre_callout block is
+ NULL. There is a description of the pcre_extra structure in
+ the pcreapi documentation.
+
+
+
+RETURN VALUES
+
+ The callout function returns an integer. If the value is
+ zero, matching proceeds as normal. If the value is greater
+ than zero, matching fails at the current point, but back-
+ tracking to test other possibilities goes ahead, just as if
+ a lookahead assertion had failed. If the value is less than
+ zero, the match is abandoned, and pcre_exec() returns the
+ value.
+
+ Negative values should normally be chosen from the set of
+ PCRE_ERROR_xxx values. In particular, PCRE_ERROR_NOMATCH
+ forces a standard "no match" failure. The error number
+ PCRE_ERROR_CALLOUT is reserved for use by callout functions;
+ it will never be used by PCRE itself.
+
+Last updated: 21 January 2003
+Copyright (c) 1997-2003 University of Cambridge.
+-----------------------------------------------------------------------------
+
+NAME
+ PCRE - Perl-compatible regular expressions
DIFFERENCES FROM PERL
- The differences described here are with respect to Perl
- 5.005.
-
- 1. By default, a whitespace character is any character that
- the C library function isspace() recognizes, though it is
- possible to compile PCRE with alternative character type
- tables. Normally isspace() matches space, formfeed, newline,
- carriage return, horizontal tab, and vertical tab. Perl 5 no
- longer includes vertical tab in its set of whitespace char-
- acters. The \v escape that was in the Perl documentation for
- a long time was never in fact recognized. However, the char-
- acter itself was treated as whitespace at least up to 5.002.
- In 5.004 and 5.005 it does not match \s.
-
- 2. PCRE does not allow repeat quantifiers on lookahead
+
+ This document describes the differences in the ways that
+ PCRE and Perl handle regular expressions. The differences
+ described here are with respect to Perl 5.8.
+
+ 1. PCRE does not allow repeat quantifiers on lookahead
assertions. Perl permits them, but they do not mean what you
might think. For example, (?!a){3} does not assert that the
next three characters are not "a". It just asserts that the
next character is not "a" three times.
- 3. Capturing subpatterns that occur inside negative looka-
+ 2. Capturing subpatterns that occur inside negative looka-
head assertions are counted, but their entries in the
offsets vector are never set. Perl sets its numerical vari-
ables from any such patterns that are matched before the
@@ -813,52 +1478,58 @@ DIFFERENCES FROM PERL
only if the negative lookahead assertion contains just one
branch.
- 4. Though binary zero characters are supported in the sub-
+ 3. Though binary zero characters are supported in the sub-
ject string, they are not allowed in a pattern string
because it is passed as a normal C string, terminated by
zero. The escape sequence "\0" can be used in the pattern to
represent a binary zero.
- 5. The following Perl escape sequences are not supported:
- \l, \u, \L, \U, \E, \Q. In fact these are implemented by
- Perl's general string-handling and are not part of its pat-
- tern matching engine.
+ 4. The following Perl escape sequences are not supported:
+ \l, \u, \L, \U, \P, \p, and \X. In fact these are imple-
+ mented by Perl's general string-handling and are not part of
+ its pattern matching engine. If any of these are encountered
+ by PCRE, an error is generated.
+
+ 5. PCRE does support the \Q...\E escape for quoting sub-
+ strings. Characters in between are treated as literals. This
+ is slightly different from Perl in that $ and @ are also
+ handled as literals inside the quotes. In Perl, they cause
+ variable interpolation (but of course PCRE does not have
+ variables). Note the following examples:
- 6. The Perl \G assertion is not supported as it is not
- relevant to single pattern matches.
+ Pattern PCRE matches Perl matches
- 7. Fairly obviously, PCRE does not support the (?{code}) and
+ \Qabc$xyz\E abc$xyz abc followed by the
+ contents of $xyz
+ \Qabc\$xyz\E abc\$xyz abc\$xyz
+ \Qabc\E\$\Qxyz\E abc$xyz abc$xyz
+
+ In PCRE, the \Q...\E mechanism is not recognized inside a
+ character class.
+
+ 8. Fairly obviously, PCRE does not support the (?{code}) and
(?p{code}) constructions. However, there is some experimen-
- tal support for recursive patterns using the non-Perl item
- (?R).
-
- 8. There are at the time of writing some oddities in Perl
- 5.005_02 concerned with the settings of captured strings
- when part of a pattern is repeated. For example, matching
- "aba" against the pattern /^(a(b)?)+$/ sets $2 to the value
- "b", but matching "aabbaa" against /^(aa(bb)?)+$/ leaves $2
- unset. However, if the pattern is changed to
- /^(aa(b(b))?)+$/ then $2 (and $3) are set.
-
- In Perl 5.004 $2 is set in both cases, and that is also true
- of PCRE. If in the future Perl changes to a consistent state
- that is different, PCRE may change to follow.
-
- 9. Another as yet unresolved discrepancy is that in Perl
- 5.005_02 the pattern /^(a)?(?(1)a|b)+$/ matches the string
- "a", whereas in PCRE it does not. However, in both Perl and
- PCRE /^(a)?a/ matched against "a" leaves $1 unset.
+ tal support for recursive patterns using the non-Perl items
+ (?R), (?number) and (?P>name). Also, the PCRE "callout"
+ feature allows an external function to be called during pat-
+ tern matching.
+
+ 9. There are some differences that are concerned with the
+ settings of captured strings when part of a pattern is
+ repeated. For example, matching "aba" against the pattern
+ /^(a(b)?)+$/ in Perl leaves $2 unset, but in PCRE it is set
+ to "b".
10. PCRE provides some extensions to the Perl regular
expression facilities:
(a) Although lookbehind assertions must match fixed length
strings, each alternative branch of a lookbehind assertion
- can match a different length of string. Perl 5.005 requires
- them all to have the same length.
+ can match a different length of string. Perl requires them
+ all to have the same length.
(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not
- set, the $ meta- character matches only at the very end of
+ set, the $ meta-character matches only at the very end of
the string.
(c) If PCRE_EXTRA is set, a backslash followed by a letter
@@ -869,32 +1540,52 @@ DIFFERENCES FROM PERL
not greedy, but if followed by a question mark they are.
(e) PCRE_ANCHORED can be used to force a pattern to be tried
- only at the start of the subject.
+ only at the first matching position in the subject string.
+
+ (f) The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, and
+ PCRE_NO_AUTO_CAPTURE options for pcre_exec() have no Perl
+ equivalents.
+
+ (g) The (?R), (?number), and (?P>name) constructs allows for
+ recursive pattern matching (Perl can do this using the
+ (?p{code}) construct, which PCRE cannot support.)
+
+ (h) PCRE supports named capturing substrings, using the
+ Python syntax.
- (f) The PCRE_NOTBOL, PCRE_NOTEOL, and PCRE_NOTEMPTY options
- for pcre_exec() have no Perl equivalents.
+ (i) PCRE supports the possessive quantifier "++" syntax,
+ taken from Sun's Java package.
- (g) The (?R) construct allows for recursive pattern matching
- (Perl 5.6 can do this using the (?p{code}) construct, which
- PCRE cannot of course support.)
+ (j) The (R) condition, for testing recursion, is a PCRE
+ extension.
+ (k) The callout facility is PCRE-specific.
+Last updated: 03 February 2003
+Copyright (c) 1997-2003 University of Cambridge.
+-----------------------------------------------------------------------------
+
+NAME
+ PCRE - Perl-compatible regular expressions
+
+
+PCRE REGULAR EXPRESSION DETAILS
-REGULAR EXPRESSION DETAILS
The syntax and semantics of the regular expressions sup-
ported by PCRE are described below. Regular expressions are
also described in the Perl documentation and in a number of
other books, some of which have copious examples. Jeffrey
Friedl's "Mastering Regular Expressions", published by
- O'Reilly (ISBN 1-56592-257), covers them in great detail.
+ O'Reilly, covers them in great detail. The description here
+ is intended as reference documentation.
- The description here is intended as reference documentation.
The basic operation of PCRE is on strings of bytes. However,
- there is the beginnings of some support for UTF-8 character
- strings. To use this support you must configure PCRE to
- include it, and then call pcre_compile() with the PCRE_UTF8
- option. How this affects the pattern matching is described
- in the final section of this document.
+ there is also support for UTF-8 character strings. To use
+ this support you must build PCRE to include UTF-8 support,
+ and then call pcre_compile() with the PCRE_UTF8 option. How
+ this affects the pattern matching is mentioned in several
+ places below. There is also a summary of UTF-8 features in
+ the section on UTF-8 support in the main pcre page.
A regular expression is a pattern that is matched against a
subject string from left to right. Most characters stand for
@@ -916,9 +1607,8 @@ REGULAR EXPRESSION DETAILS
Outside square brackets, the meta-characters are as follows:
\ general escape character with several uses
- ^ assert start of subject (or line, in multiline
- mode)
- $ assert end of subject (or line, in multiline mode)
+ ^ assert start of string (or line, in multiline mode)
+ $ assert end of string (or line, in multiline mode)
. match any character except newline (by default)
[ start character class definition
| start of alternative branch
@@ -929,6 +1619,7 @@ REGULAR EXPRESSION DETAILS
also quantifier minimizer
* 0 or more quantifier
+ 1 or more quantifier
+ also "possessive quantifier"
{ start min/max quantifier
Part of a pattern that is in square brackets is called a
@@ -938,35 +1629,55 @@ REGULAR EXPRESSION DETAILS
\ general escape character
^ negate the class, but only if the first character
- indicates character range
+ [ POSIX character class (only if followed by POSIX
+ syntax)
] terminates the character class
The following sections describe the use of each of the
meta-characters.
-
BACKSLASH
+
The backslash character has several uses. Firstly, if it is
followed by a non-alphameric character, it takes away any
special meaning that character may have. This use of
-
backslash as an escape character applies both inside and
outside character classes.
- For example, if you want to match a "*" character, you write
- "\*" in the pattern. This applies whether or not the follow-
- ing character would otherwise be interpreted as a meta-
- character, so it is always safe to precede a non-alphameric
- with "\" to specify that it stands for itself. In particu-
- lar, if you want to match a backslash, you write "\\".
+ For example, if you want to match a * character, you write
+ \* in the pattern. This escaping action applies whether or
+ not the following character would otherwise be interpreted
+ as a meta-character, so it is always safe to precede a non-
+ alphameric with backslash to specify that it stands for
+ itself. In particular, if you want to match a backslash, you
+ write \\.
If a pattern is compiled with the PCRE_EXTENDED option, whi-
tespace in the pattern (other than in a character class) and
- characters between a "#" outside a character class and the
+ characters between a # outside a character class and the
next newline character are ignored. An escaping backslash
- can be used to include a whitespace or "#" character as part
+ can be used to include a whitespace or # character as part
of the pattern.
+ If you want to remove the special meaning from a sequence of
+ characters, you can do so by putting them between \Q and \E.
+ This is different from Perl in that $ and @ are handled as
+ literals in \Q...\E sequences in PCRE, whereas in Perl, $
+ and @ cause variable interpolation. Note the following exam-
+ ples:
+
+ Pattern PCRE matches Perl matches
+
+ \Qabc$xyz\E abc$xyz abc followed by the
+
+ contents of $xyz
+ \Qabc\$xyz\E abc\$xyz abc\$xyz
+ \Qabc\E\$\Qxyz\E abc$xyz abc$xyz
+
+ The \Q...\E sequence is recognized both inside and outside
+ character classes.
+
A second use of backslash provides a way of encoding non-
printing characters in patterns in a visible manner. There
is no restriction on the appearance of non-printing charac-
@@ -975,30 +1686,44 @@ BACKSLASH
usually easier to use one of the following escape sequences
than the binary character it represents:
- \a alarm, that is, the BEL character (hex 07)
- \cx "control-x", where x is any character
- \e escape (hex 1B)
- \f formfeed (hex 0C)
- \n newline (hex 0A)
- \r carriage return (hex 0D)
- \t tab (hex 09)
- \xhh character with hex code hh
- \ddd character with octal code ddd, or backreference
-
- The precise effect of "\cx" is as follows: if "x" is a lower
+ \a alarm, that is, the BEL character (hex 07)
+ \cx "control-x", where x is any character
+ \e escape (hex 1B)
+ \f formfeed (hex 0C)
+ \n newline (hex 0A)
+ \r carriage return (hex 0D)
+ \t tab (hex 09)
+ \ddd character with octal code ddd, or backreference
+ \xhh character with hex code hh
+ \x{hhh..} character with hex code hhh... (UTF-8 mode only)
+
+ The precise effect of \cx is as follows: if x is a lower
case letter, it is converted to upper case. Then bit 6 of
- the character (hex 40) is inverted. Thus "\cz" becomes hex
- 1A, but "\c{" becomes hex 3B, while "\c;" becomes hex 7B.
-
- After "\x", up to two hexadecimal digits are read (letters
- can be in upper or lower case).
-
- After "\0" up to two further octal digits are read. In both
+ the character (hex 40) is inverted. Thus \cz becomes hex
+ 1A, but \c{ becomes hex 3B, while \c; becomes hex 7B.
+
+ After \x, from zero to two hexadecimal digits are read
+ (letters can be in upper or lower case). In UTF-8 mode, any
+ number of hexadecimal digits may appear between \x{ and },
+ but the value of the character code must be less than 2**31
+ (that is, the maximum hexadecimal value is 7FFFFFFF). If
+ characters other than hexadecimal digits appear between \x{
+ and }, or if there is no terminating }, this form of escape
+ is not recognized. Instead, the initial \x will be inter-
+ preted as a basic hexadecimal escape, with no following
+ digits, giving a byte whose value is zero.
+
+ Characters whose value is less than 256 can be defined by
+ either of the two syntaxes for \x when PCRE is in UTF-8
+ mode. There is no difference in the way they are handled.
+ For example, \xdc is exactly the same as \x{dc}.
+
+ After \0 up to two further octal digits are read. In both
cases, if there are fewer than two digits, just those that
- are present are used. Thus the sequence "\0\x\07" specifies
- two binary zeros followed by a BEL character. Make sure you
- supply two digits after the initial zero if the character
- that follows is itself an octal digit.
+ are present are used. Thus the sequence \0\x\07 specifies
+ two binary zeros followed by a BEL character (code value 7).
+ Make sure you supply two digits after the initial zero if
+ the character that follows is itself an octal digit.
The handling of a backslash followed by a digit other than 0
is complicated. Outside a character class, PCRE reads it
@@ -1024,9 +1749,10 @@ BACKSLASH
writing a tab
\011 is always a tab
\0113 is a tab followed by the character "3"
- \113 is the character with octal code 113 (since there
- can be no more than 99 back references)
- \377 is a byte consisting entirely of 1 bits
+ \113 might be a back reference, otherwise the
+ character with octal code 113
+ \377 might be a back reference, otherwise
+ the byte consisting entirely of 1 bits
\81 is either a back reference, or a binary zero
followed by the two characters "8" and "1"
@@ -1034,11 +1760,12 @@ BACKSLASH
duced by a leading zero, because no more than three octal
digits are ever read.
- All the sequences that define a single byte value can be
- used both inside and outside character classes. In addition,
- inside a character class, the sequence "\b" is interpreted
- as the backspace character (hex 08). Outside a character
- class it has a different meaning (see below).
+ All the sequences that define a single byte value or a sin-
+ gle UTF-8 character (in UTF-8 mode) can be used both inside
+ and outside character classes. In addition, inside a charac-
+ ter class, the sequence \b is interpreted as the backspace
+ character (hex 08). Outside a character class it has a dif-
+ ferent meaning (see below).
The third use of backslash is for specifying generic charac-
ter types:
@@ -1048,20 +1775,28 @@ BACKSLASH
\s any whitespace character
\S any character that is not a whitespace character
\w any "word" character
- \W any "non-word" character
+ W any "non-word" character
Each pair of escape sequences partitions the complete set of
characters into two disjoint sets. Any given character
matches one, and only one, of each pair.
+ In UTF-8 mode, characters with values greater than 255 never
+ match \d, \s, or \w, and always match \D, \S, and \W.
+
+ For compatibility with Perl, \s does not match the VT char-
+ acter (code 11). This makes it different from the the POSIX
+ "space" class. The \s characters are HT (9), LF (10), FF
+ (12), CR (13), and space (32).
+
A "word" character is any letter or digit or the underscore
character, that is, any character which can be part of a
Perl "word". The definition of letters and digits is con-
trolled by PCRE's character tables, and may vary if locale-
- specific matching is taking place (see "Locale support"
- above). For example, in the "fr" (French) locale, some char-
- acter codes greater than 128 are used for accented letters,
- and these are matched by \w.
+ specific matching is taking place (see "Locale support" in
+ the pcreapi page). For example, in the "fr" (French) locale,
+ some character codes greater than 128 are used for accented
+ letters, and these are matched by \w.
These character type sequences can appear both inside and
outside character classes. They each match one character of
@@ -1076,15 +1811,15 @@ BACKSLASH
for more complicated assertions is described below. The
backslashed assertions are
- \b word boundary
- \B not a word boundary
- \A start of subject (independent of multiline mode)
- \Z end of subject or newline at end (independent of
- multiline mode)
- \z end of subject (independent of multiline mode)
+ \b matches at a word boundary
+ \B matches when not at a word boundary
+ \A matches at start of subject
+ \Z matches at end of subject or before newline at end
+ \z matches at end of subject
+ \G matches at first matching position in subject
These assertions may not appear in character classes (but
- note that "\b" has a different meaning, namely the backspace
+ note that \b has a different meaning, namely the backspace
character, inside a character class).
A word boundary is a position in the subject string where
@@ -1092,27 +1827,51 @@ BACKSLASH
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.
-
The \A, \Z, and \z assertions differ from the traditional
circumflex and dollar (described below) in that they only
ever match at the very start and end of the subject string,
- whatever options are set. They are not affected by the
- PCRE_NOTBOL or PCRE_NOTEOL options. If the startoffset argu-
- ment of pcre_exec() is non-zero, \A can never match. The
+ whatever options are set. Thus, they are independent of mul-
+ tiline mode.
+
+ They are not affected by the PCRE_NOTBOL or PCRE_NOTEOL
+ options. If the startoffset argument of pcre_exec() 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 that is the last character of the string as well as
at the end of the string, 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 pcre_exec(). It differs from \A
+ when the value of startoffset is non-zero. By calling
+ pcre_exec() multiple times with appropriate arguments, you
+ can mimic Perl's /g option, and it is in this kind of imple-
+ mentation where \G can be useful.
+
+ Note, however, that PCRE'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 PCRE 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 anchored to the starting match position, and
+ the "anchored" flag is set in the compiled regular expres-
+ sion.
CIRCUMFLEX AND DOLLAR
+
Outside a character class, in the default matching mode, the
circumflex character is an assertion which is true only if
the current matching point is at the start of the subject
string. If the startoffset argument of pcre_exec() is non-
- zero, circumflex can never match. Inside a character class,
- circumflex has an entirely different meaning (see below).
+ zero, circumflex can never match if the PCRE_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
@@ -1134,19 +1893,19 @@ CIRCUMFLEX AND DOLLAR
The meaning of dollar can be changed so that it matches only
at the very end of the string, by setting the
- PCRE_DOLLAR_ENDONLY option at compile or matching time. This
- does not affect the \Z assertion.
+ PCRE_DOLLAR_ENDONLY option at compile time. This does not
+ affect the \Z assertion.
The meanings of the circumflex and dollar characters are
changed if the PCRE_MULTILINE option is set. When this is
the case, they match immediately after and immediately
- before an internal "\n" character, respectively, in addition
- to matching at the start and end of the subject string. For
- example, the pattern /^abc$/ matches the subject string
+ before an internal newline character, respectively, in addi-
+ tion to matching at the start and end of the subject string.
+ For example, the pattern /^abc$/ matches the subject string
"def\nabc" in multiline mode, but not otherwise. Conse-
quently, patterns that are anchored in single line mode
- because all branches start with "^" are not anchored in mul-
- tiline mode, and a match for circumflex is possible when the
+ because all branches start with ^ are not anchored in multi-
+ line mode, and a match for circumflex is possible when the
startoffset argument of pcre_exec() is non-zero. The
PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is
set.
@@ -1157,20 +1916,38 @@ CIRCUMFLEX AND DOLLAR
whether PCRE_MULTILINE is set or not.
-
FULL STOP (PERIOD, DOT)
+
Outside a character class, a dot in the pattern matches any
one character in the subject, including a non-printing char-
- acter, but not (by default) newline. If the PCRE_DOTALL
- option is set, dots match newlines as well. The handling of
- dot is entirely independent of the handling of circumflex
- and dollar, the only relationship being that they both
- involve newline characters. Dot has no special meaning in a
- character class.
+ acter, but not (by default) newline. In UTF-8 mode, a dot
+ matches any UTF-8 character, which might be more than one
+ byte long, except (by default) for newline. If the
+ PCRE_DOTALL option is set, dots match newlines as well. The
+ handling of dot is entirely independent of the handling of
+ circumflex and dollar, the only relationship being that they
+ both involve newline characters. Dot has no special meaning
+ in a character class.
+MATCHING A SINGLE BYTE
+
+ Outside a character class, the escape sequence \C matches
+ any one byte, both in and out of UTF-8 mode. Unlike a dot,
+ it always matches a newline. The feature is provided in Perl
+ in order to match individual bytes in UTF-8 mode. Because
+ it breaks up UTF-8 characters into individual bytes, what
+ remains in the string may be a malformed UTF-8 string. For
+ this reason it is best avoided.
+
+ PCRE does not allow \C to appear in lookbehind assertions
+ (see below), because in UTF-8 mode it makes it impossible to
+ calculate the length of the lookbehind.
+
+
SQUARE BRACKETS
+
An opening square bracket introduces a character class, ter-
minated by a closing square bracket. A closing square
bracket on its own is not special. If a closing square
@@ -1178,13 +1955,14 @@ SQUARE BRACKETS
the first data character in the class (after an initial cir-
cumflex, if present) or escaped with a backslash.
- A character class matches a single character in the subject;
- the character must be in the set of characters defined by
- the class, unless the first character in the class is a cir-
- cumflex, 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 it is not the
- first character, or escape it with a backslash.
+ A character class matches a single character in the subject.
+ In UTF-8 mode, the character may occupy more than one byte.
+ A matched character must be in the set of characters defined
+ by the class, unless the first character in the class defin-
+ ition 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 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
@@ -1195,12 +1973,16 @@ SQUARE BRACKETS
string, and fails if the current pointer is at the end of
the string.
+ In UTF-8 mode, characters with values greater than 255 can
+ be included in a class as a literal string of bytes, or by
+ using the \x{ escaping mechanism.
+
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 case-
- ful version would.
-
+ ful version would. PCRE does not support the concept of case
+ for characters with values greater than 255.
The newline character is never treated in any special way in
character classes, whatever the setting of the PCRE_DOTALL
or PCRE_MULTILINE options is. A class such as [^a] will
@@ -1224,14 +2006,18 @@ SQUARE BRACKETS
separate characters. The octal or hexadecimal representation
of "]" can also be used to end a range.
- Ranges operate in ASCII collating sequence. They can also be
- used for characters specified numerically, for example
- [\000-\037]. 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 if character tables for the "fr"
- locale are in use, [\xc8-\xcb] matches accented E characters
- in both cases.
+ Ranges operate in the collating sequence of character
+ values. They can also be used for characters specified
+ numerically, for example [\000-\037]. In UTF-8 mode, ranges
+ can include characters whose values are greater than 255,
+ for example [\x{100}-\x{2ff}].
+
+ 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 if character tables for the "fr" locale are
+ in use, [\xc8-\xcb] matches accented E characters in both
+ cases.
The character types \d, \D, \s, \S, \w, and \W may also
appear in a character class, and add the characters that
@@ -1247,12 +2033,12 @@ SQUARE BRACKETS
classes, but it does no harm if they are escaped.
-
POSIX CHARACTER CLASSES
- Perl 5.6 (not yet released at the time of writing) is going
- to support the POSIX notation for character classes, which
- uses names enclosed by [: and :] within the enclosing
- square brackets. PCRE supports this notation. For example,
+
+ Perl supports the POSIX notation for character classes,
+ which uses names enclosed by [: and :] within the enclosing
+ square brackets. PCRE also supports this notation. For exam-
+ ple,
[01[:alpha:]%]
@@ -1262,20 +2048,28 @@ POSIX CHARACTER CLASSES
alnum letters and digits
alpha letters
ascii character codes 0 - 127
+ blank space or tab only
cntrl control characters
digit decimal digits (same as \d)
graph printing characters, excluding space
lower lower case letters
print printing characters, including space
punct printing characters, excluding letters and digits
- space white space (same as \s)
+ space white space (not quite the same as \s)
upper upper case letters
word "word" characters (same as \w)
xdigit hexadecimal digits
- The names "ascii" and "word" are Perl extensions. Another
- Perl extension is negation, which is indicated by a ^ char-
- acter after the colon. For example,
+ The "space" characters are HT (9), LF (10), VT (11), FF
+ (12), CR (13), and space (32). Notice that this list
+ includes the VT character (code 11). This makes "space" dif-
+ ferent to \s, which does not include VT (for Perl compati-
+ bility).
+
+ 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:]]
@@ -1284,9 +2078,12 @@ POSIX CHARACTER CLASSES
"collating element", but these are not supported, and an
error is given if they are encountered.
+ In UTF-8 mode, characters with values greater than 255 do
+ not match any of the POSIX character classes.
VERTICAL BAR
+
Vertical bar characters are used to separate alternative
patterns. For example, the pattern
@@ -1302,12 +2099,12 @@ VERTICAL BAR
subpattern.
-
INTERNAL OPTION SETTING
- The settings of PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL,
- and PCRE_EXTENDED can be changed from within the pattern by
- a sequence of Perl option letters enclosed between "(?" and
- ")". The option letters are
+
+ The settings of the PCRE_CASELESS, PCRE_MULTILINE,
+ PCRE_DOTALL, and PCRE_EXTENDED options can be changed from
+ within the pattern by a sequence of Perl option letters
+ enclosed between "(?" and ")". The option letters are
i for PCRE_CASELESS
m for PCRE_MULTILINE
@@ -1322,28 +2119,15 @@ INTERNAL OPTION SETTING
If a letter appears both before and after the hyphen, the
option is unset.
- The scope of these option changes depends on where in the
- pattern the setting occurs. For settings that are outside
- any subpattern (defined below), the effect is the same as if
- the options were set or unset at the start of matching. The
- following patterns all behave in exactly the same way:
-
- (?i)abc
- a(?i)bc
- ab(?i)c
- abc(?i)
-
- which in turn is the same as compiling the pattern abc with
- PCRE_CASELESS set. In other words, such "top level" set-
- tings apply to the whole pattern (unless there are other
- changes inside subpatterns). If there is more than one set-
- ting of the same option at top level, the rightmost setting
- is used.
-
- If an option change occurs inside a subpattern, the effect
- is different. This is a change of behaviour in Perl 5.005.
- An option change inside a subpattern affects only that part
- of the subpattern that follows it, so
+ When an option change 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, PCRE extracts it
+ into the global options (and it will therefore show up in
+ data extracted by the pcre_fullinfo() function).
+
+ An option change within a subpattern affects only that part
+ of the current pattern that follows it, so
(a(?i)b)c
@@ -1370,8 +2154,8 @@ INTERNAL OPTION SETTING
even when it is at top level. It is best put at the start.
-
SUBPATTERNS
+
Subpatterns are delimited by parentheses (round brackets),
which can be nested. Marking part of a pattern as a subpat-
tern does two things:
@@ -1404,18 +2188,18 @@ SUBPATTERNS
The fact that plain parentheses fulfil two functions is not
always helpful. There are often times when a grouping sub-
pattern is required without a capturing requirement. If an
- opening parenthesis is followed by "?:", the subpattern does
- not do any capturing, 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 pat-
- tern
+ opening parenthesis is followed by a question mark and a
+ colon, the subpattern does not do any capturing, and is not
+ counted when computing the number of any subsequent captur-
+ ing subpatterns. For example, if the string "the white
+ queen" is matched against the pattern
the ((?:red|white) (king|queen))
the captured substrings are "white queen" and "queen", and
- are numbered 1 and 2. The maximum number of captured sub-
- strings is 99, and the maximum number of all subpatterns,
- both capturing and non-capturing, is 200.
+ are numbered 1 and 2. The maximum number of capturing sub-
+ patterns is 65535, and the maximum depth of nesting of all
+ subpatterns, both capturing and non-capturing, is 200.
As a convenient shorthand, if any option settings are
required at the start of a non-capturing subpattern, the
@@ -1432,17 +2216,36 @@ SUBPATTERNS
the above patterns match "SUNDAY" as well as "Saturday".
+NAMED SUBPATTERNS
+
+ Identifying capturing parentheses by number is simple, but
+ it can be very hard to keep track of the numbers in compli-
+ cated regular expressions. Furthermore, if an expression is
+ modified, the numbers may change. To help with the diffi-
+ culty, PCRE supports the naming of subpatterns, something
+ that Perl does not provide. The Python syntax (?P<name>...)
+ is used. Names consist of alphanumeric characters and under-
+ scores, and must be unique within a pattern.
+
+ Named capturing parentheses are still allocated numbers as
+ well as names. The PCRE API provides function calls for
+ extracting the name-to-number translation table from a com-
+ piled pattern. For further details see the pcreapi documen-
+ tation.
+
REPETITION
+
Repetition is specified by quantifiers, which can follow any
of the following items:
- a single character, possibly escaped
+ a literal data character
the . metacharacter
+ the \C escape sequence
+ escapes such as \d that match single characters
a character class
a back reference (see next section)
- a parenthesized subpattern (unless it is an assertion -
- see below)
+ a parenthesized subpattern (unless it is an assertion)
The general repetition quantifier specifies a minimum and
maximum number of permitted matches, by giving the two
@@ -1470,6 +2273,12 @@ REPETITION
one that does not match the syntax of a quantifier, is taken
as a literal character. For example, {,6} is not a quantif-
ier, but a literal string of four characters.
+
+ In UTF-8 mode, quantifiers apply to UTF-8 characters rather
+ than to individual bytes. Thus, for example, \x{100}{2}
+ matches two UTF-8 characters, each of which is represented
+ by a two-byte sequence.
+
The quantifier {0} is permitted, causing the expression to
behave as if the previous item and the quantifier were not
present.
@@ -1539,18 +2348,31 @@ REPETITION
repeat count that is greater than 1 or with a limited max-
imum, more store is required for the compiled pattern, in
proportion to the size of the minimum or maximum.
-
If a pattern starts with .* or .{0,} and the PCRE_DOTALL
option (equivalent to Perl's /s) is set, thus allowing the .
to match newlines, the pattern is implicitly anchored,
because whatever follows will be tried against every charac-
ter position in the subject string, so there is no point in
retrying the overall match at any position after the first.
- PCRE treats such a pattern as though it were preceded by \A.
- In cases where it is known that the subject string contains
- no newlines, it is worth setting PCRE_DOTALL when the pat-
- tern begins with .* in order to obtain this optimization, or
- alternatively using ^ to indicate anchoring explicitly.
+ PCRE normally treats such a pattern as though it were pre-
+ ceded by \A.
+
+ In cases where it is known that the subject string contains
+ no newlines, it is worth setting PCRE_DOTALL in order to
+ obtain this optimization, or alternatively using ^ to indi-
+ cate anchoring explicitly.
+
+ However, there is one situation where the optimization can-
+ not be used. When .* is inside capturing parentheses that
+ are the subject of a backreference elsewhere in the pattern,
+ a match at the start may fail, and a later one succeed. Con-
+ sider, for example:
+
+ (.*)abc\1
+
+ If the subject is "xyz123abc123" the match point is the
+ fourth character. For this reason, such a pattern is not
+ implicitly anchored.
When a capturing subpattern is repeated, the value captured
is the substring that matched the final iteration. For exam-
@@ -1570,19 +2392,110 @@ REPETITION
"b".
+ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS
-BACK REFERENCES
- Outside a character class, a backslash followed by a digit
- greater than 0 (and possibly further digits) is a back
+ With both maximizing and minimizing repetition, failure of
+ what follows normally causes the repeated item to be re-
+ evaluated to see if a different number of repeats allows the
+ rest of the pattern to match. Sometimes it is useful to
+ prevent this, either to change the nature of the match, or
+ to cause it fail earlier than it otherwise might, when the
+ author of the pattern knows there is no point in carrying
+ on.
+
+ Consider, for example, the pattern \d+foo when applied to
+ the subject line
+
+ 123456bar
+
+ After matching all 6 digits and then failing to match "foo",
+ the normal action of the matcher is to try again with only 5
+ digits matching the \d+ item, and then with 4, and so on,
+ before ultimately failing. "Atomic grouping" (a term taken
+ from Jeffrey Friedl's book) provides the means for specify-
+ ing that once a subpattern has matched, it is not to be re-
+ evaluated in this way.
+
+ If we use atomic grouping for the previous example, the
+ matcher would give up immediately on failing to match "foo"
+ the first time. The notation is a kind of special
+ parenthesis, starting with (?> as in this example:
+
+ (?>\d+)bar
+
+ This kind of parenthesis "locks up" the part of the pattern
+ it contains once it has matched, and a failure further into
+ the pattern is prevented from backtracking into it. Back-
+ tracking past it to previous items, however, works as nor-
+ mal.
+
+ An alternative description is that a subpattern of this type
+ matches the string of characters that an identical stan-
+ dalone pattern would match, if anchored at the current point
+ in the subject string.
+
+ Atomic grouping subpatterns are not capturing subpatterns.
+ Simple cases such as the above example can be thought of as
+ a maximizing repeat that must swallow everything it can. So,
+ while both \d+ and \d+? are prepared to adjust the number of
+ digits they match in order to make the rest of the pattern
+ match, (?>\d+) can only match an entire sequence of digits.
+ Atomic groups in general can of course contain arbitrarily
+ complicated subpatterns, and can be nested. However, when
+ the subpattern for an atomic group is just a single repeated
+ item, as in the example above, a simpler notation, called a
+ "possessive quantifier" can be used. This consists of an
+ additional + character following a quantifier. Using this
+ notation, the previous example can be rewritten as
+ \d++bar
+ Possessive quantifiers are always greedy; the setting of the
+ PCRE_UNGREEDY option is ignored. They are a convenient nota-
+ tion for the simpler forms of atomic group. However, there
+ is no difference in the meaning or processing of a posses-
+ sive quantifier and the equivalent atomic group.
-SunOS 5.8 Last change: 30
+ The possessive quantifier syntax is an extension to the Perl
+ syntax. It originates in Sun's Java package.
+ When a pattern contains an unlimited repeat inside a subpat-
+ tern that can itself be repeated an unlimited number of
+ times, the use of an atomic group is the only way to avoid
+ some failing matches taking a very long time indeed. The
+ pattern
+
+ (\D+|<\d+>)*[!?]
+
+ matches an unlimited number of substrings that either con-
+ sist of non-digits, or digits enclosed in <>, followed by
+ either ! or ?. When it matches, it runs quickly. However, if
+ it is applied to
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- reference to a capturing subpattern earlier (i.e. to its
+ it takes a long time before reporting failure. This is
+ because the string can be divided between the two repeats in
+ a large number of ways, and all have to be tried. (The exam-
+ ple used [!?] rather than a single character at the end,
+ because both PCRE and Perl have an optimization that allows
+ for fast failure when a single character is used. They
+ remember the last single character that is required for a
+ match, and fail early if it is not present in the string.)
+ If the pattern is changed to
+
+ ((?>\D+)|<\d+>)*[!?]
+
+ sequences of non-digits cannot be broken, and failure hap-
+ pens quickly.
+
+
+BACK REFERENCES
+
+ Outside a character class, a backslash followed by a digit
+ greater than 0 (and possibly further digits) is a back
+ reference to a capturing subpattern earlier (that is, to its
left) in the pattern, provided there have been that many
previous capturing left parentheses.
@@ -1597,7 +2510,8 @@ SunOS 5.8 Last change: 30
A back reference matches whatever actually matched the cap-
turing subpattern in the current subject string, rather than
- anything matching the subpattern itself. So the pattern
+ anything matching the subpattern itself (see "Subpatterns as
+ subroutines" below for a way of doing that). So the pattern
(sens|respons)e and \1ibility
@@ -1612,6 +2526,11 @@ SunOS 5.8 Last change: 30
though the original capturing subpattern is matched case-
lessly.
+ Back references to named subpatterns use the Python syntax
+ (?P=name). We could rewrite the above example as follows:
+
+ (?<p1>(?i)rah)\s+(?P=p1)
+
There may be more than one back reference to the same sub-
pattern. If a subpattern has not actually been used in a
particular match, any back references to it always fail. For
@@ -1620,12 +2539,13 @@ SunOS 5.8 Last change: 30
(a|(bc))\2
always fails if it starts to match "a" rather than "bc".
- Because there may be up to 99 back references, all digits
- following the backslash are taken as part of a potential
- back reference number. If the pattern continues with a digit
- character, some delimiter must be used to terminate the back
- reference. If the PCRE_EXTENDED option is set, this can be
- whitespace. Otherwise an empty comment can be used.
+ Because there may be many capturing parentheses in a pat-
+ tern, all digits following the backslash are taken as part
+ of a potential back reference number. If the pattern contin-
+ ues with a digit character, some delimiter must be used to
+ terminate the back reference. If the PCRE_EXTENDED option is
+ set, this can be whitespace. Otherwise an empty comment can
+ be used.
A back reference that occurs inside the parentheses to which
it refers fails when the subpattern is first used, so, for
@@ -1644,13 +2564,13 @@ SunOS 5.8 Last change: 30
example above, or by a quantifier with a minimum of zero.
-
ASSERTIONS
+
An assertion is a test on the characters following or
preceding the current matching point that does not actually
consume any characters. The simple assertions coded as \b,
- \B, \A, \Z, \z, ^ and $ are described above. More compli-
- cated assertions are coded as subpatterns. There are two
+ \B, \A, \G, \Z, \z, ^ and $ are described above. More com-
+ plicated assertions are coded as subpatterns. There are two
kinds: those that look ahead of the current position in the
subject string, and those that look behind it.
@@ -1677,6 +2597,11 @@ ASSERTIONS
when the next three characters are "bar". A lookbehind
assertion is needed to achieve this effect.
+ If you want to force a matching failure at some point in a
+ pattern, the most convenient way to do it is with (?!)
+ because an empty string always matches, so an assertion that
+ requires there not to be an empty string must always fail.
+
Lookbehind assertions start with (?<= for positive asser-
tions and (?<! for negative assertions. For example,
@@ -1697,8 +2622,8 @@ ASSERTIONS
causes an error at compile time. Branches that match dif-
ferent length strings are permitted only at the top level of
a lookbehind assertion. This is an extension compared with
- Perl 5.005, which requires all branches to match the same
- length of string. An assertion such as
+ Perl (at least for 5.8), which requires all branches to
+ match the same length of string. An assertion such as
(?<=ab(c|de))
@@ -1712,10 +2637,44 @@ ASSERTIONS
alternative, to temporarily move the current position back
by the fixed width and then try to match. If there are
insufficient characters before the current position, the
- match is deemed to fail. Lookbehinds in conjunction with
- once-only subpatterns can be particularly useful for match-
- ing at the ends of strings; an example is given at the end
- of the section on once-only subpatterns.
+ match is deemed to fail.
+
+ PCRE does not allow the \C escape (which matches a single
+ byte in UTF-8 mode) to appear in lookbehind assertions,
+ because it makes it impossible to calculate the length of
+ the lookbehind.
+
+ Atomic groups can be used in conjunction with lookbehind
+ assertions to specify efficient matching at the end of the
+ subject string. Consider a simple pattern such as
+
+ abcd$
+
+ when applied to a long string that does not match. Because
+ matching proceeds from left to right, PCRE will look for
+ each "a" in the subject and then see if what follows matches
+ the rest of the pattern. If the pattern is specified as
+
+ ^.*abcd$
+
+ the initial .* matches the entire string at first, but when
+ this fails (because there is no following "a"), it back-
+ tracks to match all but the last character, then all but the
+ last two characters, and so on. Once again the search for
+ "a" covers the entire string, from right to left, so we are
+ no better off. However, if the pattern is written as
+
+ ^(?>.*)(?<=abcd)
+
+ or, equivalently,
+
+ ^.*+(?<=abcd)
+
+ there can be no backtracking for the .* item; it can match
+ only the entire string. The subsequent lookbehind assertion
+ does a single test on the last four characters. If it fails,
+ the match fails immediately. For long strings, this approach
+ makes a significant difference to the processing time.
Several assertions (of any sort) may occur in succession.
For example,
@@ -1760,120 +2719,9 @@ ASSERTIONS
for positive assertions, because it does not make sense for
negative assertions.
- Assertions count towards the maximum of 200 parenthesized
- subpatterns.
-
-
-
-ONCE-ONLY SUBPATTERNS
- With both maximizing and minimizing repetition, failure of
- what follows normally causes the repeated item to be re-
- evaluated to see if a different number of repeats allows the
- rest of the pattern to match. Sometimes it is useful to
- prevent this, either to change the nature of the match, or
- to cause it fail earlier than it otherwise might, when the
- author of the pattern knows there is no point in carrying
- on.
-
- Consider, for example, the pattern \d+foo when applied to
- the subject line
-
- 123456bar
-
- After matching all 6 digits and then failing to match "foo",
- the normal action of the matcher is to try again with only 5
- digits matching the \d+ item, and then with 4, and so on,
- before ultimately failing. Once-only subpatterns provide the
- means for specifying that once a portion of the pattern has
- matched, it is not to be re-evaluated in this way, so the
- matcher would give up immediately on failing to match "foo"
- the first time. The notation is another kind of special
- parenthesis, starting with (?> as in this example:
-
- (?>\d+)bar
-
- This kind of parenthesis "locks up" the part of the pattern
- it contains once it has matched, and a failure further into
- the pattern is prevented from backtracking into it. Back-
- tracking past it to previous items, however, works as nor-
- mal.
-
- An alternative description is that a subpattern of this type
- matches the string of characters that an identical stan-
- dalone pattern would match, if anchored at the current point
- in the subject string.
-
- Once-only subpatterns are not capturing subpatterns. Simple
- cases such as the above example can be thought of as a max-
- imizing repeat that must swallow everything it can. So,
- while both \d+ and \d+? are prepared to adjust the number of
- digits they match in order to make the rest of the pattern
- match, (?>\d+) can only match an entire sequence of digits.
-
- This construction can of course contain arbitrarily compli-
- cated subpatterns, and it can be nested.
-
- Once-only subpatterns can be used in conjunction with look-
- behind assertions to specify efficient matching at the end
- of the subject string. Consider a simple pattern such as
-
- abcd$
-
- when applied to a long string which does not match. Because
- matching proceeds from left to right, PCRE will look for
- each "a" in the subject and then see if what follows matches
- the rest of the pattern. If the pattern is specified as
-
- ^.*abcd$
-
- the initial .* matches the entire string at first, but when
- this fails (because there is no following "a"), it back-
- tracks to match all but the last character, then all but the
- last two characters, and so on. Once again the search for
- "a" covers the entire string, from right to left, so we are
- no better off. However, if the pattern is written as
-
- ^(?>.*)(?<=abcd)
-
- there can be no backtracking for the .* item; it can match
- only the entire string. The subsequent lookbehind assertion
- does a single test on the last four characters. If it fails,
- the match fails immediately. For long strings, this approach
- makes a significant difference to the processing time.
-
- When a pattern contains an unlimited repeat inside a subpat-
- tern that can itself be repeated an unlimited number of
- times, the use of a once-only subpattern is the only way to
- avoid some failing matches taking a very long time indeed.
- The pattern
-
- (\D+|<\d+>)*[!?]
-
- matches an unlimited number of substrings that either con-
- sist of non-digits, or digits enclosed in <>, followed by
- either ! or ?. When it matches, it runs quickly. However, if
- it is applied to
-
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-
- it takes a long time before reporting failure. This is
- because the string can be divided between the two repeats in
- a large number of ways, and all have to be tried. (The exam-
- ple used [!?] rather than a single character at the end,
- because both PCRE and Perl have an optimization that allows
- for fast failure when a single character is used. They
- remember the last single character that is required for a
- match, and fail early if it is not present in the string.)
- If the pattern is changed to
-
- ((?>\D+)|<\d+>)*[!?]
-
- sequences of non-digits cannot be broken, and failure hap-
- pens quickly.
-
-
CONDITIONAL SUBPATTERNS
+
It is possible to cause the matching process to obey a sub-
pattern conditionally or to choose between two alternative
subpatterns, depending on the result of an assertion, or
@@ -1888,7 +2736,7 @@ CONDITIONAL SUBPATTERNS
more than two alternatives in the subpattern, a compile-time
error occurs.
- There are two kinds of condition. If the text between the
+ There are three kinds of condition. If the text between the
parentheses consists of a sequence of digits, the condition
is satisfied if the capturing subpattern of that number has
previously matched. The number must be greater than zero.
@@ -1912,11 +2760,17 @@ CONDITIONAL SUBPATTERNS
matches a sequence of non-parentheses, optionally enclosed
in parentheses.
- If the condition is not a sequence of digits, it must be an
- assertion. This may be a positive or negative lookahead or
- lookbehind assertion. Consider this pattern, again contain-
- ing non-significant white space, and with the two alterna-
- tives on the second line:
+ If the condition is the string (R), it is satisfied if a
+ recursive call to the pattern or subpattern has been made.
+ At "top level", the condition is false. This is a PCRE
+ extension. Recursive patterns are described in the next
+ section.
+
+ If the condition is not a sequence of digits or (R), it must
+ be an assertion. This may be a positive or negative looka-
+ head or lookbehind assertion. Consider this pattern, again
+ containing non-significant white space, and with the two
+ alternatives on the second line:
(?(?=[^a-z]*[a-z])
\d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} )
@@ -1931,8 +2785,8 @@ CONDITIONAL SUBPATTERNS
letters and dd are digits.
-
COMMENTS
+
The sequence (?# marks the start of a comment which contin-
ues up to the next closing parenthesis. Nested parentheses
are not permitted. The characters that make up a comment
@@ -1943,55 +2797,83 @@ COMMENTS
ues up to the next newline character in the pattern.
-
RECURSIVE PATTERNS
+
Consider the problem of matching a string in parentheses,
allowing for unlimited nested parentheses. Without the use
of recursion, the best that can be done is to use a pattern
that matches up to some fixed depth of nesting. It is not
- possible to handle an arbitrary nesting depth. Perl 5.6 has
- provided an experimental facility that allows regular
- expressions to recurse (amongst other things). It does this
- by interpolating Perl code in the expression at run time,
- and the code can refer to the expression itself. A Perl pat-
- tern to solve the parentheses problem can be created like
- this:
+ possible to handle an arbitrary nesting depth. Perl has pro-
+ vided an experimental facility that allows regular expres-
+ sions to recurse (amongst other things). It does this by
+ interpolating Perl code in the expression at run time, and
+ the code can refer to the expression itself. A Perl pattern
+ to solve the parentheses problem can be created like this:
$re = qr{\( (?: (?>[^()]+) | (?p{$re}) )* \)}x;
The (?p{...}) item interpolates Perl code at run time, and
in this case refers recursively to the pattern in which it
appears. Obviously, PCRE cannot support the interpolation of
- Perl code. Instead, the special item (?R) is provided for
- the specific case of recursion. This PCRE pattern solves the
- parentheses problem (assume the PCRE_EXTENDED option is set
- so that white space is ignored):
+ Perl code. Instead, it supports some special syntax for
+ recursion of the entire pattern, and also for individual
+ subpattern recursion.
+
+ The special item that consists of (? followed by a number
+ greater than zero and a closing parenthesis is a recursive
+ call of the subpattern of the given number, provided that it
+ occurs inside that subpattern. (If not, it is a "subroutine"
+ call, which is described in the next section.) The special
+ item (?R) is a recursive call of the entire regular expres-
+ sion.
+
+ For example, this PCRE pattern solves the nested parentheses
+ problem (assume the PCRE_EXTENDED option is set so that
+ white space is ignored):
\( ( (?>[^()]+) | (?R) )* \)
First it matches an opening parenthesis. Then it matches any
number of substrings which can either be a sequence of non-
parentheses, or a recursive match of the pattern itself
- (i.e. a correctly parenthesized substring). Finally there is
- a closing parenthesis.
+ (that is a correctly parenthesized substring). Finally
+ there is a closing parenthesis.
+
+ If this were part of a larger pattern, you would not want to
+ recurse the entire pattern, so instead you could use this:
+
+ ( \( ( (?>[^()]+) | (?1) )* \) )
+
+ We have put the pattern into parentheses, and caused the
+ recursion to refer to them instead of the whole pattern. In
+ a larger pattern, keeping track of parenthesis numbers can
+ be tricky. It may be more convenient to use named
+ parentheses instead. For this, PCRE uses (?P>name), which is
+ an extension to the Python syntax that PCRE uses for named
+ parentheses (Perl does not provide named parentheses). We
+ could rewrite the above example as follows:
+
+ (?<pn> \( ( (?>[^()]+) | (?P>pn) )* \) )
This particular example pattern contains nested unlimited
- repeats, and so the use of a once-only subpattern for match-
- ing strings of non-parentheses is important when applying
- the pattern to strings that do not match. For example, when
- it is applied to
+ repeats, and so the use of atomic grouping for matching
+ strings of non-parentheses is important when applying the
+ pattern to strings that do not match. For example, when this
+ pattern is applied to
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
- it yields "no match" quickly. However, if a once-only sub-
- pattern is not used, the match runs for a very long time
- indeed because there are so many different ways the + and *
- repeats can carve up the subject, and all have to be tested
- before failure can be reported.
-
- The values set for any capturing subpatterns are those from
- the outermost level of the recursion at which the subpattern
- value is set. If the pattern above is matched against
+ it yields "no match" quickly. However, if atomic grouping is
+ not used, the match runs for a very long time indeed because
+ there are so many different ways the + and * repeats can
+ carve up the subject, and all have to be tested before
+ failure can be reported.
+ At the end of a match, the values set for any capturing sub-
+ patterns are those from the outermost level of the recursion
+ at which the subpattern value is set. If you want to obtain
+ intermediate values, a callout function can be used (see
+ below and the pcrecallout documentation). If the pattern
+ above is matched against
(ab(cd)ef)
@@ -2001,41 +2883,120 @@ RECURSIVE PATTERNS
\( ( ( (?>[^()]+) | (?R) )* ) \)
^ ^
- ^ ^ the string they capture is
- "ab(cd)ef", the contents of the top level parentheses. If
- there are more than 15 capturing parentheses in a pattern,
- PCRE has to obtain extra memory to store data during a
- recursion, which it does by using pcre_malloc, freeing it
- via pcre_free afterwards. If no memory can be obtained, it
- saves data for the first 15 capturing parentheses only, as
- there is no way to give an out-of-memory error from within a
- recursion.
-
-
-
-PERFORMANCE
- Certain items that may appear in patterns are more efficient
- than others. It is more efficient to use a character class
- like [aeiou] than a set of alternatives such as (a|e|i|o|u).
- In general, the simplest construction that provides the
- required behaviour is usually the most efficient. Jeffrey
- Friedl's book contains a lot of discussion about optimizing
- regular expressions for efficient performance.
-
- When a pattern begins with .* and the PCRE_DOTALL option is
- set, the pattern is implicitly anchored by PCRE, since it
- can match only at the start of a subject string. However, if
- PCRE_DOTALL is not set, PCRE cannot make this optimization,
- because the . metacharacter does not then match a newline,
- and if the subject string contains newlines, the pattern may
- match from the character immediately following one of them
- instead of from the very start. For example, the pattern
-
- (.*) second
+ ^ ^
+
+ the string they capture is "ab(cd)ef", the contents of the
+ top level parentheses. If there are more than 15 capturing
+ parentheses in a pattern, PCRE has to obtain extra memory to
+ store data during a recursion, which it does by using
+ pcre_malloc, freeing it via pcre_free afterwards. If no
+ memory can be obtained, the match fails with the
+ PCRE_ERROR_NOMEMORY error.
+
+ Do not confuse the (?R) item with the condition (R), which
+ tests for recursion. Consider this pattern, which matches
+ text in angle brackets, allowing for arbitrary nesting. Only
+ digits are allowed in nested brackets (that is, when recurs-
+ ing), whereas any characters are permitted at the outer
+ level.
+
+ < (?: (?(R) \d++ | [^<>]*+) | (?R)) * >
+
+ In this pattern, (?(R) is the start of a conditional subpat-
+ tern, with two different alternatives for the recursive and
+ non-recursive cases. The (?R) item is the actual recursive
+ call.
+
+
+SUBPATTERNS AS SUBROUTINES
+
+ If the syntax for a recursive subpattern reference (either
+ by number or by name) is used outside the parentheses to
+ which it refers, it operates like a subroutine in a program-
+ ming language. An earlier example pointed out that the pat-
+ tern
+
+ (sens|respons)e and \1ibility
+
+ matches "sense and sensibility" and "response and responsi-
+ bility", but not "sense and responsibility". If instead the
+ pattern
+
+ (sens|respons)e and (?1)ibility
+
+ is used, it does match "sense and responsibility" as well as
+ the other two strings. Such references must, however, follow
+ the subpattern to which they refer.
+
+
+CALLOUTS
+
+ Perl has a feature whereby using the sequence (?{...})
+ causes arbitrary Perl code to be obeyed in the middle of
+ matching a regular expression. This makes it possible,
+ amongst other things, to extract different substrings that
+ match the same pair of parentheses when there is a repeti-
+ tion.
+
+ PCRE provides a similar feature, but of course it cannot
+ obey arbitrary Perl code. The feature is called "callout".
+ The caller of PCRE provides an external function by putting
+ its entry point in the global variable pcre_callout. By
+ default, this variable contains NULL, which disables all
+ calling out.
+
+ Within a regular expression, (?C) indicates the points at
+ which the external function is to be called. If you want to
+ identify different callout points, you can put a number less
+ than 256 after the letter C. The default value is zero. For
+ example, this pattern has two callout points:
+
+ (?C1)9abc(?C2)def
+
+ During matching, when PCRE reaches a callout point (and
+ pcre_callout is set), the external function is called. It is
+ provided with the number of the callout, and, optionally,
+ one item of data originally supplied by the caller of
+ pcre_exec(). The callout function may cause matching to
+ backtrack, or to fail altogether. A complete description of
+ the interface to the callout function is given in the pcre-
+ callout documentation.
+
+Last updated: 03 February 2003
+Copyright (c) 1997-2003 University of Cambridge.
+-----------------------------------------------------------------------------
+
+NAME
+ PCRE - Perl-compatible regular expressions
+
+
+PCRE PERFORMANCE
+
+ Certain items that may appear in regular expression patterns
+ are more efficient than others. It is more efficient to use
+ a character class like [aeiou] than a set of alternatives
+ such as (a|e|i|o|u). In general, the simplest construction
+ that provides the required behaviour is usually the most
+ efficient. Jeffrey Friedl's book contains a lot of discus-
+ sion about optimizing regular expressions for efficient per-
+ formance.
+
+ When a pattern begins with .* not in parentheses, or in
+ parentheses that are not the subject of a backreference, and
+ the PCRE_DOTALL option is set, the pattern is implicitly
+ anchored by PCRE, since it can match only at the start of a
+ subject string. However, if PCRE_DOTALL is not set, PCRE
+ cannot make this optimization, because the . metacharacter
+ does not then match a newline, and if the subject string
+ contains newlines, the pattern may match from the character
+ immediately following one of them instead of from the very
+ start. For example, the pattern
+
+ .*second
matches the subject "first\nand second" (where \n stands for
- a newline character) with the first captured substring being
- "and". In order to do this, PCRE has to retry the match
+ a newline character), with the match starting at the seventh
+ character. In order to do this, PCRE has to retry the match
starting after every newline in the subject.
If you are using such a pattern with subject strings that do
@@ -2058,7 +3019,6 @@ PERFORMANCE
that the entire match is going to fail, PCRE has in princi-
ple to try every possible variation, and this can take an
extremely long time.
-
An optimization catches some of the more simple cases such
as
@@ -2078,238 +3038,260 @@ PERFORMANCE
whereas the latter takes an appreciable time with strings
longer than about 20 characters.
+Last updated: 03 February 2003
+Copyright (c) 1997-2003 University of Cambridge.
+-----------------------------------------------------------------------------
+NAME
+ PCRE - Perl-compatible regular expressions.
-UTF-8 SUPPORT
- Starting at release 3.3, PCRE has some support for character
- strings encoded in the UTF-8 format. This is incomplete, and
- is regarded as experimental. In order to use it, you must
- configure PCRE to include UTF-8 support in the code, and, in
- addition, you must call pcre_compile() with the PCRE_UTF8
- option flag. When you do this, both the pattern and any sub-
- ject strings that are matched against it are treated as
- UTF-8 strings instead of just strings of bytes, but only in
- the cases that are mentioned below.
- If you compile PCRE with UTF-8 support, but do not use it at
- run time, the library will be a bit bigger, but the addi-
- tional run time overhead is limited to testing the PCRE_UTF8
- flag in several places, so should not be very large.
+SYNOPSIS OF POSIX API
+ #include <pcreposix.h>
- PCRE assumes that the strings it is given contain valid
- UTF-8 codes. It does not diagnose invalid UTF-8 strings. If
- you pass invalid UTF-8 strings to PCRE, the results are
- undefined.
+ int regcomp(regex_t *preg, const char *pattern,
+ int cflags);
- Running with PCRE_UTF8 set causes these changes in the way
- PCRE works:
+ int regexec(regex_t *preg, const char *string,
+ size_t nmatch, regmatch_t pmatch[], int eflags);
- 1. In a pattern, the escape sequence \x{...}, where the
- contents of the braces is a string of hexadecimal digits, is
- interpreted as a UTF-8 character whose code number is the
- given hexadecimal number, for example: \x{1234}. This
- inserts from one to six literal bytes into the pattern,
- using the UTF-8 encoding. If a non-hexadecimal digit appears
- between the braces, the item is not recognized.
+ size_t regerror(int errcode, const regex_t *preg,
+ char *errbuf, size_t errbuf_size);
- 2. The original hexadecimal escape sequence, \xhh, generates
- a two-byte UTF-8 character if its value is greater than 127.
+ void regfree(regex_t *preg);
- 3. Repeat quantifiers are NOT correctly handled if they fol-
- low a multibyte character. For example, \x{100}* and \xc3+
- do not work. If you want to repeat such characters, you must
- enclose them in non-capturing parentheses, for example
- (?:\x{100}), at present.
- 4. The dot metacharacter matches one UTF-8 character instead
- of a single byte.
+DESCRIPTION
- 5. Unlike literal UTF-8 characters, the dot metacharacter
- followed by a repeat quantifier does operate correctly on
- UTF-8 characters instead of single bytes.
+ This set of functions provides a POSIX-style API to the PCRE
+ regular expression package. See the pcreapi documentation
+ for a description of the native API, which contains addi-
+ tional functionality.
+
+ The functions described here are just wrapper functions that
+ ultimately call the PCRE native API. Their prototypes are
+ defined in the pcreposix.h header file, and on Unix systems
+ the library itself is called pcreposix.a, so can be accessed
+ by adding -lpcreposix to the command for linking an applica-
+ tion which uses them. Because the POSIX functions call the
+ native ones, it is also necessary to add -lpcre.
+
+ I have implemented only those option bits that can be rea-
+ sonably mapped to PCRE native options. In addition, the
+ options REG_EXTENDED and REG_NOSUB are defined with the
+ value zero. They have no effect, but since programs that are
+ written to the POSIX interface often use them, this makes it
+ easier to slot in PCRE as a replacement library. Other POSIX
+ options are not even defined.
+
+ When PCRE is called via these functions, it is only the API
+ that is POSIX-like in style. The syntax and semantics of the
+ regular expressions themselves are still those of Perl, sub-
+ ject to the setting of various PCRE options, as described
+ below.
+
+ The header for these functions is supplied as pcreposix.h to
+ avoid any potential clash with other POSIX libraries. It
+ can, of course, be renamed or aliased as regex.h, which is
+ the "correct" name. It provides two structure types, regex_t
+ for compiled internal forms, and regmatch_t for returning
+ captured substrings. It also defines some constants whose
+ names start with "REG_"; these are used for setting options
+ and identifying error codes.
- 4. Although the \x{...} escape is permitted in a character
- class, characters whose values are greater than 255 cannot
- be included in a class.
- 5. A class is matched against a UTF-8 character instead of
- just a single byte, but it can match only characters whose
- values are less than 256. Characters with greater values
- always fail to match a class.
+COMPILING A PATTERN
- 6. Repeated classes work correctly on multiple characters.
+ The function regcomp() is called to compile a pattern into
+ an internal form. The pattern is a C string terminated by a
+ binary zero, and is passed in the argument pattern. The preg
+ argument is a pointer to a regex_t structure which is used
+ as a base for storing information about the compiled expres-
+ sion.
- 7. Classes containing just a single character whose value is
- greater than 127 (but less than 256), for example, [\x80] or
- [^\x{93}], do not work because these are optimized into sin-
- gle byte matches. In the first case, of course, the class
- brackets are just redundant.
+ The argument cflags is either zero, or contains one or more
+ of the bits defined by the following macros:
- 8. Lookbehind assertions move backwards in the subject by a
- fixed number of characters instead of a fixed number of
- bytes. Simple cases have been tested to work correctly, but
- there may be hidden gotchas herein.
+ REG_ICASE
- 9. The character types such as \d and \w do not work
- correctly with UTF-8 characters. They continue to test a
- single byte.
+ The PCRE_CASELESS option is set when the expression is
+ passed for compilation to the native function.
- 10. Anything not explicitly mentioned here continues to work
- in bytes rather than in characters.
+ REG_NEWLINE
- The following UTF-8 features of Perl 5.6 are not imple-
- mented:
+ The PCRE_MULTILINE option is set when the expression is
+ passed for compilation to the native function. Note that
+ this does not mimic the defined POSIX behaviour for
+ REG_NEWLINE (see the following section).
- 1. The escape sequence \C to match a single byte.
+ In the absence of these flags, no options are passed to the
+ native function. This means the the regex is compiled with
+ PCRE default semantics. In particular, the way it handles
+ newline characters in the subject string is the Perl way,
+ not the POSIX way. Note that setting PCRE_MULTILINE has only
+ some of the effects specified for REG_NEWLINE. It does not
+ affect the way newlines are matched by . (they aren't) or by
+ a negative class such as [^a] (they are).
- 2. The use of Unicode tables and properties and escapes \p,
- \P, and \X.
+ The yield of regcomp() is zero on success, and non-zero oth-
+ erwise. The preg structure is filled in on success, and one
+ member of the structure is public: re_nsub contains the
+ number of capturing subpatterns in the regular expression.
+ Various error codes are defined in the header file.
+MATCHING NEWLINE CHARACTERS
-SAMPLE PROGRAM
- The code below is a simple, complete demonstration program,
- to get you started with using PCRE. This code is also sup-
- plied in the file pcredemo.c in the PCRE distribution.
+ This area is not simple, because POSIX and Perl take dif-
+ ferent views of things. It is not possible to get PCRE to
+ obey POSIX semantics, but then PCRE was never intended to be
+ a POSIX engine. The following table lists the different pos-
+ sibilities for matching newline characters in PCRE:
- The program compiles the regular expression that is its
- first argument, and matches it against the subject string in
- its second argument. No options are set, and default charac-
- ter tables are used. If matching succeeds, the program out-
- puts the portion of the subject that matched, together with
- the contents of any captured substrings.
+ Default Change with
- On a Unix system that has PCRE installed in /usr/local, you
- can compile the demonstration program using a command like
- this:
+ . matches newline no PCRE_DOTALL
+ newline matches [^a] yes not changeable
+ $ matches \n at end yes PCRE_DOLLARENDONLY
+ $ matches \n in middle no PCRE_MULTILINE
+ ^ matches \n in middle no PCRE_MULTILINE
- gcc -o pcredemo pcredemo.c -I/usr/local/include
- -L/usr/local/lib -lpcre
+ This is the equivalent table for POSIX:
- Then you can run simple tests like this:
+ Default Change with
- ./pcredemo 'cat|dog' 'the cat sat on the mat'
+ . matches newline yes REG_NEWLINE
+ newline matches [^a] yes REG_NEWLINE
+ $ matches \n at end no REG_NEWLINE
+ $ matches \n in middle no REG_NEWLINE
+ ^ matches \n in middle no REG_NEWLINE
- Note that there is a much more comprehensive test program,
- called pcretest, which supports many more facilities for
- testing regular expressions. The pcredemo program is pro-
- vided as a simple coding example.
+ PCRE's behaviour is the same as Perl's, except that there is
+ no equivalent for PCRE_DOLLARENDONLY in Perl. In both PCRE
+ and Perl, there is no way to stop newline from matching
+ [^a].
- On some operating systems (e.g. Solaris) you may get an
- error like this when you try to run pcredemo:
+ The default POSIX newline handling can be obtained by set-
+ ting PCRE_DOTALL and PCRE_DOLLARENDONLY, but there is no way
+ to make PCRE behave exactly as for the REG_NEWLINE action.
- ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such
- file or directory
- This is caused by the way shared library support works on
- those systems. You need to add
+MATCHING A PATTERN
- -R/usr/local/lib
+ The function regexec() is called to match a pre-compiled
+ pattern preg against a given string, which is terminated by
+ a zero byte, subject to the options in eflags. These can be:
- to the compile command to get round this problem. Here's the
- code:
+ REG_NOTBOL
- #include <stdio.h>
- #include <string.h>
- #include <pcre.h>
+ The PCRE_NOTBOL option is set when calling the underlying
+ PCRE matching function.
- #define OVECCOUNT 30 /* should be a multiple of 3 */
+ REG_NOTEOL
- int main(int argc, char **argv)
- {
- pcre *re;
- const char *error;
- int erroffset;
- int ovector[OVECCOUNT];
- int rc, i;
+ The PCRE_NOTEOL option is set when calling the underlying
+ PCRE matching function.
- if (argc != 3)
- {
- printf("Two arguments required: a regex and a "
- "subject string\n");
- return 1;
- }
+ The portion of the string that was matched, and also any
+ captured substrings, are returned via the pmatch argument,
+ which points to an array of nmatch structures of type
+ regmatch_t, containing the members rm_so and rm_eo. These
+ contain the offset to the first character of each substring
+ and the offset to the first character after the end of each
+ substring, respectively. The 0th element of the vector
+ relates to the entire portion of string that was matched;
+ subsequent elements relate to the capturing subpatterns of
+ the regular expression. Unused entries in the array have
+ both structure members set to -1.
- /* Compile the regular expression in the first argument */
+ A successful match yields a zero return; various error codes
+ are defined in the header file, of which REG_NOMATCH is the
+ "expected" failure code.
- re = pcre_compile(
- argv[1], /* the pattern */
- 0, /* default options */
- &error, /* for error message */
- &erroffset, /* for error offset */
- NULL); /* use default character tables */
- /* Compilation failed: print the error message and exit */
+ERROR MESSAGES
- if (re == NULL)
- {
- printf("PCRE compilation failed at offset %d: %s\n",
- erroffset, error);
- return 1;
- }
+ The regerror() function maps a non-zero errorcode from
+ either regcomp() or regexec() to a printable message. If
+ preg is not NULL, the error should have arisen from the use
+ of that structure. A message terminated by a binary zero is
+ placed in errbuf. The length of the message, including the
+ zero, is limited to errbuf_size. The yield of the function
+ is the size of buffer needed to hold the whole message.
- /* Compilation succeeded: match the subject in the second
- argument */
- rc = pcre_exec(
- re, /* the compiled pattern */
- NULL, /* we didn't study the pattern */
- argv[2], /* the subject string */
- (int)strlen(argv[2]), /* the length of the subject */
- 0, /* start at offset 0 in the subject */
- 0, /* default options */
- ovector, /* vector for substring information */
- OVECCOUNT); /* number of elements in the vector */
-
- /* Matching failed: handle error cases */
-
- if (rc < 0)
- {
- switch(rc)
- {
- case PCRE_ERROR_NOMATCH: printf("No match\n"); break;
- /*
- Handle other special cases if you like
- */
- default: printf("Matching error %d\n", rc); break;
- }
- return 1;
- }
-
- /* Match succeded */
-
- printf("Match succeeded\n");
-
- /* The output vector wasn't big enough */
-
- if (rc == 0)
- {
- rc = OVECCOUNT/3;
- printf("ovector only has room for %d captured "
- substrings\n", rc - 1);
- }
-
- /* Show substrings stored in the output vector */
-
- for (i = 0; i < rc; i++)
- {
- char *substring_start = argv[2] + ovector[2*i];
- int substring_length = ovector[2*i+1] - ovector[2*i];
- printf("%2d: %.*s\n", i, substring_length,
- substring_start);
- }
-
- return 0;
- }
+STORAGE
+ Compiling a regular expression causes memory to be allocated
+ and associated with the preg structure. The function reg-
+ free() frees all such memory, after which preg may no longer
+ be used as a compiled expression.
AUTHOR
+
Philip Hazel <ph10@cam.ac.uk>
University Computing Service,
- New Museums Site,
Cambridge CB2 3QG, England.
- Phone: +44 1223 334714
- Last updated: 15 August 2001
- Copyright (c) 1997-2001 University of Cambridge.
+Last updated: 03 February 2003
+Copyright (c) 1997-2003 University of Cambridge.
+-----------------------------------------------------------------------------
+
+NAME
+ PCRE - Perl-compatible regular expressions
+
+
+PCRE SAMPLE PROGRAM
+
+ A simple, complete demonstration program, to get you started
+ with using PCRE, is supplied in the file pcredemo.c in the
+ PCRE distribution.
+
+ The program compiles the regular expression that is its
+ first argument, and matches it against the subject string in
+ its second argument. No PCRE options are set, and default
+ character tables are used. If matching succeeds, the program
+ outputs the portion of the subject that matched, together
+ with the contents of any captured substrings.
+
+ If the -g option is given on the command line, the program
+ then goes on to check for further matches of the same regu-
+ lar expression in the same subject string. The logic is a
+ little bit tricky because of the possibility of matching an
+ empty string. Comments in the code explain what is going on.
+
+ On a Unix system that has PCRE installed in /usr/local, you
+ can compile the demonstration program using a command like
+ this:
+
+ gcc -o pcredemo pcredemo.c -I/usr/local/include \
+ -L/usr/local/lib -lpcre
+
+ Then you can run simple tests like this:
+
+ ./pcredemo 'cat|dog' 'the cat sat on the mat'
+ ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
+
+ Note that there is a much more comprehensive test program,
+ called pcretest, which supports many more facilities for
+ testing regular expressions and the PCRE library. The
+ pcredemo program is provided as a simple coding example.
+
+ On some operating systems (e.g. Solaris) you may get an
+ error like this when you try to run pcredemo:
+
+ ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such
+ file or directory
+
+ This is caused by the way shared library support works on
+ those systems. You need to add
+
+ -R/usr/local/lib
+
+ to the compile command to get round this problem.
+
+Last updated: 28 January 2003
+Copyright (c) 1997-2003 University of Cambridge.
+-----------------------------------------------------------------------------
+
diff --git a/doc/pcre_compile.3 b/doc/pcre_compile.3
new file mode 100644
index 0000000..f911623
--- /dev/null
+++ b/doc/pcre_compile.3
@@ -0,0 +1,55 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B pcre *pcre_compile(const char *\fIpattern\fR, int \fIoptions\fR,
+.ti +5n
+.B const char **\fIerrptr\fR, int *\fIerroffset\fR,
+.ti +5n
+.B const unsigned char *\fItableptr\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This function compiles a regular expression into an internal form. Its
+arguments are:
+
+ \fIpattern\fR A zero-terminated string containing the
+ regular expression to be compiled
+ \fIoptions\fR Zero or more option bits
+ \fIerrptr\fR Where to put an error message
+ \fIerroffset\fR Offset in pattern where error was found
+ \fItableptr\fR Pointer to character tables, or NULL to
+ use the built-in default
+
+The option bits are:
+
+ PCRE_ANCHORED Force pattern anchoring
+ PCRE_CASELESS Do caseless matching
+ PCRE_DOLLAR_ENDONLY $ not to match newline at end
+ PCRE_DOTALL . matches anything including NL
+ PCRE_EXTENDED Ignore whitespace and # comments
+ PCRE_EXTRA PCRE extra features
+ (not much use currently)
+ PCRE_MULTILINE ^ and $ match newlines within data
+ PCRE_NO_AUTO_CAPTURE Disable numbered capturing paren-
+ theses (named ones available)
+ PCRE_UNGREEDY Invert greediness of quantifiers
+ PCRE_UTF8 Run in UTF-8 mode
+
+PCRE must have been compiled with UTF-8 support when PCRE_UTF8 is used.
+
+The yield of the function is a pointer to a private data structure that
+contains the compiled pattern, or NULL if an error was detected.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_config.3 b/doc/pcre_config.3
new file mode 100644
index 0000000..bbebb00
--- /dev/null
+++ b/doc/pcre_config.3
@@ -0,0 +1,44 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B int pcre_config(int \fIwhat\fR, void *\fIwhere\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This function makes it possible for a client program to find out which optional
+features are available in the version of the PCRE library it is using. Its
+arguments are as follows:
+
+ \fIwhat\fR A code specifying what information is required
+ \fIwhere\fR Points to where to put the data
+
+The available codes are:
+
+ PCRE_CONFIG_LINK_SIZE Internal link size: 2, 3, or 4
+ PCRE_CONFIG_MATCH_LIMIT Internal resource limit
+ PCRE_CONFIG_NEWLINE Value of the newline character
+ PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+ Threshold of return slots, above
+ which \fBmalloc()\fR is used by
+ the POSIX API
+ PCRE_CONFIG_UTF8 Availability of UTF-8 support
+
+The function yields 0 on success or PCRE_ERROR_BADOPTION otherwise.
+
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page, and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fR
+.\"
+page.
diff --git a/doc/pcre_copy_named_substring.3 b/doc/pcre_copy_named_substring.3
new file mode 100644
index 0000000..915bd0a
--- /dev/null
+++ b/doc/pcre_copy_named_substring.3
@@ -0,0 +1,40 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B int pcre_copy_named_substring(const pcre *\fIcode\fR,
+.ti +5n
+.B const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, const char *\fIstringname\fR,
+.ti +5n
+.B char *\fIbuffer\fR, int \fIbuffersize\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for extracting a captured substring, identified
+by name, into a given buffer. The arguments are:
+
+ \fIcode\fR Pattern that was successfully matched
+ \fIsubject\fR Subject that has been successfully matched
+ \fIovector\fR Offset vector that \fBpcre_exec()\fR used
+ \fIstringcount\fR Value returned by \fBpcre_exec()\fR
+ \fIstringname\fR Name of the required substring
+ \fIbuffer\fR Buffer to receive the string
+ \fIbuffersize\fR Size of buffer
+
+The yield is the length of the substring, PCRE_ERROR_NOMEMORY if the buffer was
+too small, or PCRE_ERROR_NOSUBSTRING if the string name is invalid.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_copy_substring.3 b/doc/pcre_copy_substring.3
new file mode 100644
index 0000000..d61b99b
--- /dev/null
+++ b/doc/pcre_copy_substring.3
@@ -0,0 +1,37 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B int pcre_copy_substring(const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, int \fIstringnumber\fR, char *\fIbuffer\fR,
+.ti +5n
+.B int \fIbuffersize\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for extracting a captured substring into a given
+buffer. The arguments are:
+
+ \fIsubject\fR Subject that has been successfully matched
+ \fIovector\fR Offset vector that \fBpcre_exec()\fR used
+ \fIstringcount\fR Value returned by \fBpcre_exec()\fR
+ \fIstringnumber\fR Number of the required substring
+ \fIbuffer\fR Buffer to receive the string
+ \fIbuffersize\fR Size of buffer
+
+The yield is the legnth of the string, PCRE_ERROR_NOMEMORY if the buffer was
+too small, or PCRE_ERROR_NOSUBSTRING if the string number is invalid.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_exec.3 b/doc/pcre_exec.3
new file mode 100644
index 0000000..f61c2a4
--- /dev/null
+++ b/doc/pcre_exec.3
@@ -0,0 +1,45 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B int pcre_exec(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"
+.ti +5n
+.B "const char *\fIsubject\fR," int \fIlength\fR, int \fIstartoffset\fR,
+.ti +5n
+.B int \fIoptions\fR, int *\fIovector\fR, int \fIovecsize\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This function matches a compiled regular expression against a given subject
+string, and returns offsets to capturing subexpressions. Its arguments are:
+
+ \fIcode\fR Points to the compiled pattern
+ \fIextra\fR Points to an associated \fBpcre_extra\fR structure,
+ or is NULL
+ \fIsubject\fR Points to the subject string
+ \fIlength\fR Length of the subject string, in bytes
+ \fIstartoffset\fR Offset in bytes in the subject at which to
+ start matching
+ \fIoptions\fR Option bits
+ \fIovector\fR Points to a vector of ints for result offsets
+ \fIovecsize\fR Size of the vector (a multiple of 3)
+
+The options are:
+
+ PCRE_ANCHORED Match only at the first position
+ PCRE_NOTBOL Subject is not the beginning of a line
+ PCRE_NOTEOL Subject is not the end of a line
+ PCRE_NOTEMPTY An empty string is not a valid match
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_free_substring.3 b/doc/pcre_free_substring.3
new file mode 100644
index 0000000..3fcaf11
--- /dev/null
+++ b/doc/pcre_free_substring.3
@@ -0,0 +1,24 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B void pcre_free_substring(const char *\fIstringptr\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for freeing the store obtained by a previous
+call to \fBpcre_get_substring()\fR or \fBpcre_get_named_substring()\fR. Its
+only argument is a pointer to the string.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_free_substring_list.3 b/doc/pcre_free_substring_list.3
new file mode 100644
index 0000000..73d5993
--- /dev/null
+++ b/doc/pcre_free_substring_list.3
@@ -0,0 +1,24 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B void pcre_free_substring_list(const char **\fIstringptr\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for freeing the store obtained by a previous
+call to \fBpcre_get_substring_list()\fR. Its only argument is a pointer to the
+list of string pointers.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_fullinfo.3 b/doc/pcre_fullinfo.3
new file mode 100644
index 0000000..06de985
--- /dev/null
+++ b/doc/pcre_fullinfo.3
@@ -0,0 +1,53 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B int pcre_fullinfo(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"
+.ti +5n
+.B int \fIwhat\fR, void *\fIwhere\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This function returns information about a compiled pattern. Its arguments are:
+
+ \fIcode\fR Compiled regular expression
+ \fIextra\fR Result of \fBpcre_study()\fR or NULL
+ \fIwhat\fR What information is required
+ \fIwhere\fR Where to put the information
+
+The following information is available:
+
+ PCRE_INFO_BACKREFMAX Number of highest back reference
+ PCRE_INFO_CAPTURECOUNT Number of capturing subpatterns
+ PCRE_INFO_FIRSTBYTE Fixed first byte for a match, or
+ -1 for start of string
+ or after newline, or
+ -2 otherwise
+ PCRE_INFO_FIRSTTABLE Table of first bytes
+ (after studying)
+ PCRE_INFO_LASTLITERAL Literal last byte required
+ PCRE_INFO_NAMECOUNT Number of named subpatterns
+ PCRE_INFO_NAMEENTRYSIZE Size of name table entry
+ PCRE_INFO_NAMETABLE Pointer to name table
+ PCRE_INFO_OPTIONS Options used for compilation
+ PCRE_INFO_SIZE Size of compiled pattern
+
+The yield of the function is zero on success or:
+
+ PCRE_ERROR_NULL the argument \fIcode\fR was NULL
+ the argument \fIwhere\fR was NULL
+ PCRE_ERROR_BADMAGIC the "magic number" was not found
+ PCRE_ERROR_BADOPTION the value of \fIwhat\fR was invalid
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_get_named_substring.3 b/doc/pcre_get_named_substring.3
new file mode 100644
index 0000000..6d3f80e
--- /dev/null
+++ b/doc/pcre_get_named_substring.3
@@ -0,0 +1,40 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B int pcre_get_named_substring(const pcre *\fIcode\fR,
+.ti +5n
+.B const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, const char *\fIstringname\fR,
+.ti +5n
+.B const char **\fIstringptr\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for extracting a captured substring by name. The
+arguments are:
+
+ \fIcode\fR Compiled pattern
+ \fIsubject\fR Subject that has been successfully matched
+ \fIovector\fR Offset vector that \fBpcre_exec()\fR used
+ \fIstringcount\fR Value returned by \fBpcre_exec()\fR
+ \fIstringname\fR Name of the required substring
+ \fIstringptr\fR Where to put the string pointer
+
+The yield is the length of the extracted substring, PCRE_ERROR_NOMEMORY if
+sufficient memory could not be obtained, or PCRE_ERROR_NOSUBSTRING if the
+string name is invalid.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_get_stringnumber.3 b/doc/pcre_get_stringnumber.3
new file mode 100644
index 0000000..f6c9357
--- /dev/null
+++ b/doc/pcre_get_stringnumber.3
@@ -0,0 +1,31 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B int pcre_get_stringnumber(const pcre *\fIcode\fR,
+.ti +5n
+.B const char *\fIname\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This convenience function finds the number of a named substring capturing
+parenthesis in a compiled pattern. Its arguments are:
+
+ \fIcode\fR Compiled regular expression
+ \fIname\fR Name whose number is required
+
+The yield of the function is the number of the parenthesis if the name is
+found, or PCRE_ERROR_NOSUBSTRING otherwise.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_get_substring.3 b/doc/pcre_get_substring.3
new file mode 100644
index 0000000..4c92c9c
--- /dev/null
+++ b/doc/pcre_get_substring.3
@@ -0,0 +1,37 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B int pcre_get_substring(const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, int \fIstringnumber\fR,
+.ti +5n
+.B const char **\fIstringptr\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for extracting a captured substring. The
+arguments are:
+
+ \fIsubject\fR Subject that has been successfully matched
+ \fIovector\fR Offset vector that \fBpcre_exec()\fR used
+ \fIstringcount\fR Value returned by \fBpcre_exec()\fR
+ \fIstringnumber\fR Number of the required substring
+ \fIstringptr\fR Where to put the string pointer
+
+The yield is the length of the substring, PCRE_ERROR_NOMEMORY if sufficient
+memory could not be obtained, or PCRE_ERROR_NOSUBSTRING if the string number is
+invalid.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_get_substring_list.3 b/doc/pcre_get_substring_list.3
new file mode 100644
index 0000000..69090e1
--- /dev/null
+++ b/doc/pcre_get_substring_list.3
@@ -0,0 +1,33 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B int pcre_get_substring_list(const char *\fIsubject\fR,
+.ti +5n
+.B int *\fIovector\fR, int \fIstringcount\fR, "const char ***\fIlistptr\fR);"
+
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for extracting a list of all the captured
+substrings. The arguments are:
+
+ \fIsubject\fR Subject that has been successfully matched
+ \fIovector\fR Offset vector that \fBpcre_exec\fR used
+ \fIstringcount\fR Value returned by \fBpcre_exec\fR
+ \fIlistptr\fR Where to put a pointer to the list
+
+The yield is zero on success or PCRE_ERROR_NOMEMORY if sufficient memory could
+not be obtained.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_info.3 b/doc/pcre_info.3
new file mode 100644
index 0000000..c497076
--- /dev/null
+++ b/doc/pcre_info.3
@@ -0,0 +1,23 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B int pcre_info(const pcre *\fIcode\fR, int *\fIoptptr\fR, int
+.B *\fIfirstcharptr\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This function is obsolete. You should be using \fBpcre_fullinfo()\fR instead.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_maketables.3 b/doc/pcre_maketables.3
new file mode 100644
index 0000000..7d459ed
--- /dev/null
+++ b/doc/pcre_maketables.3
@@ -0,0 +1,26 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B const unsigned char *pcre_maketables(void);
+
+.SH DESCRIPTION
+.rs
+.sp
+This function builds a set of character tables which can be passed to
+\fBpcre_compile()\fR to override PCRE's internal, built-in tables (which were
+made by \fBpcre_maketables()\fR when PCRE was compiled). You might want to do
+this if you are using a non-standard locale. The function yields a pointer to
+the tables.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_study.3 b/doc/pcre_study.3
new file mode 100644
index 0000000..69ff20e
--- /dev/null
+++ b/doc/pcre_study.3
@@ -0,0 +1,36 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B pcre_extra *pcre_study(const pcre *\fIcode\fR, int \fIoptions\fR,
+.ti +5n
+.B const char **\fIerrptr\fR);
+
+.SH DESCRIPTION
+.rs
+.sp
+This function studies a compiled pattern, to see if additional information can
+be extracted that might speed up matching. Its arguments are:
+
+ \fIcode\fR A compiled regular expression
+ \fIoptions\fR Options for \fBpcre_study()\fR
+ \fIerrptr\fR Where to put an error message
+
+If the function returns NULL, either it could not find any additional
+information, or there was an error. You can tell the difference by looking at
+the error value. It is NULL in first case.
+
+There are currently no options defined; the value of the second argument should
+always be zero.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcre_version.3 b/doc/pcre_version.3
new file mode 100644
index 0000000..6f98122
--- /dev/null
+++ b/doc/pcre_version.3
@@ -0,0 +1,23 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B char *pcre_version(void);
+
+.SH DESCRIPTION
+.rs
+.sp
+This function returns a character string that gives the version number of the
+PCRE library, and its date of release.
+
+There is a complete description of the PCRE API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page.
diff --git a/doc/pcreapi.3 b/doc/pcreapi.3
new file mode 100644
index 0000000..b808aba
--- /dev/null
+++ b/doc/pcreapi.3
@@ -0,0 +1,1014 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS OF PCRE API
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.br
+.B pcre *pcre_compile(const char *\fIpattern\fR, int \fIoptions\fR,
+.ti +5n
+.B const char **\fIerrptr\fR, int *\fIerroffset\fR,
+.ti +5n
+.B const unsigned char *\fItableptr\fR);
+.PP
+.br
+.B pcre_extra *pcre_study(const pcre *\fIcode\fR, int \fIoptions\fR,
+.ti +5n
+.B const char **\fIerrptr\fR);
+.PP
+.br
+.B int pcre_exec(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"
+.ti +5n
+.B "const char *\fIsubject\fR," int \fIlength\fR, int \fIstartoffset\fR,
+.ti +5n
+.B int \fIoptions\fR, int *\fIovector\fR, int \fIovecsize\fR);
+.PP
+.br
+.B int pcre_copy_named_substring(const pcre *\fIcode\fR,
+.ti +5n
+.B const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, const char *\fIstringname\fR,
+.ti +5n
+.B char *\fIbuffer\fR, int \fIbuffersize\fR);
+.PP
+.br
+.B int pcre_copy_substring(const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, int \fIstringnumber\fR, char *\fIbuffer\fR,
+.ti +5n
+.B int \fIbuffersize\fR);
+.PP
+.br
+.B int pcre_get_named_substring(const pcre *\fIcode\fR,
+.ti +5n
+.B const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, const char *\fIstringname\fR,
+.ti +5n
+.B const char **\fIstringptr\fR);
+.PP
+.br
+.B int pcre_get_stringnumber(const pcre *\fIcode\fR,
+.ti +5n
+.B const char *\fIname\fR);
+.PP
+.br
+.B int pcre_get_substring(const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, int \fIstringnumber\fR,
+.ti +5n
+.B const char **\fIstringptr\fR);
+.PP
+.br
+.B int pcre_get_substring_list(const char *\fIsubject\fR,
+.ti +5n
+.B int *\fIovector\fR, int \fIstringcount\fR, "const char ***\fIlistptr\fR);"
+.PP
+.br
+.B void pcre_free_substring(const char *\fIstringptr\fR);
+.PP
+.br
+.B void pcre_free_substring_list(const char **\fIstringptr\fR);
+.PP
+.br
+.B const unsigned char *pcre_maketables(void);
+.PP
+.br
+.B int pcre_fullinfo(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"
+.ti +5n
+.B int \fIwhat\fR, void *\fIwhere\fR);
+.PP
+.br
+.B int pcre_info(const pcre *\fIcode\fR, int *\fIoptptr\fR, int
+.B *\fIfirstcharptr\fR);
+.PP
+.br
+.B int pcre_config(int \fIwhat\fR, void *\fIwhere\fR);
+.PP
+.br
+.B char *pcre_version(void);
+.PP
+.br
+.B void *(*pcre_malloc)(size_t);
+.PP
+.br
+.B void (*pcre_free)(void *);
+.PP
+.br
+.B int (*pcre_callout)(pcre_callout_block *);
+
+.SH PCRE API
+.rs
+.sp
+PCRE has its own native API, which is described in this document. There is also
+a set of wrapper functions that correspond to the POSIX regular expression API.
+These are described in the \fBpcreposix\fR documentation.
+
+The native API function prototypes are defined in the header file \fBpcre.h\fR,
+and on Unix systems the library itself is called \fBlibpcre.a\fR, so can be
+accessed by adding \fB-lpcre\fR to the command for linking an application which
+calls it. The header file defines the macros PCRE_MAJOR and PCRE_MINOR to
+contain the major and minor release numbers for the library. Applications can
+use these to include support for different releases.
+
+The functions \fBpcre_compile()\fR, \fBpcre_study()\fR, and \fBpcre_exec()\fR
+are used for compiling and matching regular expressions. A sample program that
+demonstrates the simplest way of using them is given in the file
+\fIpcredemo.c\fR. The \fBpcresample\fR documentation describes how to run it.
+
+There are convenience functions for extracting captured substrings from a
+matched subject string. They are:
+
+ \fBpcre_copy_substring()\fR
+ \fBpcre_copy_named_substring()\fR
+ \fBpcre_get_substring()\fR
+ \fBpcre_get_named_substring()\fR
+ \fBpcre_get_substring_list()\fR
+
+\fBpcre_free_substring()\fR and \fBpcre_free_substring_list()\fR are also
+provided, to free the memory used for extracted strings.
+
+The function \fBpcre_maketables()\fR is used (optionally) to build a set of
+character tables in the current locale for passing to \fBpcre_compile()\fR.
+
+The function \fBpcre_fullinfo()\fR is used to find out information about a
+compiled pattern; \fBpcre_info()\fR is an obsolete version which returns only
+some of the available information, but is retained for backwards compatibility.
+The function \fBpcre_version()\fR returns a pointer to a string containing the
+version of PCRE and its date of release.
+
+The global variables \fBpcre_malloc\fR and \fBpcre_free\fR initially contain
+the entry points of the standard \fBmalloc()\fR and \fBfree()\fR functions
+respectively. PCRE calls the memory management functions via these variables,
+so a calling program can replace them if it wishes to intercept the calls. This
+should be done before calling any PCRE functions.
+
+The global variable \fBpcre_callout\fR initially contains NULL. It can be set
+by the caller to a "callout" function, which PCRE will then call at specified
+points during a matching operation. Details are given in the \fBpcrecallout\fR
+documentation.
+
+.SH MULTITHREADING
+.rs
+.sp
+The PCRE functions can be used in multi-threading applications, with the
+proviso that the memory management functions pointed to by \fBpcre_malloc\fR
+and \fBpcre_free\fR, and the callout function pointed to by \fBpcre_callout\fR,
+are shared by all threads.
+
+The compiled form of a regular expression is not altered during matching, so
+the same compiled pattern can safely be used by several threads at once.
+
+.SH CHECKING BUILD-TIME OPTIONS
+.rs
+.sp
+.B int pcre_config(int \fIwhat\fR, void *\fIwhere\fR);
+.PP
+The function \fBpcre_config()\fR makes it possible for a PCRE client to
+discover which optional features have been compiled into the PCRE library. The
+.\" HREF
+\fBpcrebuild\fR
+.\"
+documentation has more details about these optional features.
+
+The first argument for \fBpcre_config()\fR is an integer, specifying which
+information is required; the second argument is a pointer to a variable into
+which the information is placed. The following information is available:
+
+ PCRE_CONFIG_UTF8
+
+The output is an integer that is set to one if UTF-8 support is available;
+otherwise it is set to zero.
+
+ PCRE_CONFIG_NEWLINE
+
+The output is an integer that is set to the value of the code that is used for
+the newline character. It is either linefeed (10) or carriage return (13), and
+should normally be the standard character for your operating system.
+
+ PCRE_CONFIG_LINK_SIZE
+
+The output is an integer that contains the number of bytes used for internal
+linkage in compiled regular expressions. The value is 2, 3, or 4. Larger values
+allow larger regular expressions to be compiled, at the expense of slower
+matching. The default value of 2 is sufficient for all but the most massive
+patterns, since it allows the compiled pattern to be up to 64K in size.
+
+ PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+
+The output is an integer that contains the threshold above which the POSIX
+interface uses \fBmalloc()\fR for output vectors. Further details are given in
+the \fBpcreposix\fR documentation.
+
+ PCRE_CONFIG_MATCH_LIMIT
+
+The output is an integer that gives the default limit for the number of
+internal matching function calls in a \fBpcre_exec()\fR execution. Further
+details are given with \fBpcre_exec()\fR below.
+
+.SH COMPILING A PATTERN
+.rs
+.sp
+.B pcre *pcre_compile(const char *\fIpattern\fR, int \fIoptions\fR,
+.ti +5n
+.B const char **\fIerrptr\fR, int *\fIerroffset\fR,
+.ti +5n
+.B const unsigned char *\fItableptr\fR);
+.PP
+
+The function \fBpcre_compile()\fR is called to compile a pattern into an
+internal form. The pattern is a C string terminated by a binary zero, and
+is passed in the argument \fIpattern\fR. A pointer to a single block of memory
+that is obtained via \fBpcre_malloc\fR is returned. This contains the compiled
+code and related data. The \fBpcre\fR type is defined for the returned block;
+this is a typedef for a structure whose contents are not externally defined. It
+is up to the caller to free the memory when it is no longer required.
+
+Although the compiled code of a PCRE regex is relocatable, that is, it does not
+depend on memory location, the complete \fBpcre\fR data block is not
+fully relocatable, because it contains a copy of the \fItableptr\fR argument,
+which is an address (see below).
+
+The \fIoptions\fR argument contains independent bits that affect the
+compilation. It should be zero if no options are required. Some of the options,
+in particular, those that are compatible with Perl, can also be set and unset
+from within the pattern (see the detailed description of regular expressions
+in the \fBpcrepattern\fR documentation). For these options, the contents of the
+\fIoptions\fR argument specifies their initial settings at the start of
+compilation and execution. The PCRE_ANCHORED option can be set at the time of
+matching as well as at compile time.
+
+If \fIerrptr\fR is NULL, \fBpcre_compile()\fR returns NULL immediately.
+Otherwise, if compilation of a pattern fails, \fBpcre_compile()\fR returns
+NULL, and sets the variable pointed to by \fIerrptr\fR to point to a textual
+error message. The offset from the start of the pattern to the character where
+the error was discovered is placed in the variable pointed to by
+\fIerroffset\fR, which must not be NULL. If it is, an immediate error is given.
+
+If the final argument, \fItableptr\fR, is NULL, PCRE uses a default set of
+character tables which are built when it is compiled, using the default C
+locale. Otherwise, \fItableptr\fR must be the result of a call to
+\fBpcre_maketables()\fR. See the section on locale support below.
+
+This code fragment shows a typical straightforward call to \fBpcre_compile()\fR:
+
+ pcre *re;
+ const char *error;
+ int erroffset;
+ re = pcre_compile(
+ "^A.*Z", /* the pattern */
+ 0, /* default options */
+ &error, /* for error message */
+ &erroffset, /* for error offset */
+ NULL); /* use default character tables */
+
+The following option bits are defined:
+
+ PCRE_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 which 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.
+
+ PCRE_CASELESS
+
+If this bit is set, letters in the pattern match both upper and lower case
+letters. It is equivalent to Perl's /i option, and it can be changed within a
+pattern by a (?i) option setting.
+
+ PCRE_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 the final character if it is a newline (but not before any
+other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is
+set. There is no equivalent to this option in Perl, and no way to set it within
+a pattern.
+
+ PCRE_DOTALL
+
+If this bit is set, a dot metacharater in the pattern matches all characters,
+including newlines. Without it, newlines are excluded. This option is
+equivalent to Perl's /s option, and it can be changed within a pattern by a
+(?s) option setting. A negative class such as [^a] always matches a newline
+character, independent of the setting of this option.
+
+ PCRE_EXTENDED
+
+If this bit is set, whitespace data characters in the pattern are totally
+ignored except when escaped or inside a character class. Whitespace does not
+include the VT character (code 11). In addition, characters between an
+unescaped # outside a character class and the next newline character,
+inclusive, are also ignored. This is equivalent to Perl's /x option, and it can
+be changed within a pattern by a (?x) option setting.
+
+This option makes it possible to include comments inside complicated patterns.
+Note, however, that this applies only to data characters. Whitespace characters
+may never appear within special character sequences in a pattern, for example
+within the sequence (?( which introduces a conditional subpattern.
+
+ PCRE_EXTRA
+
+This option was invented in order to turn on additional functionality of PCRE
+that is incompatible with Perl, but it is currently of very little use. When
+set, any backslash in a pattern that is followed by a letter that has no
+special meaning causes an error, thus reserving these combinations for future
+expansion. By default, as in Perl, a backslash followed by a letter with no
+special meaning is treated as a literal. There are at present no other features
+controlled by this option. It can also be set by a (?X) option setting within a
+pattern.
+
+ PCRE_MULTILINE
+
+By default, PCRE treats the subject string as consisting of a single "line" of
+characters (even if it actually contains several newlines). The "start of line"
+metacharacter (^) matches only at the start of the string, while the "end of
+line" metacharacter ($) matches only at the end of the string, or before a
+terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as
+Perl.
+
+When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs
+match immediately following or immediately before any newline in the subject
+string, respectively, as well as at the very start and end. This is equivalent
+to Perl's /m option, and it can be changed within a pattern by a (?m) option
+setting. If there are no "\\n" characters in a subject string, or no
+occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect.
+
+ PCRE_NO_AUTO_CAPTURE
+
+If this option is set, it disables the use of numbered capturing parentheses in
+the pattern. Any opening parenthesis that is not followed by ? behaves as if it
+were followed by ?: but named parentheses can still be used for capturing (and
+they acquire numbers in the usual way). There is no equivalent of this option
+in Perl.
+
+ PCRE_UNGREEDY
+
+This option inverts the "greediness" of the quantifiers so that they are not
+greedy by default, but become greedy if followed by "?". It is not compatible
+with Perl. It can also be set by a (?U) option setting within the pattern.
+
+ PCRE_UTF8
+
+This option causes PCRE to regard both the pattern and the subject as strings
+of UTF-8 characters instead of single-byte character strings. However, it is
+available only if PCRE has been built to include UTF-8 support. If not, the use
+of this option provokes an error. Details of how this option changes the
+behaviour of PCRE are given in the
+.\" HTML <a href="pcre.html#utf8support">
+.\" </a>
+section on UTF-8 support
+.\"
+in the main
+.\" HREF
+\fBpcre\fR
+.\"
+page.
+
+.SH STUDYING A PATTERN
+.rs
+.sp
+.B pcre_extra *pcre_study(const pcre *\fIcode\fR, int \fIoptions\fR,
+.ti +5n
+.B const char **\fIerrptr\fR);
+.PP
+When a pattern is going to be used several times, it is worth spending more
+time analyzing it in order to speed up the time taken for matching. The
+function \fBpcre_study()\fR takes a pointer to a compiled pattern as its first
+argument. If studing the pattern produces additional information that will help
+speed up matching, \fBpcre_study()\fR returns a pointer to a \fBpcre_extra\fR
+block, in which the \fIstudy_data\fR field points to the results of the study.
+
+The returned value from a \fBpcre_study()\fR can be passed directly to
+\fBpcre_exec()\fR. However, the \fBpcre_extra\fR block also contains other
+fields that can be set by the caller before the block is passed; these are
+described below. If studying the pattern does not produce any additional
+information, \fBpcre_study()\fR returns NULL. In that circumstance, if the
+calling program wants to pass some of the other fields to \fBpcre_exec()\fR, it
+must set up its own \fBpcre_extra\fR block.
+
+The second argument contains option bits. At present, no options are defined
+for \fBpcre_study()\fR, and this argument should always be zero.
+
+The third argument for \fBpcre_study()\fR is a pointer for an error message. If
+studying succeeds (even if no data is returned), the variable it points to is
+set to NULL. Otherwise it points to a textual error message. You should
+therefore test the error pointer for NULL after calling \fBpcre_study()\fR, to
+be sure that it has run successfully.
+
+This is a typical call to \fBpcre_study\fR():
+
+ pcre_extra *pe;
+ pe = pcre_study(
+ re, /* result of pcre_compile() */
+ 0, /* no options exist */
+ &error); /* set to NULL or points to a message */
+
+At present, studying a pattern is useful only for non-anchored patterns that do
+not have a single fixed starting character. A bitmap of possible starting
+characters is created.
+
+.\" HTML <a name="localesupport"></a>
+.SH LOCALE SUPPORT
+.rs
+.sp
+PCRE handles caseless matching, and determines whether characters are letters,
+digits, or whatever, by reference to a set of tables. When running in UTF-8
+mode, this applies only to characters with codes less than 256. The library
+contains a default set of tables that is created in the default C locale when
+PCRE is compiled. This is used when the final argument of \fBpcre_compile()\fR
+is NULL, and is sufficient for many applications.
+
+An alternative set of tables can, however, be supplied. Such tables are built
+by calling the \fBpcre_maketables()\fR function, which has no arguments, in the
+relevant locale. The result can then be passed to \fBpcre_compile()\fR as often
+as necessary. For example, to build and use tables that are appropriate for the
+French locale (where accented characters with codes greater than 128 are
+treated as letters), the following code could be used:
+
+ setlocale(LC_CTYPE, "fr");
+ tables = pcre_maketables();
+ re = pcre_compile(..., tables);
+
+The tables are built in memory that is obtained via \fBpcre_malloc\fR. The
+pointer that is passed to \fBpcre_compile\fR is saved with the compiled
+pattern, and the same tables are used via this pointer by \fBpcre_study()\fR
+and \fBpcre_exec()\fR. Thus, for any single pattern, compilation, studying and
+matching all happen in the same locale, but different patterns can be compiled
+in different locales. It is the caller's responsibility to ensure that the
+memory containing the tables remains available for as long as it is needed.
+
+.SH INFORMATION ABOUT A PATTERN
+.rs
+.sp
+.B int pcre_fullinfo(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"
+.ti +5n
+.B int \fIwhat\fR, void *\fIwhere\fR);
+.PP
+The \fBpcre_fullinfo()\fR function returns information about a compiled
+pattern. It replaces the obsolete \fBpcre_info()\fR function, which is
+nevertheless retained for backwards compability (and is documented below).
+
+The first argument for \fBpcre_fullinfo()\fR is a pointer to the compiled
+pattern. The second argument is the result of \fBpcre_study()\fR, or NULL if
+the pattern was not studied. The third argument specifies which piece of
+information is required, and the fourth argument is a pointer to a variable
+to receive the data. The yield of the function is zero for success, or one of
+the following negative numbers:
+
+ PCRE_ERROR_NULL the argument \fIcode\fR was NULL
+ the argument \fIwhere\fR was NULL
+ PCRE_ERROR_BADMAGIC the "magic number" was not found
+ PCRE_ERROR_BADOPTION the value of \fIwhat\fR was invalid
+
+Here is a typical call of \fBpcre_fullinfo()\fR, to obtain the length of the
+compiled pattern:
+
+ int rc;
+ unsigned long int length;
+ rc = pcre_fullinfo(
+ re, /* result of pcre_compile() */
+ pe, /* result of pcre_study(), or NULL */
+ PCRE_INFO_SIZE, /* what is required */
+ &length); /* where to put the data */
+
+The possible values for the third argument are defined in \fBpcre.h\fR, and are
+as follows:
+
+ PCRE_INFO_BACKREFMAX
+
+Return the number of the highest back reference in the pattern. The fourth
+argument should point to an \fBint\fR variable. Zero is returned if there are
+no back references.
+
+ PCRE_INFO_CAPTURECOUNT
+
+Return the number of capturing subpatterns in the pattern. The fourth argument
+should point to an \fbint\fR variable.
+
+ PCRE_INFO_FIRSTBYTE
+
+Return information about the first byte of any matched string, for a
+non-anchored pattern. (This option used to be called PCRE_INFO_FIRSTCHAR; the
+old name is still recognized for backwards compatibility.)
+
+If there is a fixed first byte, e.g. from a pattern such as (cat|cow|coyote),
+it is returned in the integer pointed to by \fIwhere\fR. Otherwise, if either
+
+(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
+starts with "^", or
+
+(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set
+(if it were set, the pattern would be anchored),
+
+-1 is returned, indicating that the pattern matches only at the start of a
+subject string or after any newline within the string. Otherwise -2 is
+returned. For anchored patterns, -2 is returned.
+
+ PCRE_INFO_FIRSTTABLE
+
+If the pattern was studied, and this resulted in the construction of a 256-bit
+table indicating a fixed set of bytes for the first byte in any matching
+string, a pointer to the table is returned. Otherwise NULL is returned. The
+fourth argument should point to an \fBunsigned char *\fR variable.
+
+ PCRE_INFO_LASTLITERAL
+
+For a non-anchored pattern, return the value of the rightmost literal byte
+which must exist in any matched string, other than at its start. The fourth
+argument should point to an \fBint\fR variable. If there is no such byte, or if
+the pattern is anchored, -1 is returned. For example, for the pattern
+/a\\d+z\\d+/ the returned value is 'z'.
+
+ PCRE_INFO_NAMECOUNT
+ PCRE_INFO_NAMEENTRYSIZE
+ PCRE_INFO_NAMETABLE
+
+PCRE supports the use of named as well as numbered capturing parentheses. The
+names are just an additional way of identifying the parentheses, which still
+acquire a number. A caller that wants to extract data from a named subpattern
+must convert the name to a number in order to access the correct pointers in
+the output vector (described with \fBpcre_exec()\fR below). In order to do
+this, it must first use these three values to obtain the name-to-number mapping
+table for the pattern.
+
+The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT gives
+the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size of each
+entry; both of these return an \fBint\fR value. The entry size depends on the
+length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first
+entry of the table (a pointer to \fBchar\fR). The first two bytes of each entry
+are the number of the capturing parenthesis, most significant byte first. The
+rest of the entry is the corresponding name, zero terminated. The names are in
+alphabetical order. For example, consider the following pattern (assume
+PCRE_EXTENDED is set, so white space - including newlines - is ignored):
+
+ (?P<date> (?P<year>(\\d\\d)?\\d\\d) -
+ (?P<month>\\d\\d) - (?P<day>\\d\\d) )
+
+There are four named subpatterns, so the table has four entries, and each entry
+in the table is eight bytes long. The table is as follows, with non-printing
+bytes shows in hex, and undefined bytes shown as ??:
+
+ 00 01 d a t e 00 ??
+ 00 05 d a y 00 ?? ??
+ 00 04 m o n t h 00
+ 00 02 y e a r 00 ??
+
+When writing code to extract data from named subpatterns, remember that the
+length of each entry may be different for each compiled pattern.
+
+ PCRE_INFO_OPTIONS
+
+Return a copy of the options with which the pattern was compiled. The fourth
+argument should point to an \fBunsigned long int\fR variable. These option bits
+are those specified in the call to \fBpcre_compile()\fR, modified by any
+top-level option settings within the pattern itself.
+
+A pattern is automatically anchored by PCRE if all of its top-level
+alternatives begin with one of the following:
+
+ ^ unless PCRE_MULTILINE is set
+ \\A always
+ \\G always
+ .* if PCRE_DOTALL is set and there are no back
+ references to the subpattern in which .* appears
+
+For such patterns, the PCRE_ANCHORED bit is set in the options returned by
+\fBpcre_fullinfo()\fR.
+
+ PCRE_INFO_SIZE
+
+Return the size of the compiled pattern, that is, the value that was passed as
+the argument to \fBpcre_malloc()\fR when PCRE was getting memory in which to
+place the compiled data. The fourth argument should point to a \fBsize_t\fR
+variable.
+
+ PCRE_INFO_STUDYSIZE
+
+Returns the size of the data block pointed to by the \fIstudy_data\fR field in
+a \fBpcre_extra\fR block. That is, it is the value that was passed to
+\fBpcre_malloc()\fR when PCRE was getting memory into which to place the data
+created by \fBpcre_study()\fR. The fourth argument should point to a
+\fBsize_t\fR variable.
+
+.SH OBSOLETE INFO FUNCTION
+.rs
+.sp
+.B int pcre_info(const pcre *\fIcode\fR, int *\fIoptptr\fR, int
+.B *\fIfirstcharptr\fR);
+.PP
+The \fBpcre_info()\fR function is now obsolete because its interface is too
+restrictive to return all the available data about a compiled pattern. New
+programs should use \fBpcre_fullinfo()\fR instead. The yield of
+\fBpcre_info()\fR is the number of capturing subpatterns, or one of the
+following negative numbers:
+
+ PCRE_ERROR_NULL the argument \fIcode\fR was NULL
+ PCRE_ERROR_BADMAGIC the "magic number" was not found
+
+If the \fIoptptr\fR argument is not NULL, a copy of the options with which the
+pattern was compiled is placed in the integer it points to (see
+PCRE_INFO_OPTIONS above).
+
+If the pattern is not anchored and the \fIfirstcharptr\fR argument is not NULL,
+it is used to pass back information about the first character of any matched
+string (see PCRE_INFO_FIRSTBYTE above).
+
+.SH MATCHING A PATTERN
+.rs
+.sp
+.B int pcre_exec(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"
+.ti +5n
+.B "const char *\fIsubject\fR," int \fIlength\fR, int \fIstartoffset\fR,
+.ti +5n
+.B int \fIoptions\fR, int *\fIovector\fR, int \fIovecsize\fR);
+.PP
+The function \fBpcre_exec()\fR is called to match a subject string against a
+pre-compiled pattern, which is passed in the \fIcode\fR argument. If the
+pattern has been studied, the result of the study should be passed in the
+\fIextra\fR argument.
+
+Here is an example of a simple call to \fBpcre_exec()\fR:
+
+ int rc;
+ int ovector[30];
+ rc = pcre_exec(
+ re, /* result of pcre_compile() */
+ NULL, /* we didn't study the pattern */
+ "some string", /* the subject string */
+ 11, /* the length of the subject string */
+ 0, /* start at offset 0 in the subject */
+ 0, /* default options */
+ ovector, /* vector for substring information */
+ 30); /* number of elements in the vector */
+
+If the \fIextra\fR argument is not NULL, it must point to a \fBpcre_extra\fR
+data block. The \fBpcre_study()\fR function returns such a block (when it
+doesn't return NULL), but you can also create one for yourself, and pass
+additional information in it. The fields in the block are as follows:
+
+ unsigned long int \fIflags\fR;
+ void *\fIstudy_data\fR;
+ unsigned long int \fImatch_limit\fR;
+ void *\fIcallout_data\fR;
+
+The \fIflags\fR field is a bitmap that specifies which of the other fields
+are set. The flag bits are:
+
+ PCRE_EXTRA_STUDY_DATA
+ PCRE_EXTRA_MATCH_LIMIT
+ PCRE_EXTRA_CALLOUT_DATA
+
+Other flag bits should be set to zero. The \fIstudy_data\fR field is set in the
+\fBpcre_extra\fR block that is returned by \fBpcre_study()\fR, together with
+the appropriate flag bit. You should not set this yourself, but you can add to
+the block by setting the other fields.
+
+The \fImatch_limit\fR field provides a means of preventing PCRE from using up a
+vast amount of resources when running patterns that are not going to match,
+but which have a very large number of possibilities in their search trees. The
+classic example is the use of nested unlimited repeats. Internally, PCRE uses a
+function called \fBmatch()\fR which it calls repeatedly (sometimes
+recursively). The limit is imposed on the number of times this function is
+called during a match, which has the effect of limiting the amount of recursion
+and backtracking that can take place. For patterns that are not anchored, the
+count starts from zero for each position in the subject string.
+
+The default limit for the library can be set when PCRE is built; the default
+default is 10 million, which handles all but the most extreme cases. You can
+reduce the default by suppling \fBpcre_exec()\fR with a \fRpcre_extra\fR block
+in which \fImatch_limit\fR is set to a smaller value, and
+PCRE_EXTRA_MATCH_LIMIT is set in the \fIflags\fR field. If the limit is
+exceeded, \fBpcre_exec()\fR returns PCRE_ERROR_MATCHLIMIT.
+
+The \fIpcre_callout\fR field is used in conjunction with the "callout" feature,
+which is described in the \fBpcrecallout\fR documentation.
+
+The PCRE_ANCHORED option can be passed in the \fIoptions\fR argument, whose
+unused bits must be zero. This limits \fBpcre_exec()\fR to matching at the
+first matching position. However, if a pattern was compiled with PCRE_ANCHORED,
+or turned out to be anchored by virtue of its contents, it cannot be made
+unachored at matching time.
+
+There are also three further options that can be set only at matching time:
+
+ PCRE_NOTBOL
+
+The first character of the string is not the beginning of a line, so the
+circumflex metacharacter should not match before it. Setting this without
+PCRE_MULTILINE (at compile time) causes circumflex never to match.
+
+ PCRE_NOTEOL
+
+The end of the string is not the end of a line, so the dollar metacharacter
+should not match it nor (except in multiline mode) a newline immediately before
+it. Setting this without PCRE_MULTILINE (at compile time) causes dollar never
+to match.
+
+ PCRE_NOTEMPTY
+
+An empty string is not considered to be a valid match if this option is set. If
+there are alternatives in the pattern, they are tried. If all the alternatives
+match the empty string, the entire match fails. For example, if the pattern
+
+ a?b?
+
+is applied to a string not beginning with "a" or "b", it matches the empty
+string at the start of the subject. With PCRE_NOTEMPTY set, this match is not
+valid, so PCRE searches further into the string for occurrences of "a" or "b".
+
+Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a special case
+of a pattern match of the empty string within its \fBsplit()\fR function, and
+when using the /g modifier. It is possible to emulate Perl's behaviour after
+matching a null string by first trying the match again at the same offset with
+PCRE_NOTEMPTY set, and then if that fails by advancing the starting offset (see
+below) and trying an ordinary match again.
+
+The subject string is passed to \fBpcre_exec()\fR as a pointer in
+\fIsubject\fR, a length in \fIlength\fR, and a starting offset in
+\fIstartoffset\fR. Unlike the pattern string, the subject may contain binary
+zero bytes. When the starting offset is zero, the search for a match starts at
+the beginning of the subject, and this is by far the most common case.
+
+If the pattern was compiled with the PCRE_UTF8 option, the subject must be a
+sequence of bytes that is a valid UTF-8 string. If an invalid UTF-8 string is
+passed, PCRE's behaviour is not defined.
+
+A non-zero starting offset is useful when searching for another match in the
+same subject by calling \fBpcre_exec()\fR again after a previous success.
+Setting \fIstartoffset\fR differs from just passing over a shortened string and
+setting PCRE_NOTBOL in the case of a pattern that begins with any kind of
+lookbehind. For example, consider the pattern
+
+ \\Biss\\B
+
+which finds occurrences of "iss" in the middle of words. (\\B matches only if
+the current position in the subject is not a word boundary.) When applied to
+the string "Mississipi" the first call to \fBpcre_exec()\fR finds the first
+occurrence. If \fBpcre_exec()\fR is called again with just the remainder of the
+subject, namely "issipi", it does not match, because \\B is always false at the
+start of the subject, which is deemed to be a word boundary. However, if
+\fBpcre_exec()\fR is passed the entire string again, but with \fIstartoffset\fR
+set to 4, it finds the second occurrence of "iss" because it is able to look
+behind the starting point to discover that it is preceded by a letter.
+
+If a non-zero starting offset is passed when the pattern is anchored, one
+attempt to match at the given offset is tried. This can only succeed if the
+pattern does not require the match to be at the start of the subject.
+
+In general, a pattern matches a certain portion of the subject, and in
+addition, further substrings from the subject may be picked out by parts of the
+pattern. Following the usage in Jeffrey Friedl's book, this is called
+"capturing" in what follows, and the phrase "capturing subpattern" is used for
+a fragment of a pattern that picks out a substring. PCRE supports several other
+kinds of parenthesized subpattern that do not cause substrings to be captured.
+
+Captured substrings are returned to the caller via a vector of integer offsets
+whose address is passed in \fIovector\fR. The number of elements in the vector
+is passed in \fIovecsize\fR. The first two-thirds of the vector is used to pass
+back captured substrings, each substring using a pair of integers. The
+remaining third of the vector is used as workspace by \fBpcre_exec()\fR while
+matching capturing subpatterns, and is not available for passing back
+information. The length passed in \fIovecsize\fR should always be a multiple of
+three. If it is not, it is rounded down.
+
+When a match has been successful, information about captured substrings is
+returned in pairs of integers, starting at the beginning of \fIovector\fR, and
+continuing up to two-thirds of its length at the most. The first element of a
+pair is set to the offset of the first character in a substring, and the second
+is set to the offset of the first character after the end of a substring. The
+first pair, \fIovector[0]\fR and \fIovector[1]\fR, identify the portion of the
+subject string matched by the entire pattern. The next pair is used for the
+first capturing subpattern, and so on. The value returned by \fBpcre_exec()\fR
+is the number of pairs that have been set. If there are no capturing
+subpatterns, the return value from a successful match is 1, indicating that
+just the first pair of offsets has been set.
+
+Some convenience functions are provided for extracting the captured substrings
+as separate strings. These are described in the following section.
+
+It is possible for an capturing subpattern number \fIn+1\fR to match some
+part of the subject when subpattern \fIn\fR has not been used at all. For
+example, if the string "abc" is matched against the pattern (a|(z))(bc)
+subpatterns 1 and 3 are matched, but 2 is not. When this happens, both offset
+values corresponding to the unused subpattern are set to -1.
+
+If a capturing subpattern is matched repeatedly, it is the last portion of the
+string that it matched that gets returned.
+
+If the vector is too small to hold all the captured substrings, it is used as
+far as possible (up to two-thirds of its length), and the function returns a
+value of zero. In particular, if the substring offsets are not of interest,
+\fBpcre_exec()\fR may be called with \fIovector\fR passed as NULL and
+\fIovecsize\fR as zero. However, if the pattern contains back references and
+the \fIovector\fR isn't big enough to remember the related substrings, PCRE has
+to get additional memory for use during matching. Thus it is usually advisable
+to supply an \fIovector\fR.
+
+Note that \fBpcre_info()\fR can be used to find out how many capturing
+subpatterns there are in a compiled pattern. The smallest size for
+\fIovector\fR that will allow for \fIn\fR captured substrings, in addition to
+the offsets of the substring matched by the whole pattern, is (\fIn\fR+1)*3.
+
+If \fBpcre_exec()\fR fails, it returns a negative number. The following are
+defined in the header file:
+
+ PCRE_ERROR_NOMATCH (-1)
+
+The subject string did not match the pattern.
+
+ PCRE_ERROR_NULL (-2)
+
+Either \fIcode\fR or \fIsubject\fR was passed as NULL, or \fIovector\fR was
+NULL and \fIovecsize\fR was not zero.
+
+ PCRE_ERROR_BADOPTION (-3)
+
+An unrecognized bit was set in the \fIoptions\fR argument.
+
+ PCRE_ERROR_BADMAGIC (-4)
+
+PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch
+the case when it is passed a junk pointer. This is the error it gives when the
+magic number isn't present.
+
+ PCRE_ERROR_UNKNOWN_NODE (-5)
+
+While running the pattern match, an unknown item was encountered in the
+compiled pattern. This error could be caused by a bug in PCRE or by overwriting
+of the compiled pattern.
+
+ PCRE_ERROR_NOMEMORY (-6)
+
+If a pattern contains back references, but the \fIovector\fR that is passed to
+\fBpcre_exec()\fR is not big enough to remember the referenced substrings, PCRE
+gets a block of memory at the start of matching to use for this purpose. If the
+call via \fBpcre_malloc()\fR fails, this error is given. The memory is freed at
+the end of matching.
+
+ PCRE_ERROR_NOSUBSTRING (-7)
+
+This error is used by the \fBpcre_copy_substring()\fR,
+\fBpcre_get_substring()\fR, and \fBpcre_get_substring_list()\fR functions (see
+below). It is never returned by \fBpcre_exec()\fR.
+
+ PCRE_ERROR_MATCHLIMIT (-8)
+
+The recursion and backtracking limit, as specified by the \fImatch_limit\fR
+field in a \fBpcre_extra\fR structure (or defaulted) was reached. See the
+description above.
+
+ PCRE_ERROR_CALLOUT (-9)
+
+This error is never generated by \fBpcre_exec()\fR itself. It is provided for
+use by callout functions that want to yield a distinctive error code. See the
+\fBpcrecallout\fR documentation for details.
+
+.SH EXTRACTING CAPTURED SUBSTRINGS BY NUMBER
+.rs
+.sp
+.B int pcre_copy_substring(const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, int \fIstringnumber\fR, char *\fIbuffer\fR,
+.ti +5n
+.B int \fIbuffersize\fR);
+.PP
+.br
+.B int pcre_get_substring(const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, int \fIstringnumber\fR,
+.ti +5n
+.B const char **\fIstringptr\fR);
+.PP
+.br
+.B int pcre_get_substring_list(const char *\fIsubject\fR,
+.ti +5n
+.B int *\fIovector\fR, int \fIstringcount\fR, "const char ***\fIlistptr\fR);"
+.PP
+Captured substrings can be accessed directly by using the offsets returned by
+\fBpcre_exec()\fR in \fIovector\fR. For convenience, the functions
+\fBpcre_copy_substring()\fR, \fBpcre_get_substring()\fR, and
+\fBpcre_get_substring_list()\fR are provided for extracting captured substrings
+as new, separate, zero-terminated strings. These functions identify substrings
+by number. The next section describes functions for extracting named
+substrings. A substring that contains a binary zero is correctly extracted and
+has a further zero added on the end, but the result is not, of course,
+a C string.
+
+The first three arguments are the same for all three of these functions:
+\fIsubject\fR is the subject string which has just been successfully matched,
+\fIovector\fR is a pointer to the vector of integer offsets that was passed to
+\fBpcre_exec()\fR, and \fIstringcount\fR is the number of substrings that were
+captured by the match, including the substring that matched the entire regular
+expression. This is the value returned by \fBpcre_exec\fR if it is greater than
+zero. If \fBpcre_exec()\fR returned zero, indicating that it ran out of space
+in \fIovector\fR, the value passed as \fIstringcount\fR should be the size of
+the vector divided by three.
+
+The functions \fBpcre_copy_substring()\fR and \fBpcre_get_substring()\fR
+extract a single substring, whose number is given as \fIstringnumber\fR. A
+value of zero extracts the substring that matched the entire pattern, while
+higher values extract the captured substrings. For \fBpcre_copy_substring()\fR,
+the string is placed in \fIbuffer\fR, whose length is given by
+\fIbuffersize\fR, while for \fBpcre_get_substring()\fR a new block of memory is
+obtained via \fBpcre_malloc\fR, and its address is returned via
+\fIstringptr\fR. The yield of the function is the length of the string, not
+including the terminating zero, or one of
+
+ PCRE_ERROR_NOMEMORY (-6)
+
+The buffer was too small for \fBpcre_copy_substring()\fR, or the attempt to get
+memory failed for \fBpcre_get_substring()\fR.
+
+ PCRE_ERROR_NOSUBSTRING (-7)
+
+There is no substring whose number is \fIstringnumber\fR.
+
+The \fBpcre_get_substring_list()\fR function extracts all available substrings
+and builds a list of pointers to them. All this is done in a single block of
+memory which is obtained via \fBpcre_malloc\fR. The address of the memory block
+is returned via \fIlistptr\fR, which is also the start of the list of string
+pointers. The end of the list is marked by a NULL pointer. The yield of the
+function is zero if all went well, or
+
+ PCRE_ERROR_NOMEMORY (-6)
+
+if the attempt to get the memory block failed.
+
+When any of these functions encounter a substring that is unset, which can
+happen when capturing subpattern number \fIn+1\fR matches some part of the
+subject, but subpattern \fIn\fR has not been used at all, they return an empty
+string. This can be distinguished from a genuine zero-length substring by
+inspecting the appropriate offset in \fIovector\fR, which is negative for unset
+substrings.
+
+The two convenience functions \fBpcre_free_substring()\fR and
+\fBpcre_free_substring_list()\fR can be used to free the memory returned by
+a previous call of \fBpcre_get_substring()\fR or
+\fBpcre_get_substring_list()\fR, respectively. They do nothing more than call
+the function pointed to by \fBpcre_free\fR, which of course could be called
+directly from a C program. However, PCRE is used in some situations where it is
+linked via a special interface to another programming language which cannot use
+\fBpcre_free\fR directly; it is for these cases that the functions are
+provided.
+
+.SH EXTRACTING CAPTURED SUBSTRINGS BY NAME
+.rs
+.sp
+.B int pcre_copy_named_substring(const pcre *\fIcode\fR,
+.ti +5n
+.B const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, const char *\fIstringname\fR,
+.ti +5n
+.B char *\fIbuffer\fR, int \fIbuffersize\fR);
+.PP
+.br
+.B int pcre_get_stringnumber(const pcre *\fIcode\fR,
+.ti +5n
+.B const char *\fIname\fR);
+.PP
+.br
+.B int pcre_get_named_substring(const pcre *\fIcode\fR,
+.ti +5n
+.B const char *\fIsubject\fR, int *\fIovector\fR,
+.ti +5n
+.B int \fIstringcount\fR, const char *\fIstringname\fR,
+.ti +5n
+.B const char **\fIstringptr\fR);
+.PP
+To extract a substring by name, you first have to find associated number. This
+can be done by calling \fBpcre_get_stringnumber()\fR. The first argument is the
+compiled pattern, and the second is the name. For example, for this pattern
+
+ ab(?<xxx>\\d+)...
+
+the number of the subpattern called "xxx" is 1. Given the number, you can then
+extract the substring directly, or use one of the functions described in the
+previous section. For convenience, there are also two functions that do the
+whole job.
+
+Most of the arguments of \fIpcre_copy_named_substring()\fR and
+\fIpcre_get_named_substring()\fR are the same as those for the functions that
+extract by number, and so are not re-described here. There are just two
+differences.
+
+First, instead of a substring number, a substring name is given. Second, there
+is an extra argument, given at the start, which is a pointer to the compiled
+pattern. This is needed in order to gain access to the name-to-number
+translation table.
+
+These functions call \fBpcre_get_stringnumber()\fR, and if it succeeds, they
+then call \fIpcre_copy_substring()\fR or \fIpcre_get_substring()\fR, as
+appropriate.
+
+.in 0
+Last updated: 03 February 2003
+.br
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcrebuild.3 b/doc/pcrebuild.3
new file mode 100644
index 0000000..52ebefb
--- /dev/null
+++ b/doc/pcrebuild.3
@@ -0,0 +1,112 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH PCRE BUILD-TIME OPTIONS
+.rs
+.sp
+This document describes the optional features of PCRE that can be selected when
+the library is compiled. They are all selected, or deselected, by providing
+options to the \fBconfigure\fR script which is run before the \fBmake\fR
+command. The complete list of options for \fBconfigure\fR (which includes the
+standard ones such as the selection of the installation directory) can be
+obtained by running
+
+ ./configure --help
+
+The following sections describe certain options whose names begin with --enable
+or --disable. These settings specify changes to the defaults for the
+\fBconfigure\fR command. Because of the way that \fBconfigure\fR works,
+--enable and --disable always come in pairs, so the complementary option always
+exists as well, but as it specifies the default, it is not described.
+
+.SH UTF-8 SUPPORT
+.rs
+.sp
+To build PCRE with support for UTF-8 character strings, add
+
+ --enable-utf8
+
+to the \fBconfigure\fR command. Of itself, this does not make PCRE treat
+strings as UTF-8. As well as compiling PCRE with this option, you also have
+have to set the PCRE_UTF8 option when you call the \fBpcre_compile()\fR
+function.
+
+.SH CODE VALUE OF NEWLINE
+.rs
+.sp
+By default, PCRE treats character 10 (linefeed) as the newline character. This
+is the normal newline character on Unix-like systems. You can compile PCRE to
+use character 13 (carriage return) instead by adding
+
+ --enable-newline-is-cr
+
+to the \fBconfigure\fR command. For completeness there is also a
+--enable-newline-is-lf option, which explicitly specifies linefeed as the
+newline character.
+
+.SH BUILDING SHARED AND STATIC LIBRARIES
+.rs
+.sp
+The PCRE building process uses \fBlibtool\fR to build both shared and static
+Unix libraries by default. You can suppress one of these by adding one of
+
+ --disable-shared
+ --disable-static
+
+to the \fBconfigure\fR command, as required.
+
+.SH POSIX MALLOC USAGE
+.rs
+.sp
+When PCRE is called through the POSIX interface (see the \fBpcreposix\fR
+documentation), additional working storage is required for holding the pointers
+to capturing substrings because PCRE requires three integers per substring,
+whereas the POSIX interface provides only two. If the number of expected
+substrings is small, the wrapper function uses space on the stack, because this
+is faster than using \fBmalloc()\fR for each call. The default threshold above
+which the stack is no longer used is 10; it can be changed by adding a setting
+such as
+
+ --with-posix-malloc-threshold=20
+
+to the \fBconfigure\fR command.
+
+.SH LIMITING PCRE RESOURCE USAGE
+.rs
+.sp
+Internally, PCRE has a function called \fBmatch()\fR which it calls repeatedly
+(possibly recursively) when performing a matching operation. By limiting the
+number of times this function may be called, a limit can be placed on the
+resources used by a single call to \fBpcre_exec()\fR. The limit can be changed
+at run time, as described in the \fBpcreapi\fR documentation. The default is 10
+million, but this can be changed by adding a setting such as
+
+ --with-match-limit=500000
+
+to the \fBconfigure\fR command.
+
+.SH HANDLING VERY LARGE PATTERNS
+.rs
+.sp
+Within a compiled pattern, offset values are used to point from one part to
+another (for example, from an opening parenthesis to an alternation
+metacharacter). By default two-byte values are used for these offsets, leading
+to a maximum size for a compiled pattern of around 64K. This is sufficient to
+handle all but the most gigantic patterns. Nevertheless, some people do want to
+process enormous patterns, so it is possible to compile PCRE to use three-byte
+or four-byte offsets by adding a setting such as
+
+ --with-link-size=3
+
+to the \fBconfigure\fR command. The value given must be 2, 3, or 4. Using
+longer offsets slows down the operation of PCRE because it has to load
+additional bytes when handling them.
+
+If you build PCRE with an increased link size, test 2 (and test 5 if you are
+using UTF-8) will fail. Part of the output of these tests is a representation
+of the compiled pattern, and this changes with the link size.
+
+.in 0
+Last updated: 21 January 2003
+.br
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcrecallout.3 b/doc/pcrecallout.3
new file mode 100644
index 0000000..f54d0dd
--- /dev/null
+++ b/doc/pcrecallout.3
@@ -0,0 +1,91 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH PCRE CALLOUTS
+.rs
+.sp
+.B int (*pcre_callout)(pcre_callout_block *);
+.PP
+PCRE provides a feature called "callout", which is a means of temporarily
+passing control to the caller of PCRE in the middle of pattern matching. The
+caller of PCRE provides an external function by putting its entry point in the
+global variable \fIpcre_callout\fR. By default, this variable contains NULL,
+which disables all calling out.
+
+Within a regular expression, (?C) indicates the points at which the external
+function is to be called. Different callout points can be identified by putting
+a number less than 256 after the letter C. The default value is zero.
+For example, this pattern has two callout points:
+
+ (?C1)\dabc(?C2)def
+
+During matching, when PCRE reaches a callout point (and \fIpcre_callout\fR is
+set), the external function is called. Its only argument is a pointer to a
+\fBpcre_callout\fR block. This contains the following variables:
+
+ int \fIversion\fR;
+ int \fIcallout_number\fR;
+ int *\fIoffset_vector\fR;
+ const char *\fIsubject\fR;
+ int \fIsubject_length\fR;
+ int \fIstart_match\fR;
+ int \fIcurrent_position\fR;
+ int \fIcapture_top\fR;
+ int \fIcapture_last\fR;
+ void *\fIcallout_data\fR;
+
+The \fIversion\fR field is an integer containing the version number of the
+block format. The current version is zero. The version number may change in
+future if additional fields are added, but the intention is never to remove any
+of the existing fields.
+
+The \fIcallout_number\fR field contains the number of the callout, as compiled
+into the pattern (that is, the number after ?C).
+
+The \fIoffset_vector\fR field is a pointer to the vector of offsets that was
+passed by the caller to \fBpcre_exec()\fR. The contents can be inspected in
+order to extract substrings that have been matched so far, in the same way as
+for extracting substrings after a match has completed.
+
+The \fIsubject\fR and \fIsubject_length\fR fields contain copies the values
+that were passed to \fBpcre_exec()\fR.
+
+The \fIstart_match\fR field contains the offset within the subject at which the
+current match attempt started. If the pattern is not anchored, the callout
+function may be called several times for different starting points.
+
+The \fIcurrent_position\fR field contains the offset within the subject of the
+current match pointer.
+
+The \fIcapture_top\fR field contains the number of the highest captured
+substring so far.
+
+The \fIcapture_last\fR field contains the number of the most recently captured
+substring.
+
+The \fIcallout_data\fR field contains a value that is passed to
+\fBpcre_exec()\fR by the caller specifically so that it can be passed back in
+callouts. It is passed in the \fIpcre_callout\fR field of the \fBpcre_extra\fR
+data structure. If no such data was passed, the value of \fIcallout_data\fR in
+a \fBpcre_callout\fR block is NULL. There is a description of the
+\fBpcre_extra\fR structure in the \fBpcreapi\fR documentation.
+
+
+.SH RETURN VALUES
+.rs
+.sp
+The callout function returns an integer. If the value is zero, matching
+proceeds as normal. If the value is greater than zero, matching fails at the
+current point, but backtracking to test other possibilities goes ahead, just as
+if a lookahead assertion had failed. If the value is less than zero, the match
+is abandoned, and \fBpcre_exec()\fR returns the value.
+
+Negative values should normally be chosen from the set of PCRE_ERROR_xxx
+values. In particular, PCRE_ERROR_NOMATCH forces a standard "no match" failure.
+The error number PCRE_ERROR_CALLOUT is reserved for use by callout functions;
+it will never be used by PCRE itself.
+
+.in 0
+Last updated: 21 January 2003
+.br
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcrecompat.3 b/doc/pcrecompat.3
new file mode 100644
index 0000000..7af9ede
--- /dev/null
+++ b/doc/pcrecompat.3
@@ -0,0 +1,95 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH DIFFERENCES FROM PERL
+.rs
+.sp
+This document describes the differences in the ways that PCRE and Perl handle
+regular expressions. The differences described here are with respect to Perl
+5.8.
+
+1. PCRE does not allow repeat quantifiers on lookahead assertions. Perl permits
+them, but they do not mean what you might think. For example, (?!a){3} does
+not assert that the next three characters are not "a". It just asserts that the
+next character is not "a" three times.
+
+2. Capturing subpatterns that occur inside negative lookahead assertions are
+counted, but their entries in the offsets vector are never set. Perl sets its
+numerical variables from any such patterns that are matched before the
+assertion fails to match something (thereby succeeding), but only if the
+negative lookahead assertion contains just one branch.
+
+3. Though binary zero characters are supported in the subject string, they are
+not allowed in a pattern string because it is passed as a normal C string,
+terminated by zero. The escape sequence "\\0" can be used in the pattern to
+represent a binary zero.
+
+4. The following Perl escape sequences are not supported: \\l, \\u, \\L,
+\\U, \\P, \\p, \N, and \\X. In fact these are implemented by Perl's general
+string-handling and are not part of its pattern matching engine. If any of
+these are encountered by PCRE, an error is generated.
+
+5. PCRE does support the \\Q...\\E escape for quoting substrings. Characters in
+between are treated as literals. This is slightly different from Perl in that $
+and @ are also handled as literals inside the quotes. In Perl, they cause
+variable interpolation (but of course PCRE does not have variables). Note the
+following examples:
+
+ Pattern PCRE matches Perl matches
+
+ \\Qabc$xyz\\E abc$xyz abc followed by the
+ contents of $xyz
+ \\Qabc\\$xyz\\E abc\\$xyz abc\\$xyz
+ \\Qabc\\E\\$\\Qxyz\\E abc$xyz abc$xyz
+
+In PCRE, the \\Q...\\E mechanism is not recognized inside a character class.
+
+8. Fairly obviously, PCRE does not support the (?{code}) and (?p{code})
+constructions. However, there is some experimental support for recursive
+patterns using the non-Perl items (?R), (?number) and (?P>name). Also, the PCRE
+"callout" feature allows an external function to be called during pattern
+matching.
+
+9. There are some differences that are concerned with the settings of captured
+strings when part of a pattern is repeated. For example, matching "aba" against
+the pattern /^(a(b)?)+$/ in Perl leaves $2 unset, but in PCRE it is set to "b".
+
+10. PCRE provides some extensions to the Perl regular expression facilities:
+
+(a) Although lookbehind assertions must match fixed length strings, each
+alternative branch of a lookbehind assertion can match a different length of
+string. Perl requires them all to have the same length.
+
+(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $
+meta-character matches only at the very end of the string.
+
+(c) If PCRE_EXTRA is set, a backslash followed by a letter with no special
+meaning is faulted.
+
+(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is
+inverted, that is, by default they are not greedy, but if followed by a
+question mark they are.
+
+(e) PCRE_ANCHORED can be used to force a pattern to be tried only at the first
+matching position in the subject string.
+
+(f) The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, and PCRE_NO_AUTO_CAPTURE
+options for \fBpcre_exec()\fR have no Perl equivalents.
+
+(g) The (?R), (?number), and (?P>name) constructs allows for recursive pattern
+matching (Perl can do this using the (?p{code}) construct, which PCRE cannot
+support.)
+
+(h) PCRE supports named capturing substrings, using the Python syntax.
+
+(i) PCRE supports the possessive quantifier "++" syntax, taken from Sun's Java
+package.
+
+(j) The (R) condition, for testing recursion, is a PCRE extension.
+
+(k) The callout facility is PCRE-specific.
+
+.in 0
+Last updated: 03 February 2003
+.br
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcregrep.1 b/doc/pcregrep.1
index 5d3151e..c40dc05 100644
--- a/doc/pcregrep.1
+++ b/doc/pcregrep.1
@@ -2,14 +2,22 @@
.SH NAME
pcregrep - a grep with Perl-compatible regular expressions.
.SH SYNOPSIS
-.B pcregrep [-Vcfhilnrsvx] pattern [file] ...
-
+.B pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...]
.SH DESCRIPTION
+.rs
+.sp
\fBpcregrep\fR searches files for character patterns, in the same way as other
grep commands do, but it uses the PCRE regular expression library to support
patterns that are compatible with the regular expressions of Perl 5. See
-\fBpcre(3)\fR for a full description of syntax and semantics.
+.\" HREF
+\fBpcrepattern\fR
+.\"
+for a full description of syntax and semantics of the regular expressions that
+PCRE supports.
+
+A pattern must be specified on the command line unless the \fB-f\fR option is
+used (see below).
If no files are specified, \fBpcregrep\fR reads the standard input. By default,
each line that matches the pattern is copied to the standard output, and if
@@ -20,8 +28,9 @@ Lines are limited to BUFSIZ characters. BUFSIZ is defined in \fB<stdio.h>\fR.
The newline character is removed from the end of each line before it is matched
against the pattern.
-
.SH OPTIONS
+.rs
+.sp
.TP 10
\fB-V\fR
Write the version number of the PCRE library being used to the standard error
@@ -32,11 +41,13 @@ Do not print individual lines; instead just print a count of the number of
lines that would otherwise have been printed. If several files are given, a
count is printed for each of them.
.TP
-\fB-f\fIfilename\fR
-Read patterns from the file, one per line, and match all patterns against each
-line. There is a maximum of 100 patterns. Trailing white space is removed, and
-blank lines are ignored. An empty file contains no patterns and therefore
-matches nothing.
+\fB-f\fR\fIfilename\fR
+Read a number of patterns from the file, one per line, and match all of them
+against each line of input. A line is output if any of the patterns match it.
+When \fB-f\fR is used, no pattern is taken from the command line; all arguments
+are treated as file names. There is a maximum of 100 patterns. Trailing white
+space is removed, and blank lines are ignored. An empty file contains no
+patterns and therefore matches nothing.
.TP
\fB-h\fR
Suppress printing of filenames when searching multiple files.
@@ -60,6 +71,11 @@ If any file is a directory, recursively scan the files it contains. Without
Work silently, that is, display nothing except error messages.
The exit status indicates whether any matches were found.
.TP
+\fB-u\fR
+Operate in UTF-8 mode. This option is available only if PCRE has been compiled
+with UTF-8 support. Both the pattern and each subject line are assumed to be
+valid strings of UTF-8 characters.
+.TP
\fB-v\fR
Invert the sense of the match, so that lines which do \fInot\fR match the
pattern are now the ones that are found.
@@ -70,19 +86,45 @@ the line) and in addition, require it to match the entire line. This is
equivalent to having ^ and $ characters at the start and end of each
alternative branch in the regular expression.
+.SH LONG OPTIONS
+.rs
+.sp
+Long forms of all the options are available, as in GNU grep. They are shown in
+the following table:
-.SH SEE ALSO
-\fBpcre(3)\fR, Perl 5 documentation
+ -c --count
+ -h --no-filename
+ -i --ignore-case
+ -l --files-with-matches
+ -n --line-number
+ -r --recursive
+ -s --no-messages
+ -u --utf-8
+ -V --version
+ -v --invert-match
+ -x --line-regex
+ -x --line-regexp
+In addition, --file=\fIfilename\fR is equivalent to -f\fIfilename\fR, and
+--help shows the list of options and then exits.
.SH DIAGNOSTICS
+.rs
+.sp
Exit status is 0 if any matches were found, 1 if no matches were found, and 2
for syntax errors or inacessible files (even if matches were found).
.SH AUTHOR
+.rs
+.sp
Philip Hazel <ph10@cam.ac.uk>
+.br
+University Computing Service
+.br
+Cambridge CB2 3QG, England.
-Last updated: 15 August 2001
+.in 0
+Last updated: 03 February 2003
.br
-Copyright (c) 1997-2001 University of Cambridge.
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcregrep.html b/doc/pcregrep.html
deleted file mode 100644
index 7bc210c..0000000
--- a/doc/pcregrep.html
+++ /dev/null
@@ -1,120 +0,0 @@
-<HTML>
-<HEAD>
-<TITLE>pcregrep specification</TITLE>
-</HEAD>
-<body bgcolor="#FFFFFF" text="#00005A">
-<H1>pcregrep specification</H1>
-This HTML document has been generated automatically from the original man page.
-If there is any nonsense in it, please consult the man page in case the
-conversion went wrong.
-<UL>
-<LI><A NAME="TOC1" HREF="#SEC1">NAME</A>
-<LI><A NAME="TOC2" HREF="#SEC2">SYNOPSIS</A>
-<LI><A NAME="TOC3" HREF="#SEC3">DESCRIPTION</A>
-<LI><A NAME="TOC4" HREF="#SEC4">OPTIONS</A>
-<LI><A NAME="TOC5" HREF="#SEC5">SEE ALSO</A>
-<LI><A NAME="TOC6" HREF="#SEC6">DIAGNOSTICS</A>
-<LI><A NAME="TOC7" HREF="#SEC7">AUTHOR</A>
-</UL>
-<LI><A NAME="SEC1" HREF="#TOC1">NAME</A>
-<P>
-pcregrep - a grep with Perl-compatible regular expressions.
-</P>
-<LI><A NAME="SEC2" HREF="#TOC1">SYNOPSIS</A>
-<P>
-<B>pcregrep [-Vcfhilnrsvx] pattern [file] ...</B>
-</P>
-<LI><A NAME="SEC3" HREF="#TOC1">DESCRIPTION</A>
-<P>
-<B>pcregrep</B> searches files for character patterns, in the same way as other
-grep commands do, but it uses the PCRE regular expression library to support
-patterns that are compatible with the regular expressions of Perl 5. See
-<B>pcre(3)</B> for a full description of syntax and semantics.
-</P>
-<P>
-If no files are specified, <B>pcregrep</B> reads the standard input. By default,
-each line that matches the pattern is copied to the standard output, and if
-there is more than one file, the file name is printed before each line of
-output. However, there are options that can change how <B>pcregrep</B> behaves.
-</P>
-<P>
-Lines are limited to BUFSIZ characters. BUFSIZ is defined in <B>&#60;stdio.h&#62;</B>.
-The newline character is removed from the end of each line before it is matched
-against the pattern.
-</P>
-<LI><A NAME="SEC4" HREF="#TOC1">OPTIONS</A>
-<P>
-<B>-V</B>
-Write the version number of the PCRE library being used to the standard error
-stream.
-</P>
-<P>
-<B>-c</B>
-Do not print individual lines; instead just print a count of the number of
-lines that would otherwise have been printed. If several files are given, a
-count is printed for each of them.
-</P>
-<P>
-\fB-f<I>filename</I>
-Read patterns from the file, one per line, and match all patterns against each
-line. There is a maximum of 100 patterns. Trailing white space is removed, and
-blank lines are ignored. An empty file contains no patterns and therefore
-matches nothing.
-</P>
-<P>
-<B>-h</B>
-Suppress printing of filenames when searching multiple files.
-</P>
-<P>
-<B>-i</B>
-Ignore upper/lower case distinctions during comparisons.
-</P>
-<P>
-<B>-l</B>
-Instead of printing lines from the files, just print the names of the files
-containing lines that would have been printed. Each file name is printed
-once, on a separate line.
-</P>
-<P>
-<B>-n</B>
-Precede each line by its line number in the file.
-</P>
-<P>
-<B>-r</B>
-If any file is a directory, recursively scan the files it contains. Without
-<B>-r</B> a directory is scanned as a normal file.
-</P>
-<P>
-<B>-s</B>
-Work silently, that is, display nothing except error messages.
-The exit status indicates whether any matches were found.
-</P>
-<P>
-<B>-v</B>
-Invert the sense of the match, so that lines which do <I>not</I> match the
-pattern are now the ones that are found.
-</P>
-<P>
-<B>-x</B>
-Force the pattern to be anchored (it must start matching at the beginning of
-the line) and in addition, require it to match the entire line. This is
-equivalent to having ^ and $ characters at the start and end of each
-alternative branch in the regular expression.
-</P>
-<LI><A NAME="SEC5" HREF="#TOC1">SEE ALSO</A>
-<P>
-<B>pcre(3)</B>, Perl 5 documentation
-</P>
-<LI><A NAME="SEC6" HREF="#TOC1">DIAGNOSTICS</A>
-<P>
-Exit status is 0 if any matches were found, 1 if no matches were found, and 2
-for syntax errors or inacessible files (even if matches were found).
-</P>
-<LI><A NAME="SEC7" HREF="#TOC1">AUTHOR</A>
-<P>
-Philip Hazel &#60;ph10@cam.ac.uk&#62;
-</P>
-<P>
-Last updated: 15 August 2001
-<BR>
-Copyright (c) 1997-2001 University of Cambridge.
diff --git a/doc/pcregrep.txt b/doc/pcregrep.txt
index 1600228..ebff1e3 100644
--- a/doc/pcregrep.txt
+++ b/doc/pcregrep.txt
@@ -2,18 +2,21 @@ NAME
pcregrep - a grep with Perl-compatible regular expressions.
-
SYNOPSIS
- pcregrep [-Vcfhilnrsvx] pattern [file] ...
-
+ pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1
DESCRIPTION
+
pcregrep searches files for character patterns, in the same
way as other grep commands do, but it uses the PCRE regular
expression library to support patterns that are compatible
- with the regular expressions of Perl 5. See pcre(3) for a
- full description of syntax and semantics.
+ with the regular expressions of Perl 5. See pcrepattern for
+ a full description of syntax and semantics of the regular
+ expressions that PCRE supports.
+
+ A pattern must be specified on the command line unless the
+ -f option is used (see below).
If no files are specified, pcregrep reads the standard
input. By default, each line that matches the pattern is
@@ -27,8 +30,9 @@ DESCRIPTION
each line before it is matched against the pattern.
-
OPTIONS
+
+
-V Write the version number of the PCRE library being
used to the standard error stream.
@@ -38,12 +42,15 @@ OPTIONS
given, a count is printed for each of them.
-ffilename
- Read patterns from the file, one per line, and
- match all patterns against each line. There is a
- maximum of 100 patterns. Trailing white space is
- removed, and blank lines are ignored. An empty
- file contains no patterns and therefore matches
- nothing.
+ Read a number of patterns from the file, one per
+ line, and match all of them against each line of
+ input. A line is output if any of the patterns
+ match it. When -f is used, no pattern is taken
+ from the command line; all arguments are treated
+ as file names. There is a maximum of 100 patterns.
+ Trailing white space is removed, and blank lines
+ are ignored. An empty file contains no patterns
+ and therefore matches nothing.
-h Suppress printing of filenames when searching mul-
tiple files.
@@ -52,7 +59,6 @@ OPTIONS
parisons.
-l Instead of printing lines from the files, just
-
print the names of the files containing lines that
would have been printed. Each file name is printed
once, on a separate line.
@@ -67,6 +73,11 @@ OPTIONS
error messages. The exit status indicates whether
any matches were found.
+ -u Operate in UTF-8 mode. This option is available
+ only if PCRE has been compiled with UTF-8 support.
+ Both the pattern and each subject line are assumed
+ to be valid strings of UTF-8 characters.
+
-v Invert the sense of the match, so that lines which
do not match the pattern are now the ones that are
found.
@@ -79,15 +90,30 @@ OPTIONS
the regular expression.
+LONG OPTIONS
-SEE ALSO
- pcre(3), Perl 5 documentation
-
+ Long forms of all the options are available, as in GNU grep.
+ They are shown in the following table:
+ -c --count
+ -h --no-filename
+ -i --ignore-case
+ -l --files-with-matches
+ -n --line-number
+ -r --recursive
+ -s --no-messages
+ -u --utf-8
+ -V --version
+ -v --invert-match
+ -x --line-regex
+ -x --line-regexp
+ In addition, --file=filename is equivalent to -ffilename,
+ and --help shows the list of options and then exits.
DIAGNOSTICS
+
Exit status is 0 if any matches were found, 1 if no matches
were found, and 2 for syntax errors or inacessible files
(even if matches were found).
@@ -95,7 +121,10 @@ DIAGNOSTICS
AUTHOR
+
Philip Hazel <ph10@cam.ac.uk>
+ University Computing Service
+ Cambridge CB2 3QG, England.
- Last updated: 15 August 2001
- Copyright (c) 1997-2001 University of Cambridge.
+Last updated: 03 February 2003
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcrepattern.3 b/doc/pcrepattern.3
new file mode 100644
index 0000000..cef74e1
--- /dev/null
+++ b/doc/pcrepattern.3
@@ -0,0 +1,1231 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH PCRE REGULAR EXPRESSION DETAILS
+.rs
+.sp
+The syntax and semantics of the regular expressions supported by PCRE are
+described below. Regular expressions are also described in the Perl
+documentation and in a number of other books, some of which have copious
+examples. Jeffrey Friedl's "Mastering Regular Expressions", published by
+O'Reilly, covers them in great detail. The description here is intended as
+reference documentation.
+
+The basic operation of PCRE is on strings of bytes. However, there is also
+support for UTF-8 character strings. To use this support you must build PCRE to
+include UTF-8 support, and then call \fBpcre_compile()\fR with the PCRE_UTF8
+option. How this affects the pattern matching is mentioned in several places
+below. There is also a summary of UTF-8 features in the
+.\" HTML <a href="pcre.html#utf8support">
+.\" </a>
+section on UTF-8 support
+.\"
+in the main
+.\" HREF
+\fBpcre\fR
+.\"
+page.
+
+A regular expression is a pattern that is matched against a subject string from
+left to right. Most characters stand for themselves in a pattern, and match the
+corresponding characters in the subject. As a trivial example, the pattern
+
+ The quick brown fox
+
+matches a portion of a subject string that is identical to itself. The power of
+regular expressions comes from the ability to include alternatives and
+repetitions in the pattern. These are encoded in the pattern by the use of
+\fImeta-characters\fR, which do not stand for themselves but instead are
+interpreted in some special way.
+
+There are two different sets of meta-characters: those that are recognized
+anywhere in the pattern except within square brackets, and those that are
+recognized in square brackets. Outside square brackets, the meta-characters are
+as follows:
+
+ \\ general escape character with several uses
+ ^ assert start of string (or line, in multiline mode)
+ $ assert end of string (or line, in multiline mode)
+ . match any character except newline (by default)
+ [ start character class definition
+ | start of alternative branch
+ ( start subpattern
+ ) end subpattern
+ ? extends the meaning of (
+ also 0 or 1 quantifier
+ also quantifier minimizer
+ * 0 or more quantifier
+ + 1 or more quantifier
+ also "possessive quantifier"
+ { start min/max quantifier
+
+Part of a pattern that is in square brackets is called a "character class". In
+a character class the only meta-characters are:
+
+ \\ general escape character
+ ^ negate the class, but only if the first character
+ - indicates character range
+ [ POSIX character class (only if followed by POSIX
+ syntax)
+ ] terminates the character class
+
+The following sections describe the use of each of the meta-characters.
+
+.SH BACKSLASH
+.rs
+.sp
+The backslash character has several uses. Firstly, if it is followed by a
+non-alphameric character, it takes away any special meaning that character may
+have. This use of backslash as an escape character applies both inside and
+outside character classes.
+
+For example, if you want to match a * character, you write \\* in the pattern.
+This escaping action applies whether or not the following character would
+otherwise be interpreted as a meta-character, so it is always safe to precede a
+non-alphameric with backslash to specify that it stands for itself. In
+particular, if you want to match a backslash, you write \\\\.
+
+If a pattern is compiled with the PCRE_EXTENDED option, whitespace in the
+pattern (other than in a character class) and characters between a # outside
+a character class and the next newline character are ignored. An escaping
+backslash can be used to include a whitespace or # character as part of the
+pattern.
+
+If you want to remove the special meaning from a sequence of characters, you
+can do so by putting them between \\Q and \\E. This is different from Perl in
+that $ and @ are handled as literals in \\Q...\\E sequences in PCRE, whereas in
+Perl, $ and @ cause variable interpolation. Note the following examples:
+
+ Pattern PCRE matches Perl matches
+
+ \\Qabc$xyz\\E abc$xyz abc followed by the
+ contents of $xyz
+ \\Qabc\\$xyz\\E abc\\$xyz abc\\$xyz
+ \\Qabc\\E\\$\\Qxyz\\E abc$xyz abc$xyz
+
+The \\Q...\\E sequence is recognized both inside and outside character classes.
+
+A second use of backslash provides a way of encoding non-printing characters
+in patterns in a visible manner. There is no restriction on the appearance of
+non-printing characters, apart from the binary zero that terminates a pattern,
+but when a pattern is being prepared by text editing, it is usually easier to
+use one of the following escape sequences than the binary character it
+represents:
+
+ \\a alarm, that is, the BEL character (hex 07)
+ \\cx "control-x", where x is any character
+ \\e escape (hex 1B)
+ \\f formfeed (hex 0C)
+ \\n newline (hex 0A)
+ \\r carriage return (hex 0D)
+ \\t tab (hex 09)
+ \\ddd character with octal code ddd, or backreference
+ \\xhh character with hex code hh
+ \\x{hhh..} character with hex code hhh... (UTF-8 mode only)
+
+The precise effect of \\cx is as follows: if x is a lower case letter, it
+is converted to upper case. Then bit 6 of the character (hex 40) is inverted.
+Thus \\cz becomes hex 1A, but \\c{ becomes hex 3B, while \\c; becomes hex
+7B.
+
+After \\x, from zero to two hexadecimal digits are read (letters can be in
+upper or lower case). In UTF-8 mode, any number of hexadecimal digits may
+appear between \\x{ and }, but the value of the character code must be less
+than 2**31 (that is, the maximum hexadecimal value is 7FFFFFFF). If characters
+other than hexadecimal digits appear between \\x{ and }, or if there is no
+terminating }, this form of escape is not recognized. Instead, the initial
+\\x will be interpreted as a basic hexadecimal escape, with no following
+digits, giving a byte whose value is zero.
+
+Characters whose value is less than 256 can be defined by either of the two
+syntaxes for \\x when PCRE is in UTF-8 mode. There is no difference in the
+way they are handled. For example, \\xdc is exactly the same as \\x{dc}.
+
+After \\0 up to two further octal digits are read. In both cases, if there
+are fewer than two digits, just those that are present are used. Thus the
+sequence \\0\\x\\07 specifies two binary zeros followed by a BEL character
+(code value 7). Make sure you supply two digits after the initial zero if the
+character that follows is itself an octal digit.
+
+The handling of a backslash followed by a digit other than 0 is complicated.
+Outside a character class, PCRE reads it and any following digits as a decimal
+number. If the number is less than 10, or if there have been at least that many
+previous capturing left parentheses in the expression, the entire sequence is
+taken as a \fIback reference\fR. A description of how this works is given
+later, following the discussion of parenthesized subpatterns.
+
+Inside a character class, or if the decimal number is greater than 9 and there
+have not been that many capturing subpatterns, PCRE re-reads up to three octal
+digits following the backslash, and generates a single byte from the least
+significant 8 bits of the value. Any subsequent digits stand for themselves.
+For example:
+
+ \\040 is another way of writing a space
+ \\40 is the same, provided there are fewer than 40
+ previous capturing subpatterns
+ \\7 is always a back reference
+ \\11 might be a back reference, or another way of
+ writing a tab
+ \\011 is always a tab
+ \\0113 is a tab followed by the character "3"
+ \\113 might be a back reference, otherwise the
+ character with octal code 113
+ \\377 might be a back reference, otherwise
+ the byte consisting entirely of 1 bits
+ \\81 is either a back reference, or a binary zero
+ followed by the two characters "8" and "1"
+
+Note that octal values of 100 or greater must not be introduced by a leading
+zero, because no more than three octal digits are ever read.
+
+All the sequences that define a single byte value or a single UTF-8 character
+(in UTF-8 mode) can be used both inside and outside character classes. In
+addition, inside a character class, the sequence \\b is interpreted as the
+backspace character (hex 08). Outside a character class it has a different
+meaning (see below).
+
+The third use of backslash is for specifying generic character types:
+
+ \\d any decimal digit
+ \\D any character that is not a decimal digit
+ \\s any whitespace character
+ \\S any character that is not a whitespace character
+ \\w any "word" character
+ \\W any "non-word" character
+
+Each pair of escape sequences partitions the complete set of characters into
+two disjoint sets. Any given character matches one, and only one, of each pair.
+
+In UTF-8 mode, characters with values greater than 255 never match \\d, \\s, or
+\\w, and always match \\D, \\S, and \\W.
+
+For compatibility with Perl, \\s does not match the VT character (code 11).
+This makes it different from the the POSIX "space" class. The \\s characters
+are HT (9), LF (10), FF (12), CR (13), and space (32).
+
+A "word" character is any letter or digit or the underscore character, that is,
+any character which can be part of a Perl "word". The definition of letters and
+digits is controlled by PCRE's character tables, and may vary if locale-
+specific matching is taking place (see
+.\" HTML <a href="pcreapi.html#localesupport">
+.\" </a>
+"Locale support"
+.\"
+in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page). For example, in the "fr" (French) locale, some character codes greater
+than 128 are used for accented letters, and these are matched by \\w.
+
+These character type sequences can appear both inside and outside character
+classes. They each match one character of the appropriate type. If the current
+matching point is at the end of the subject string, all of them fail, since
+there is no character to match.
+
+The fourth use of backslash is for certain simple assertions. An assertion
+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
+ \\B matches when not at a word boundary
+ \\A matches at start of subject
+ \\Z matches at end of subject or before newline at end
+ \\z matches at end of subject
+ \\G matches at first matching position in subject
+
+These assertions may not appear in character classes (but note that \\b has a
+different meaning, namely the backspace character, inside a character class).
+
+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.
+
+The \\A, \\Z, and \\z assertions differ from the traditional circumflex and
+dollar (described below) 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.
+
+They are not affected by the PCRE_NOTBOL or PCRE_NOTEOL options. If the
+\fIstartoffset\fR argument of \fBpcre_exec()\fR 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 that is the last character of the string as well as at the end of the
+string, 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 \fIstartoffset\fR argument of
+\fBpcre_exec()\fR. It differs from \\A when the value of \fIstartoffset\fR is
+non-zero. By calling \fBpcre_exec()\fR 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 PCRE'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 PCRE 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 anchored
+to the starting match position, and the "anchored" flag is set in the compiled
+regular expression.
+
+.SH CIRCUMFLEX AND DOLLAR
+.rs
+.sp
+Outside a character class, in the default matching mode, the circumflex
+character is an assertion which is true only if the current matching point is
+at the start of the subject string. If the \fIstartoffset\fR argument of
+\fBpcre_exec()\fR is non-zero, circumflex can never match if the PCRE_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 subject, it is said to be an
+"anchored" pattern. (There are also other constructs that can cause a pattern
+to be anchored.)
+
+A dollar character is an assertion which is true only if the current matching
+point is at the end of the subject string, or immediately before a newline
+character that is the last character in the string (by default). Dollar need
+not be the last character of the pattern if a number 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 character class.
+
+The meaning of dollar can be changed so that it matches only at the very end of
+the string, by setting the PCRE_DOLLAR_ENDONLY option at compile time. This
+does not affect the \\Z assertion.
+
+The meanings of the circumflex and dollar characters are changed if the
+PCRE_MULTILINE option is set. When this is the case, they match immediately
+after and immediately before an internal newline character, respectively, in
+addition to matching at the start and end of the subject string. For example,
+the pattern /^abc$/ matches the subject string "def\\nabc" 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 \fIstartoffset\fR argument of
+\fBpcre_exec()\fR is non-zero. The PCRE_DOLLAR_ENDONLY option is ignored if
+PCRE_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 PCRE_MULTILINE is set or not.
+
+.SH FULL STOP (PERIOD, DOT)
+.rs
+.sp
+Outside a character class, a dot in the pattern matches any one character in
+the subject, including a non-printing character, but not (by default) newline.
+In UTF-8 mode, a dot matches any UTF-8 character, which might be more than one
+byte long, except (by default) for newline. If the PCRE_DOTALL option is set,
+dots match newlines as well. The handling of dot is entirely independent of the
+handling of circumflex and dollar, the only relationship being that they both
+involve newline characters. Dot has no special meaning in a character class.
+
+.SH MATCHING A SINGLE BYTE
+.rs
+.sp
+Outside a character class, the escape sequence \\C matches any one byte, both
+in and out of UTF-8 mode. Unlike a dot, it always matches a newline. The
+feature is provided in Perl in order to match individual bytes in UTF-8 mode.
+Because it breaks up UTF-8 characters into individual bytes, what remains in
+the string may be a malformed UTF-8 string. For this reason it is best avoided.
+
+PCRE does not allow \\C to appear in lookbehind assertions (see below), because
+in UTF-8 mode it makes it impossible to calculate the length of the lookbehind.
+
+.SH SQUARE BRACKETS
+.rs
+.sp
+An opening square bracket introduces a character class, terminated by a closing
+square bracket. A closing square bracket on its own is not special. 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.
+
+A character class matches a single character in the subject. In UTF-8 mode, the
+character may occupy more than one byte. 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 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 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. Note that a
+circumflex is just a convenient notation for specifying the characters which
+are in the class by enumerating those that are not. It is not an assertion: it
+still consumes a character from the subject string, and fails if the current
+pointer is at the end of the string.
+
+In UTF-8 mode, characters with values greater than 255 can be included in a
+class as a literal string of bytes, or by using the \\x{ escaping mechanism.
+
+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. PCRE does not support the concept of case for characters
+with values greater than 255.
+
+The newline character is never treated in any special way in character classes,
+whatever the setting of the PCRE_DOTALL or PCRE_MULTILINE options is. A class
+such as [^a] will always match a newline.
+
+The minus (hyphen) character can be used to specify a range of characters 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.
+
+It is not possible to have the literal character "]" as the end character 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 interpreted as a single class containing a
+range followed by two separate characters. The octal or hexadecimal
+representation of "]" can also be used to end a range.
+
+Ranges operate in the collating sequence of character values. They can also be
+used for characters specified numerically, for example [\\000-\\037]. In UTF-8
+mode, ranges can include characters whose values are greater than 255, for
+example [\\x{100}-\\x{2ff}].
+
+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 if character tables for the "fr"
+locale are in use, [\\xc8-\\xcb] matches accented E characters in both cases.
+
+The character types \\d, \\D, \\s, \\S, \\w, and \\W may also appear in a
+character class, and add the characters that they match to the class. For
+example, [\\dABCDEF] matches any hexadecimal digit. 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.
+
+All non-alphameric characters other than \\, -, ^ (at the start) and the
+terminating ] are non-special in character classes, but it does no harm if they
+are escaped.
+
+.SH POSIX CHARACTER CLASSES
+.rs
+.sp
+Perl supports the POSIX notation for character classes, which uses names
+enclosed by [: and :] within the enclosing square brackets. PCRE also supports
+this notation. For example,
+
+ [01[:alpha:]%]
+
+matches "0", "1", any alphabetic character, or "%". The supported class names
+are
+
+ alnum letters and digits
+ alpha letters
+ ascii character codes 0 - 127
+ blank space or tab only
+ cntrl control characters
+ digit decimal digits (same as \\d)
+ graph printing characters, excluding space
+ lower lower case letters
+ print printing characters, including space
+ punct printing characters, excluding letters and digits
+ space white space (not quite the same as \\s)
+ upper upper case letters
+ word "word" characters (same as \\w)
+ xdigit hexadecimal digits
+
+The "space" characters are HT (9), LF (10), VT (11), FF (12), CR (13), and
+space (32). Notice that this list includes the VT character (code 11). This
+makes "space" different to \\s, which does not include VT (for Perl
+compatibility).
+
+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:]]
+
+matches "1", "2", or any non-digit. PCRE (and Perl) also recognize the POSIX
+syntax [.ch.] and [=ch=] where "ch" is a "collating element", but these are not
+supported, and an error is given if they are encountered.
+
+In UTF-8 mode, characters with values greater than 255 do not match any of
+the POSIX character classes.
+
+.SH VERTICAL BAR
+.rs
+.sp
+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 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 rest of the main
+pattern as well as the alternative in the subpattern.
+
+.SH INTERNAL OPTION SETTING
+.rs
+.sp
+The settings of the PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and
+PCRE_EXTENDED options can be changed from within the pattern by a sequence of
+Perl option letters enclosed between "(?" and ")". The option letters are
+
+ i for PCRE_CASELESS
+ m for PCRE_MULTILINE
+ s for PCRE_DOTALL
+ x for PCRE_EXTENDED
+
+For example, (?im) sets caseless, multiline matching. It is also possible to
+unset these options by preceding the letter with a hyphen, and a combined
+setting and unsetting such as (?im-sx), which sets PCRE_CASELESS and
+PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED, is also
+permitted. If a letter appears both before and after the hyphen, the option is
+unset.
+
+When an option change 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, PCRE extracts it into
+the global options (and it will therefore show up in data extracted by the
+\fBpcre_fullinfo()\fR function).
+
+An option change within a subpattern affects only that part of the current
+pattern that follows it, so
+
+ (a(?i)b)c
+
+matches abc and aBc and no other strings (assuming PCRE_CASELESS is not used).
+By this means, options can be made to have different settings in different
+parts of the pattern. Any changes made in one alternative do carry on
+into subsequent branches within the same subpattern. For example,
+
+ (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 some very weird
+behaviour otherwise.
+
+The PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can be changed in the
+same way as the Perl-compatible options by using the characters U and X
+respectively. The (?X) flag setting is special in that it must always occur
+earlier in the pattern than any of the additional features it turns on, even
+when it is at top level. It is best put at the start.
+
+.SH SUBPATTERNS
+.rs
+.sp
+Subpatterns are delimited by parentheses (round brackets), which can be nested.
+Marking part of a pattern as a subpattern does two things:
+
+1. It localizes a set of alternatives. For example, the pattern
+
+ cat(aract|erpillar|)
+
+matches one of the words "cat", "cataract", or "caterpillar". Without the
+parentheses, it would match "cataract", "erpillar" or the empty string.
+
+2. It sets up the subpattern as a capturing subpattern (as defined above).
+When the whole pattern matches, that portion of the subject string that matched
+the subpattern is passed back to the caller via the \fIovector\fR argument of
+\fBpcre_exec()\fR. Opening parentheses are counted from left to right (starting
+from 1) to obtain the numbers of the capturing subpatterns.
+
+For example, if the string "the red king" is matched against the pattern
+
+ the ((red|white) (king|queen))
+
+the captured substrings are "red king", "red", and "king", and are numbered 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 capturing, 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))
+
+the captured substrings are "white queen" and "queen", and are numbered 1 and
+2. The maximum number of capturing subpatterns is 65535, and the maximum depth
+of nesting of all subpatterns, both capturing and non-capturing, is 200.
+
+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)
+ (?:(?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 "Saturday".
+
+.SH NAMED SUBPATTERNS
+.rs
+.sp
+Identifying capturing parentheses by number is simple, but it can be very hard
+to keep track of the numbers in complicated regular expressions. Furthermore,
+if an expression is modified, the numbers may change. To help with the
+difficulty, PCRE supports the naming of subpatterns, something that Perl does
+not provide. The Python syntax (?P<name>...) is used. Names consist of
+alphanumeric characters and underscores, and must be unique within a pattern.
+
+Named capturing parentheses are still allocated numbers as well as names. The
+PCRE API provides function calls for extracting the name-to-number translation
+table from a compiled pattern. For further details see the
+.\" HREF
+\fBpcreapi\fR
+.\"
+documentation.
+
+.SH REPETITION
+.rs
+.sp
+Repetition is specified by quantifiers, which can follow any of the following
+items:
+
+ a literal data character
+ the . metacharacter
+ the \\C escape sequence
+ escapes such as \\d that match single characters
+ a character class
+ a back reference (see next section)
+ a parenthesized subpattern (unless it is an assertion)
+
+The general repetition quantifier specifies a minimum and maximum number of
+permitted matches, by giving the two numbers in curly brackets (braces),
+separated by a comma. The numbers must be less than 65536, and the first must
+be less than or equal to the second. For example:
+
+ z{2,4}
+
+matches "zz", "zzz", or "zzzz". A closing brace on its own is not a special
+character. If the second number is omitted, but the comma is present, there is
+no upper limit; if the second number and the comma are both omitted, the
+quantifier specifies an exact number of required matches. Thus
+
+ [aeiou]{3,}
+
+matches at least 3 successive vowels, but may match many more, while
+
+ \\d{8}
+
+matches exactly 8 digits. An opening curly bracket that appears in a position
+where a quantifier is not allowed, or one that does not match the syntax of a
+quantifier, is taken as a literal character. For example, {,6} is not a
+quantifier, but a literal string of four characters.
+
+In UTF-8 mode, quantifiers apply to UTF-8 characters rather than to individual
+bytes. Thus, for example, \\x{100}{2} matches two UTF-8 characters, each of
+which is represented by a two-byte sequence.
+
+The quantifier {0} is permitted, causing the expression to behave as if the
+previous item and the quantifier were not present.
+
+For convenience (and historical compatibility) the three most common
+quantifiers have single-character abbreviations:
+
+ * is equivalent to {0,}
+ + is equivalent to {1,}
+ ? is equivalent to {0,1}
+
+It is possible to construct infinite loops by following a subpattern that can
+match no characters with a quantifier that has no upper limit, for example:
+
+ (a?)*
+
+Earlier versions of Perl and PCRE used to give an error at compile time for
+such patterns. However, because there are cases where this can be useful, such
+patterns are now accepted, but if any repetition of the subpattern does in fact
+match no characters, the loop is forcibly broken.
+
+By default, the quantifiers are "greedy", that is, they match as much as
+possible (up to the maximum number of permitted times), without causing the
+rest of the pattern to fail. The classic example of where this gives problems
+is in trying to match comments in C programs. These appear between the
+sequences /* and */ and within the sequence, individual * and / characters may
+appear. An attempt to match C comments by applying the pattern
+
+ /\\*.*\\*/
+
+to the string
+
+ /* first command */ not comment /* second comment */
+
+fails, because it matches the entire string owing to the greediness of the .*
+item.
+
+However, if a quantifier is followed by a question mark, it ceases to be
+greedy, and instead matches the minimum number of times possible, so the
+pattern
+
+ /\\*.*?\\*/
+
+does the right thing with the C comments. The meaning of the various
+quantifiers is not otherwise changed, just the preferred number of matches.
+Do not confuse this use of question mark with its use as a quantifier in its
+own right. Because it has two uses, it can sometimes appear doubled, as in
+
+ \\d??\\d
+
+which matches one digit by preference, but can match two if that is the only
+way the rest of the pattern matches.
+
+If the PCRE_UNGREEDY option is set (an option which is not available in Perl),
+the quantifiers are not greedy by default, but individual ones can be made
+greedy by following them with a question mark. In other words, it inverts the
+default behaviour.
+
+When a parenthesized subpattern is quantified with a minimum repeat count that
+is greater than 1 or with a limited maximum, more store is required for the
+compiled pattern, in proportion to the size of the minimum or maximum.
+
+If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equivalent
+to Perl's /s) is set, thus allowing the . to match newlines, the pattern is
+implicitly anchored, because whatever follows will be tried against every
+character position in the subject string, so there is no point in retrying the
+overall match at any position after the first. PCRE normally treats such a
+pattern as though it were preceded by \\A.
+
+In cases where it is known that the subject string contains no newlines, it is
+worth setting PCRE_DOTALL in order to obtain this optimization, or
+alternatively using ^ to indicate anchoring explicitly.
+
+However, there is one situation where the optimization cannot be used. When .*
+is inside capturing parentheses that are the subject of a backreference
+elsewhere in the pattern, a match at the start may fail, and a later one
+succeed. Consider, for example:
+
+ (.*)abc\\1
+
+If the subject is "xyz123abc123" the match point is the fourth character. For
+this reason, such a pattern is not implicitly anchored.
+
+When a capturing subpattern is repeated, the value captured is the substring
+that matched the final iteration. For example, after
+
+ (tweedle[dume]{3}\\s*)+
+
+has matched "tweedledum tweedledee" the value of the captured substring is
+"tweedledee". However, if there are nested capturing subpatterns, the
+corresponding captured values may have been set in previous iterations. For
+example, after
+
+ /(a|(b))+/
+
+matches "aba" the value of the second captured substring is "b".
+
+.SH ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS
+.rs
+.sp
+With both maximizing and minimizing repetition, failure of what follows
+normally causes the repeated item to be re-evaluated to see if a different
+number of repeats allows the rest of the pattern to match. Sometimes it is
+useful to prevent this, either to change the nature of the match, or to cause
+it fail earlier than it otherwise might, when the author of the pattern knows
+there is no point in carrying on.
+
+Consider, for example, the pattern \\d+foo when applied to the subject line
+
+ 123456bar
+
+After matching all 6 digits and then failing to match "foo", the normal
+action of the matcher is to try again with only 5 digits matching the \\d+
+item, and then with 4, and so on, before ultimately failing. "Atomic grouping"
+(a term taken from Jeffrey Friedl's book) provides the means for specifying
+that once a subpattern has matched, it is not to be re-evaluated in this way.
+
+If we use atomic grouping for the previous example, the matcher would give up
+immediately on failing to match "foo" the first time. The notation is a kind of
+special parenthesis, starting with (?> as in this example:
+
+ (?>\\d+)bar
+
+This kind of parenthesis "locks up" the part of the pattern it contains once
+it has matched, and a failure further into the pattern is prevented from
+backtracking into it. Backtracking past it to previous items, however, works as
+normal.
+
+An alternative description is that a subpattern of this type matches the string
+of characters that an identical standalone pattern would match, if anchored at
+the current point in the subject string.
+
+Atomic grouping subpatterns are not capturing subpatterns. Simple cases such as
+the above example can be thought of as a maximizing repeat that must swallow
+everything it can. So, while both \\d+ and \\d+? are prepared to adjust the
+number of digits they match in order to make the rest of the pattern match,
+(?>\\d+) can only match an entire sequence of digits.
+
+Atomic groups in general can of course contain arbitrarily complicated
+subpatterns, and can be nested. However, when the subpattern for an atomic
+group is just a single repeated item, as in the example above, a simpler
+notation, called a "possessive quantifier" can be used. This consists of an
+additional + character following a quantifier. Using this notation, the
+previous example can be rewritten as
+
+ \\d++bar
+
+Possessive quantifiers are always greedy; the setting of the PCRE_UNGREEDY
+option is ignored. They are a convenient notation for the simpler forms of
+atomic group. However, there is no difference in the meaning or processing of a
+possessive quantifier and the equivalent atomic group.
+
+The possessive quantifier syntax is an extension to the Perl syntax. It
+originates in Sun's Java package.
+
+When a pattern contains an unlimited repeat inside a subpattern that can itself
+be repeated an unlimited number of times, the use of an atomic group is the
+only way to avoid some failing matches taking a very long time indeed. The
+pattern
+
+ (\\D+|<\\d+>)*[!?]
+
+matches an unlimited number of substrings that either consist of non-digits, or
+digits enclosed in <>, followed by either ! or ?. When it matches, it runs
+quickly. However, if it is applied to
+
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+it takes a long time before reporting failure. This is because the string can
+be divided between the two repeats in a large number of ways, and all have to
+be tried. (The example used [!?] rather than a single character at the end,
+because both PCRE and Perl have an optimization that allows for fast failure
+when a single character is used. They remember the last single character that
+is required for a match, and fail early if it is not present in the string.)
+If the pattern is changed to
+
+ ((?>\\D+)|<\\d+>)*[!?]
+
+sequences of non-digits cannot be broken, and failure happens quickly.
+
+.SH BACK REFERENCES
+.rs
+.sp
+Outside a character class, a backslash followed by a digit greater than 0 (and
+possibly further digits) is a back reference to a capturing subpattern earlier
+(that is, to its left) in the pattern, provided there have been that many
+previous capturing left parentheses.
+
+However, if the decimal number following the backslash is less than 10, it is
+always taken as a back reference, and causes an error only if there are not
+that many capturing left parentheses in the entire pattern. In other words, the
+parentheses that are referenced need not be to the left of the reference for
+numbers less than 10. See the section entitled "Backslash" above for further
+details of the handling of digits following a backslash.
+
+A back reference matches whatever actually matched the capturing subpattern in
+the current subject string, rather than anything matching the subpattern
+itself (see
+.\" HTML <a href="#subpatternsassubroutines">
+.\" </a>
+"Subpatterns as subroutines"
+.\"
+below for a way of doing that). So the pattern
+
+ (sens|respons)e and \\1ibility
+
+matches "sense and sensibility" and "response and responsibility", but not
+"sense and responsibility". If caseful matching is in force at the time of the
+back reference, the case of letters is relevant. For example,
+
+ ((?i)rah)\\s+\\1
+
+matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original
+capturing subpattern is matched caselessly.
+
+Back references to named subpatterns use the Python syntax (?P=name). We could
+rewrite the above example as follows:
+
+ (?<p1>(?i)rah)\\s+(?P=p1)
+
+There may be more than one back reference to the same subpattern. If a
+subpattern has not actually been used in a particular match, any back
+references to it always fail. For example, the pattern
+
+ (a|(bc))\\2
+
+always fails if it starts to match "a" rather than "bc". Because there may be
+many capturing parentheses in a pattern, all digits following the backslash are
+taken as part of a potential back reference number. If the pattern continues
+with a digit character, some delimiter must be used to terminate the back
+reference. If the PCRE_EXTENDED option is set, this can be whitespace.
+Otherwise an empty comment can be used.
+
+A back reference that occurs inside the parentheses to which it refers fails
+when the subpattern is first used, so, for example, (a\\1) never matches.
+However, such references can be useful inside repeated subpatterns. For
+example, the pattern
+
+ (a|b\\1)+
+
+matches any number of "a"s and also "aba", "ababbaa" etc. At each iteration of
+the subpattern, the back reference matches the character string corresponding
+to the previous iteration. In order for this to work, the pattern must be such
+that the first iteration does not need to match the back reference. This can be
+done using alternation, as in the example above, or by a quantifier with a
+minimum of zero.
+
+.SH ASSERTIONS
+.rs
+.sp
+An assertion is a test on the characters following or preceding the current
+matching point that does not actually consume any characters. The simple
+assertions coded as \\b, \\B, \\A, \\G, \\Z, \\z, ^ and $ are described above.
+More complicated assertions are coded as subpatterns. There are two kinds:
+those that look ahead of the current position in the subject string, and those
+that look behind it.
+
+An assertion subpattern is matched in the normal way, except that it does not
+cause the current matching position to be changed. Lookahead assertions start
+with (?= for positive assertions and (?! for negative assertions. For example,
+
+ \\w+(?=;)
+
+matches a word followed by a semicolon, but does not include the semicolon in
+the match, and
+
+ foo(?!bar)
+
+matches any occurrence of "foo" that is not followed by "bar". Note that the
+apparently similar pattern
+
+ (?!foo)bar
+
+does not find an occurrence of "bar" that is preceded by something other than
+"foo"; it finds any occurrence of "bar" whatsoever, because the assertion
+(?!foo) is always true when the next three characters are "bar". A
+lookbehind assertion is needed to achieve this effect.
+
+If you want to force a matching failure at some point in a pattern, the most
+convenient way to do it is with (?!) because an empty string always matches, so
+an assertion that requires there not to be an empty string must always fail.
+
+Lookbehind assertions start with (?<= for positive assertions and (?<! for
+negative assertions. For example,
+
+ (?<!foo)bar
+
+does find an occurrence of "bar" that is not preceded by "foo". The contents of
+a lookbehind assertion are restricted such that all the strings it matches must
+have a fixed length. However, if there are several alternatives, they do not
+all have to have the same fixed length. Thus
+
+ (?<=bullock|donkey)
+
+is permitted, but
+
+ (?<!dogs?|cats?)
+
+causes an error at compile time. Branches that match different length strings
+are permitted only at the top level of a lookbehind assertion. This is an
+extension compared with Perl (at least for 5.8), which requires all branches to
+match the same length of string. An assertion such as
+
+ (?<=ab(c|de))
+
+is not permitted, because its single top-level branch can match two different
+lengths, but it is acceptable if rewritten to use two top-level branches:
+
+ (?<=abc|abde)
+
+The implementation of lookbehind assertions is, for each alternative, to
+temporarily move the current position back by the fixed width and then try to
+match. If there are insufficient characters before the current position, the
+match is deemed to fail.
+
+PCRE does not allow the \\C escape (which matches a single byte in UTF-8 mode)
+to appear in lookbehind assertions, because it makes it impossible to calculate
+the length of the lookbehind.
+
+Atomic groups can be used in conjunction with lookbehind assertions to specify
+efficient matching at the end of the subject string. Consider a simple pattern
+such as
+
+ abcd$
+
+when applied to a long string that does not match. Because matching proceeds
+from left to right, PCRE will look for each "a" in the subject and then see if
+what follows matches the rest of the pattern. If the pattern is specified as
+
+ ^.*abcd$
+
+the initial .* matches the entire string at first, but when this fails (because
+there is no following "a"), it backtracks to match all but the last character,
+then all but the last two characters, and so on. Once again the search for "a"
+covers the entire string, from right to left, so we are no better off. However,
+if the pattern is written as
+
+ ^(?>.*)(?<=abcd)
+
+or, equivalently,
+
+ ^.*+(?<=abcd)
+
+there can be no backtracking for the .* item; it can match only the entire
+string. The subsequent lookbehind assertion does a single test on the last four
+characters. If it fails, the match fails immediately. For long strings, this
+approach makes a significant difference to the processing time.
+
+Several assertions (of any sort) may occur in succession. For example,
+
+ (?<=\\d{3})(?<!999)foo
+
+matches "foo" preceded by three digits that are not "999". Notice that each of
+the assertions is applied independently at the same point in the subject
+string. First there is a check that the previous three characters are all
+digits, and then there is a check that the same three characters are not "999".
+This pattern does \fInot\fR match "foo" preceded by six characters, the first
+of which are digits and the last three of which are not "999". For example, it
+doesn't match "123abcfoo". A pattern to do that is
+
+ (?<=\\d{3}...)(?<!999)foo
+
+This time the first assertion looks at the preceding six characters, checking
+that the first three are digits, and then the second assertion checks that the
+preceding three characters are not "999".
+
+Assertions can be nested in any combination. For example,
+
+ (?<=(?<!foo)bar)baz
+
+matches an occurrence of "baz" that is preceded by "bar" which in turn is not
+preceded by "foo", while
+
+ (?<=\\d{3}(?!999)...)foo
+
+is another pattern which matches "foo" preceded by three digits and any three
+characters that are not "999".
+
+Assertion subpatterns are not capturing subpatterns, and may not be repeated,
+because it makes no sense to assert the same thing several times. If any kind
+of assertion contains capturing subpatterns within it, these are counted for
+the purposes of numbering the capturing subpatterns in the whole pattern.
+However, substring capturing is carried out only for positive assertions,
+because it does not make sense for negative assertions.
+
+.SH CONDITIONAL SUBPATTERNS
+.rs
+.sp
+It is possible to cause the matching process to obey a subpattern
+conditionally or to choose between two alternative subpatterns, depending on
+the result of an assertion, or whether a previous capturing subpattern matched
+or not. The two possible forms of conditional subpattern are
+
+ (?(condition)yes-pattern)
+ (?(condition)yes-pattern|no-pattern)
+
+If the condition is satisfied, the yes-pattern is used; otherwise the
+no-pattern (if present) is used. If there are more than two alternatives in the
+subpattern, a compile-time error occurs.
+
+There are three kinds of condition. If the text between the parentheses
+consists of a sequence of digits, the condition is satisfied if the capturing
+subpattern of that number has previously matched. The number must be greater
+than zero. Consider the following pattern, which contains non-significant white
+space to make it more readable (assume the PCRE_EXTENDED option) and to divide
+it into three parts for ease of discussion:
+
+ ( \\( )? [^()]+ (?(1) \\) )
+
+The first part matches an optional opening parenthesis, and if that
+character is present, sets it as the first captured substring. The second part
+matches one or more characters that are not parentheses. The third part is a
+conditional subpattern that tests whether the first set of parentheses matched
+or not. If they did, that is, if subject started with an opening parenthesis,
+the condition is true, and so the yes-pattern is executed and a closing
+parenthesis is required. Otherwise, since no-pattern is not present, the
+subpattern matches nothing. In other words, this pattern matches a sequence of
+non-parentheses, optionally enclosed in parentheses.
+
+If the condition is the string (R), it is satisfied if a recursive call to the
+pattern or subpattern has been made. At "top level", the condition is false.
+This is a PCRE extension. Recursive patterns are described in the next section.
+
+If the condition is not a sequence of digits or (R), it must be an assertion.
+This may be a positive or negative lookahead or lookbehind assertion. Consider
+this pattern, again containing non-significant white space, and with the two
+alternatives on the second line:
+
+ (?(?=[^a-z]*[a-z])
+ \\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} )
+
+The condition is a positive lookahead assertion that matches an optional
+sequence of non-letters followed by a letter. In other words, it tests for the
+presence of at least one letter in the subject. If a letter is found, the
+subject is matched against the first alternative; otherwise it is matched
+against the second. This pattern matches strings in one of the two forms
+dd-aaa-dd or dd-dd-dd, where aaa are letters and dd are digits.
+
+.SH COMMENTS
+.rs
+.sp
+The sequence (?# marks the start of a comment which continues up to the next
+closing parenthesis. Nested parentheses are not permitted. The characters
+that make up a comment play no part in the pattern matching at all.
+
+If the PCRE_EXTENDED option is set, an unescaped # character outside a
+character class introduces a comment that continues up to the next newline
+character in the pattern.
+
+.SH RECURSIVE PATTERNS
+.rs
+.sp
+Consider the problem of matching a string in parentheses, allowing for
+unlimited nested parentheses. Without the use of recursion, the best that can
+be done is to use a pattern that matches up to some fixed depth of nesting. It
+is not possible to handle an arbitrary nesting depth. Perl has provided an
+experimental facility that allows regular expressions to recurse (amongst other
+things). It does this by interpolating Perl code in the expression at run time,
+and the code can refer to the expression itself. A Perl pattern to solve the
+parentheses problem can be created like this:
+
+ $re = qr{\\( (?: (?>[^()]+) | (?p{$re}) )* \\)}x;
+
+The (?p{...}) item interpolates Perl code at run time, and in this case refers
+recursively to the pattern in which it appears. Obviously, PCRE cannot support
+the interpolation of Perl code. Instead, it supports some special syntax for
+recursion of the entire pattern, and also for individual subpattern recursion.
+
+The special item that consists of (? followed by a number greater than zero and
+a closing parenthesis is a recursive call of the subpattern of the given
+number, provided that it occurs inside that subpattern. (If not, it is a
+"subroutine" call, which is described in the next section.) The special item
+(?R) is a recursive call of the entire regular expression.
+
+For example, this PCRE pattern solves the nested parentheses problem (assume
+the PCRE_EXTENDED option is set so that white space is ignored):
+
+ \\( ( (?>[^()]+) | (?R) )* \\)
+
+First it matches an opening parenthesis. Then it matches any number of
+substrings which can either be a sequence of non-parentheses, or a recursive
+match of the pattern itself (that is a correctly parenthesized substring).
+Finally there is a closing parenthesis.
+
+If this were part of a larger pattern, you would not want to recurse the entire
+pattern, so instead you could use this:
+
+ ( \\( ( (?>[^()]+) | (?1) )* \\) )
+
+We have put the pattern into parentheses, and caused the recursion to refer to
+them instead of the whole pattern. In a larger pattern, keeping track of
+parenthesis numbers can be tricky. It may be more convenient to use named
+parentheses instead. For this, PCRE uses (?P>name), which is an extension to
+the Python syntax that PCRE uses for named parentheses (Perl does not provide
+named parentheses). We could rewrite the above example as follows:
+
+ (?<pn> \\( ( (?>[^()]+) | (?P>pn) )* \\) )
+
+This particular example pattern contains nested unlimited repeats, and so the
+use of atomic grouping for matching strings of non-parentheses is important
+when applying the pattern to strings that do not match. For example, when this
+pattern is applied to
+
+ (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
+
+it yields "no match" quickly. However, if atomic grouping is not used,
+the match runs for a very long time indeed because there are so many different
+ways the + and * repeats can carve up the subject, and all have to be tested
+before failure can be reported.
+
+At the end of a match, the values set for any capturing subpatterns are those
+from the outermost level of the recursion at which the subpattern value is set.
+If you want to obtain intermediate values, a callout function can be used (see
+below and the
+.\" HREF
+\fBpcrecallout\fR
+.\"
+documentation). If the pattern above is matched against
+
+ (ab(cd)ef)
+
+the value for the capturing parentheses is "ef", which is the last value taken
+on at the top level. If additional parentheses are added, giving
+
+ \\( ( ( (?>[^()]+) | (?R) )* ) \\)
+ ^ ^
+ ^ ^
+
+the string they capture is "ab(cd)ef", the contents of the top level
+parentheses. If there are more than 15 capturing parentheses in a pattern, PCRE
+has to obtain extra memory to store data during a recursion, which it does by
+using \fBpcre_malloc\fR, freeing it via \fBpcre_free\fR afterwards. If no
+memory can be obtained, the match fails with the PCRE_ERROR_NOMEMORY error.
+
+Do not confuse the (?R) item with the condition (R), which tests for recursion.
+Consider this pattern, which matches text in angle brackets, allowing for
+arbitrary nesting. Only digits are allowed in nested brackets (that is, when
+recursing), whereas any characters are permitted at the outer level.
+
+ < (?: (?(R) \\d++ | [^<>]*+) | (?R)) * >
+
+In this pattern, (?(R) is the start of a conditional subpattern, with two
+different alternatives for the recursive and non-recursive cases. The (?R) item
+is the actual recursive call.
+
+.\" HTML <a name="subpatternsassubroutines"></a>
+.SH SUBPATTERNS AS SUBROUTINES
+.rs
+.sp
+If the syntax for a recursive subpattern reference (either by number or by
+name) is used outside the parentheses to which it refers, it operates like a
+subroutine in a programming language. An earlier example pointed out that the
+pattern
+
+ (sens|respons)e and \\1ibility
+
+matches "sense and sensibility" and "response and responsibility", but not
+"sense and responsibility". If instead the pattern
+
+ (sens|respons)e and (?1)ibility
+
+is used, it does match "sense and responsibility" as well as the other two
+strings. Such references must, however, follow the subpattern to which they
+refer.
+
+.SH CALLOUTS
+.rs
+.sp
+Perl has a feature whereby using the sequence (?{...}) causes arbitrary Perl
+code to be obeyed in the middle of matching a regular expression. This makes it
+possible, amongst other things, to extract different substrings that match the
+same pair of parentheses when there is a repetition.
+
+PCRE provides a similar feature, but of course it cannot obey arbitrary Perl
+code. The feature is called "callout". The caller of PCRE provides an external
+function by putting its entry point in the global variable \fIpcre_callout\fR.
+By default, this variable contains NULL, which disables all calling out.
+
+Within a regular expression, (?C) indicates the points at which the external
+function is to be called. If you want to identify different callout points, you
+can put a number less than 256 after the letter C. The default value is zero.
+For example, this pattern has two callout points:
+
+ (?C1)\dabc(?C2)def
+
+During matching, when PCRE reaches a callout point (and \fIpcre_callout\fR is
+set), the external function is called. It is provided with the number of the
+callout, and, optionally, one item of data originally supplied by the caller of
+\fBpcre_exec()\fR. The callout function may cause matching to backtrack, or to
+fail altogether. A complete description of the interface to the callout
+function is given in the
+.\" HREF
+\fBpcrecallout\fR
+.\"
+documentation.
+
+.in 0
+Last updated: 03 February 2003
+.br
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcreperform.3 b/doc/pcreperform.3
new file mode 100644
index 0000000..52a332f
--- /dev/null
+++ b/doc/pcreperform.3
@@ -0,0 +1,66 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH PCRE PERFORMANCE
+.rs
+.sp
+Certain items that may appear in regular expression patterns are more efficient
+than others. It is more efficient to use a character class like [aeiou] than a
+set of alternatives such as (a|e|i|o|u). In general, the simplest construction
+that provides the required behaviour is usually the most efficient. Jeffrey
+Friedl's book contains a lot of discussion about optimizing regular expressions
+for efficient performance.
+
+When a pattern begins with .* not in parentheses, or in parentheses that are
+not the subject of a backreference, and the PCRE_DOTALL option is set, the
+pattern is implicitly anchored by PCRE, since it can match only at the start of
+a subject string. However, if PCRE_DOTALL is not set, PCRE cannot make this
+optimization, because the . metacharacter does not then match a newline, and if
+the subject string contains newlines, the pattern may match from the character
+immediately following one of them instead of from the very start. For example,
+the pattern
+
+ .*second
+
+matches the subject "first\\nand second" (where \\n stands for a newline
+character), with the match starting at the seventh character. In order to do
+this, PCRE has to retry the match starting after every newline in the subject.
+
+If you are using such a pattern with subject strings that do not contain
+newlines, the best performance is obtained by setting PCRE_DOTALL, or starting
+the pattern with ^.* to indicate explicit anchoring. That saves PCRE from
+having to scan along the subject looking for a newline to restart at.
+
+Beware of patterns that contain nested indefinite repeats. These can take a
+long time to run when applied to a string that does not match. Consider the
+pattern fragment
+
+ (a+)*
+
+This can match "aaaa" in 33 different ways, and this number increases very
+rapidly as the string gets longer. (The * repeat can match 0, 1, 2, 3, or 4
+times, and for each of those cases other than 0, the + repeats can match
+different numbers of times.) When the remainder of the pattern is such that the
+entire match is going to fail, PCRE has in principle to try every possible
+variation, and this can take an extremely long time.
+
+An optimization catches some of the more simple cases such as
+
+ (a+)*b
+
+where a literal character follows. Before embarking on the standard matching
+procedure, PCRE checks that there is a "b" later in the subject string, and if
+there is not, it fails the match immediately. However, when there is no
+following literal this optimization cannot be used. You can see the difference
+by comparing the behaviour of
+
+ (a+)*\\d
+
+with the pattern above. The former gives a failure almost instantly when
+applied to a whole line of "a" characters, whereas the latter takes an
+appreciable time with strings longer than about 20 characters.
+
+.in 0
+Last updated: 03 February 2003
+.br
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcreposix.3 b/doc/pcreposix.3
index 41716ea..018abdb 100644
--- a/doc/pcreposix.3
+++ b/doc/pcreposix.3
@@ -1,7 +1,7 @@
.TH PCRE 3
.SH NAME
-pcreposix - POSIX API for Perl-compatible regular expressions.
-.SH SYNOPSIS
+PCRE - Perl-compatible regular expressions.
+.SH SYNOPSIS OF POSIX API
.B #include <pcreposix.h>
.PP
.SM
@@ -23,18 +23,23 @@ pcreposix - POSIX API for Perl-compatible regular expressions.
.br
.B void regfree(regex_t *\fIpreg\fR);
-
.SH DESCRIPTION
+.rs
+.sp
This set of functions provides a POSIX-style API to the PCRE regular expression
-package. See the \fBpcre\fR documentation for a description of the native API,
-which contains additional functionality.
+package. See the
+.\" HREF
+\fBpcreapi\fR
+.\"
+documentation for a description of the native API, which contains additional
+functionality.
The functions described here are just wrapper functions that ultimately call
-the native API. Their prototypes are defined in the \fBpcreposix.h\fR header
-file, and on Unix systems the library itself is called \fBpcreposix.a\fR, so
-can be accessed by adding \fB-lpcreposix\fR to the command for linking an
-application which uses them. Because the POSIX functions call the native ones,
-it is also necessary to add \fR-lpcre\fR.
+the PCRE native API. Their prototypes are defined in the \fBpcreposix.h\fR
+header file, and on Unix systems the library itself is called
+\fBpcreposix.a\fR, so can be accessed by adding \fB-lpcreposix\fR to the
+command for linking an application which uses them. Because the POSIX functions
+call the native ones, it is also necessary to add \fR-lpcre\fR.
I have implemented only those option bits that can be reasonably mapped to PCRE
native options. In addition, the options REG_EXTENDED and REG_NOSUB are defined
@@ -55,9 +60,9 @@ structure types, \fIregex_t\fR for compiled internal forms, and
constants whose names start with "REG_"; these are used for setting options and
identifying error codes.
-
.SH COMPILING A PATTERN
-
+.rs
+.sp
The function \fBregcomp()\fR is called to compile a pattern into an
internal form. The pattern is a C string terminated by a binary zero, and
is passed in the argument \fIpattern\fR. The \fIpreg\fR argument is a pointer
@@ -75,23 +80,59 @@ to the native function.
REG_NEWLINE
The PCRE_MULTILINE option is set when the expression is passed for compilation
-to the native function.
+to the native function. Note that this does \fInot\fR mimic the defined POSIX
+behaviour for REG_NEWLINE (see the following section).
In the absence of these flags, no options are passed to the native function.
This means the the regex is compiled with PCRE default semantics. In
particular, the way it handles newline characters in the subject string is the
Perl way, not the POSIX way. Note that setting PCRE_MULTILINE has only
\fIsome\fR of the effects specified for REG_NEWLINE. It does not affect the way
-newlines are matched by . (they aren't) or a negative class such as [^a] (they
-are).
+newlines are matched by . (they aren't) or by a negative class such as [^a]
+(they are).
The yield of \fBregcomp()\fR is zero on success, and non-zero otherwise. The
\fIpreg\fR structure is filled in on success, and one member of the structure
-is publicized: \fIre_nsub\fR contains the number of capturing subpatterns in
+is public: \fIre_nsub\fR contains the number of capturing subpatterns in
the regular expression. Various error codes are defined in the header file.
+.SH MATCHING NEWLINE CHARACTERS
+.rs
+.sp
+This area is not simple, because POSIX and Perl take different views of things.
+It is not possible to get PCRE to obey POSIX semantics, but then PCRE was never
+intended to be a POSIX engine. The following table lists the different
+possibilities for matching newline characters in PCRE:
+
+ Default Change with
+
+ . matches newline no PCRE_DOTALL
+ newline matches [^a] yes not changeable
+ $ matches \\n at end yes PCRE_DOLLARENDONLY
+ $ matches \\n in middle no PCRE_MULTILINE
+ ^ matches \\n in middle no PCRE_MULTILINE
+
+This is the equivalent table for POSIX:
+
+ Default Change with
+
+ . matches newline yes REG_NEWLINE
+ newline matches [^a] yes REG_NEWLINE
+ $ matches \\n at end no REG_NEWLINE
+ $ matches \\n in middle no REG_NEWLINE
+ ^ matches \\n in middle no REG_NEWLINE
+
+PCRE's behaviour is the same as Perl's, except that there is no equivalent for
+PCRE_DOLLARENDONLY in Perl. In both PCRE and Perl, there is no way to stop
+newline from matching [^a].
+
+The default POSIX newline handling can be obtained by setting PCRE_DOTALL and
+PCRE_DOLLARENDONLY, but there is no way to make PCRE behave exactly as for the
+REG_NEWLINE action.
.SH MATCHING A PATTERN
+.rs
+.sp
The function \fBregexec()\fR is called to match a pre-compiled pattern
\fIpreg\fR against a given \fIstring\fR, which is terminated by a zero byte,
subject to the options in \fIeflags\fR. These can be:
@@ -119,31 +160,33 @@ have both structure members set to -1.
A successful match yields a zero return; various error codes are defined in the
header file, of which REG_NOMATCH is the "expected" failure code.
-
.SH ERROR MESSAGES
+.rs
+.sp
The \fBregerror()\fR function maps a non-zero errorcode from either
-\fBregcomp\fR or \fBregexec\fR to a printable message. If \fIpreg\fR is not
+\fBregcomp()\fR or \fBregexec()\fR to a printable message. If \fIpreg\fR is not
NULL, the error should have arisen from the use of that structure. A message
terminated by a binary zero is placed in \fIerrbuf\fR. The length of the
message, including the zero, is limited to \fIerrbuf_size\fR. The yield of the
function is the size of buffer needed to hold the whole message.
-
.SH STORAGE
+.rs
+.sp
Compiling a regular expression causes memory to be allocated and associated
with the \fIpreg\fR structure. The function \fBregfree()\fR frees all such
memory, after which \fIpreg\fR may no longer be used as a compiled expression.
-
.SH AUTHOR
+.rs
+.sp
Philip Hazel <ph10@cam.ac.uk>
.br
University Computing Service,
.br
-New Museums Site,
-.br
Cambridge CB2 3QG, England.
-.br
-Phone: +44 1223 334714
-Copyright (c) 1997-2000 University of Cambridge.
+.in 0
+Last updated: 03 February 2003
+.br
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcreposix.html b/doc/pcreposix.html
deleted file mode 100644
index 9c89478..0000000
--- a/doc/pcreposix.html
+++ /dev/null
@@ -1,191 +0,0 @@
-<HTML>
-<HEAD>
-<TITLE>pcreposix specification</TITLE>
-</HEAD>
-<body bgcolor="#FFFFFF" text="#00005A">
-<H1>pcreposix specification</H1>
-This HTML document has been generated automatically from the original man page.
-If there is any nonsense in it, please consult the man page in case the
-conversion went wrong.
-<UL>
-<LI><A NAME="TOC1" HREF="#SEC1">NAME</A>
-<LI><A NAME="TOC2" HREF="#SEC2">SYNOPSIS</A>
-<LI><A NAME="TOC3" HREF="#SEC3">DESCRIPTION</A>
-<LI><A NAME="TOC4" HREF="#SEC4">COMPILING A PATTERN</A>
-<LI><A NAME="TOC5" HREF="#SEC5">MATCHING A PATTERN</A>
-<LI><A NAME="TOC6" HREF="#SEC6">ERROR MESSAGES</A>
-<LI><A NAME="TOC7" HREF="#SEC7">STORAGE</A>
-<LI><A NAME="TOC8" HREF="#SEC8">AUTHOR</A>
-</UL>
-<LI><A NAME="SEC1" HREF="#TOC1">NAME</A>
-<P>
-pcreposix - POSIX API for Perl-compatible regular expressions.
-</P>
-<LI><A NAME="SEC2" HREF="#TOC1">SYNOPSIS</A>
-<P>
-<B>#include &#60;pcreposix.h&#62;</B>
-</P>
-<P>
-<B>int regcomp(regex_t *<I>preg</I>, const char *<I>pattern</I>,</B>
-<B>int <I>cflags</I>);</B>
-</P>
-<P>
-<B>int regexec(regex_t *<I>preg</I>, const char *<I>string</I>,</B>
-<B>size_t <I>nmatch</I>, regmatch_t <I>pmatch</I>[], int <I>eflags</I>);</B>
-</P>
-<P>
-<B>size_t regerror(int <I>errcode</I>, const regex_t *<I>preg</I>,</B>
-<B>char *<I>errbuf</I>, size_t <I>errbuf_size</I>);</B>
-</P>
-<P>
-<B>void regfree(regex_t *<I>preg</I>);</B>
-</P>
-<LI><A NAME="SEC3" HREF="#TOC1">DESCRIPTION</A>
-<P>
-This set of functions provides a POSIX-style API to the PCRE regular expression
-package. See the <B>pcre</B> documentation for a description of the native API,
-which contains additional functionality.
-</P>
-<P>
-The functions described here are just wrapper functions that ultimately call
-the native API. Their prototypes are defined in the <B>pcreposix.h</B> header
-file, and on Unix systems the library itself is called <B>pcreposix.a</B>, so
-can be accessed by adding <B>-lpcreposix</B> to the command for linking an
-application which uses them. Because the POSIX functions call the native ones,
-it is also necessary to add \fR-lpcre\fR.
-</P>
-<P>
-I have implemented only those option bits that can be reasonably mapped to PCRE
-native options. In addition, the options REG_EXTENDED and REG_NOSUB are defined
-with the value zero. They have no effect, but since programs that are written
-to the POSIX interface often use them, this makes it easier to slot in PCRE as
-a replacement library. Other POSIX options are not even defined.
-</P>
-<P>
-When PCRE is called via these functions, it is only the API that is POSIX-like
-in style. The syntax and semantics of the regular expressions themselves are
-still those of Perl, subject to the setting of various PCRE options, as
-described below.
-</P>
-<P>
-The header for these functions is supplied as <B>pcreposix.h</B> to avoid any
-potential clash with other POSIX libraries. It can, of course, be renamed or
-aliased as <B>regex.h</B>, which is the "correct" name. It provides two
-structure types, <I>regex_t</I> for compiled internal forms, and
-<I>regmatch_t</I> for returning captured substrings. It also defines some
-constants whose names start with "REG_"; these are used for setting options and
-identifying error codes.
-</P>
-<LI><A NAME="SEC4" HREF="#TOC1">COMPILING A PATTERN</A>
-<P>
-The function <B>regcomp()</B> is called to compile a pattern into an
-internal form. The pattern is a C string terminated by a binary zero, and
-is passed in the argument <I>pattern</I>. The <I>preg</I> argument is a pointer
-to a regex_t structure which is used as a base for storing information about
-the compiled expression.
-</P>
-<P>
-The argument <I>cflags</I> is either zero, or contains one or more of the bits
-defined by the following macros:
-</P>
-<P>
-<PRE>
- REG_ICASE
-</PRE>
-</P>
-<P>
-The PCRE_CASELESS option is set when the expression is passed for compilation
-to the native function.
-</P>
-<P>
-<PRE>
- REG_NEWLINE
-</PRE>
-</P>
-<P>
-The PCRE_MULTILINE option is set when the expression is passed for compilation
-to the native function.
-</P>
-<P>
-In the absence of these flags, no options are passed to the native function.
-This means the the regex is compiled with PCRE default semantics. In
-particular, the way it handles newline characters in the subject string is the
-Perl way, not the POSIX way. Note that setting PCRE_MULTILINE has only
-<I>some</I> of the effects specified for REG_NEWLINE. It does not affect the way
-newlines are matched by . (they aren't) or a negative class such as [^a] (they
-are).
-</P>
-<P>
-The yield of <B>regcomp()</B> is zero on success, and non-zero otherwise. The
-<I>preg</I> structure is filled in on success, and one member of the structure
-is publicized: <I>re_nsub</I> contains the number of capturing subpatterns in
-the regular expression. Various error codes are defined in the header file.
-</P>
-<LI><A NAME="SEC5" HREF="#TOC1">MATCHING A PATTERN</A>
-<P>
-The function <B>regexec()</B> is called to match a pre-compiled pattern
-<I>preg</I> against a given <I>string</I>, which is terminated by a zero byte,
-subject to the options in <I>eflags</I>. These can be:
-</P>
-<P>
-<PRE>
- REG_NOTBOL
-</PRE>
-</P>
-<P>
-The PCRE_NOTBOL option is set when calling the underlying PCRE matching
-function.
-</P>
-<P>
-<PRE>
- REG_NOTEOL
-</PRE>
-</P>
-<P>
-The PCRE_NOTEOL option is set when calling the underlying PCRE matching
-function.
-</P>
-<P>
-The portion of the string that was matched, and also any captured substrings,
-are returned via the <I>pmatch</I> argument, which points to an array of
-<I>nmatch</I> structures of type <I>regmatch_t</I>, containing the members
-<I>rm_so</I> and <I>rm_eo</I>. These contain the offset to the first character of
-each substring and the offset to the first character after the end of each
-substring, respectively. The 0th element of the vector relates to the entire
-portion of <I>string</I> that was matched; subsequent elements relate to the
-capturing subpatterns of the regular expression. Unused entries in the array
-have both structure members set to -1.
-</P>
-<P>
-A successful match yields a zero return; various error codes are defined in the
-header file, of which REG_NOMATCH is the "expected" failure code.
-</P>
-<LI><A NAME="SEC6" HREF="#TOC1">ERROR MESSAGES</A>
-<P>
-The <B>regerror()</B> function maps a non-zero errorcode from either
-<B>regcomp</B> or <B>regexec</B> to a printable message. If <I>preg</I> is not
-NULL, the error should have arisen from the use of that structure. A message
-terminated by a binary zero is placed in <I>errbuf</I>. The length of the
-message, including the zero, is limited to <I>errbuf_size</I>. The yield of the
-function is the size of buffer needed to hold the whole message.
-</P>
-<LI><A NAME="SEC7" HREF="#TOC1">STORAGE</A>
-<P>
-Compiling a regular expression causes memory to be allocated and associated
-with the <I>preg</I> structure. The function <B>regfree()</B> frees all such
-memory, after which <I>preg</I> may no longer be used as a compiled expression.
-</P>
-<LI><A NAME="SEC8" HREF="#TOC1">AUTHOR</A>
-<P>
-Philip Hazel &#60;ph10@cam.ac.uk&#62;
-<BR>
-University Computing Service,
-<BR>
-New Museums Site,
-<BR>
-Cambridge CB2 3QG, England.
-<BR>
-Phone: +44 1223 334714
-</P>
-<P>
-Copyright (c) 1997-2000 University of Cambridge.
diff --git a/doc/pcreposix.txt b/doc/pcreposix.txt
deleted file mode 100644
index 2d76f7c..0000000
--- a/doc/pcreposix.txt
+++ /dev/null
@@ -1,159 +0,0 @@
-NAME
- pcreposix - POSIX API for Perl-compatible regular expres-
- sions.
-
-
-
-SYNOPSIS
- #include <pcreposix.h>
-
- int regcomp(regex_t *preg, const char *pattern,
- int cflags);
-
- int regexec(regex_t *preg, const char *string,
- size_t nmatch, regmatch_t pmatch[], int eflags);
-
- size_t regerror(int errcode, const regex_t *preg,
- char *errbuf, size_t errbuf_size);
-
- void regfree(regex_t *preg);
-
-
-
-DESCRIPTION
- This set of functions provides a POSIX-style API to the PCRE
- regular expression package. See the pcre documentation for a
- description of the native API, which contains additional
- functionality.
-
- The functions described here are just wrapper functions that
- ultimately call the native API. Their prototypes are defined
- in the pcreposix.h header file, and on Unix systems the
- library itself is called pcreposix.a, so can be accessed by
- adding -lpcreposix to the command for linking an application
- which uses them. Because the POSIX functions call the native
- ones, it is also necessary to add -lpcre.
-
- I have implemented only those option bits that can be rea-
- sonably mapped to PCRE native options. In addition, the
- options REG_EXTENDED and REG_NOSUB are defined with the
- value zero. They have no effect, but since programs that are
- written to the POSIX interface often use them, this makes it
- easier to slot in PCRE as a replacement library. Other POSIX
- options are not even defined.
-
- When PCRE is called via these functions, it is only the API
- that is POSIX-like in style. The syntax and semantics of the
- regular expressions themselves are still those of Perl, sub-
- ject to the setting of various PCRE options, as described
- below.
-
- The header for these functions is supplied as pcreposix.h to
- avoid any potential clash with other POSIX libraries. It
- can, of course, be renamed or aliased as regex.h, which is
- the "correct" name. It provides two structure types, regex_t
- for compiled internal forms, and regmatch_t for returning
- captured substrings. It also defines some constants whose
- names start with "REG_"; these are used for setting options
- and identifying error codes.
-
-
-
-COMPILING A PATTERN
- The function regcomp() is called to compile a pattern into
- an internal form. The pattern is a C string terminated by a
- binary zero, and is passed in the argument pattern. The preg
- argument is a pointer to a regex_t structure which is used
- as a base for storing information about the compiled expres-
- sion.
-
- The argument cflags is either zero, or contains one or more
- of the bits defined by the following macros:
-
- REG_ICASE
-
- The PCRE_CASELESS option is set when the expression is
- passed for compilation to the native function.
-
- REG_NEWLINE
-
- The PCRE_MULTILINE option is set when the expression is
- passed for compilation to the native function.
-
- In the absence of these flags, no options are passed to the
- native function. This means the the regex is compiled with
- PCRE default semantics. In particular, the way it handles
- newline characters in the subject string is the Perl way,
- not the POSIX way. Note that setting PCRE_MULTILINE has only
- some of the effects specified for REG_NEWLINE. It does not
- affect the way newlines are matched by . (they aren't) or a
- negative class such as [^a] (they are).
-
- The yield of regcomp() is zero on success, and non-zero oth-
- erwise. The preg structure is filled in on success, and one
- member of the structure is publicized: re_nsub contains the
- number of capturing subpatterns in the regular expression.
- Various error codes are defined in the header file.
-
-
-
-MATCHING A PATTERN
- The function regexec() is called to match a pre-compiled
- pattern preg against a given string, which is terminated by
- a zero byte, subject to the options in eflags. These can be:
-
- REG_NOTBOL
-
- The PCRE_NOTBOL option is set when calling the underlying
- PCRE matching function.
-
- REG_NOTEOL
-
- The PCRE_NOTEOL option is set when calling the underlying
- PCRE matching function.
-
- The portion of the string that was matched, and also any
- captured substrings, are returned via the pmatch argument,
- which points to an array of nmatch structures of type
- regmatch_t, containing the members rm_so and rm_eo. These
- contain the offset to the first character of each substring
- and the offset to the first character after the end of each
- substring, respectively. The 0th element of the vector
- relates to the entire portion of string that was matched;
- subsequent elements relate to the capturing subpatterns of
- the regular expression. Unused entries in the array have
- both structure members set to -1.
-
- A successful match yields a zero return; various error codes
- are defined in the header file, of which REG_NOMATCH is the
- "expected" failure code.
-
-
-
-ERROR MESSAGES
- The regerror() function maps a non-zero errorcode from
- either regcomp or regexec to a printable message. If preg is
- not NULL, the error should have arisen from the use of that
- structure. A message terminated by a binary zero is placed
- in errbuf. The length of the message, including the zero, is
- limited to errbuf_size. The yield of the function is the
- size of buffer needed to hold the whole message.
-
-
-
-STORAGE
- Compiling a regular expression causes memory to be allocated
- and associated with the preg structure. The function reg-
- free() frees all such memory, after which preg may no longer
- be used as a compiled expression.
-
-
-
-AUTHOR
- Philip Hazel <ph10@cam.ac.uk>
- University Computing Service,
- New Museums Site,
- Cambridge CB2 3QG, England.
- Phone: +44 1223 334714
-
- Copyright (c) 1997-2000 University of Cambridge.
diff --git a/doc/pcresample.3 b/doc/pcresample.3
new file mode 100644
index 0000000..02a7a54
--- /dev/null
+++ b/doc/pcresample.3
@@ -0,0 +1,52 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH PCRE SAMPLE PROGRAM
+.rs
+.sp
+A simple, complete demonstration program, to get you started with using PCRE,
+is supplied in the file \fIpcredemo.c\fR in the PCRE distribution.
+
+The program compiles the regular expression that is its first argument, and
+matches it against the subject string in its second argument. No PCRE options
+are set, and default character tables are used. If matching succeeds, the
+program outputs the portion of the subject that matched, together with the
+contents of any captured substrings.
+
+If the -g option is given on the command line, the program then goes on to
+check for further matches of the same regular expression in the same subject
+string. The logic is a little bit tricky because of the possibility of matching
+an empty string. Comments in the code explain what is going on.
+
+On a Unix system that has PCRE installed in \fI/usr/local\fR, you can compile
+the demonstration program using a command like this:
+
+ gcc -o pcredemo pcredemo.c -I/usr/local/include \\
+ -L/usr/local/lib -lpcre
+
+Then you can run simple tests like this:
+
+ ./pcredemo 'cat|dog' 'the cat sat on the mat'
+ ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
+
+Note that there is a much more comprehensive test program, called
+\fBpcretest\fR, which supports many more facilities for testing regular
+expressions and the PCRE library. The \fBpcredemo\fR program is provided as a
+simple coding example.
+
+On some operating systems (e.g. Solaris) you may get an error like this when
+you try to run \fBpcredemo\fR:
+
+ ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
+
+This is caused by the way shared library support works on those systems. You
+need to add
+
+ -R/usr/local/lib
+
+to the compile command to get round this problem.
+
+.in 0
+Last updated: 28 January 2003
+.br
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcretest.1 b/doc/pcretest.1
index b2e2556..76daaf3 100644
--- a/doc/pcretest.1
+++ b/doc/pcretest.1
@@ -6,10 +6,24 @@ pcretest - a program for testing Perl-compatible regular expressions.
\fBpcretest\fR was written as a test program for the PCRE regular expression
library itself, but it can also be used for experimenting with regular
-expressions. This man page describes the features of the test program; for
-details of the regular expressions themselves, see the \fBpcre\fR man page.
+expressions. This document describes the features of the test program; for
+details of the regular expressions themselves, see the
+.\" HREF
+\fBpcrepattern\fR
+.\"
+documentation. For details of PCRE and its options, see the
+.\" HREF
+\fBpcreapi\fR
+.\"
+documentation.
.SH OPTIONS
+.rs
+.sp
+.TP 10
+\fB-C\fR
+Output the version number of the PCRE library, and all available information
+about the optional features that are included, and then exit.
.TP 10
\fB-d\fR
Behave as if each regex had the \fB/D\fR modifier (see below); the internal
@@ -35,14 +49,14 @@ Behave as if each regex has \fB/P\fR modifier; the POSIX wrapper API is used
to call PCRE. None of the other options has any effect when \fB-p\fR is set.
.TP 10
\fB-t\fR
-Run each compile, study, and match 20000 times with a timer, and output
+Run each compile, study, and match many times with a timer, and output
resulting time per compile or match (in milliseconds). Do not set \fB-t\fR with
\fB-m\fR, because you will then get the size output 20000 times and the timing
will be distorted.
-
.SH DESCRIPTION
-
+.rs
+.sp
If \fBpcretest\fR is given two filename arguments, it reads from the first and
writes to the second. If it is given only one filename argument, it reads from
that file and writes to stdout. Otherwise, it reads from stdin and writes to
@@ -51,10 +65,16 @@ expressions, and "data>" to prompt for data lines.
The program handles any number of sets of input on a single input file. Each
set starts with a regular expression, and continues with any number of data
-lines to be matched against the pattern. An empty line signals the end of the
-data lines, at which point a new regular expression is read. The regular
-expressions are given enclosed in any non-alphameric delimiters other than
-backslash, for example
+lines to be matched against the pattern.
+
+Each line is matched separately and independently. If you want to do
+multiple-line matches, you have to use the \\n escape sequence in a single line
+of input to encode the newline characters. The maximum length of data line is
+30,000 characters.
+
+An empty line signals the end of the data lines, at which point a new regular
+expression is read. The regular expressions are given enclosed in any
+non-alphameric delimiters other than backslash, for example
/(a|bc)x+yz/
@@ -81,9 +101,9 @@ backslash, because
is interpreted as the first line of a pattern that starts with "abc/", causing
pcretest to read the next line as a continuation of the regular expression.
-
.SH PATTERN MODIFIERS
-
+.rs
+.sp
The pattern may be followed by \fBi\fR, \fBm\fR, \fBs\fR, or \fBx\fR to set the
PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options,
respectively. For example:
@@ -138,7 +158,8 @@ studied, the results of that are also output.
The \fB/D\fR modifier is a PCRE debugging feature, which also assumes \fB/I\fR.
It causes the internal form of compiled regular expressions to be output after
-compilation.
+compilation. If the pattern was studied, the information returned is also
+output.
The \fB/S\fR modifier causes \fBpcre_study()\fR to be called after the
expression has been compiled, and the results used when the expression is
@@ -154,17 +175,47 @@ present, and REG_NEWLINE is set if \fB/m\fR is present. The wrapper functions
force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.
The \fB/8\fR modifier causes \fBpcretest\fR to call PCRE with the PCRE_UTF8
-option set. This turns on the (currently incomplete) support for UTF-8
-character handling in PCRE, provided that it was compiled with this support
-enabled. This modifier also causes any non-printing characters in output
-strings to be printed using the \\x{hh...} notation if they are valid UTF-8
-sequences.
-
+option set. This turns on support for UTF-8 character handling in PCRE,
+provided that it was compiled with this support enabled. This modifier also
+causes any non-printing characters in output strings to be printed using the
+\\x{hh...} notation if they are valid UTF-8 sequences.
+
+.SH CALLOUTS
+.rs
+.sp
+If the pattern contains any callout requests, \fBpcretest\fR's callout function
+will be called. By default, it displays the callout number, and the start and
+current positions in the text at the callout time. For example, the output
+
+ --->pqrabcdef
+ 0 ^ ^
+
+indicates that callout number 0 occurred for a match attempt starting at the
+fourth character of the subject string, when the pointer was at the seventh
+character. The callout function returns zero (carry on matching) by default.
+
+Inserting callouts may be helpful when using \fBpcretest\fR to check
+complicated regular expressions. For further information about callouts, see
+the
+.\" HREF
+\fBpcrecallout\fR
+.\"
+documentation.
+
+For testing the PCRE library, additional control of callout behaviour is
+available via escape sequences in the data, as described in the following
+section. In particular, it is possible to pass in a number as callout data (the
+default is zero). If the callout function receives a non-zero number, it
+returns that value instead of zero.
.SH DATA LINES
-
+.rs
+.sp
Before each data line is passed to \fBpcre_exec()\fR, leading and trailing
-whitespace is removed, and it is then scanned for \\ escapes. The following are
+whitespace is removed, and it is then scanned for \\ escapes. Some of these are
+pretty esoteric features, intended for checking out some of the more
+complicated features of PCRE. If you are just testing "ordinary" regular
+expressions, you probably don't need any of these. The following escapes are
recognized:
\\a alarm (= BEL)
@@ -177,24 +228,49 @@ recognized:
\\v vertical tab
\\nnn octal character (up to 3 octal digits)
\\xhh hexadecimal character (up to 2 hex digits)
- \\x{hh...} hexadecimal UTF-8 character
-
+ \\x{hh...} hexadecimal character, any number of digits
+ in UTF-8 mode
\\A pass the PCRE_ANCHORED option to \fBpcre_exec()\fR
\\B pass the PCRE_NOTBOL option to \fBpcre_exec()\fR
\\Cdd call pcre_copy_substring() for substring dd
- after a successful match (any decimal number
- less than 32)
+ after a successful match (any decimal number
+ less than 32)
+ \\Cname call pcre_copy_named_substring() for substring
+ "name" after a successful match (name termin-
+ ated by next non alphanumeric character)
+ \\C+ show the current captured substrings at callout
+ time
+ \\C- do not supply a callout function
+ \\C!n return 1 instead of 0 when callout number n is
+ reached
+ \\C!n!m return 1 instead of 0 when callout number n is
+ reached for the nth time
+ \\C*n pass the number n (may be negative) as callout
+ data
\\Gdd call pcre_get_substring() for substring dd
- after a successful match (any decimal number
- less than 32)
+ after a successful match (any decimal number
+ less than 32)
+ \\Gname call pcre_get_named_substring() for substring
+ "name" after a successful match (name termin-
+ ated by next non-alphanumeric character)
\\L call pcre_get_substringlist() after a
- successful match
+ successful match
+ \\M discover the minimum MATCH_LIMIT setting
\\N pass the PCRE_NOTEMPTY option to \fBpcre_exec()\fR
\\Odd set the size of the output vector passed to
- \fBpcre_exec()\fR to dd (any number of decimal
- digits)
+ \fBpcre_exec()\fR to dd (any number of decimal
+ digits)
\\Z pass the PCRE_NOTEOL option to \fBpcre_exec()\fR
+If \\M is present, \fBpcretest\fR calls \fBpcre_exec()\fR several times, with
+different values in the \fImatch_limit\fR field of the \fBpcre_extra\fR data
+structure, until it finds the minimum number that is needed for
+\fBpcre_exec()\fR to complete. This number is a measure of the amount of
+recursion and backtracking that takes place, and checking it out can be
+instructive. For most simple matches, the number is quite small, but for
+patterns with very large numbers of matching possibilities, it can become large
+very quickly with increasing length of subject string.
+
When \\O is used, it may be higher or lower than the size set by the \fB-O\fR
option (or defaulted to 45); \\O applies only to the call of \fBpcre_exec()\fR
for the line in which it appears.
@@ -212,15 +288,15 @@ of the \fB/8\fR modifier on the pattern. It is recognized always. There may be
any number of hexadecimal digits inside the braces. The result is from one to
six bytes, encoded according to the UTF-8 rules.
-
.SH OUTPUT FROM PCRETEST
-
+.rs
+.sp
When a match succeeds, pcretest outputs the list of captured substrings that
\fBpcre_exec()\fR returns, starting with number 0 for the string that matched
the whole pattern. Here is an example of an interactive pcretest run.
$ pcretest
- PCRE version 2.06 08-Jun-1999
+ PCRE version 4.00 08-Jan-2003
re> /^abc(\\d+)/
data> abc123
@@ -265,18 +341,16 @@ Note that while patterns can be continued over several lines (a plain ">"
prompt is used for continuations), data lines may not. However newlines can be
included in data by means of the \\n escape.
-
.SH AUTHOR
+.rs
+.sp
Philip Hazel <ph10@cam.ac.uk>
.br
University Computing Service,
.br
-New Museums Site,
-.br
Cambridge CB2 3QG, England.
-.br
-Phone: +44 1223 334714
-Last updated: 15 August 2001
+.in 0
+Last updated: 03 February 2003
.br
-Copyright (c) 1997-2001 University of Cambridge.
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/pcretest.html b/doc/pcretest.html
deleted file mode 100644
index 918e6de..0000000
--- a/doc/pcretest.html
+++ /dev/null
@@ -1,369 +0,0 @@
-<HTML>
-<HEAD>
-<TITLE>pcretest specification</TITLE>
-</HEAD>
-<body bgcolor="#FFFFFF" text="#00005A">
-<H1>pcretest specification</H1>
-This HTML document has been generated automatically from the original man page.
-If there is any nonsense in it, please consult the man page in case the
-conversion went wrong.
-<UL>
-<LI><A NAME="TOC1" HREF="#SEC1">NAME</A>
-<LI><A NAME="TOC2" HREF="#SEC2">SYNOPSIS</A>
-<LI><A NAME="TOC3" HREF="#SEC3">OPTIONS</A>
-<LI><A NAME="TOC4" HREF="#SEC4">DESCRIPTION</A>
-<LI><A NAME="TOC5" HREF="#SEC5">PATTERN MODIFIERS</A>
-<LI><A NAME="TOC6" HREF="#SEC6">DATA LINES</A>
-<LI><A NAME="TOC7" HREF="#SEC7">OUTPUT FROM PCRETEST</A>
-<LI><A NAME="TOC8" HREF="#SEC8">AUTHOR</A>
-</UL>
-<LI><A NAME="SEC1" HREF="#TOC1">NAME</A>
-<P>
-pcretest - a program for testing Perl-compatible regular expressions.
-</P>
-<LI><A NAME="SEC2" HREF="#TOC1">SYNOPSIS</A>
-<P>
-<B>pcretest [-d] [-i] [-m] [-o osize] [-p] [-t] [source] [destination]</B>
-</P>
-<P>
-<B>pcretest</B> was written as a test program for the PCRE regular expression
-library itself, but it can also be used for experimenting with regular
-expressions. This man page describes the features of the test program; for
-details of the regular expressions themselves, see the <B>pcre</B> man page.
-</P>
-<LI><A NAME="SEC3" HREF="#TOC1">OPTIONS</A>
-<P>
-<B>-d</B>
-Behave as if each regex had the <B>/D</B> modifier (see below); the internal
-form is output after compilation.
-</P>
-<P>
-<B>-i</B>
-Behave as if each regex had the <B>/I</B> modifier; information about the
-compiled pattern is given after compilation.
-</P>
-<P>
-<B>-m</B>
-Output the size of each compiled pattern after it has been compiled. This is
-equivalent to adding /M to each regular expression. For compatibility with
-earlier versions of pcretest, <B>-s</B> is a synonym for <B>-m</B>.
-</P>
-<P>
-<B>-o</B> <I>osize</I>
-Set the number of elements in the output vector that is used when calling PCRE
-to be <I>osize</I>. The default value is 45, which is enough for 14 capturing
-subexpressions. The vector size can be changed for individual matching calls by
-including \O in the data line (see below).
-</P>
-<P>
-<B>-p</B>
-Behave as if each regex has <B>/P</B> modifier; the POSIX wrapper API is used
-to call PCRE. None of the other options has any effect when <B>-p</B> is set.
-</P>
-<P>
-<B>-t</B>
-Run each compile, study, and match 20000 times with a timer, and output
-resulting time per compile or match (in milliseconds). Do not set <B>-t</B> with
-<B>-m</B>, because you will then get the size output 20000 times and the timing
-will be distorted.
-</P>
-<LI><A NAME="SEC4" HREF="#TOC1">DESCRIPTION</A>
-<P>
-If <B>pcretest</B> is given two filename arguments, it reads from the first and
-writes to the second. If it is given only one filename argument, it reads from
-that file and writes to stdout. Otherwise, it reads from stdin and writes to
-stdout, and prompts for each line of input, using "re&#62;" to prompt for regular
-expressions, and "data&#62;" to prompt for data lines.
-</P>
-<P>
-The program handles any number of sets of input on a single input file. Each
-set starts with a regular expression, and continues with any number of data
-lines to be matched against the pattern. An empty line signals the end of the
-data lines, at which point a new regular expression is read. The regular
-expressions are given enclosed in any non-alphameric delimiters other than
-backslash, for example
-</P>
-<P>
-<PRE>
- /(a|bc)x+yz/
-</PRE>
-</P>
-<P>
-White space before the initial delimiter is ignored. A regular expression may
-be continued over several input lines, in which case the newline characters are
-included within it. It is possible to include the delimiter within the pattern
-by escaping it, for example
-</P>
-<P>
-<PRE>
- /abc\/def/
-</PRE>
-</P>
-<P>
-If you do so, the escape and the delimiter form part of the pattern, but since
-delimiters are always non-alphameric, this does not affect its interpretation.
-If the terminating delimiter is immediately followed by a backslash, for
-example,
-</P>
-<P>
-<PRE>
- /abc/\
-</PRE>
-</P>
-<P>
-then a backslash is added to the end of the pattern. This is done to provide a
-way of testing the error condition that arises if a pattern finishes with a
-backslash, because
-</P>
-<P>
-<PRE>
- /abc\/
-</PRE>
-</P>
-<P>
-is interpreted as the first line of a pattern that starts with "abc/", causing
-pcretest to read the next line as a continuation of the regular expression.
-</P>
-<LI><A NAME="SEC5" HREF="#TOC1">PATTERN MODIFIERS</A>
-<P>
-The pattern may be followed by <B>i</B>, <B>m</B>, <B>s</B>, or <B>x</B> to set the
-PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options,
-respectively. For example:
-</P>
-<P>
-<PRE>
- /caseless/i
-</PRE>
-</P>
-<P>
-These modifier letters have the same effect as they do in Perl. There are
-others which set PCRE options that do not correspond to anything in Perl:
-<B>/A</B>, <B>/E</B>, and <B>/X</B> set PCRE_ANCHORED, PCRE_DOLLAR_ENDONLY, and
-PCRE_EXTRA respectively.
-</P>
-<P>
-Searching for all possible matches within each subject string can be requested
-by the <B>/g</B> or <B>/G</B> modifier. After finding a match, PCRE is called
-again to search the remainder of the subject string. The difference between
-<B>/g</B> and <B>/G</B> is that the former uses the <I>startoffset</I> argument to
-<B>pcre_exec()</B> to start searching at a new point within the entire string
-(which is in effect what Perl does), whereas the latter passes over a shortened
-substring. This makes a difference to the matching process if the pattern
-begins with a lookbehind assertion (including \b or \B).
-</P>
-<P>
-If any call to <B>pcre_exec()</B> in a <B>/g</B> or <B>/G</B> sequence matches an
-empty string, the next call is done with the PCRE_NOTEMPTY and PCRE_ANCHORED
-flags set in order to search for another, non-empty, match at the same point.
-If this second match fails, the start offset is advanced by one, and the normal
-match is retried. This imitates the way Perl handles such cases when using the
-<B>/g</B> modifier or the <B>split()</B> function.
-</P>
-<P>
-There are a number of other modifiers for controlling the way <B>pcretest</B>
-operates.
-</P>
-<P>
-The <B>/+</B> modifier requests that as well as outputting the substring that
-matched the entire pattern, pcretest should in addition output the remainder of
-the subject string. This is useful for tests where the subject contains
-multiple copies of the same substring.
-</P>
-<P>
-The <B>/L</B> modifier must be followed directly by the name of a locale, for
-example,
-</P>
-<P>
-<PRE>
- /pattern/Lfr
-</PRE>
-</P>
-<P>
-For this reason, it must be the last modifier letter. The given locale is set,
-<B>pcre_maketables()</B> is called to build a set of character tables for the
-locale, and this is then passed to <B>pcre_compile()</B> when compiling the
-regular expression. Without an <B>/L</B> modifier, NULL is passed as the tables
-pointer; that is, <B>/L</B> applies only to the expression on which it appears.
-</P>
-<P>
-The <B>/I</B> modifier requests that <B>pcretest</B> output information about the
-compiled expression (whether it is anchored, has a fixed first character, and
-so on). It does this by calling <B>pcre_fullinfo()</B> after compiling an
-expression, and outputting the information it gets back. If the pattern is
-studied, the results of that are also output.
-</P>
-<P>
-The <B>/D</B> modifier is a PCRE debugging feature, which also assumes <B>/I</B>.
-It causes the internal form of compiled regular expressions to be output after
-compilation.
-</P>
-<P>
-The <B>/S</B> modifier causes <B>pcre_study()</B> to be called after the
-expression has been compiled, and the results used when the expression is
-matched.
-</P>
-<P>
-The <B>/M</B> modifier causes the size of memory block used to hold the compiled
-pattern to be output.
-</P>
-<P>
-The <B>/P</B> modifier causes <B>pcretest</B> to call PCRE via the POSIX wrapper
-API rather than its native API. When this is done, all other modifiers except
-<B>/i</B>, <B>/m</B>, and <B>/+</B> are ignored. REG_ICASE is set if <B>/i</B> is
-present, and REG_NEWLINE is set if <B>/m</B> is present. The wrapper functions
-force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.
-</P>
-<P>
-The <B>/8</B> modifier causes <B>pcretest</B> to call PCRE with the PCRE_UTF8
-option set. This turns on the (currently incomplete) support for UTF-8
-character handling in PCRE, provided that it was compiled with this support
-enabled. This modifier also causes any non-printing characters in output
-strings to be printed using the \x{hh...} notation if they are valid UTF-8
-sequences.
-</P>
-<LI><A NAME="SEC6" HREF="#TOC1">DATA LINES</A>
-<P>
-Before each data line is passed to <B>pcre_exec()</B>, leading and trailing
-whitespace is removed, and it is then scanned for \ escapes. The following are
-recognized:
-</P>
-<P>
-<PRE>
- \a alarm (= BEL)
- \b backspace
- \e escape
- \f formfeed
- \n newline
- \r carriage return
- \t tab
- \v vertical tab
- \nnn octal character (up to 3 octal digits)
- \xhh hexadecimal character (up to 2 hex digits)
- \x{hh...} hexadecimal UTF-8 character
-</PRE>
-</P>
-<P>
-<PRE>
- \A pass the PCRE_ANCHORED option to <B>pcre_exec()</B>
- \B pass the PCRE_NOTBOL option to <B>pcre_exec()</B>
- \Cdd call pcre_copy_substring() for substring dd
- after a successful match (any decimal number
- less than 32)
- \Gdd call pcre_get_substring() for substring dd
- after a successful match (any decimal number
- less than 32)
- \L call pcre_get_substringlist() after a
- successful match
- \N pass the PCRE_NOTEMPTY option to <B>pcre_exec()</B>
- \Odd set the size of the output vector passed to
- <B>pcre_exec()</B> to dd (any number of decimal
- digits)
- \Z pass the PCRE_NOTEOL option to <B>pcre_exec()</B>
-</PRE>
-</P>
-<P>
-When \O is used, it may be higher or lower than the size set by the <B>-O</B>
-option (or defaulted to 45); \O applies only to the call of <B>pcre_exec()</B>
-for the line in which it appears.
-</P>
-<P>
-A backslash followed by anything else just escapes the anything else. If the
-very last character is a backslash, it is ignored. This gives a way of passing
-an empty line as data, since a real empty line terminates the data input.
-</P>
-<P>
-If <B>/P</B> was present on the regex, causing the POSIX wrapper API to be used,
-only <B>\B</B>, and <B>\Z</B> have any effect, causing REG_NOTBOL and REG_NOTEOL
-to be passed to <B>regexec()</B> respectively.
-</P>
-<P>
-The use of \x{hh...} to represent UTF-8 characters is not dependent on the use
-of the <B>/8</B> modifier on the pattern. It is recognized always. There may be
-any number of hexadecimal digits inside the braces. The result is from one to
-six bytes, encoded according to the UTF-8 rules.
-</P>
-<LI><A NAME="SEC7" HREF="#TOC1">OUTPUT FROM PCRETEST</A>
-<P>
-When a match succeeds, pcretest outputs the list of captured substrings that
-<B>pcre_exec()</B> returns, starting with number 0 for the string that matched
-the whole pattern. Here is an example of an interactive pcretest run.
-</P>
-<P>
-<PRE>
- $ pcretest
- PCRE version 2.06 08-Jun-1999
-</PRE>
-</P>
-<P>
-<PRE>
- re&#62; /^abc(\d+)/
- data&#62; abc123
- 0: abc123
- 1: 123
- data&#62; xyz
- No match
-</PRE>
-</P>
-<P>
-If the strings contain any non-printing characters, they are output as \0x
-escapes, or as \x{...} escapes if the <B>/8</B> modifier was present on the
-pattern. If the pattern has the <B>/+</B> modifier, then the output for
-substring 0 is followed by the the rest of the subject string, identified by
-"0+" like this:
-</P>
-<P>
-<PRE>
- re&#62; /cat/+
- data&#62; cataract
- 0: cat
- 0+ aract
-</PRE>
-</P>
-<P>
-If the pattern has the <B>/g</B> or <B>/G</B> modifier, the results of successive
-matching attempts are output in sequence, like this:
-</P>
-<P>
-<PRE>
- re&#62; /\Bi(\w\w)/g
- data&#62; Mississippi
- 0: iss
- 1: ss
- 0: iss
- 1: ss
- 0: ipp
- 1: pp
-</PRE>
-</P>
-<P>
-"No match" is output only if the first match attempt fails.
-</P>
-<P>
-If any of the sequences <B>\C</B>, <B>\G</B>, or <B>\L</B> are present in a
-data line that is successfully matched, the substrings extracted by the
-convenience functions are output with C, G, or L after the string number
-instead of a colon. This is in addition to the normal full list. The string
-length (that is, the return from the extraction function) is given in
-parentheses after each string for <B>\C</B> and <B>\G</B>.
-</P>
-<P>
-Note that while patterns can be continued over several lines (a plain "&#62;"
-prompt is used for continuations), data lines may not. However newlines can be
-included in data by means of the \n escape.
-</P>
-<LI><A NAME="SEC8" HREF="#TOC1">AUTHOR</A>
-<P>
-Philip Hazel &#60;ph10@cam.ac.uk&#62;
-<BR>
-University Computing Service,
-<BR>
-New Museums Site,
-<BR>
-Cambridge CB2 3QG, England.
-<BR>
-Phone: +44 1223 334714
-</P>
-<P>
-Last updated: 15 August 2001
-<BR>
-Copyright (c) 1997-2001 University of Cambridge.
diff --git a/doc/pcretest.txt b/doc/pcretest.txt
index 0e13b6c..80585af 100644
--- a/doc/pcretest.txt
+++ b/doc/pcretest.txt
@@ -3,20 +3,26 @@ NAME
expressions.
-
SYNOPSIS
pcretest [-d] [-i] [-m] [-o osize] [-p] [-t] [source] [des-
tination]
pcretest was written as a test program for the PCRE regular
expression library itself, but it can also be used for
- experimenting with regular expressions. This man page
+ experimenting with regular expressions. This document
describes the features of the test program; for details of
- the regular expressions themselves, see the pcre man page.
-
+ the regular expressions themselves, see the pcrepattern
+ documentation. For details of PCRE and its options, see the
+ pcreapi documentation.
OPTIONS
+
+
+ -C Output the version number of the PCRE library, and
+ all available information about the optional
+ features that are included, and then exit.
+
-d Behave as if each regex had the /D modifier (see
below); the internal form is output after compila-
tion.
@@ -42,25 +48,17 @@ OPTIONS
wrapper API is used to call PCRE. None of the
other options has any effect when -p is set.
- -t Run each compile, study, and match 20000 times
- with a timer, and output resulting time per com-
- pile or match (in milliseconds). Do not set -t
- with -m, because you will then get the size output
- 20000 times and the timing will be distorted.
-
+ -t Run each compile, study, and match many times with
+ a timer, and output resulting time per compile or
+ match (in milliseconds). Do not set -t with -m,
+ because you will then get the size output 20000
+ times and the timing will be distorted.
DESCRIPTION
+
If pcretest is given two filename arguments, it reads from
the first and writes to the second. If it is given only one
-
-
-
-
-SunOS 5.8 Last change: 1
-
-
-
filename argument, it reads from that file and writes to
stdout. Otherwise, it reads from stdin and writes to stdout,
and prompts for each line of input, using "re>" to prompt
@@ -70,10 +68,18 @@ SunOS 5.8 Last change: 1
The program handles any number of sets of input on a single
input file. Each set starts with a regular expression, and
continues with any number of data lines to be matched
- against the pattern. An empty line signals the end of the
- data lines, at which point a new regular expression is read.
- The regular expressions are given enclosed in any non-
- alphameric delimiters other than backslash, for example
+ against the pattern.
+
+ Each line is matched separately and independently. If you
+ want to do multiple-line matches, you have to use the \n
+ escape sequence in a single line of input to encode the new-
+ line characters. The maximum length of data line is 30,000
+ characters.
+
+ An empty line signals the end of the data lines, at which
+ point a new regular expression is read. The regular expres-
+ sions are given enclosed in any non-alphameric delimiters
+ other than backslash, for example
/(a|bc)x+yz/
@@ -104,8 +110,8 @@ SunOS 5.8 Last change: 1
continuation of the regular expression.
-
PATTERN MODIFIERS
+
The pattern may be followed by i, m, s, or x to set the
PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED
options, respectively. For example:
@@ -165,9 +171,11 @@ PATTERN MODIFIERS
pcre_fullinfo() after compiling an expression, and output-
ting the information it gets back. If the pattern is stu-
died, the results of that are also output.
+
The /D modifier is a PCRE debugging feature, which also
assumes /I. It causes the internal form of compiled regular
- expressions to be output after compilation.
+ expressions to be output after compilation. If the pattern
+ was studied, the information returned is also output.
The /S modifier causes pcre_study() to be called after the
expression has been compiled, and the results used when the
@@ -185,19 +193,49 @@ PATTERN MODIFIERS
REG_NEWLINE is set.
The /8 modifier causes pcretest to call PCRE with the
- PCRE_UTF8 option set. This turns on the (currently incom-
- plete) support for UTF-8 character handling in PCRE, pro-
- vided that it was compiled with this support enabled. This
- modifier also causes any non-printing characters in output
- strings to be printed using the \x{hh...} notation if they
- are valid UTF-8 sequences.
+ PCRE_UTF8 option set. This turns on support for UTF-8 char-
+ acter handling in PCRE, provided that it was compiled with
+ this support enabled. This modifier also causes any non-
+ printing characters in output strings to be printed using
+ the \x{hh...} notation if they are valid UTF-8 sequences.
+
+
+CALLOUTS
+
+ If the pattern contains any callout requests, pcretest's
+ callout function will be called. By default, it displays the
+ callout number, and the start and current positions in the
+ text at the callout time. For example, the output
+
+ --->pqrabcdef
+ 0 ^ ^
+
+ indicates that callout number 0 occurred for a match attempt
+ starting at the fourth character of the subject string, when
+ the pointer was at the seventh character. The callout func-
+ tion returns zero (carry on matching) by default.
+
+ Inserting callouts may be helpful when using pcretest to
+ check complicated regular expressions. For further informa-
+ tion about callouts, see the pcrecallout documentation.
+ For testing the PCRE library, additional control of callout
+ behaviour is available via escape sequences in the data, as
+ described in the following section. In particular, it is
+ possible to pass in a number as callout data (the default is
+ zero). If the callout function receives a non-zero number,
+ it returns that value instead of zero.
DATA LINES
+
Before each data line is passed to pcre_exec(), leading and
trailing whitespace is removed, and it is then scanned for \
- escapes. The following are recognized:
+ escapes. Some of these are pretty esoteric features,
+ intended for checking out some of the more complicated
+ features of PCRE. If you are just testing "ordinary" regular
+ expressions, you probably don't need any of these. The fol-
+ lowing escapes are recognized:
\a alarm (= BEL)
\b backspace
@@ -209,25 +247,52 @@ DATA LINES
\v vertical tab
\nnn octal character (up to 3 octal digits)
\xhh hexadecimal character (up to 2 hex digits)
- \x{hh...} hexadecimal UTF-8 character
-
+ \x{hh...} hexadecimal character, any number of digits
+ in UTF-8 mode
\A pass the PCRE_ANCHORED option to pcre_exec()
\B pass the PCRE_NOTBOL option to pcre_exec()
\Cdd call pcre_copy_substring() for substring dd
- after a successful match (any decimal number
- less than 32)
+ after a successful match (any decimal number
+ less than 32)
+ \Cname call pcre_copy_named_substring() for substring
+ "name" after a successful match (name termin-
+ ated by next non alphanumeric character)
+ \C+ show the current captured substrings at callout
+ time
+
+ C- do not supply a callout function
+ \C!n return 1 instead of 0 when callout number n is
+ reached
+ \C!n!m return 1 instead of 0 when callout number n is
+ reached for the nth time
+ \C*n pass the number n (may be negative) as callout
+ data
\Gdd call pcre_get_substring() for substring dd
-
- after a successful match (any decimal number
- less than 32)
+ after a successful match (any decimal number
+ less than 32)
+ \Gname call pcre_get_named_substring() for substring
+ "name" after a successful match (name termin-
+ ated by next non-alphanumeric character)
\L call pcre_get_substringlist() after a
- successful match
+ successful match
+ \M discover the minimum MATCH_LIMIT setting
\N pass the PCRE_NOTEMPTY option to pcre_exec()
\Odd set the size of the output vector passed to
- pcre_exec() to dd (any number of decimal
- digits)
+ pcre_exec() to dd (any number of decimal
+ digits)
\Z pass the PCRE_NOTEOL option to pcre_exec()
+ If \M is present, pcretest calls pcre_exec() several times,
+ with different values in the match_limit field of the
+ pcre_extra data structure, until it finds the minimum number
+ that is needed for pcre_exec() to complete. This number is a
+ measure of the amount of recursion and backtracking that
+ takes place, and checking it out can be instructive. For
+ most simple matches, the number is quite small, but for pat-
+ terns with very large numbers of matching possibilities, it
+ can become large very quickly with increasing length of sub-
+ ject string.
+
When \O is used, it may be higher or lower than the size set
by the -O option (or defaulted to 45); \O applies only to
the call of pcre_exec() for the line in which it appears.
@@ -249,15 +314,15 @@ DATA LINES
bytes, encoded according to the UTF-8 rules.
-
OUTPUT FROM PCRETEST
+
When a match succeeds, pcretest outputs the list of captured
substrings that pcre_exec() returns, starting with number 0
for the string that matched the whole pattern. Here is an
example of an interactive pcretest run.
$ pcretest
- PCRE version 2.06 08-Jun-1999
+ PCRE version 4.00 08-Jan-2003
re> /^abc(\d+)/
data> abc123
@@ -307,13 +372,11 @@ OUTPUT FROM PCRETEST
of the \n escape.
-
AUTHOR
+
Philip Hazel <ph10@cam.ac.uk>
University Computing Service,
- New Museums Site,
Cambridge CB2 3QG, England.
- Phone: +44 1223 334714
- Last updated: 15 August 2001
- Copyright (c) 1997-2001 University of Cambridge.
+Last updated: 03 February 2003
+Copyright (c) 1997-2003 University of Cambridge.
diff --git a/doc/perltest.txt b/doc/perltest.txt
index 5a40401..9ea9d93 100644
--- a/doc/perltest.txt
+++ b/doc/perltest.txt
@@ -13,10 +13,15 @@ for perltest as well as for pcretest, and the special upper case modifiers such
as /A that pcretest recognizes are not used in these files. The output should
be identical, apart from the initial identifying banner.
-For testing UTF-8 features, an alternative form of perltest, called perltest8,
-is supplied. This requires Perl 5.6 or higher. It recognizes the special
-modifier /8 that pcretest uses to invoke UTF-8 functionality. The testinput5
-file can be fed to perltest8.
+The perltest script can also test UTF-8 features. It works as is for Perl 5.8
+or higher. It recognizes the special modifier /8 that pcretest uses to invoke
+UTF-8 functionality. The testinput5 file can be fed to perltest to run UTF-8
+tests.
+
+For Perl 5.6, perltest won't work unmodified for the UTF-8 tests. You need to
+uncomment the "use utf8" lines that it contains. It is best to do this on a
+copy of the script, because for non-UTF-8 tests, these lines should remain
+commented out.
The testinput2 and testinput4 files are not suitable for feeding to perltest,
since they do make use of the special upper case modifiers and escapes that
@@ -26,4 +31,4 @@ them correctly. Similarly, testinput6 tests UTF-8 features that do not relate
to Perl.
Philip Hazel <ph10@cam.ac.uk>
-August 2000
+August 2002
diff --git a/get.c b/get.c
index 55e736d..a20473c 100644
--- a/get.c
+++ b/get.c
@@ -9,7 +9,7 @@ the file Tech.Notes for some information on the internals.
Written by: Philip Hazel <ph10@cam.ac.uk>
- Copyright (c) 1997-2001 University of Cambridge
+ Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
@@ -43,6 +43,52 @@ the external pcre header. */
#include "internal.h"
+/*************************************************
+* Find number for named string *
+*************************************************/
+
+/* This function is used by the two extraction functions below, as well
+as being generally available.
+
+Arguments:
+ code the compiled regex
+ stringname the name whose number is required
+
+Returns: the number of the named parentheses, or a negative number
+ (PCRE_ERROR_NOSUBSTRING) if not found
+*/
+
+int
+pcre_get_stringnumber(const pcre *code, const char *stringname)
+{
+int rc;
+int entrysize;
+int top, bot;
+uschar *nametable;
+
+if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
+ return rc;
+if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
+
+if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
+ return rc;
+if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
+ return rc;
+
+bot = 0;
+while (top > bot)
+ {
+ int mid = (top + bot) / 2;
+ uschar *entry = nametable + entrysize*mid;
+ int c = strcmp(stringname, (char *)(entry + 2));
+ if (c == 0) return (entry[0] << 8) + entry[1];
+ if (c > 0) bot = mid + 1; else top = mid;
+ }
+
+return PCRE_ERROR_NOSUBSTRING;
+}
+
+
/*************************************************
* Copy captured string to given buffer *
@@ -89,6 +135,44 @@ return yield;
/*************************************************
+* Copy named captured string to given buffer *
+*************************************************/
+
+/* This function copies a single captured substring into a given buffer,
+identifying it by name.
+
+Arguments:
+ code the compiled regex
+ subject the subject string that was matched
+ ovector pointer to the offsets table
+ stringcount the number of substrings that were captured
+ (i.e. the yield of the pcre_exec call, unless
+ that was zero, in which case it should be 1/3
+ of the offset table size)
+ stringname the name of the required substring
+ buffer where to put the substring
+ size the size of the buffer
+
+Returns: if successful:
+ the length of the copied string, not including the zero
+ that is put on the end; can be zero
+ if not successful:
+ PCRE_ERROR_NOMEMORY (-6) buffer too small
+ PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
+*/
+
+int
+pcre_copy_named_substring(const pcre *code, const char *subject, int *ovector,
+ int stringcount, const char *stringname, char *buffer, int size)
+{
+int n = pcre_get_stringnumber(code, stringname);
+if (n <= 0) return n;
+return pcre_copy_substring(subject, ovector, stringcount, n, buffer, size);
+}
+
+
+
+/*************************************************
* Copy all captured strings to new store *
*************************************************/
@@ -208,6 +292,44 @@ return yield;
/*************************************************
+* Copy named captured string to new store *
+*************************************************/
+
+/* This function copies a single captured substring, identified by name, into
+new store.
+
+Arguments:
+ code the compiled regex
+ subject the subject string that was matched
+ ovector pointer to the offsets table
+ stringcount the number of substrings that were captured
+ (i.e. the yield of the pcre_exec call, unless
+ that was zero, in which case it should be 1/3
+ of the offset table size)
+ stringname the name of the required substring
+ stringptr where to put the pointer
+
+Returns: if successful:
+ the length of the copied string, not including the zero
+ that is put on the end; can be zero
+ if not successful:
+ PCRE_ERROR_NOMEMORY (-6) couldn't get memory
+ PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
+*/
+
+int
+pcre_get_named_substring(const pcre *code, const char *subject, int *ovector,
+ int stringcount, const char *stringname, const char **stringptr)
+{
+int n = pcre_get_stringnumber(code, stringname);
+if (n <= 0) return n;
+return pcre_get_substring(subject, ovector, stringcount, n, stringptr);
+}
+
+
+
+
+/*************************************************
* Free store obtained by get_substring *
*************************************************/
diff --git a/internal.h b/internal.h
index 0c8c1c9..d7a47df 100644
--- a/internal.h
+++ b/internal.h
@@ -9,7 +9,7 @@ the file Tech.Notes for some information on the internals.
Written by: Philip Hazel <ph10@cam.ac.uk>
- Copyright (c) 1997-2001 University of Cambridge
+ Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
@@ -39,6 +39,17 @@ modules, but which are not relevant to the outside. */
#include "config.h"
+/* When compiling for use with the Virtual Pascal compiler, these functions
+need to have their names changed. PCRE must be compiled with the -DVPCOMPAT
+option on the command line. */
+
+#ifdef VPCOMPAT
+#define strncmp(s1,s2,m) _strncmp(s1,s2,m)
+#define memcpy(d,s,n) _memcpy(d,s,n)
+#define memmove(d,s,n) _memmove(d,s,n)
+#define memset(s,c,n) _memset(s,c,n)
+#else /* VPCOMPAT */
+
/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),
define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY
is set. Otherwise, include an emulating function for those systems that have
@@ -50,7 +61,7 @@ case in PCRE. */
#undef memmove /* some systems may have a macro */
#if HAVE_BCOPY
#define memmove(a, b, c) bcopy(b, a, c)
-#else
+#else /* HAVE_BCOPY */
void *
pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n)
{
@@ -60,8 +71,85 @@ src += n;
for (i = 0; i < n; ++i) *(--dest) = *(--src);
}
#define memmove(a, b, c) pcre_memmove(a, b, c)
+#endif /* not HAVE_BCOPY */
+#endif /* not HAVE_MEMMOVE */
+#endif /* not VPCOMPAT */
+
+
+/* PCRE keeps offsets in its compiled code as 2-byte quantities by default.
+These are used, for example, to link from the start of a subpattern to its
+alternatives and its end. The use of 2 bytes per offset limits the size of the
+compiled regex to around 64K, which is big enough for almost everybody.
+However, I received a request for an even bigger limit. For this reason, and
+also to make the code easier to maintain, the storing and loading of offsets
+from the byte string is now handled by the macros that are defined here.
+
+The macros are controlled by the value of LINK_SIZE. This defaults to 2 in
+the config.h file, but can be overridden by using -D on the command line. This
+is automated on Unix systems via the "configure" command. */
+
+#if LINK_SIZE == 2
+
+#define PUT(a,n,d) \
+ (a[n] = (d) >> 8), \
+ (a[(n)+1] = (d) & 255)
+
+#define GET(a,n) \
+ (((a)[n] << 8) | (a)[(n)+1])
+
+#define MAX_PATTERN_SIZE (1 << 16)
+
+
+#elif LINK_SIZE == 3
+
+#define PUT(a,n,d) \
+ (a[n] = (d) >> 16), \
+ (a[(n)+1] = (d) >> 8), \
+ (a[(n)+2] = (d) & 255)
+
+#define GET(a,n) \
+ (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
+
+#define MAX_PATTERN_SIZE (1 << 24)
+
+
+#elif LINK_SIZE == 4
+
+#define PUT(a,n,d) \
+ (a[n] = (d) >> 24), \
+ (a[(n)+1] = (d) >> 16), \
+ (a[(n)+2] = (d) >> 8), \
+ (a[(n)+3] = (d) & 255)
+
+#define GET(a,n) \
+ (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
+
+#define MAX_PATTERN_SIZE (1 << 30) /* Keep it positive */
+
+
+#else
+#error LINK_SIZE must be either 2, 3, or 4
#endif
-#endif
+
+
+/* Convenience macro defined in terms of the others */
+
+#define PUTINC(a,n,d) PUT(a,n,d), a += LINK_SIZE
+
+
+/* PCRE uses some other 2-byte quantities that do not change when the size of
+offsets changes. There are used for repeat counts and for other things such as
+capturing parenthesis numbers in back references. */
+
+#define PUT2(a,n,d) \
+ a[n] = (d) >> 8; \
+ a[(n)+1] = (d) & 255
+
+#define GET2(a,n) \
+ (((a)[n] << 8) | (a)[(n)+1])
+
+#define PUT2INC(a,n,d) PUT2(a,n,d), a += 2
+
/* Standard C headers plus the external interface definition */
@@ -71,6 +159,11 @@ for (i = 0; i < n; ++i) *(--dest) = *(--src);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#ifndef PCRE_SPY
+#define PCRE_DEFINITION /* Win32 __declspec(export) trigger for .dll */
+#endif
+
#include "pcre.h"
/* In case there is no definition of offsetof() provided - though any proper
@@ -90,11 +183,10 @@ with negative values. The public options defined in pcre.h start at the least
significant end. Make sure they don't overlap, though now that we have expanded
to four bytes there is plenty of space. */
-#define PCRE_FIRSTSET 0x40000000 /* first_char is set */
-#define PCRE_REQCHSET 0x20000000 /* req_char is set */
+#define PCRE_FIRSTSET 0x40000000 /* first_byte is set */
+#define PCRE_REQCHSET 0x20000000 /* req_byte is set */
#define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */
-#define PCRE_INGROUP 0x08000000 /* compiling inside a group */
-#define PCRE_ICHANGED 0x04000000 /* i option changes within regex */
+#define PCRE_ICHANGED 0x08000000 /* i option changes within regex */
/* Options for the "extra" block produced by pcre_study(). */
@@ -105,7 +197,8 @@ time, run time or study time, respectively. */
#define PUBLIC_OPTIONS \
(PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
- PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8)
+ PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
+ PCRE_NO_AUTO_CAPTURE)
#define PUBLIC_EXEC_OPTIONS \
(PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY)
@@ -116,6 +209,16 @@ time, run time or study time, respectively. */
#define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
+/* Negative values for the firstchar and reqchar variables */
+
+#define REQ_UNSET (-2)
+#define REQ_NONE (-1)
+
+/* Flags added to firstchar or reqchar */
+
+#define REQ_CASELESS 0x0100 /* indicates caselessness */
+#define REQ_EOL 0x0200 /* indicates reqchar followed by $ */
+
/* Miscellaneous definitions */
typedef int BOOL;
@@ -124,143 +227,241 @@ typedef int BOOL;
#define TRUE 1
/* Escape items that are just an encoding of a particular data value. Note that
-ESC_N is defined as yet another macro, which is set in config.h to either \n
+ESC_n is defined as yet another macro, which is set in config.h to either \n
(the default) or \r (which some people want). */
-#ifndef ESC_E
-#define ESC_E 27
+#ifndef ESC_e
+#define ESC_e 27
#endif
-#ifndef ESC_F
-#define ESC_F '\f'
+#ifndef ESC_f
+#define ESC_f '\f'
#endif
-#ifndef ESC_N
-#define ESC_N NEWLINE
+#ifndef ESC_n
+#define ESC_n NEWLINE
#endif
-#ifndef ESC_R
-#define ESC_R '\r'
+#ifndef ESC_r
+#define ESC_r '\r'
#endif
-#ifndef ESC_T
-#define ESC_T '\t'
+#ifndef ESC_t
+#define ESC_t '\t'
#endif
/* These are escaped items that aren't just an encoding of a particular data
value such as \n. They must have non-zero values, as check_escape() returns
their negation. Also, they must appear in the same order as in the opcode
-definitions below, up to ESC_z. The final one must be ESC_REF as subsequent
-values are used for \1, \2, \3, etc. There is a test in the code for an escape
-greater than ESC_b and less than ESC_Z to detect the types that may be
-repeated. If any new escapes are put in-between that don't consume a character,
-that code will have to change. */
+definitions below, up to ESC_z. There's a dummy for OP_ANY because it
+corresponds to "." rather than an escape sequence. The final one must be
+ESC_REF as subsequent values are used for \1, \2, \3, etc. There is are two
+tests in the code for an escape greater than ESC_b and less than ESC_Z to
+detect the types that may be repeated. These are the types that consume a
+character. If any new escapes are put in between that don't consume a
+character, that code will have to change. */
+
+enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,
+ ESC_w, ESC_dum1, ESC_C, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_REF };
+
+/* Flag bits and data types for the extended class (OP_XCLASS) for classes that
+contain UTF-8 characters with values greater than 255. */
+
+#define XCL_NOT 0x01 /* Flag: this is a negative class */
+#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */
+
+#define XCL_END 0 /* Marks end of individual items */
+#define XCL_SINGLE 1 /* Single item (one multibyte char) follows */
+#define XCL_RANGE 2 /* A range (two multibyte chars) follows */
-enum { ESC_A = 1, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W, ESC_w,
- ESC_Z, ESC_z, ESC_REF };
/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
-OP_EOD must correspond in order to the list of escapes immediately above. */
+OP_EOD must correspond in order to the list of escapes immediately above.
+Note that whenever this list is updated, the two macro definitions that follow
+must also be updated to match. */
enum {
- OP_END, /* End of pattern */
+ OP_END, /* 0 End of pattern */
/* Values corresponding to backslashed metacharacters */
- OP_SOD, /* Start of data: \A */
- OP_NOT_WORD_BOUNDARY, /* \B */
- OP_WORD_BOUNDARY, /* \b */
- OP_NOT_DIGIT, /* \D */
- OP_DIGIT, /* \d */
- OP_NOT_WHITESPACE, /* \S */
- OP_WHITESPACE, /* \s */
- OP_NOT_WORDCHAR, /* \W */
- OP_WORDCHAR, /* \w */
- OP_EODN, /* End of data or \n at end of data: \Z. */
- OP_EOD, /* End of data: \z */
-
- OP_OPT, /* Set runtime options */
- OP_CIRC, /* Start of line - varies with multiline switch */
- OP_DOLL, /* End of line - varies with multiline switch */
- OP_ANY, /* Match any character */
- OP_CHARS, /* Match string of characters */
- OP_NOT, /* Match anything but the following char */
-
- OP_STAR, /* The maximizing and minimizing versions of */
- OP_MINSTAR, /* all these opcodes must come in pairs, with */
- OP_PLUS, /* the minimizing one second. */
- OP_MINPLUS, /* This first set applies to single characters */
- OP_QUERY,
- OP_MINQUERY,
- OP_UPTO, /* From 0 to n matches */
- OP_MINUPTO,
- OP_EXACT, /* Exactly n matches */
-
- OP_NOTSTAR, /* The maximizing and minimizing versions of */
- OP_NOTMINSTAR, /* all these opcodes must come in pairs, with */
- OP_NOTPLUS, /* the minimizing one second. */
- OP_NOTMINPLUS, /* This first set applies to "not" single characters */
- OP_NOTQUERY,
- OP_NOTMINQUERY,
- OP_NOTUPTO, /* From 0 to n matches */
- OP_NOTMINUPTO,
- OP_NOTEXACT, /* Exactly n matches */
-
- OP_TYPESTAR, /* The maximizing and minimizing versions of */
- OP_TYPEMINSTAR, /* all these opcodes must come in pairs, with */
- OP_TYPEPLUS, /* the minimizing one second. These codes must */
- OP_TYPEMINPLUS, /* be in exactly the same order as those above. */
- OP_TYPEQUERY, /* This set applies to character types such as \d */
- OP_TYPEMINQUERY,
- OP_TYPEUPTO, /* From 0 to n matches */
- OP_TYPEMINUPTO,
- OP_TYPEEXACT, /* Exactly n matches */
-
- OP_CRSTAR, /* The maximizing and minimizing versions of */
- OP_CRMINSTAR, /* all these opcodes must come in pairs, with */
- OP_CRPLUS, /* the minimizing one second. These codes must */
- OP_CRMINPLUS, /* be in exactly the same order as those above. */
- OP_CRQUERY, /* These are for character classes and back refs */
- OP_CRMINQUERY,
- OP_CRRANGE, /* These are different to the three seta above. */
- OP_CRMINRANGE,
-
- OP_CLASS, /* Match a character class */
- OP_REF, /* Match a back reference */
- OP_RECURSE, /* Match this pattern recursively */
-
- OP_ALT, /* Start of alternation */
- OP_KET, /* End of group that doesn't have an unbounded repeat */
- OP_KETRMAX, /* These two must remain together and in this */
- OP_KETRMIN, /* order. They are for groups the repeat for ever. */
+ OP_SOD, /* 1 Start of data: \A */
+ OP_SOM, /* 2 Start of match (subject + offset): \G */
+ OP_NOT_WORD_BOUNDARY, /* 3 \B */
+ OP_WORD_BOUNDARY, /* 4 \b */
+ OP_NOT_DIGIT, /* 5 \D */
+ OP_DIGIT, /* 6 \d */
+ OP_NOT_WHITESPACE, /* 7 \S */
+ OP_WHITESPACE, /* 8 \s */
+ OP_NOT_WORDCHAR, /* 9 \W */
+ OP_WORDCHAR, /* 10 \w */
+ OP_ANY, /* 11 Match any character */
+ OP_ANYBYTE, /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */
+ OP_EODN, /* 13 End of data or \n at end of data: \Z. */
+ OP_EOD, /* 14 End of data: \z */
+
+ OP_OPT, /* 15 Set runtime options */
+ OP_CIRC, /* 16 Start of line - varies with multiline switch */
+ OP_DOLL, /* 17 End of line - varies with multiline switch */
+ OP_CHARS, /* 18 Match string of characters */
+ OP_NOT, /* 19 Match anything but the following char */
+
+ OP_STAR, /* 20 The maximizing and minimizing versions of */
+ OP_MINSTAR, /* 21 all these opcodes must come in pairs, with */
+ OP_PLUS, /* 22 the minimizing one second. */
+ OP_MINPLUS, /* 23 This first set applies to single characters */
+ OP_QUERY, /* 24 */
+ OP_MINQUERY, /* 25 */
+ OP_UPTO, /* 26 From 0 to n matches */
+ OP_MINUPTO, /* 27 */
+ OP_EXACT, /* 28 Exactly n matches */
+
+ OP_NOTSTAR, /* 29 The maximizing and minimizing versions of */
+ OP_NOTMINSTAR, /* 30 all these opcodes must come in pairs, with */
+ OP_NOTPLUS, /* 31 the minimizing one second. */
+ OP_NOTMINPLUS, /* 32 This set applies to "not" single characters */
+ OP_NOTQUERY, /* 33 */
+ OP_NOTMINQUERY, /* 34 */
+ OP_NOTUPTO, /* 35 From 0 to n matches */
+ OP_NOTMINUPTO, /* 36 */
+ OP_NOTEXACT, /* 37 Exactly n matches */
+
+ OP_TYPESTAR, /* 38 The maximizing and minimizing versions of */
+ OP_TYPEMINSTAR, /* 39 all these opcodes must come in pairs, with */
+ OP_TYPEPLUS, /* 40 the minimizing one second. These codes must */
+ OP_TYPEMINPLUS, /* 41 be in exactly the same order as those above. */
+ OP_TYPEQUERY, /* 42 This set applies to character types such as \d */
+ OP_TYPEMINQUERY, /* 43 */
+ OP_TYPEUPTO, /* 44 From 0 to n matches */
+ OP_TYPEMINUPTO, /* 45 */
+ OP_TYPEEXACT, /* 46 Exactly n matches */
+
+ OP_CRSTAR, /* 47 The maximizing and minimizing versions of */
+ OP_CRMINSTAR, /* 48 all these opcodes must come in pairs, with */
+ OP_CRPLUS, /* 49 the minimizing one second. These codes must */
+ OP_CRMINPLUS, /* 50 be in exactly the same order as those above. */
+ OP_CRQUERY, /* 51 These are for character classes and back refs */
+ OP_CRMINQUERY, /* 52 */
+ OP_CRRANGE, /* 53 These are different to the three seta above. */
+ OP_CRMINRANGE, /* 54 */
+
+ OP_CLASS, /* 55 Match a character class, chars < 256 only */
+ OP_NCLASS, /* 56 Same, but the bitmap was created from a negative
+ class - the difference is relevant only when a UTF-8
+ character > 255 is encountered. */
+
+ OP_XCLASS, /* 56 Extended class for handling UTF-8 chars within the
+ class. This does both positive and negative. */
+
+ OP_REF, /* 57 Match a back reference */
+ OP_RECURSE, /* 58 Match a numbered subpattern (possibly recursive) */
+ OP_CALLOUT, /* 59 Call out to external function if provided */
+
+ OP_ALT, /* 60 Start of alternation */
+ OP_KET, /* 61 End of group that doesn't have an unbounded repeat */
+ OP_KETRMAX, /* 62 These two must remain together and in this */
+ OP_KETRMIN, /* 63 order. They are for groups the repeat for ever. */
/* The assertions must come before ONCE and COND */
- OP_ASSERT, /* Positive lookahead */
- OP_ASSERT_NOT, /* Negative lookahead */
- OP_ASSERTBACK, /* Positive lookbehind */
- OP_ASSERTBACK_NOT, /* Negative lookbehind */
- OP_REVERSE, /* Move pointer back - used in lookbehind assertions */
+ OP_ASSERT, /* 64 Positive lookahead */
+ OP_ASSERT_NOT, /* 65 Negative lookahead */
+ OP_ASSERTBACK, /* 66 Positive lookbehind */
+ OP_ASSERTBACK_NOT, /* 67 Negative lookbehind */
+ OP_REVERSE, /* 68 Move pointer back - used in lookbehind assertions */
/* ONCE and COND must come after the assertions, with ONCE first, as there's
a test for >= ONCE for a subpattern that isn't an assertion. */
- OP_ONCE, /* Once matched, don't back up into the subpattern */
- OP_COND, /* Conditional group */
- OP_CREF, /* Used to hold an extraction string number (cond ref) */
+ OP_ONCE, /* 69 Once matched, don't back up into the subpattern */
+ OP_COND, /* 70 Conditional group */
+ OP_CREF, /* 71 Used to hold an extraction string number (cond ref) */
- OP_BRAZERO, /* These two must remain together and in this */
- OP_BRAMINZERO, /* order. */
+ OP_BRAZERO, /* 72 These two must remain together and in this */
+ OP_BRAMINZERO, /* 73 order. */
- OP_BRANUMBER, /* Used for extracting brackets whose number is greater
- than can fit into an opcode. */
+ OP_BRANUMBER, /* 74 Used for extracting brackets whose number is greater
+ than can fit into an opcode. */
- OP_BRA /* This and greater values are used for brackets that
- extract substrings up to a basic limit. After that,
- use is made of OP_BRANUMBER. */
+ OP_BRA /* 75 This and greater values are used for brackets that
+ extract substrings up to a basic limit. After that,
+ use is made of OP_BRANUMBER. */
};
+/* WARNING: There is an implicit assumption in study.c that all opcodes are
+less than 128 in value. This makes handling UTF-8 character sequences easier.
+*/
+
+
+/* This macro defines textual names for all the opcodes. There are used only
+for debugging, in pcre.c when DEBUG is defined, and also in pcretest.c. The
+macro is referenced only in printint.c. */
+
+#define OP_NAME_LIST \
+ "End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d", \
+ "\\S", "\\s", "\\W", "\\w", "Any", "Anybyte", "\\Z", "\\z", \
+ "Opt", "^", "$", "chars", "not", \
+ "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
+ "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
+ "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
+ "*", "*?", "+", "+?", "?", "??", "{", "{", \
+ "class", "nclass", "xclass", "Ref", "Recurse", "Callout", \
+ "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not", \
+ "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cond ref",\
+ "Brazero", "Braminzero", "Branumber", "Bra"
+
+
+/* This macro defines the length of fixed length operations in the compiled
+regex. The lengths are used when searching for specific things, and also in the
+debugging printing of a compiled regex. We use a macro so that it can be
+incorporated both into pcre.c and pcretest.c without being publicly exposed.
+
+As things have been extended, some of these are no longer fixed lenths, but are
+minima instead. For example, the length of a single-character repeat may vary
+in UTF-8 mode. The code that uses this table must know about such things. */
+
+#define OP_LENGTHS \
+ 1, /* End */ \
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* \A, \G, \B, \B, \D, \d, \S, \s, \W, \w */ \
+ 1, 1, 1, 1, 2, 1, 1, /* Any, Anybyte, \Z, \z, Opt, ^, $ */ \
+ 2, /* Chars - the minimum length */ \
+ 2, /* not */ \
+ /* Positive single-char repeats */ \
+ 2, 2, 2, 2, 2, 2, /* *, *?, +, +?, ?, ?? ** These are */ \
+ 4, 4, 4, /* upto, minupto, exact ** minima */ \
+ /* Negative single-char repeats */ \
+ 2, 2, 2, 2, 2, 2, /* NOT *, *?, +, +?, ?, ?? */ \
+ 4, 4, 4, /* NOT upto, minupto, exact */ \
+ /* Positive type repeats */ \
+ 2, 2, 2, 2, 2, 2, /* Type *, *?, +, +?, ?, ?? */ \
+ 4, 4, 4, /* Type upto, minupto, exact */ \
+ /* Character class & ref repeats */ \
+ 1, 1, 1, 1, 1, 1, /* *, *?, +, +?, ?, ?? */ \
+ 5, 5, /* CRRANGE, CRMINRANGE */ \
+ 33, /* CLASS */ \
+ 33, /* NCLASS */ \
+ 0, /* XCLASS - variable length */ \
+ 3, /* REF */ \
+ 1+LINK_SIZE, /* RECURSE */ \
+ 2, /* CALLOUT */ \
+ 1+LINK_SIZE, /* Alt */ \
+ 1+LINK_SIZE, /* Ket */ \
+ 1+LINK_SIZE, /* KetRmax */ \
+ 1+LINK_SIZE, /* KetRmin */ \
+ 1+LINK_SIZE, /* Assert */ \
+ 1+LINK_SIZE, /* Assert not */ \
+ 1+LINK_SIZE, /* Assert behind */ \
+ 1+LINK_SIZE, /* Assert behind not */ \
+ 1+LINK_SIZE, /* Reverse */ \
+ 1+LINK_SIZE, /* Once */ \
+ 1+LINK_SIZE, /* COND */ \
+ 3, /* CREF */ \
+ 1, 1, /* BRAZERO, BRAMINZERO */ \
+ 3, /* BRANUMBER */ \
+ 1+LINK_SIZE /* BRA */ \
+
+
/* The highest extraction number before we have to start using additional
bytes. (Originally PCRE didn't have support for extraction counts highter than
this number.) The value is limited by the number of opcodes left after OP_BRA,
@@ -269,6 +470,10 @@ opcodes. */
#define EXTRACT_BASIC_MAX 150
+/* A magic value for OP_CREF to indicate the "in recursion" condition. */
+
+#define CREF_RECURSE 0xffff
+
/* The texts of compile-time error messages are defined as macros here so that
they can be accessed by the POSIX wrapper and converted into error codes. Yes,
I could have used error codes in the first place, but didn't feel like changing
@@ -286,9 +491,9 @@ just to accommodate the POSIX wrapper. */
#define ERR10 "operand of unlimited repeat could match the empty string"
#define ERR11 "internal error: unexpected repeat"
#define ERR12 "unrecognized character after (?"
-#define ERR13 "unused error"
+#define ERR13 "POSIX named classes are supported only within a class"
#define ERR14 "missing )"
-#define ERR15 "back reference to non-existent subpattern"
+#define ERR15 "reference to non-existent subpattern"
#define ERR16 "erroffset passed as NULL"
#define ERR17 "unknown option bit(s) set"
#define ERR18 "missing ) after comment"
@@ -302,13 +507,21 @@ just to accommodate the POSIX wrapper. */
#define ERR26 "malformed number after (?("
#define ERR27 "conditional group contains more than two branches"
#define ERR28 "assertion expected after (?("
-#define ERR29 "(?p must be followed by )"
+#define ERR29 "(?R or (?digits must be followed by )"
#define ERR30 "unknown POSIX class name"
#define ERR31 "POSIX collating elements are not supported"
#define ERR32 "this version of PCRE is not compiled with PCRE_UTF8 support"
-#define ERR33 "characters with values > 255 are not yet supported in classes"
+#define ERR33 "spare error"
#define ERR34 "character value in \\x{...} sequence is too large"
#define ERR35 "invalid condition (?(0)"
+#define ERR36 "\\C not allowed in lookbehind assertion"
+#define ERR37 "PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X"
+#define ERR38 "number after (?C is > 255"
+#define ERR39 "closing ) for (?C expected"
+#define ERR40 "recursive call could loop indefinitely"
+#define ERR41 "unrecognized character after (?P"
+#define ERR42 "syntax error after (?P"
+#define ERR43 "two named groups have the same name"
/* All character handling must be done as unsigned characters. Otherwise there
are problems with top-bit-set characters and functions such as isspace().
@@ -319,28 +532,29 @@ Unix, where it is defined in sys/types, so use "uschar" instead. */
typedef unsigned char uschar;
-/* The real format of the start of the pcre block; the actual code vector
-runs on as long as necessary after the end. */
+/* The real format of the start of the pcre block; the index of names and the
+code vector run on as long as necessary after the end. */
typedef struct real_pcre {
unsigned long int magic_number;
- size_t size;
- const unsigned char *tables;
+ size_t size; /* Total that was malloced */
+ const unsigned char *tables; /* Pointer to tables */
unsigned long int options;
unsigned short int top_bracket;
unsigned short int top_backref;
- uschar first_char;
- uschar req_char;
- uschar code[1];
+ unsigned short int first_byte;
+ unsigned short int req_byte;
+ unsigned short int name_entry_size; /* Size of any name items; 0 => none */
+ unsigned short int name_count; /* Number of name items */
} real_pcre;
-/* The real format of the extra block returned by pcre_study(). */
+/* The format of the block used to store data from pcre_study(). */
-typedef struct real_pcre_extra {
+typedef struct pcre_study_data {
+ size_t size; /* Total that was malloced */
uschar options;
uschar start_bits[32];
-} real_pcre_extra;
-
+} pcre_study_data;
/* Structure for passing "static" information around between the functions
doing the compiling, so that they are thread-safe. */
@@ -350,13 +564,40 @@ typedef struct compile_data {
const uschar *fcc; /* Points to case-flipping table */
const uschar *cbits; /* Points to character type table */
const uschar *ctypes; /* Points to table of type maps */
+ const uschar *start_code; /* The start of the compiled code */
+ uschar *name_table; /* The name/number table */
+ int names_found; /* Number of entries so far */
+ int name_entry_size; /* Size of each entry */
+ int top_backref; /* Maximum back reference */
+ unsigned int backref_map; /* Bitmap of low back refs */
} compile_data;
+/* Structure for maintaining a chain of pointers to the currently incomplete
+branches, for testing for left recursion. */
+
+typedef struct branch_chain {
+ struct branch_chain *outer;
+ uschar *current;
+} branch_chain;
+
+/* Structure for items in a linked list that represents an explicit recursive
+call within the pattern. */
+
+typedef struct recursion_info {
+ struct recursion_info *prev; /* Previous recursion record (or NULL) */
+ int group_num; /* Number of group that was called */
+ const uschar *after_call; /* "Return value": points after the call in the expr */
+ const uschar *save_start; /* Old value of md->start_match */
+ int *offset_save; /* Pointer to start of saved offsets */
+ int saved_max; /* Number of saved offsets */
+} recursion_info;
+
/* Structure for passing "static" information around between the functions
doing the matching, so that they are thread-safe. */
typedef struct match_data {
- int errorcode; /* As it says */
+ int match_call_count; /* As it says */
+ int match_limit; /* As it says */
int *offset_vector; /* Offset vector */
int offset_end; /* One past the end */
int offset_max; /* The maximum usable for return data */
@@ -368,12 +609,16 @@ typedef struct match_data {
BOOL utf8; /* UTF8 flag */
BOOL endonly; /* Dollar not before final \n */
BOOL notempty; /* Empty string match not wanted */
- const uschar *start_pattern; /* For use when recursing */
+ const uschar *start_code; /* For use when recursing */
const uschar *start_subject; /* Start of the subject string */
const uschar *end_subject; /* End of the subject string */
const uschar *start_match; /* Start of this match attempt */
const uschar *end_match_ptr; /* Subject position at end match */
int end_offset_top; /* Highwater mark at end of match */
+ int capture_last; /* Most recent capture number */
+ int start_offset; /* The start offset value */
+ recursion_info *recursive; /* Linked list of recursion data */
+ void *callout_data; /* To pass back to callouts */
} match_data;
/* Bit definitions for entries in the pcre_ctypes table. */
diff --git a/ltmain.sh b/ltmain.sh
index 5959c47..de848c6 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -48,15 +48,22 @@ EOF
exit 0
fi
+# Modification by PH (18-Feb-2003) to ensure that ${SED} is always set
+# (it is not set on my system).
+
+case "X${SED}" in
+ X) SED=sed ;;
+esac
+
# The name of this program.
-progname=`$echo "$0" | sed 's%^.*/%%'`
+progname=`$echo "$0" | ${SED} 's%^.*/%%'`
modename="$progname"
# Constants.
PROGRAM=ltmain.sh
PACKAGE=libtool
-VERSION=1.4
-TIMESTAMP=" (1.920 2001/04/24 23:26:18)"
+VERSION=1.4.3
+TIMESTAMP=" (1.922.2.110 2002/10/23 01:39:54)"
default_mode=
help="Try \`$progname --help' for more information."
@@ -67,10 +74,19 @@ rm="rm -f"
# Sed substitution that helps us do robust quoting. It backslashifies
# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
+Xsed="${SED}"' -e 1s/^X//'
sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
-SP2NL='tr \040 \012'
-NL2SP='tr \015\012 \040\040'
+# test EBCDIC or ASCII
+case `echo A|od -x` in
+ *[Cc]1*) # EBCDIC based system
+ SP2NL="tr '\100' '\n'"
+ NL2SP="tr '\r\n' '\100\100'"
+ ;;
+ *) # Assume ASCII based system
+ SP2NL="tr '\040' '\012'"
+ NL2SP="tr '\015\012' '\040\040'"
+ ;;
+esac
# NLS nuisances.
# Only set LANG and LC_ALL to C if already set.
@@ -84,6 +100,9 @@ if test "${LANG+set}" = set; then
save_LANG="$LANG"; LANG=C; export LANG
fi
+# Make sure IFS has a sensible default
+: ${IFS=" "}
+
if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
echo "$modename: not configured to build any kind of library" 1>&2
echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
@@ -141,7 +160,7 @@ do
;;
--config)
- sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
+ ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
exit 0
;;
@@ -174,6 +193,8 @@ do
--mode) prevopt="--mode" prev=mode ;;
--mode=*) mode="$optarg" ;;
+ --preserve-dup-deps) duplicate_deps="yes" ;;
+
--quiet | --silent)
show=:
;;
@@ -202,12 +223,17 @@ if test -n "$prevopt"; then
exit 1
fi
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end. This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
if test -z "$show_help"; then
# Infer the operation mode.
if test -z "$mode"; then
case $nonopt in
- *cc | *++ | gcc* | *-gcc*)
+ *cc | *++ | gcc* | *-gcc* | xlc*)
mode=link
for arg
do
@@ -329,7 +355,7 @@ if test -z "$show_help"; then
-Wc,*)
args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
lastarg=
- IFS="${IFS= }"; save_ifs="$IFS"; IFS=','
+ save_ifs="$IFS"; IFS=','
for arg in $args; do
IFS="$save_ifs"
@@ -459,7 +485,7 @@ if test -z "$show_help"; then
pic_mode=default
;;
esac
- if test $pic_mode = no && test "$deplibs_check_method" != pass_all; then
+ if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
# non-PIC code in shared libraries is not supported
pic_mode=default
fi
@@ -615,6 +641,10 @@ compiler."
# Now arrange that obj and lo_libobj become the same file
$show "(cd $xdir && $LN_S $baseobj $libobj)"
if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then
+ # Unlock the critical section if it was locked
+ if test "$need_locks" != no; then
+ $run $rm "$lockfile"
+ fi
exit 0
else
error=$?
@@ -980,7 +1010,7 @@ compiler."
# so, if we see these flags be careful not to treat them like -L
-L[A-Z][A-Z]*:*)
case $with_gcc/$host in
- no/*-*-irix*)
+ no/*-*-irix* | no/*-*-nonstopux*)
compile_command="$compile_command $arg"
finalize_command="$finalize_command $arg"
;;
@@ -1031,6 +1061,17 @@ compiler."
# These systems don't actually have a C library (as such)
test "X$arg" = "X-lc" && continue
;;
+ *-*-openbsd* | *-*-freebsd*)
+ # Do not include libc due to us having libc/libc_r.
+ test "X$arg" = "X-lc" && continue
+ ;;
+ esac
+ elif test "X$arg" = "X-lc_r"; then
+ case $host in
+ *-*-openbsd* | *-*-freebsd*)
+ # Do not include libc_r directly, use -pthread flag.
+ continue
+ ;;
esac
fi
deplibs="$deplibs $arg"
@@ -1122,7 +1163,7 @@ compiler."
-Wc,*)
args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
arg=
- IFS="${IFS= }"; save_ifs="$IFS"; IFS=','
+ save_ifs="$IFS"; IFS=','
for flag in $args; do
IFS="$save_ifs"
case $flag in
@@ -1140,7 +1181,7 @@ compiler."
-Wl,*)
args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
arg=
- IFS="${IFS= }"; save_ifs="$IFS"; IFS=','
+ save_ifs="$IFS"; IFS=','
for flag in $args; do
IFS="$save_ifs"
case $flag in
@@ -1307,9 +1348,11 @@ compiler."
# Find all interdependent deplibs by searching for libraries
# that are linked more than once (e.g. -la -lb -la)
for deplib in $deplibs; do
- case "$libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
libs="$libs $deplib"
done
deplibs=
@@ -1438,10 +1481,12 @@ compiler."
lib)
if test "$deplibs_check_method" != pass_all; then
echo
- echo "*** Warning: This library needs some functionality provided by $deplib."
+ echo "*** Warning: Trying to link with static lib archive $deplib."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
- echo "*** shared version of the library, which you do not appear to have."
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because the file extensions .$libext of this argument makes me believe"
+ echo "*** that it is just a static archive that I should not used here."
else
echo
echo "*** Warning: Linking the shared library $output against the"
@@ -1485,7 +1530,7 @@ compiler."
fi
# Check to see that this really is a libtool archive.
- if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ if (${SED} -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
else
$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
exit 1
@@ -1532,9 +1577,11 @@ compiler."
tmp_libs=
for deplib in $dependency_libs; do
deplibs="$deplib $deplibs"
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
tmp_libs="$tmp_libs $deplib"
done
elif test $linkmode != prog && test $linkmode != lib; then
@@ -1657,9 +1704,11 @@ compiler."
# or/and link against static libraries
newdependency_libs="$deplib $newdependency_libs"
fi
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
tmp_libs="$tmp_libs $deplib"
done # for deplib
continue
@@ -1743,14 +1792,14 @@ compiler."
# Make a new name for the extract_expsyms_cmds to use
soroot="$soname"
- soname=`echo $soroot | sed -e 's/^.*\///'`
- newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a"
+ soname=`echo $soroot | ${SED} -e 's/^.*\///'`
+ newlib="libimp-`echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
# If the library has no export list, then create one now
if test -f "$output_objdir/$soname-def"; then :
else
$show "extracting exported symbol list from \`$soname'"
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
eval cmds=\"$extract_expsyms_cmds\"
for cmd in $cmds; do
IFS="$save_ifs"
@@ -1763,7 +1812,7 @@ compiler."
# Create $newlib
if test -f "$output_objdir/$newlib"; then :; else
$show "generating import library for \`$soname'"
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
eval cmds=\"$old_archive_from_expsyms_cmds\"
for cmd in $cmds; do
IFS="$save_ifs"
@@ -1903,25 +1952,26 @@ compiler."
# Just print a warning and add the library to dependency_libs so
# that the program can be linked against the static library.
echo
- echo "*** Warning: This library needs some functionality provided by $lib."
+ echo "*** Warning: This system can not link to static lib archive $lib."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
echo "*** shared version of the library, which you do not appear to have."
if test "$module" = yes; then
- echo "*** Therefore, libtool will create a static module, that should work "
- echo "*** as long as the dlopening application is linked with the -dlopen flag."
+ echo "*** But as you try to build a module library, libtool will still create "
+ echo "*** a static module, that should work as long as the dlopening application"
+ echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
if test -z "$global_symbol_pipe"; then
- echo
- echo "*** However, this would only work if libtool was able to extract symbol"
- echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
- echo "*** not find such a program. So, this module is probably useless."
- echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ echo
+ echo "*** However, this would only work if libtool was able to extract symbol"
+ echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ echo "*** not find such a program. So, this module is probably useless."
+ echo "*** \`nm' from GNU binutils and a full rebuild may help."
fi
if test "$build_old_libs" = no; then
- build_libtool_libs=module
- build_old_libs=yes
+ build_libtool_libs=module
+ build_old_libs=yes
else
- build_libtool_libs=no
+ build_libtool_libs=no
fi
fi
else
@@ -1958,9 +2008,11 @@ compiler."
tmp_libs=
for deplib in $dependency_libs; do
newdependency_libs="$deplib $newdependency_libs"
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
tmp_libs="$tmp_libs $deplib"
done
@@ -1986,7 +2038,7 @@ compiler."
if grep "^installed=no" $deplib > /dev/null; then
path="-L$absdir/$objdir"
else
- eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
if test -z "$libdir"; then
$echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
exit 1
@@ -2175,7 +2227,7 @@ compiler."
else
# Parse the version information argument.
- IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
+ save_ifs="$IFS"; IFS=':'
set dummy $vinfo 0 0 0
IFS="$save_ifs"
@@ -2250,16 +2302,21 @@ compiler."
versuffix=".$current";
;;
- irix)
+ irix | nonstopux)
major=`expr $current - $age + 1`
- verstring="sgi$major.$revision"
+
+ case $version_type in
+ nonstopux) verstring_prefix=nonstopux ;;
+ *) verstring_prefix=sgi ;;
+ esac
+ verstring="$verstring_prefix$major.$revision"
# Add in all the interfaces that we are compatible with.
loop=$revision
while test $loop != 0; do
iface=`expr $revision - $loop`
loop=`expr $loop - 1`
- verstring="sgi$major.$iface:$verstring"
+ verstring="$verstring_prefix$major.$iface:$verstring"
done
# Before this point, $major must not contain `.'.
@@ -2273,7 +2330,7 @@ compiler."
;;
osf)
- major=`expr $current - $age`
+ major=.`expr $current - $age`
versuffix=".$current.$age.$revision"
verstring="$current.$age.$revision"
@@ -2312,6 +2369,16 @@ compiler."
if test -z "$vinfo" && test -n "$release"; then
major=
verstring="0.0"
+ case $version_type in
+ darwin)
+ # we can't check for "0.0" in archive_cmds due to quoting
+ # problems, so we reset it completely
+ verstring=""
+ ;;
+ *)
+ verstring="0.0"
+ ;;
+ esac
if test "$need_version" = no; then
versuffix=
else
@@ -2355,9 +2422,9 @@ compiler."
# Eliminate all temporary directories.
for path in $notinst_path; do
- lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'`
- deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'`
- dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'`
+ lib_search_path=`echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
+ deplibs=`echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
+ dependency_libs=`echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
done
if test -n "$xrpath"; then
@@ -2408,6 +2475,9 @@ compiler."
*-*-netbsd*)
# Don't link with libc until the a.out ld.so is fixed.
;;
+ *-*-openbsd* | *-*-freebsd*)
+ # Do not include libc due to us having libc/libc_r.
+ ;;
*)
# Add libc to deplibs on all other systems if necessary.
if test $build_libtool_need_lc = "yes"; then
@@ -2435,7 +2505,7 @@ compiler."
pass_all)
# Don't check for shared/static. Everything works.
# This might be a little naive. We might want to check
- # whether the library exists or not. But this is on
+ # whether the library exists or not. But this is on
# osf3 & osf4 and I'm not really sure... Just
# implementing what was already the behaviour.
newdeplibs=$deplibs
@@ -2466,18 +2536,20 @@ EOF
else
droppeddeps=yes
echo
- echo "*** Warning: This library needs some functionality provided by $i."
+ echo "*** Warning: dynamic linker does not accept needed library $i."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
- echo "*** shared version of the library, which you do not appear to have."
+ echo "*** shared version of the library, which I believe you do not have"
+ echo "*** because a test_compile did reveal that the linker did not use it for"
+ echo "*** its dynamic dependency list that programs get resolved with at runtime."
fi
else
newdeplibs="$newdeplibs $i"
fi
done
else
- # Error occured in the first compile. Let's try to salvage the situation:
- # Compile a seperate program for each library.
+ # Error occured in the first compile. Let's try to salvage
+ # the situation: Compile a separate program for each library.
for i in $deplibs; do
name="`expr $i : '-l\(.*\)'`"
# If $name is empty we are operating on a -L argument.
@@ -2496,10 +2568,12 @@ EOF
else
droppeddeps=yes
echo
- echo "*** Warning: This library needs some functionality provided by $i."
+ echo "*** Warning: dynamic linker does not accept needed library $i."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
- echo "*** shared version of the library, which you do not appear to have."
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because a test_compile did reveal that the linker did not use this one"
+ echo "*** as a dynamic dependency that programs can get resolved with at runtime."
fi
else
droppeddeps=yes
@@ -2538,14 +2612,14 @@ EOF
# but so what?
potlib="$potent_lib"
while test -h "$potlib" 2>/dev/null; do
- potliblink=`ls -ld $potlib | sed 's/.* -> //'`
+ potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
case $potliblink in
[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
esac
done
if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
- | sed 10q \
+ | ${SED} 10q \
| egrep "$file_magic_regex" > /dev/null; then
newdeplibs="$newdeplibs $a_deplib"
a_deplib=""
@@ -2556,10 +2630,17 @@ EOF
if test -n "$a_deplib" ; then
droppeddeps=yes
echo
- echo "*** Warning: This library needs some functionality provided by $a_deplib."
+ echo "*** Warning: linker path does not have real file for library $a_deplib."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
- echo "*** shared version of the library, which you do not appear to have."
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ echo "*** with $libname but no candidates were found. (...for file magic test)"
+ else
+ echo "*** with $libname and none of the candidates passed a file format test"
+ echo "*** using a file magic. Last file checked: $potlib"
+ fi
fi
else
# Add a -L argument.
@@ -2578,8 +2659,9 @@ EOF
for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
for potent_lib in $potential_libs; do
+ potlib="$potent_lib" # see symlink-check below in file_magic test
if eval echo \"$potent_lib\" 2>/dev/null \
- | sed 10q \
+ | ${SED} 10q \
| egrep "$match_pattern_regex" > /dev/null; then
newdeplibs="$newdeplibs $a_deplib"
a_deplib=""
@@ -2590,10 +2672,17 @@ EOF
if test -n "$a_deplib" ; then
droppeddeps=yes
echo
- echo "*** Warning: This library needs some functionality provided by $a_deplib."
+ echo "*** Warning: linker path does not have real file for library $a_deplib."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
- echo "*** shared version of the library, which you do not appear to have."
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ echo "*** with $libname but no candidates were found. (...for regex pattern test)"
+ else
+ echo "*** with $libname and none of the candidates passed a file format test"
+ echo "*** using a regex pattern. Last file checked: $potlib"
+ fi
fi
else
# Add a -L argument.
@@ -2604,7 +2693,7 @@ EOF
none | unknown | *)
newdeplibs=""
if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
- -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' |
+ -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' |
grep . >/dev/null; then
echo
if test "X$deplibs_check_method" = "Xnone"; then
@@ -2634,7 +2723,7 @@ EOF
if test "$module" = yes; then
echo
echo "*** Warning: libtool could not satisfy all declared inter-library"
- echo "*** dependencies of module $libname. Therefore, libtool will create"
+ echo "*** dependencies of module $libname. Therefore, libtool will create"
echo "*** a static module, that should work as long as the dlopening"
echo "*** application is linked with the -dlopen flag."
if test -z "$global_symbol_pipe"; then
@@ -2784,7 +2873,7 @@ EOF
export_symbols="$output_objdir/$libname.exp"
$run $rm $export_symbols
eval cmds=\"$export_symbols_cmds\"
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
@@ -2858,9 +2947,20 @@ EOF
if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
eval cmds=\"$archive_expsym_cmds\"
else
+ save_deplibs="$deplibs"
+ for conv in $convenience; do
+ tmp_deplibs=
+ for test_deplib in $deplibs; do
+ if test "$test_deplib" != "$conv"; then
+ tmp_deplibs="$tmp_deplibs $test_deplib"
+ fi
+ done
+ deplibs="$tmp_deplibs"
+ done
eval cmds=\"$archive_cmds\"
+ deplibs="$save_deplibs"
fi
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
@@ -2988,7 +3088,7 @@ EOF
output="$obj"
eval cmds=\"$reload_cmds\"
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
@@ -3024,7 +3124,7 @@ EOF
reload_objs="$libobjs $reload_conv_objs"
output="$libobj"
eval cmds=\"$reload_cmds\"
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
@@ -3057,7 +3157,7 @@ EOF
prog)
case $host in
- *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;;
+ *cygwin*) output=`echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
esac
if test -n "$vinfo"; then
$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
@@ -3079,6 +3179,13 @@ EOF
# On Rhapsody replace the C library is the System framework
compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+ case $host in
+ *darwin*)
+ # Don't allow lazy linking, it breaks C++ global constructors
+ compile_command="$compile_command ${wl}-bind_at_load"
+ finalize_command="$finalize_command ${wl}-bind_at_load"
+ ;;
+ esac
;;
esac
@@ -3245,9 +3352,9 @@ extern \"C\" {
if test -z "$export_symbols"; then
export_symbols="$output_objdir/$output.exp"
$run $rm $export_symbols
- $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+ $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
else
- $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
+ $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
$run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
$run eval 'mv "$nlist"T "$nlist"'
fi
@@ -3255,7 +3362,7 @@ extern \"C\" {
for arg in $dlprefiles; do
$show "extracting global C symbols from \`$arg'"
- name=`echo "$arg" | sed -e 's%^.*/%%'`
+ name=`echo "$arg" | ${SED} -e 's%^.*/%%'`
$run eval 'echo ": $name " >> "$nlist"'
$run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
done
@@ -3270,7 +3377,13 @@ extern \"C\" {
fi
# Try sorting and uniquifying the output.
- if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then
+ if grep -v "^: " < "$nlist" |
+ if sort -k 3 </dev/null >/dev/null 2>&1; then
+ sort -k 3
+ else
+ sort +2
+ fi |
+ uniq > "$nlist"S; then
:
else
grep -v "^: " < "$nlist" > "$nlist"S
@@ -3287,27 +3400,25 @@ extern \"C\" {
#undef lt_preloaded_symbols
#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
+# define lt_ptr void *
#else
-# define lt_ptr_t char *
+# define lt_ptr char *
# define const
#endif
/* The mapping between symbol names and symbols. */
const struct {
const char *name;
- lt_ptr_t address;
+ lt_ptr address;
}
lt_preloaded_symbols[] =
{\
"
- sed -n -e 's/^: \([^ ]*\) $/ {\"\1\", (lt_ptr_t) 0},/p' \
- -e 's/^. \([^ ]*\) \([^ ]*\)$/ {"\2", (lt_ptr_t) \&\2},/p' \
- < "$nlist" >> "$output_objdir/$dlsyms"
+ eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
$echo >> "$output_objdir/$dlsyms" "\
- {0, (lt_ptr_t) 0}
+ {0, (lt_ptr) 0}
};
/* This works around a problem in FreeBSD linker */
@@ -3494,7 +3605,7 @@ static const void *lt_preloaded_setup() {
relink_command="$var=\"$var_value\"; export $var; $relink_command"
fi
done
- relink_command="cd `pwd`; $relink_command"
+ relink_command="(cd `pwd`; $relink_command)"
relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
fi
@@ -3514,7 +3625,7 @@ static const void *lt_preloaded_setup() {
# win32 will think the script is a binary if it has
# a .exe suffix, so we strip it off here.
case $output in
- *.exe) output=`echo $output|sed 's,.exe$,,'` ;;
+ *.exe) output=`echo $output|${SED} 's,.exe$,,'` ;;
esac
# test for cygwin because mv fails w/o .exe extensions
case $host in
@@ -3538,7 +3649,7 @@ static const void *lt_preloaded_setup() {
# Sed substitution that helps us do robust quoting. It backslashifies
# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
+Xsed="${SED}"' -e 1s/^X//'
sed_quote_subst='$sed_quote_subst'
# The HP-UX ksh and POSIX shell print the target directory to stdout
@@ -3576,7 +3687,7 @@ else
test \"x\$thisdir\" = \"x\$file\" && thisdir=.
# Follow symbolic links until we get to the real thisdir.
- file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\`
+ file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
while test -n \"\$file\"; do
destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
@@ -3589,7 +3700,7 @@ else
fi
file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
- file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\`
+ file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
done
# Try to get the absolute directory name.
@@ -3603,7 +3714,7 @@ else
progdir=\"\$thisdir/$objdir\"
if test ! -f \"\$progdir/\$program\" || \\
- { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
+ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
test \"X\$file\" != \"X\$progdir/\$program\"; }; then
file=\"\$\$-\$program\"
@@ -3618,8 +3729,9 @@ else
# relink executable if necessary
if test -n \"\$relink_command\"; then
- if (eval \$relink_command); then :
+ if relink_command_output=\`eval \$relink_command 2>&1\`; then :
else
+ $echo \"\$relink_command_output\" >&2
$rm \"\$progdir/\$file\"
exit 1
fi
@@ -3648,7 +3760,7 @@ else
$shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
# Some systems cannot cope with colon-terminated $shlibpath_var
- # The second colon is a workaround for a bug in BeOS R4 sed
+ # The second colon is a workaround for a bug in BeOS R4 ${SED}
$shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
export $shlibpath_var
@@ -3790,7 +3902,7 @@ fi\
eval cmds=\"$old_archive_cmds\"
fi
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
@@ -3823,7 +3935,7 @@ fi\
fi
done
# Quote the link command for shipping.
- relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args"
+ relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args)"
relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
# Only create the output if not a dry run.
@@ -3840,7 +3952,7 @@ fi\
case $deplib in
*.la)
name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
if test -z "$libdir"; then
$echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
exit 1
@@ -3854,7 +3966,7 @@ fi\
newdlfiles=
for lib in $dlfiles; do
name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
if test -z "$libdir"; then
$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
exit 1
@@ -3865,7 +3977,7 @@ fi\
newdlprefiles=
for lib in $dlprefiles; do
name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
if test -z "$libdir"; then
$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
exit 1
@@ -4089,7 +4201,7 @@ relink_command=\"$relink_command\""
*.la)
# Check to see that this really is a libtool archive.
- if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
else
$echo "$modename: \`$file' is not a valid libtool archive" 1>&2
$echo "$help" 1>&2
@@ -4165,7 +4277,7 @@ relink_command=\"$relink_command\""
# Do each command in the postinstall commands.
lib="$destdir/$realname"
eval cmds=\"$postinstall_cmds\"
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
@@ -4238,19 +4350,27 @@ relink_command=\"$relink_command\""
fi
# Do a test to see if this is really a libtool program.
- if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ case $host in
+ *cygwin*|*mingw*)
+ wrapper=`echo $file | ${SED} -e 's,.exe$,,'`
+ ;;
+ *)
+ wrapper=$file
+ ;;
+ esac
+ if (${SED} -e '4q' $wrapper | egrep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
notinst_deplibs=
relink_command=
# If there is no directory component, then add one.
case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
+ */* | *\\*) . $wrapper ;;
+ *) . ./$wrapper ;;
esac
# Check the variables that should have been set.
if test -z "$notinst_deplibs"; then
- $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2
+ $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
exit 1
fi
@@ -4275,8 +4395,8 @@ relink_command=\"$relink_command\""
relink_command=
# If there is no directory component, then add one.
case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
+ */* | *\\*) . $wrapper ;;
+ *) . ./$wrapper ;;
esac
outputname=
@@ -4324,7 +4444,7 @@ relink_command=\"$relink_command\""
destfile=$destfile.exe
;;
*:*.exe)
- destfile=`echo $destfile | sed -e 's,.exe$,,'`
+ destfile=`echo $destfile | ${SED} -e 's,.exe$,,'`
;;
esac
;;
@@ -4352,7 +4472,7 @@ relink_command=\"$relink_command\""
# Do each command in the postinstall commands.
eval cmds=\"$old_postinstall_cmds\"
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
@@ -4368,11 +4488,10 @@ relink_command=\"$relink_command\""
if test -n "$current_libdirs"; then
# Maybe just do a dry run.
test -n "$run" && current_libdirs=" -n$current_libdirs"
- exec $SHELL $0 --finish$current_libdirs
- exit 1
+ exec_cmd='$SHELL $0 --finish$current_libdirs'
+ else
+ exit 0
fi
-
- exit 0
;;
# libtool finish mode
@@ -4391,7 +4510,7 @@ relink_command=\"$relink_command\""
if test -n "$finish_cmds"; then
# Do each command in the finish commands.
eval cmds=\"$finish_cmds\"
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
@@ -4473,7 +4592,7 @@ relink_command=\"$relink_command\""
case $file in
*.la)
# Check to see that this really is a libtool archive.
- if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
else
$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
$echo "$help" 1>&2
@@ -4544,7 +4663,7 @@ relink_command=\"$relink_command\""
-*) ;;
*)
# Do a test to see if this is really a libtool program.
- if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ if (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
# If there is no directory component, then add one.
case $file in
*/* | *\\*) . $file ;;
@@ -4575,11 +4694,8 @@ relink_command=\"$relink_command\""
LANG="$save_LANG"; export LANG
fi
- # Now actually exec the command.
- eval "exec \$cmd$args"
-
- $echo "$modename: cannot exec \$cmd$args"
- exit 1
+ # Now prepare to actually exec the command.
+ exec_cmd="\$cmd$args"
else
# Display what would be done.
if test -n "$shlibpath_var"; then
@@ -4641,14 +4757,14 @@ relink_command=\"$relink_command\""
# Don't error if the file doesn't exist and rm -f was used.
if (test -L "$file") >/dev/null 2>&1 \
- || (test -h "$file") >/dev/null 2>&1 \
+ || (test -h "$file") >/dev/null 2>&1 \
|| test -f "$file"; then
- :
+ :
elif test -d "$file"; then
- exit_status=1
+ exit_status=1
continue
elif test "$rmforce" = yes; then
- continue
+ continue
fi
rmfiles="$file"
@@ -4656,7 +4772,7 @@ relink_command=\"$relink_command\""
case $name in
*.la)
# Possibly a libtool archive, so verify it.
- if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
. $dir/$name
# Delete the libtool libraries and symlinks.
@@ -4670,7 +4786,7 @@ relink_command=\"$relink_command\""
if test -n "$library_names"; then
# Do each command in the postuninstall commands.
eval cmds=\"$postuninstall_cmds\"
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
@@ -4685,7 +4801,7 @@ relink_command=\"$relink_command\""
if test -n "$old_library"; then
# Do each command in the old_postuninstall commands.
eval cmds=\"$old_postuninstall_cmds\"
- IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
@@ -4711,7 +4827,7 @@ relink_command=\"$relink_command\""
*)
# Do a test to see if this is a libtool program.
if test $mode = clean &&
- (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
relink_command=
. $dir/$file
@@ -4744,11 +4860,18 @@ relink_command=\"$relink_command\""
;;
esac
- $echo "$modename: invalid operation mode \`$mode'" 1>&2
- $echo "$generic_help" 1>&2
- exit 1
+ if test -z "$exec_cmd"; then
+ $echo "$modename: invalid operation mode \`$mode'" 1>&2
+ $echo "$generic_help" 1>&2
+ exit 1
+ fi
fi # test -z "$show_help"
+if test -n "$exec_cmd"; then
+ eval exec $exec_cmd
+ exit 1
+fi
+
# We need to display help for each of the modes.
case $mode in
"") $echo \
diff --git a/maketables.c b/maketables.c
index 01078f1..257fe89 100644
--- a/maketables.c
+++ b/maketables.c
@@ -8,7 +8,7 @@ and semantics are as close as possible to those of the Perl 5 language.
Written by: Philip Hazel <ph10@cam.ac.uk>
- Copyright (c) 1997-2001 University of Cambridge
+ Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
@@ -82,7 +82,9 @@ for (i = 0; i < 256; i++) *p++ = tolower(i);
for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);
/* Then the character class tables. Don't try to be clever and save effort
-on exclusive ones - in some locales things may be different. */
+on exclusive ones - in some locales things may be different. Note that the
+table for "space" includes everything "isspace" gives, including VT in the
+default locale. This makes it work for the POSIX class [:space:]. */
memset(p, 0, cbit_length);
for (i = 0; i < 256; i++)
@@ -112,12 +114,14 @@ for (i = 0; i < 256; i++)
}
p += cbit_length;
-/* Finally, the character type table */
+/* Finally, the character type table. In this, we exclude VT from the white
+space chars, because Perl doesn't recognize it as such for \s and for comments
+within regexes. */
for (i = 0; i < 256; i++)
{
int x = 0;
- if (isspace(i)) x += ctype_space;
+ if (i != 0x0b && isspace(i)) x += ctype_space;
if (isalpha(i)) x += ctype_letter;
if (isdigit(i)) x += ctype_digit;
if (isxdigit(i)) x += ctype_xdigit;
diff --git a/makevp.bat b/makevp.bat
new file mode 100644
index 0000000..10bd248
--- /dev/null
+++ b/makevp.bat
@@ -0,0 +1,25 @@
+@echo off
+
+REM This file was contributed by Alexander Tokarev for building PCRE for use
+REM with Virtual Pascal. It has not been tested with the latest PCRE release.
+
+REM CHANGE THIS FOR YOUR BORLAND C++ COMPILER PATH
+
+SET BORLAND=c:\usr\apps\bcc55
+
+sh configure
+
+bcc32 -DDFTABLES -DSTATIC -DVPCOMPAT -I%BORLAND%\include -L%BORLAND%\lib dftables.c
+
+dftables > chartables.c
+
+bcc32 -c -RT- -y- -v- -u- -P- -O2 -5 -DSTATIC -DVPCOMPAT -UDFTABLES -I%BORLAND%\include get.c maketables.c pcre.c study.c
+
+tlib %BORLAND%\lib\cw32.lib *calloc *del *strncmp *memcpy *memmove *memset
+tlib pcre.lib +get.obj +maketables.obj +pcre.obj +study.obj +calloc.obj +del.obj +strncmp.obj +memcpy.obj +memmove.obj +memset.obj
+
+del *.obj *.exe *.tds *.bak >nul 2>nul
+
+echo ---
+echo Now the library should be complete. Please check all messages above.
+echo Don't care for warnings, it's OK.
diff --git a/pcre.c b/pcre.c
index ad3ddc7..0018613 100644
--- a/pcre.c
+++ b/pcre.c
@@ -9,7 +9,7 @@ the file Tech.Notes for some information on the internals.
Written by: Philip Hazel <ph10@cam.ac.uk>
- Copyright (c) 1997-2001 University of Cambridge
+ Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
@@ -32,7 +32,6 @@ restrictions:
-----------------------------------------------------------------------------
*/
-
/* Define DEBUG to get debugging output on stdout. */
/* #define DEBUG */
@@ -69,39 +68,32 @@ compile time. */
#define BRASTACK_SIZE 200
+
+/* Maximum number of ints of offset to save on the stack for recursive calls.
+If the offset vector is bigger, malloc is used. This should be a multiple of 3,
+because the offset vector is always a multiple of 3 long. */
+
+#define REC_STACK_SAVE_MAX 30
+
+
/* The number of bytes in a literal character string above which we can't add
-any more is different when UTF-8 characters may be encountered. */
+any more is set at 250 in order to allow for UTF-8 characters. (In theory it
+could be 255 when UTF-8 support is excluded, but that means that some of the
+test output would be different, which just complicates things.) */
-#ifdef SUPPORT_UTF8
#define MAXLIT 250
-#else
-#define MAXLIT 255
-#endif
+/* Table of sizes for the fixed-length opcodes. It's defined in a macro so that
+the definition is next to the definition of the opcodes in internal.h. */
+
+static uschar OP_lengths[] = { OP_LENGTHS };
+
/* Min and max values for the common repeats; for the maxima, 0 => infinity */
static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };
static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };
-/* Text forms of OP_ values and things, for debugging (not all used) */
-
-#ifdef DEBUG
-static const char *OP_names[] = {
- "End", "\\A", "\\B", "\\b", "\\D", "\\d",
- "\\S", "\\s", "\\W", "\\w", "\\Z", "\\z",
- "Opt", "^", "$", "Any", "chars", "not",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{",
- "class", "Ref", "Recurse",
- "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",
- "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cref",
- "Brazero", "Braminzero", "Branumber", "Bra"
-};
-#endif
-
/* Table for handling escaped characters in the range '0'-'z'. Positive returns
are simple data values; negative values are for special things like \d and so
on. Zero means further processing is needed (for things like \x), or the escape
@@ -110,13 +102,13 @@ is invalid. */
static const short int escapes[] = {
0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 7 */
0, 0, ':', ';', '<', '=', '>', '?', /* 8 - ? */
- '@', -ESC_A, -ESC_B, 0, -ESC_D, 0, 0, 0, /* @ - G */
+ '@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E, 0, -ESC_G, /* @ - G */
0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
- 0, 0, 0, -ESC_S, 0, 0, 0, -ESC_W, /* P - W */
+ 0, -ESC_Q, 0, -ESC_S, 0, 0, 0, -ESC_W, /* P - W */
0, 0, -ESC_Z, '[', '\\', ']', '^', '_', /* X - _ */
- '`', 7, -ESC_b, 0, -ESC_d, ESC_E, ESC_F, 0, /* ` - g */
- 0, 0, 0, 0, 0, 0, ESC_N, 0, /* h - o */
- 0, 0, ESC_R, -ESC_s, ESC_T, 0, 0, -ESC_w, /* p - w */
+ '`', 7, -ESC_b, 0, -ESC_d, ESC_e, ESC_f, 0, /* ` - g */
+ 0, 0, 0, 0, 0, 0, ESC_n, 0, /* h - o */
+ 0, 0, ESC_r, -ESC_s, ESC_t, 0, 0, -ESC_w, /* p - w */
0, 0, -ESC_z /* x - z */
};
@@ -126,14 +118,15 @@ as this is assumed for handling case independence. */
static const char *posix_names[] = {
"alpha", "lower", "upper",
- "alnum", "ascii", "cntrl", "digit", "graph",
+ "alnum", "ascii", "blank", "cntrl", "digit", "graph",
"print", "punct", "space", "word", "xdigit" };
static const uschar posix_name_lengths[] = {
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 };
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 };
/* Table of class bit maps for each POSIX class; up to three may be combined
-to form the class. */
+to form the class. The table for [:blank:] is dynamically modified to remove
+the vertical space characters. */
static const int posix_class_maps[] = {
cbit_lower, cbit_upper, -1, /* alpha */
@@ -141,13 +134,14 @@ static const int posix_class_maps[] = {
cbit_upper, -1, -1, /* upper */
cbit_digit, cbit_lower, cbit_upper, /* alnum */
cbit_print, cbit_cntrl, -1, /* ascii */
+ cbit_space, -1, -1, /* blank - a GNU extension */
cbit_cntrl, -1, -1, /* cntrl */
cbit_digit, -1, -1, /* digit */
cbit_graph, -1, -1, /* graph */
cbit_print, -1, -1, /* print */
cbit_punct, -1, -1, /* punct */
cbit_space, -1, -1, /* space */
- cbit_word, -1, -1, /* word */
+ cbit_word, -1, -1, /* word - a Perl extension */
cbit_xdigit,-1, -1 /* xdigit */
};
@@ -156,7 +150,7 @@ static const int posix_class_maps[] = {
static BOOL
compile_regex(int, int, int *, uschar **, const uschar **, const char **,
- BOOL, int, int *, int *, compile_data *);
+ BOOL, int, int *, int *, branch_chain *, compile_data *);
/* Structure for building a chain of data that actually lives on the
stack, for holding the values of the subject pointer at the start of each
@@ -173,6 +167,12 @@ typedef struct eptrblock {
#define match_condassert 0x01 /* Called to check a condition assertion */
#define match_isgroup 0x02 /* Set if start of bracketed group */
+/* Non-error returns from the match() function. Error returns are externally
+defined PCRE_ERROR_xxx codes, which are all negative. */
+
+#define MATCH_MATCH 1
+#define MATCH_NOMATCH 0
+
/*************************************************
@@ -181,12 +181,15 @@ typedef struct eptrblock {
/* PCRE is thread-clean and doesn't use any global variables in the normal
sense. However, it calls memory allocation and free functions via the two
-indirections below, which are can be changed by the caller, but are shared
-between all threads. */
+indirections below, and it can optionally do callouts. These values can be
+changed by the caller, but are shared between all threads. However, when
+compiling for Virtual Pascal, things are done differently (see pcre.in). */
+#ifndef VPCOMPAT
void *(*pcre_malloc)(size_t) = malloc;
void (*pcre_free)(void *) = free;
-
+int (*pcre_callout)(pcre_callout_block *) = NULL;
+#endif
/*************************************************
@@ -198,16 +201,53 @@ byte. The macros for character handling generate simple sequences when used in
byte-mode, and more complicated ones for UTF-8 characters. */
#ifndef SUPPORT_UTF8
+#define GETCHAR(c, eptr) c = *eptr;
#define GETCHARINC(c, eptr) c = *eptr++;
+#define GETCHARINCTEST(c, eptr) c = *eptr++;
#define GETCHARLEN(c, eptr, len) c = *eptr;
#define BACKCHAR(eptr)
#else /* SUPPORT_UTF8 */
-/* Get the next UTF-8 character, advancing the pointer */
+/* Get the next UTF-8 character, not advancing the pointer. This is called when
+we know we are in UTF-8 mode. */
+
+#define GETCHAR(c, eptr) \
+ c = *eptr; \
+ if ((c & 0xc0) == 0xc0) \
+ { \
+ int i; \
+ int a = utf8_table4[c & 0x3f]; /* Number of additional bytes */ \
+ int s = 6*a; \
+ c = (c & utf8_table3[a]) << s; \
+ for (i = 1; i <= a; i++) \
+ { \
+ s -= 6; \
+ c |= (eptr[i] & 0x3f) << s; \
+ } \
+ }
+
+/* Get the next UTF-8 character, advancing the pointer. This is called when we
+know we are in UTF-8 mode. */
#define GETCHARINC(c, eptr) \
c = *eptr++; \
+ if ((c & 0xc0) == 0xc0) \
+ { \
+ int a = utf8_table4[c & 0x3f]; /* Number of additional bytes */ \
+ int s = 6*a; \
+ c = (c & utf8_table3[a]) << s; \
+ while (a-- > 0) \
+ { \
+ s -= 6; \
+ c |= (*eptr++ & 0x3f) << s; \
+ } \
+ }
+
+/* Get the next character, testing for UTF-8 mode, and advancing the pointer */
+
+#define GETCHARINCTEST(c, eptr) \
+ c = *eptr++; \
if (md->utf8 && (c & 0xc0) == 0xc0) \
{ \
int a = utf8_table4[c & 0x3f]; /* Number of additional bytes */ \
@@ -220,12 +260,12 @@ byte-mode, and more complicated ones for UTF-8 characters. */
} \
}
-/* Get the next UTF-8 character, not advancing the pointer, setting length */
+/* Get the next UTF-8 character, not advancing the pointer, incrementing length
+if there are extra bytes. This is called when we know we are in UTF-8 mode. */
#define GETCHARLEN(c, eptr, len) \
c = *eptr; \
- len = 1; \
- if (md->utf8 && (c & 0xc0) == 0xc0) \
+ if ((c & 0xc0) == 0xc0) \
{ \
int i; \
int a = utf8_table4[c & 0x3f]; /* Number of additional bytes */ \
@@ -240,7 +280,7 @@ byte-mode, and more complicated ones for UTF-8 characters. */
}
/* If the pointer is not at the start of a character, move it back until
-it is. */
+it is. Called only in UTF-8 mode. */
#define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--;
@@ -323,6 +363,19 @@ return i + 1;
/*************************************************
+* Print compiled regex *
+*************************************************/
+
+/* The code for doing this is held in a separate file that is also included in
+pcretest.c. It defines a function called print_internals(). */
+
+#ifdef DEBUG
+#include "printint.c"
+#endif
+
+
+
+/*************************************************
* Return version string *
*************************************************/
@@ -352,7 +405,7 @@ Therefore, I haven't changed the API for pcre_info().
Arguments:
external_re points to compiled code
optptr where to pass back the options
- first_char where to pass back the first character,
+ first_byte where to pass back the first character,
or -1 if multiline and all branches start ^,
or -2 otherwise
@@ -361,14 +414,14 @@ Returns: number of capturing subpatterns
*/
int
-pcre_info(const pcre *external_re, int *optptr, int *first_char)
+pcre_info(const pcre *external_re, int *optptr, int *first_byte)
{
const real_pcre *re = (const real_pcre *)external_re;
if (re == NULL) return PCRE_ERROR_NULL;
if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
if (optptr != NULL) *optptr = (int)(re->options & PUBLIC_OPTIONS);
-if (first_char != NULL)
- *first_char = ((re->options & PCRE_FIRSTSET) != 0)? re->first_char :
+if (first_byte != NULL)
+ *first_byte = ((re->options & PCRE_FIRSTSET) != 0)? re->first_byte :
((re->options & PCRE_STARTLINE) != 0)? -1 : -2;
return re->top_bracket;
}
@@ -384,7 +437,7 @@ that additional items can be added compatibly.
Arguments:
external_re points to compiled code
- external_study points to study data, or NULL
+ extra_data points extra data, or NULL
what what information is required
where where to put the information
@@ -392,15 +445,18 @@ Returns: 0 if data returned, negative on error
*/
int
-pcre_fullinfo(const pcre *external_re, const pcre_extra *study_data, int what,
+pcre_fullinfo(const pcre *external_re, const pcre_extra *extra_data, int what,
void *where)
{
const real_pcre *re = (const real_pcre *)external_re;
-const real_pcre_extra *study = (const real_pcre_extra *)study_data;
+const pcre_study_data *study = NULL;
if (re == NULL || where == NULL) return PCRE_ERROR_NULL;
if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
+if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
+ study = extra_data->study_data;
+
switch (what)
{
case PCRE_INFO_OPTIONS:
@@ -411,6 +467,10 @@ switch (what)
*((size_t *)where) = re->size;
break;
+ case PCRE_INFO_STUDYSIZE:
+ *((size_t *)where) = (study == NULL)? 0 : study->size;
+ break;
+
case PCRE_INFO_CAPTURECOUNT:
*((int *)where) = re->top_bracket;
break;
@@ -419,9 +479,9 @@ switch (what)
*((int *)where) = re->top_backref;
break;
- case PCRE_INFO_FIRSTCHAR:
+ case PCRE_INFO_FIRSTBYTE:
*((int *)where) =
- ((re->options & PCRE_FIRSTSET) != 0)? re->first_char :
+ ((re->options & PCRE_FIRSTSET) != 0)? re->first_byte :
((re->options & PCRE_STARTLINE) != 0)? -1 : -2;
break;
@@ -433,7 +493,70 @@ switch (what)
case PCRE_INFO_LASTLITERAL:
*((int *)where) =
- ((re->options & PCRE_REQCHSET) != 0)? re->req_char : -1;
+ ((re->options & PCRE_REQCHSET) != 0)? re->req_byte : -1;
+ break;
+
+ case PCRE_INFO_NAMEENTRYSIZE:
+ *((int *)where) = re->name_entry_size;
+ break;
+
+ case PCRE_INFO_NAMECOUNT:
+ *((int *)where) = re->name_count;
+ break;
+
+ case PCRE_INFO_NAMETABLE:
+ *((const uschar **)where) = (const uschar *)re + sizeof(real_pcre);
+ break;
+
+ default: return PCRE_ERROR_BADOPTION;
+ }
+
+return 0;
+}
+
+
+
+/*************************************************
+* Return info about what features are configured *
+*************************************************/
+
+/* This is function which has an extensible interface so that additional items
+can be added compatibly.
+
+Arguments:
+ what what information is required
+ where where to put the information
+
+Returns: 0 if data returned, negative on error
+*/
+
+int
+pcre_config(int what, void *where)
+{
+switch (what)
+ {
+ case PCRE_CONFIG_UTF8:
+ #ifdef SUPPORT_UTF8
+ *((int *)where) = 1;
+ #else
+ *((int *)where) = 0;
+ #endif
+ break;
+
+ case PCRE_CONFIG_NEWLINE:
+ *((int *)where) = NEWLINE;
+ break;
+
+ case PCRE_CONFIG_LINK_SIZE:
+ *((int *)where) = LINK_SIZE;
+ break;
+
+ case PCRE_CONFIG_POSIX_MALLOC_THRESHOLD:
+ *((int *)where) = POSIX_MALLOC_THRESHOLD;
+ break;
+
+ case PCRE_CONFIG_MATCH_LIMIT:
+ *((unsigned int *)where) = MATCH_LIMIT;
break;
default: return PCRE_ERROR_BADOPTION;
@@ -525,6 +648,20 @@ else
const uschar *oldptr;
switch (c)
{
+ /* A number of Perl escapes are not handled by PCRE. We give an explicit
+ error. */
+
+ case 'l':
+ case 'L':
+ case 'N':
+ case 'p':
+ case 'P':
+ case 'u':
+ case 'U':
+ case 'X':
+ *errorptr = ERR37;
+ break;
+
/* The handling of escape sequences consisting of a string of digits
starting with one that is not zero is not straightforward. By experiment,
the way Perl works seems to be as follows:
@@ -746,17 +883,73 @@ return p;
/*************************************************
+* Find first significant op code *
+*************************************************/
+
+/* This is called by several functions that scan a compiled expression looking
+for a fixed first character, or an anchoring op code etc. It skips over things
+that do not influence this. For some calls, a change of option is important.
+
+Arguments:
+ code pointer to the start of the group
+ options pointer to external options
+ optbit the option bit whose changing is significant, or
+ zero if none are
+
+Returns: pointer to the first significant opcode
+*/
+
+static const uschar*
+first_significant_code(const uschar *code, int *options, int optbit)
+{
+for (;;)
+ {
+ switch ((int)*code)
+ {
+ case OP_OPT:
+ if (optbit > 0 && ((int)code[1] & optbit) != (*options & optbit))
+ *options = (int)code[1];
+ code += 2;
+ break;
+
+ case OP_ASSERT_NOT:
+ case OP_ASSERTBACK:
+ case OP_ASSERTBACK_NOT:
+ do code += GET(code, 1); while (*code == OP_ALT);
+ /* Fall through */
+
+ case OP_CALLOUT:
+ case OP_CREF:
+ case OP_BRANUMBER:
+ case OP_WORD_BOUNDARY:
+ case OP_NOT_WORD_BOUNDARY:
+ code += OP_lengths[*code];
+ break;
+
+ default:
+ return code;
+ }
+ }
+/* Control never reaches here */
+}
+
+
+
+
+/*************************************************
* Find the fixed length of a pattern *
*************************************************/
/* Scan a pattern and compute the fixed length of subject that will match it,
if the length is fixed. This is needed for dealing with backward assertions.
+In UTF8 mode, the result is in characters rather than bytes.
Arguments:
code points to the start of the pattern (the bracket)
options the compiling options
-Returns: the fixed length, or -1 if there is no fixed length
+Returns: the fixed length, or -1 if there is no fixed length,
+ or -2 if \C was encountered
*/
static int
@@ -765,7 +958,7 @@ find_fixedlength(uschar *code, int options)
int length = -1;
register int branchlength = 0;
-register uschar *cc = code + 3;
+register uschar *cc = code + 1 + LINK_SIZE;
/* Scan along the opcodes for this branch. If we get to the end of the
branch, check the length against that of the other branches. */
@@ -782,10 +975,10 @@ for (;;)
case OP_ONCE:
case OP_COND:
d = find_fixedlength(cc, options);
- if (d < 0) return -1;
+ if (d < 0) return d;
branchlength += d;
- do cc += (cc[1] << 8) + cc[2]; while (*cc == OP_ALT);
- cc += 3;
+ do cc += GET(cc, 1); while (*cc == OP_ALT);
+ cc += 1 + LINK_SIZE;
break;
/* Reached end of a branch; if it's a ket it is the end of a nested
@@ -800,7 +993,7 @@ for (;;)
if (length < 0) length = branchlength;
else if (length != branchlength) return -1;
if (*cc != OP_ALT) return length;
- cc += 3;
+ cc += 1 + LINK_SIZE;
branchlength = 0;
break;
@@ -810,51 +1003,58 @@ for (;;)
case OP_ASSERT_NOT:
case OP_ASSERTBACK:
case OP_ASSERTBACK_NOT:
- do cc += (cc[1] << 8) + cc[2]; while (*cc == OP_ALT);
- cc += 3;
- break;
+ do cc += GET(cc, 1); while (*cc == OP_ALT);
+ /* Fall through */
/* Skip over things that don't match chars */
case OP_REVERSE:
case OP_BRANUMBER:
case OP_CREF:
- cc++;
- /* Fall through */
-
case OP_OPT:
- cc++;
- /* Fall through */
-
+ case OP_CALLOUT:
case OP_SOD:
+ case OP_SOM:
case OP_EOD:
case OP_EODN:
case OP_CIRC:
case OP_DOLL:
case OP_NOT_WORD_BOUNDARY:
case OP_WORD_BOUNDARY:
- cc++;
+ cc += OP_lengths[*cc];
break;
/* Handle char strings. In UTF-8 mode we must count characters, not bytes.
This requires a scan of the string, unfortunately. We assume valid UTF-8
- strings, so all we do is reduce the length by one for byte whose bits are
- 10xxxxxx. */
+ strings, so all we do is reduce the length by one for every byte whose bits
+ are 10xxxxxx. */
case OP_CHARS:
branchlength += *(++cc);
#ifdef SUPPORT_UTF8
- for (d = 1; d <= *cc; d++)
- if ((cc[d] & 0xc0) == 0x80) branchlength--;
+ if ((options & PCRE_UTF8) != 0)
+ for (d = 1; d <= *cc; d++)
+ if ((cc[d] & 0xc0) == 0x80) branchlength--;
#endif
cc += *cc + 1;
break;
- /* Handle exact repetitions */
+ /* Handle exact repetitions. The count is already in characters, but we
+ need to skip over a multibyte character in UTF8 mode. */
case OP_EXACT:
+ branchlength += GET2(cc,1);
+ cc += 4;
+#ifdef SUPPORT_UTF8
+ if ((options & PCRE_UTF8) != 0)
+ {
+ while((*cc & 0x80) == 0x80) cc++;
+ }
+#endif
+ break;
+
case OP_TYPEEXACT:
- branchlength += (cc[1] << 8) + cc[2];
+ branchlength += GET2(cc,1);
cc += 4;
break;
@@ -871,10 +1071,21 @@ for (;;)
cc++;
break;
+ /* The single-byte matcher isn't allowed */
+
+ case OP_ANYBYTE:
+ return -2;
/* Check a class for variable quantification */
+#ifdef SUPPORT_UTF8
+ case OP_XCLASS:
+ cc += GET(cc, 1) - 33;
+ /* Fall through */
+#endif
+
case OP_CLASS:
+ case OP_NCLASS:
cc += 33;
switch (*cc)
@@ -887,8 +1098,8 @@ for (;;)
case OP_CRRANGE:
case OP_CRMINRANGE:
- if ((cc[1] << 8) + cc[2] != (cc[3] << 8) + cc[4]) return -1;
- branchlength += (cc[1] << 8) + cc[2];
+ if (GET2(cc,1) != GET2(cc,3)) return -1;
+ branchlength += GET2(cc,1);
cc += 5;
break;
@@ -910,6 +1121,239 @@ for (;;)
/*************************************************
+* Scan compiled regex for numbered bracket *
+*************************************************/
+
+/* This little function scans through a compiled pattern until it finds a
+capturing bracket with the given number.
+
+Arguments:
+ code points to start of expression
+ utf8 TRUE in UTF-8 mode
+ number the required bracket number
+
+Returns: pointer to the opcode for the bracket, or NULL if not found
+*/
+
+static const uschar *
+find_bracket(const uschar *code, BOOL utf8, int number)
+{
+for (;;)
+ {
+ register int c = *code;
+ if (c == OP_END) return NULL;
+ else if (c == OP_CHARS) code += code[1] + OP_lengths[c];
+ else if (c > OP_BRA)
+ {
+ int n = c - OP_BRA;
+ if (n > EXTRACT_BASIC_MAX) n = GET2(code, 2+LINK_SIZE);
+ if (n == number) return (uschar *)code;
+ code += OP_lengths[OP_BRA];
+ }
+ else
+ {
+ code += OP_lengths[c];
+
+ /* In UTF-8 mode, opcodes that are followed by a character may be followed
+ by a multi-byte character. The length in the table is a minimum, so we have
+ to scan along to skip the extra characters. All opcodes are less than 128,
+ so we can use relatively efficient code. */
+
+#ifdef SUPPORT_UTF8
+ if (utf8) switch(c)
+ {
+ case OP_EXACT:
+ case OP_UPTO:
+ case OP_MINUPTO:
+ case OP_STAR:
+ case OP_MINSTAR:
+ case OP_PLUS:
+ case OP_MINPLUS:
+ case OP_QUERY:
+ case OP_MINQUERY:
+ while ((*code & 0xc0) == 0x80) code++;
+ break;
+ }
+#endif
+ }
+ }
+}
+
+
+
+/*************************************************
+* Scan compiled branch for non-emptiness *
+*************************************************/
+
+/* This function scans through a branch of a compiled pattern to see whether it
+can match the empty string or not. It is called only from could_be_empty()
+below. Note that first_significant_code() skips over assertions. If we hit an
+unclosed bracket, we return "empty" - this means we've struck an inner bracket
+whose current branch will already have been scanned.
+
+Arguments:
+ code points to start of search
+ endcode points to where to stop
+ utf8 TRUE if in UTF8 mode
+
+Returns: TRUE if what is matched could be empty
+*/
+
+static BOOL
+could_be_empty_branch(const uschar *code, const uschar *endcode, BOOL utf8)
+{
+register int c;
+for (code = first_significant_code(code + 1 + LINK_SIZE, NULL, 0);
+ code < endcode;
+ code = first_significant_code(code + OP_lengths[c], NULL, 0))
+ {
+ const uschar *ccode;
+
+ c = *code;
+
+ if (c >= OP_BRA)
+ {
+ BOOL empty_branch;
+ if (GET(code, 1) == 0) return TRUE; /* Hit unclosed bracket */
+
+ /* Scan a closed bracket */
+
+ empty_branch = FALSE;
+ do
+ {
+ if (!empty_branch && could_be_empty_branch(code, endcode, utf8))
+ empty_branch = TRUE;
+ code += GET(code, 1);
+ }
+ while (*code == OP_ALT);
+ if (!empty_branch) return FALSE; /* All branches are non-empty */
+ code += 1 + LINK_SIZE;
+ c = *code;
+ }
+
+ else switch (c)
+ {
+ /* Check for quantifiers after a class */
+
+#ifdef SUPPORT_UTF8
+ case OP_XCLASS:
+ ccode = code + GET(code, 1);
+ goto CHECK_CLASS_REPEAT;
+#endif
+
+ case OP_CLASS:
+ case OP_NCLASS:
+ ccode = code + 33;
+
+#ifdef SUPPORT_UTF8
+ CHECK_CLASS_REPEAT:
+#endif
+
+ switch (*ccode)
+ {
+ case OP_CRSTAR: /* These could be empty; continue */
+ case OP_CRMINSTAR:
+ case OP_CRQUERY:
+ case OP_CRMINQUERY:
+ break;
+
+ default: /* Non-repeat => class must match */
+ case OP_CRPLUS: /* These repeats aren't empty */
+ case OP_CRMINPLUS:
+ return FALSE;
+
+ case OP_CRRANGE:
+ case OP_CRMINRANGE:
+ if (GET2(ccode, 1) > 0) return FALSE; /* Minimum > 0 */
+ break;
+ }
+ break;
+
+ /* Opcodes that must match a character */
+
+ case OP_NOT_DIGIT:
+ case OP_DIGIT:
+ case OP_NOT_WHITESPACE:
+ case OP_WHITESPACE:
+ case OP_NOT_WORDCHAR:
+ case OP_WORDCHAR:
+ case OP_ANY:
+ case OP_ANYBYTE:
+ case OP_CHARS:
+ case OP_NOT:
+ case OP_PLUS:
+ case OP_MINPLUS:
+ case OP_EXACT:
+ case OP_NOTPLUS:
+ case OP_NOTMINPLUS:
+ case OP_NOTEXACT:
+ case OP_TYPEPLUS:
+ case OP_TYPEMINPLUS:
+ case OP_TYPEEXACT:
+ return FALSE;
+
+ /* End of branch */
+
+ case OP_KET:
+ case OP_KETRMAX:
+ case OP_KETRMIN:
+ case OP_ALT:
+ return TRUE;
+
+ /* In UTF-8 mode, STAR, MINSTAR, QUERY, MINQUERY, UPTO, and MINUPTO may be
+ followed by a multibyte character */
+
+#ifdef SUPPORT_UTF8
+ case OP_STAR:
+ case OP_MINSTAR:
+ case OP_QUERY:
+ case OP_MINQUERY:
+ case OP_UPTO:
+ case OP_MINUPTO:
+ if (utf8) while ((code[2] & 0xc0) == 0x80) code++;
+ break;
+#endif
+ }
+ }
+
+return TRUE;
+}
+
+
+
+/*************************************************
+* Scan compiled regex for non-emptiness *
+*************************************************/
+
+/* This function is called to check for left recursive calls. We want to check
+the current branch of the current pattern to see if it could match the empty
+string. If it could, we must look outwards for branches at other levels,
+stopping when we pass beyond the bracket which is the subject of the recursion.
+
+Arguments:
+ code points to start of the recursion
+ endcode points to where to stop (current RECURSE item)
+ bcptr points to the chain of current (unclosed) branch starts
+ utf8 TRUE if in UTF-8 mode
+
+Returns: TRUE if what is matched could be empty
+*/
+
+static BOOL
+could_be_empty(const uschar *code, const uschar *endcode, branch_chain *bcptr,
+ BOOL utf8)
+{
+while (bcptr != NULL && bcptr->current >= code)
+ {
+ if (!could_be_empty_branch(bcptr->current, endcode, utf8)) return FALSE;
+ bcptr = bcptr->outer;
+ }
+return TRUE;
+}
+
+
+
+/*************************************************
* Check for POSIX class syntax *
*************************************************/
@@ -978,65 +1422,100 @@ return -1;
* Compile one branch *
*************************************************/
-/* Scan the pattern, compiling it into the code vector.
+/* Scan the pattern, compiling it into the code vector. If the options are
+changed during the branch, the pointer is used to change the external options
+bits.
Arguments:
- options the option bits
- brackets points to number of extracting brackets used
- code points to the pointer to the current code point
- ptrptr points to the current pattern pointer
- errorptr points to pointer to error message
- optchanged set to the value of the last OP_OPT item compiled
- reqchar set to the last literal character required, else -1
- countlits set to count of mandatory literal characters
- cd contains pointers to tables
-
-Returns: TRUE on success
- FALSE, with *errorptr set on error
+ optionsptr pointer to the option bits
+ brackets points to number of extracting brackets used
+ code points to the pointer to the current code point
+ ptrptr points to the current pattern pointer
+ errorptr points to pointer to error message
+ firstbyteptr set to initial literal character, or < 0 (REQ_UNSET, REQ_NONE)
+ reqbyteptr set to the last literal character required, else < 0
+ bcptr points to current branch chain
+ cd contains pointers to tables etc.
+
+Returns: TRUE on success
+ FALSE, with *errorptr set on error
*/
static BOOL
-compile_branch(int options, int *brackets, uschar **codeptr,
- const uschar **ptrptr, const char **errorptr, int *optchanged,
- int *reqchar, int *countlits, compile_data *cd)
+compile_branch(int *optionsptr, int *brackets, uschar **codeptr,
+ const uschar **ptrptr, const char **errorptr, int *firstbyteptr,
+ int *reqbyteptr, branch_chain *bcptr, compile_data *cd)
{
int repeat_type, op_type;
-int repeat_min, repeat_max;
-int bravalue, length;
+int repeat_min = 0, repeat_max = 0; /* To please picky compilers */
+int bravalue = 0;
+int length;
int greedy_default, greedy_non_default;
-int prevreqchar;
+int firstbyte, reqbyte;
+int zeroreqbyte, zerofirstbyte;
+int req_caseopt;
int condcount = 0;
-int subcountlits = 0;
+int options = *optionsptr;
register int c;
register uschar *code = *codeptr;
uschar *tempcode;
+BOOL inescq = FALSE;
+BOOL groupsetfirstbyte = FALSE;
const uschar *ptr = *ptrptr;
const uschar *tempptr;
uschar *previous = NULL;
uschar class[32];
+#ifdef SUPPORT_UTF8
+BOOL class_utf8;
+BOOL utf8 = (options & PCRE_UTF8) != 0;
+uschar *class_utf8data;
+uschar utf8_char[6];
+#else
+BOOL utf8 = FALSE;
+#endif
+
/* Set up the default and non-default settings for greediness */
greedy_default = ((options & PCRE_UNGREEDY) != 0);
greedy_non_default = greedy_default ^ 1;
-/* Initialize no required char, and count of literals */
+/* Initialize no first char, no required char. REQ_UNSET means "no char
+matching encountered yet". It gets changed to REQ_NONE if we hit something that
+matches a non-fixed char first char; reqbyte just remains unset if we never
+find one.
+
+When we hit a repeat whose minimum is zero, we may have to adjust these values
+to take the zero repeat into account. This is implemented by setting them to
+zerofirstbyte and zeroreqbyte when such a repeat is encountered. The individual
+item types that can be repeated set these backoff variables appropriately. */
-*reqchar = prevreqchar = -1;
-*countlits = 0;
+firstbyte = reqbyte = zerofirstbyte = zeroreqbyte = REQ_UNSET;
+
+/* The variable req_caseopt contains either the REQ_CASELESS value or zero,
+according to the current setting of the caseless flag. REQ_CASELESS is a bit
+value > 255. It is added into the firstbyte or reqbyte variables to record the
+case status of the value. */
+
+req_caseopt = ((options & PCRE_CASELESS) != 0)? REQ_CASELESS : 0;
/* Switch on next character until the end of the branch */
for (;; ptr++)
{
BOOL negate_class;
+ BOOL possessive_quantifier;
int class_charcount;
int class_lastchar;
int newoptions;
+ int recno;
int skipbytes;
- int subreqchar;
+ int subreqbyte;
+ int subfirstbyte;
c = *ptr;
+ if (inescq && c != 0) goto NORMAL_CHAR;
+
if ((options & PCRE_EXTENDED) != 0)
{
if ((cd->ctypes[c] & ctype_space) != 0) continue;
@@ -1045,7 +1524,7 @@ for (;; ptr++)
/* The space before the ; is to avoid a warning on a silly compiler
on the Macintosh. */
while ((c = *(++ptr)) != 0 && c != NEWLINE) ;
- continue;
+ if (c != 0) continue; /* Else fall through to handle end of string */
}
}
@@ -1056,13 +1535,20 @@ for (;; ptr++)
case 0:
case '|':
case ')':
+ *firstbyteptr = firstbyte;
+ *reqbyteptr = reqbyte;
*codeptr = code;
*ptrptr = ptr;
return TRUE;
- /* Handle single-character metacharacters */
+ /* Handle single-character metacharacters. In multiline mode, ^ disables
+ the setting of any following char as a first character. */
case '^':
+ if ((options & PCRE_MULTILINE) != 0)
+ {
+ if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+ }
previous = NULL;
*code++ = OP_CIRC;
break;
@@ -1072,19 +1558,41 @@ for (;; ptr++)
*code++ = OP_DOLL;
break;
+ /* There can never be a first char if '.' is first, whatever happens about
+ repeats. The value of reqbyte doesn't change either. */
+
case '.':
+ if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+ zerofirstbyte = firstbyte;
+ zeroreqbyte = reqbyte;
previous = code;
*code++ = OP_ANY;
break;
- /* Character classes. These always build a 32-byte bitmap of the permitted
- characters, except in the special case where there is only one character.
- For negated classes, we build the map as usual, then invert it at the end.
+ /* Character classes. If the included characters are all < 255 in value, we
+ build a 32-byte bitmap of the permitted characters, except in the special
+ case where there is only one such character. For negated classes, we build
+ the map as usual, then invert it at the end. However, we use a different
+ opcode so that data characters > 255 can be handled correctly.
+
+ If the class contains characters outside the 0-255 range, a different
+ opcode is compiled. It may optionally have a bit map for characters < 256,
+ but those above are are explicitly listed afterwards. A flag byte tells
+ whether the bitmap is present, and whether this is a negated class or not.
*/
case '[':
previous = code;
- *code++ = OP_CLASS;
+
+ /* PCRE supports POSIX class stuff inside a class. Perl gives an error if
+ they are encountered at the top level, so we'll do that too. */
+
+ if ((ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
+ check_posix_syntax(ptr, &tempptr, cd))
+ {
+ *errorptr = (ptr[1] == ':')? ERR13 : ERR31;
+ goto FAILED;
+ }
/* If the first character is '^', set the negation flag and skip it. */
@@ -1093,37 +1601,60 @@ for (;; ptr++)
negate_class = TRUE;
c = *(++ptr);
}
- else negate_class = FALSE;
+ else
+ {
+ negate_class = FALSE;
+ }
- /* Keep a count of chars so that we can optimize the case of just a single
- character. */
+ /* Keep a count of chars with values < 256 so that we can optimize the case
+ of just a single character (as long as it's < 256). For higher valued UTF-8
+ characters, we don't yet do any optimization. */
class_charcount = 0;
class_lastchar = -1;
+#ifdef SUPPORT_UTF8
+ class_utf8 = FALSE; /* No chars >= 256 */
+ class_utf8data = code + LINK_SIZE + 34; /* For UTF-8 items */
+#endif
+
/* Initialize the 32-char bit map to all zeros. We have to build the
map in a temporary bit of store, in case the class contains only 1
- character, because in that case the compiled code doesn't use the
+ character (< 256), because in that case the compiled code doesn't use the
bit map. */
memset(class, 0, 32 * sizeof(uschar));
/* Process characters until ] is reached. By writing this as a "do" it
- means that an initial ] is taken as a data character. */
+ means that an initial ] is taken as a data character. The first pass
+ through the regex checked the overall syntax, so we don't need to be very
+ strict here. At the start of the loop, c contains the first byte of the
+ character. */
do
{
- if (c == 0)
+#ifdef SUPPORT_UTF8
+ if (utf8 && c > 127) GETCHARLEN(c, ptr, ptr);
+#endif
+
+ /* Inside \Q...\E everything is literal except \E */
+
+ if (inescq)
{
- *errorptr = ERR6;
- goto FAILED;
+ if (c == '\\' && ptr[1] == 'E')
+ {
+ inescq = FALSE;
+ ptr++;
+ continue;
+ }
+ else goto LONE_SINGLE_CHARACTER;
}
/* Handle POSIX class names. Perl allows a negation extension of the
- form [:^name]. A square bracket that doesn't match the syntax is
+ form [:^name:]. A square bracket that doesn't match the syntax is
treated as a literal. We also recognize the POSIX constructions
[.ch.] and [=ch=] ("collating elements") and fault them, as Perl
- 5.6 does. */
+ 5.6 and 5.8 do. */
if (c == '[' &&
(ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
@@ -1161,22 +1692,31 @@ for (;; ptr++)
posix_class = 0;
/* Or into the map we are building up to 3 of the static class
- tables, or their negations. */
+ tables, or their negations. The [:blank:] class sets up the same
+ chars as the [:space:] class (all white space). We remove the vertical
+ white space chars afterwards. */
posix_class *= 3;
for (i = 0; i < 3; i++)
{
+ BOOL isblank = strncmp(ptr, "blank", 5) == 0;
int taboffset = posix_class_maps[posix_class + i];
if (taboffset < 0) break;
if (local_negate)
+ {
for (c = 0; c < 32; c++) class[c] |= ~cbits[c+taboffset];
+ if (isblank) class[1] |= 0x3c;
+ }
else
+ {
for (c = 0; c < 32; c++) class[c] |= cbits[c+taboffset];
+ if (isblank) class[1] &= ~0x3c;
+ }
}
ptr = tempptr + 1;
class_charcount = 10; /* Set > 1; assumes more than 1 per class */
- continue;
+ continue; /* End of POSIX syntax handling */
}
/* Backslash may introduce a single character, or it may introduce one
@@ -1185,16 +1725,27 @@ for (;; ptr++)
Inside a class (and only there) it is treated as backspace. Elsewhere
it marks a word boundary. Other escapes have preset maps ready to
or into the one we are building. We assume they have more than one
- character in them, so set class_count bigger than one. */
+ character in them, so set class_charcount bigger than one. */
if (c == '\\')
{
c = check_escape(&ptr, errorptr, *brackets, options, TRUE, cd);
- if (-c == ESC_b) c = '\b';
+ if (-c == ESC_b) c = '\b'; /* \b is backslash in a class */
+
+ if (-c == ESC_Q) /* Handle start of quoted string */
+ {
+ if (ptr[1] == '\\' && ptr[2] == 'E')
+ {
+ ptr += 2; /* avoid empty string */
+ }
+ else inescq = TRUE;
+ continue;
+ }
+
else if (c < 0)
{
register const uschar *cbits = cd->cbits;
- class_charcount = 10;
+ class_charcount = 10; /* Greater than 1 is what matters */
switch (-c)
{
case ESC_d:
@@ -1215,29 +1766,32 @@ for (;; ptr++)
case ESC_s:
for (c = 0; c < 32; c++) class[c] |= cbits[c+cbit_space];
+ class[1] &= ~0x08; /* Perl 5.004 onwards omits VT from \s */
continue;
case ESC_S:
for (c = 0; c < 32; c++) class[c] |= ~cbits[c+cbit_space];
+ class[1] |= 0x08; /* Perl 5.004 onwards omits VT from \s */
continue;
+ /* Unrecognized escapes are faulted if PCRE is running in its
+ strict mode. By default, for compatibility with Perl, they are
+ treated as literals. */
+
default:
- *errorptr = ERR7;
- goto FAILED;
+ if ((options & PCRE_EXTRA) != 0)
+ {
+ *errorptr = ERR7;
+ goto FAILED;
+ }
+ c = *ptr; /* The final character */
}
}
- /* Fall through if single character, but don't at present allow
- chars > 255 in UTF-8 mode. */
+ /* Fall through if we have a single character (c >= 0). This may be
+ > 256 in UTF-8 mode. */
-#ifdef SUPPORT_UTF8
- if (c > 255)
- {
- *errorptr = ERR33;
- goto FAILED;
- }
-#endif
- }
+ } /* End of backslash handling */
/* A single character may be followed by '-' to form a range. However,
Perl does not permit ']' to be the end of the range. A '-' character
@@ -1247,13 +1801,15 @@ for (;; ptr++)
{
int d;
ptr += 2;
- d = *ptr;
- if (d == 0)
- {
- *errorptr = ERR6;
- goto FAILED;
+#ifdef SUPPORT_UTF8
+ if (utf8)
+ { /* Braces are required because the */
+ GETCHARLEN(d, ptr, ptr); /* macro generates multiple statements */
}
+ else
+#endif
+ d = *ptr;
/* The second part of a range can be a single-character escape, but
not any of the other escapes. Perl 5.6 treats a hyphen as a literal
@@ -1264,13 +1820,6 @@ for (;; ptr++)
const uschar *oldptr = ptr;
d = check_escape(&ptr, errorptr, *brackets, options, TRUE, cd);
-#ifdef SUPPORT_UTF8
- if (d > 255)
- {
- *errorptr = ERR33;
- goto FAILED;
- }
-#endif
/* \b is backslash; any other special means the '-' was literal */
if (d < 0)
@@ -1278,17 +1827,45 @@ for (;; ptr++)
if (d == -ESC_b) d = '\b'; else
{
ptr = oldptr - 2;
- goto SINGLE_CHARACTER; /* A few lines below */
+ goto LONE_SINGLE_CHARACTER; /* A few lines below */
}
}
}
+ /* Check that the two values are in the correct order */
+
if (d < c)
{
*errorptr = ERR8;
goto FAILED;
}
+ /* If d is greater than 255, we can't just use the bit map, so set up
+ for the UTF-8 supporting class type. If we are not caseless, we can
+ just set up a single range. If we are caseless, the characters < 256
+ are handled with a bitmap, in order to get the case-insensitive
+ handling. */
+
+#ifdef SUPPORT_UTF8
+ if (d > 255)
+ {
+ class_utf8 = TRUE;
+ *class_utf8data++ = XCL_RANGE;
+ if ((options & PCRE_CASELESS) == 0)
+ {
+ class_utf8data += ord2utf8(c, class_utf8data);
+ class_utf8data += ord2utf8(d, class_utf8data);
+ continue; /* Go get the next char in the class */
+ }
+ class_utf8data += ord2utf8(256, class_utf8data);
+ class_utf8data += ord2utf8(d, class_utf8data);
+ d = 255;
+ /* Fall through */
+ }
+#endif
+ /* We use the bit map if the range is entirely < 255, or if part of it
+ is < 255 and matching is caseless. */
+
for (; c <= d; c++)
{
class[c/8] |= (1 << (c&7));
@@ -1300,59 +1877,149 @@ for (;; ptr++)
class_charcount++; /* in case a one-char range */
class_lastchar = c;
}
+
continue; /* Go get the next char in the class */
}
/* Handle a lone single character - we can get here for a normal
non-escape char, or after \ that introduces a single character. */
- SINGLE_CHARACTER:
+ LONE_SINGLE_CHARACTER:
- class [c/8] |= (1 << (c&7));
- if ((options & PCRE_CASELESS) != 0)
+ /* Handle a multibyte character */
+
+#ifdef SUPPORT_UTF8
+ if (utf8 && c > 255)
{
- c = cd->fcc[c]; /* flip case */
- class[c/8] |= (1 << (c&7));
+ class_utf8 = TRUE;
+ *class_utf8data++ = XCL_SINGLE;
+ class_utf8data += ord2utf8(c, class_utf8data);
+ }
+ else
+#endif
+ /* Handle a single-byte character */
+ {
+ class [c/8] |= (1 << (c&7));
+ if ((options & PCRE_CASELESS) != 0)
+ {
+ c = cd->fcc[c]; /* flip case */
+ class[c/8] |= (1 << (c&7));
+ }
+ class_charcount++;
+ class_lastchar = c;
}
- class_charcount++;
- class_lastchar = c;
}
/* Loop until ']' reached; the check for end of string happens inside the
loop. This "while" is the end of the "do" above. */
- while ((c = *(++ptr)) != ']');
+ while ((c = *(++ptr)) != ']' || inescq);
- /* If class_charcount is 1 and class_lastchar is not negative, we saw
- precisely one character. This doesn't need the whole 32-byte bit map.
- We turn it into a 1-character OP_CHAR if it's positive, or OP_NOT if
- it's negative. */
+ /* If class_charcount is 1, we saw precisely one character with a value <
+ 256. In UTF-8 mode, we can optimize if there were no characters >= 256 and
+ the one character is < 128. In non-UTF-8 mode we can always optimize.
- if (class_charcount == 1 && class_lastchar >= 0)
+ The optimization throws away the bit map. We turn the item into a
+ 1-character OP_CHARS if it's positive, or OP_NOT if it's negative. Note
+ that OP_NOT does not support multibyte characters. In the positive case, it
+ can cause firstbyte to be set. Otherwise, there can be no first char if
+ this item is first, whatever repeat count may follow. In the case of
+ reqbyte, save the previous value for reinstating. */
+
+#ifdef SUPPORT_UTF8
+ if (!class_utf8 && class_charcount == 1 && class_lastchar < 128)
+#else
+ if (class_charcount == 1)
+#endif
{
+ zeroreqbyte = reqbyte;
if (negate_class)
{
- code[-1] = OP_NOT;
+ if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+ zerofirstbyte = firstbyte;
+ *code++ = OP_NOT;
}
else
{
- code[-1] = OP_CHARS;
+ if (firstbyte == REQ_UNSET)
+ {
+ zerofirstbyte = REQ_NONE;
+ firstbyte = class_lastchar | req_caseopt;
+ }
+ else
+ {
+ zerofirstbyte = firstbyte;
+ reqbyte = class_lastchar | req_caseopt;
+ }
+ *code++ = OP_CHARS;
*code++ = 1;
}
*code++ = class_lastchar;
+ break; /* End of class handling */
+ } /* End of 1-byte optimization */
+
+ /* Otherwise, if this is the first thing in the branch, there can be no
+ first char setting, whatever the repeat count. Any reqbyte setting must
+ remain unchanged after any kind of repeat. */
+
+ if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+ zerofirstbyte = firstbyte;
+ zeroreqbyte = reqbyte;
+
+ /* If there are characters with values > 255, we have to compile an
+ extended class, with its own opcode. If there are no characters < 256,
+ we can omit the bitmap. */
+
+#ifdef SUPPORT_UTF8
+ if (class_utf8)
+ {
+ *class_utf8data++ = XCL_END; /* Marks the end of extra data */
+ *code++ = OP_XCLASS;
+ code += LINK_SIZE;
+ *code = negate_class? XCL_NOT : 0;
+
+ /* If the map is required, install it, and move on to the end of
+ the extra data */
+
+ if (class_charcount > 0)
+ {
+ *code++ |= XCL_MAP;
+ memcpy(code, class, 32);
+ code = class_utf8data;
+ }
+
+ /* If the map is not required, slide down the extra data. */
+
+ else
+ {
+ int len = class_utf8data - (code + 33);
+ memmove(code + 1, code + 33, len);
+ code += len + 1;
+ }
+
+ /* Now fill in the complete length of the item */
+
+ PUT(previous, 1, code - previous);
+ break; /* End of class handling */
}
+#endif
- /* Otherwise, negate the 32-byte map if necessary, and copy it into
- the code vector. */
+ /* If there are no characters > 255, negate the 32-byte map if necessary,
+ and copy it into the code vector. If this is the first thing in the branch,
+ there can be no first char setting, whatever the repeat count. Any reqbyte
+ setting must remain unchanged after any kind of repeat. */
+ if (negate_class)
+ {
+ *code++ = OP_NCLASS;
+ for (c = 0; c < 32; c++) code[c] = ~class[c];
+ }
else
{
- if (negate_class)
- for (c = 0; c < 32; c++) code[c] = ~class[c];
- else
- memcpy(code, class, 32);
- code += 32;
+ *code++ = OP_CLASS;
+ memcpy(code, class, 32);
}
+ code += 32;
break;
/* Various kinds of repeat */
@@ -1384,47 +2051,115 @@ for (;; ptr++)
goto FAILED;
}
- /* If the next character is '?' this is a minimizing repeat, by default,
- but if PCRE_UNGREEDY is set, it works the other way round. Advance to the
- next character. */
+ if (repeat_min == 0)
+ {
+ firstbyte = zerofirstbyte; /* Adjust for zero repeat */
+ reqbyte = zeroreqbyte; /* Ditto */
+ }
- if (ptr[1] == '?')
- { repeat_type = greedy_non_default; ptr++; }
+ op_type = 0; /* Default single-char op codes */
+ possessive_quantifier = FALSE; /* Default not possessive quantifier */
+
+ /* Save start of previous item, in case we have to move it up to make space
+ for an inserted OP_ONCE for the additional '+' extension. */
+
+ tempcode = previous;
+
+ /* If the next character is '+', we have a possessive quantifier. This
+ implies greediness, whatever the setting of the PCRE_UNGREEDY option.
+ If the next character is '?' this is a minimizing repeat, by default,
+ but if PCRE_UNGREEDY is set, it works the other way round. We change the
+ repeat type to the non-default. */
+
+ if (ptr[1] == '+')
+ {
+ repeat_type = 0; /* Force greedy */
+ possessive_quantifier = TRUE;
+ ptr++;
+ }
+ else if (ptr[1] == '?')
+ {
+ repeat_type = greedy_non_default;
+ ptr++;
+ }
else repeat_type = greedy_default;
+ /* If previous was a recursion, we need to wrap it inside brackets so that
+ it can be replicated if necessary. */
+
+ if (*previous == OP_RECURSE)
+ {
+ memmove(previous + 1 + LINK_SIZE, previous, 1 + LINK_SIZE);
+ code += 1 + LINK_SIZE;
+ *previous = OP_BRA;
+ PUT(previous, 1, code - previous);
+ *code = OP_KET;
+ PUT(code, 1, code - previous);
+ code += 1 + LINK_SIZE;
+ }
+
/* If previous was a string of characters, chop off the last one and use it
as the subject of the repeat. If there was only one character, we can
- abolish the previous item altogether. A repeat with a zero minimum wipes
- out any reqchar setting, backing up to the previous value. We must also
- adjust the countlits value. */
+ abolish the previous item altogether. If a one-char item has a minumum of
+ more than one, ensure that it is set in reqbyte - it might not be if a
+ sequence such as x{3} is the first thing in a branch because the x will
+ have gone into firstbyte instead. */
if (*previous == OP_CHARS)
{
- int len = previous[1];
-
- if (repeat_min == 0) *reqchar = prevreqchar;
- *countlits += repeat_min - 1;
+ /* Deal with UTF-8 characters that take up more than one byte. It's
+ easier to write this out separately than try to macrify it. Use c to
+ hold the length of the character in bytes, plus 0x80 to flag that it's a
+ length rather than a small character. */
- if (len == 1)
+#ifdef SUPPORT_UTF8
+ if (utf8 && (code[-1] & 0x80) != 0)
{
- c = previous[2];
- code = previous;
+ uschar *lastchar = code - 1;
+ while((*lastchar & 0xc0) == 0x80) lastchar--;
+ c = code - lastchar; /* Length of UTF-8 character */
+ memcpy(utf8_char, lastchar, c); /* Save the char */
+ if (lastchar == previous + 2) /* There was only one character */
+ {
+ code = previous; /* Abolish the previous item */
+ }
+ else
+ {
+ previous[1] -= c; /* Adjust length of previous */
+ code = lastchar; /* Lost char off the end */
+ tempcode = code; /* Adjust position to be moved for '+' */
+ }
+ c |= 0x80; /* Flag c as a length */
}
else
+#endif
+
+ /* Handle the case of a single byte - either with no UTF8 support, or
+ with UTF-8 disabled, or for a UTF-8 character < 128. */
+
{
- c = previous[len+1];
- previous[1]--;
- code--;
+ c = *(--code);
+ if (code == previous + 2) /* There was only one character */
+ {
+ code = previous; /* Abolish the previous item */
+ if (repeat_min > 1) reqbyte = c | req_caseopt;
+ }
+ else
+ {
+ previous[1]--; /* adjust length */
+ tempcode = code; /* Adjust position to be moved for '+' */
+ }
}
- op_type = 0; /* Use single-char op codes */
+
goto OUTPUT_SINGLE_REPEAT; /* Code shared with single character types */
}
/* If previous was a single negated character ([^a] or similar), we use
one of the special opcodes, replacing it. The code is shared with single-
- character repeats by adding a suitable offset into repeat_type. */
+ character repeats by setting opt_type to add a suitable offset into
+ repeat_type. OP_NOT is currently used only for single-byte chars. */
- else if ((int)*previous == OP_NOT)
+ else if (*previous == OP_NOT)
{
op_type = OP_NOTSTAR - OP_STAR; /* Use "not" opcodes */
c = previous[1];
@@ -1434,9 +2169,9 @@ for (;; ptr++)
/* If previous was a character type match (\d or similar), abolish it and
create a suitable repeat item. The code is shared with single-character
- repeats by adding a suitable offset into repeat_type. */
+ repeats by setting op_type to add a suitable offset into repeat_type. */
- else if ((int)*previous < OP_EODN || *previous == OP_ANY)
+ else if (*previous < OP_EODN)
{
op_type = OP_TYPESTAR - OP_STAR; /* Use type opcodes */
c = *previous;
@@ -1463,8 +2198,7 @@ for (;; ptr++)
else
{
*code++ = OP_UPTO + repeat_type;
- *code++ = repeat_max >> 8;
- *code++ = (repeat_max & 255);
+ PUT2INC(code, 0, repeat_max);
}
}
@@ -1481,8 +2215,7 @@ for (;; ptr++)
if (repeat_min != 1)
{
*code++ = OP_EXACT + op_type; /* NB EXACT doesn't have repeat_type */
- *code++ = repeat_min >> 8;
- *code++ = (repeat_min & 255);
+ PUT2INC(code, 0, repeat_min);
}
/* If the mininum is 1 and the previous item was a character string,
@@ -1490,47 +2223,88 @@ for (;; ptr++)
length was 1, or add the character back onto the end of a longer
string. For a character type nothing need be done; it will just get
put back naturally. Note that the final character is always going to
- get added below. */
+ get added below, so we leave code ready for its insertion. */
else if (*previous == OP_CHARS)
{
- if (code == previous) code += 2; else previous[1]++;
+ if (code == previous) code += 2; else
+
+ /* In UTF-8 mode, a multibyte char has its length in c, with the 0x80
+ bit set as a flag. The length will always be between 2 and 6. */
+
+#ifdef SUPPORT_UTF8
+ if (utf8 && c >= 128) previous[1] += c & 7; else
+#endif
+ previous[1]++;
}
/* For a single negated character we also have to put back the
- item that got cancelled. */
+ item that got cancelled. At present this applies only to single byte
+ characters in any mode. */
else if (*previous == OP_NOT) code++;
- /* If the maximum is unlimited, insert an OP_STAR. */
+ /* If the maximum is unlimited, insert an OP_STAR. Before doing so,
+ we have to insert the character for the previous code. In UTF-8 mode,
+ long characters have their length in c, with the 0x80 bit as a flag. */
if (repeat_max < 0)
{
+#ifdef SUPPORT_UTF8
+ if (utf8 && c >= 128)
+ {
+ memcpy(code, utf8_char, c & 7);
+ code += c & 7;
+ }
+ else
+#endif
*code++ = c;
*code++ = OP_STAR + repeat_type;
}
- /* Else insert an UPTO if the max is greater than the min. */
+ /* Else insert an UPTO if the max is greater than the min, again
+ preceded by the character, for the previously inserted code. */
else if (repeat_max != repeat_min)
{
+#ifdef SUPPORT_UTF8
+ if (utf8 && c >= 128)
+ {
+ memcpy(code, utf8_char, c & 7);
+ code += c & 7;
+ }
+ else
+#endif
*code++ = c;
repeat_max -= repeat_min;
*code++ = OP_UPTO + repeat_type;
- *code++ = repeat_max >> 8;
- *code++ = (repeat_max & 255);
+ PUT2INC(code, 0, repeat_max);
}
}
/* The character or character type itself comes last in all cases. */
+#ifdef SUPPORT_UTF8
+ if (utf8 && c >= 128)
+ {
+ memcpy(code, utf8_char, c & 7);
+ code += c & 7;
+ }
+ else
+#endif
+
*code++ = c;
}
/* If previous was a character class or a back reference, we put the repeat
stuff after it, but just skip the item if the repeat was {0,0}. */
- else if (*previous == OP_CLASS || *previous == OP_REF)
+ else if (*previous == OP_CLASS ||
+ *previous == OP_NCLASS ||
+#ifdef SUPPORT_UTF8
+ *previous == OP_XCLASS ||
+#endif
+ *previous == OP_REF)
{
if (repeat_max == 0)
{
@@ -1546,19 +2320,17 @@ for (;; ptr++)
else
{
*code++ = OP_CRRANGE + repeat_type;
- *code++ = repeat_min >> 8;
- *code++ = repeat_min & 255;
+ PUT2INC(code, 0, repeat_min);
if (repeat_max == -1) repeat_max = 0; /* 2-byte encoding for max */
- *code++ = repeat_max >> 8;
- *code++ = repeat_max & 255;
+ PUT2INC(code, 0, repeat_max);
}
}
/* If previous was a bracket group, we may have to replicate it in certain
cases. */
- else if ((int)*previous >= OP_BRA || (int)*previous == OP_ONCE ||
- (int)*previous == OP_COND)
+ else if (*previous >= OP_BRA || *previous == OP_ONCE ||
+ *previous == OP_COND)
{
register int i;
int ketoffset = 0;
@@ -1574,7 +2346,7 @@ for (;; ptr++)
if (repeat_max == -1)
{
register uschar *ket = previous;
- do ket += (ket[1] << 8) + ket[2]; while (*ket != OP_KET);
+ do ket += GET(ket, 1); while (*ket != OP_KET);
ketoffset = code - ket;
}
@@ -1587,15 +2359,6 @@ for (;; ptr++)
if (repeat_min == 0)
{
- /* If we set up a required char from the bracket, we must back off
- to the previous value and reset the countlits value too. */
-
- if (subcountlits > 0)
- {
- *reqchar = prevreqchar;
- *countlits -= subcountlits;
- }
-
/* If the maximum is also zero, we just omit the group from the output
altogether. */
@@ -1625,8 +2388,8 @@ for (;; ptr++)
else
{
int offset;
- memmove(previous+4, previous, len);
- code += 4;
+ memmove(previous + 2 + LINK_SIZE, previous, len);
+ code += 2 + LINK_SIZE;
*previous++ = OP_BRAZERO + repeat_type;
*previous++ = OP_BRA;
@@ -1635,8 +2398,7 @@ for (;; ptr++)
offset = (bralink == NULL)? 0 : previous - bralink;
bralink = previous;
- *previous++ = offset >> 8;
- *previous++ = offset & 255;
+ PUTINC(previous, 0, offset);
}
repeat_max--;
@@ -1644,14 +2406,19 @@ for (;; ptr++)
/* If the minimum is greater than zero, replicate the group as many
times as necessary, and adjust the maximum to the number of subsequent
- copies that we need. */
+ copies that we need. If we set a first char from the group, and didn't
+ set a required char, copy the latter from the former. */
else
{
- for (i = 1; i < repeat_min; i++)
+ if (repeat_min > 1)
{
- memcpy(code, previous, len);
- code += len;
+ if (groupsetfirstbyte && reqbyte < 0) reqbyte = firstbyte;
+ for (i = 1; i < repeat_min; i++)
+ {
+ memcpy(code, previous, len);
+ code += len;
+ }
}
if (repeat_max > 0) repeat_max -= repeat_min;
}
@@ -1677,8 +2444,7 @@ for (;; ptr++)
*code++ = OP_BRA;
offset = (bralink == NULL)? 0 : code - bralink;
bralink = code;
- *code++ = offset >> 8;
- *code++ = offset & 255;
+ PUTINC(code, 0, offset);
}
memcpy(code, previous, len);
@@ -1693,11 +2459,11 @@ for (;; ptr++)
int oldlinkoffset;
int offset = code - bralink + 1;
uschar *bra = code - offset;
- oldlinkoffset = (bra[1] << 8) + bra[2];
+ oldlinkoffset = GET(bra, 1);
bralink = (oldlinkoffset == 0)? NULL : bralink - oldlinkoffset;
*code++ = OP_KET;
- *code++ = bra[1] = offset >> 8;
- *code++ = bra[2] = (offset & 255);
+ PUTINC(code, 0, offset);
+ PUT(bra, 1, offset);
}
}
@@ -1717,6 +2483,24 @@ for (;; ptr++)
goto FAILED;
}
+ /* If the character following a repeat is '+', we wrap the entire repeated
+ item inside OP_ONCE brackets. This is just syntactic sugar, taken from
+ Sun's Java package. The repeated item starts at tempcode, not at previous,
+ which might be the first part of a string whose (former) last char we
+ repeated. However, we don't support '+' after a greediness '?'. */
+
+ if (possessive_quantifier)
+ {
+ int len = code - tempcode;
+ memmove(tempcode + 1+LINK_SIZE, tempcode, len);
+ code += 1 + LINK_SIZE;
+ len += 1 + LINK_SIZE;
+ tempcode[0] = OP_ONCE;
+ *code++ = OP_KET;
+ PUTINC(code, 0, len);
+ PUT(tempcode, 1, len);
+ }
+
/* In all case we no longer have a previous item. */
END_REPEAT:
@@ -1754,9 +2538,22 @@ for (;; ptr++)
case '(':
bravalue = OP_COND; /* Conditional group */
- if ((cd->ctypes[*(++ptr)] & ctype_digit) != 0)
+
+ /* Condition to test for recursion */
+
+ if (ptr[1] == 'R')
+ {
+ code[1+LINK_SIZE] = OP_CREF;
+ PUT2(code, 2+LINK_SIZE, CREF_RECURSE);
+ skipbytes = 3;
+ ptr += 3;
+ }
+
+ /* Condition to test for a numbered subpattern match */
+
+ else if ((cd->ctypes[ptr[1]] & ctype_digit) != 0)
{
- int condref = *ptr - '0';
+ int condref = *(++ptr) - '0';
while (*(++ptr) != ')') condref = condref*10 + *ptr - '0';
if (condref == 0)
{
@@ -1764,12 +2561,12 @@ for (;; ptr++)
goto FAILED;
}
ptr++;
- code[3] = OP_CREF;
- code[4] = condref >> 8;
- code[5] = condref & 255;
+ code[1+LINK_SIZE] = OP_CREF;
+ PUT2(code, 2+LINK_SIZE, condref);
skipbytes = 3;
}
- else ptr--;
+ /* For conditions that are assertions, we just fall through, having
+ set bravalue above. */
break;
case '=': /* Positive lookahead */
@@ -1794,10 +2591,6 @@ for (;; ptr++)
bravalue = OP_ASSERTBACK_NOT;
ptr++;
break;
-
- default: /* Syntax error */
- *errorptr = ERR24;
- goto FAILED;
}
break;
@@ -1806,11 +2599,148 @@ for (;; ptr++)
ptr++;
break;
+ case 'C': /* Callout - may be followed by digits */
+ *code++ = OP_CALLOUT;
+ {
+ int n = 0;
+ while ((cd->ctypes[*(++ptr)] & ctype_digit) != 0)
+ n = n * 10 + *ptr - '0';
+ if (n > 255)
+ {
+ *errorptr = ERR38;
+ goto FAILED;
+ }
+ *code++ = n;
+ }
+ previous = NULL;
+ continue;
+
+ case 'P': /* Named subpattern handling */
+ if (*(++ptr) == '<') /* Definition */
+ {
+ int i, namelen;
+ const uschar *name = ++ptr;
+ uschar *slot = cd->name_table;
+
+ while (*ptr++ != '>');
+ namelen = ptr - name - 1;
+
+ for (i = 0; i < cd->names_found; i++)
+ {
+ int c = memcmp(name, slot+2, namelen + 1);
+ if (c == 0)
+ {
+ *errorptr = ERR43;
+ goto FAILED;
+ }
+ if (c < 0)
+ {
+ memmove(slot + cd->name_entry_size, slot,
+ (cd->names_found - i) * cd->name_entry_size);
+ break;
+ }
+ slot += cd->name_entry_size;
+ }
+
+ PUT2(slot, 0, *brackets + 1);
+ memcpy(slot + 2, name, namelen);
+ slot[2+namelen] = 0;
+ cd->names_found++;
+ goto NUMBERED_GROUP;
+ }
+
+ if (*ptr == '=' || *ptr == '>') /* Reference or recursion */
+ {
+ int i, namelen;
+ int type = *ptr++;
+ const uschar *name = ptr;
+ uschar *slot = cd->name_table;
+
+ while (*ptr != ')') ptr++;
+ namelen = ptr - name;
+
+ for (i = 0; i < cd->names_found; i++)
+ {
+ if (strncmp(name, slot+2, namelen) == 0) break;
+ slot += cd->name_entry_size;
+ }
+ if (i >= cd->names_found)
+ {
+ *errorptr = ERR15;
+ goto FAILED;
+ }
+
+ recno = GET2(slot, 0);
+
+ if (type == '>') goto HANDLE_RECURSION; /* A few lines below */
+
+ /* Back reference */
+
+ previous = code;
+ *code++ = OP_REF;
+ PUT2INC(code, 0, recno);
+ cd->backref_map |= (recno < 32)? (1 << recno) : 1;
+ if (recno > cd->top_backref) cd->top_backref = recno;
+ continue;
+ }
+
+ /* Should never happen */
+ break;
+
case 'R': /* Pattern recursion */
- *code++ = OP_RECURSE;
- ptr++;
+ ptr++; /* Same as (?0) */
+ /* Fall through */
+
+ /* Recursion or "subroutine" call */
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ {
+ const uschar *called;
+ recno = 0;
+
+ while ((cd->ctypes[*ptr] & ctype_digit) != 0)
+ recno = recno * 10 + *ptr++ - '0';
+
+ /* Come here from code above that handles a named recursion */
+
+ HANDLE_RECURSION:
+
+ previous = code;
+
+ /* Find the bracket that is being referenced. Temporarily end the
+ regex in case it doesn't exist. */
+
+ *code = OP_END;
+ called = (recno == 0)?
+ cd->start_code : find_bracket(cd->start_code, utf8, recno);
+
+ if (called == NULL)
+ {
+ *errorptr = ERR15;
+ goto FAILED;
+ }
+
+ /* If the subpattern is still open, this is a recursive call. We
+ check to see if this is a left recursion that could loop for ever,
+ and diagnose that case. */
+
+ if (GET(called, 1) == 0 && could_be_empty(called, code, bcptr, utf8))
+ {
+ *errorptr = ERR40;
+ goto FAILED;
+ }
+
+ /* Insert the recursion/subroutine item */
+
+ *code = OP_RECURSE;
+ PUT(code, 1, called - cd->start_code);
+ code += 1 + LINK_SIZE;
+ }
continue;
+ /* Character after (? not specially recognized */
+
default: /* Option setting */
set = unset = 0;
optset = &set;
@@ -1827,10 +2757,6 @@ for (;; ptr++)
case 'x': *optset |= PCRE_EXTENDED; break;
case 'U': *optset |= PCRE_UNGREEDY; break;
case 'X': *optset |= PCRE_EXTRA; break;
-
- default:
- *errorptr = ERR12;
- goto FAILED;
}
}
@@ -1839,23 +2765,33 @@ for (;; ptr++)
newoptions = (options | set) & (~unset);
/* If the options ended with ')' this is not the start of a nested
- group with option changes, so the options change at this level. At top
- level there is nothing else to be done (the options will in fact have
- been set from the start of compiling as a result of the first pass) but
- at an inner level we must compile code to change the ims options if
- necessary, and pass the new setting back so that it can be put at the
- start of any following branches, and when this group ends, a resetting
- item can be compiled. */
+ group with option changes, so the options change at this level. Compile
+ code to change the ims options if this setting actually changes any of
+ them. We also pass the new setting back so that it can be put at the
+ start of any following branches, and when this group ends (if we are in
+ a group), a resetting item can be compiled.
+
+ Note that if this item is right at the start of the pattern, the
+ options will have been abstracted and made global, so there will be no
+ change to compile. */
if (*ptr == ')')
{
- if ((options & PCRE_INGROUP) != 0 &&
- (options & PCRE_IMS) != (newoptions & PCRE_IMS))
+ if ((options & PCRE_IMS) != (newoptions & PCRE_IMS))
{
*code++ = OP_OPT;
- *code++ = *optchanged = newoptions & PCRE_IMS;
+ *code++ = newoptions & PCRE_IMS;
}
- options = newoptions; /* Change options at this level */
+
+ /* Change options at this level, and pass them back for use
+ in subsequent branches. Reset the greedy defaults and the case
+ value for firstbyte and reqbyte. */
+
+ *optionsptr = options = newoptions;
+ greedy_default = ((newoptions & PCRE_UNGREEDY) != 0);
+ greedy_non_default = greedy_default ^ 1;
+ req_caseopt = ((options & PCRE_CASELESS) != 0)? REQ_CASELESS : 0;
+
previous = NULL; /* This item can't be repeated */
continue; /* It is complete */
}
@@ -1870,18 +2806,26 @@ for (;; ptr++)
}
}
+ /* If PCRE_NO_AUTO_CAPTURE is set, all unadorned brackets become
+ non-capturing and behave like (?:...) brackets */
+
+ else if ((options & PCRE_NO_AUTO_CAPTURE) != 0)
+ {
+ bravalue = OP_BRA;
+ }
+
/* Else we have a referencing group; adjust the opcode. If the bracket
number is greater than EXTRACT_BASIC_MAX, we set the opcode one higher, and
arrange for the true number to follow later, in an OP_BRANUMBER item. */
else
{
+ NUMBERED_GROUP:
if (++(*brackets) > EXTRACT_BASIC_MAX)
{
bravalue = OP_BRA + EXTRACT_BASIC_MAX + 1;
- code[3] = OP_BRANUMBER;
- code[4] = *brackets >> 8;
- code[5] = *brackets & 255;
+ code[1+LINK_SIZE] = OP_BRANUMBER;
+ PUT2(code, 2+LINK_SIZE, *brackets);
skipbytes = 3;
}
else bravalue = OP_BRA + *brackets;
@@ -1897,9 +2841,8 @@ for (;; ptr++)
tempcode = code;
if (!compile_regex(
- options | PCRE_INGROUP, /* Set for all nested groups */
- ((options & PCRE_IMS) != (newoptions & PCRE_IMS))?
- newoptions & PCRE_IMS : -1, /* Pass ims options if changed */
+ newoptions, /* The complete new option state */
+ options & PCRE_IMS, /* The previous ims option state */
brackets, /* Extracting bracket count */
&tempcode, /* Where to put code (updated) */
&ptr, /* Input pointer (updated) */
@@ -1907,8 +2850,9 @@ for (;; ptr++)
(bravalue == OP_ASSERTBACK ||
bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */
skipbytes, /* Skip over OP_COND/OP_BRANUMBER */
- &subreqchar, /* For possible last char */
- &subcountlits, /* For literal count */
+ &subfirstbyte, /* For possible first char */
+ &subreqbyte, /* For possible last char */
+ bcptr, /* Current branch chain */
cd)) /* Tables block */
goto FAILED;
@@ -1927,7 +2871,7 @@ for (;; ptr++)
do {
condcount++;
- tc += (tc[1] << 8) | tc[2];
+ tc += GET(tc,1);
}
while (*tc != OP_KET);
@@ -1936,25 +2880,63 @@ for (;; ptr++)
*errorptr = ERR27;
goto FAILED;
}
+
+ /* If there is just one branch, we must not make use of its firstbyte or
+ reqbyte, because this is equivalent to an empty second branch. */
+
+ if (condcount == 1) subfirstbyte = subreqbyte = REQ_NONE;
}
- /* Handle updating of the required character. If the subpattern didn't
- set one, leave it as it was. Otherwise, update it for normal brackets of
- all kinds, forward assertions, and conditions with two branches. Don't
- update the literal count for forward assertions, however. If the bracket
- is followed by a quantifier with zero repeat, we have to back off. Hence
- the definition of prevreqchar and subcountlits outside the main loop so
- that they can be accessed for the back off. */
-
- if (subreqchar > 0 &&
- (bravalue >= OP_BRA || bravalue == OP_ONCE || bravalue == OP_ASSERT ||
- (bravalue == OP_COND && condcount == 2)))
+ /* Handle updating of the required and first characters. Update for normal
+ brackets of all kinds, and conditions with two branches (see code above).
+ If the bracket is followed by a quantifier with zero repeat, we have to
+ back off. Hence the definition of zeroreqbyte and zerofirstbyte outside the
+ main loop so that they can be accessed for the back off. */
+
+ zeroreqbyte = reqbyte;
+ zerofirstbyte = firstbyte;
+ groupsetfirstbyte = FALSE;
+
+ if (bravalue >= OP_BRA || bravalue == OP_ONCE || bravalue == OP_COND)
{
- prevreqchar = *reqchar;
- *reqchar = subreqchar;
- if (bravalue != OP_ASSERT) *countlits += subcountlits;
+ /* If we have not yet set a firstbyte in this branch, take it from the
+ subpattern, remembering that it was set here so that a repeat of more
+ than one can replicate it as reqbyte if necessary. If the subpattern has
+ no firstbyte, set "none" for the whole branch. In both cases, a zero
+ repeat forces firstbyte to "none". */
+
+ if (firstbyte == REQ_UNSET)
+ {
+ if (subfirstbyte >= 0)
+ {
+ firstbyte = subfirstbyte;
+ groupsetfirstbyte = TRUE;
+ }
+ else firstbyte = REQ_NONE;
+ zerofirstbyte = REQ_NONE;
+ }
+
+ /* If firstbyte was previously set, convert the subpattern's firstbyte
+ into reqbyte if there wasn't one. */
+
+ else if (subfirstbyte >= 0 && subreqbyte < 0) subreqbyte = subfirstbyte;
+
+ /* If the subpattern set a required char (or set a first char that isn't
+ really the first char - see above), set it. */
+
+ if (subreqbyte >= 0) reqbyte = subreqbyte;
}
+ /* For a forward assertion, we take the reqbyte, if set. This can be
+ helpful if the pattern that follows the assertion doesn't set a different
+ char. For example, it's useful for /(?=abcde).+/. We can't set firstbyte
+ for an assertion, however because it leads to incorrect effect for patterns
+ such as /(?=a)a.+/ when the "real" "a" would then become a reqbyte instead
+ of a firstbyte. This is overcome by a scan at the end if there's no
+ firstbyte, looking for an asserted first char. */
+
+ else if (bravalue == OP_ASSERT && subreqbyte >= 0) reqbyte = subreqbyte;
+
/* Now update the main code pointer to the end of the group. */
code = tempcode;
@@ -1985,13 +2967,32 @@ for (;; ptr++)
if (c < 0)
{
+ if (-c == ESC_Q) /* Handle start of quoted string */
+ {
+ if (ptr[1] == '\\' && ptr[2] == 'E') ptr += 2; /* avoid empty string */
+ else inescq = TRUE;
+ continue;
+ }
+
+ /* For metasequences that actually match a character, we disable the
+ setting of a first character if it hasn't already been set. */
+
+ if (firstbyte == REQ_UNSET && -c > ESC_b && -c < ESC_Z)
+ firstbyte = REQ_NONE;
+
+ /* Set values to reset to if this is followed by a zero repeat. */
+
+ zerofirstbyte = firstbyte;
+ zeroreqbyte = reqbyte;
+
+ /* Back references are handled specially */
+
if (-c >= ESC_REF)
{
int number = -c - ESC_REF;
previous = code;
*code++ = OP_REF;
- *code++ = number >> 8;
- *code++ = number & 255;
+ PUT2INC(code, 0, number);
}
else
{
@@ -2019,6 +3020,25 @@ for (;; ptr++)
do
{
+ /* If in \Q...\E, check for the end; if not, we always have a literal */
+
+ if (inescq)
+ {
+ if (c == '\\' && ptr[1] == 'E')
+ {
+ inescq = FALSE;
+ ptr++;
+ }
+ else
+ {
+ *code++ = c;
+ length++;
+ }
+ continue;
+ }
+
+ /* Skip white space and comments for /x patterns */
+
if ((options & PCRE_EXTENDED) != 0)
{
if ((cd->ctypes[c] & ctype_space) != 0) continue;
@@ -2046,7 +3066,7 @@ for (;; ptr++)
two or more characters in the UTF-8 encoding. */
#ifdef SUPPORT_UTF8
- if (c > 127 && (options & PCRE_UTF8) != 0)
+ if (utf8 && c > 127)
{
uschar buffer[8];
int len = ord2utf8(c, buffer);
@@ -2067,14 +3087,115 @@ for (;; ptr++)
while (length < MAXLIT && (cd->ctypes[c = *(++ptr)] & ctype_meta) == 0);
- /* Update the last character and the count of literals */
+ /* Update the first and last requirements. These are always bytes, even in
+ UTF-8 mode. However, there is a special case to be considered when there
+ are only one or two characters. Because this gets messy in UTF-8 mode, the
+ code is kept separate. When we get here "length" contains the number of
+ bytes. */
+
+#ifdef SUPPORT_UTF8
+ if (utf8 && length > 1)
+ {
+ uschar *t = previous + 3; /* After this code, t */
+ while (t < code && (*t & 0xc0) == 0x80) t++; /* follows the 1st char */
+
+ /* Handle the case when there is only one multibyte character. It must
+ have at least two bytes because of the "length > 1" test above. */
+
+ if (t == code)
+ {
+ /* If no previous first byte, set it from this character, but revert to
+ none on a zero repeat. */
+
+ if (firstbyte == REQ_UNSET)
+ {
+ zerofirstbyte = REQ_NONE;
+ firstbyte = previous[2];
+ }
+
+ /* Otherwise, leave the first byte value alone, and don't change it on
+ a zero repeat */
+
+ else zerofirstbyte = firstbyte;
+
+ /* In both cases, a zero repeat resets the previous required byte */
+
+ zeroreqbyte = reqbyte;
+ }
+
+ /* Handle the case when there is more than one character. These may be
+ single-byte or multibyte characters */
+
+ else
+ {
+ uschar *t = code - 1; /* After this code, t is at the */
+ while ((*t & 0xc0) == 0x80) t--; /* start of the last character */
+
+ /* If no previous first byte, set it from the first character, and
+ retain it on a zero repeat (of the last character). The required byte
+ is reset on a zero repeat, either to the byte before the last
+ character, unless this is the first byte of the string. In that case,
+ it reverts to its previous value. */
+
+ if (firstbyte == REQ_UNSET)
+ {
+ zerofirstbyte = firstbyte = previous[2] | req_caseopt;
+ zeroreqbyte = (t - 1 == previous + 2)? reqbyte : t[-1] | req_caseopt;
+ }
+
+ /* If there was a previous first byte, leave it alone, and don't change
+ it on a zero repeat. The required byte is reset on a zero repeat to the
+ byte before the last character. */
+
+ else
+ {
+ zerofirstbyte = firstbyte;
+ zeroreqbyte = t[-1] | req_caseopt;
+ }
+ }
+
+ /* In all cases (we know length > 1), the new required byte is the last
+ byte of the string. */
+
+ reqbyte = code[-1] | req_caseopt;
+ }
+
+ else /* End of UTF-8 coding */
+#endif
+
+ /* This is the code for non-UTF-8 operation, either without UTF-8 support,
+ or when UTF-8 is not enabled. */
+
+ {
+ /* firstbyte was not previously set; take it from this string */
- prevreqchar = (length > 1)? code[-2] : *reqchar;
- *reqchar = code[-1];
- *countlits += length;
+ if (firstbyte == REQ_UNSET)
+ {
+ if (length == 1)
+ {
+ zerofirstbyte = REQ_NONE;
+ firstbyte = previous[2] | req_caseopt;
+ zeroreqbyte = reqbyte;
+ }
+ else
+ {
+ zerofirstbyte = firstbyte = previous[2] | req_caseopt;
+ zeroreqbyte = (length > 2)? (code[-2] | req_caseopt) : reqbyte;
+ reqbyte = code[-1] | req_caseopt;
+ }
+ }
- /* Compute the length and set it in the data vector, and advance to
- the next state. */
+ /* firstbyte was previously set */
+
+ else
+ {
+ zerofirstbyte = firstbyte;
+ zeroreqbyte = (length == 1)? reqbyte : code[-2] | req_caseopt;
+ reqbyte = code[-1] | req_caseopt;
+ }
+ }
+
+ /* Set the length in the data vector, and advance to the next state. */
previous[1] = length;
if (length < MAXLIT) ptr--;
@@ -2107,52 +3228,56 @@ following branch to ensure they get set correctly at run time, and also pass
the new options into every subsequent branch compile.
Argument:
- options the option bits
- optchanged new ims options to set as if (?ims) were at the start, or -1
- for no change
- brackets -> int containing the number of extracting brackets used
- codeptr -> the address of the current code pointer
- ptrptr -> the address of the current pattern pointer
- errorptr -> pointer to error message
- lookbehind TRUE if this is a lookbehind assertion
- skipbytes skip this many bytes at start (for OP_COND, OP_BRANUMBER)
- reqchar -> place to put the last required character, or a negative number
- countlits -> place to put the shortest literal count of any branch
- cd points to the data block with tables pointers
+ options option bits, including any changes for this subpattern
+ oldims previous settings of ims option bits
+ brackets -> int containing the number of extracting brackets used
+ codeptr -> the address of the current code pointer
+ ptrptr -> the address of the current pattern pointer
+ errorptr -> pointer to error message
+ lookbehind TRUE if this is a lookbehind assertion
+ skipbytes skip this many bytes at start (for OP_COND, OP_BRANUMBER)
+ firstbyteptr place to put the first required character, or a negative number
+ reqbyteptr place to put the last required character, or a negative number
+ bcptr pointer to the chain of currently open branches
+ cd points to the data block with tables pointers etc.
Returns: TRUE on success
*/
static BOOL
-compile_regex(int options, int optchanged, int *brackets, uschar **codeptr,
+compile_regex(int options, int oldims, int *brackets, uschar **codeptr,
const uschar **ptrptr, const char **errorptr, BOOL lookbehind, int skipbytes,
- int *reqchar, int *countlits, compile_data *cd)
+ int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr, compile_data *cd)
{
const uschar *ptr = *ptrptr;
uschar *code = *codeptr;
uschar *last_branch = code;
uschar *start_bracket = code;
uschar *reverse_count = NULL;
-int oldoptions = options & PCRE_IMS;
-int branchreqchar, branchcountlits;
+int firstbyte, reqbyte;
+int branchfirstbyte, branchreqbyte;
+branch_chain bc;
+
+bc.outer = bcptr;
+bc.current = code;
-*reqchar = -1;
-*countlits = INT_MAX;
-code += 3 + skipbytes;
+firstbyte = reqbyte = REQ_UNSET;
+
+/* Offset is set zero to mark that this bracket is still open */
+
+PUT(code, 1, 0);
+code += 1 + LINK_SIZE + skipbytes;
/* Loop for each alternative branch */
for (;;)
{
- int length;
+ /* Handle a change of ims options at the start of the branch */
- /* Handle change of options */
-
- if (optchanged >= 0)
+ if ((options & PCRE_IMS) != oldims)
{
*code++ = OP_OPT;
- *code++ = optchanged;
- options = (options & ~PCRE_IMS) | optchanged;
+ *code++ = options & PCRE_IMS;
}
/* Set up dummy OP_REVERSE if lookbehind assertion */
@@ -2161,43 +3286,52 @@ for (;;)
{
*code++ = OP_REVERSE;
reverse_count = code;
- *code++ = 0;
- *code++ = 0;
+ PUTINC(code, 0, 0);
}
/* Now compile the branch */
- if (!compile_branch(options, brackets, &code, &ptr, errorptr, &optchanged,
- &branchreqchar, &branchcountlits, cd))
+ if (!compile_branch(&options, brackets, &code, &ptr, errorptr,
+ &branchfirstbyte, &branchreqbyte, &bc, cd))
{
*ptrptr = ptr;
return FALSE;
}
- /* Fill in the length of the last branch */
+ /* If this is the first branch, the firstbyte and reqbyte values for the
+ branch become the values for the regex. */
- length = code - last_branch;
- last_branch[1] = length >> 8;
- last_branch[2] = length & 255;
+ if (*last_branch != OP_ALT)
+ {
+ firstbyte = branchfirstbyte;
+ reqbyte = branchreqbyte;
+ }
- /* Save the last required character if all branches have the same; a current
- value of -1 means unset, while -2 means "previous branch had no last required
- char". */
+ /* If this is not the first branch, the first char and reqbyte have to
+ match the values from all the previous branches. */
- if (*reqchar != -2)
+ else
{
- if (branchreqchar >= 0)
+ /* If we previously had a firstbyte, but it doesn't match the new branch,
+ we have to abandon the firstbyte for the regex, but if there was previously
+ no reqbyte, it takes on the value of the old firstbyte. */
+
+ if (firstbyte >= 0 && firstbyte != branchfirstbyte)
{
- if (*reqchar == -1) *reqchar = branchreqchar;
- else if (*reqchar != branchreqchar) *reqchar = -2;
+ if (reqbyte < 0) reqbyte = firstbyte;
+ firstbyte = REQ_NONE;
}
- else *reqchar = -2;
- }
- /* Keep the shortest literal count */
+ /* If we (now or from before) have no firstbyte, a firstbyte from the
+ branch becomes a reqbyte if there isn't a branch reqbyte. */
+
+ if (firstbyte < 0 && branchfirstbyte >= 0 && branchreqbyte < 0)
+ branchreqbyte = branchfirstbyte;
- if (branchcountlits < *countlits) *countlits = branchcountlits;
- DPRINTF(("literal count = %d min=%d\n", branchcountlits, *countlits));
+ /* Now ensure that the reqbytes match */
+
+ if (reqbyte != branchreqbyte) reqbyte = REQ_NONE;
+ }
/* If lookbehind, check that this branch matches a fixed-length string,
and put the length into the OP_REVERSE item. Temporarily mark the end of
@@ -2205,110 +3339,73 @@ for (;;)
if (lookbehind)
{
+ int length;
*code = OP_END;
length = find_fixedlength(last_branch, options);
DPRINTF(("fixed length = %d\n", length));
if (length < 0)
{
- *errorptr = ERR25;
+ *errorptr = (length == -2)? ERR36 : ERR25;
*ptrptr = ptr;
return FALSE;
}
- reverse_count[0] = (length >> 8);
- reverse_count[1] = length & 255;
+ PUT(reverse_count, 0, length);
}
- /* Reached end of expression, either ')' or end of pattern. Insert a
- terminating ket and the length of the whole bracketed item, and return,
- leaving the pointer at the terminating char. If any of the ims options
- were changed inside the group, compile a resetting op-code following. */
+ /* Reached end of expression, either ')' or end of pattern. Go back through
+ the alternative branches and reverse the chain of offsets, with the field in
+ the BRA item now becoming an offset to the first alternative. If there are
+ no alternatives, it points to the end of the group. The length in the
+ terminating ket is always the length of the whole bracketed item. If any of
+ the ims options were changed inside the group, compile a resetting op-code
+ following, except at the very end of the pattern. Return leaving the pointer
+ at the terminating char. */
if (*ptr != '|')
{
- length = code - start_bracket;
- *code++ = OP_KET;
- *code++ = length >> 8;
- *code++ = length & 255;
- if (optchanged >= 0)
+ int length = code - last_branch;
+ do
{
- *code++ = OP_OPT;
- *code++ = oldoptions;
+ int prev_length = GET(last_branch, 1);
+ PUT(last_branch, 1, length);
+ length = prev_length;
+ last_branch -= length;
}
- *codeptr = code;
- *ptrptr = ptr;
- return TRUE;
- }
+ while (length > 0);
- /* Another branch follows; insert an "or" node and advance the pointer. */
+ /* Fill in the ket */
- *code = OP_ALT;
- last_branch = code;
- code += 3;
- ptr++;
- }
-/* Control never reaches here */
-}
-
-
-
-
-/*************************************************
-* Find first significant op code *
-*************************************************/
-
-/* This is called by several functions that scan a compiled expression looking
-for a fixed first character, or an anchoring op code etc. It skips over things
-that do not influence this. For one application, a change of caseless option is
-important.
-
-Arguments:
- code pointer to the start of the group
- options pointer to external options
- optbit the option bit whose changing is significant, or
- zero if none are
- optstop TRUE to return on option change, otherwise change the options
- value and continue
+ *code = OP_KET;
+ PUT(code, 1, code - start_bracket);
+ code += 1 + LINK_SIZE;
-Returns: pointer to the first significant opcode
-*/
+ /* Resetting option if needed */
-static const uschar*
-first_significant_code(const uschar *code, int *options, int optbit,
- BOOL optstop)
-{
-for (;;)
- {
- switch ((int)*code)
- {
- case OP_OPT:
- if (optbit > 0 && ((int)code[1] & optbit) != (*options & optbit))
+ if ((options & PCRE_IMS) != oldims && *ptr == ')')
{
- if (optstop) return code;
- *options = (int)code[1];
+ *code++ = OP_OPT;
+ *code++ = oldims;
}
- code += 2;
- break;
- case OP_CREF:
- case OP_BRANUMBER:
- code += 3;
- break;
+ /* Set values to pass back */
- case OP_WORD_BOUNDARY:
- case OP_NOT_WORD_BOUNDARY:
- code++;
- break;
+ *codeptr = code;
+ *ptrptr = ptr;
+ *firstbyteptr = firstbyte;
+ *reqbyteptr = reqbyte;
+ return TRUE;
+ }
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- do code += (code[1] << 8) + code[2]; while (*code == OP_ALT);
- code += 3;
- break;
+ /* Another branch follows; insert an "or" node. Its length field points back
+ to the previous branch while the bracket remains open. At the end the chain
+ is reversed. It's done like this so that the start of the bracket has a
+ zero offset until it is closed, making it possible to detect recursion. */
- default:
- return code;
- }
+ *code = OP_ALT;
+ PUT(code, 1, code - last_branch);
+ bc.current = last_branch = code;
+ code += 1 + LINK_SIZE;
+ ptr++;
}
/* Control never reaches here */
}
@@ -2326,35 +3423,78 @@ all of whose alternatives start with OP_SOD or OP_CIRC (recurse ad lib), then
it's anchored. However, if this is a multiline pattern, then only OP_SOD
counts, since OP_CIRC can match in the middle.
+We can also consider a regex to be anchored if OP_SOM starts all its branches.
+This is the code for \G, which means "match at start of match position, taking
+into account the match offset".
+
A branch is also implicitly anchored if it starts with .* and DOTALL is set,
because that will try the rest of the pattern at all possible matching points,
-so there is no point trying them again.
+so there is no point trying again.... er ....
+
+.... except when the .* appears inside capturing parentheses, and there is a
+subsequent back reference to those parentheses. We haven't enough information
+to catch that case precisely.
+
+At first, the best we could do was to detect when .* was in capturing brackets
+and the highest back reference was greater than or equal to that level.
+However, by keeping a bitmap of the first 31 back references, we can catch some
+of the more common cases more precisely.
Arguments:
- code points to start of expression (the bracket)
- options points to the options setting
+ code points to start of expression (the bracket)
+ options points to the options setting
+ bracket_map a bitmap of which brackets we are inside while testing; this
+ handles up to substring 31; after that we just have to take
+ the less precise approach
+ backref_map the back reference bitmap
Returns: TRUE or FALSE
*/
static BOOL
-is_anchored(register const uschar *code, int *options)
+is_anchored(register const uschar *code, int *options, unsigned int bracket_map,
+ unsigned int backref_map)
{
do {
- const uschar *scode = first_significant_code(code + 3, options,
- PCRE_MULTILINE, FALSE);
+ const uschar *scode =
+ first_significant_code(code + 1+LINK_SIZE, options, PCRE_MULTILINE);
register int op = *scode;
- if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)
- { if (!is_anchored(scode, options)) return FALSE; }
+
+ /* Capturing brackets */
+
+ if (op > OP_BRA)
+ {
+ int new_map;
+ op -= OP_BRA;
+ if (op > EXTRACT_BASIC_MAX) op = GET2(scode, 2+LINK_SIZE);
+ new_map = bracket_map | ((op < 32)? (1 << op) : 1);
+ if (!is_anchored(scode, options, new_map, backref_map)) return FALSE;
+ }
+
+ /* Other brackets */
+
+ else if (op == OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)
+ {
+ if (!is_anchored(scode, options, bracket_map, backref_map)) return FALSE;
+ }
+
+ /* .* is not anchored unless DOTALL is set and it isn't in brackets that
+ are or may be referenced. */
+
else if ((op == OP_TYPESTAR || op == OP_TYPEMINSTAR) &&
(*options & PCRE_DOTALL) != 0)
- { if (scode[1] != OP_ANY) return FALSE; }
- else if (op != OP_SOD &&
+ {
+ if (scode[1] != OP_ANY || (bracket_map & backref_map) != 0) return FALSE;
+ }
+
+ /* Check for explicit anchoring */
+
+ else if (op != OP_SOD && op != OP_SOM &&
((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC))
return FALSE;
- code += (code[1] << 8) + code[2];
+ code += GET(code, 1);
}
-while (*code == OP_ALT);
+while (*code == OP_ALT); /* Loop for each alternative */
return TRUE;
}
@@ -2367,56 +3507,91 @@ return TRUE;
/* This is called to find out if every branch starts with ^ or .* so that
"first char" processing can be done to speed things up in multiline
matching and for non-DOTALL patterns that start with .* (which must start at
-the beginning or after \n).
+the beginning or after \n). As in the case of is_anchored() (see above), we
+have to take account of back references to capturing brackets that contain .*
+because in that case we can't make the assumption.
-Argument: points to start of expression (the bracket)
-Returns: TRUE or FALSE
+Arguments:
+ code points to start of expression (the bracket)
+ bracket_map a bitmap of which brackets we are inside while testing; this
+ handles up to substring 31; after that we just have to take
+ the less precise approach
+ backref_map the back reference bitmap
+
+Returns: TRUE or FALSE
*/
static BOOL
-is_startline(const uschar *code)
+is_startline(const uschar *code, unsigned int bracket_map,
+ unsigned int backref_map)
{
do {
- const uschar *scode = first_significant_code(code + 3, NULL, 0, FALSE);
+ const uschar *scode = first_significant_code(code + 1+LINK_SIZE, NULL, 0);
register int op = *scode;
- if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)
- { if (!is_startline(scode)) return FALSE; }
+
+ /* Capturing brackets */
+
+ if (op > OP_BRA)
+ {
+ int new_map;
+ op -= OP_BRA;
+ if (op > EXTRACT_BASIC_MAX) op = GET2(scode, 2+LINK_SIZE);
+ new_map = bracket_map | ((op < 32)? (1 << op) : 1);
+ if (!is_startline(scode, new_map, backref_map)) return FALSE;
+ }
+
+ /* Other brackets */
+
+ else if (op == OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)
+ { if (!is_startline(scode, bracket_map, backref_map)) return FALSE; }
+
+ /* .* is not anchored unless DOTALL is set and it isn't in brackets that
+ may be referenced. */
+
else if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR)
- { if (scode[1] != OP_ANY) return FALSE; }
+ {
+ if (scode[1] != OP_ANY || (bracket_map & backref_map) != 0) return FALSE;
+ }
+
+ /* Check for explicit circumflex */
+
else if (op != OP_CIRC) return FALSE;
- code += (code[1] << 8) + code[2];
+ code += GET(code, 1);
}
-while (*code == OP_ALT);
+while (*code == OP_ALT); /* Loop for each alternative */
return TRUE;
}
/*************************************************
-* Check for fixed first char *
+* Check for asserted fixed first char *
*************************************************/
-/* Try to find out if there is a fixed first character. This is called for
-unanchored expressions, as it speeds up their processing quite considerably.
-Consider each alternative branch. If they all start with the same char, or with
-a bracket all of whose alternatives start with the same char (recurse ad lib),
-then we return that char, otherwise -1.
+/* During compilation, the "first char" settings from forward assertions are
+discarded, because they can cause conflicts with actual literals that follow.
+However, if we end up without a first char setting for an unanchored pattern,
+it is worth scanning the regex to see if there is an initial asserted first
+char. If all branches start with the same asserted char, or with a bracket all
+of whose alternatives start with the same asserted char (recurse ad lib), then
+we return that char, otherwise -1.
Arguments:
code points to start of expression (the bracket)
options pointer to the options (used to check casing changes)
+ inassert TRUE if in an assertion
Returns: -1 or the fixed first char
*/
static int
-find_firstchar(const uschar *code, int *options)
+find_firstassertedchar(const uschar *code, int *options, BOOL inassert)
{
register int c = -1;
do {
int d;
- const uschar *scode = first_significant_code(code + 3, options,
- PCRE_CASELESS, TRUE);
+ const uschar *scode =
+ first_significant_code(code + 1+LINK_SIZE, options, PCRE_CASELESS);
register int op = *scode;
if (op >= OP_BRA) op = OP_BRA;
@@ -2430,7 +3605,8 @@ do {
case OP_ASSERT:
case OP_ONCE:
case OP_COND:
- if ((d = find_firstchar(scode, options)) < 0) return -1;
+ if ((d = find_firstassertedchar(scode, options, op == OP_ASSERT)) < 0)
+ return -1;
if (c < 0) c = d; else if (c != d) return -1;
break;
@@ -2442,11 +3618,17 @@ do {
case OP_PLUS:
case OP_MINPLUS:
- if (c < 0) c = scode[1]; else if (c != scode[1]) return -1;
+ if (!inassert) return -1;
+ if (c < 0)
+ {
+ c = scode[1];
+ if ((*options & PCRE_CASELESS) != 0) c |= REQ_CASELESS;
+ }
+ else if (c != scode[1]) return -1;
break;
}
- code += (code[1] << 8) + code[2];
+ code += GET(code, 1);
}
while (*code == OP_ALT);
return c;
@@ -2455,7 +3637,6 @@ return c;
-
/*************************************************
* Compile a Regular Expression *
*************************************************/
@@ -2479,35 +3660,30 @@ pcre_compile(const char *pattern, int options, const char **errorptr,
int *erroroffset, const unsigned char *tables)
{
real_pcre *re;
-int length = 3; /* For initial BRA plus length */
+int length = 1 + LINK_SIZE; /* For initial BRA plus length */
int runlength;
-int c, reqchar, countlits;
+int c, firstbyte, reqbyte;
int bracount = 0;
-int top_backref = 0;
int branch_extra = 0;
int branch_newextra;
+int item_count = -1;
+int name_count = 0;
+int max_name_size = 0;
+#ifdef SUPPORT_UTF8
+int lastcharlength = 0;
+BOOL utf8;
+BOOL class_utf8;
+#endif
+BOOL inescq = FALSE;
unsigned int brastackptr = 0;
size_t size;
uschar *code;
+const uschar *codestart;
const uschar *ptr;
compile_data compile_block;
int brastack[BRASTACK_SIZE];
uschar bralenstack[BRASTACK_SIZE];
-#ifdef DEBUG
-uschar *code_base, *code_end;
-#endif
-
-/* Can't support UTF8 unless PCRE has been compiled to include the code. */
-
-#ifndef SUPPORT_UTF8
-if ((options & PCRE_UTF8) != 0)
- {
- *errorptr = ERR32;
- return NULL;
- }
-#endif
-
/* We can't pass back an error message if errorptr is NULL; I guess the best we
can do is just return NULL. */
@@ -2523,6 +3699,18 @@ if (erroroffset == NULL)
}
*erroroffset = 0;
+/* Can't support UTF8 unless PCRE has been compiled to include the code. */
+
+#ifdef SUPPORT_UTF8
+utf8 = (options & PCRE_UTF8) != 0;
+#else
+if ((options & PCRE_UTF8) != 0)
+ {
+ *errorptr = ERR32;
+ return NULL;
+ }
+#endif
+
if ((options & ~PUBLIC_OPTIONS) != 0)
{
*errorptr = ERR17;
@@ -2537,6 +3725,14 @@ compile_block.fcc = tables + fcc_offset;
compile_block.cbits = tables + cbits_offset;
compile_block.ctypes = tables + ctypes_offset;
+/* Maximum back reference and backref bitmap. This is updated for numeric
+references during the first pass, but for named references during the actual
+compile pass. The bitmap records up to 31 back references to help in deciding
+whether (.*) can be treated as anchored or not. */
+
+compile_block.top_backref = 0;
+compile_block.backref_map = 0;
+
/* Reflect pattern for debugging output */
DPRINTF(("------------------------------------------------------------------\n"));
@@ -2545,16 +3741,23 @@ DPRINTF(("%s\n", pattern));
/* The first thing to do is to make a pass over the pattern to compute the
amount of store required to hold the compiled code. This does not have to be
perfect as long as errors are overestimates. At the same time we can detect any
-internal flag settings. Make an attempt to correct for any counted white space
-if an "extended" flag setting appears late in the pattern. We can't be so
-clever for #-comments. */
+flag settings right at the start, and extract them. Make an attempt to correct
+for any counted white space if an "extended" flag setting appears late in the
+pattern. We can't be so clever for #-comments. */
ptr = (const uschar *)(pattern - 1);
while ((c = *(++ptr)) != 0)
{
int min, max;
- int class_charcount;
+ int class_optcount;
int bracket_length;
+ int duplength;
+
+ /* If we are inside a \Q...\E sequence, all chars are literal */
+
+ if (inescq) goto NORMAL_CHAR;
+
+ /* Otherwise, first check for ignored whitespace and comments */
if ((options & PCRE_EXTENDED) != 0)
{
@@ -2564,10 +3767,13 @@ while ((c = *(++ptr)) != 0)
/* The space before the ; is to avoid a warning on a silly compiler
on the Macintosh. */
while ((c = *(++ptr)) != 0 && c != NEWLINE) ;
+ if (c == 0) break;
continue;
}
}
+ item_count++; /* Is zero for the first non-comment item */
+
switch(c)
{
/* A backslashed item may be an escaped "normal" character or a
@@ -2587,7 +3793,21 @@ while ((c = *(++ptr)) != 0)
goto NORMAL_CHAR;
}
}
+
+ /* If \Q, enter "literal" mode */
+
+ if (-c == ESC_Q)
+ {
+ inescq = TRUE;
+ continue;
+ }
+
+ /* Other escapes need one byte, and are of length one for repeats */
+
length++;
+#ifdef SUPPORT_UTF8
+ lastcharlength = 1;
+#endif
/* A back reference needs an additional 2 bytes, plus either one or 5
bytes for a repeat. We also need to keep the value of the highest
@@ -2596,7 +3816,9 @@ while ((c = *(++ptr)) != 0)
if (c <= -ESC_REF)
{
int refnum = -c - ESC_REF;
- if (refnum > top_backref) top_backref = refnum;
+ compile_block.backref_map |= (refnum < 32)? (1 << refnum) : 1;
+ if (refnum > compile_block.top_backref)
+ compile_block.top_backref = refnum;
length += 2; /* For single back reference */
if (ptr[1] == '{' && is_counted_repeat(ptr+2, &compile_block))
{
@@ -2611,32 +3833,73 @@ while ((c = *(++ptr)) != 0)
}
continue;
- case '^':
+ case '^': /* Single-byte metacharacters */
case '.':
case '$':
- case '*': /* These repeats won't be after brackets; */
- case '+': /* those are handled separately */
- case '?':
length++;
+#ifdef SUPPORT_UTF8
+ lastcharlength = 1;
+#endif
continue;
- /* This covers the cases of repeats after a single char, metachar, class,
- or back reference. */
+ case '*': /* These repeats won't be after brackets; */
+ case '+': /* those are handled separately */
+ case '?':
+ length++;
+ goto POSESSIVE; /* A few lines below */
+
+ /* This covers the cases of braced repeats after a single char, metachar,
+ class, or back reference. */
case '{':
if (!is_counted_repeat(ptr+1, &compile_block)) goto NORMAL_CHAR;
ptr = read_repeat_counts(ptr+1, &min, &max, errorptr, &compile_block);
if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
+
+ /* These special cases just insert one extra opcode */
+
if ((min == 0 && (max == 1 || max == -1)) ||
(min == 1 && max == -1))
length++;
+
+ /* These cases might insert additional copies of a preceding character. */
+
else
{
- length--; /* Uncount the original char or metachar */
- if (min == 1) length++; else if (min > 0) length += 4;
- if (max > 0) length += 4; else length += 2;
+#ifdef SUPPORT_UTF8
+ /* In UTF-8 mode, we should find the length in lastcharlength */
+ if (utf8)
+ {
+ if (min != 1)
+ {
+ length -= lastcharlength; /* Uncount the original char or metachar */
+ if (min > 0) length += 3 + lastcharlength;
+ }
+ length += lastcharlength + ((max > 0)? 3 : 1);
+ }
+ else
+#endif
+
+ /* Not UTF-8 mode: all characters are one byte */
+ {
+ if (min != 1)
+ {
+ length--; /* Uncount the original char or metachar */
+ if (min > 0) length += 4;
+ }
+
+ length += (max > 0)? 4 : 2;
+ }
+ }
+
+ if (ptr[1] == '?') ptr++; /* Needs no extra length */
+
+ POSESSIVE: /* Test for possessive quantifier */
+ if (ptr[1] == '+')
+ {
+ ptr++;
+ length += 2 + 2*LINK_SIZE; /* Allow for atomic brackets */
}
- if (ptr[1] == '?') ptr++;
continue;
/* An alternation contains an offset to the next branch or ket. If any ims
@@ -2645,34 +3908,154 @@ while ((c = *(++ptr)) != 0)
branch. This is handled by branch_extra. */
case '|':
- length += 3 + branch_extra;
+ length += 1 + LINK_SIZE + branch_extra;
continue;
- /* A character class uses 33 characters. Don't worry about character types
- that aren't allowed in classes - they'll get picked up during the compile.
- A character class that contains only one character uses 2 or 3 bytes,
- depending on whether it is negated or not. Notice this where we can. */
+ /* A character class uses 33 characters provided that all the character
+ values are less than 256. Otherwise, it uses a bit map for low valued
+ characters, and individual items for others. Don't worry about character
+ types that aren't allowed in classes - they'll get picked up during the
+ compile. A character class that contains only one single-byte character
+ uses 2 or 3 bytes, depending on whether it is negated or not. Notice this
+ where we can. (In UTF-8 mode we can do this only for chars < 128.) */
case '[':
- class_charcount = 0;
+ class_optcount = 0;
+
+#ifdef SUPPORT_UTF8
+ class_utf8 = FALSE;
+#endif
+
if (*(++ptr) == '^') ptr++;
- do
+
+ /* Written as a "do" so that an initial ']' is taken as data */
+
+ if (*ptr != 0) do
{
+ /* Inside \Q...\E everything is literal except \E */
+
+ if (inescq)
+ {
+ if (*ptr != '\\' || ptr[1] != 'E') goto NON_SPECIAL_CHARACTER;
+ inescq = FALSE;
+ ptr += 1;
+ continue;
+ }
+
+ /* Outside \Q...\E, check for escapes */
+
if (*ptr == '\\')
{
+#ifdef SUPPORT_UTF8
+ int prevchar = ptr[-1];
+#endif
int ch = check_escape(&ptr, errorptr, bracount, options, TRUE,
&compile_block);
if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
- if (-ch == ESC_b) class_charcount++; else class_charcount = 10;
+
+ /* \b is backspace inside a class */
+
+ if (-ch == ESC_b) ch = '\b';
+
+ /* \Q enters quoting mode */
+
+ if (-ch == ESC_Q)
+ {
+ inescq = TRUE;
+ continue;
+ }
+
+ /* Handle escapes that turn into characters */
+
+ if (ch >= 0)
+ {
+#ifdef SUPPORT_UTF8
+ if (utf8)
+ {
+ if (ch > 127) class_optcount = 10; /* Ensure > 1 */
+ if (ch > 255)
+ {
+ uschar buffer[6];
+ if (!class_utf8)
+ {
+ class_utf8 = TRUE;
+ length += LINK_SIZE + 1 + 1;
+ }
+ length += 1 + ord2utf8(ch, buffer);
+
+ /* If this wide character is preceded by '-', add an extra 2 to
+ the length in case the previous character was < 128, because in
+ this case the whole range will be put into the list. */
+
+ if (prevchar == '-') length += 2;
+ }
+ }
+#endif
+ class_optcount++; /* for possible optimization */
+ }
+ else class_optcount = 10; /* \d, \s etc; make sure > 1 */
+ }
+
+ /* Check the syntax for POSIX stuff. The bits we actually handle are
+ checked during the real compile phase. */
+
+ else if (*ptr == '[' && check_posix_syntax(ptr, &ptr, &compile_block))
+ {
+ ptr++;
+ class_optcount = 10; /* Make sure > 1 */
+ }
+
+ /* Anything else just increments the possible optimization count. If
+ there are wide characters, we are going to have to use an XCLASS. */
+
+ else
+ {
+ NON_SPECIAL_CHARACTER:
+ class_optcount++;
+
+#ifdef SUPPORT_UTF8
+ if (utf8)
+ {
+ int c;
+ int extra = 0;
+ GETCHARLEN(c, ptr, extra);
+ if (c > 127) class_optcount = 10; /* No optimization possible */
+ if (c > 255)
+ {
+ if (!class_utf8)
+ {
+ class_utf8 = TRUE;
+ length += LINK_SIZE + 1 + 1;
+ }
+ length += 2 + extra;
+
+ /* If this wide character is preceded by '-', add an extra 2 to
+ the length in case the previous character was < 128, because in
+ this case the whole range will be put into the list. */
+
+ if (ptr[-1] == '-') length += 2;
+
+ /* Advance to the end of this character */
+
+ ptr += extra;
+ }
+ }
+#endif
}
- else class_charcount++;
- ptr++;
}
- while (*ptr != 0 && *ptr != ']');
+ while (*(++ptr) != 0 && (inescq || *ptr != ']')); /* Concludes "do" above */
- /* Repeats for negated single chars are handled by the general code */
+ if (*ptr == 0) /* Missing terminating ']' */
+ {
+ *errorptr = ERR6;
+ goto PCRE_ERROR_RETURN;
+ }
- if (class_charcount == 1) length += 3; else
+ /* We can optimize when there was only one optimizable character. Repeats
+ for positive and negated single one-byte chars are handled by the general
+ code. Here, we handle repeats for the class opcodes. */
+
+ if (class_optcount == 1) length += 3; else
{
length += 33;
@@ -2695,7 +4078,7 @@ while ((c = *(++ptr)) != 0)
case '(':
branch_newextra = 0;
- bracket_length = 3;
+ bracket_length = 1 + LINK_SIZE;
/* Handle special forms of bracket, which all start (? */
@@ -2729,27 +4112,98 @@ while ((c = *(++ptr)) != 0)
ptr += 2;
break;
- /* A recursive call to the regex is an extension, to provide the
- facility which can be obtained by $(?p{perl-code}) in Perl 5.6. */
+ /* (?R) specifies a recursive call to the regex, which is an extension
+ to provide the facility which can be obtained by (?p{perl-code}) in
+ Perl 5.6. In Perl 5.8 this has become (??{perl-code}).
+
+ From PCRE 4.00, items such as (?3) specify subroutine-like "calls" to
+ the appropriate numbered brackets. This includes both recursive and
+ non-recursive calls. (?R) is now synonymous with (?0). */
case 'R':
- if (ptr[3] != ')')
+ ptr++;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ ptr += 2;
+ if (c != 'R')
+ while ((compile_block.ctypes[*(++ptr)] & ctype_digit) != 0);
+ if (*ptr != ')')
{
*errorptr = ERR29;
goto PCRE_ERROR_RETURN;
}
+ length += 1 + LINK_SIZE;
+
+ /* If this item is quantified, it will get wrapped inside brackets so
+ as to use the code for quantified brackets. We jump down and use the
+ code that handles this for real brackets. */
+
+ if (ptr[1] == '+' || ptr[1] == '*' || ptr[1] == '?' || ptr[1] == '{')
+ {
+ length += 2 + 2 * LINK_SIZE; /* to make bracketed */
+ duplength = 5 + 3 * LINK_SIZE;
+ goto HANDLE_QUANTIFIED_BRACKETS;
+ }
+ continue;
+
+ /* (?C) is an extension which provides "callout" - to provide a bit of
+ the functionality of the Perl (?{...}) feature. An optional number may
+ follow (default is zero). */
+
+ case 'C':
+ ptr += 2;
+ while ((compile_block.ctypes[*(++ptr)] & ctype_digit) != 0);
+ if (*ptr != ')')
+ {
+ *errorptr = ERR39;
+ goto PCRE_ERROR_RETURN;
+ }
+ length += 2;
+ continue;
+
+ /* Named subpatterns are an extension copied from Python */
+
+ case 'P':
ptr += 3;
- length += 1;
- break;
+ if (*ptr == '<')
+ {
+ const uschar *p = ++ptr;
+ while ((compile_block.ctypes[*ptr] & ctype_word) != 0) ptr++;
+ if (*ptr != '>')
+ {
+ *errorptr = ERR42;
+ goto PCRE_ERROR_RETURN;
+ }
+ name_count++;
+ if (ptr - p > max_name_size) max_name_size = (ptr - p);
+ break;
+ }
+
+ if (*ptr == '=' || *ptr == '>')
+ {
+ while ((compile_block.ctypes[*(++ptr)] & ctype_word) != 0);
+ if (*ptr != ')')
+ {
+ *errorptr = ERR42;
+ goto PCRE_ERROR_RETURN;
+ }
+ break;
+ }
+
+ /* Unknown character after (?P */
+
+ *errorptr = ERR41;
+ goto PCRE_ERROR_RETURN;
/* Lookbehinds are in Perl from version 5.005 */
case '<':
- if (ptr[3] == '=' || ptr[3] == '!')
+ ptr += 3;
+ if (*ptr == '=' || *ptr == '!')
{
- ptr += 3;
- branch_newextra = 3;
- length += 3; /* For the first branch */
+ branch_newextra = 1 + LINK_SIZE;
+ length += 1 + LINK_SIZE; /* For the first branch */
break;
}
*errorptr = ERR24;
@@ -2757,10 +4211,15 @@ while ((c = *(++ptr)) != 0)
/* Conditionals are in Perl from version 5.005. The bracket must either
be followed by a number (for bracket reference) or by an assertion
- group. */
+ group, or (a PCRE extension) by 'R' for a recursion test. */
case '(':
- if ((compile_block.ctypes[ptr[3]] & ctype_digit) != 0)
+ if (ptr[3] == 'R' && ptr[4] == ')')
+ {
+ ptr += 4;
+ length += 3;
+ }
+ else if ((compile_block.ctypes[ptr[3]] & ctype_digit) != 0)
{
ptr += 4;
length += 3;
@@ -2827,17 +4286,27 @@ while ((c = *(++ptr)) != 0)
optset = &unset;
continue;
- /* A termination by ')' indicates an options-setting-only item;
- this is global at top level; otherwise nothing is done here and
- it is handled during the compiling process on a per-bracket-group
- basis. */
+ /* A termination by ')' indicates an options-setting-only item; if
+ this is at the very start of the pattern (indicated by item_count
+ being zero), we use it to set the global options. This is helpful
+ when analyzing the pattern for first characters, etc. Otherwise
+ nothing is done here and it is handled during the compiling
+ process.
+
+ [Historical note: Up to Perl 5.8, options settings at top level
+ were always global settings, wherever they appeared in the pattern.
+ That is, they were equivalent to an external setting. From 5.8
+ onwards, they apply only to what follows (which is what you might
+ expect).] */
case ')':
- if (brastackptr == 0)
+ if (item_count == 0)
{
options = (options | set) & (~unset);
set = unset = 0; /* To save length */
+ item_count--; /* To allow for several */
}
+
/* Fall through */
/* A termination by ':' indicates the start of a nested group with
@@ -2879,7 +4348,8 @@ while ((c = *(++ptr)) != 0)
END_OPTIONS:
if (c == ')')
{
- if (branch_newextra == 2 && (branch_extra == 0 || branch_extra == 3))
+ if (branch_newextra == 2 &&
+ (branch_extra == 0 || branch_extra == 1+LINK_SIZE))
branch_extra += branch_newextra;
continue;
}
@@ -2891,9 +4361,11 @@ while ((c = *(++ptr)) != 0)
/* Extracting brackets must be counted so we can process escapes in a
Perlish way. If the number exceeds EXTRACT_BASIC_MAX we are going to
- need an additional 3 bytes of store per extracting bracket. */
+ need an additional 3 bytes of store per extracting bracket. However, if
+ PCRE_NO_AUTO)CAPTURE is set, unadorned brackets become non-capturing, so we
+ must leave the count alone (it will aways be zero). */
- else
+ else if ((options & PCRE_NO_AUTO_CAPTURE) == 0)
{
bracount++;
if (bracount > EXTRACT_BASIC_MAX) bracket_length += 3;
@@ -2924,62 +4396,72 @@ while ((c = *(++ptr)) != 0)
the branch_extra value. */
case ')':
- length += 3;
+ length += 1 + LINK_SIZE;
+ if (brastackptr > 0)
{
- int minval = 1;
- int maxval = 1;
- int duplength;
+ duplength = length - brastack[--brastackptr];
+ branch_extra = bralenstack[brastackptr];
+ }
+ else duplength = 0;
- if (brastackptr > 0)
- {
- duplength = length - brastack[--brastackptr];
- branch_extra = bralenstack[brastackptr];
- }
- else duplength = 0;
+ /* The following code is also used when a recursion such as (?3) is
+ followed by a quantifier, because in that case, it has to be wrapped inside
+ brackets so that the quantifier works. The value of duplength must be
+ set before arrival. */
- /* Leave ptr at the final char; for read_repeat_counts this happens
- automatically; for the others we need an increment. */
+ HANDLE_QUANTIFIED_BRACKETS:
- if ((c = ptr[1]) == '{' && is_counted_repeat(ptr+2, &compile_block))
- {
- ptr = read_repeat_counts(ptr+2, &minval, &maxval, errorptr,
- &compile_block);
- if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
- }
- else if (c == '*') { minval = 0; maxval = -1; ptr++; }
- else if (c == '+') { maxval = -1; ptr++; }
- else if (c == '?') { minval = 0; ptr++; }
+ /* Leave ptr at the final char; for read_repeat_counts this happens
+ automatically; for the others we need an increment. */
- /* If the minimum is zero, we have to allow for an OP_BRAZERO before the
- group, and if the maximum is greater than zero, we have to replicate
- maxval-1 times; each replication acquires an OP_BRAZERO plus a nesting
- bracket set - hence the 7. */
+ if ((c = ptr[1]) == '{' && is_counted_repeat(ptr+2, &compile_block))
+ {
+ ptr = read_repeat_counts(ptr+2, &min, &max, errorptr, &compile_block);
+ if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
+ }
+ else if (c == '*') { min = 0; max = -1; ptr++; }
+ else if (c == '+') { min = 1; max = -1; ptr++; }
+ else if (c == '?') { min = 0; max = 1; ptr++; }
+ else { min = 1; max = 1; }
- if (minval == 0)
- {
- length++;
- if (maxval > 0) length += (maxval - 1) * (duplength + 7);
- }
+ /* If the minimum is zero, we have to allow for an OP_BRAZERO before the
+ group, and if the maximum is greater than zero, we have to replicate
+ maxval-1 times; each replication acquires an OP_BRAZERO plus a nesting
+ bracket set. */
- /* When the minimum is greater than zero, 1 we have to replicate up to
- minval-1 times, with no additions required in the copies. Then, if
- there is a limited maximum we have to replicate up to maxval-1 times
- allowing for a BRAZERO item before each optional copy and nesting
- brackets for all but one of the optional copies. */
+ if (min == 0)
+ {
+ length++;
+ if (max > 0) length += (max - 1) * (duplength + 3 + 2*LINK_SIZE);
+ }
- else
- {
- length += (minval - 1) * duplength;
- if (maxval > minval) /* Need this test as maxval=-1 means no limit */
- length += (maxval - minval) * (duplength + 7) - 6;
- }
+ /* When the minimum is greater than zero, we have to replicate up to
+ minval-1 times, with no additions required in the copies. Then, if there
+ is a limited maximum we have to replicate up to maxval-1 times allowing
+ for a BRAZERO item before each optional copy and nesting brackets for all
+ but one of the optional copies. */
+
+ else
+ {
+ length += (min - 1) * duplength;
+ if (max > min) /* Need this test as max=-1 means no limit */
+ length += (max - min) * (duplength + 3 + 2*LINK_SIZE)
+ - (2 + 2*LINK_SIZE);
+ }
+
+ /* Allow space for once brackets for "possessive quantifier" */
+
+ if (ptr[1] == '+')
+ {
+ ptr++;
+ length += 2 + 2*LINK_SIZE;
}
continue;
/* Non-special character. For a run of such characters the length required
- is the number of characters + 2, except that the maximum run length is 255.
- We won't get a skipped space or a non-data escape or the start of a #
- comment as the first character, so the length can't be zero. */
+ is the number of characters + 2, except that the maximum run length is
+ MAXLIT. We won't get a skipped space or a non-data escape or the start of a
+ # comment as the first character, so the length can't be zero. */
NORMAL_CHAR:
default:
@@ -2987,6 +4469,24 @@ while ((c = *(++ptr)) != 0)
runlength = 0;
do
{
+#ifdef SUPPORT_UTF8
+ lastcharlength = 1; /* Need length of last char for UTF-8 repeats */
+#endif
+
+ /* If in a \Q...\E sequence, check for end; otherwise it's a literal */
+ if (inescq)
+ {
+ if (c == '\\' && ptr[1] == 'E')
+ {
+ inescq = FALSE;
+ ptr++;
+ }
+ else runlength++;
+ continue;
+ }
+
+ /* Skip whitespace and comments for /x */
+
if ((options & PCRE_EXTENDED) != 0)
{
if ((compile_block.ctypes[c] & ctype_space) != 0) continue;
@@ -3010,13 +4510,18 @@ while ((c = *(++ptr)) != 0)
if (*errorptr != NULL) goto PCRE_ERROR_RETURN;
if (c < 0) { ptr = saveptr; break; }
+ /* In UTF-8 mode, add on the number of additional bytes needed to
+ encode this character, and save the total length in case this is a
+ final char that is repeated. */
+
#ifdef SUPPORT_UTF8
- if (c > 127 && (options & PCRE_UTF8) != 0)
+ if (utf8 && c > 127)
{
int i;
for (i = 0; i < sizeof(utf8_table1)/sizeof(int); i++)
if (c <= utf8_table1[i]) break;
runlength += i;
+ lastcharlength += i;
}
#endif
}
@@ -3031,27 +4536,44 @@ while ((c = *(++ptr)) != 0)
while (runlength < MAXLIT &&
(compile_block.ctypes[c = *(++ptr)] & ctype_meta) == 0);
- ptr--;
+ /* If we hit a meta-character, back off to point to it */
+
+ if (runlength < MAXLIT) ptr--;
+
+ /* If the last char in the string is a UTF-8 multibyte character, we must
+ set lastcharlength correctly. If it was specified as an escape, this will
+ already have been done above. However, we also have to support in-line
+ UTF-8 characters, so check backwards from where we are. */
+
+#ifdef SUPPORT_UTF8
+ if (utf8)
+ {
+ const uschar *lastptr = ptr - 1;
+ if ((*lastptr & 0x80) != 0)
+ {
+ while((*lastptr & 0xc0) == 0x80) lastptr--;
+ lastcharlength = ptr - lastptr;
+ }
+ }
+#endif
+
length += runlength;
continue;
}
}
-length += 4; /* For final KET and END */
+length += 2 + LINK_SIZE; /* For final KET and END */
-if (length > 65539)
+if (length > MAX_PATTERN_SIZE)
{
*errorptr = ERR20;
return NULL;
}
/* Compute the size of data block needed and get it, either from malloc or
-externally provided function. We specify "code[0]" in the offsetof() expression
-rather than just "code", because it has been reported that one broken compiler
-fails on "code" because it is also an independent variable. It should make no
-difference to the value of the offsetof(). */
+externally provided function. */
-size = length + offsetof(real_pcre, code[0]);
+size = length + sizeof(real_pcre) + name_count * (max_name_size + 3);
re = (real_pcre *)(pcre_malloc)(size);
if (re == NULL)
@@ -3066,19 +4588,30 @@ re->magic_number = MAGIC_NUMBER;
re->size = size;
re->options = options;
re->tables = tables;
+re->name_entry_size = max_name_size + 3;
+re->name_count = name_count;
+
+/* The starting points of the name/number translation table and of the code are
+passed around in the compile data block. */
+
+compile_block.names_found = 0;
+compile_block.name_entry_size = max_name_size + 3;
+compile_block.name_table = (uschar *)re + sizeof(real_pcre);
+codestart = compile_block.name_table + re->name_entry_size * re->name_count;
+compile_block.start_code = codestart;
/* Set up a starting, non-extracting bracket, then compile the expression. On
error, *errorptr will be set non-NULL, so we don't need to look at the result
of the function here. */
ptr = (const uschar *)pattern;
-code = re->code;
+code = (uschar *)codestart;
*code = OP_BRA;
bracount = 0;
-(void)compile_regex(options, -1, &bracount, &code, &ptr, errorptr, FALSE, 0,
- &reqchar, &countlits, &compile_block);
+(void)compile_regex(options, options & PCRE_IMS, &bracount, &code, &ptr,
+ errorptr, FALSE, 0, &firstbyte, &reqbyte, NULL, &compile_block);
re->top_bracket = bracount;
-re->top_backref = top_backref;
+re->top_backref = compile_block.top_backref;
/* If not reached end of pattern on success, there's an excess bracket. */
@@ -3090,15 +4623,15 @@ if debugging, leave the test till after things are printed out. */
*code++ = OP_END;
#ifndef DEBUG
-if (code - re->code > length) *errorptr = ERR23;
+if (code - codestart > length) *errorptr = ERR23;
#endif
/* Give an error if there's back reference to a non-existent capturing
subpattern. */
-if (top_backref > re->top_bracket) *errorptr = ERR15;
+if (re->top_backref > re->top_bracket) *errorptr = ERR15;
-/* Failed to compile */
+/* Failed to compile, or error while post-processing */
if (*errorptr != NULL)
{
@@ -3108,12 +4641,12 @@ if (*errorptr != NULL)
return NULL;
}
-/* If the anchored option was not passed, set flag if we can determine that the
-pattern is anchored by virtue of ^ characters or \A or anything else (such as
-starting with .* when DOTALL is set).
+/* If the anchored option was not passed, set the flag if we can determine that
+the pattern is anchored by virtue of ^ characters or \A or anything else (such
+as starting with .* when DOTALL is set).
-Otherwise, see if we can determine what the first character has to be, because
-that speeds up unanchored matches no end. If not, see if we can set the
+Otherwise, if we know what the first character has to be, save it, because that
+speeds up unanchored matches no end. If not, see if we can set the
PCRE_STARTLINE flag. This is helpful for multiline matches when all branches
start with ^. and also when all branches start with .* for non-DOTALL matches.
*/
@@ -3121,27 +4654,35 @@ start with ^. and also when all branches start with .* for non-DOTALL matches.
if ((options & PCRE_ANCHORED) == 0)
{
int temp_options = options;
- if (is_anchored(re->code, &temp_options))
+ if (is_anchored(codestart, &temp_options, 0, compile_block.backref_map))
re->options |= PCRE_ANCHORED;
else
{
- int ch = find_firstchar(re->code, &temp_options);
- if (ch >= 0)
+ if (firstbyte < 0)
+ firstbyte = find_firstassertedchar(codestart, &temp_options, FALSE);
+ if (firstbyte >= 0) /* Remove caseless flag for non-caseable chars */
{
- re->first_char = ch;
+ int ch = firstbyte & 255;
+ re->first_byte = ((firstbyte & REQ_CASELESS) != 0 &&
+ compile_block.fcc[ch] == ch)? ch : firstbyte;
re->options |= PCRE_FIRSTSET;
}
- else if (is_startline(re->code))
+ else if (is_startline(codestart, 0, compile_block.backref_map))
re->options |= PCRE_STARTLINE;
}
}
-/* Save the last required character if there are at least two literal
-characters on all paths, or if there is no first character setting. */
+/* Save the last required character if any. Remove caseless flag for
+non-caseable chars. */
-if (reqchar >= 0 && (countlits > 1 || (re->options & PCRE_FIRSTSET) == 0))
+if ((re->options & PCRE_ANCHORED) != 0 && reqbyte < 0 && firstbyte >= 0)
+ reqbyte = firstbyte;
+
+if (reqbyte >= 0)
{
- re->req_char = reqchar;
+ int ch = reqbyte & 255;
+ re->req_byte = ((reqbyte & REQ_CASELESS) != 0 &&
+ compile_block.fcc[ch] == ch)? (reqbyte & ~REQ_CASELESS) : reqbyte;
re->options |= PCRE_REQCHSET;
}
@@ -3168,209 +4709,26 @@ if (re->options != 0)
if ((re->options & PCRE_FIRSTSET) != 0)
{
- if (isprint(re->first_char)) printf("First char = %c\n", re->first_char);
- else printf("First char = \\x%02x\n", re->first_char);
+ int ch = re->first_byte & 255;
+ char *caseless = ((re->first_byte & REQ_CASELESS) == 0)? "" : " (caseless)";
+ if (isprint(ch)) printf("First char = %c%s\n", ch, caseless);
+ else printf("First char = \\x%02x%s\n", ch, caseless);
}
if ((re->options & PCRE_REQCHSET) != 0)
{
- if (isprint(re->req_char)) printf("Req char = %c\n", re->req_char);
- else printf("Req char = \\x%02x\n", re->req_char);
+ int ch = re->req_byte & 255;
+ char *caseless = ((re->req_byte & REQ_CASELESS) == 0)? "" : " (caseless)";
+ if (isprint(ch)) printf("Req char = %c%s\n", ch, caseless);
+ else printf("Req char = \\x%02x%s\n", ch, caseless);
}
-code_end = code;
-code_base = code = re->code;
-
-while (code < code_end)
- {
- int charlength;
-
- printf("%3d ", code - code_base);
-
- if (*code >= OP_BRA)
- {
- if (*code - OP_BRA > EXTRACT_BASIC_MAX)
- printf("%3d Bra extra", (code[1] << 8) + code[2]);
- else
- printf("%3d Bra %d", (code[1] << 8) + code[2], *code - OP_BRA);
- code += 2;
- }
-
- else switch(*code)
- {
- case OP_OPT:
- printf(" %.2x %s", code[1], OP_names[*code]);
- code++;
- break;
-
- case OP_CHARS:
- charlength = *(++code);
- printf("%3d ", charlength);
- while (charlength-- > 0)
- if (isprint(c = *(++code))) printf("%c", c); else printf("\\x%02x", c);
- break;
-
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_ALT:
- case OP_KET:
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- case OP_REVERSE:
- case OP_BRANUMBER:
- case OP_COND:
- case OP_CREF:
- printf("%3d %s", (code[1] << 8) + code[2], OP_names[*code]);
- code += 2;
- break;
-
- case OP_STAR:
- case OP_MINSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- if (*code >= OP_TYPESTAR)
- printf(" %s", OP_names[code[1]]);
- else if (isprint(c = code[1])) printf(" %c", c);
- else printf(" \\x%02x", c);
- printf("%s", OP_names[*code++]);
- break;
-
- case OP_EXACT:
- case OP_UPTO:
- case OP_MINUPTO:
- if (isprint(c = code[3])) printf(" %c{", c);
- else printf(" \\x%02x{", c);
- if (*code != OP_EXACT) printf("0,");
- printf("%d}", (code[1] << 8) + code[2]);
- if (*code == OP_MINUPTO) printf("?");
- code += 3;
- break;
-
- case OP_TYPEEXACT:
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- printf(" %s{", OP_names[code[3]]);
- if (*code != OP_TYPEEXACT) printf(",");
- printf("%d}", (code[1] << 8) + code[2]);
- if (*code == OP_TYPEMINUPTO) printf("?");
- code += 3;
- break;
-
- case OP_NOT:
- if (isprint(c = *(++code))) printf(" [^%c]", c);
- else printf(" [^\\x%02x]", c);
- break;
-
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- if (isprint(c = code[1])) printf(" [^%c]", c);
- else printf(" [^\\x%02x]", c);
- printf("%s", OP_names[*code++]);
- break;
-
- case OP_NOTEXACT:
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- if (isprint(c = code[3])) printf(" [^%c]{", c);
- else printf(" [^\\x%02x]{", c);
- if (*code != OP_NOTEXACT) printf(",");
- printf("%d}", (code[1] << 8) + code[2]);
- if (*code == OP_NOTMINUPTO) printf("?");
- code += 3;
- break;
-
- case OP_REF:
- printf(" \\%d", (code[1] << 8) | code[2]);
- code += 3;
- goto CLASS_REF_REPEAT;
-
- case OP_CLASS:
- {
- int i, min, max;
- code++;
- printf(" [");
-
- for (i = 0; i < 256; i++)
- {
- if ((code[i/8] & (1 << (i&7))) != 0)
- {
- int j;
- for (j = i+1; j < 256; j++)
- if ((code[j/8] & (1 << (j&7))) == 0) break;
- if (i == '-' || i == ']') printf("\\");
- if (isprint(i)) printf("%c", i); else printf("\\x%02x", i);
- if (--j > i)
- {
- printf("-");
- if (j == '-' || j == ']') printf("\\");
- if (isprint(j)) printf("%c", j); else printf("\\x%02x", j);
- }
- i = j;
- }
- }
- printf("]");
- code += 32;
-
- CLASS_REF_REPEAT:
-
- switch(*code)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- printf("%s", OP_names[*code]);
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- min = (code[1] << 8) + code[2];
- max = (code[3] << 8) + code[4];
- if (max == 0) printf("{%d,}", min);
- else printf("{%d,%d}", min, max);
- if (*code == OP_CRMINRANGE) printf("?");
- code += 4;
- break;
-
- default:
- code--;
- }
- }
- break;
-
- /* Anything else is just a one-node item */
-
- default:
- printf(" %s", OP_names[*code]);
- break;
- }
-
- code++;
- printf("\n");
- }
-printf("------------------------------------------------------------------\n");
+print_internals(re, stdout);
/* This check is done here in the debugging case so that the code that
was compiled can be seen. */
-if (code - re->code > length)
+if (code - codestart > length)
{
*errorptr = ERR23;
(pcre_free)(re);
@@ -3438,6 +4796,63 @@ return TRUE;
}
+#ifdef SUPPORT_UTF8
+/*************************************************
+* Match character against an XCLASS *
+*************************************************/
+
+/* This function is called from within the XCLASS code below, to match a
+character against an extended class which might match values > 255.
+
+Arguments:
+ c the character
+ data points to the flag byte of the XCLASS data
+
+Returns: TRUE if character matches, else FALSE
+*/
+
+static BOOL
+match_xclass(int c, const uschar *data)
+{
+int t;
+BOOL negated = (*data & XCL_NOT) != 0;
+
+/* Character values < 256 are matched against a bitmap, if one is present. If
+not, we still carry on, because there may be ranges that start below 256 in the
+additional data. */
+
+if (c < 256)
+ {
+ if ((*data & XCL_MAP) != 0 && (data[1 + c/8] & (1 << (c&7))) != 0)
+ return !negated; /* char found */
+ }
+
+/* Now match against the list of large chars or ranges that end with a large
+char. First skip the bit map if present. */
+
+if ((*data++ & XCL_MAP) != 0) data += 32;
+
+while ((t = *data++) != XCL_END)
+ {
+ int x, y;
+ GETCHARINC(x, data);
+ if (t == XCL_SINGLE)
+ {
+ if (c == x) return !negated;
+ }
+ else
+ {
+ GETCHARINC(y, data);
+ if (c >= x && c <= y) return !negated;
+ }
+ }
+
+return negated; /* char was not found */
+}
+#endif
+
+
+
/*************************************************
* Match from current position *
@@ -3446,7 +4861,14 @@ return TRUE;
/* On entry ecode points to the first opcode, and eptr to the first character
in the subject string, while eptrb holds the value of eptr at the start of the
last bracketed group - used for breaking infinite loops matching zero-length
-strings.
+strings. This function is called recursively in many circumstances. Whenever it
+returns a negative (error) response, the outer incarnation must also return the
+same response.
+
+Performance note: It might be tempting to extract commonly used fields from the
+md structure (e.g. utf8, end_subject) into individual variables to improve
+performance. Tests using gcc on a SPARC disproved this; in the first case, it
+made performance worse.
Arguments:
eptr pointer in subject
@@ -3460,17 +4882,23 @@ Arguments:
match_condassert - this is an assertion condition
match_isgroup - this is the start of a bracketed group
-Returns: TRUE if matched
+Returns: MATCH_MATCH if matched ) these values are >= 0
+ MATCH_NOMATCH if failed to match )
+ a negative PCRE_ERROR_xxx value if aborted by an error condition
+ (e.g. stopped by recursion limit)
*/
-static BOOL
+static int
match(register const uschar *eptr, register const uschar *ecode,
int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,
int flags)
{
unsigned long int original_ims = ims; /* Save for resetting on ')' */
+register int rrc;
eptrblock newptrb;
+if (md->match_call_count++ >= md->match_limit) return PCRE_ERROR_MATCHLIMIT;
+
/* At the start of a bracketed group, add the current subject pointer to the
stack of such pointers, to be re-instated at the end of the group when we hit
the closing ket. When match() is called in other circumstances, we don't add to
@@ -3515,7 +4943,8 @@ for (;;)
/* For extended extraction brackets (large number), we have to fish out the
number from a dummy opcode at the start. */
- if (number > EXTRACT_BASIC_MAX) number = (ecode[4] << 8) | ecode[5];
+ if (number > EXTRACT_BASIC_MAX)
+ number = GET2(ecode, 2+LINK_SIZE);
offset = number << 1;
#ifdef DEBUG
@@ -3529,15 +4958,17 @@ for (;;)
int save_offset1 = md->offset_vector[offset];
int save_offset2 = md->offset_vector[offset+1];
int save_offset3 = md->offset_vector[md->offset_end - number];
+ int save_capture_last = md->capture_last;
DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
do
{
- if (match(eptr, ecode+3, offset_top, md, ims, eptrb, match_isgroup))
- return TRUE;
- ecode += (ecode[1] << 8) + ecode[2];
+ if ((rrc = match(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims,
+ eptrb, match_isgroup)) != MATCH_NOMATCH) return rrc;
+ md->capture_last = save_capture_last;
+ ecode += GET(ecode, 1);
}
while (*ecode == OP_ALT);
@@ -3547,7 +4978,7 @@ for (;;)
md->offset_vector[offset+1] = save_offset2;
md->offset_vector[md->offset_end - number] = save_offset3;
- return FALSE;
+ return MATCH_NOMATCH;
}
/* Insufficient room for saving captured contents */
@@ -3563,13 +4994,13 @@ for (;;)
DPRINTF(("start bracket 0\n"));
do
{
- if (match(eptr, ecode+3, offset_top, md, ims, eptrb, match_isgroup))
- return TRUE;
- ecode += (ecode[1] << 8) + ecode[2];
+ if ((rrc = match(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
+ match_isgroup)) != MATCH_NOMATCH) return rrc;
+ ecode += GET(ecode, 1);
}
while (*ecode == OP_ALT);
DPRINTF(("bracket 0 failed\n"));
- return FALSE;
+ return MATCH_NOMATCH;
/* Conditional group: compilation checked that there are no more than
two branches. If the condition is false, skipping the first branch takes us
@@ -3577,12 +5008,14 @@ for (;;)
exactly what going to the ket would do. */
case OP_COND:
- if (ecode[3] == OP_CREF) /* Condition is extraction test */
+ if (ecode[LINK_SIZE+1] == OP_CREF) /* Condition extract or recurse test */
{
- int offset = (ecode[4] << 9) | (ecode[5] << 1); /* Doubled ref number */
- return match(eptr,
- ecode + ((offset < offset_top && md->offset_vector[offset] >= 0)?
- 6 : 3 + (ecode[1] << 8) + ecode[2]),
+ int offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */
+ BOOL condition = (offset == CREF_RECURSE * 2)?
+ (md->recursive != NULL) :
+ (offset < offset_top && md->offset_vector[offset] >= 0);
+ return match(eptr, ecode + (condition?
+ (LINK_SIZE + 4) : (LINK_SIZE + 1 + GET(ecode, 1))),
offset_top, md, ims, eptrb, match_isgroup);
}
@@ -3591,14 +5024,16 @@ for (;;)
else
{
- if (match(eptr, ecode+3, offset_top, md, ims, NULL,
- match_condassert | match_isgroup))
+ if ((rrc = match(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
+ match_condassert | match_isgroup)) == MATCH_MATCH)
{
- ecode += 3 + (ecode[4] << 8) + ecode[5];
- while (*ecode == OP_ALT) ecode += (ecode[1] << 8) + ecode[2];
+ ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE+2);
+ while (*ecode == OP_ALT) ecode += GET(ecode, 1);
}
- else ecode += (ecode[1] << 8) + ecode[2];
- return match(eptr, ecode+3, offset_top, md, ims, eptrb, match_isgroup);
+ else if (rrc != MATCH_NOMATCH) return rrc;
+ else ecode += GET(ecode, 1);
+ return match(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,
+ match_isgroup);
}
/* Control never reaches here */
@@ -3610,14 +5045,30 @@ for (;;)
ecode += 3;
break;
- /* End of the pattern. If PCRE_NOTEMPTY is set, fail if we have matched
- an empty string - recursion will then try other alternatives, if any. */
+ /* End of the pattern. If we are in a recursion, we should restore the
+ offsets appropriately and continue from after the call. */
case OP_END:
- if (md->notempty && eptr == md->start_match) return FALSE;
+ if (md->recursive != NULL && md->recursive->group_num == 0)
+ {
+ recursion_info *rec = md->recursive;
+ DPRINTF(("Hit the end in a (?0) recursion\n"));
+ md->recursive = rec->prev;
+ memmove(md->offset_vector, rec->offset_save,
+ rec->saved_max * sizeof(int));
+ md->start_match = rec->save_start;
+ ims = original_ims;
+ ecode = rec->after_call;
+ break;
+ }
+
+ /* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty
+ string - backtracking will then try other alternatives, if any. */
+
+ if (md->notempty && eptr == md->start_match) return MATCH_NOMATCH;
md->end_match_ptr = eptr; /* Record where we ended */
md->end_offset_top = offset_top; /* and how many extracts were taken */
- return TRUE;
+ return MATCH_MATCH;
/* Change option settings */
@@ -3637,21 +5088,23 @@ for (;;)
case OP_ASSERTBACK:
do
{
- if (match(eptr, ecode+3, offset_top, md, ims, NULL, match_isgroup)) break;
- ecode += (ecode[1] << 8) + ecode[2];
+ if ((rrc = match(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
+ match_isgroup)) == MATCH_MATCH) break;
+ if (rrc != MATCH_NOMATCH) return rrc;
+ ecode += GET(ecode, 1);
}
while (*ecode == OP_ALT);
- if (*ecode == OP_KET) return FALSE;
+ if (*ecode == OP_KET) return MATCH_NOMATCH;
- /* If checking an assertion for a condition, return TRUE. */
+ /* If checking an assertion for a condition, return MATCH_MATCH. */
- if ((flags & match_condassert) != 0) return TRUE;
+ if ((flags & match_condassert) != 0) return MATCH_MATCH;
/* Continue from after the assertion, updating the offsets high water
mark, since extracts may have been taken during the assertion. */
- do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT);
- ecode += 3;
+ do ecode += GET(ecode,1); while (*ecode == OP_ALT);
+ ecode += 1 + LINK_SIZE;
offset_top = md->end_offset_top;
continue;
@@ -3661,15 +5114,16 @@ for (;;)
case OP_ASSERTBACK_NOT:
do
{
- if (match(eptr, ecode+3, offset_top, md, ims, NULL, match_isgroup))
- return FALSE;
- ecode += (ecode[1] << 8) + ecode[2];
+ if ((rrc = match(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
+ match_isgroup)) == MATCH_MATCH) return MATCH_NOMATCH;
+ if (rrc != MATCH_NOMATCH) return rrc;
+ ecode += GET(ecode,1);
}
while (*ecode == OP_ALT);
- if ((flags & match_condassert) != 0) return TRUE;
+ if ((flags & match_condassert) != 0) return MATCH_MATCH;
- ecode += 3;
+ ecode += 1 + LINK_SIZE;
continue;
/* Move the subject pointer back. This occurs only at the start of
@@ -3679,75 +5133,144 @@ for (;;)
case OP_REVERSE:
#ifdef SUPPORT_UTF8
- c = (ecode[1] << 8) + ecode[2];
+ c = GET(ecode,1);
for (i = 0; i < c; i++)
{
eptr--;
BACKCHAR(eptr)
}
#else
- eptr -= (ecode[1] << 8) + ecode[2];
+ eptr -= GET(ecode,1);
#endif
- if (eptr < md->start_subject) return FALSE;
- ecode += 3;
+ if (eptr < md->start_subject) return MATCH_NOMATCH;
+ ecode += 1 + LINK_SIZE;
+ break;
+
+ /* The callout item calls an external function, if one is provided, passing
+ details of the match so far. This is mainly for debugging, though the
+ function is able to force a failure. */
+
+ case OP_CALLOUT:
+ if (pcre_callout != NULL)
+ {
+ pcre_callout_block cb;
+ cb.version = 0; /* Version 0 of the callout block */
+ cb.callout_number = ecode[1];
+ cb.offset_vector = md->offset_vector;
+ cb.subject = (const char *)md->start_subject;
+ cb.subject_length = md->end_subject - md->start_subject;
+ cb.start_match = md->start_match - md->start_subject;
+ cb.current_position = eptr - md->start_subject;
+ cb.capture_top = offset_top/2;
+ cb.capture_last = md->capture_last;
+ cb.callout_data = md->callout_data;
+ if ((rrc = (*pcre_callout)(&cb)) > 0) return MATCH_NOMATCH;
+ if (rrc < 0) return rrc;
+ }
+ ecode += 2;
break;
- /* Recursion matches the current regex, nested. If there are any capturing
- brackets started but not finished, we have to save their starting points
- and reinstate them after the recursion. However, we don't know how many
- such there are (offset_top records the completed total) so we just have
- to save all the potential data. There may be up to 99 such values, which
- is a bit large to put on the stack, but using malloc for small numbers
- seems expensive. As a compromise, the stack is used when there are fewer
- than 16 values to store; otherwise malloc is used. A problem is what to do
- if the malloc fails ... there is no way of returning to the top level with
- an error. Save the top 15 values on the stack, and accept that the rest
- may be wrong. */
+ /* Recursion either matches the current regex, or some subexpression. The
+ offset data is the offset to the starting bracket from the start of the
+ whole pattern. However, it is possible that a BRAZERO was inserted before
+ this bracket after we took the offset - we just skip it if encountered.
+
+ If there are any capturing brackets started but not finished, we have to
+ save their starting points and reinstate them after the recursion. However,
+ we don't know how many such there are (offset_top records the completed
+ total) so we just have to save all the potential data. There may be up to
+ 65535 such values, which is too large to put on the stack, but using malloc
+ for small numbers seems expensive. As a compromise, the stack is used when
+ there are no more than REC_STACK_SAVE_MAX values to store; otherwise malloc
+ is used. A problem is what to do if the malloc fails ... there is no way of
+ returning to the top level with an error. Save the top REC_STACK_SAVE_MAX
+ values on the stack, and accept that the rest may be wrong.
+
+ There are also other values that have to be saved. We use a chained
+ sequence of blocks that actually live on the stack. Thanks to Robin Houston
+ for the original version of this logic. */
case OP_RECURSE:
{
- BOOL rc;
- int *save;
- int stacksave[15];
+ int stacksave[REC_STACK_SAVE_MAX];
+ recursion_info new_recursive;
+ const uschar *callpat = md->start_code + GET(ecode, 1);
+
+ if (*callpat == OP_BRAZERO) callpat++;
+
+ new_recursive.group_num = *callpat - OP_BRA;
+
+ /* For extended extraction brackets (large number), we have to fish out
+ the number from a dummy opcode at the start. */
+
+ if (new_recursive.group_num > EXTRACT_BASIC_MAX)
+ new_recursive.group_num = GET2(callpat, 2+LINK_SIZE);
- c = md->offset_max;
+ /* Add to "recursing stack" */
- if (c < 16) save = stacksave; else
+ new_recursive.prev = md->recursive;
+ md->recursive = &new_recursive;
+
+ /* Find where to continue from afterwards */
+
+ ecode += 1 + LINK_SIZE;
+ new_recursive.after_call = ecode;
+
+ /* Now save the offset data. */
+
+ new_recursive.saved_max = md->offset_end;
+ if (new_recursive.saved_max <= REC_STACK_SAVE_MAX)
+ new_recursive.offset_save = stacksave;
+ else
{
- save = (int *)(pcre_malloc)((c+1) * sizeof(int));
- if (save == NULL)
- {
- save = stacksave;
- c = 15;
- }
+ new_recursive.offset_save =
+ (int *)(pcre_malloc)(new_recursive.saved_max * sizeof(int));
+ if (new_recursive.offset_save == NULL) return PCRE_ERROR_NOMEMORY;
}
- for (i = 1; i <= c; i++)
- save[i] = md->offset_vector[md->offset_end - i];
- rc = match(eptr, md->start_pattern, offset_top, md, ims, eptrb,
- match_isgroup);
- for (i = 1; i <= c; i++)
- md->offset_vector[md->offset_end - i] = save[i];
- if (save != stacksave) (pcre_free)(save);
- if (!rc) return FALSE;
+ memcpy(new_recursive.offset_save, md->offset_vector,
+ new_recursive.saved_max * sizeof(int));
+ new_recursive.save_start = md->start_match;
+ md->start_match = eptr;
- /* In case the recursion has set more capturing values, save the final
- number, then move along the subject till after the recursive match,
- and advance one byte in the pattern code. */
+ /* OK, now we can do the recursion. For each top-level alternative we
+ restore the offset and recursion data. */
- offset_top = md->end_offset_top;
- eptr = md->end_match_ptr;
- ecode++;
+ DPRINTF(("Recursing into group %d\n", new_recursive.group_num));
+ do
+ {
+ if ((rrc = match(eptr, callpat + 1 + LINK_SIZE, offset_top, md, ims,
+ eptrb, match_isgroup)) == MATCH_MATCH)
+ {
+ md->recursive = new_recursive.prev;
+ if (new_recursive.offset_save != stacksave)
+ (pcre_free)(new_recursive.offset_save);
+ return MATCH_MATCH;
+ }
+ else if (rrc != MATCH_NOMATCH) return rrc;
+
+ md->recursive = &new_recursive;
+ memcpy(md->offset_vector, new_recursive.offset_save,
+ new_recursive.saved_max * sizeof(int));
+ callpat += GET(callpat, 1);
+ }
+ while (*callpat == OP_ALT);
+
+ DPRINTF(("Recursion didn't match\n"));
+ md->recursive = new_recursive.prev;
+ if (new_recursive.offset_save != stacksave)
+ (pcre_free)(new_recursive.offset_save);
+ return MATCH_NOMATCH;
}
break;
/* "Once" brackets are like assertion brackets except that after a match,
the point in the subject string is not moved back. Thus there can never be
- a move back into the brackets. Check the alternative branches in turn - the
- matching won't pass the KET for this kind of subpattern. If any one branch
- matches, we carry on as at the end of a normal bracket, leaving the subject
- pointer. */
+ a move back into the brackets. Friedl calls these "atomic" subpatterns.
+ Check the alternative branches in turn - the matching won't pass the KET
+ for this kind of subpattern. If any one branch matches, we carry on as at
+ the end of a normal bracket, leaving the subject pointer. */
case OP_ONCE:
{
@@ -3756,20 +5279,21 @@ for (;;)
do
{
- if (match(eptr, ecode+3, offset_top, md, ims, eptrb, match_isgroup))
- break;
- ecode += (ecode[1] << 8) + ecode[2];
+ if ((rrc = match(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims,
+ eptrb, match_isgroup)) == MATCH_MATCH) break;
+ if (rrc != MATCH_NOMATCH) return rrc;
+ ecode += GET(ecode,1);
}
while (*ecode == OP_ALT);
/* If hit the end of the group (which could be repeated), fail */
- if (*ecode != OP_ONCE && *ecode != OP_ALT) return FALSE;
+ if (*ecode != OP_ONCE && *ecode != OP_ALT) return MATCH_NOMATCH;
/* Continue as from after the assertion, updating the offsets high water
mark, since extracts may have been taken. */
- do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT);
+ do ecode += GET(ecode,1); while (*ecode == OP_ALT);
offset_top = md->end_offset_top;
eptr = md->end_match_ptr;
@@ -3782,7 +5306,7 @@ for (;;)
if (*ecode == OP_KET || eptr == saved_eptr)
{
- ecode += 3;
+ ecode += 1+LINK_SIZE;
break;
}
@@ -3791,7 +5315,7 @@ for (;;)
that changed within the bracket before re-running it, so check the next
opcode. */
- if (ecode[3] == OP_OPT)
+ if (ecode[1+LINK_SIZE] == OP_OPT)
{
ims = (ims & ~PCRE_IMS) | ecode[4];
DPRINTF(("ims set to %02lx at group repeat\n", ims));
@@ -3799,23 +5323,26 @@ for (;;)
if (*ecode == OP_KETRMIN)
{
- if (match(eptr, ecode+3, offset_top, md, ims, eptrb, 0) ||
- match(eptr, prev, offset_top, md, ims, eptrb, match_isgroup))
- return TRUE;
+ if ((rrc = match(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims,
+ eptrb, 0)) != MATCH_NOMATCH) return rrc;
+ if ((rrc = match(eptr, prev, offset_top, md, ims, eptrb,
+ match_isgroup)) != MATCH_NOMATCH) return rrc;
}
else /* OP_KETRMAX */
{
- if (match(eptr, prev, offset_top, md, ims, eptrb, match_isgroup) ||
- match(eptr, ecode+3, offset_top, md, ims, eptrb, 0)) return TRUE;
+ if ((rrc = match(eptr, prev, offset_top, md, ims, eptrb,
+ match_isgroup)) != MATCH_NOMATCH) return rrc;
+ if ((rrc = match(eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb,
+ 0)) != MATCH_NOMATCH) return rrc;
}
}
- return FALSE;
+ return MATCH_NOMATCH;
/* An alternation is the end of a branch; scan along to find the end of the
bracketed group and go to there. */
case OP_ALT:
- do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT);
+ do ecode += GET(ecode,1); while (*ecode == OP_ALT);
break;
/* BRAZERO and BRAMINZERO occur just before a bracket group, indicating
@@ -3827,25 +5354,25 @@ for (;;)
case OP_BRAZERO:
{
const uschar *next = ecode+1;
- if (match(eptr, next, offset_top, md, ims, eptrb, match_isgroup))
- return TRUE;
- do next += (next[1] << 8) + next[2]; while (*next == OP_ALT);
- ecode = next + 3;
+ if ((rrc = match(eptr, next, offset_top, md, ims, eptrb, match_isgroup))
+ != MATCH_NOMATCH) return rrc;
+ do next += GET(next,1); while (*next == OP_ALT);
+ ecode = next + 1+LINK_SIZE;
}
break;
case OP_BRAMINZERO:
{
const uschar *next = ecode+1;
- do next += (next[1] << 8) + next[2]; while (*next == OP_ALT);
- if (match(eptr, next+3, offset_top, md, ims, eptrb, match_isgroup))
- return TRUE;
+ do next += GET(next,1); while (*next == OP_ALT);
+ if ((rrc = match(eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb,
+ match_isgroup)) != MATCH_NOMATCH) return rrc;
ecode++;
}
break;
/* End of a group, repeated or non-repeating. If we are at the end of
- an assertion "group", stop matching and return TRUE, but record the
+ an assertion "group", stop matching and return MATCH_MATCH, but record the
current high water mark for use by positive assertions. Do this also
for the "once" (not-backup up) groups. */
@@ -3853,7 +5380,7 @@ for (;;)
case OP_KETRMIN:
case OP_KETRMAX:
{
- const uschar *prev = ecode - (ecode[1] << 8) - ecode[2];
+ const uschar *prev = ecode - GET(ecode, 1);
const uschar *saved_eptr = eptrb->saved_eptr;
eptrb = eptrb->prev; /* Back up the stack of bracket start pointers */
@@ -3864,7 +5391,7 @@ for (;;)
{
md->end_match_ptr = eptr; /* For ONCE */
md->end_offset_top = offset_top;
- return TRUE;
+ return MATCH_MATCH;
}
/* In all other cases except a conditional group we have to check the
@@ -3879,7 +5406,7 @@ for (;;)
/* For extended extraction brackets (large number), we have to fish out
the number from a dummy opcode at the start. */
- if (number > EXTRACT_BASIC_MAX) number = (prev[4] << 8) | prev[5];
+ if (number > EXTRACT_BASIC_MAX) number = GET2(prev, 2+LINK_SIZE);
offset = number << 1;
#ifdef DEBUG
@@ -3887,8 +5414,14 @@ for (;;)
printf("\n");
#endif
+ /* Test for a numbered group. This includes groups called as a result
+ of recursion. Note that whole-pattern recursion is coded as a recurse
+ into group 0, so it won't be picked up here. Instead, we catch it when
+ the OP_END is reached. */
+
if (number > 0)
{
+ md->capture_last = number;
if (offset >= md->offset_max) md->offset_overflow = TRUE; else
{
md->offset_vector[offset] =
@@ -3896,6 +5429,22 @@ for (;;)
md->offset_vector[offset+1] = eptr - md->start_subject;
if (offset_top <= offset) offset_top = offset + 2;
}
+
+ /* Handle a recursively called group. Restore the offsets
+ appropriately and continue from after the call. */
+
+ if (md->recursive != NULL && md->recursive->group_num == number)
+ {
+ recursion_info *rec = md->recursive;
+ DPRINTF(("Recursion (%d) succeeded - continuing\n", number));
+ md->recursive = rec->prev;
+ md->start_match = rec->save_start;
+ memcpy(md->offset_vector, rec->offset_save,
+ rec->saved_max * sizeof(int));
+ ecode = rec->after_call;
+ ims = original_ims;
+ break;
+ }
}
}
@@ -3913,7 +5462,7 @@ for (;;)
if (*ecode == OP_KET || eptr == saved_eptr)
{
- ecode += 3;
+ ecode += 1 + LINK_SIZE;
break;
}
@@ -3922,25 +5471,29 @@ for (;;)
if (*ecode == OP_KETRMIN)
{
- if (match(eptr, ecode+3, offset_top, md, ims, eptrb, 0) ||
- match(eptr, prev, offset_top, md, ims, eptrb, match_isgroup))
- return TRUE;
+ if ((rrc = match(eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb,
+ 0)) != MATCH_NOMATCH) return rrc;
+ if ((rrc = match(eptr, prev, offset_top, md, ims, eptrb,
+ match_isgroup)) != MATCH_NOMATCH) return rrc;
}
else /* OP_KETRMAX */
{
- if (match(eptr, prev, offset_top, md, ims, eptrb, match_isgroup) ||
- match(eptr, ecode+3, offset_top, md, ims, eptrb, 0)) return TRUE;
+ if ((rrc = match(eptr, prev, offset_top, md, ims, eptrb,
+ match_isgroup)) != MATCH_NOMATCH) return rrc;
+ if ((rrc = match(eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb,
+ 0)) != MATCH_NOMATCH) return rrc;
}
}
- return FALSE;
+ return MATCH_NOMATCH;
/* Start of subject unless notbol, or after internal newline if multiline */
case OP_CIRC:
- if (md->notbol && eptr == md->start_subject) return FALSE;
+ if (md->notbol && eptr == md->start_subject) return MATCH_NOMATCH;
if ((ims & PCRE_MULTILINE) != 0)
{
- if (eptr != md->start_subject && eptr[-1] != NEWLINE) return FALSE;
+ if (eptr != md->start_subject && eptr[-1] != NEWLINE)
+ return MATCH_NOMATCH;
ecode++;
break;
}
@@ -3949,7 +5502,14 @@ for (;;)
/* Start of subject assertion */
case OP_SOD:
- if (eptr != md->start_subject) return FALSE;
+ if (eptr != md->start_subject) return MATCH_NOMATCH;
+ ecode++;
+ break;
+
+ /* Start of match assertion */
+
+ case OP_SOM:
+ if (eptr != md->start_subject + md->start_offset) return MATCH_NOMATCH;
ecode++;
break;
@@ -3959,19 +5519,21 @@ for (;;)
case OP_DOLL:
if ((ims & PCRE_MULTILINE) != 0)
{
- if (eptr < md->end_subject) { if (*eptr != NEWLINE) return FALSE; }
- else { if (md->noteol) return FALSE; }
+ if (eptr < md->end_subject)
+ { if (*eptr != NEWLINE) return MATCH_NOMATCH; }
+ else
+ { if (md->noteol) return MATCH_NOMATCH; }
ecode++;
break;
}
else
{
- if (md->noteol) return FALSE;
+ if (md->noteol) return MATCH_NOMATCH;
if (!md->endonly)
{
if (eptr < md->end_subject - 1 ||
- (eptr == md->end_subject - 1 && *eptr != NEWLINE)) return FALSE;
-
+ (eptr == md->end_subject - 1 && *eptr != NEWLINE))
+ return MATCH_NOMATCH;
ecode++;
break;
}
@@ -3981,7 +5543,7 @@ for (;;)
/* End of subject assertion (\z) */
case OP_EOD:
- if (eptr < md->end_subject) return FALSE;
+ if (eptr < md->end_subject) return MATCH_NOMATCH;
ecode++;
break;
@@ -3989,7 +5551,7 @@ for (;;)
case OP_EODN:
if (eptr < md->end_subject - 1 ||
- (eptr == md->end_subject - 1 && *eptr != NEWLINE)) return FALSE;
+ (eptr == md->end_subject - 1 && *eptr != NEWLINE)) return MATCH_NOMATCH;
ecode++;
break;
@@ -3998,13 +5560,45 @@ for (;;)
case OP_NOT_WORD_BOUNDARY:
case OP_WORD_BOUNDARY:
{
- BOOL prev_is_word = (eptr != md->start_subject) &&
- ((md->ctypes[eptr[-1]] & ctype_word) != 0);
- BOOL cur_is_word = (eptr < md->end_subject) &&
- ((md->ctypes[*eptr] & ctype_word) != 0);
+ BOOL prev_is_word, cur_is_word;
+
+ /* Find out if the previous and current characters are "word" characters.
+ It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to
+ be "non-word" characters. */
+
+#if SUPPORT_UTF8
+ if (md->utf8)
+ {
+ if (eptr == md->start_subject) prev_is_word = FALSE; else
+ {
+ const uschar *lastptr = eptr - 1;
+ while((*lastptr & 0xc0) == 0x80) lastptr--;
+ GETCHAR(c, lastptr);
+ prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
+ }
+ if (eptr >= md->end_subject) cur_is_word = FALSE; else
+ {
+ GETCHAR(c, eptr);
+ cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
+ }
+ }
+ else
+#endif
+
+ /* More streamlined when not in UTF-8 mode */
+
+ {
+ prev_is_word = (eptr != md->start_subject) &&
+ ((md->ctypes[eptr[-1]] & ctype_word) != 0);
+ cur_is_word = (eptr < md->end_subject) &&
+ ((md->ctypes[*eptr] & ctype_word) != 0);
+ }
+
+ /* Now see if the situation is what we want */
+
if ((*ecode++ == OP_WORD_BOUNDARY)?
cur_is_word == prev_is_word : cur_is_word != prev_is_word)
- return FALSE;
+ return MATCH_NOMATCH;
}
break;
@@ -4012,8 +5606,8 @@ for (;;)
case OP_ANY:
if ((ims & PCRE_DOTALL) == 0 && eptr < md->end_subject && *eptr == NEWLINE)
- return FALSE;
- if (eptr++ >= md->end_subject) return FALSE;
+ return MATCH_NOMATCH;
+ if (eptr++ >= md->end_subject) return MATCH_NOMATCH;
#ifdef SUPPORT_UTF8
if (md->utf8)
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
@@ -4021,45 +5615,89 @@ for (;;)
ecode++;
break;
+ /* Match a single byte, even in UTF-8 mode. This opcode really does match
+ any byte, even newline, independent of the setting of PCRE_DOTALL. */
+
+ case OP_ANYBYTE:
+ if (eptr++ >= md->end_subject) return MATCH_NOMATCH;
+ ecode++;
+ break;
+
case OP_NOT_DIGIT:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_digit) != 0)
- return FALSE;
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINCTEST(c, eptr);
+ if (
+#ifdef SUPPORT_UTF8
+ c < 256 &&
+#endif
+ (md->ctypes[c] & ctype_digit) != 0
+ )
+ return MATCH_NOMATCH;
ecode++;
break;
case OP_DIGIT:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_digit) == 0)
- return FALSE;
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINCTEST(c, eptr);
+ if (
+#ifdef SUPPORT_UTF8
+ c >= 256 ||
+#endif
+ (md->ctypes[c] & ctype_digit) == 0
+ )
+ return MATCH_NOMATCH;
ecode++;
break;
case OP_NOT_WHITESPACE:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_space) != 0)
- return FALSE;
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINCTEST(c, eptr);
+ if (
+#ifdef SUPPORT_UTF8
+ c < 256 &&
+#endif
+ (md->ctypes[c] & ctype_space) != 0
+ )
+ return MATCH_NOMATCH;
ecode++;
break;
case OP_WHITESPACE:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_space) == 0)
- return FALSE;
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINCTEST(c, eptr);
+ if (
+#ifdef SUPPORT_UTF8
+ c >= 256 ||
+#endif
+ (md->ctypes[c] & ctype_space) == 0
+ )
+ return MATCH_NOMATCH;
ecode++;
break;
case OP_NOT_WORDCHAR:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_word) != 0)
- return FALSE;
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINCTEST(c, eptr);
+ if (
+#ifdef SUPPORT_UTF8
+ c < 256 &&
+#endif
+ (md->ctypes[c] & ctype_word) != 0
+ )
+ return MATCH_NOMATCH;
ecode++;
break;
case OP_WORDCHAR:
- if (eptr >= md->end_subject ||
- (md->ctypes[*eptr++] & ctype_word) == 0)
- return FALSE;
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINCTEST(c, eptr);
+ if (
+#ifdef SUPPORT_UTF8
+ c >= 256 ||
+#endif
+ (md->ctypes[c] & ctype_word) == 0
+ )
+ return MATCH_NOMATCH;
ecode++;
break;
@@ -4074,7 +5712,7 @@ for (;;)
case OP_REF:
{
int length;
- int offset = (ecode[1] << 9) | (ecode[2] << 1); /* Doubled ref number */
+ int offset = GET2(ecode, 1) << 1; /* Doubled ref number */
ecode += 3; /* Advance past item */
/* If the reference is unset, set the length to be longer than the amount
@@ -4106,14 +5744,14 @@ for (;;)
case OP_CRRANGE:
case OP_CRMINRANGE:
minimize = (*ecode == OP_CRMINRANGE);
- min = (ecode[1] << 8) + ecode[2];
- max = (ecode[3] << 8) + ecode[4];
+ min = GET2(ecode, 1);
+ max = GET2(ecode, 3);
if (max == 0) max = INT_MAX;
ecode += 5;
break;
default: /* No repeat follows */
- if (!match_ref(offset, eptr, length, md, ims)) return FALSE;
+ if (!match_ref(offset, eptr, length, md, ims)) return MATCH_NOMATCH;
eptr += length;
continue; /* With the main loop */
}
@@ -4129,7 +5767,7 @@ for (;;)
for (i = 1; i <= min; i++)
{
- if (!match_ref(offset, eptr, length, md, ims)) return FALSE;
+ if (!match_ref(offset, eptr, length, md, ims)) return MATCH_NOMATCH;
eptr += length;
}
@@ -4144,10 +5782,10 @@ for (;;)
{
for (i = min;; i++)
{
- if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
if (i >= max || !match_ref(offset, eptr, length, md, ims))
- return FALSE;
+ return MATCH_NOMATCH;
eptr += length;
}
/* Control never gets here */
@@ -4165,21 +5803,27 @@ for (;;)
}
while (eptr >= pp)
{
- if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
eptr -= length;
}
- return FALSE;
+ return MATCH_NOMATCH;
}
}
/* Control never gets here */
- /* Match a character class, possibly repeatedly. Look past the end of the
- item to see if there is repeat information following. Then obey similar
- code to character type repeats - written out again for speed. */
+ /* Match a bit-mapped character class, possibly repeatedly. This op code is
+ used when all the characters in the class have values in the range 0-255.
+ The only difference between OP_CLASS and OP_NCLASS occurs when a data
+ character outside the range is encountered.
+
+ First, look past the end of the item to see if there is repeat information
+ following. Then obey similar code to character type repeats - written out
+ again for speed. */
+ case OP_NCLASS:
case OP_CLASS:
{
const uschar *data = ecode + 1; /* Save for matching */
@@ -4203,8 +5847,8 @@ for (;;)
case OP_CRRANGE:
case OP_CRMINRANGE:
minimize = (*ecode == OP_CRMINRANGE);
- min = (ecode[1] << 8) + ecode[2];
- max = (ecode[3] << 8) + ecode[4];
+ min = GET2(ecode, 1);
+ max = GET2(ecode, 3);
if (max == 0) max = INT_MAX;
ecode += 5;
break;
@@ -4216,18 +5860,183 @@ for (;;)
/* First, ensure the minimum number of matches are present. */
- for (i = 1; i <= min; i++)
+#ifdef SUPPORT_UTF8
+ /* UTF-8 mode */
+ if (md->utf8)
+ {
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINC(c, eptr);
+ if (c > 255)
+ {
+ if (op == OP_CLASS) return MATCH_NOMATCH;
+ }
+ else
+ {
+ if ((data[c/8] & (1 << (c&7))) == 0) return MATCH_NOMATCH;
+ }
+ }
+ }
+ else
+#endif
+ /* Not UTF-8 mode */
{
- if (eptr >= md->end_subject) return FALSE;
- GETCHARINC(c, eptr) /* Get character; increment eptr */
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
+ c = *eptr++;
+ if ((data[c/8] & (1 << (c&7))) == 0) return MATCH_NOMATCH;
+ }
+ }
+
+ /* If max == min we can continue with the main loop without the
+ need to recurse. */
+ if (min == max) continue;
+
+ /* If minimizing, keep testing the rest of the expression and advancing
+ the pointer while it matches the class. */
+
+ if (minimize)
+ {
#ifdef SUPPORT_UTF8
- /* We do not yet support class members > 255 */
- if (c > 255) return FALSE;
+ /* UTF-8 mode */
+ if (md->utf8)
+ {
+ for (i = min;; i++)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ if (i >= max || eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINC(c, eptr);
+ if (c > 255)
+ {
+ if (op == OP_CLASS) return MATCH_NOMATCH;
+ }
+ else
+ {
+ if ((data[c/8] & (1 << (c&7))) == 0) return MATCH_NOMATCH;
+ }
+ }
+ }
+ else
#endif
+ /* Not UTF-8 mode */
+ {
+ for (i = min;; i++)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ if (i >= max || eptr >= md->end_subject) return MATCH_NOMATCH;
+ c = *eptr++;
+ if ((data[c/8] & (1 << (c&7))) == 0) return MATCH_NOMATCH;
+ }
+ }
+ /* Control never gets here */
+ }
+
+ /* If maximizing, find the longest possible run, then work backwards. */
+
+ else
+ {
+ const uschar *pp = eptr;
+
+#ifdef SUPPORT_UTF8
+ /* UTF-8 mode */
+ if (md->utf8)
+ {
+ for (i = min; i < max; i++)
+ {
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(c, eptr, len);
+ if (c > 255)
+ {
+ if (op == OP_CLASS) break;
+ }
+ else
+ {
+ if ((data[c/8] & (1 << (c&7))) == 0) break;
+ }
+ eptr += len;
+ }
+ while (eptr >= pp)
+ {
+ if ((rrc = match(eptr--, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ BACKCHAR(eptr)
+ }
+ }
+ else
+#endif
+ /* Not UTF-8 mode */
+ {
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject) break;
+ c = *eptr;
+ if ((data[c/8] & (1 << (c&7))) == 0) break;
+ eptr++;
+ }
+ while (eptr >= pp)
+ {
+ if ((rrc = match(eptr--, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ }
+ }
+
+ return MATCH_NOMATCH;
+ }
+ }
+ /* Control never gets here */
+
+
+ /* Match an extended character class. This opcode is encountered only
+ in UTF-8 mode, because that's the only time it is compiled. */
+
+#ifdef SUPPORT_UTF8
+ case OP_XCLASS:
+ {
+ const uschar *data = ecode + 1 + LINK_SIZE; /* Save for matching */
+ ecode += GET(ecode, 1); /* Advance past the item */
+
+ switch (*ecode)
+ {
+ case OP_CRSTAR:
+ case OP_CRMINSTAR:
+ case OP_CRPLUS:
+ case OP_CRMINPLUS:
+ case OP_CRQUERY:
+ case OP_CRMINQUERY:
+ c = *ecode++ - OP_CRSTAR;
+ minimize = (c & 1) != 0;
+ min = rep_min[c]; /* Pick up values from tables; */
+ max = rep_max[c]; /* zero for max => infinity */
+ if (max == 0) max = INT_MAX;
+ break;
+
+ case OP_CRRANGE:
+ case OP_CRMINRANGE:
+ minimize = (*ecode == OP_CRMINRANGE);
+ min = GET2(ecode, 1);
+ max = GET2(ecode, 3);
+ if (max == 0) max = INT_MAX;
+ ecode += 5;
+ break;
- if ((data[c/8] & (1 << (c&7))) != 0) continue;
- return FALSE;
+ default: /* No repeat follows */
+ min = max = 1;
+ break;
+ }
+
+ /* First, ensure the minimum number of matches are present. */
+
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINC(c, eptr);
+ if (!match_xclass(c, data)) return MATCH_NOMATCH;
}
/* If max == min we can continue with the main loop without the
@@ -4242,17 +6051,11 @@ for (;;)
{
for (i = min;; i++)
{
- if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
- if (i >= max || eptr >= md->end_subject) return FALSE;
- GETCHARINC(c, eptr) /* Get character; increment eptr */
-
-#ifdef SUPPORT_UTF8
- /* We do not yet support class members > 255 */
- if (c > 255) return FALSE;
-#endif
- if ((data[c/8] & (1 << (c&7))) != 0) continue;
- return FALSE;
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ if (i >= max || eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINC(c, eptr);
+ if (!match_xclass(c, data)) return MATCH_NOMATCH;
}
/* Control never gets here */
}
@@ -4262,33 +6065,26 @@ for (;;)
else
{
const uschar *pp = eptr;
- int len = 1;
for (i = min; i < max; i++)
{
+ int len = 1;
if (eptr >= md->end_subject) break;
- GETCHARLEN(c, eptr, len) /* Get character, set length if UTF-8 */
-
-#ifdef SUPPORT_UTF8
- /* We do not yet support class members > 255 */
- if (c > 255) break;
-#endif
- if ((data[c/8] & (1 << (c&7))) == 0) break;
+ GETCHARLEN(c, eptr, len);
+ if (!match_xclass(c, data)) break;
eptr += len;
}
-
while (eptr >= pp)
{
- if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
-
-#ifdef SUPPORT_UTF8
+ if ((rrc = match(eptr--, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
BACKCHAR(eptr)
-#endif
}
- return FALSE;
+ return MATCH_NOMATCH;
}
+
+ /* Control never gets here */
}
- /* Control never gets here */
+#endif /* End of XCLASS */
/* Match a run of characters */
@@ -4310,16 +6106,16 @@ for (;;)
printf("\n");
#endif
- if (length > md->end_subject - eptr) return FALSE;
+ if (length > md->end_subject - eptr) return MATCH_NOMATCH;
if ((ims & PCRE_CASELESS) != 0)
{
while (length-- > 0)
if (md->lcc[*ecode++] != md->lcc[*eptr++])
- return FALSE;
+ return MATCH_NOMATCH;
}
else
{
- while (length-- > 0) if (*ecode++ != *eptr++) return FALSE;
+ while (length-- > 0) if (*ecode++ != *eptr++) return MATCH_NOMATCH;
}
}
break;
@@ -4327,14 +6123,14 @@ for (;;)
/* Match a single character repeatedly; different opcodes share code. */
case OP_EXACT:
- min = max = (ecode[1] << 8) + ecode[2];
+ min = max = GET2(ecode, 1);
ecode += 3;
goto REPEATCHAR;
case OP_UPTO:
case OP_MINUPTO:
min = 0;
- max = (ecode[1] << 8) + ecode[2];
+ max = GET2(ecode, 1);
minimize = *ecode == OP_MINUPTO;
ecode += 3;
goto REPEATCHAR;
@@ -4356,16 +6152,84 @@ for (;;)
the subject. */
REPEATCHAR:
- if (min > md->end_subject - eptr) return FALSE;
- c = *ecode++;
+#ifdef SUPPORT_UTF8
+ if (md->utf8)
+ {
+ int len = 1;
+ const uschar *charptr = ecode;
+ GETCHARLEN(c, ecode, len);
+ if (min * len > md->end_subject - eptr) return MATCH_NOMATCH;
+ ecode += len;
- /* The code is duplicated for the caseless and caseful cases, for speed,
- since matching characters is likely to be quite common. First, ensure the
- minimum number of matches are present. If min = max, continue at the same
- level without recursing. Otherwise, if minimizing, keep trying the rest of
- the expression and advancing one matching character if failing, up to the
- maximum. Alternatively, if maximizing, find the maximum number of
- characters and work backwards. */
+ /* Handle multibyte character matching specially here. There is no
+ support for any kind of casing for multibyte characters. */
+
+ if (len > 1)
+ {
+ for (i = 1; i <= min; i++)
+ {
+ if (memcmp(eptr, charptr, len) != 0) return MATCH_NOMATCH;
+ eptr += len;
+ }
+
+ if (min == max) continue;
+
+ if (minimize)
+ {
+ for (i = min;; i++)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ if (i >= max ||
+ eptr >= md->end_subject ||
+ memcmp(eptr, charptr, len) != 0)
+ return MATCH_NOMATCH;
+ eptr += len;
+ }
+ /* Control never gets here */
+ }
+ else
+ {
+ const uschar *pp = eptr;
+ for (i = min; i < max; i++)
+ {
+ if (eptr > md->end_subject - len ||
+ memcmp(eptr, charptr, len) != 0)
+ break;
+ eptr += len;
+ }
+ while (eptr >= pp)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ eptr -= len;
+ }
+ return MATCH_NOMATCH;
+ }
+ /* Control never gets here */
+ }
+
+ /* If the length of a UTF-8 character is 1, we fall through here, and
+ obey the code as for non-UTF-8 characters below, though in this case the
+ value of c will always be < 128. */
+ }
+ else
+#endif
+
+ /* When not in UTF-8 mode, load a single-byte character. */
+ {
+ if (min > md->end_subject - eptr) return MATCH_NOMATCH;
+ c = *ecode++;
+ }
+
+ /* The value of c at this point is always less than 256, though we may or
+ may not be in UTF-8 mode. The code is duplicated for the caseless and
+ caseful cases, for speed, since matching characters is likely to be quite
+ common. First, ensure the minimum number of matches are present. If min =
+ max, continue at the same level without recursing. Otherwise, if
+ minimizing, keep trying the rest of the expression and advancing one
+ matching character if failing, up to the maximum. Alternatively, if
+ maximizing, find the maximum number of characters and work backwards. */
DPRINTF(("matching %c{%d,%d} against subject %.*s\n", c, min, max,
max, eptr));
@@ -4374,17 +6238,17 @@ for (;;)
{
c = md->lcc[c];
for (i = 1; i <= min; i++)
- if (c != md->lcc[*eptr++]) return FALSE;
+ if (c != md->lcc[*eptr++]) return MATCH_NOMATCH;
if (min == max) continue;
if (minimize)
{
for (i = min;; i++)
{
- if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
if (i >= max || eptr >= md->end_subject ||
c != md->lcc[*eptr++])
- return FALSE;
+ return MATCH_NOMATCH;
}
/* Control never gets here */
}
@@ -4397,26 +6261,27 @@ for (;;)
eptr++;
}
while (eptr >= pp)
- if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
- return FALSE;
+ if ((rrc = match(eptr--, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ return MATCH_NOMATCH;
}
/* Control never gets here */
}
- /* Caseful comparisons */
+ /* Caseful comparisons (includes all multi-byte characters) */
else
{
- for (i = 1; i <= min; i++) if (c != *eptr++) return FALSE;
+ for (i = 1; i <= min; i++) if (c != *eptr++) return MATCH_NOMATCH;
if (min == max) continue;
if (minimize)
{
for (i = min;; i++)
{
- if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
- if (i >= max || eptr >= md->end_subject || c != *eptr++) return FALSE;
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ if (i >= max || eptr >= md->end_subject || c != *eptr++)
+ return MATCH_NOMATCH;
}
/* Control never gets here */
}
@@ -4429,43 +6294,50 @@ for (;;)
eptr++;
}
while (eptr >= pp)
- if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
- return FALSE;
+ if ((rrc = match(eptr--, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ return MATCH_NOMATCH;
}
}
/* Control never gets here */
- /* Match a negated single character */
+ /* Match a negated single one-byte character. The character we are
+ checking can be multibyte. */
case OP_NOT:
- if (eptr >= md->end_subject) return FALSE;
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
ecode++;
+ GETCHARINCTEST(c, eptr);
if ((ims & PCRE_CASELESS) != 0)
{
- if (md->lcc[*ecode++] == md->lcc[*eptr++]) return FALSE;
+#ifdef SUPPORT_UTF8
+ if (c < 256)
+#endif
+ c = md->lcc[c];
+ if (md->lcc[*ecode++] == c) return MATCH_NOMATCH;
}
else
{
- if (*ecode++ == *eptr++) return FALSE;
+ if (*ecode++ == c) return MATCH_NOMATCH;
}
break;
- /* Match a negated single character repeatedly. This is almost a repeat of
- the code for a repeated single character, but I haven't found a nice way of
- commoning these up that doesn't require a test of the positive/negative
- option for each character match. Maybe that wouldn't add very much to the
- time taken, but character matching *is* what this is all about... */
+ /* Match a negated single one-byte character repeatedly. This is almost a
+ repeat of the code for a repeated single character, but I haven't found a
+ nice way of commoning these up that doesn't require a test of the
+ positive/negative option for each character match. Maybe that wouldn't add
+ very much to the time taken, but character matching *is* what this is all
+ about... */
case OP_NOTEXACT:
- min = max = (ecode[1] << 8) + ecode[2];
+ min = max = GET2(ecode, 1);
ecode += 3;
goto REPEATNOTCHAR;
case OP_NOTUPTO:
case OP_NOTMINUPTO:
min = 0;
- max = (ecode[1] << 8) + ecode[2];
+ max = GET2(ecode, 1);
minimize = *ecode == OP_NOTMINUPTO;
ecode += 3;
goto REPEATNOTCHAR;
@@ -4482,12 +6354,12 @@ for (;;)
max = rep_max[c]; /* zero for max => infinity */
if (max == 0) max = INT_MAX;
- /* Common code for all repeated single-character matches. We can give
- up quickly if there are fewer than the minimum number of characters left in
- the subject. */
+ /* Common code for all repeated single-character (less than 255) matches.
+ We can give up quickly if there are fewer than the minimum number of
+ characters left in the subject. */
REPEATNOTCHAR:
- if (min > md->end_subject - eptr) return FALSE;
+ if (min > md->end_subject - eptr) return MATCH_NOMATCH;
c = *ecode++;
/* The code is duplicated for the caseless and caseful cases, for speed,
@@ -4504,33 +6376,108 @@ for (;;)
if ((ims & PCRE_CASELESS) != 0)
{
c = md->lcc[c];
- for (i = 1; i <= min; i++)
- if (c == md->lcc[*eptr++]) return FALSE;
+
+#ifdef SUPPORT_UTF8
+ /* UTF-8 mode */
+ if (md->utf8)
+ {
+ register int d;
+ for (i = 1; i <= min; i++)
+ {
+ GETCHARINC(d, eptr);
+ if (d < 256) d = md->lcc[d];
+ if (c == d) return MATCH_NOMATCH;
+ }
+ }
+ else
+#endif
+
+ /* Not UTF-8 mode */
+ {
+ for (i = 1; i <= min; i++)
+ if (c == md->lcc[*eptr++]) return MATCH_NOMATCH;
+ }
+
if (min == max) continue;
+
if (minimize)
{
- for (i = min;; i++)
+#ifdef SUPPORT_UTF8
+ /* UTF-8 mode */
+ if (md->utf8)
{
- if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
- if (i >= max || eptr >= md->end_subject ||
- c == md->lcc[*eptr++])
- return FALSE;
+ register int d;
+ for (i = min;; i++)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ GETCHARINC(d, eptr);
+ if (d < 256) d = md->lcc[d];
+ if (i >= max || eptr >= md->end_subject || c == d)
+ return MATCH_NOMATCH;
+ }
+ }
+ else
+#endif
+ /* Not UTF-8 mode */
+ {
+ for (i = min;; i++)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ if (i >= max || eptr >= md->end_subject || c == md->lcc[*eptr++])
+ return MATCH_NOMATCH;
+ }
}
/* Control never gets here */
}
+
+ /* Maximize case */
+
else
{
const uschar *pp = eptr;
- for (i = min; i < max; i++)
+
+#ifdef SUPPORT_UTF8
+ /* UTF-8 mode */
+ if (md->utf8)
{
- if (eptr >= md->end_subject || c == md->lcc[*eptr]) break;
- eptr++;
+ register int d;
+ for (i = min; i < max; i++)
+ {
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(d, eptr, len);
+ if (d < 256) d = md->lcc[d];
+ if (c == d) break;
+ eptr += len;
+ }
+ while (eptr >= pp)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ eptr--;
+ BACKCHAR(eptr);
+ }
}
- while (eptr >= pp)
- if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
- return FALSE;
+ else
+#endif
+ /* Not UTF-8 mode */
+ {
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || c == md->lcc[*eptr]) break;
+ eptr++;
+ }
+ while (eptr >= pp)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ eptr--;
+ }
+ }
+
+ return MATCH_NOMATCH;
}
/* Control never gets here */
}
@@ -4539,30 +6486,103 @@ for (;;)
else
{
- for (i = 1; i <= min; i++) if (c == *eptr++) return FALSE;
+#ifdef SUPPORT_UTF8
+ /* UTF-8 mode */
+ if (md->utf8)
+ {
+ register int d;
+ for (i = 1; i <= min; i++)
+ {
+ GETCHARINC(d, eptr);
+ if (c == d) return MATCH_NOMATCH;
+ }
+ }
+ else
+#endif
+ /* Not UTF-8 mode */
+ {
+ for (i = 1; i <= min; i++)
+ if (c == *eptr++) return MATCH_NOMATCH;
+ }
+
if (min == max) continue;
+
if (minimize)
{
- for (i = min;; i++)
+#ifdef SUPPORT_UTF8
+ /* UTF-8 mode */
+ if (md->utf8)
+ {
+ register int d;
+ for (i = min;; i++)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ GETCHARINC(d, eptr);
+ if (i >= max || eptr >= md->end_subject || c == d)
+ return MATCH_NOMATCH;
+ }
+ }
+ else
+#endif
+ /* Not UTF-8 mode */
{
- if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
- if (i >= max || eptr >= md->end_subject || c == *eptr++) return FALSE;
+ for (i = min;; i++)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ if (i >= max || eptr >= md->end_subject || c == *eptr++)
+ return MATCH_NOMATCH;
+ }
}
/* Control never gets here */
}
+
+ /* Maximize case */
+
else
{
const uschar *pp = eptr;
- for (i = min; i < max; i++)
+
+#ifdef SUPPORT_UTF8
+ /* UTF-8 mode */
+ if (md->utf8)
{
- if (eptr >= md->end_subject || c == *eptr) break;
- eptr++;
+ register int d;
+ for (i = min; i < max; i++)
+ {
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(d, eptr, len);
+ if (c == d) break;
+ eptr += len;
+ }
+ while (eptr >= pp)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ eptr--;
+ BACKCHAR(eptr);
+ }
}
- while (eptr >= pp)
- if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
- return FALSE;
+ else
+#endif
+ /* Not UTF-8 mode */
+ {
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || c == *eptr) break;
+ eptr++;
+ }
+ while (eptr >= pp)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ eptr--;
+ }
+ }
+
+ return MATCH_NOMATCH;
}
}
/* Control never gets here */
@@ -4572,7 +6592,7 @@ for (;;)
repeat it in the interests of efficiency. */
case OP_TYPEEXACT:
- min = max = (ecode[1] << 8) + ecode[2];
+ min = max = GET2(ecode, 1);
minimize = TRUE;
ecode += 3;
goto REPEATTYPE;
@@ -4580,7 +6600,7 @@ for (;;)
case OP_TYPEUPTO:
case OP_TYPEMINUPTO:
min = 0;
- max = (ecode[1] << 8) + ecode[2];
+ max = GET2(ecode, 1);
minimize = *ecode == OP_TYPEMINUPTO;
ecode += 3;
goto REPEATTYPE;
@@ -4597,7 +6617,9 @@ for (;;)
max = rep_max[c]; /* zero for max => infinity */
if (max == 0) max = INT_MAX;
- /* Common code for all repeated single character type matches */
+ /* Common code for all repeated single character type matches. Note that
+ in UTF-8 mode, '.' matches a character of any length, but for the other
+ character types, the valid characters are all one-byte long. */
REPEATTYPE:
ctype = *ecode++; /* Code for the character type */
@@ -4605,64 +6627,142 @@ for (;;)
/* First, ensure the minimum number of matches are present. Use inline
code for maximizing the speed, and do the type test once at the start
(i.e. keep it out of the loop). Also we can test that there are at least
- the minimum number of bytes before we start, except when doing '.' in
- UTF8 mode. Leave the test in in all cases; in the special case we have
- to test after each character. */
+ the minimum number of bytes before we start. This isn't as effective in
+ UTF-8 mode, but it does no harm. Separate the UTF-8 code completely as that
+ is tidier. */
- if (min > md->end_subject - eptr) return FALSE;
- if (min > 0) switch(ctype)
+ if (min > md->end_subject - eptr) return MATCH_NOMATCH;
+ if (min > 0)
{
- case OP_ANY:
#ifdef SUPPORT_UTF8
- if (md->utf8)
+ if (md->utf8) switch(ctype)
{
+ case OP_ANY:
for (i = 1; i <= min; i++)
{
if (eptr >= md->end_subject ||
(*eptr++ == NEWLINE && (ims & PCRE_DOTALL) == 0))
- return FALSE;
+ return MATCH_NOMATCH;
+ while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+ }
+ break;
+
+ case OP_ANYBYTE:
+ eptr += min;
+ break;
+
+ case OP_NOT_DIGIT:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject) return MATCH_NOMATCH;
+ GETCHARINC(c, eptr);
+ if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
+ return MATCH_NOMATCH;
+ }
+ break;
+
+ case OP_DIGIT:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject ||
+ *eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)
+ return MATCH_NOMATCH;
+ /* No need to skip more bytes - we know it's a 1-byte character */
+ }
+ break;
+
+ case OP_NOT_WHITESPACE:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject ||
+ (*eptr < 128 && (md->ctypes[*eptr++] & ctype_space) != 0))
+ return MATCH_NOMATCH;
+ while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+ }
+ break;
+
+ case OP_WHITESPACE:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject ||
+ *eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)
+ return MATCH_NOMATCH;
+ /* No need to skip more bytes - we know it's a 1-byte character */
+ }
+ break;
+
+ case OP_NOT_WORDCHAR:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject ||
+ (*eptr < 128 && (md->ctypes[*eptr++] & ctype_word) != 0))
+ return MATCH_NOMATCH;
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
}
break;
+
+ case OP_WORDCHAR:
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject ||
+ *eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)
+ return MATCH_NOMATCH;
+ /* No need to skip more bytes - we know it's a 1-byte character */
+ }
+ break;
}
+ else
#endif
- /* Non-UTF8 can be faster */
- if ((ims & PCRE_DOTALL) == 0)
- { for (i = 1; i <= min; i++) if (*eptr++ == NEWLINE) return FALSE; }
- else eptr += min;
- break;
- case OP_NOT_DIGIT:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_digit) != 0) return FALSE;
- break;
+ /* Code for the non-UTF-8 case for minimum matching */
- case OP_DIGIT:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_digit) == 0) return FALSE;
- break;
+ switch(ctype)
+ {
+ case OP_ANY:
+ if ((ims & PCRE_DOTALL) == 0)
+ {
+ for (i = 1; i <= min; i++)
+ if (*eptr++ == NEWLINE) return MATCH_NOMATCH;
+ }
+ else eptr += min;
+ break;
- case OP_NOT_WHITESPACE:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_space) != 0) return FALSE;
- break;
+ case OP_ANYBYTE:
+ eptr += min;
+ break;
- case OP_WHITESPACE:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_space) == 0) return FALSE;
- break;
+ case OP_NOT_DIGIT:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_digit) != 0) return MATCH_NOMATCH;
+ break;
- case OP_NOT_WORDCHAR:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_word) != 0)
- return FALSE;
- break;
+ case OP_DIGIT:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_digit) == 0) return MATCH_NOMATCH;
+ break;
- case OP_WORDCHAR:
- for (i = 1; i <= min; i++)
- if ((md->ctypes[*eptr++] & ctype_word) == 0)
- return FALSE;
- break;
+ case OP_NOT_WHITESPACE:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_space) != 0) return MATCH_NOMATCH;
+ break;
+
+ case OP_WHITESPACE:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_space) == 0) return MATCH_NOMATCH;
+ break;
+
+ case OP_NOT_WORDCHAR:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_word) != 0)
+ return MATCH_NOMATCH;
+ break;
+
+ case OP_WORDCHAR:
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype_word) == 0)
+ return MATCH_NOMATCH;
+ break;
+ }
}
/* If min = max, continue at the same level without recursing */
@@ -4670,180 +6770,361 @@ for (;;)
if (min == max) continue;
/* If minimizing, we have to test the rest of the pattern before each
- subsequent match. */
+ subsequent match. Again, separate the UTF-8 case for speed. */
if (minimize)
{
- for (i = min;; i++)
+#ifdef SUPPORT_UTF8
+ /* UTF-8 mode */
+ if (md->utf8)
+ {
+ for (i = min;; i++)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ if (i >= max || eptr >= md->end_subject) return MATCH_NOMATCH;
+
+ GETCHARINC(c, eptr);
+ switch(ctype)
+ {
+ case OP_ANY:
+ if ((ims & PCRE_DOTALL) == 0 && c == NEWLINE) return MATCH_NOMATCH;
+ break;
+
+ case OP_ANYBYTE:
+ break;
+
+ case OP_NOT_DIGIT:
+ if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
+ return MATCH_NOMATCH;
+ break;
+
+ case OP_DIGIT:
+ if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)
+ return MATCH_NOMATCH;
+ break;
+
+ case OP_NOT_WHITESPACE:
+ if (c < 256 && (md->ctypes[c] & ctype_space) != 0)
+ return MATCH_NOMATCH;
+ break;
+
+ case OP_WHITESPACE:
+ if (c >= 256 || (md->ctypes[c] & ctype_space) == 0)
+ return MATCH_NOMATCH;
+ break;
+
+ case OP_NOT_WORDCHAR:
+ if (c < 256 && (md->ctypes[c] & ctype_word) != 0)
+ return MATCH_NOMATCH;
+ break;
+
+ case OP_WORDCHAR:
+ if (c >= 256 && (md->ctypes[c] & ctype_word) == 0)
+ return MATCH_NOMATCH;
+ break;
+ }
+ }
+ }
+ else
+#endif
+ /* Not UTF-8 mode */
{
- if (match(eptr, ecode, offset_top, md, ims, eptrb, 0)) return TRUE;
- if (i >= max || eptr >= md->end_subject) return FALSE;
+ for (i = min;; i++)
+ {
+ if ((rrc = match(eptr, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ if (i >= max || eptr >= md->end_subject) return MATCH_NOMATCH;
+ c = *eptr++;
+ switch(ctype)
+ {
+ case OP_ANY:
+ if ((ims & PCRE_DOTALL) == 0 && c == NEWLINE) return MATCH_NOMATCH;
+ break;
+
+ case OP_ANYBYTE:
+ break;
+
+ case OP_NOT_DIGIT:
+ if ((md->ctypes[c] & ctype_digit) != 0) return MATCH_NOMATCH;
+ break;
+
+ case OP_DIGIT:
+ if ((md->ctypes[c] & ctype_digit) == 0) return MATCH_NOMATCH;
+ break;
+
+ case OP_NOT_WHITESPACE:
+ if ((md->ctypes[c] & ctype_space) != 0) return MATCH_NOMATCH;
+ break;
+
+ case OP_WHITESPACE:
+ if ((md->ctypes[c] & ctype_space) == 0) return MATCH_NOMATCH;
+ break;
+
+ case OP_NOT_WORDCHAR:
+ if ((md->ctypes[c] & ctype_word) != 0) return MATCH_NOMATCH;
+ break;
- c = *eptr++;
+ case OP_WORDCHAR:
+ if ((md->ctypes[c] & ctype_word) == 0) return MATCH_NOMATCH;
+ break;
+ }
+ }
+ }
+ /* Control never gets here */
+ }
+
+ /* If maximizing it is worth using inline code for speed, doing the type
+ test once at the start (i.e. keep it out of the loop). Again, keep the
+ UTF-8 stuff separate. */
+
+ else
+ {
+ const uschar *pp = eptr;
+
+#ifdef SUPPORT_UTF8
+ /* UTF-8 mode */
+
+ if (md->utf8)
+ {
switch(ctype)
{
case OP_ANY:
- if ((ims & PCRE_DOTALL) == 0 && c == NEWLINE) return FALSE;
-#ifdef SUPPORT_UTF8
- if (md->utf8)
- while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
-#endif
+
+ /* Special code is required for UTF8, but when the maximum is unlimited
+ we don't need it, so we repeat the non-UTF8 code. This is probably
+ worth it, because .* is quite a common idiom. */
+
+ if (max < INT_MAX)
+ {
+ if ((ims & PCRE_DOTALL) == 0)
+ {
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || *eptr == NEWLINE) break;
+ eptr++;
+ while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+ }
+ }
+ else
+ {
+ for (i = min; i < max; i++)
+ {
+ eptr++;
+ while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+ }
+ }
+ }
+
+ /* Handle unlimited UTF-8 repeat */
+
+ else
+ {
+ if ((ims & PCRE_DOTALL) == 0)
+ {
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || *eptr == NEWLINE) break;
+ eptr++;
+ }
+ break;
+ }
+ else
+ {
+ c = max - min;
+ if (c > md->end_subject - eptr) c = md->end_subject - eptr;
+ eptr += c;
+ }
+ }
+ break;
+
+ /* The byte case is the same as non-UTF8 */
+
+ case OP_ANYBYTE:
+ c = max - min;
+ if (c > md->end_subject - eptr) c = md->end_subject - eptr;
+ eptr += c;
break;
case OP_NOT_DIGIT:
- if ((md->ctypes[c] & ctype_digit) != 0) return FALSE;
+ for (i = min; i < max; i++)
+ {
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(c, eptr, len);
+ if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break;
+ eptr+= len;
+ }
break;
case OP_DIGIT:
- if ((md->ctypes[c] & ctype_digit) == 0) return FALSE;
+ for (i = min; i < max; i++)
+ {
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(c, eptr, len);
+ if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break;
+ eptr+= len;
+ }
break;
case OP_NOT_WHITESPACE:
- if ((md->ctypes[c] & ctype_space) != 0) return FALSE;
+ for (i = min; i < max; i++)
+ {
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(c, eptr, len);
+ if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break;
+ eptr+= len;
+ }
break;
case OP_WHITESPACE:
- if ((md->ctypes[c] & ctype_space) == 0) return FALSE;
+ for (i = min; i < max; i++)
+ {
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(c, eptr, len);
+ if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break;
+ eptr+= len;
+ }
break;
case OP_NOT_WORDCHAR:
- if ((md->ctypes[c] & ctype_word) != 0) return FALSE;
+ for (i = min; i < max; i++)
+ {
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(c, eptr, len);
+ if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break;
+ eptr+= len;
+ }
break;
case OP_WORDCHAR:
- if ((md->ctypes[c] & ctype_word) == 0) return FALSE;
+ for (i = min; i < max; i++)
+ {
+ int len = 1;
+ if (eptr >= md->end_subject) break;
+ GETCHARLEN(c, eptr, len);
+ if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break;
+ eptr+= len;
+ }
break;
}
- }
- /* Control never gets here */
- }
- /* If maximizing it is worth using inline code for speed, doing the type
- test once at the start (i.e. keep it out of the loop). */
-
- else
- {
- const uschar *pp = eptr;
- switch(ctype)
- {
- case OP_ANY:
+ /* eptr is now past the end of the maximum run */
- /* Special code is required for UTF8, but when the maximum is unlimited
- we don't need it. */
+ while (eptr >= pp)
+ {
+ if ((rrc = match(eptr--, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
+ BACKCHAR(eptr);
+ }
+ }
+ else
+#endif
-#ifdef SUPPORT_UTF8
- if (md->utf8 && max < INT_MAX)
+ /* Not UTF-8 mode */
+ {
+ switch(ctype)
{
+ case OP_ANY:
if ((ims & PCRE_DOTALL) == 0)
{
for (i = min; i < max; i++)
{
- if (eptr >= md->end_subject || *eptr++ == NEWLINE) break;
- while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+ if (eptr >= md->end_subject || *eptr == NEWLINE) break;
+ eptr++;
}
+ break;
}
- else
+ /* For DOTALL case, fall through and treat as \C */
+
+ case OP_ANYBYTE:
+ c = max - min;
+ if (c > md->end_subject - eptr) c = md->end_subject - eptr;
+ eptr += c;
+ break;
+
+ case OP_NOT_DIGIT:
+ for (i = min; i < max; i++)
{
- for (i = min; i < max; i++)
- {
- eptr++;
- while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
- }
+ if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0)
+ break;
+ eptr++;
}
break;
- }
-#endif
- /* Non-UTF8 can be faster */
- if ((ims & PCRE_DOTALL) == 0)
- {
+
+ case OP_DIGIT:
for (i = min; i < max; i++)
{
- if (eptr >= md->end_subject || *eptr == NEWLINE) break;
+ if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0)
+ break;
eptr++;
}
- }
- else
- {
- c = max - min;
- if (c > md->end_subject - eptr) c = md->end_subject - eptr;
- eptr += c;
- }
- break;
+ break;
- case OP_NOT_DIGIT:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0)
- break;
- eptr++;
- }
- break;
+ case OP_NOT_WHITESPACE:
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0)
+ break;
+ eptr++;
+ }
+ break;
- case OP_DIGIT:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0)
- break;
- eptr++;
- }
- break;
+ case OP_WHITESPACE:
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0)
+ break;
+ eptr++;
+ }
+ break;
- case OP_NOT_WHITESPACE:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0)
- break;
- eptr++;
- }
- break;
+ case OP_NOT_WORDCHAR:
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0)
+ break;
+ eptr++;
+ }
+ break;
- case OP_WHITESPACE:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0)
- break;
- eptr++;
+ case OP_WORDCHAR:
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0)
+ break;
+ eptr++;
+ }
+ break;
}
- break;
- case OP_NOT_WORDCHAR:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0)
- break;
- eptr++;
- }
- break;
+ /* eptr is now past the end of the maximum run */
- case OP_WORDCHAR:
- for (i = min; i < max; i++)
+ while (eptr >= pp)
{
- if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0)
- break;
- eptr++;
+ if ((rrc = match(eptr--, ecode, offset_top, md, ims, eptrb, 0)) !=
+ MATCH_NOMATCH) return rrc;
}
- break;
}
- while (eptr >= pp)
- {
- if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
- return TRUE;
-#ifdef SUPPORT_UTF8
- if (md->utf8)
- while (eptr > pp && (*eptr & 0xc0) == 0x80) eptr--;
-#endif
- }
- return FALSE;
+ /* Get here if we can't make it match with any permitted repetitions */
+
+ return MATCH_NOMATCH;
}
/* Control never gets here */
- /* There's been some horrible disaster. */
+ /* There's been some horrible disaster. Since all codes > OP_BRA are
+ for capturing brackets, and there shouldn't be any gaps between 0 and
+ OP_BRA, arrival here can only mean there is something seriously wrong
+ in the code above or the OP_xxx definitions. */
default:
DPRINTF(("Unknown opcode %d\n", *ecode));
- md->errorcode = PCRE_ERROR_UNKNOWN_NODE;
- return FALSE;
+ return PCRE_ERROR_UNKNOWN_NODE;
}
/* Do not stick any code in here without much thought; it is assumed
@@ -4867,7 +7148,7 @@ each substring: the offsets to the start and end of the substring.
Arguments:
external_re points to the compiled expression
- external_extra points to "hints" from pcre_study() or is NULL
+ extra_data points to extra data or is NULL
subject points to the subject string
length length of subject string (may contain binary zeros)
start_offset where to start in the subject string
@@ -4882,37 +7163,63 @@ Returns: > 0 => success; value is the number of elements filled in
*/
int
-pcre_exec(const pcre *external_re, const pcre_extra *external_extra,
+pcre_exec(const pcre *external_re, const pcre_extra *extra_data,
const char *subject, int length, int start_offset, int options, int *offsets,
int offsetcount)
{
-int resetcount, ocount;
-int first_char = -1;
-int req_char = -1;
-int req_char2 = -1;
+int rc, resetcount, ocount;
+int first_byte = -1;
+int req_byte = -1;
+int req_byte2 = -1;
unsigned long int ims = 0;
+BOOL using_temporary_offsets = FALSE;
+BOOL anchored;
+BOOL startline;
+BOOL first_byte_caseless = FALSE;
+BOOL req_byte_caseless = FALSE;
match_data match_block;
const uschar *start_bits = NULL;
const uschar *start_match = (const uschar *)subject + start_offset;
const uschar *end_subject;
-const uschar *req_char_ptr = start_match - 1;
+const uschar *req_byte_ptr = start_match - 1;
+const pcre_study_data *study;
const real_pcre *re = (const real_pcre *)external_re;
-const real_pcre_extra *extra = (const real_pcre_extra *)external_extra;
-BOOL using_temporary_offsets = FALSE;
-BOOL anchored;
-BOOL startline;
-if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
+/* Plausibility checks */
+if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
if (re == NULL || subject == NULL ||
(offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;
+
+/* Fish out the optional data from the extra_data structure, first setting
+the default values. */
+
+study = NULL;
+match_block.match_limit = MATCH_LIMIT;
+match_block.callout_data = NULL;
+
+if (extra_data != NULL)
+ {
+ register unsigned int flags = extra_data->flags;
+ if ((flags & PCRE_EXTRA_STUDY_DATA) != 0)
+ study = extra_data->study_data;
+ if ((flags & PCRE_EXTRA_MATCH_LIMIT) != 0)
+ match_block.match_limit = extra_data->match_limit;
+ if ((flags & PCRE_EXTRA_CALLOUT_DATA) != 0)
+ match_block.callout_data = extra_data->callout_data;
+ }
+
+/* Now we have re supposedly pointing to the regex */
+
if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
startline = (re->options & PCRE_STARTLINE) != 0;
-match_block.start_pattern = re->code;
+match_block.start_code =
+ (const uschar *)re + sizeof(real_pcre) + re->name_count * re->name_entry_size;
match_block.start_subject = (const uschar *)subject;
+match_block.start_offset = start_offset;
match_block.end_subject = match_block.start_subject + length;
end_subject = match_block.end_subject;
@@ -4923,7 +7230,7 @@ match_block.notbol = (options & PCRE_NOTBOL) != 0;
match_block.noteol = (options & PCRE_NOTEOL) != 0;
match_block.notempty = (options & PCRE_NOTEMPTY) != 0;
-match_block.errorcode = PCRE_ERROR_NOMATCH; /* Default error */
+match_block.recursive = NULL; /* No recursion at top level */
match_block.lcc = re->tables + lcc_offset;
match_block.ctypes = re->tables + ctypes_offset;
@@ -4954,6 +7261,7 @@ else match_block.offset_vector = offsets;
match_block.offset_end = ocount;
match_block.offset_max = (2*ocount)/3;
match_block.offset_overflow = FALSE;
+match_block.capture_last = -1;
/* Compute the minimum number of offsets that we need to reset each time. Doing
this makes a huge difference to execution time when there aren't many brackets
@@ -4973,7 +7281,7 @@ if (match_block.offset_vector != NULL)
while (--iptr >= iend) *iptr = -1;
}
-/* Set up the first character to match, if available. The first_char value is
+/* Set up the first character to match, if available. The first_byte value is
never set for an anchored regular expression, but the anchoring may be forced
at run time, so we have to test for anchoring. The first char may be unset for
an unanchored pattern, of course. If there's no first char and the pattern was
@@ -4983,28 +7291,24 @@ if (!anchored)
{
if ((re->options & PCRE_FIRSTSET) != 0)
{
- first_char = re->first_char;
- if ((ims & PCRE_CASELESS) != 0) first_char = match_block.lcc[first_char];
+ first_byte = re->first_byte & 255;
+ if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
+ first_byte = match_block.lcc[first_byte];
}
else
- if (!startline && extra != NULL &&
- (extra->options & PCRE_STUDY_MAPPED) != 0)
- start_bits = extra->start_bits;
+ if (!startline && study != NULL &&
+ (study->options & PCRE_STUDY_MAPPED) != 0)
+ start_bits = study->start_bits;
}
/* For anchored or unanchored matches, there may be a "last known required
-character" set. If the PCRE_CASELESS is set, implying that the match starts
-caselessly, or if there are any changes of this flag within the regex, set up
-both cases of the character. Otherwise set the two values the same, which will
-avoid duplicate testing (which takes significant time). This covers the vast
-majority of cases. It will be suboptimal when the case flag changes in a regex
-and the required character in fact is caseful. */
+character" set. */
if ((re->options & PCRE_REQCHSET) != 0)
{
- req_char = re->req_char;
- req_char2 = ((re->options & (PCRE_CASELESS | PCRE_ICHANGED)) != 0)?
- (re->tables + fcc_offset)[req_char] : req_char;
+ req_byte = re->req_byte & 255;
+ req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
+ req_byte2 = (re->tables + fcc_offset)[req_byte]; /* case flipped */
}
/* Loop for handling unanchored repeated matching attempts; for anchored regexs
@@ -5012,7 +7316,6 @@ the loop runs just once. */
do
{
- int rc;
register int *iptr = match_block.offset_vector;
register int *iend = iptr + resetcount;
@@ -5022,14 +7325,14 @@ do
/* Advance to a unique first char if possible */
- if (first_char >= 0)
+ if (first_byte >= 0)
{
- if ((ims & PCRE_CASELESS) != 0)
+ if (first_byte_caseless)
while (start_match < end_subject &&
- match_block.lcc[*start_match] != first_char)
+ match_block.lcc[*start_match] != first_byte)
start_match++;
else
- while (start_match < end_subject && *start_match != first_char)
+ while (start_match < end_subject && *start_match != first_byte)
start_match++;
}
@@ -5061,44 +7364,36 @@ do
printf("\n");
#endif
- /* If req_char is set, we know that that character must appear in the subject
- for the match to succeed. If the first character is set, req_char must be
+ /* If req_byte is set, we know that that character must appear in the subject
+ for the match to succeed. If the first character is set, req_byte must be
later in the subject; otherwise the test starts at the match point. This
optimization can save a huge amount of backtracking in patterns with nested
- unlimited repeats that aren't going to match. We don't know what the state of
- case matching may be when this character is hit, so test for it in both its
- cases if necessary. However, the different cased versions will not be set up
- unless PCRE_CASELESS was given or the casing state changes within the regex.
- Writing separate code makes it go faster, as does using an autoincrement and
- backing off on a match. */
-
- if (req_char >= 0)
+ unlimited repeats that aren't going to match. Writing separate code for
+ cased/caseless versions makes it go faster, as does using an autoincrement
+ and backing off on a match. */
+
+ if (req_byte >= 0)
{
- register const uschar *p = start_match + ((first_char >= 0)? 1 : 0);
+ register const uschar *p = start_match + ((first_byte >= 0)? 1 : 0);
/* We don't need to repeat the search if we haven't yet reached the
place we found it at last time. */
- if (p > req_char_ptr)
+ if (p > req_byte_ptr)
{
- /* Do a single test if no case difference is set up */
-
- if (req_char == req_char2)
+ if (req_byte_caseless)
{
while (p < end_subject)
{
- if (*p++ == req_char) { p--; break; }
+ register int pp = *p++;
+ if (pp == req_byte || pp == req_byte2) { p--; break; }
}
}
-
- /* Otherwise test for either case */
-
else
{
while (p < end_subject)
{
- register int pp = *p++;
- if (pp == req_char || pp == req_char2) { p--; break; }
+ if (*p++ == req_byte) { p--; break; }
}
}
@@ -5110,7 +7405,7 @@ do
found it, so that we don't search again next time round the loop if
the start hasn't passed this character yet. */
- req_char_ptr = p;
+ req_byte_ptr = p;
}
}
@@ -5122,10 +7417,29 @@ do
if certain parts of the pattern were not used. */
match_block.start_match = start_match;
- if (!match(start_match, re->code, 2, &match_block, ims, NULL, match_isgroup))
+ match_block.match_call_count = 0;
+
+ rc = match(start_match, match_block.start_code, 2, &match_block, ims, NULL,
+ match_isgroup);
+
+ if (rc == MATCH_NOMATCH)
+ {
+ start_match++;
+#ifdef SUPPORT_UTF8
+ if (match_block.utf8)
+ while((*start_match & 0xc0) == 0x80) start_match++;
+#endif
continue;
+ }
+
+ if (rc != MATCH_MATCH)
+ {
+ DPRINTF((">>>> error: returning %d\n", rc));
+ return rc;
+ }
- /* Copy the offset information from temporary store if necessary */
+ /* We have a match! Copy the offset information from temporary store if
+ necessary */
if (using_temporary_offsets)
{
@@ -5156,9 +7470,7 @@ do
/* This "while" is the end of the "do" above */
-while (!anchored &&
- match_block.errorcode == PCRE_ERROR_NOMATCH &&
- start_match++ < end_subject);
+while (!anchored && start_match <= end_subject);
if (using_temporary_offsets)
{
@@ -5166,9 +7478,9 @@ if (using_temporary_offsets)
(pcre_free)(match_block.offset_vector);
}
-DPRINTF((">>>> returning %d\n", match_block.errorcode));
+DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n"));
-return match_block.errorcode;
+return PCRE_ERROR_NOMATCH;
}
/* End of pcre.c */
diff --git a/pcre.def b/pcre.def
index 0e8cf3f..4f6c4bf 100644
--- a/pcre.def
+++ b/pcre.def
@@ -8,7 +8,10 @@ pcre_copy_substring
pcre_exec
pcre_get_substring
pcre_get_substring_list
+pcre_free_substring
+pcre_free_substring_list
pcre_info
+pcre_fullinfo
pcre_maketables
pcre_study
pcre_version
diff --git a/pcre.in b/pcre.in
index ef37569..2aa44b9 100644
--- a/pcre.in
+++ b/pcre.in
@@ -2,7 +2,7 @@
* Perl-Compatible Regular Expressions *
*************************************************/
-/* Copyright (c) 1997-2001 University of Cambridge */
+/* Copyright (c) 1997-2003 University of Cambridge */
#ifndef _PCRE_H
#define _PCRE_H
@@ -17,13 +17,18 @@ make changes to pcre.in. */
/* Win32 uses DLL by default */
#ifdef _WIN32
-# ifdef STATIC
-# define PCRE_DL_IMPORT
-# else
-# define PCRE_DL_IMPORT __declspec(dllimport)
-# endif
-#else
-# define PCRE_DL_IMPORT
+# ifdef PCRE_DEFINITION
+# ifdef DLL_EXPORT
+# define PCRE_DATA_SCOPE __declspec(dllexport)
+# endif
+# else
+# ifndef PCRE_STATIC
+# define PCRE_DATA_SCOPE __declspec(dllimport)
+# endif
+# endif
+#endif
+#ifndef PCRE_DATA_SCOPE
+# define PCRE_DATA_SCOPE extern
#endif
/* Have to include stdlib.h in order to ensure that size_t is defined;
@@ -39,20 +44,21 @@ extern "C" {
/* Options */
-#define PCRE_CASELESS 0x0001
-#define PCRE_MULTILINE 0x0002
-#define PCRE_DOTALL 0x0004
-#define PCRE_EXTENDED 0x0008
-#define PCRE_ANCHORED 0x0010
-#define PCRE_DOLLAR_ENDONLY 0x0020
-#define PCRE_EXTRA 0x0040
-#define PCRE_NOTBOL 0x0080
-#define PCRE_NOTEOL 0x0100
-#define PCRE_UNGREEDY 0x0200
-#define PCRE_NOTEMPTY 0x0400
-#define PCRE_UTF8 0x0800
-
-/* Exec-time and get-time error codes */
+#define PCRE_CASELESS 0x0001
+#define PCRE_MULTILINE 0x0002
+#define PCRE_DOTALL 0x0004
+#define PCRE_EXTENDED 0x0008
+#define PCRE_ANCHORED 0x0010
+#define PCRE_DOLLAR_ENDONLY 0x0020
+#define PCRE_EXTRA 0x0040
+#define PCRE_NOTBOL 0x0080
+#define PCRE_NOTEOL 0x0100
+#define PCRE_UNGREEDY 0x0200
+#define PCRE_NOTEMPTY 0x0400
+#define PCRE_UTF8 0x0800
+#define PCRE_NO_AUTO_CAPTURE 0x1000
+
+/* Exec-time and get/set-time error codes */
#define PCRE_ERROR_NOMATCH (-1)
#define PCRE_ERROR_NULL (-2)
@@ -61,47 +67,112 @@ extern "C" {
#define PCRE_ERROR_UNKNOWN_NODE (-5)
#define PCRE_ERROR_NOMEMORY (-6)
#define PCRE_ERROR_NOSUBSTRING (-7)
+#define PCRE_ERROR_MATCHLIMIT (-8)
+#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
/* Request types for pcre_fullinfo() */
-#define PCRE_INFO_OPTIONS 0
-#define PCRE_INFO_SIZE 1
-#define PCRE_INFO_CAPTURECOUNT 2
-#define PCRE_INFO_BACKREFMAX 3
-#define PCRE_INFO_FIRSTCHAR 4
-#define PCRE_INFO_FIRSTTABLE 5
-#define PCRE_INFO_LASTLITERAL 6
+#define PCRE_INFO_OPTIONS 0
+#define PCRE_INFO_SIZE 1
+#define PCRE_INFO_CAPTURECOUNT 2
+#define PCRE_INFO_BACKREFMAX 3
+#define PCRE_INFO_FIRSTBYTE 4
+#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */
+#define PCRE_INFO_FIRSTTABLE 5
+#define PCRE_INFO_LASTLITERAL 6
+#define PCRE_INFO_NAMEENTRYSIZE 7
+#define PCRE_INFO_NAMECOUNT 8
+#define PCRE_INFO_NAMETABLE 9
+#define PCRE_INFO_STUDYSIZE 10
+
+/* Request types for pcre_config() */
+
+#define PCRE_CONFIG_UTF8 0
+#define PCRE_CONFIG_NEWLINE 1
+#define PCRE_CONFIG_LINK_SIZE 2
+#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
+#define PCRE_CONFIG_MATCH_LIMIT 4
+
+/* Bit flags for the pcre_extra structure */
+
+#define PCRE_EXTRA_STUDY_DATA 0x0001
+#define PCRE_EXTRA_MATCH_LIMIT 0x0002
+#define PCRE_EXTRA_CALLOUT_DATA 0x0004
/* Types */
-struct real_pcre; /* declaration; the definition is private */
-struct real_pcre_extra; /* declaration; the definition is private */
-
+struct real_pcre; /* declaration; the definition is private */
typedef struct real_pcre pcre;
-typedef struct real_pcre_extra pcre_extra;
-
-/* Store get and free functions. These can be set to alternative malloc/free
-functions if required. Some magic is required for Win32 DLL; it is null on
-other OS. */
-
-PCRE_DL_IMPORT extern void *(*pcre_malloc)(size_t);
-PCRE_DL_IMPORT extern void (*pcre_free)(void *);
-
-#undef PCRE_DL_IMPORT
-
-/* Functions */
-extern pcre *pcre_compile(const char *, int, const char **, int *,
- const unsigned char *);
-extern int pcre_copy_substring(const char *, int *, int, int, char *, int);
-extern int pcre_exec(const pcre *, const pcre_extra *, const char *,
- int, int, int, int *, int);
+/* The structure for passing additional data to pcre_exec(). This is defined in
+such as way as to be extensible. */
+
+typedef struct pcre_extra {
+ unsigned long int flags; /* Bits for which fields are set */
+ void *study_data; /* Opaque data from pcre_study() */
+ unsigned long int match_limit; /* Maximum number of calls to match() */
+ void *callout_data; /* Data passed back in callouts */
+} pcre_extra;
+
+/* The structure for passing out data via the pcre_callout_function. We use a
+structure so that new fields can be added on the end in future versions,
+without changing the API of the function, thereby allowing old clients to work
+without modification. */
+
+typedef struct pcre_callout_block {
+ int version; /* Identifies version of block */
+ /* ------------------------ Version 0 ------------------------------- */
+ int callout_number; /* Number compiled into pattern */
+ int *offset_vector; /* The offset vector */
+ const char *subject; /* The subject being matched */
+ int subject_length; /* The length of the subject */
+ int start_match; /* Offset to start of this match attempt */
+ int current_position; /* Where we currently are */
+ int capture_top; /* Max current capture */
+ int capture_last; /* Most recently closed capture */
+ void *callout_data; /* Data passed in with the call */
+ /* ------------------------------------------------------------------ */
+} pcre_callout_block;
+
+/* Indirection for store get and free functions. These can be set to
+alternative malloc/free functions if required. There is also an optional
+callout function that is triggered by the (?) regex item. Some magic is
+required for Win32 DLL; it is null on other OS. For Virtual Pascal, these
+have to be different again. */
+
+#ifndef VPCOMPAT
+PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);
+PCRE_DATA_SCOPE void (*pcre_free)(void *);
+PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *);
+#else /* VPCOMPAT */
+extern void *pcre_malloc(size_t);
+extern void pcre_free(void *);
+extern int pcre_callout(pcre_callout_block *);
+#endif /* VPCOMPAT */
+
+/* Exported PCRE functions */
+
+extern pcre *pcre_compile(const char *, int, const char **,
+ int *, const unsigned char *);
+extern int pcre_config(int, void *);
+extern int pcre_copy_named_substring(const pcre *, const char *,
+ int *, int, const char *, char *, int);
+extern int pcre_copy_substring(const char *, int *, int, int,
+ char *, int);
+extern int pcre_exec(const pcre *, const pcre_extra *,
+ const char *, int, int, int, int *, int);
extern void pcre_free_substring(const char *);
extern void pcre_free_substring_list(const char **);
-extern int pcre_get_substring(const char *, int *, int, int, const char **);
-extern int pcre_get_substring_list(const char *, int *, int, const char ***);
+extern int pcre_fullinfo(const pcre *, const pcre_extra *, int,
+ void *);
+extern int pcre_get_named_substring(const pcre *, const char *,
+ int *, int, const char *, const char **);
+extern int pcre_get_stringnumber(const pcre *, const char *);
+extern int pcre_get_substring(const char *, int *, int, int,
+ const char **);
+extern int pcre_get_substring_list(const char *, int *, int,
+ const char ***);
extern int pcre_info(const pcre *, int *, int *);
-extern int pcre_fullinfo(const pcre *, const pcre_extra *, int, void *);
extern const unsigned char *pcre_maketables(void);
extern pcre_extra *pcre_study(const pcre *, int, const char **);
extern const char *pcre_version(void);
diff --git a/pcredemo.c b/pcredemo.c
index cb4e46f..3c827e7 100644
--- a/pcredemo.c
+++ b/pcredemo.c
@@ -1,32 +1,79 @@
-#include <stdio.h>
-#include <string.h>
-#include <pcre.h>
+/*************************************************
+* PCRE DEMONSTRATION PROGRAM *
+*************************************************/
-/* Compile thuswise:
+/* This is a demonstration program to illustrate the most straightforward ways
+of calling the PCRE regular expression library from a C program. See the
+pcresample documentation for a short discussion.
+
+Compile thuswise:
gcc -Wall pcredemo.c -I/opt/local/include -L/opt/local/lib \
-R/opt/local/lib -lpcre
+
+Replace "/opt/local/include" and "/opt/local/lib" with wherever the include and
+library files for PCRE are installed on your system. Only some operating
+systems (e.g. Solaris) use the -R option.
*/
+
+#include <stdio.h>
+#include <string.h>
+#include <pcre.h>
+
#define OVECCOUNT 30 /* should be a multiple of 3 */
+
int main(int argc, char **argv)
{
pcre *re;
const char *error;
+char *pattern;
+char *subject;
+unsigned char *name_table;
int erroffset;
+int find_all;
+int namecount;
+int name_entry_size;
int ovector[OVECCOUNT];
+int subject_length;
int rc, i;
-if (argc != 3)
+
+/*************************************************************************
+* First, sort out the command line. There is only one possible option at *
+* the moment, "-g" to request repeated matching to find all occurrences, *
+* like Perl's /g option. We set the variable find_all non-zero if it is *
+* present. Apart from that, there must be exactly two arguments. *
+*************************************************************************/
+
+find_all = 0;
+for (i = 1; i < argc; i++)
+ {
+ if (strcmp(argv[i], "-g") == 0) find_all = 1;
+ else break;
+ }
+
+/* After the options, we require exactly two arguments, which are the pattern,
+and the subject string. */
+
+if (argc - i != 2)
{
printf("Two arguments required: a regex and a subject string\n");
return 1;
}
-/* Compile the regular expression in the first argument */
+pattern = argv[i];
+subject = argv[i+1];
+subject_length = (int)strlen(subject);
+
+
+/*************************************************************************
+* Now we are going to compile the regular expression pattern, and handle *
+* and errors that are detected. *
+*************************************************************************/
re = pcre_compile(
- argv[1], /* the pattern */
+ pattern, /* the pattern */
0, /* default options */
&error, /* for error message */
&erroffset, /* for error offset */
@@ -40,13 +87,18 @@ if (re == NULL)
return 1;
}
-/* Compilation succeeded: match the subject in the second argument */
+
+/*************************************************************************
+* If the compilation succeeded, we call PCRE again, in order to do a *
+* pattern match against the subject string. This just does ONE match. If *
+* further matching is needed, it will be done below. *
+*************************************************************************/
rc = pcre_exec(
re, /* the compiled pattern */
NULL, /* no extra data - we didn't study the pattern */
- argv[2], /* the subject string */
- (int)strlen(argv[2]), /* the length of the subject */
+ subject, /* the subject string */
+ subject_length, /* the length of the subject */
0, /* start at offset 0 in the subject */
0, /* default options */
ovector, /* output vector for substring information */
@@ -69,7 +121,14 @@ if (rc < 0)
/* Match succeded */
-printf("Match succeeded\n");
+printf("\nMatch succeeded at offset %d\n", ovector[0]);
+
+
+/*************************************************************************
+* We have found the first match within the subject string. If the output *
+* vector wasn't big enough, set its size to the maximum. Then output any *
+* substrings that were captured. *
+*************************************************************************/
/* The output vector wasn't big enough */
@@ -79,16 +138,179 @@ if (rc == 0)
printf("ovector only has room for %d captured substrings\n", rc - 1);
}
-/* Show substrings stored in the output vector */
+/* Show substrings stored in the output vector by number. Obviously, in a real
+application you might want to do things other than print them. */
for (i = 0; i < rc; i++)
{
- char *substring_start = argv[2] + ovector[2*i];
+ char *substring_start = subject + ovector[2*i];
int substring_length = ovector[2*i+1] - ovector[2*i];
printf("%2d: %.*s\n", i, substring_length, substring_start);
}
+
+/*************************************************************************
+* That concludes the basic part of this demonstration program. We have *
+* compiled a pattern, and performed a single match. The code that follows*
+* first shows how to access named substrings, and then how to code for *
+* repeated matches on the same subject. *
+*************************************************************************/
+
+/* See if there are any named substrings, and if so, show them by name. First
+we have to extract the count of named parentheses from the pattern. */
+
+(void)pcre_fullinfo(
+ re, /* the compiled pattern */
+ NULL, /* no extra data - we didn't study the pattern */
+ PCRE_INFO_NAMECOUNT, /* number of named substrings */
+ &namecount); /* where to put the answer */
+
+if (namecount <= 0) printf("No named substrings\n"); else
+ {
+ unsigned char *tabptr;
+ printf("Named substrings\n");
+
+ /* Before we can access the substrings, we must extract the table for
+ translating names to numbers, and the size of each entry in the table. */
+
+ (void)pcre_fullinfo(
+ re, /* the compiled pattern */
+ NULL, /* no extra data - we didn't study the pattern */
+ PCRE_INFO_NAMETABLE, /* address of the table */
+ &name_table); /* where to put the answer */
+
+ (void)pcre_fullinfo(
+ re, /* the compiled pattern */
+ NULL, /* no extra data - we didn't study the pattern */
+ PCRE_INFO_NAMEENTRYSIZE, /* size of each entry in the table */
+ &name_entry_size); /* where to put the answer */
+
+ /* Now we can scan the table and, for each entry, print the number, the name,
+ and the substring itself. */
+
+ tabptr = name_table;
+ for (i = 0; i < namecount; i++)
+ {
+ int n = (tabptr[0] << 8) | tabptr[1];
+ printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2,
+ ovector[2*n+1] - ovector[2*n], subject + ovector[2*n]);
+ tabptr += name_entry_size;
+ }
+ }
+
+
+/*************************************************************************
+* If the "-g" option was given on the command line, we want to continue *
+* to search for additional matches in the subject string, in a similar *
+* way to the /g option in Perl. This turns out to be trickier than you *
+* might think because of the possibility of matching an empty string. *
+* What happens is as follows: *
+* *
+* If the previous match was NOT for an empty string, we can just start *
+* the next match at the end of the previous one. *
+* *
+* If the previous match WAS for an empty string, we can't do that, as it *
+* would lead to an infinite loop. Instead, a special call of pcre_exec() *
+* is made with the PCRE_NOTEMPTY and PCRE_ANCHORED flags set. The first *
+* of these tells PCRE that an empty string is not a valid match; other *
+* possibilities must be tried. The second flag restricts PCRE to one *
+* match attempt at the initial string position. If this match succeeds, *
+* an alternative to the empty string match has been found, and we can *
+* proceed round the loop. *
+*************************************************************************/
+
+if (!find_all) return 0; /* Finish unless -g was given */
+
+/* Loop for second and subsequent matches */
+
+for (;;)
+ {
+ int options = 0; /* Normally no options */
+ int start_offset = ovector[1]; /* Start at end of previous match */
+
+ /* If the previous match was for an empty string, we are finished if we are
+ at the end of the subject. Otherwise, arrange to run another match at the
+ same point to see if a non-empty match can be found. */
+
+ if (ovector[0] == ovector[1])
+ {
+ if (ovector[0] == subject_length) break;
+ options = PCRE_NOTEMPTY | PCRE_ANCHORED;
+ }
+
+ /* Run the next matching operation */
+
+ rc = pcre_exec(
+ re, /* the compiled pattern */
+ NULL, /* no extra data - we didn't study the pattern */
+ subject, /* the subject string */
+ subject_length, /* the length of the subject */
+ start_offset, /* starting offset in the subject */
+ options, /* options */
+ ovector, /* output vector for substring information */
+ OVECCOUNT); /* number of elements in the output vector */
+
+ /* This time, a result of NOMATCH isn't an error. If the value in "options"
+ is zero, it just means we have found all possible matches, so the loop ends.
+ Otherwise, it means we have failed to find a non-empty-string match at a
+ point where there was a previous empty-string match. In this case, we do what
+ Perl does: advance the matching position by one, and continue. We do this by
+ setting the "end of previous match" offset, because that is picked up at the
+ top of the loop as the point at which to start again. */
+
+ if (rc == PCRE_ERROR_NOMATCH)
+ {
+ if (options == 0) break;
+ ovector[1] = start_offset + 1;
+ continue; /* Go round the loop again */
+ }
+
+ /* Other matching errors are not recoverable. */
+
+ if (rc < 0)
+ {
+ printf("Matching error %d\n", rc);
+ return 1;
+ }
+
+ /* Match succeded */
+
+ printf("\nMatch succeeded again at offset %d\n", ovector[0]);
+
+ /* The match succeeded, but the output vector wasn't big enough. */
+
+ if (rc == 0)
+ {
+ rc = OVECCOUNT/3;
+ printf("ovector only has room for %d captured substrings\n", rc - 1);
+ }
+
+ /* As before, show substrings stored in the output vector by number, and then
+ also any named substrings. */
+
+ for (i = 0; i < rc; i++)
+ {
+ char *substring_start = subject + ovector[2*i];
+ int substring_length = ovector[2*i+1] - ovector[2*i];
+ printf("%2d: %.*s\n", i, substring_length, substring_start);
+ }
+
+ if (namecount <= 0) printf("No named substrings\n"); else
+ {
+ unsigned char *tabptr = name_table;
+ printf("Named substrings\n");
+ for (i = 0; i < namecount; i++)
+ {
+ int n = (tabptr[0] << 8) | tabptr[1];
+ printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2,
+ ovector[2*n+1] - ovector[2*n], subject + ovector[2*n]);
+ tabptr += name_entry_size;
+ }
+ }
+ } /* End of loop to find second and subsequent matches */
+
+printf("\n");
return 0;
}
-
+/* End of pcredemo.c */
diff --git a/pcregrep.c b/pcregrep.c
index b50ed07..a86fefb 100644
--- a/pcregrep.c
+++ b/pcregrep.c
@@ -3,7 +3,8 @@
*************************************************/
/* This is a grep program that uses the PCRE regular expression library to do
-its pattern matching. On a Unix system it can recurse into directories. */
+its pattern matching. On a Unix or Win32 system it can recurse into
+directories. */
#include <ctype.h>
#include <stdio.h>
@@ -18,7 +19,7 @@ its pattern matching. On a Unix system it can recurse into directories. */
typedef int BOOL;
-#define VERSION "2.0 01-Aug-2001"
+#define VERSION "3.0 14-Jan-2003"
#define MAX_PATTERN_COUNT 100
@@ -57,6 +58,7 @@ static option_item optionlist[] = {
{ 'n', "line-number", "print line number with output lines" },
{ 'r', "recursive", "recursively scan sub-directories" },
{ 's', "no-messages", "suppress error messages" },
+ { 'u', "utf-8", "use UTF-8 mode" },
{ 'V', "version", "print version information and exit" },
{ 'v', "invert-match", "select non-matching lines" },
{ 'x', "line-regex", "force PATTERN to match only whole lines" },
@@ -70,8 +72,8 @@ static option_item optionlist[] = {
*************************************************/
/* These functions are defined so that they can be made system specific,
-although at present the only ones are for Unix, and for "no directory recursion
-support". */
+although at present the only ones are for Unix, Win32, and for "no directory
+recursion support". */
/************* Directory scanning in Unix ***********/
@@ -118,13 +120,105 @@ closedir(dir);
}
-#else
+/************* Directory scanning in Win32 ***********/
+
+/* I (Philip Hazel) have no means of testing this code. It was contributed by
+Lionel Fourquaux. */
+
+
+#elif HAVE_WIN32API
+
+#ifndef STRICT
+# define STRICT
+#endif
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+
+typedef struct directory_type
+{
+HANDLE handle;
+BOOL first;
+WIN32_FIND_DATA data;
+} directory_type;
+
+int
+isdirectory(char *filename)
+{
+DWORD attr = GetFileAttributes(filename);
+if (attr == INVALID_FILE_ATTRIBUTES)
+ return 0;
+return ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) ? '/' : 0;
+}
+
+directory_type *
+opendirectory(char *filename)
+{
+size_t len;
+char *pattern;
+directory_type *dir;
+DWORD err;
+len = strlen(filename);
+pattern = (char *) malloc(len + 3);
+dir = (directory_type *) malloc(sizeof(*dir));
+if ((pattern == NULL) || (dir == NULL))
+ {
+ fprintf(stderr, "pcregrep: malloc failed\n");
+ exit(2);
+ }
+memcpy(pattern, filename, len);
+memcpy(&(pattern[len]), "\\*", 3);
+dir->handle = FindFirstFile(pattern, &(dir->data));
+if (dir->handle != INVALID_HANDLE_VALUE)
+ {
+ free(pattern);
+ dir->first = TRUE;
+ return dir;
+ }
+err = GetLastError();
+free(pattern);
+free(dir);
+errno = (err == ERROR_ACCESS_DENIED) ? EACCES : ENOENT;
+return NULL;
+}
+
+char *
+readdirectory(directory_type *dir)
+{
+for (;;)
+ {
+ if (!dir->first)
+ {
+ if (!FindNextFile(dir->handle, &(dir->data)))
+ return NULL;
+ }
+ else
+ {
+ dir->first = FALSE;
+ }
+ if (strcmp(dir->data.cFileName, ".") != 0 && strcmp(dir->data.cFileName, "..") != 0)
+ return dir->data.cFileName;
+ }
+#ifndef _MSC_VER
+return NULL; /* Keep compiler happy; never executed */
+#endif
+}
+
+void
+closedirectory(directory_type *dir)
+{
+FindClose(dir->handle);
+free(dir);
+}
/************* Directory scanning when we can't do it ***********/
/* The type is void, and apart from isdirectory(), the functions do nothing. */
+#else
+
typedef void directory_type;
int isdirectory(char *filename) { return FALSE; }
@@ -262,8 +356,9 @@ if ((sep = isdirectory(filename)) != 0 && recurse)
}
/* If the file is not a directory, or we are not recursing, scan it. If this is
-the first and only argument at top level, we don't show the file name.
-Otherwise, control is via the show_filenames variable. */
+the first and only argument at top level, we don't show the file name (unless
+we are only showing the file name). Otherwise, control is via the
+show_filenames variable. */
in = fopen(filename, "r");
if (in == NULL)
@@ -272,7 +367,8 @@ if (in == NULL)
return 2;
}
-rc = pcregrep(in, (show_filenames && !only_one_at_top)? filename : NULL);
+rc = pcregrep(in, (filenames_only || (show_filenames && !only_one_at_top))?
+ filename : NULL);
fclose(in);
return rc;
}
@@ -287,7 +383,7 @@ return rc;
static int
usage(int rc)
{
-fprintf(stderr, "Usage: pcregrep [-Vcfhilnrsvx] [long-options] pattern [file] ...\n");
+fprintf(stderr, "Usage: pcregrep [-Vcfhilnrsvx] [long-options] [pattern] [file1 file2 ...]\n");
fprintf(stderr, "Type `pcregrep --help' for more information.\n");
return rc;
}
@@ -304,8 +400,9 @@ help(void)
{
option_item *op;
-printf("Usage: pcregrep [OPTION]... PATTERN [FILE] ...\n");
+printf("Usage: pcregrep [OPTION]... [PATTERN] [FILE1 FILE2 ...]\n");
printf("Search for PATTERN in each FILE or standard input.\n");
+printf("PATTERN must be present if -f is not used.\n");
printf("Example: pcregrep -i 'hello.*world' menu.h main.c\n\n");
printf("Options:\n");
@@ -350,6 +447,7 @@ switch(letter)
case 'n': number = TRUE; break;
case 'r': recurse = TRUE; break;
case 's': silent = TRUE; break;
+ case 'u': options |= PCRE_UTF8; break;
case 'v': invert = TRUE; break;
case 'x': whole_lines = TRUE; options |= PCRE_ANCHORED; break;
@@ -390,6 +488,10 @@ for (i = 1; i < argc; i++)
{
if (argv[i][0] != '-') break;
+ /* Missing options */
+
+ if (argv[i][1] == 0) exit(usage(2));
+
/* Long name options */
if (argv[i][1] == '-')
@@ -492,7 +594,7 @@ if (pattern_filename != NULL)
else
{
- if (i >= argc) return usage(0);
+ if (i >= argc) return usage(2);
pattern_list[0] = pcre_compile(argv[i++], options, &error, &errptr, NULL);
if (pattern_list[0] == NULL)
{
diff --git a/pcreposix.c b/pcreposix.c
index ba48d55..ef7beef 100644
--- a/pcreposix.c
+++ b/pcreposix.c
@@ -12,7 +12,7 @@ functions.
Written by: Philip Hazel <ph10@cam.ac.uk>
- Copyright (c) 1997-2001 University of Cambridge
+ Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
@@ -47,7 +47,8 @@ static const char *estring[] = {
ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR10,
ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20,
ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR29, ERR29, ERR30,
- ERR31 };
+ ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39, ERR40,
+ ERR41, ERR42, ERR43 };
static int eint[] = {
REG_EESCAPE, /* "\\ at end of pattern" */
@@ -62,9 +63,9 @@ static int eint[] = {
REG_BADRPT, /* "operand of unlimited repeat could match the empty string" */
REG_ASSERT, /* "internal error: unexpected repeat" */
REG_BADPAT, /* "unrecognized character after (?" */
- REG_ASSERT, /* "unused error" */
+ REG_BADPAT, /* "POSIX named classes are supported only within a class" */
REG_EPAREN, /* "missing )" */
- REG_ESUBREG, /* "back reference to non-existent subpattern" */
+ REG_ESUBREG, /* "reference to non-existent subpattern" */
REG_INVARG, /* "erroffset passed as NULL" */
REG_INVARG, /* "unknown option bit(s) set" */
REG_EPAREN, /* "missing ) after comment" */
@@ -78,13 +79,21 @@ static int eint[] = {
REG_BADPAT, /* "malformed number after (?(" */
REG_BADPAT, /* "conditional group containe more than two branches" */
REG_BADPAT, /* "assertion expected after (?(" */
- REG_BADPAT, /* "(?p must be followed by )" */
+ REG_BADPAT, /* "(?R or (?digits must be followed by )" */
REG_ECTYPE, /* "unknown POSIX class name" */
REG_BADPAT, /* "POSIX collating elements are not supported" */
REG_INVARG, /* "this version of PCRE is not compiled with PCRE_UTF8 support" */
- REG_BADPAT, /* "characters with values > 255 are not yet supported in classes" */
+ REG_BADPAT, /* "spare error" */
REG_BADPAT, /* "character value in \x{...} sequence is too large" */
- REG_BADPAT /* "invalid condition (?(0)" */
+ REG_BADPAT, /* "invalid condition (?(0)" */
+ REG_BADPAT, /* "\\C not allowed in lookbehind assertion" */
+ REG_EESCAPE, /* "PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X" */
+ REG_BADPAT, /* "number after (?C is > 255" */
+ REG_BADPAT, /* "closing ) for (?C expected" */
+ REG_BADPAT, /* "recursive call could loop indefinitely" */
+ REG_BADPAT, /* "unrecognized character after (?P" */
+ REG_BADPAT, /* "syntax error after (?P" */
+ REG_BADPAT /* "two named groups have the same name" */
};
/* Table of texts corresponding to POSIX error codes */
@@ -222,7 +231,9 @@ return 0;
/* Unfortunately, PCRE requires 3 ints of working space for each captured
substring, so we have to get and release working store instead of just using
the POSIX structures as was done in earlier releases when PCRE needed only 2
-ints. */
+ints. However, if the number of possible capturing brackets is small, use a
+block of store on the stack, to reduce the use of malloc/free. The threshold is
+in a macro that can be changed at configure time. */
int
regexec(regex_t *preg, const char *string, size_t nmatch,
@@ -231,6 +242,8 @@ regexec(regex_t *preg, const char *string, size_t nmatch,
int rc;
int options = 0;
int *ovector = NULL;
+int small_ovector[POSIX_MALLOC_THRESHOLD * 3];
+BOOL allocated_ovector = FALSE;
if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
@@ -239,8 +252,16 @@ preg->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
if (nmatch > 0)
{
- ovector = (int *)malloc(sizeof(int) * nmatch * 3);
- if (ovector == NULL) return REG_ESPACE;
+ if (nmatch <= POSIX_MALLOC_THRESHOLD)
+ {
+ ovector = &(small_ovector[0]);
+ }
+ else
+ {
+ ovector = (int *)malloc(sizeof(int) * nmatch * 3);
+ if (ovector == NULL) return REG_ESPACE;
+ allocated_ovector = TRUE;
+ }
}
rc = pcre_exec(preg->re_pcre, NULL, string, (int)strlen(string), 0, options,
@@ -251,19 +272,19 @@ if (rc == 0) rc = nmatch; /* All captured slots were filled in */
if (rc >= 0)
{
size_t i;
- for (i = 0; i < rc; i++)
+ for (i = 0; i < (size_t)rc; i++)
{
pmatch[i].rm_so = ovector[i*2];
pmatch[i].rm_eo = ovector[i*2+1];
}
- if (ovector != NULL) free(ovector);
+ if (allocated_ovector) free(ovector);
for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;
return 0;
}
else
{
- if (ovector != NULL) free(ovector);
+ if (allocated_ovector) free(ovector);
switch(rc)
{
case PCRE_ERROR_NOMATCH: return REG_NOMATCH;
diff --git a/pcreposix.h b/pcreposix.h
index e70af2d..05a0d7d 100644
--- a/pcreposix.h
+++ b/pcreposix.h
@@ -2,7 +2,7 @@
* Perl-Compatible Regular Expressions *
*************************************************/
-/* Copyright (c) 1997-2001 University of Cambridge */
+/* Copyright (c) 1997-2003 University of Cambridge */
#ifndef _PCREPOSIX_H
#define _PCREPOSIX_H
diff --git a/pcretest.c b/pcretest.c
index f04443a..1b79669 100644
--- a/pcretest.c
+++ b/pcretest.c
@@ -2,6 +2,10 @@
* PCRE testing program *
*************************************************/
+/* This program was hacked up as a tester for PCRE. I really should have
+written it more tidily in the first place. Will I ever learn? It has grown and
+been extended and consequently is now rather untidy in places. */
+
#include <ctype.h>
#include <stdio.h>
#include <string.h>
@@ -9,8 +13,10 @@
#include <time.h>
#include <locale.h>
-/* Use the internal info for displaying the results of pcre_study(). */
+/* We need the internal info for displaying the results of pcre_study(). Also
+for getting the opcodes for showing compiled code. */
+#define PCRE_SPY /* For Win32 build, import data, not export */
#include "internal.h"
/* It is possible to compile this test program without including support for
@@ -29,11 +35,17 @@ Makefile. */
#endif
#endif
-#define LOOPREPEAT 20000
+#define LOOPREPEAT 50000
static FILE *outfile;
static int log_store = 0;
+static int callout_count;
+static int callout_extra;
+static int callout_fail_count;
+static int callout_fail_id;
+static int first_callout;
+static int utf8;
static size_t gotten_store;
@@ -48,6 +60,49 @@ static int utf8_table3[] = {
0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
+
+/*************************************************
+* Print compiled regex *
+*************************************************/
+
+/* The code for doing this is held in a separate file that is also included in
+pcre.c when it is compiled with the debug switch. It defines a function called
+print_internals(), which uses a table of opcode lengths defined by the macro
+OP_LENGTHS, whose name must be OP_lengths. */
+
+static uschar OP_lengths[] = { OP_LENGTHS };
+
+#include "printint.c"
+
+
+
+/*************************************************
+* Read number from string *
+*************************************************/
+
+/* We don't use strtoul() because SunOS4 doesn't have it. Rather than mess
+around with conditional compilation, just do the job by hand. It is only used
+for unpicking the -o argument, so just keep it simple.
+
+Arguments:
+ str string to be converted
+ endptr where to put the end pointer
+
+Returns: the unsigned long
+*/
+
+static int
+get_value(unsigned char *str, unsigned char **endptr)
+{
+int result = 0;
+while(*str != 0 && isspace(*str)) str++;
+while (isdigit(*str)) result = result * 10 + (int)(*str++ - '0');
+*endptr = str;
+return(result);
+}
+
+
+
/*************************************************
* Convert character value to UTF-8 *
*************************************************/
@@ -143,256 +198,144 @@ return i+1;
+/*************************************************
+* Print character string *
+*************************************************/
+/* Character string printing function. Must handle UTF-8 strings in utf8
+mode. Yields number of characters printed. If handed a NULL file, just counts
+chars without printing. */
-
-/* Debugging function to print the internal form of the regex. This is the same
-code as contained in pcre.c under the DEBUG macro. */
-
-static const char *OP_names[] = {
- "End", "\\A", "\\B", "\\b", "\\D", "\\d",
- "\\S", "\\s", "\\W", "\\w", "\\Z", "\\z",
- "Opt", "^", "$", "Any", "chars", "not",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{",
- "*", "*?", "+", "+?", "?", "??", "{", "{",
- "class", "Ref", "Recurse",
- "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",
- "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cref",
- "Brazero", "Braminzero", "Branumber", "Bra"
-};
-
-
-static void print_internals(pcre *re)
+static int pchars(unsigned char *p, int length, FILE *f)
{
-unsigned char *code = ((real_pcre *)re)->code;
-
-fprintf(outfile, "------------------------------------------------------------------\n");
+int c;
+int yield = 0;
-for(;;)
+while (length-- > 0)
{
- int c;
- int charlength;
-
- fprintf(outfile, "%3d ", (int)(code - ((real_pcre *)re)->code));
-
- if (*code >= OP_BRA)
+ if (utf8)
{
- if (*code - OP_BRA > EXTRACT_BASIC_MAX)
- fprintf(outfile, "%3d Bra extra", (code[1] << 8) + code[2]);
- else
- fprintf(outfile, "%3d Bra %d", (code[1] << 8) + code[2], *code - OP_BRA);
- code += 2;
- }
+ int rc = utf82ord(p, &c);
- else switch(*code)
- {
- case OP_END:
- fprintf(outfile, " %s\n", OP_names[*code]);
- fprintf(outfile, "------------------------------------------------------------------\n");
- return;
-
- case OP_OPT:
- fprintf(outfile, " %.2x %s", code[1], OP_names[*code]);
- code++;
- break;
-
- case OP_CHARS:
- charlength = *(++code);
- fprintf(outfile, "%3d ", charlength);
- while (charlength-- > 0)
- if (isprint(c = *(++code))) fprintf(outfile, "%c", c);
- else fprintf(outfile, "\\x%02x", c);
- break;
-
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_ALT:
- case OP_KET:
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- case OP_COND:
- case OP_BRANUMBER:
- case OP_REVERSE:
- case OP_CREF:
- fprintf(outfile, "%3d %s", (code[1] << 8) + code[2], OP_names[*code]);
- code += 2;
- break;
-
- case OP_STAR:
- case OP_MINSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- if (*code >= OP_TYPESTAR)
- fprintf(outfile, " %s", OP_names[code[1]]);
- else if (isprint(c = code[1])) fprintf(outfile, " %c", c);
- else fprintf(outfile, " \\x%02x", c);
- fprintf(outfile, "%s", OP_names[*code++]);
- break;
-
- case OP_EXACT:
- case OP_UPTO:
- case OP_MINUPTO:
- if (isprint(c = code[3])) fprintf(outfile, " %c{", c);
- else fprintf(outfile, " \\x%02x{", c);
- if (*code != OP_EXACT) fprintf(outfile, ",");
- fprintf(outfile, "%d}", (code[1] << 8) + code[2]);
- if (*code == OP_MINUPTO) fprintf(outfile, "?");
- code += 3;
- break;
-
- case OP_TYPEEXACT:
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- fprintf(outfile, " %s{", OP_names[code[3]]);
- if (*code != OP_TYPEEXACT) fprintf(outfile, "0,");
- fprintf(outfile, "%d}", (code[1] << 8) + code[2]);
- if (*code == OP_TYPEMINUPTO) fprintf(outfile, "?");
- code += 3;
- break;
-
- case OP_NOT:
- if (isprint(c = *(++code))) fprintf(outfile, " [^%c]", c);
- else fprintf(outfile, " [^\\x%02x]", c);
- break;
-
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- if (isprint(c = code[1])) fprintf(outfile, " [^%c]", c);
- else fprintf(outfile, " [^\\x%02x]", c);
- fprintf(outfile, "%s", OP_names[*code++]);
- break;
-
- case OP_NOTEXACT:
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- if (isprint(c = code[3])) fprintf(outfile, " [^%c]{", c);
- else fprintf(outfile, " [^\\x%02x]{", c);
- if (*code != OP_NOTEXACT) fprintf(outfile, ",");
- fprintf(outfile, "%d}", (code[1] << 8) + code[2]);
- if (*code == OP_NOTMINUPTO) fprintf(outfile, "?");
- code += 3;
- break;
-
- case OP_REF:
- fprintf(outfile, " \\%d", (code[1] << 8) | code[2]);
- code += 3;
- goto CLASS_REF_REPEAT;
-
- case OP_CLASS:
+ if (rc > 0 && rc <= length + 1) /* Mustn't run over the end */
{
- int i, min, max;
- code++;
- fprintf(outfile, " [");
-
- for (i = 0; i < 256; i++)
+ length -= rc - 1;
+ p += rc;
+ if (c < 256 && isprint(c))
{
- if ((code[i/8] & (1 << (i&7))) != 0)
- {
- int j;
- for (j = i+1; j < 256; j++)
- if ((code[j/8] & (1 << (j&7))) == 0) break;
- if (i == '-' || i == ']') fprintf(outfile, "\\");
- if (isprint(i)) fprintf(outfile, "%c", i); else fprintf(outfile, "\\x%02x", i);
- if (--j > i)
- {
- fprintf(outfile, "-");
- if (j == '-' || j == ']') fprintf(outfile, "\\");
- if (isprint(j)) fprintf(outfile, "%c", j); else fprintf(outfile, "\\x%02x", j);
- }
- i = j;
- }
+ if (f != NULL) fprintf(f, "%c", c);
+ yield++;
}
- fprintf(outfile, "]");
- code += 32;
-
- CLASS_REF_REPEAT:
-
- switch(*code)
+ else
{
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- fprintf(outfile, "%s", OP_names[*code]);
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- min = (code[1] << 8) + code[2];
- max = (code[3] << 8) + code[4];
- if (max == 0) fprintf(outfile, "{%d,}", min);
- else fprintf(outfile, "{%d,%d}", min, max);
- if (*code == OP_CRMINRANGE) fprintf(outfile, "?");
- code += 4;
- break;
-
- default:
- code--;
+ int n;
+ if (f != NULL) fprintf(f, "\\x{%02x}%n", c, &n);
+ yield += n;
}
+ continue;
}
- break;
+ }
- /* Anything else is just a one-node item */
+ /* Not UTF-8, or malformed UTF-8 */
- default:
- fprintf(outfile, " %s", OP_names[*code]);
- break;
+ if (isprint(c = *(p++)))
+ {
+ if (f != NULL) fprintf(f, "%c", c);
+ yield++;
+ }
+ else
+ {
+ if (f != NULL) fprintf(f, "\\x%02x", c);
+ yield += 4;
}
-
- code++;
- fprintf(outfile, "\n");
}
+
+return yield;
}
-/* Character string printing function. A "normal" and a UTF-8 version. */
+/*************************************************
+* Callout function *
+*************************************************/
-static void pchars(unsigned char *p, int length, int utf8)
+/* Called from PCRE as a result of the (?C) item. We print out where we are in
+the match. Yield zero unless more callouts than the fail count, or the callout
+data is not zero. */
+
+static int callout(pcre_callout_block *cb)
{
-int c;
-while (length-- > 0)
+FILE *f = (first_callout | callout_extra)? outfile : NULL;
+int i, pre_start, post_start;
+
+if (callout_extra)
{
- if (utf8)
+ int i;
+ fprintf(f, "Callout %d: last capture = %d\n",
+ cb->callout_number, cb->capture_last);
+
+ for (i = 0; i < cb->capture_top * 2; i += 2)
{
- int rc = utf82ord(p, &c);
- if (rc > 0)
+ if (cb->offset_vector[i] < 0)
+ fprintf(f, "%2d: <unset>\n", i/2);
+ else
{
- length -= rc - 1;
- p += rc;
- if (c < 256 && isprint(c)) fprintf(outfile, "%c", c);
- else fprintf(outfile, "\\x{%02x}", c);
- continue;
+ fprintf(f, "%2d: ", i/2);
+ (void)pchars((unsigned char *)cb->subject + cb->offset_vector[i],
+ cb->offset_vector[i+1] - cb->offset_vector[i], f);
+ fprintf(f, "\n");
}
}
+ }
- /* Not UTF-8, or malformed UTF-8 */
+/* Re-print the subject in canonical form, the first time or if giving full
+datails. On subsequent calls in the same match, we use pchars just to find the
+printed lengths of the substrings. */
+
+if (f != NULL) fprintf(f, "--->");
+
+pre_start = pchars((unsigned char *)cb->subject, cb->start_match, f);
+post_start = pchars((unsigned char *)(cb->subject + cb->start_match),
+ cb->current_position - cb->start_match, f);
+
+(void)pchars((unsigned char *)(cb->subject + cb->current_position),
+ cb->subject_length - cb->current_position, f);
+
+if (f != NULL) fprintf(f, "\n");
- if (isprint(c = *(p++))) fprintf(outfile, "%c", c);
- else fprintf(outfile, "\\x%02x", c);
+/* Always print appropriate indicators, with callout number if not already
+shown */
+
+if (callout_extra) fprintf(outfile, " ");
+ else fprintf(outfile, "%3d ", cb->callout_number);
+
+for (i = 0; i < pre_start; i++) fprintf(outfile, " ");
+fprintf(outfile, "^");
+
+if (post_start > 0)
+ {
+ for (i = 0; i < post_start - 1; i++) fprintf(outfile, " ");
+ fprintf(outfile, "^");
}
+
+fprintf(outfile, "\n");
+
+first_callout = 0;
+
+if ((int)(cb->callout_data) != 0)
+ {
+ fprintf(outfile, "Callout data = %d\n", (int)(cb->callout_data));
+ return (int)(cb->callout_data);
+ }
+
+return (cb->callout_number != callout_fail_id)? 0 :
+ (++callout_count >= callout_fail_count)? 1 : 0;
}
+/*************************************************
+* Local malloc function *
+*************************************************/
/* Alternative malloc function, to test functionality and show the size of the
compiled re. */
@@ -400,14 +343,14 @@ compiled re. */
static void *new_malloc(size_t size)
{
gotten_store = size;
-if (log_store)
- fprintf(outfile, "Memory allocation (code space): %d\n",
- (int)((int)size - offsetof(real_pcre, code[0])));
return malloc(size);
}
+/*************************************************
+* Call pcre_fullinfo() *
+*************************************************/
/* Get one piece of information from the pcre_fullinfo() function */
@@ -420,6 +363,9 @@ if ((rc = pcre_fullinfo(re, study, option, ptr)) < 0)
+/*************************************************
+* Main Program *
+*************************************************/
/* Read lines from named file or stdin and write to named file or stdout; lines
consist of a regular expression, in delimiters and optionally followed by
@@ -453,7 +399,7 @@ outfile = stdout;
while (argc > 1 && argv[op][0] == '-')
{
- char *endptr;
+ unsigned char *endptr;
if (strcmp(argv[op], "-s") == 0 || strcmp(argv[op], "-m") == 0)
showstore = 1;
@@ -461,7 +407,7 @@ while (argc > 1 && argv[op][0] == '-')
else if (strcmp(argv[op], "-i") == 0) showinfo = 1;
else if (strcmp(argv[op], "-d") == 0) showinfo = debug = 1;
else if (strcmp(argv[op], "-o") == 0 && argc > 2 &&
- ((size_offsets = (int)strtoul(argv[op+1], &endptr, 10)), *endptr == 0))
+ ((size_offsets = get_value(argv[op+1], &endptr)), *endptr == 0))
{
op++;
argc--;
@@ -469,10 +415,28 @@ while (argc > 1 && argv[op][0] == '-')
#if !defined NOPOSIX
else if (strcmp(argv[op], "-p") == 0) posix = 1;
#endif
+ else if (strcmp(argv[op], "-C") == 0)
+ {
+ int rc;
+ printf("PCRE version %s\n", pcre_version());
+ printf("Compiled with\n");
+ (void)pcre_config(PCRE_CONFIG_UTF8, &rc);
+ printf(" %sUTF-8 support\n", rc? "" : "No ");
+ (void)pcre_config(PCRE_CONFIG_NEWLINE, &rc);
+ printf(" Newline character is %s\n", (rc == '\r')? "CR" : "LF");
+ (void)pcre_config(PCRE_CONFIG_LINK_SIZE, &rc);
+ printf(" Internal link size = %d\n", rc);
+ (void)pcre_config(PCRE_CONFIG_POSIX_MALLOC_THRESHOLD, &rc);
+ printf(" POSIX malloc threshold = %d\n", rc);
+ (void)pcre_config(PCRE_CONFIG_MATCH_LIMIT, &rc);
+ printf(" Default match limit = %d\n", rc);
+ exit(0);
+ }
else
{
printf("** Unknown or malformed option %s\n", argv[op]);
printf("Usage: pcretest [-d] [-i] [-o <n>] [-p] [-s] [-t] [<input> [<output>]]\n");
+ printf(" -C show PCRE compile-time options and exit\n");
printf(" -d debug: show compiled code; implies -i\n"
" -i show information about compiled pattern\n"
" -o <n> set size of offsets vector to <n>\n");
@@ -549,12 +513,14 @@ while (!done)
int do_g = 0;
int do_showinfo = showinfo;
int do_showrest = 0;
- int utf8 = 0;
int erroroffset, len, delimiter;
+ utf8 = 0;
+
if (infile == stdin) printf(" re> ");
if (fgets((char *)buffer, sizeof(buffer), infile) == NULL) break;
if (infile != stdin) fprintf(outfile, "%s", (char *)buffer);
+ fflush(outfile);
p = buffer;
while (isspace(*p)) p++;
@@ -633,6 +599,7 @@ while (!done)
case 'G': do_G = 1; break;
case 'I': do_showinfo = 1; break;
case 'M': log_store = 1; break;
+ case 'N': options |= PCRE_NO_AUTO_CAPTURE; break;
#if !defined NOPOSIX
case 'P': do_posix = 1; break;
@@ -705,8 +672,8 @@ while (!done)
}
time_taken = clock() - start_time;
fprintf(outfile, "Compile time %.3f milliseconds\n",
- ((double)time_taken * 1000.0) /
- ((double)LOOPREPEAT * (double)CLOCKS_PER_SEC));
+ (((double)time_taken * 1000.0) / (double)LOOPREPEAT) /
+ (double)CLOCKS_PER_SEC);
}
re = pcre_compile((char *)p, options, &error, &erroroffset, tables);
@@ -740,21 +707,36 @@ while (!done)
info-returning functions. The old one has a limited interface and
returns only limited data. Check that it agrees with the newer one. */
+ if (log_store)
+ fprintf(outfile, "Memory allocation (code space): %d\n",
+ (int)(gotten_store -
+ sizeof(real_pcre) -
+ ((real_pcre *)re)->name_count * ((real_pcre *)re)->name_entry_size));
+
if (do_showinfo)
{
unsigned long int get_options;
int old_first_char, old_options, old_count;
int count, backrefmax, first_char, need_char;
+ int nameentrysize, namecount;
+ const uschar *nametable;
size_t size;
- if (do_debug) print_internals(re);
+ if (do_debug)
+ {
+ fprintf(outfile, "------------------------------------------------------------------\n");
+ print_internals(re, outfile);
+ }
new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options);
new_info(re, NULL, PCRE_INFO_SIZE, &size);
new_info(re, NULL, PCRE_INFO_CAPTURECOUNT, &count);
new_info(re, NULL, PCRE_INFO_BACKREFMAX, &backrefmax);
- new_info(re, NULL, PCRE_INFO_FIRSTCHAR, &first_char);
+ new_info(re, NULL, PCRE_INFO_FIRSTBYTE, &first_char);
new_info(re, NULL, PCRE_INFO_LASTLITERAL, &need_char);
+ new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &nameentrysize);
+ new_info(re, NULL, PCRE_INFO_NAMECOUNT, &namecount);
+ new_info(re, NULL, PCRE_INFO_NAMETABLE, &nametable);
old_count = pcre_info(re, &old_options, &old_first_char);
if (count < 0) fprintf(outfile,
@@ -781,6 +763,19 @@ while (!done)
fprintf(outfile, "Capturing subpattern count = %d\n", count);
if (backrefmax > 0)
fprintf(outfile, "Max back reference = %d\n", backrefmax);
+
+ if (namecount > 0)
+ {
+ fprintf(outfile, "Named capturing subpatterns:\n");
+ while (namecount-- > 0)
+ {
+ fprintf(outfile, " %s %*s%3d\n", nametable + 2,
+ nameentrysize - 3 - (int)strlen((char *)nametable + 2), "",
+ GET2(nametable, 0));
+ nametable += nameentrysize;
+ }
+ }
+
if (get_options == 0) fprintf(outfile, "No options\n");
else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s\n",
((get_options & PCRE_ANCHORED) != 0)? " anchored" : "",
@@ -806,10 +801,13 @@ while (!done)
}
else
{
- if (isprint(first_char))
- fprintf(outfile, "First char = \'%c\'\n", first_char);
+ int ch = first_char & 255;
+ char *caseless = ((first_char & REQ_CASELESS) == 0)?
+ "" : " (caseless)";
+ if (isprint(ch))
+ fprintf(outfile, "First char = \'%c\'%s\n", ch, caseless);
else
- fprintf(outfile, "First char = %d\n", first_char);
+ fprintf(outfile, "First char = %d%s\n", ch, caseless);
}
if (need_char < 0)
@@ -818,10 +816,13 @@ while (!done)
}
else
{
- if (isprint(need_char))
- fprintf(outfile, "Need char = \'%c\'\n", need_char);
+ int ch = need_char & 255;
+ char *caseless = ((need_char & REQ_CASELESS) == 0)?
+ "" : " (caseless)";
+ if (isprint(ch))
+ fprintf(outfile, "Need char = \'%c\'%s\n", ch, caseless);
else
- fprintf(outfile, "Need char = %d\n", need_char);
+ fprintf(outfile, "Need char = %d%s\n", ch, caseless);
}
}
@@ -840,8 +841,8 @@ while (!done)
time_taken = clock() - start_time;
if (extra != NULL) free(extra);
fprintf(outfile, " Study time %.3f milliseconds\n",
- ((double)time_taken * 1000.0)/
- ((double)LOOPREPEAT * (double)CLOCKS_PER_SEC));
+ (((double)time_taken * 1000.0) / (double)LOOPREPEAT) /
+ (double)CLOCKS_PER_SEC);
}
extra = pcre_study(re, study_options, &error);
@@ -852,8 +853,11 @@ while (!done)
else if (do_showinfo)
{
+ size_t size;
uschar *start_bits = NULL;
+ new_info(re, extra, PCRE_INFO_STUDYSIZE, &size);
new_info(re, extra, PCRE_INFO_FIRSTTABLE, &start_bits);
+ fprintf(outfile, "Study size = %d\n", size);
if (start_bits == NULL)
fprintf(outfile, "No starting character set\n");
else
@@ -896,8 +900,11 @@ while (!done)
unsigned char *bptr = dbuffer;
int *use_offsets = offsets;
int use_size_offsets = size_offsets;
+ int callout_data = 0;
+ int callout_data_set = 0;
int count, c;
int copystrings = 0;
+ int find_match_limit = 0;
int getstrings = 0;
int getlist = 0;
int gmatched = 0;
@@ -906,6 +913,13 @@ while (!done)
options = 0;
+ pcre_callout = callout;
+ first_callout = 1;
+ callout_extra = 0;
+ callout_count = 0;
+ callout_fail_count = 999999;
+ callout_fail_id = -1;
+
if (infile == stdin) printf("data> ");
if (fgets((char *)buffer, sizeof(buffer), infile) == NULL)
{
@@ -927,6 +941,7 @@ while (!done)
{
int i = 0;
int n = 0;
+
if (c == '\\') switch ((c = *p++))
{
case 'a': c = 7; break;
@@ -991,19 +1006,85 @@ while (!done)
continue;
case 'C':
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
- copystrings |= 1 << n;
+ if (isdigit(*p)) /* Set copy string */
+ {
+ while(isdigit(*p)) n = n * 10 + *p++ - '0';
+ copystrings |= 1 << n;
+ }
+ else if (isalnum(*p))
+ {
+ uschar name[256];
+ uschar *pp = name;
+ while (isalnum(*p)) *pp++ = *p++;
+ *pp = 0;
+ n = pcre_get_stringnumber(re, name);
+ if (n < 0)
+ fprintf(outfile, "no parentheses with name \"%s\"\n", name);
+ else copystrings |= 1 << n;
+ }
+ else if (*p == '+')
+ {
+ callout_extra = 1;
+ p++;
+ }
+ else if (*p == '-')
+ {
+ pcre_callout = NULL;
+ p++;
+ }
+ else if (*p == '!')
+ {
+ callout_fail_id = 0;
+ p++;
+ while(isdigit(*p))
+ callout_fail_id = callout_fail_id * 10 + *p++ - '0';
+ callout_fail_count = 0;
+ if (*p == '!')
+ {
+ p++;
+ while(isdigit(*p))
+ callout_fail_count = callout_fail_count * 10 + *p++ - '0';
+ }
+ }
+ else if (*p == '*')
+ {
+ int sign = 1;
+ callout_data = 0;
+ if (*(++p) == '-') { sign = -1; p++; }
+ while(isdigit(*p))
+ callout_data = callout_data * 10 + *p++ - '0';
+ callout_data *= sign;
+ callout_data_set = 1;
+ }
continue;
case 'G':
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
- getstrings |= 1 << n;
+ if (isdigit(*p))
+ {
+ while(isdigit(*p)) n = n * 10 + *p++ - '0';
+ getstrings |= 1 << n;
+ }
+ else if (isalnum(*p))
+ {
+ uschar name[256];
+ uschar *pp = name;
+ while (isalnum(*p)) *pp++ = *p++;
+ *pp = 0;
+ n = pcre_get_stringnumber(re, name);
+ if (n < 0)
+ fprintf(outfile, "no parentheses with name \"%s\"\n", name);
+ else getstrings |= 1 << n;
+ }
continue;
case 'L':
getlist = 1;
continue;
+ case 'M':
+ find_match_limit = 1;
+ continue;
+
case 'N':
options |= PCRE_NOTEMPTY;
continue;
@@ -1023,7 +1104,7 @@ while (!done)
}
}
use_size_offsets = n;
- if (n == 0) use_offsets = NULL;
+ if (n == 0) use_offsets = NULL; /* Ensures it can't write to it */
continue;
case 'Z':
@@ -1036,14 +1117,16 @@ while (!done)
len = q - dbuffer;
/* Handle matching via the POSIX interface, which does not
- support timing. */
+ support timing or playing with the match limit or callout data. */
#if !defined NOPOSIX
if (posix || do_posix)
{
int rc;
int eflags = 0;
- regmatch_t *pmatch = malloc(sizeof(regmatch_t) * use_size_offsets);
+ regmatch_t *pmatch = NULL;
+ if (use_size_offsets > 0)
+ pmatch = malloc(sizeof(regmatch_t) * use_size_offsets);
if ((options & PCRE_NOTBOL) != 0) eflags |= REG_NOTBOL;
if ((options & PCRE_NOTEOL) != 0) eflags |= REG_NOTEOL;
@@ -1057,18 +1140,19 @@ while (!done)
else
{
size_t i;
- for (i = 0; i < use_size_offsets; i++)
+ for (i = 0; i < (size_t)use_size_offsets; i++)
{
if (pmatch[i].rm_so >= 0)
{
fprintf(outfile, "%2d: ", (int)i);
- pchars(dbuffer + pmatch[i].rm_so,
- pmatch[i].rm_eo - pmatch[i].rm_so, utf8);
+ (void)pchars(dbuffer + pmatch[i].rm_so,
+ pmatch[i].rm_eo - pmatch[i].rm_so, outfile);
fprintf(outfile, "\n");
if (i == 0 && do_showrest)
{
fprintf(outfile, " 0+ ");
- pchars(dbuffer + pmatch[i].rm_eo, len - pmatch[i].rm_eo, utf8);
+ (void)pchars(dbuffer + pmatch[i].rm_eo, len - pmatch[i].rm_eo,
+ outfile);
fprintf(outfile, "\n");
}
}
@@ -1094,11 +1178,74 @@ while (!done)
start_offset, options | g_notempty, use_offsets, use_size_offsets);
time_taken = clock() - start_time;
fprintf(outfile, "Execute time %.3f milliseconds\n",
- ((double)time_taken * 1000.0)/
- ((double)LOOPREPEAT * (double)CLOCKS_PER_SEC));
+ (((double)time_taken * 1000.0) / (double)LOOPREPEAT) /
+ (double)CLOCKS_PER_SEC);
}
- count = pcre_exec(re, extra, (char *)bptr, len,
+ /* If find_match_limit is set, we want to do repeated matches with
+ varying limits in order to find the minimum value. */
+
+ if (find_match_limit)
+ {
+ int min = 0;
+ int mid = 64;
+ int max = -1;
+
+ if (extra == NULL)
+ {
+ extra = malloc(sizeof(pcre_extra));
+ extra->flags = 0;
+ }
+ extra->flags |= PCRE_EXTRA_MATCH_LIMIT;
+
+ for (;;)
+ {
+ extra->match_limit = mid;
+ count = pcre_exec(re, extra, (char *)bptr, len, start_offset,
+ options | g_notempty, use_offsets, use_size_offsets);
+ if (count == PCRE_ERROR_MATCHLIMIT)
+ {
+ /* fprintf(outfile, "Testing match limit = %d\n", mid); */
+ min = mid;
+ mid = (mid == max - 1)? max : (max > 0)? (min + max)/2 : mid*2;
+ }
+ else if (count >= 0 || count == PCRE_ERROR_NOMATCH)
+ {
+ if (mid == min + 1)
+ {
+ fprintf(outfile, "Minimum match limit = %d\n", mid);
+ break;
+ }
+ /* fprintf(outfile, "Testing match limit = %d\n", mid); */
+ max = mid;
+ mid = (min + mid)/2;
+ }
+ else break; /* Some other error */
+ }
+
+ extra->flags &= ~PCRE_EXTRA_MATCH_LIMIT;
+ }
+
+ /* If callout_data is set, use the interface with additional data */
+
+ else if (callout_data_set)
+ {
+ if (extra == NULL)
+ {
+ extra = malloc(sizeof(pcre_extra));
+ extra->flags = 0;
+ }
+ extra->flags |= PCRE_EXTRA_CALLOUT_DATA;
+ extra->callout_data = (void *)callout_data;
+ count = pcre_exec(re, extra, (char *)bptr, len, start_offset,
+ options | g_notempty, use_offsets, use_size_offsets);
+ extra->flags &= ~PCRE_EXTRA_CALLOUT_DATA;
+ }
+
+ /* The normal case is just to do the match once, with the default
+ value of match_limit. */
+
+ else count = pcre_exec(re, extra, (char *)bptr, len,
start_offset, options | g_notempty, use_offsets, use_size_offsets);
if (count == 0)
@@ -1119,14 +1266,16 @@ while (!done)
else
{
fprintf(outfile, "%2d: ", i/2);
- pchars(bptr + use_offsets[i], use_offsets[i+1] - use_offsets[i], utf8);
+ (void)pchars(bptr + use_offsets[i],
+ use_offsets[i+1] - use_offsets[i], outfile);
fprintf(outfile, "\n");
if (i == 0)
{
if (do_showrest)
{
fprintf(outfile, " 0+ ");
- pchars(bptr + use_offsets[i+1], len - use_offsets[i+1], utf8);
+ (void)pchars(bptr + use_offsets[i+1], len - use_offsets[i+1],
+ outfile);
fprintf(outfile, "\n");
}
}
diff --git a/perltest b/perltest
index e6f7974..bb34cc8 100755
--- a/perltest
+++ b/perltest
@@ -1,19 +1,39 @@
#! /usr/bin/perl
# Program for testing regular expressions with perl to check that PCRE handles
-# them the same.
+# them the same. This is the version that supports /8 for UTF-8 testing. As it
+# stands, it requires at least Perl 5.8 for UTF-8 support. For Perl 5.6, it
+# can be used as is for non-UTF-8 testing, but you have to uncomment the
+# "use utf8" lines in order to to UTF-8 stuff (and you mustn't uncomment them
+# for non-UTF-8 use).
-# Function for turning a string into a string of printing chars
+# Function for turning a string into a string of printing chars. There are
+# currently problems with UTF-8 strings; this fudges round them.
sub pchars {
my($t) = "";
-foreach $c (split(//, $_[0]))
+if ($utf8)
{
- if (ord $c >= 32 && ord $c < 127) { $t .= $c; }
- else { $t .= sprintf("\\x%02x", ord $c); }
+# use utf8; <=============== For UTF-8 in Perl 5.6
+ @p = unpack('U*', $_[0]);
+ foreach $c (@p)
+ {
+ if ($c >= 32 && $c < 127) { $t .= chr $c; }
+ else { $t .= sprintf("\\x{%02x}", $c); }
+ }
}
+
+else
+ {
+ foreach $c (split(//, $_[0]))
+ {
+ if (ord $c >= 32 && ord $c < 127) { $t .= $c; }
+ else { $t .= sprintf("\\x%02x", ord $c); }
+ }
+ }
+
$t;
}
@@ -64,14 +84,27 @@ for (;;)
chomp($pattern);
$pattern =~ s/\s+$//;
- # The private /+ modifier means "print $' afterwards". We use it
- # only on the end of patterns to make it easy to chop off here.
+ # The private /+ modifier means "print $' afterwards".
$showrest = ($pattern =~ s/\+(?=[a-z]*$)//);
+ # The private /8 modifier means "operate in UTF-8". Currently, Perl
+ # has bugs that we try to work around using this flag.
+
+ $utf8 = ($pattern =~ s/8(?=[a-z]*$)//);
+
# Check that the pattern is valid
- eval "\$_ =~ ${pattern}";
+ if ($utf8)
+ {
+# use utf8; <=============== For UTF-8 in Perl 5.6
+ eval "\$_ =~ ${pattern}";
+ }
+ else
+ {
+ eval "\$_ =~ ${pattern}";
+ }
+
if ($@)
{
printf $outfile "Error: $@";
@@ -112,8 +145,7 @@ for (;;)
@subs = ();
- eval "${cmd} (\$x =~ ${pattern}) {" .
- "push \@subs,\$&;" .
+ $pushes = "push \@subs,\$&;" .
"push \@subs,\$1;" .
"push \@subs,\$2;" .
"push \@subs,\$3;" .
@@ -132,6 +164,16 @@ for (;;)
"push \@subs,\$16;" .
"push \@subs,\$'; }";
+ if ($utf8)
+ {
+# use utf8; <=============== For UTF-8 in Perl 5.6
+ eval "${cmd} (\$x =~ ${pattern}) {" . $pushes;
+ }
+ else
+ {
+ eval "${cmd} (\$x =~ ${pattern}) {" . $pushes;
+ }
+
if ($@)
{
printf $outfile "Error: $@\n";
diff --git a/perltest8 b/perltest8
deleted file mode 100755
index 2fe522d..0000000
--- a/perltest8
+++ /dev/null
@@ -1,208 +0,0 @@
-#! /usr/bin/perl
-
-# Program for testing regular expressions with perl to check that PCRE handles
-# them the same. This is the version that supports /8 for UTF-8 testing. It
-# requires at least Perl 5.6.
-
-
-# Function for turning a string into a string of printing chars. There are
-# currently problems with UTF-8 strings; this fudges round them.
-
-sub pchars {
-my($t) = "";
-
-if ($utf8)
- {
- use utf8;
- @p = unpack('U*', $_[0]);
- foreach $c (@p)
- {
- if ($c >= 32 && $c < 127) { $t .= chr $c; }
- else { $t .= sprintf("\\x{%02x}", $c); }
- }
- }
-
-else
- {
- foreach $c (split(//, $_[0]))
- {
- if (ord $c >= 32 && ord $c < 127) { $t .= $c; }
- else { $t .= sprintf("\\x%02x", ord $c); }
- }
- }
-
-$t;
-}
-
-
-
-# Read lines from named file or stdin and write to named file or stdout; lines
-# consist of a regular expression, in delimiters and optionally followed by
-# options, followed by a set of test data, terminated by an empty line.
-
-# Sort out the input and output files
-
-if (@ARGV > 0)
- {
- open(INFILE, "<$ARGV[0]") || die "Failed to open $ARGV[0]\n";
- $infile = "INFILE";
- }
-else { $infile = "STDIN"; }
-
-if (@ARGV > 1)
- {
- open(OUTFILE, ">$ARGV[1]") || die "Failed to open $ARGV[1]\n";
- $outfile = "OUTFILE";
- }
-else { $outfile = "STDOUT"; }
-
-printf($outfile "Perl $] Regular Expressions\n\n");
-
-# Main loop
-
-NEXT_RE:
-for (;;)
- {
- printf " re> " if $infile eq "STDIN";
- last if ! ($_ = <$infile>);
- printf $outfile "$_" if $infile ne "STDIN";
- next if ($_ eq "");
-
- $pattern = $_;
-
- while ($pattern !~ /^\s*(.).*\1/s)
- {
- printf " > " if $infile eq "STDIN";
- last if ! ($_ = <$infile>);
- printf $outfile "$_" if $infile ne "STDIN";
- $pattern .= $_;
- }
-
- chomp($pattern);
- $pattern =~ s/\s+$//;
-
- # The private /+ modifier means "print $' afterwards".
-
- $showrest = ($pattern =~ s/\+(?=[a-z]*$)//);
-
- # The private /8 modifier means "operate in UTF-8". Currently, Perl
- # has bugs that we try to work around using this flag.
-
- $utf8 = ($pattern =~ s/8(?=[a-z]*$)//);
-
- # Check that the pattern is valid
-
- if ($utf8)
- {
- use utf8;
- eval "\$_ =~ ${pattern}";
- }
- else
- {
- eval "\$_ =~ ${pattern}";
- }
-
- if ($@)
- {
- printf $outfile "Error: $@";
- next NEXT_RE;
- }
-
- # If the /g modifier is present, we want to put a loop round the matching;
- # otherwise just a single "if".
-
- $cmd = ($pattern =~ /g[a-z]*$/)? "while" : "if";
-
- # If the pattern is actually the null string, Perl uses the most recently
- # executed (and successfully compiled) regex is used instead. This is a
- # nasty trap for the unwary! The PCRE test suite does contain null strings
- # in places - if they are allowed through here all sorts of weird and
- # unexpected effects happen. To avoid this, we replace such patterns with
- # a non-null pattern that has the same effect.
-
- $pattern = "/(?#)/$2" if ($pattern =~ /^(.)\1(.*)$/);
-
- # Read data lines and test them
-
- for (;;)
- {
- printf "data> " if $infile eq "STDIN";
- last NEXT_RE if ! ($_ = <$infile>);
- chomp;
- printf $outfile "$_\n" if $infile ne "STDIN";
-
- s/\s+$//;
- s/^\s+//;
-
- last if ($_ eq "");
-
- $x = eval "\"$_\""; # To get escapes processed
-
- # Empty array for holding results, then do the matching.
-
- @subs = ();
-
- $pushes = "push \@subs,\$&;" .
- "push \@subs,\$1;" .
- "push \@subs,\$2;" .
- "push \@subs,\$3;" .
- "push \@subs,\$4;" .
- "push \@subs,\$5;" .
- "push \@subs,\$6;" .
- "push \@subs,\$7;" .
- "push \@subs,\$8;" .
- "push \@subs,\$9;" .
- "push \@subs,\$10;" .
- "push \@subs,\$11;" .
- "push \@subs,\$12;" .
- "push \@subs,\$13;" .
- "push \@subs,\$14;" .
- "push \@subs,\$15;" .
- "push \@subs,\$16;" .
- "push \@subs,\$'; }";
-
- if ($utf8)
- {
- use utf8;
- eval "${cmd} (\$x =~ ${pattern}) {" . $pushes;
- }
- else
- {
- eval "${cmd} (\$x =~ ${pattern}) {" . $pushes;
- }
-
- if ($@)
- {
- printf $outfile "Error: $@\n";
- next NEXT_RE;
- }
- elsif (scalar(@subs) == 0)
- {
- printf $outfile "No match\n";
- }
- else
- {
- while (scalar(@subs) != 0)
- {
- printf $outfile (" 0: %s\n", &pchars($subs[0]));
- printf $outfile (" 0+ %s\n", &pchars($subs[17])) if $showrest;
- $last_printed = 0;
- for ($i = 1; $i <= 16; $i++)
- {
- if (defined $subs[$i])
- {
- while ($last_printed++ < $i-1)
- { printf $outfile ("%2d: <unset>\n", $last_printed); }
- printf $outfile ("%2d: %s\n", $i, &pchars($subs[$i]));
- $last_printed = $i;
- }
- }
- splice(@subs, 0, 18);
- }
- }
- }
- }
-
-printf $outfile "\n";
-
-# End
diff --git a/printint.c b/printint.c
new file mode 100644
index 0000000..276704b
--- /dev/null
+++ b/printint.c
@@ -0,0 +1,360 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+This is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language. See
+the file Tech.Notes for some information on the internals.
+
+Written by: Philip Hazel <ph10@cam.ac.uk>
+
+ Copyright (c) 1997-2003 University of Cambridge
+
+-----------------------------------------------------------------------------
+Permission is granted to anyone to use this software for any purpose on any
+computer system, and to redistribute it freely, subject to the following
+restrictions:
+
+1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains a debugging function for printing out the internal form
+of a compiled regular expression. It is kept in a separate file so that it can
+be #included both in the pcretest program, and in the library itself when
+compiled with the debugging switch. */
+
+
+static const char *OP_names[] = { OP_NAME_LIST };
+
+
+/*************************************************
+* Print single- or multi-byte character *
+*************************************************/
+
+/* These tables are actually copies of ones in pcre.c. If we compile the
+library with debugging, they are included twice, but that isn't really a
+problem - compiling with debugging is pretty rare and these are very small. */
+
+static int utf8_t3[] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
+
+static uschar utf8_t4[] = {
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+ 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
+
+static int
+print_char(FILE *f, uschar *ptr, BOOL utf8)
+{
+int c = *ptr;
+
+if (!utf8 || (c & 0xc0) != 0xc0)
+ {
+ if (isprint(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
+ return 0;
+ }
+else
+ {
+ int i;
+ int a = utf8_t4[c & 0x3f]; /* Number of additional bytes */
+ int s = 6*a;
+ c = (c & utf8_t3[a]) << s;
+ for (i = 1; i <= a; i++)
+ {
+ s -= 6;
+ c |= (ptr[i] & 0x3f) << s;
+ }
+ if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c);
+ return a;
+ }
+}
+
+
+
+
+/*************************************************
+* Print compiled regex *
+*************************************************/
+
+static void
+print_internals(pcre *external_re, FILE *f)
+{
+real_pcre *re = (real_pcre *)external_re;
+uschar *codestart =
+ (uschar *)re + sizeof(real_pcre) + re->name_count * re->name_entry_size;
+uschar *code = codestart;
+BOOL utf8 = (re->options & PCRE_UTF8) != 0;
+
+for(;;)
+ {
+ uschar *ccode;
+ int c;
+ int extra = 0;
+
+ fprintf(f, "%3d ", code - codestart);
+
+ if (*code >= OP_BRA)
+ {
+ if (*code - OP_BRA > EXTRACT_BASIC_MAX)
+ fprintf(f, "%3d Bra extra\n", GET(code, 1));
+ else
+ fprintf(f, "%3d Bra %d\n", GET(code, 1), *code - OP_BRA);
+ code += OP_lengths[OP_BRA];
+ continue;
+ }
+
+ switch(*code)
+ {
+ case OP_END:
+ fprintf(f, " %s\n", OP_names[*code]);
+ fprintf(f, "------------------------------------------------------------------\n");
+ return;
+
+ case OP_OPT:
+ fprintf(f, " %.2x %s", code[1], OP_names[*code]);
+ break;
+
+ case OP_CHARS:
+ {
+ int charlength = code[1];
+ ccode = code + 2;
+ extra = charlength;
+ fprintf(f, "%3d ", charlength);
+ while (charlength > 0)
+ {
+ int extra = print_char(f, ccode, utf8);
+ ccode += 1 + extra;
+ charlength -= 1 + extra;
+ }
+ }
+ break;
+
+ case OP_KETRMAX:
+ case OP_KETRMIN:
+ case OP_ALT:
+ case OP_KET:
+ case OP_ASSERT:
+ case OP_ASSERT_NOT:
+ case OP_ASSERTBACK:
+ case OP_ASSERTBACK_NOT:
+ case OP_ONCE:
+ case OP_COND:
+ case OP_REVERSE:
+ fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]);
+ break;
+
+ case OP_BRANUMBER:
+ printf("%3d %s", GET2(code, 1), OP_names[*code]);
+ break;
+
+ case OP_CREF:
+ if (GET2(code, 1) == CREF_RECURSE)
+ fprintf(f, " Cond recurse");
+ else
+ fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);
+ break;
+
+ case OP_STAR:
+ case OP_MINSTAR:
+ case OP_PLUS:
+ case OP_MINPLUS:
+ case OP_QUERY:
+ case OP_MINQUERY:
+ case OP_TYPESTAR:
+ case OP_TYPEMINSTAR:
+ case OP_TYPEPLUS:
+ case OP_TYPEMINPLUS:
+ case OP_TYPEQUERY:
+ case OP_TYPEMINQUERY:
+ fprintf(f, " ");
+ if (*code >= OP_TYPESTAR) fprintf(f, "%s", OP_names[code[1]]);
+ else extra = print_char(f, code+1, utf8);
+ fprintf(f, "%s", OP_names[*code]);
+ break;
+
+ case OP_EXACT:
+ case OP_UPTO:
+ case OP_MINUPTO:
+ fprintf(f, " ");
+ extra = print_char(f, code+3, utf8);
+ fprintf(f, "{");
+ if (*code != OP_EXACT) fprintf(f, ",");
+ fprintf(f, "%d}", GET2(code,1));
+ if (*code == OP_MINUPTO) fprintf(f, "?");
+ break;
+
+ case OP_TYPEEXACT:
+ case OP_TYPEUPTO:
+ case OP_TYPEMINUPTO:
+ fprintf(f, " %s{", OP_names[code[3]]);
+ if (*code != OP_TYPEEXACT) fprintf(f, "0,");
+ fprintf(f, "%d}", GET2(code,1));
+ if (*code == OP_TYPEMINUPTO) fprintf(f, "?");
+ break;
+
+ case OP_NOT:
+ if (isprint(c = code[1])) fprintf(f, " [^%c]", c);
+ else fprintf(f, " [^\\x%02x]", c);
+ break;
+
+ case OP_NOTSTAR:
+ case OP_NOTMINSTAR:
+ case OP_NOTPLUS:
+ case OP_NOTMINPLUS:
+ case OP_NOTQUERY:
+ case OP_NOTMINQUERY:
+ if (isprint(c = code[1])) fprintf(f, " [^%c]", c);
+ else fprintf(f, " [^\\x%02x]", c);
+ fprintf(f, "%s", OP_names[*code]);
+ break;
+
+ case OP_NOTEXACT:
+ case OP_NOTUPTO:
+ case OP_NOTMINUPTO:
+ if (isprint(c = code[3])) fprintf(f, " [^%c]{", c);
+ else fprintf(f, " [^\\x%02x]{", c);
+ if (*code != OP_NOTEXACT) fprintf(f, ",");
+ fprintf(f, "%d}", GET2(code,1));
+ if (*code == OP_NOTMINUPTO) fprintf(f, "?");
+ break;
+
+ case OP_RECURSE:
+ fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]);
+ break;
+
+ case OP_REF:
+ fprintf(f, " \\%d", GET2(code,1));
+ ccode = code + OP_lengths[*code];
+ goto CLASS_REF_REPEAT;
+
+ case OP_CALLOUT:
+ fprintf(f, " %s %d", OP_names[*code], code[1]);
+ break;
+
+ /* OP_XCLASS can only occur in UTF-8 mode. However, there's no harm in
+ having this code always here, and it makes it less messy without all those
+ #ifdefs. */
+
+ case OP_CLASS:
+ case OP_NCLASS:
+ case OP_XCLASS:
+ {
+ int i, min, max;
+ BOOL printmap;
+
+ fprintf(f, " [");
+
+ if (*code == OP_XCLASS)
+ {
+ extra = GET(code, 1);
+ ccode = code + LINK_SIZE + 1;
+ printmap = (*ccode & XCL_MAP) != 0;
+ if ((*ccode++ & XCL_NOT) != 0) fprintf(f, "^");
+ }
+ else
+ {
+ printmap = TRUE;
+ ccode = code + 1;
+ }
+
+ /* Print a bit map */
+
+ if (printmap)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ if ((ccode[i/8] & (1 << (i&7))) != 0)
+ {
+ int j;
+ for (j = i+1; j < 256; j++)
+ if ((ccode[j/8] & (1 << (j&7))) == 0) break;
+ if (i == '-' || i == ']') fprintf(f, "\\");
+ if (isprint(i)) fprintf(f, "%c", i); else fprintf(f, "\\x%02x", i);
+ if (--j > i)
+ {
+ fprintf(f, "-");
+ if (j == '-' || j == ']') fprintf(f, "\\");
+ if (isprint(j)) fprintf(f, "%c", j); else fprintf(f, "\\x%02x", j);
+ }
+ i = j;
+ }
+ }
+ ccode += 32;
+ }
+
+ /* For an XCLASS there is always some additional data */
+
+ if (*code == OP_XCLASS)
+ {
+ int c;
+ while ((c = *ccode++) != XCL_END)
+ {
+ ccode += 1 + print_char(f, ccode, TRUE);
+ if (c == XCL_RANGE)
+ {
+ fprintf(f, "-");
+ ccode += 1 + print_char(f, ccode, TRUE);
+ }
+ }
+ }
+
+ /* Indicate a non-UTF8 class which was created by negation */
+
+ fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");
+
+ /* Handle repeats after a class or a back reference */
+
+ CLASS_REF_REPEAT:
+ switch(*ccode)
+ {
+ case OP_CRSTAR:
+ case OP_CRMINSTAR:
+ case OP_CRPLUS:
+ case OP_CRMINPLUS:
+ case OP_CRQUERY:
+ case OP_CRMINQUERY:
+ fprintf(f, "%s", OP_names[*ccode]);
+ extra = OP_lengths[*ccode];
+ break;
+
+ case OP_CRRANGE:
+ case OP_CRMINRANGE:
+ min = GET2(ccode,1);
+ max = GET2(ccode,3);
+ if (max == 0) fprintf(f, "{%d,}", min);
+ else fprintf(f, "{%d,%d}", min, max);
+ if (*ccode == OP_CRMINRANGE) fprintf(f, "?");
+ extra = OP_lengths[*ccode];
+ break;
+ }
+ }
+ break;
+
+ /* Anything else is just an item with no data*/
+
+ default:
+ fprintf(f, " %s", OP_names[*code]);
+ break;
+ }
+
+ code += OP_lengths[*code] + extra;
+ fprintf(f, "\n");
+ }
+}
+
+/* End of printint.c */
diff --git a/study.c b/study.c
index f924543..4320bd2 100644
--- a/study.c
+++ b/study.c
@@ -9,7 +9,7 @@ the file Tech.Notes for some information on the internals.
Written by: Philip Hazel <ph10@cam.ac.uk>
- Copyright (c) 1997-2001 University of Cambridge
+ Copyright (c) 1997-2002 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
@@ -78,6 +78,7 @@ Arguments:
code points to an expression
start_bits points to a 32-byte table, initialized to 0
caseless the current state of the caseless flag
+ utf8 TRUE if in UTF-8 mode
cd the block with char table pointers
Returns: TRUE if table built, FALSE otherwise
@@ -85,7 +86,7 @@ Returns: TRUE if table built, FALSE otherwise
static BOOL
set_start_bits(const uschar *code, uschar *start_bits, BOOL caseless,
- compile_data *cd)
+ BOOL utf8, compile_data *cd)
{
register int c;
@@ -99,7 +100,7 @@ volatile int dummy;
do
{
- const uschar *tcode = code + 3;
+ const uschar *tcode = code + 1 + LINK_SIZE;
BOOL try_next = TRUE;
while (try_next)
@@ -109,7 +110,7 @@ do
if ((int)*tcode >= OP_BRA || *tcode == OP_ASSERT)
{
- if (!set_start_bits(tcode, start_bits, caseless, cd))
+ if (!set_start_bits(tcode, start_bits, caseless, utf8, cd))
return FALSE;
try_next = FALSE;
}
@@ -119,6 +120,12 @@ do
default:
return FALSE;
+ /* Skip over callout */
+
+ case OP_CALLOUT:
+ tcode += 2;
+ break;
+
/* Skip over extended extraction bracket number */
case OP_BRANUMBER:
@@ -130,8 +137,8 @@ do
case OP_ASSERT_NOT:
case OP_ASSERTBACK:
case OP_ASSERTBACK_NOT:
- do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT);
- tcode += 3;
+ do tcode += GET(tcode, 1); while (*tcode == OP_ALT);
+ tcode += 1+LINK_SIZE;
break;
/* Skip over an option setting, changing the caseless flag */
@@ -145,11 +152,11 @@ do
case OP_BRAZERO:
case OP_BRAMINZERO:
- if (!set_start_bits(++tcode, start_bits, caseless, cd))
+ if (!set_start_bits(++tcode, start_bits, caseless, utf8, cd))
return FALSE;
dummy = 1;
- do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT);
- tcode += 3;
+ do tcode += GET(tcode,1); while (*tcode == OP_ALT);
+ tcode += 1+LINK_SIZE;
break;
/* Single-char * or ? sets the bit and tries the next item */
@@ -160,6 +167,9 @@ do
case OP_MINQUERY:
set_bit(start_bits, tcode[1], caseless, cd);
tcode += 2;
+#ifdef SUPPORT_UTF8
+ if (utf8) while ((*tcode & 0xc0) == 0x80) tcode++;
+#endif
break;
/* Single-char upto sets the bit and tries the next */
@@ -168,6 +178,9 @@ do
case OP_MINUPTO:
set_bit(start_bits, tcode[3], caseless, cd);
tcode += 4;
+#ifdef SUPPORT_UTF8
+ if (utf8) while ((*tcode & 0xc0) == 0x80) tcode++;
+#endif
break;
/* At least one single char sets the bit and stops */
@@ -281,8 +294,17 @@ do
tcode += 2;
break;
- /* Character class: set the bits and either carry on or not,
- according to the repeat count. */
+ /* Character class where all the information is in a bit map: set the
+ bits and either carry on or not, according to the repeat count. If it was
+ a negative class, and we are operating with UTF-8 characters, any byte
+ with the top-bit set is a potentially valid starter because it may start
+ a character with a value > 255. (This is sub-optimal in that the
+ character may be in the range 128-255, and those characters might be
+ unwanted, but that's as far as we go for the moment.) */
+
+ case OP_NCLASS:
+ if (utf8) memset(start_bits+16, 0xff, 16);
+ /* Fall through */
case OP_CLASS:
{
@@ -309,12 +331,12 @@ do
break;
}
}
- break; /* End of class handling */
+ break; /* End of bitmap class handling */
} /* End of switch */
} /* End of try_next loop */
- code += (code[1] << 8) + code[2]; /* Advance to next branch */
+ code += GET(code, 1); /* Advance to next branch */
}
while (*code == OP_ALT);
return TRUE;
@@ -336,7 +358,8 @@ Arguments:
errorptr points to where to place error messages;
set NULL unless error
-Returns: pointer to a pcre_extra block,
+Returns: pointer to a pcre_extra block, with study_data filled in and the
+ appropriate flag set;
NULL on error or if no optimization possible
*/
@@ -344,8 +367,11 @@ pcre_extra *
pcre_study(const pcre *external_re, int options, const char **errorptr)
{
uschar start_bits[32];
-real_pcre_extra *extra;
+pcre_extra *extra;
+pcre_study_data *study;
const real_pcre *re = (const real_pcre *)external_re;
+uschar *code = (uschar *)re + sizeof(real_pcre) +
+ (re->name_count * re->name_entry_size);
compile_data compile_block;
*errorptr = NULL;
@@ -362,9 +388,9 @@ if ((options & ~PUBLIC_STUDY_OPTIONS) != 0)
return NULL;
}
-/* For an anchored pattern, or an unchored pattern that has a first char, or a
-multiline pattern that matches only at "line starts", no further processing at
-present. */
+/* For an anchored pattern, or an unanchored pattern that has a first char, or
+a multiline pattern that matches only at "line starts", no further processing
+at present. */
if ((re->options & (PCRE_ANCHORED|PCRE_FIRSTSET|PCRE_STARTLINE)) != 0)
return NULL;
@@ -379,12 +405,18 @@ compile_block.ctypes = re->tables + ctypes_offset;
/* See if we can find a fixed set of initial characters for the pattern. */
memset(start_bits, 0, 32 * sizeof(uschar));
-if (!set_start_bits(re->code, start_bits, (re->options & PCRE_CASELESS) != 0,
- &compile_block)) return NULL;
+if (!set_start_bits(code, start_bits, (re->options & PCRE_CASELESS) != 0,
+ (re->options & PCRE_UTF8) != 0, &compile_block)) return NULL;
-/* Get an "extra" block and put the information therein. */
+/* Get a pcre_extra block and a pcre_study_data block. The study data is put in
+the latter, which is pointed to by the former, which may also get additional
+data set later by the calling program. At the moment, the size of
+pcre_study_data is fixed. We nevertheless save it in a field for returning via
+the pcre_fullinfo() function so that if it becomes variable in the future, we
+don't have to change that code. */
-extra = (real_pcre_extra *)(pcre_malloc)(sizeof(real_pcre_extra));
+extra = (pcre_extra *)(pcre_malloc)
+ (sizeof(pcre_extra) + sizeof(pcre_study_data));
if (extra == NULL)
{
@@ -392,10 +424,15 @@ if (extra == NULL)
return NULL;
}
-extra->options = PCRE_STUDY_MAPPED;
-memcpy(extra->start_bits, start_bits, sizeof(start_bits));
+study = (pcre_study_data *)((char *)extra + sizeof(pcre_extra));
+extra->flags = PCRE_EXTRA_STUDY_DATA;
+extra->study_data = study;
+
+study->size = sizeof(pcre_study_data);
+study->options = PCRE_STUDY_MAPPED;
+memcpy(study->start_bits, start_bits, sizeof(start_bits));
-return (pcre_extra *)extra;
+return extra;
}
/* End of study.c */
diff --git a/testdata/testinput1 b/testdata/testinput1
index 66df9b3..02211ac 100644
--- a/testdata/testinput1
+++ b/testdata/testinput1
@@ -1357,7 +1357,7 @@
/^[W-c]+$/
WXY_^abc
- ***Failers
+ *** Failers
wxy
/^[W-c]+$/i
@@ -1517,7 +1517,7 @@
/(abc)[\1]de/
abc\1de
-/a.b(?s)/
+/(?s)a.b/
a\nb
/^([^a])([^\b])([^c]*)([^d]{3,4})/
@@ -1947,4 +1947,1877 @@
/(AB)*\1/
ABABAB
+/(?<!bar)foo/
+ foo
+ catfood
+ arfootle
+ rfoosh
+ *** Failers
+ barfoo
+ towbarfoo
+
+/\w{3}(?<!bar)foo/
+ catfood
+ *** Failers
+ foo
+ barfoo
+ towbarfoo
+
+/(?<=(foo)a)bar/
+ fooabar
+ *** Failers
+ bar
+ foobbar
+
+/\Aabc\z/m
+ abc
+ *** Failers
+ abc\n
+ qqq\nabc
+ abc\nzzz
+ qqq\nabc\nzzz
+
+"(?>.*/)foo"
+ /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
+
+"(?>.*/)foo"
+ /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
+
+/(?>(\.\d\d[1-9]?))\d+/
+ 1.230003938
+ 1.875000282
+ *** Failers
+ 1.235
+
+/^((?>\w+)|(?>\s+))*$/
+ now is the time for all good men to come to the aid of the party
+ *** Failers
+ this is not a line with only words and spaces!
+
+/(\d+)(\w)/
+ 12345a
+ 12345+
+
+/((?>\d+))(\w)/
+ 12345a
+ *** Failers
+ 12345+
+
+/(?>a+)b/
+ aaab
+
+/((?>a+)b)/
+ aaab
+
+/(?>(a+))b/
+ aaab
+
+/(?>b)+/
+ aaabbbccc
+
+/(?>a+|b+|c+)*c/
+ aaabbbbccccd
+
+/((?>[^()]+)|\([^()]*\))+/
+ ((abc(ade)ufh()()x
+
+/\(((?>[^()]+)|\([^()]+\))+\)/
+ (abc)
+ (abc(def)xyz)
+ *** Failers
+ ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/a(?-i)b/i
+ ab
+ Ab
+ *** Failers
+ aB
+ AB
+
+/(a (?x)b c)d e/
+ a bcd e
+ *** Failers
+ a b cd e
+ abcd e
+ a bcde
+
+/(a b(?x)c d (?-x)e f)/
+ a bcde f
+ *** Failers
+ abcdef
+
+/(a(?i)b)c/
+ abc
+ aBc
+ *** Failers
+ abC
+ aBC
+ Abc
+ ABc
+ ABC
+ AbC
+
+/a(?i:b)c/
+ abc
+ aBc
+ *** Failers
+ ABC
+ abC
+ aBC
+
+/a(?i:b)*c/
+ aBc
+ aBBc
+ *** Failers
+ aBC
+ aBBC
+
+/a(?=b(?i)c)\w\wd/
+ abcd
+ abCd
+ *** Failers
+ aBCd
+ abcD
+
+/(?s-i:more.*than).*million/i
+ more than million
+ more than MILLION
+ more \n than Million
+ *** Failers
+ MORE THAN MILLION
+ more \n than \n million
+
+/(?:(?s-i)more.*than).*million/i
+ more than million
+ more than MILLION
+ more \n than Million
+ *** Failers
+ MORE THAN MILLION
+ more \n than \n million
+
+/(?>a(?i)b+)+c/
+ abc
+ aBbc
+ aBBc
+ *** Failers
+ Abc
+ abAb
+ abbC
+
+/(?=a(?i)b)\w\wc/
+ abc
+ aBc
+ *** Failers
+ Ab
+ abC
+ aBC
+
+/(?<=a(?i)b)(\w\w)c/
+ abxxc
+ aBxxc
+ *** Failers
+ Abxxc
+ ABxxc
+ abxxC
+
+/(?:(a)|b)(?(1)A|B)/
+ aA
+ bB
+ *** Failers
+ aB
+ bA
+
+/^(a)?(?(1)a|b)+$/
+ aa
+ b
+ bb
+ *** Failers
+ ab
+
+/^(?(?=abc)\w{3}:|\d\d)$/
+ abc:
+ 12
+ *** Failers
+ 123
+ xyz
+
+/^(?(?!abc)\d\d|\w{3}:)$/
+ abc:
+ 12
+ *** Failers
+ 123
+ xyz
+
+/(?(?<=foo)bar|cat)/
+ foobar
+ cat
+ fcat
+ focat
+ *** Failers
+ foocat
+
+/(?(?<!foo)cat|bar)/
+ foobar
+ cat
+ fcat
+ focat
+ *** Failers
+ foocat
+
+/( \( )? [^()]+ (?(1) \) |) /x
+ abcd
+ (abcd)
+ the quick (abcd) fox
+ (abcd
+
+/( \( )? [^()]+ (?(1) \) ) /x
+ abcd
+ (abcd)
+ the quick (abcd) fox
+ (abcd
+
+/^(?(2)a|(1)(2))+$/
+ 12
+ 12a
+ 12aa
+ *** Failers
+ 1234
+
+/((?i)blah)\s+\1/
+ blah blah
+ BLAH BLAH
+ Blah Blah
+ blaH blaH
+ *** Failers
+ blah BLAH
+ Blah blah
+ blaH blah
+
+/((?i)blah)\s+(?i:\1)/
+ blah blah
+ BLAH BLAH
+ Blah Blah
+ blaH blaH
+ blah BLAH
+ Blah blah
+ blaH blah
+
+/(?>a*)*/
+ a
+ aa
+ aaaa
+
+/(abc|)+/
+ abc
+ abcabc
+ abcabcabc
+ xyz
+
+/([a]*)*/
+ a
+ aaaaa
+
+/([ab]*)*/
+ a
+ b
+ ababab
+ aaaabcde
+ bbbb
+
+/([^a]*)*/
+ b
+ bbbb
+ aaa
+
+/([^ab]*)*/
+ cccc
+ abab
+
+/([a]*?)*/
+ a
+ aaaa
+
+/([ab]*?)*/
+ a
+ b
+ abab
+ baba
+
+/([^a]*?)*/
+ b
+ bbbb
+ aaa
+
+/([^ab]*?)*/
+ c
+ cccc
+ baba
+
+/(?>a*)*/
+ a
+ aaabcde
+
+/((?>a*))*/
+ aaaaa
+ aabbaa
+
+/((?>a*?))*/
+ aaaaa
+ aabbaa
+
+/(?(?=[^a-z]+[a-z]) \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} ) /x
+ 12-sep-98
+ 12-09-98
+ *** Failers
+ sep-12-98
+
+/(?<=(foo))bar\1/
+ foobarfoo
+ foobarfootling
+ *** Failers
+ foobar
+ barfoo
+
+/(?i:saturday|sunday)/
+ saturday
+ sunday
+ Saturday
+ Sunday
+ SATURDAY
+ SUNDAY
+ SunDay
+
+/(a(?i)bc|BB)x/
+ abcx
+ aBCx
+ bbx
+ BBx
+ *** Failers
+ abcX
+ aBCX
+ bbX
+ BBX
+
+/^([ab](?i)[cd]|[ef])/
+ ac
+ aC
+ bD
+ elephant
+ Europe
+ frog
+ France
+ *** Failers
+ Africa
+
+/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
+ ab
+ aBd
+ xy
+ xY
+ zebra
+ Zambesi
+ *** Failers
+ aCD
+ XY
+
+/(?<=foo\n)^bar/m
+ foo\nbar
+ *** Failers
+ bar
+ baz\nbar
+
+/(?<=(?<!foo)bar)baz/
+ barbaz
+ barbarbaz
+ koobarbaz
+ *** Failers
+ baz
+ foobarbaz
+
+/The case of aaaaaa is missed out below because I think Perl 5.005_02 gets/
+/it wrong; it sets $1 to aaa rather than aa. Compare the following test,/
+/where it does set $1 to aa when matching aaaaaa./
+
+/^(a\1?){4}$/
+ a
+ aa
+ aaa
+ aaaa
+ aaaaa
+ aaaaaaa
+ aaaaaaaa
+ aaaaaaaaa
+ aaaaaaaaaa
+ aaaaaaaaaaa
+ aaaaaaaaaaaa
+ aaaaaaaaaaaaa
+ aaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaa
+
+/^(a\1?)(a\1?)(a\2?)(a\3?)$/
+ a
+ aa
+ aaa
+ aaaa
+ aaaaa
+ aaaaaa
+ aaaaaaa
+ aaaaaaaa
+ aaaaaaaaa
+ aaaaaaaaaa
+ aaaaaaaaaaa
+ aaaaaaaaaaaa
+ aaaaaaaaaaaaa
+ aaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaa
+
+/The following tests are taken from the Perl 5.005 test suite; some of them/
+/are compatible with 5.004, but I'd rather not have to sort them out./
+
+/abc/
+ abc
+ xabcy
+ ababc
+ *** Failers
+ xbc
+ axc
+ abx
+
+/ab*c/
+ abc
+
+/ab*bc/
+ abc
+ abbc
+ abbbbc
+
+/.{1}/
+ abbbbc
+
+/.{3,4}/
+ abbbbc
+
+/ab{0,}bc/
+ abbbbc
+
+/ab+bc/
+ abbc
+ *** Failers
+ abc
+ abq
+
+/ab{1,}bc/
+
+/ab+bc/
+ abbbbc
+
+/ab{1,}bc/
+ abbbbc
+
+/ab{1,3}bc/
+ abbbbc
+
+/ab{3,4}bc/
+ abbbbc
+
+/ab{4,5}bc/
+ *** Failers
+ abq
+ abbbbc
+
+/ab?bc/
+ abbc
+ abc
+
+/ab{0,1}bc/
+ abc
+
+/ab?bc/
+
+/ab?c/
+ abc
+
+/ab{0,1}c/
+ abc
+
+/^abc$/
+ abc
+ *** Failers
+ abbbbc
+ abcc
+
+/^abc/
+ abcc
+
+/^abc$/
+
+/abc$/
+ aabc
+ *** Failers
+ aabc
+ aabcd
+
+/^/
+ abc
+
+/$/
+ abc
+
+/a.c/
+ abc
+ axc
+
+/a.*c/
+ axyzc
+
+/a[bc]d/
+ abd
+ *** Failers
+ axyzd
+ abc
+
+/a[b-d]e/
+ ace
+
+/a[b-d]/
+ aac
+
+/a[-b]/
+ a-
+
+/a[b-]/
+ a-
+
+/a]/
+ a]
+
+/a[]]b/
+ a]b
+
+/a[^bc]d/
+ aed
+ *** Failers
+ abd
+ abd
+
+/a[^-b]c/
+ adc
+
+/a[^]b]c/
+ adc
+ *** Failers
+ a-c
+ a]c
+
+/\ba\b/
+ a-
+ -a
+ -a-
+
+/\by\b/
+ *** Failers
+ xy
+ yz
+ xyz
+
+/\Ba\B/
+ *** Failers
+ a-
+ -a
+ -a-
+
+/\By\b/
+ xy
+
+/\by\B/
+ yz
+
+/\By\B/
+ xyz
+
+/\w/
+ a
+
+/\W/
+ -
+ *** Failers
+ -
+ a
+
+/a\sb/
+ a b
+
+/a\Sb/
+ a-b
+ *** Failers
+ a-b
+ a b
+
+/\d/
+ 1
+
+/\D/
+ -
+ *** Failers
+ -
+ 1
+
+/[\w]/
+ a
+
+/[\W]/
+ -
+ *** Failers
+ -
+ a
+
+/a[\s]b/
+ a b
+
+/a[\S]b/
+ a-b
+ *** Failers
+ a-b
+ a b
+
+/[\d]/
+ 1
+
+/[\D]/
+ -
+ *** Failers
+ -
+ 1
+
+/ab|cd/
+ abc
+ abcd
+
+/()ef/
+ def
+
+/$b/
+
+/a\(b/
+ a(b
+
+/a\(*b/
+ ab
+ a((b
+
+/a\\b/
+ a\b
+
+/((a))/
+ abc
+
+/(a)b(c)/
+ abc
+
+/a+b+c/
+ aabbabc
+
+/a{1,}b{1,}c/
+ aabbabc
+
+/a.+?c/
+ abcabc
+
+/(a+|b)*/
+ ab
+
+/(a+|b){0,}/
+ ab
+
+/(a+|b)+/
+ ab
+
+/(a+|b){1,}/
+ ab
+
+/(a+|b)?/
+ ab
+
+/(a+|b){0,1}/
+ ab
+
+/[^ab]*/
+ cde
+
+/abc/
+ *** Failers
+ b
+
+
+/a*/
+
+
+/([abc])*d/
+ abbbcd
+
+/([abc])*bcd/
+ abcd
+
+/a|b|c|d|e/
+ e
+
+/(a|b|c|d|e)f/
+ ef
+
+/abcd*efg/
+ abcdefg
+
+/ab*/
+ xabyabbbz
+ xayabbbz
+
+/(ab|cd)e/
+ abcde
+
+/[abhgefdc]ij/
+ hij
+
+/^(ab|cd)e/
+
+/(abc|)ef/
+ abcdef
+
+/(a|b)c*d/
+ abcd
+
+/(ab|ab*)bc/
+ abc
+
+/a([bc]*)c*/
+ abc
+
+/a([bc]*)(c*d)/
+ abcd
+
+/a([bc]+)(c*d)/
+ abcd
+
+/a([bc]*)(c+d)/
+ abcd
+
+/a[bcd]*dcdcde/
+ adcdcde
+
+/a[bcd]+dcdcde/
+ *** Failers
+ abcde
+ adcdcde
+
+/(ab|a)b*c/
+ abc
+
+/((a)(b)c)(d)/
+ abcd
+
+/[a-zA-Z_][a-zA-Z0-9_]*/
+ alpha
+
+/^a(bc+|b[eh])g|.h$/
+ abh
+
+/(bc+d$|ef*g.|h?i(j|k))/
+ effgz
+ ij
+ reffgz
+ *** Failers
+ effg
+ bcdd
+
+/((((((((((a))))))))))/
+ a
+
+/((((((((((a))))))))))\10/
+ aa
+
+/(((((((((a)))))))))/
+ a
+
+/multiple words of text/
+ *** Failers
+ aa
+ uh-uh
+
+/multiple words/
+ multiple words, yeah
+
+/(.*)c(.*)/
+ abcde
+
+/\((.*), (.*)\)/
+ (a, b)
+
+/[k]/
+
+/abcd/
+ abcd
+
+/a(bc)d/
+ abcd
+
+/a[-]?c/
+ ac
+
+/(abc)\1/
+ abcabc
+
+/([a-c]*)\1/
+ abcabc
+
+/(a)|\1/
+ a
+ *** Failers
+ ab
+ x
+
+/(([a-c])b*?\2)*/
+ ababbbcbc
+
+/(([a-c])b*?\2){3}/
+ ababbbcbc
+
+/((\3|b)\2(a)x)+/
+ aaaxabaxbaaxbbax
+
+/((\3|b)\2(a)){2,}/
+ bbaababbabaaaaabbaaaabba
+
+/abc/i
+ ABC
+ XABCY
+ ABABC
+ *** Failers
+ aaxabxbaxbbx
+ XBC
+ AXC
+ ABX
+
+/ab*c/i
+ ABC
+
+/ab*bc/i
+ ABC
+ ABBC
+
+/ab*?bc/i
+ ABBBBC
+
+/ab{0,}?bc/i
+ ABBBBC
+
+/ab+?bc/i
+ ABBC
+
+/ab+bc/i
+ *** Failers
+ ABC
+ ABQ
+
+/ab{1,}bc/i
+
+/ab+bc/i
+ ABBBBC
+
+/ab{1,}?bc/i
+ ABBBBC
+
+/ab{1,3}?bc/i
+ ABBBBC
+
+/ab{3,4}?bc/i
+ ABBBBC
+
+/ab{4,5}?bc/i
+ *** Failers
+ ABQ
+ ABBBBC
+
+/ab??bc/i
+ ABBC
+ ABC
+
+/ab{0,1}?bc/i
+ ABC
+
+/ab??bc/i
+
+/ab??c/i
+ ABC
+
+/ab{0,1}?c/i
+ ABC
+
+/^abc$/i
+ ABC
+ *** Failers
+ ABBBBC
+ ABCC
+
+/^abc/i
+ ABCC
+
+/^abc$/i
+
+/abc$/i
+ AABC
+
+/^/i
+ ABC
+
+/$/i
+ ABC
+
+/a.c/i
+ ABC
+ AXC
+
+/a.*?c/i
+ AXYZC
+
+/a.*c/i
+ *** Failers
+ AABC
+ AXYZD
+
+/a[bc]d/i
+ ABD
+
+/a[b-d]e/i
+ ACE
+ *** Failers
+ ABC
+ ABD
+
+/a[b-d]/i
+ AAC
+
+/a[-b]/i
+ A-
+
+/a[b-]/i
+ A-
+
+/a]/i
+ A]
+
+/a[]]b/i
+ A]B
+
+/a[^bc]d/i
+ AED
+
+/a[^-b]c/i
+ ADC
+ *** Failers
+ ABD
+ A-C
+
+/a[^]b]c/i
+ ADC
+
+/ab|cd/i
+ ABC
+ ABCD
+
+/()ef/i
+ DEF
+
+/$b/i
+ *** Failers
+ A]C
+ B
+
+/a\(b/i
+ A(B
+
+/a\(*b/i
+ AB
+ A((B
+
+/a\\b/i
+ A\B
+
+/((a))/i
+ ABC
+
+/(a)b(c)/i
+ ABC
+
+/a+b+c/i
+ AABBABC
+
+/a{1,}b{1,}c/i
+ AABBABC
+
+/a.+?c/i
+ ABCABC
+
+/a.*?c/i
+ ABCABC
+
+/a.{0,5}?c/i
+ ABCABC
+
+/(a+|b)*/i
+ AB
+
+/(a+|b){0,}/i
+ AB
+
+/(a+|b)+/i
+ AB
+
+/(a+|b){1,}/i
+ AB
+
+/(a+|b)?/i
+ AB
+
+/(a+|b){0,1}/i
+ AB
+
+/(a+|b){0,1}?/i
+ AB
+
+/[^ab]*/i
+ CDE
+
+/abc/i
+
+/a*/i
+
+
+/([abc])*d/i
+ ABBBCD
+
+/([abc])*bcd/i
+ ABCD
+
+/a|b|c|d|e/i
+ E
+
+/(a|b|c|d|e)f/i
+ EF
+
+/abcd*efg/i
+ ABCDEFG
+
+/ab*/i
+ XABYABBBZ
+ XAYABBBZ
+
+/(ab|cd)e/i
+ ABCDE
+
+/[abhgefdc]ij/i
+ HIJ
+
+/^(ab|cd)e/i
+ ABCDE
+
+/(abc|)ef/i
+ ABCDEF
+
+/(a|b)c*d/i
+ ABCD
+
+/(ab|ab*)bc/i
+ ABC
+
+/a([bc]*)c*/i
+ ABC
+
+/a([bc]*)(c*d)/i
+ ABCD
+
+/a([bc]+)(c*d)/i
+ ABCD
+
+/a([bc]*)(c+d)/i
+ ABCD
+
+/a[bcd]*dcdcde/i
+ ADCDCDE
+
+/a[bcd]+dcdcde/i
+
+/(ab|a)b*c/i
+ ABC
+
+/((a)(b)c)(d)/i
+ ABCD
+
+/[a-zA-Z_][a-zA-Z0-9_]*/i
+ ALPHA
+
+/^a(bc+|b[eh])g|.h$/i
+ ABH
+
+/(bc+d$|ef*g.|h?i(j|k))/i
+ EFFGZ
+ IJ
+ REFFGZ
+ *** Failers
+ ADCDCDE
+ EFFG
+ BCDD
+
+/((((((((((a))))))))))/i
+ A
+
+/((((((((((a))))))))))\10/i
+ AA
+
+/(((((((((a)))))))))/i
+ A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
+ A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
+ C
+
+/multiple words of text/i
+ *** Failers
+ AA
+ UH-UH
+
+/multiple words/i
+ MULTIPLE WORDS, YEAH
+
+/(.*)c(.*)/i
+ ABCDE
+
+/\((.*), (.*)\)/i
+ (A, B)
+
+/[k]/i
+
+/abcd/i
+ ABCD
+
+/a(bc)d/i
+ ABCD
+
+/a[-]?c/i
+ AC
+
+/(abc)\1/i
+ ABCABC
+
+/([a-c]*)\1/i
+ ABCABC
+
+/a(?!b)./
+ abad
+
+/a(?=d)./
+ abad
+
+/a(?=c|d)./
+ abad
+
+/a(?:b|c|d)(.)/
+ ace
+
+/a(?:b|c|d)*(.)/
+ ace
+
+/a(?:b|c|d)+?(.)/
+ ace
+ acdbcdbe
+
+/a(?:b|c|d)+(.)/
+ acdbcdbe
+
+/a(?:b|c|d){2}(.)/
+ acdbcdbe
+
+/a(?:b|c|d){4,5}(.)/
+ acdbcdbe
+
+/a(?:b|c|d){4,5}?(.)/
+ acdbcdbe
+
+/((foo)|(bar))*/
+ foobar
+
+/a(?:b|c|d){6,7}(.)/
+ acdbcdbe
+
+/a(?:b|c|d){6,7}?(.)/
+ acdbcdbe
+
+/a(?:b|c|d){5,6}(.)/
+ acdbcdbe
+
+/a(?:b|c|d){5,6}?(.)/
+ acdbcdbe
+
+/a(?:b|c|d){5,7}(.)/
+ acdbcdbe
+
+/a(?:b|c|d){5,7}?(.)/
+ acdbcdbe
+
+/a(?:b|(c|e){1,2}?|d)+?(.)/
+ ace
+
+/^(.+)?B/
+ AB
+
+/^([^a-z])|(\^)$/
+ .
+
+/^[<>]&/
+ <&OUT
+
+/^(a\1?){4}$/
+ aaaaaaaaaa
+ *** Failers
+ AB
+ aaaaaaaaa
+ aaaaaaaaaaa
+
+/^(a(?(1)\1)){4}$/
+ aaaaaaaaaa
+ *** Failers
+ aaaaaaaaa
+ aaaaaaaaaaa
+
+/(?:(f)(o)(o)|(b)(a)(r))*/
+ foobar
+
+/(?<=a)b/
+ ab
+ *** Failers
+ cb
+ b
+
+/(?<!c)b/
+ ab
+ b
+ b
+
+/(?:..)*a/
+ aba
+
+/(?:..)*?a/
+ aba
+
+/^(?:b|a(?=(.)))*\1/
+ abc
+
+/^(){3,5}/
+ abc
+
+/^(a+)*ax/
+ aax
+
+/^((a|b)+)*ax/
+ aax
+
+/^((a|bc)+)*ax/
+ aax
+
+/(a|x)*ab/
+ cab
+
+/(a)*ab/
+ cab
+
+/(?:(?i)a)b/
+ ab
+
+/((?i)a)b/
+ ab
+
+/(?:(?i)a)b/
+ Ab
+
+/((?i)a)b/
+ Ab
+
+/(?:(?i)a)b/
+ *** Failers
+ cb
+ aB
+
+/((?i)a)b/
+
+/(?i:a)b/
+ ab
+
+/((?i:a))b/
+ ab
+
+/(?i:a)b/
+ Ab
+
+/((?i:a))b/
+ Ab
+
+/(?i:a)b/
+ *** Failers
+ aB
+ aB
+
+/((?i:a))b/
+
+/(?:(?-i)a)b/i
+ ab
+
+/((?-i)a)b/i
+ ab
+
+/(?:(?-i)a)b/i
+ aB
+
+/((?-i)a)b/i
+ aB
+
+/(?:(?-i)a)b/i
+ *** Failers
+ aB
+ Ab
+
+/((?-i)a)b/i
+
+/(?:(?-i)a)b/i
+ aB
+
+/((?-i)a)b/i
+ aB
+
+/(?:(?-i)a)b/i
+ *** Failers
+ Ab
+ AB
+
+/((?-i)a)b/i
+
+/(?-i:a)b/i
+ ab
+
+/((?-i:a))b/i
+ ab
+
+/(?-i:a)b/i
+ aB
+
+/((?-i:a))b/i
+ aB
+
+/(?-i:a)b/i
+ *** Failers
+ AB
+ Ab
+
+/((?-i:a))b/i
+
+/(?-i:a)b/i
+ aB
+
+/((?-i:a))b/i
+ aB
+
+/(?-i:a)b/i
+ *** Failers
+ Ab
+ AB
+
+/((?-i:a))b/i
+
+/((?-i:a.))b/i
+ *** Failers
+ AB
+ a\nB
+
+/((?s-i:a.))b/i
+ a\nB
+
+/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
+ cabbbb
+
+/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
+ caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+/(ab)\d\1/i
+ Ab4ab
+ ab4Ab
+
+/foo\w*\d{4}baz/
+ foobar1234baz
+
+/x(~~)*(?:(?:F)?)?/
+ x~~
+
+/^a(?#xxx){3}c/
+ aaac
+
+/^a (?#xxx) (?#yyy) {3}c/x
+ aaac
+
+/(?<![cd])b/
+ *** Failers
+ B\nB
+ dbcb
+
+/(?<![cd])[ab]/
+ dbaacb
+
+/(?<!(c|d))b/
+
+/(?<!(c|d))[ab]/
+ dbaacb
+
+/(?<!cd)[ab]/
+ cdaccb
+
+/^(?:a?b?)*$/
+ *** Failers
+ dbcb
+ a--
+
+/((?s)^a(.))((?m)^b$)/
+ a\nb\nc\n
+
+/((?m)^b$)/
+ a\nb\nc\n
+
+/(?m)^b/
+ a\nb\n
+
+/(?m)^(b)/
+ a\nb\n
+
+/((?m)^b)/
+ a\nb\n
+
+/\n((?m)^b)/
+ a\nb\n
+
+/((?s).)c(?!.)/
+ a\nb\nc\n
+ a\nb\nc\n
+
+/((?s)b.)c(?!.)/
+ a\nb\nc\n
+ a\nb\nc\n
+
+/^b/
+
+/()^b/
+ *** Failers
+ a\nb\nc\n
+ a\nb\nc\n
+
+/((?m)^b)/
+ a\nb\nc\n
+
+/(?(1)a|b)/
+
+/(?(1)b|a)/
+ a
+
+/(x)?(?(1)a|b)/
+ *** Failers
+ a
+ a
+
+/(x)?(?(1)b|a)/
+ a
+
+/()?(?(1)b|a)/
+ a
+
+/()(?(1)b|a)/
+
+/()?(?(1)a|b)/
+ a
+
+/^(\()?blah(?(1)(\)))$/
+ (blah)
+ blah
+ *** Failers
+ a
+ blah)
+ (blah
+
+/^(\(+)?blah(?(1)(\)))$/
+ (blah)
+ blah
+ *** Failers
+ blah)
+ (blah
+
+/(?(?!a)a|b)/
+
+/(?(?!a)b|a)/
+ a
+
+/(?(?=a)b|a)/
+ *** Failers
+ a
+ a
+
+/(?(?=a)a|b)/
+ a
+
+/(?=(a+?))(\1ab)/
+ aaab
+
+/^(?=(a+?))\1ab/
+
+/(\w+:)+/
+ one:
+
+/$(?<=^(a))/
+ a
+
+/(?=(a+?))(\1ab)/
+ aaab
+
+/^(?=(a+?))\1ab/
+ *** Failers
+ aaab
+ aaab
+
+/([\w:]+::)?(\w+)$/
+ abcd
+ xy:z:::abcd
+
+/^[^bcd]*(c+)/
+ aexycd
+
+/(a*)b+/
+ caab
+
+/([\w:]+::)?(\w+)$/
+ abcd
+ xy:z:::abcd
+ *** Failers
+ abcd:
+ abcd:
+
+/^[^bcd]*(c+)/
+ aexycd
+
+/(>a+)ab/
+
+/(?>a+)b/
+ aaab
+
+/([[:]+)/
+ a:[b]:
+
+/([[=]+)/
+ a=[b]=
+
+/([[.]+)/
+ a.[b].
+
+/((?>a+)b)/
+ aaab
+
+/(?>(a+))b/
+ aaab
+
+/((?>[^()]+)|\([^()]*\))+/
+ ((abc(ade)ufh()()x
+
+/a\Z/
+ *** Failers
+ aaab
+ a\nb\n
+
+/b\Z/
+ a\nb\n
+
+/b\z/
+
+/b\Z/
+ a\nb
+
+/b\z/
+ a\nb
+ *** Failers
+
+/^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
+ a
+ abc
+ a-b
+ 0-9
+ a.b
+ 5.6.7
+ the.quick.brown.fox
+ a100.b200.300c
+ 12-ab.1245
+ *** Failers
+ \
+ .a
+ -a
+ a-
+ a.
+ a_b
+ a.-
+ a..
+ ab..bc
+ the.quick.brown.fox-
+ the.quick.brown.fox.
+ the.quick.brown.fox_
+ the.quick.brown.fox+
+
+/(?>.*)(?<=(abcd|wxyz))/
+ alphabetabcd
+ endingwxyz
+ *** Failers
+ a rather long string that doesn't end with one of them
+
+/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
+ word cat dog elephant mussel cow horse canary baboon snake shark otherword
+ word cat dog elephant mussel cow horse canary baboon snake shark
+
+/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
+ word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
+
+/(?<=\d{3}(?!999))foo/
+ 999foo
+ 123999foo
+ *** Failers
+ 123abcfoo
+
+/(?<=(?!...999)\d{3})foo/
+ 999foo
+ 123999foo
+ *** Failers
+ 123abcfoo
+
+/(?<=\d{3}(?!999)...)foo/
+ 123abcfoo
+ 123456foo
+ *** Failers
+ 123999foo
+
+/(?<=\d{3}...)(?<!999)foo/
+ 123abcfoo
+ 123456foo
+ *** Failers
+ 123999foo
+
+/<a[\s]+href[\s]*=[\s]* # find <a href=
+ ([\"\'])? # find single or double quote
+ (?(1) (.*?)\1 | ([^\s]+)) # if quote found, match up to next matching
+ # quote, otherwise match up to next space
+/isx
+ <a href=abcd xyz
+ <a href=\"abcd xyz pqr\" cats
+ <a href=\'abcd xyz pqr\' cats
+
+/<a\s+href\s*=\s* # find <a href=
+ (["'])? # find single or double quote
+ (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
+ # quote, otherwise match up to next space
+/isx
+ <a href=abcd xyz
+ <a href=\"abcd xyz pqr\" cats
+ <a href = \'abcd xyz pqr\' cats
+
+/<a\s+href(?>\s*)=(?>\s*) # find <a href=
+ (["'])? # find single or double quote
+ (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
+ # quote, otherwise match up to next space
+/isx
+ <a href=abcd xyz
+ <a href=\"abcd xyz pqr\" cats
+ <a href = \'abcd xyz pqr\' cats
+
+/((Z)+|A)*/
+ ZABCDEFG
+
+/(Z()|A)*/
+ ZABCDEFG
+
+/(Z(())|A)*/
+ ZABCDEFG
+
+/((?>Z)+|A)*/
+ ZABCDEFG
+
+/((?>)+|A)*/
+ ZABCDEFG
+
+/a*/g
+ abbab
+
+/^[a-\d]/
+ abcde
+ -things
+ 0digit
+ *** Failers
+ bcdef
+
+/^[\d-a]/
+ abcde
+ -things
+ 0digit
+ *** Failers
+ bcdef
+
+/[[:space:]]+/
+ > \x09\x0a\x0c\x0d\x0b<
+
+/[[:blank:]]+/
+ > \x09\x0a\x0c\x0d\x0b<
+
+/[\s]+/
+ > \x09\x0a\x0c\x0d\x0b<
+
+/\s+/
+ > \x09\x0a\x0c\x0d\x0b<
+
+/a b/x
+ ab
+
+/(?!\A)x/m
+ a\nxb\n
+
+/(?!^)x/m
+ a\nxb\n
+
+/abc\Qabc\Eabc/
+ abcabcabc
+
+/abc\Q(*+|\Eabc/
+ abc(*+|abc
+
+/ abc\Q abc\Eabc/x
+ abc abcabc
+ *** Failers
+ abcabcabc
+
+/abc#comment
+ \Q#not comment
+ literal\E/x
+ abc#not comment\n literal
+
+/abc#comment
+ \Q#not comment
+ literal/x
+ abc#not comment\n literal
+
+/abc#comment
+ \Q#not comment
+ literal\E #more comment
+ /x
+ abc#not comment\n literal
+
+/abc#comment
+ \Q#not comment
+ literal\E #more comment/x
+ abc#not comment\n literal
+
+/\Qabc\$xyz\E/
+ abc\\\$xyz
+
+/\Qabc\E\$\Qxyz\E/
+ abc\$xyz
+
+/\Gabc/
+ abc
+ *** Failers
+ xyzabc
+
+/\Gabc./g
+ abc1abc2xyzabc3
+
+/abc./g
+ abc1abc2xyzabc3
+
+/a(?x: b c )d/
+ XabcdY
+ *** Failers
+ Xa b c d Y
+
+/((?x)x y z | a b c)/
+ XabcY
+ AxyzB
+
+/(?i)AB(?-i)C/
+ XabCY
+ *** Failers
+ XabcY
+
+/((?i)AB(?-i)C|D)E/
+ abCE
+ DE
+ *** Failers
+ abcE
+ abCe
+ dE
+ De
+
+/(.*)\d+\1/
+ abc123abc
+ abc123bc
+
+/(.*)\d+\1/s
+ abc123abc
+ abc123bc
+
+/((.*))\d+\1/
+ abc123abc
+ abc123bc
+
+/-- This tests for an IPv6 address in the form where it can have up to --/
+/-- eight components, one and only one of which is empty. This must be --/
+/-- an internal component. --/
+
+/^(?!:) # colon disallowed at start
+ (?: # start of item
+ (?: [0-9a-f]{1,4} | # 1-4 hex digits or
+ (?(1)0 | () ) ) # if null previously matched, fail; else null
+ : # followed by colon
+ ){1,7} # end item; 1-7 of them required
+ [0-9a-f]{1,4} $ # final hex number at end of string
+ (?(1)|.) # check that there was an empty component
+ /xi
+ a123::a123
+ a123:b342::abcd
+ a123:b342::324e:abcd
+ a123:ddde:b342::324e:abcd
+ a123:ddde:b342::324e:dcba:abcd
+ a123:ddde:9999:b342::324e:dcba:abcd
+ *** Failers
+ 1:2:3:4:5:6:7:8
+ a123:bce:ddde:9999:b342::324e:dcba:abcd
+ a123::9999:b342::324e:dcba:abcd
+ abcde:2:3:4:5:6:7:8
+ ::1
+ abcd:fee0:123::
+ :1
+ 1:
+
+/[z\Qa-d]\E]/
+ z
+ a
+ -
+ d
+ ]
+ *** Failers
+ b
+
+/[\z\C]/
+ z
+ C
+
+/\M/
+ M
+
/ End of testinput1 /
diff --git a/testdata/testinput2 b/testdata/testinput2
index f41478e..d46546a 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -38,7 +38,7 @@
/[abcd/
-/[\B]/
+/(?X)[\B]/
/[z-a]/
@@ -173,7 +173,7 @@
/<.*>/U
abc<def>ghi<klm>nop
-/<.*>(?U)/
+/(?U)<.*>/
abc<def>ghi<klm>nop
/<.*?>/U
@@ -658,6 +658,8 @@
/^[[:ascii:]]/D
+/^[[:blank:]]/D
+
/^[[:cntrl:]]/D
/^[[:digit:]]/D
@@ -682,6 +684,8 @@
/^[12[:^digit:]]/D
+/^[[:^blank:]]/D
+
/[01[:alpha:]%]/D
/[[.ch.]]/
@@ -720,4 +724,505 @@
mainmain
mainOmain
+/These are all cases where Perl does it differently (nested captures)/
+
+/^(a(b)?)+$/
+ aba
+
+/^(aa(bb)?)+$/
+ aabbaa
+
+/^(aa|aa(bb))+$/
+ aabbaa
+
+/^(aa(bb)??)+$/
+ aabbaa
+
+/^(?:aa(bb)?)+$/
+ aabbaa
+
+/^(aa(b(b))?)+$/
+ aabbaa
+
+/^(?:aa(b(b))?)+$/
+ aabbaa
+
+/^(?:aa(b(?:b))?)+$/
+ aabbaa
+
+/^(?:aa(bb(?:b))?)+$/
+ aabbbaa
+
+/^(?:aa(b(?:bb))?)+$/
+ aabbbaa
+
+/^(?:aa(?:b(b))?)+$/
+ aabbaa
+
+/^(?:aa(?:b(bb))?)+$/
+ aabbbaa
+
+/^(aa(b(bb))?)+$/
+ aabbbaa
+
+/^(aa(bb(bb))?)+$/
+ aabbbbaa
+
+/--------------------------------------------------------------------/
+
+/#/xMD
+
+/a#/xMD
+
+/[\s]/D
+
+/[\S]/D
+
+/a(?i)b/D
+ ab
+ aB
+ *** Failers
+ AB
+
+/(a(?i)b)/D
+ ab
+ aB
+ *** Failers
+ AB
+
+/ (?i)abc/xD
+
+/#this is a comment
+ (?i)abc/xD
+
+/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/D
+
+/\Q123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/D
+
+/\Q\E/D
+ \
+
+/\Q\Ex/D
+
+/ \Q\E/D
+
+/a\Q\E/D
+ abc
+ bca
+ bac
+
+/a\Q\Eb/D
+ abc
+
+/\Q\Eabc/D
+
+/x*+\w/D
+ *** Failers
+ xxxxx
+
+/x?+/D
+
+/x++/D
+
+/x{1,3}+/D
+
+/(x)*+/D
+
+/^(\w++|\s++)*$/
+ now is the time for all good men to come to the aid of the party
+ *** Failers
+ this is not a line with only words and spaces!
+
+/(\d++)(\w)/
+ 12345a
+ *** Failers
+ 12345+
+
+/a++b/
+ aaab
+
+/(a++b)/
+ aaab
+
+/(a++)b/
+ aaab
+
+/([^()]++|\([^()]*\))+/
+ ((abc(ade)ufh()()x
+
+/\(([^()]++|\([^()]+\))+\)/
+ (abc)
+ (abc(def)xyz)
+ *** Failers
+ ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/(abc){1,3}+/D
+
+/a+?+/
+
+/a{2,3}?+b/
+
+/(?U)a+?+/
+
+/a{2,3}?+b/U
+
+/x(?U)a++b/D
+ xaaaab
+
+/(?U)xa++b/D
+ xaaaab
+
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/D
+
+/^x(?U)a+b/D
+
+/^x(?U)(a+)b/D
+
+/[.x.]/
+
+/[=x=]/
+
+/[:x:]/
+
+/\l/
+
+/\L/
+
+/\N{name}/
+
+/\pP/
+
+/\PP/
+
+/\p{prop}/
+
+/\P{prop}/
+
+/\u/
+
+/\U/
+
+/\X/
+
+/[/
+
+/[a-/
+
+/[[:space:]/
+
+/[\s]/DM
+
+/[[:space:]]/DM
+
+/[[:space:]abcde]/DM
+
+/< (?: (?(R) \d++ | [^<>]*+) | (?R)) * >/x
+ <>
+ <abcd>
+ <abc <123> hij>
+ <abc <def> hij>
+ <abc<>def>
+ <abc<>
+ *** Failers
+ <abc
+
+|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|DM
+
+|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|DM
+
+/(.*)\d+\1/I
+
+/(.*)\d+/I
+
+/(.*)\d+\1/Is
+
+/(.*)\d+/Is
+
+/(.*(xyz))\d+\2/I
+
+/((.*))\d+\1/I
+ abc123bc
+
+/a[b]/I
+
+/(?=a).*/I
+
+/(?=abc).xyz/iI
+
+/(?=abc)(?i).xyz/I
+
+/(?=a)(?=b)/I
+
+/(?=.)a/I
+
+/((?=abcda)a)/I
+
+/((?=abcda)ab)/I
+
+/()a/I
+
+/(?(1)ab|ac)/I
+
+/(?(1)abz|acz)/I
+
+/(?(1)abz)/I
+
+/(?(1)abz)123/I
+
+/(a)+/I
+
+/(a){2,3}/I
+
+/(a)*/I
+
+/[a]/I
+
+/[ab]/I
+
+/[ab]/IS
+
+/[^a]/I
+
+/\d456/I
+
+/\d456/IS
+
+/a^b/I
+
+/^a/mI
+ abcde
+ xy\nabc
+ *** Failers
+ xyabc
+
+/c|abc/I
+
+/(?i)[ab]/IS
+
+/[ab](?i)cd/IS
+
+/abc(?C)def/
+ abcdef
+ 1234abcdef
+ *** Failers
+ abcxyz
+ abcxyzf
+
+/abc(?C)de(?C1)f/
+ 123abcdef
+
+/(?C1)\dabc(?C2)def/
+ 1234abcdef
+ *** Failers
+ abcdef
+
+/(?C255)ab/
+
+/(?C256)ab/
+
+/(?Cab)xx/
+
+/(?C12vr)x/
+
+/abc(?C)def/
+ *** Failers
+ \x83\x0\x61bcdef
+
+/(abc)(?C)de(?C1)f/
+ 123abcdef
+ 123abcdef\C+
+ 123abcdef\C-
+ *** Failers
+ 123abcdef\C!1
+
+/(?C0)(abc(?C1))*/
+ abcabcabc
+ abcabc\C!1!3
+ *** Failers
+ abcabcabc\C!1!3
+
+/(\d{3}(?C))*/
+ 123\C+
+ 123456\C+
+ 123456789\C+
+
+/((xyz)(?C)p|(?C1)xyzabc)/
+ xyzabc\C+
+
+/(X)((xyz)(?C)p|(?C1)xyzabc)/
+ Xxyzabc\C+
+
+/(?=(abc))(?C)abcdef/
+ abcdef\C+
+
+/(?!(abc)(?C1)d)(?C2)abcxyz/
+ abcxyz\C+
+
+/(?<=(abc)(?C))xyz/
+ abcxyz\C+
+
+/(?C)abc/
+
+/(?C)^abc/
+
+/(?C)a|b/S
+
+/(?R)/
+
+/(a|(?R))/
+
+/(ab|(bc|(de|(?R))))/
+
+/x(ab|(bc|(de|(?R))))/
+ xab
+ xbc
+ xde
+ xxab
+ xxxab
+ *** Failers
+ xyab
+
+/(ab|(bc|(de|(?1))))/
+
+/x(ab|(bc|(de|(?1)x)x)x)/
+
+/^([^()]|\((?1)*\))*$/
+ abc
+ a(b)c
+ a(b(c))d
+ *** Failers)
+ a(b(c)d
+
+/^>abc>([^()]|\((?1)*\))*<xyz<$/
+ >abc>123<xyz<
+ >abc>1(2)3<xyz<
+ >abc>(1(2)3)<xyz<
+
+/(a(?1)b)/D
+
+/(a(?1)+b)/D
+
+/^\W*(?:((.)\W*(?1)\W*\2|)|((.)\W*(?3)\W*\4|\W*.\W*))\W*$/i
+ 1221
+ Satan, oscillate my metallic sonatas!
+ A man, a plan, a canal: Panama!
+ Able was I ere I saw Elba.
+ *** Failers
+ The quick brown fox
+
+/^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/
+ 12
+ (((2+2)*-3)-7)
+ -12
+ *** Failers
+ ((2+2)*-3)-7)
+
+/^(x(y|(?1){2})z)/
+ xyz
+ xxyzxyzz
+ *** Failers
+ xxyzz
+ xxyzxyzxyzz
+
+/((< (?: (?(R) \d++ | [^<>]*+) | (?2)) * >))/x
+ <>
+ <abcd>
+ <abc <123> hij>
+ <abc <def> hij>
+ <abc<>def>
+ <abc<>
+ *** Failers
+ <abc
+
+/(?1)/
+
+/((?2)(abc)/
+
+/^(abc)def(?1)/
+ abcdefabc
+
+/^(a|b|c)=(?1)+/
+ a=a
+ a=b
+ a=bc
+
+/^(a|b|c)=((?1))+/
+ a=a
+ a=b
+ a=bc
+
+/a(?P<name1>b|c)d(?P<longername2>e)/D
+ abde
+ acde
+
+/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/D
+
+/(?P<a>a)...(?P=a)bbb(?P>a)d/D
+
+/^\W*(?:(?P<one>(?P<two>.)\W*(?P>one)\W*(?P=two)|)|(?P<three>(?P<four>.)\W*(?P>three)\W*(?P=four)|\W*.\W*))\W*$/i
+ 1221
+ Satan, oscillate my metallic sonatas!
+ A man, a plan, a canal: Panama!
+ Able was I ere I saw Elba.
+ *** Failers
+ The quick brown fox
+
+/((?(R)a|b))\1(?1)?/
+ bb
+ bbaa
+
+/(.*)a/sI
+
+/(.*)a\1/sI
+
+/(.*)a(b)\2/sI
+
+/((.*)a|(.*)b)z/sI
+
+/((.*)a|(.*)b)z\1/sI
+
+/((.*)a|(.*)b)z\2/sI
+
+/((.*)a|(.*)b)z\3/sI
+
+/((.*)a|^(.*)b)z\3/sI
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a/sI
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\31/sI
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\32/sI
+
+/(a)(bc)/ND
+ abc
+
+/(?P<one>a)(bc)/ND
+ abc
+
+/(a)(?P<named>bc)/ND
+
+/(a+)*zz/
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzbbbbbb\M
+ aaaaaaaaaaaaaz\M
+
+/(aaa(?C1)bbb|ab)/
+ aaabbb
+ aaabbb\C*0
+ aaabbb\C*1
+ aaabbb\C*-1
+
+/ab(?P<one>cd)ef(?P<two>gh)/
+ abcdefgh
+ abcdefgh\C1\Gtwo
+ abcdefgh\Cone\Ctwo
+ abcdefgh\Cthree
+
+/(?P<Tes>)(?P<Test>)/D
+
+/(?P<Test>)(?P<Tes>)/D
+
+/(?P<Z>zz)(?P<A>aa)/
+ zzaa\CZ
+ zzaa\CA
+
/ End of testinput2 /
diff --git a/testdata/testinput3 b/testdata/testinput3
index d3bd74f..391aa62 100644
--- a/testdata/testinput3
+++ b/testdata/testinput3
@@ -1,1724 +1,65 @@
-/(?<!bar)foo/
- foo
- catfood
- arfootle
- rfoosh
+/^[\w]+/
*** Failers
- barfoo
- towbarfoo
+ École
-/\w{3}(?<!bar)foo/
- catfood
- *** Failers
- foo
- barfoo
- towbarfoo
-
-/(?<=(foo)a)bar/
- fooabar
- *** Failers
- bar
- foobbar
-
-/\Aabc\z/m
- abc
- *** Failers
- abc\n
- qqq\nabc
- abc\nzzz
- qqq\nabc\nzzz
-
-"(?>.*/)foo"
- /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
-
-"(?>.*/)foo"
- /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
-
-/(?>(\.\d\d[1-9]?))\d+/
- 1.230003938
- 1.875000282
- *** Failers
- 1.235
-
-/^((?>\w+)|(?>\s+))*$/
- now is the time for all good men to come to the aid of the party
- *** Failers
- this is not a line with only words and spaces!
-
-/(\d+)(\w)/
- 12345a
- 12345+
-
-/((?>\d+))(\w)/
- 12345a
- *** Failers
- 12345+
-
-/(?>a+)b/
- aaab
-
-/((?>a+)b)/
- aaab
-
-/(?>(a+))b/
- aaab
-
-/(?>b)+/
- aaabbbccc
-
-/(?>a+|b+|c+)*c/
- aaabbbbccccd
-
-/((?>[^()]+)|\([^()]*\))+/
- ((abc(ade)ufh()()x
-
-/\(((?>[^()]+)|\([^()]+\))+\)/
- (abc)
- (abc(def)xyz)
- *** Failers
- ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-
-/a(?-i)b/i
- ab
- *** Failers
- Ab
- aB
- AB
-
-/(a (?x)b c)d e/
- a bcd e
- *** Failers
- a b cd e
- abcd e
- a bcde
-
-/(a b(?x)c d (?-x)e f)/
- a bcde f
- *** Failers
- abcdef
-
-/(a(?i)b)c/
- abc
- aBc
- *** Failers
- abC
- aBC
- Abc
- ABc
- ABC
- AbC
-
-/a(?i:b)c/
- abc
- aBc
- *** Failers
- ABC
- abC
- aBC
-
-/a(?i:b)*c/
- aBc
- aBBc
- *** Failers
- aBC
- aBBC
-
-/a(?=b(?i)c)\w\wd/
- abcd
- abCd
- *** Failers
- aBCd
- abcD
-
-/(?s-i:more.*than).*million/i
- more than million
- more than MILLION
- more \n than Million
- *** Failers
- MORE THAN MILLION
- more \n than \n million
-
-/(?:(?s-i)more.*than).*million/i
- more than million
- more than MILLION
- more \n than Million
- *** Failers
- MORE THAN MILLION
- more \n than \n million
-
-/(?>a(?i)b+)+c/
- abc
- aBbc
- aBBc
- *** Failers
- Abc
- abAb
- abbC
-
-/(?=a(?i)b)\w\wc/
- abc
- aBc
- *** Failers
- Ab
- abC
- aBC
-
-/(?<=a(?i)b)(\w\w)c/
- abxxc
- aBxxc
- *** Failers
- Abxxc
- ABxxc
- abxxC
-
-/(?:(a)|b)(?(1)A|B)/
- aA
- bB
- *** Failers
- aB
- bA
-
-/^(a)?(?(1)a|b)+$/
- aa
- b
- bb
- *** Failers
- ab
-
-/^(?(?=abc)\w{3}:|\d\d)$/
- abc:
- 12
- *** Failers
- 123
- xyz
-
-/^(?(?!abc)\d\d|\w{3}:)$/
- abc:
- 12
- *** Failers
- 123
- xyz
-
-/(?(?<=foo)bar|cat)/
- foobar
- cat
- fcat
- focat
- *** Failers
- foocat
+/^[\w]+/Lfr
+ École
-/(?(?<!foo)cat|bar)/
- foobar
- cat
- fcat
- focat
+/^[\w]+/
*** Failers
- foocat
+ École
-/( \( )? [^()]+ (?(1) \) |) /x
- abcd
- (abcd)
- the quick (abcd) fox
- (abcd
+/^[\W]+/
+ École
-/( \( )? [^()]+ (?(1) \) ) /x
- abcd
- (abcd)
- the quick (abcd) fox
- (abcd
-
-/^(?(2)a|(1)(2))+$/
- 12
- 12a
- 12aa
+/^[\W]+/Lfr
*** Failers
- 1234
+ École
-/((?i)blah)\s+\1/
- blah blah
- BLAH BLAH
- Blah Blah
- blaH blaH
+/[\b]/
+ \b
*** Failers
- blah BLAH
- Blah blah
- blaH blah
-
-/((?i)blah)\s+(?i:\1)/
- blah blah
- BLAH BLAH
- Blah Blah
- blaH blaH
- blah BLAH
- Blah blah
- blaH blah
-
-/(?>a*)*/
a
- aa
- aaaa
-
-/(abc|)+/
- abc
- abcabc
- abcabcabc
- xyz
-
-/([a]*)*/
- a
- aaaaa
-
-/([ab]*)*/
- a
- b
- ababab
- aaaabcde
- bbbb
-
-/([^a]*)*/
- b
- bbbb
- aaa
-
-/([^ab]*)*/
- cccc
- abab
-
-/([a]*?)*/
- a
- aaaa
-
-/([ab]*?)*/
- a
- b
- abab
- baba
-
-/([^a]*?)*/
- b
- bbbb
- aaa
-
-/([^ab]*?)*/
- c
- cccc
- baba
-
-/(?>a*)*/
- a
- aaabcde
-
-/((?>a*))*/
- aaaaa
- aabbaa
-
-/((?>a*?))*/
- aaaaa
- aabbaa
-
-/(?(?=[^a-z]+[a-z]) \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} ) /x
- 12-sep-98
- 12-09-98
- *** Failers
- sep-12-98
-
-/(?<=(foo))bar\1/
- foobarfoo
- foobarfootling
- *** Failers
- foobar
- barfoo
-
-/(?i:saturday|sunday)/
- saturday
- sunday
- Saturday
- Sunday
- SATURDAY
- SUNDAY
- SunDay
-
-/(a(?i)bc|BB)x/
- abcx
- aBCx
- bbx
- BBx
- *** Failers
- abcX
- aBCX
- bbX
- BBX
-
-/^([ab](?i)[cd]|[ef])/
- ac
- aC
- bD
- elephant
- Europe
- frog
- France
- *** Failers
- Africa
-
-/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
- ab
- aBd
- xy
- xY
- zebra
- Zambesi
- *** Failers
- aCD
- XY
-
-/(?<=foo\n)^bar/m
- foo\nbar
- *** Failers
- bar
- baz\nbar
-/(?<=(?<!foo)bar)baz/
- barbaz
- barbarbaz
- koobarbaz
+/[\b]/Lfr
+ \b
*** Failers
- baz
- foobarbaz
-
-/The case of aaaaaa is missed out below because I think Perl 5.005_02 gets/
-/it wrong; it sets $1 to aaa rather than aa. Compare the following test,/
-/where it does set $1 to aa when matching aaaaaa./
-
-/^(a\1?){4}$/
- a
- aa
- aaa
- aaaa
- aaaaa
- aaaaaaa
- aaaaaaaa
- aaaaaaaaa
- aaaaaaaaaa
- aaaaaaaaaaa
- aaaaaaaaaaaa
- aaaaaaaaaaaaa
- aaaaaaaaaaaaaa
- aaaaaaaaaaaaaaa
- aaaaaaaaaaaaaaaa
-
-/^(a\1?)(a\1?)(a\2?)(a\3?)$/
a
- aa
- aaa
- aaaa
- aaaaa
- aaaaaa
- aaaaaaa
- aaaaaaaa
- aaaaaaaaa
- aaaaaaaaaa
- aaaaaaaaaaa
- aaaaaaaaaaaa
- aaaaaaaaaaaaa
- aaaaaaaaaaaaaa
- aaaaaaaaaaaaaaa
- aaaaaaaaaaaaaaaa
-
-/The following tests are taken from the Perl 5.005 test suite; some of them/
-/are compatible with 5.004, but I'd rather not have to sort them out./
-
-/abc/
- abc
- xabcy
- ababc
- *** Failers
- xbc
- axc
- abx
-
-/ab*c/
- abc
-
-/ab*bc/
- abc
- abbc
- abbbbc
-
-/.{1}/
- abbbbc
-
-/.{3,4}/
- abbbbc
-
-/ab{0,}bc/
- abbbbc
-
-/ab+bc/
- abbc
- *** Failers
- abc
- abq
-
-/ab{1,}bc/
-
-/ab+bc/
- abbbbc
-
-/ab{1,}bc/
- abbbbc
-
-/ab{1,3}bc/
- abbbbc
-
-/ab{3,4}bc/
- abbbbc
-
-/ab{4,5}bc/
- *** Failers
- abq
- abbbbc
-
-/ab?bc/
- abbc
- abc
-
-/ab{0,1}bc/
- abc
-
-/ab?bc/
-
-/ab?c/
- abc
-
-/ab{0,1}c/
- abc
-
-/^abc$/
- abc
- *** Failers
- abbbbc
- abcc
-
-/^abc/
- abcc
-
-/^abc$/
-/abc$/
- aabc
+/^\w+/
*** Failers
- aabc
- aabcd
+ École
-/^/
- abc
+/^\w+/Lfr
+ École
-/$/
- abc
+/(.+)\b(.+)/
+ École
-/a.c/
- abc
- axc
-
-/a.*c/
- axyzc
-
-/a[bc]d/
- abd
- *** Failers
- axyzd
- abc
-
-/a[b-d]e/
- ace
-
-/a[b-d]/
- aac
-
-/a[-b]/
- a-
-
-/a[b-]/
- a-
-
-/a]/
- a]
-
-/a[]]b/
- a]b
-
-/a[^bc]d/
- aed
- *** Failers
- abd
- abd
-
-/a[^-b]c/
- adc
-
-/a[^]b]c/
- adc
- *** Failers
- a-c
- a]c
-
-/\ba\b/
- a-
- -a
- -a-
-
-/\by\b/
+/(.+)\b(.+)/Lfr
*** Failers
- xy
- yz
- xyz
+ École
-/\Ba\B/
+/École/i
+ École
*** Failers
- a-
- -a
- -a-
+ école
-/\By\b/
- xy
+/École/iLfr
+ École
+ école
-/\by\B/
- yz
+/\w/IS
-/\By\B/
- xyz
+/\w/ISLfr
-/\w/
- a
-
-/\W/
- -
- *** Failers
- -
- a
-
-/a\sb/
- a b
-
-/a\Sb/
- a-b
- *** Failers
- a-b
- a b
-
-/\d/
- 1
-
-/\D/
- -
- *** Failers
- -
- 1
-
-/[\w]/
- a
-
-/[\W]/
- -
- *** Failers
- -
- a
-
-/a[\s]b/
- a b
-
-/a[\S]b/
- a-b
- *** Failers
- a-b
- a b
-
-/[\d]/
- 1
-
-/[\D]/
- -
- *** Failers
- -
- 1
-
-/ab|cd/
- abc
- abcd
-
-/()ef/
- def
-
-/$b/
-
-/a\(b/
- a(b
-
-/a\(*b/
- ab
- a((b
-
-/a\\b/
- a\b
-
-/((a))/
- abc
-
-/(a)b(c)/
- abc
-
-/a+b+c/
- aabbabc
-
-/a{1,}b{1,}c/
- aabbabc
-
-/a.+?c/
- abcabc
-
-/(a+|b)*/
- ab
-
-/(a+|b){0,}/
- ab
-
-/(a+|b)+/
- ab
-
-/(a+|b){1,}/
- ab
-
-/(a+|b)?/
- ab
-
-/(a+|b){0,1}/
- ab
-
-/[^ab]*/
- cde
-
-/abc/
- *** Failers
- b
-
-
-/a*/
-
-
-/([abc])*d/
- abbbcd
-
-/([abc])*bcd/
- abcd
-
-/a|b|c|d|e/
- e
-
-/(a|b|c|d|e)f/
- ef
-
-/abcd*efg/
- abcdefg
-
-/ab*/
- xabyabbbz
- xayabbbz
-
-/(ab|cd)e/
- abcde
-
-/[abhgefdc]ij/
- hij
-
-/^(ab|cd)e/
-
-/(abc|)ef/
- abcdef
-
-/(a|b)c*d/
- abcd
-
-/(ab|ab*)bc/
- abc
-
-/a([bc]*)c*/
- abc
-
-/a([bc]*)(c*d)/
- abcd
-
-/a([bc]+)(c*d)/
- abcd
-
-/a([bc]*)(c+d)/
- abcd
-
-/a[bcd]*dcdcde/
- adcdcde
-
-/a[bcd]+dcdcde/
- *** Failers
- abcde
- adcdcde
-
-/(ab|a)b*c/
- abc
-
-/((a)(b)c)(d)/
- abcd
-
-/[a-zA-Z_][a-zA-Z0-9_]*/
- alpha
-
-/^a(bc+|b[eh])g|.h$/
- abh
-
-/(bc+d$|ef*g.|h?i(j|k))/
- effgz
- ij
- reffgz
- *** Failers
- effg
- bcdd
-
-/((((((((((a))))))))))/
- a
-
-/((((((((((a))))))))))\10/
- aa
-
-/(((((((((a)))))))))/
- a
-
-/multiple words of text/
- *** Failers
- aa
- uh-uh
-
-/multiple words/
- multiple words, yeah
-
-/(.*)c(.*)/
- abcde
-
-/\((.*), (.*)\)/
- (a, b)
-
-/[k]/
-
-/abcd/
- abcd
-
-/a(bc)d/
- abcd
-
-/a[-]?c/
- ac
-
-/(abc)\1/
- abcabc
-
-/([a-c]*)\1/
- abcabc
-
-/(a)|\1/
- a
- *** Failers
- ab
- x
-
-/(([a-c])b*?\2)*/
- ababbbcbc
-
-/(([a-c])b*?\2){3}/
- ababbbcbc
-
-/((\3|b)\2(a)x)+/
- aaaxabaxbaaxbbax
-
-/((\3|b)\2(a)){2,}/
- bbaababbabaaaaabbaaaabba
-
-/abc/i
- ABC
- XABCY
- ABABC
- *** Failers
- aaxabxbaxbbx
- XBC
- AXC
- ABX
-
-/ab*c/i
- ABC
-
-/ab*bc/i
- ABC
- ABBC
-
-/ab*?bc/i
- ABBBBC
-
-/ab{0,}?bc/i
- ABBBBC
-
-/ab+?bc/i
- ABBC
-
-/ab+bc/i
- *** Failers
- ABC
- ABQ
-
-/ab{1,}bc/i
-
-/ab+bc/i
- ABBBBC
-
-/ab{1,}?bc/i
- ABBBBC
-
-/ab{1,3}?bc/i
- ABBBBC
-
-/ab{3,4}?bc/i
- ABBBBC
-
-/ab{4,5}?bc/i
- *** Failers
- ABQ
- ABBBBC
-
-/ab??bc/i
- ABBC
- ABC
-
-/ab{0,1}?bc/i
- ABC
-
-/ab??bc/i
-
-/ab??c/i
- ABC
-
-/ab{0,1}?c/i
- ABC
-
-/^abc$/i
- ABC
- *** Failers
- ABBBBC
- ABCC
-
-/^abc/i
- ABCC
-
-/^abc$/i
-
-/abc$/i
- AABC
-
-/^/i
- ABC
-
-/$/i
- ABC
-
-/a.c/i
- ABC
- AXC
-
-/a.*?c/i
- AXYZC
-
-/a.*c/i
- *** Failers
- AABC
- AXYZD
-
-/a[bc]d/i
- ABD
-
-/a[b-d]e/i
- ACE
- *** Failers
- ABC
- ABD
-
-/a[b-d]/i
- AAC
-
-/a[-b]/i
- A-
-
-/a[b-]/i
- A-
-
-/a]/i
- A]
-
-/a[]]b/i
- A]B
-
-/a[^bc]d/i
- AED
-
-/a[^-b]c/i
- ADC
- *** Failers
- ABD
- A-C
-
-/a[^]b]c/i
- ADC
-
-/ab|cd/i
- ABC
- ABCD
-
-/()ef/i
- DEF
-
-/$b/i
- *** Failers
- A]C
- B
+/^[\xc8-\xc9]/iLfr
+ École
+ école
-/a\(b/i
- A(B
-
-/a\(*b/i
- AB
- A((B
-
-/a\\b/i
- A\B
-
-/((a))/i
- ABC
-
-/(a)b(c)/i
- ABC
-
-/a+b+c/i
- AABBABC
-
-/a{1,}b{1,}c/i
- AABBABC
-
-/a.+?c/i
- ABCABC
-
-/a.*?c/i
- ABCABC
-
-/a.{0,5}?c/i
- ABCABC
-
-/(a+|b)*/i
- AB
-
-/(a+|b){0,}/i
- AB
-
-/(a+|b)+/i
- AB
-
-/(a+|b){1,}/i
- AB
-
-/(a+|b)?/i
- AB
-
-/(a+|b){0,1}/i
- AB
-
-/(a+|b){0,1}?/i
- AB
-
-/[^ab]*/i
- CDE
-
-/abc/i
-
-/a*/i
-
-
-/([abc])*d/i
- ABBBCD
-
-/([abc])*bcd/i
- ABCD
-
-/a|b|c|d|e/i
- E
-
-/(a|b|c|d|e)f/i
- EF
-
-/abcd*efg/i
- ABCDEFG
-
-/ab*/i
- XABYABBBZ
- XAYABBBZ
-
-/(ab|cd)e/i
- ABCDE
-
-/[abhgefdc]ij/i
- HIJ
-
-/^(ab|cd)e/i
- ABCDE
-
-/(abc|)ef/i
- ABCDEF
-
-/(a|b)c*d/i
- ABCD
-
-/(ab|ab*)bc/i
- ABC
-
-/a([bc]*)c*/i
- ABC
-
-/a([bc]*)(c*d)/i
- ABCD
-
-/a([bc]+)(c*d)/i
- ABCD
-
-/a([bc]*)(c+d)/i
- ABCD
-
-/a[bcd]*dcdcde/i
- ADCDCDE
-
-/a[bcd]+dcdcde/i
-
-/(ab|a)b*c/i
- ABC
-
-/((a)(b)c)(d)/i
- ABCD
-
-/[a-zA-Z_][a-zA-Z0-9_]*/i
- ALPHA
-
-/^a(bc+|b[eh])g|.h$/i
- ABH
-
-/(bc+d$|ef*g.|h?i(j|k))/i
- EFFGZ
- IJ
- REFFGZ
- *** Failers
- ADCDCDE
- EFFG
- BCDD
-
-/((((((((((a))))))))))/i
- A
-
-/((((((((((a))))))))))\10/i
- AA
-
-/(((((((((a)))))))))/i
- A
-
-/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
- A
-
-/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
- C
-
-/multiple words of text/i
- *** Failers
- AA
- UH-UH
-
-/multiple words/i
- MULTIPLE WORDS, YEAH
-
-/(.*)c(.*)/i
- ABCDE
-
-/\((.*), (.*)\)/i
- (A, B)
-
-/[k]/i
-
-/abcd/i
- ABCD
-
-/a(bc)d/i
- ABCD
-
-/a[-]?c/i
- AC
-
-/(abc)\1/i
- ABCABC
-
-/([a-c]*)\1/i
- ABCABC
-
-/a(?!b)./
- abad
-
-/a(?=d)./
- abad
-
-/a(?=c|d)./
- abad
-
-/a(?:b|c|d)(.)/
- ace
-
-/a(?:b|c|d)*(.)/
- ace
-
-/a(?:b|c|d)+?(.)/
- ace
- acdbcdbe
-
-/a(?:b|c|d)+(.)/
- acdbcdbe
-
-/a(?:b|c|d){2}(.)/
- acdbcdbe
-
-/a(?:b|c|d){4,5}(.)/
- acdbcdbe
-
-/a(?:b|c|d){4,5}?(.)/
- acdbcdbe
-
-/((foo)|(bar))*/
- foobar
-
-/a(?:b|c|d){6,7}(.)/
- acdbcdbe
-
-/a(?:b|c|d){6,7}?(.)/
- acdbcdbe
-
-/a(?:b|c|d){5,6}(.)/
- acdbcdbe
-
-/a(?:b|c|d){5,6}?(.)/
- acdbcdbe
-
-/a(?:b|c|d){5,7}(.)/
- acdbcdbe
-
-/a(?:b|c|d){5,7}?(.)/
- acdbcdbe
-
-/a(?:b|(c|e){1,2}?|d)+?(.)/
- ace
-
-/^(.+)?B/
- AB
-
-/^([^a-z])|(\^)$/
- .
-
-/^[<>]&/
- <&OUT
-
-/^(a\1?){4}$/
- aaaaaaaaaa
- *** Failers
- AB
- aaaaaaaaa
- aaaaaaaaaaa
-
-/^(a(?(1)\1)){4}$/
- aaaaaaaaaa
- *** Failers
- aaaaaaaaa
- aaaaaaaaaaa
-
-/(?:(f)(o)(o)|(b)(a)(r))*/
- foobar
-
-/(?<=a)b/
- ab
- *** Failers
- cb
- b
-
-/(?<!c)b/
- ab
- b
- b
-
-/(?:..)*a/
- aba
-
-/(?:..)*?a/
- aba
-
-/^(?:b|a(?=(.)))*\1/
- abc
-
-/^(){3,5}/
- abc
-
-/^(a+)*ax/
- aax
-
-/^((a|b)+)*ax/
- aax
-
-/^((a|bc)+)*ax/
- aax
-
-/(a|x)*ab/
- cab
-
-/(a)*ab/
- cab
-
-/(?:(?i)a)b/
- ab
-
-/((?i)a)b/
- ab
-
-/(?:(?i)a)b/
- Ab
-
-/((?i)a)b/
- Ab
-
-/(?:(?i)a)b/
- *** Failers
- cb
- aB
-
-/((?i)a)b/
-
-/(?i:a)b/
- ab
-
-/((?i:a))b/
- ab
-
-/(?i:a)b/
- Ab
-
-/((?i:a))b/
- Ab
-
-/(?i:a)b/
- *** Failers
- aB
- aB
-
-/((?i:a))b/
-
-/(?:(?-i)a)b/i
- ab
-
-/((?-i)a)b/i
- ab
-
-/(?:(?-i)a)b/i
- aB
-
-/((?-i)a)b/i
- aB
-
-/(?:(?-i)a)b/i
- *** Failers
- aB
- Ab
-
-/((?-i)a)b/i
-
-/(?:(?-i)a)b/i
- aB
-
-/((?-i)a)b/i
- aB
-
-/(?:(?-i)a)b/i
- *** Failers
- Ab
- AB
-
-/((?-i)a)b/i
-
-/(?-i:a)b/i
- ab
-
-/((?-i:a))b/i
- ab
-
-/(?-i:a)b/i
- aB
-
-/((?-i:a))b/i
- aB
-
-/(?-i:a)b/i
- *** Failers
- AB
- Ab
-
-/((?-i:a))b/i
-
-/(?-i:a)b/i
- aB
-
-/((?-i:a))b/i
- aB
-
-/(?-i:a)b/i
- *** Failers
- Ab
- AB
-
-/((?-i:a))b/i
-
-/((?-i:a.))b/i
- *** Failers
- AB
- a\nB
-
-/((?s-i:a.))b/i
- a\nB
-
-/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
- cabbbb
-
-/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
- caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
-
-/(ab)\d\1/i
- Ab4ab
- ab4Ab
-
-/foo\w*\d{4}baz/
- foobar1234baz
-
-/x(~~)*(?:(?:F)?)?/
- x~~
-
-/^a(?#xxx){3}c/
- aaac
-
-/^a (?#xxx) (?#yyy) {3}c/x
- aaac
-
-/(?<![cd])b/
- *** Failers
- B\nB
- dbcb
-
-/(?<![cd])[ab]/
- dbaacb
-
-/(?<!(c|d))b/
-
-/(?<!(c|d))[ab]/
- dbaacb
-
-/(?<!cd)[ab]/
- cdaccb
-
-/^(?:a?b?)*$/
- *** Failers
- dbcb
- a--
-
-/((?s)^a(.))((?m)^b$)/
- a\nb\nc\n
-
-/((?m)^b$)/
- a\nb\nc\n
-
-/(?m)^b/
- a\nb\n
-
-/(?m)^(b)/
- a\nb\n
-
-/((?m)^b)/
- a\nb\n
-
-/\n((?m)^b)/
- a\nb\n
-
-/((?s).)c(?!.)/
- a\nb\nc\n
- a\nb\nc\n
-
-/((?s)b.)c(?!.)/
- a\nb\nc\n
- a\nb\nc\n
-
-/^b/
-
-/()^b/
- *** Failers
- a\nb\nc\n
- a\nb\nc\n
-
-/((?m)^b)/
- a\nb\nc\n
-
-/(?(1)a|b)/
-
-/(?(1)b|a)/
- a
-
-/(x)?(?(1)a|b)/
- *** Failers
- a
- a
-
-/(x)?(?(1)b|a)/
- a
-
-/()?(?(1)b|a)/
- a
-
-/()(?(1)b|a)/
-
-/()?(?(1)a|b)/
- a
-
-/^(\()?blah(?(1)(\)))$/
- (blah)
- blah
- *** Failers
- a
- blah)
- (blah
-
-/^(\(+)?blah(?(1)(\)))$/
- (blah)
- blah
- *** Failers
- blah)
- (blah
-
-/(?(?!a)a|b)/
-
-/(?(?!a)b|a)/
- a
-
-/(?(?=a)b|a)/
- *** Failers
- a
- a
-
-/(?(?=a)a|b)/
- a
-
-/(?=(a+?))(\1ab)/
- aaab
-
-/^(?=(a+?))\1ab/
-
-/(\w+:)+/
- one:
-
-/$(?<=^(a))/
- a
-
-/(?=(a+?))(\1ab)/
- aaab
-
-/^(?=(a+?))\1ab/
- *** Failers
- aaab
- aaab
-
-/([\w:]+::)?(\w+)$/
- abcd
- xy:z:::abcd
-
-/^[^bcd]*(c+)/
- aexycd
-
-/(a*)b+/
- caab
-
-/([\w:]+::)?(\w+)$/
- abcd
- xy:z:::abcd
- *** Failers
- abcd:
- abcd:
-
-/^[^bcd]*(c+)/
- aexycd
-
-/(>a+)ab/
-
-/(?>a+)b/
- aaab
-
-/([[:]+)/
- a:[b]:
-
-/([[=]+)/
- a=[b]=
-
-/([[.]+)/
- a.[b].
-
-/((?>a+)b)/
- aaab
-
-/(?>(a+))b/
- aaab
-
-/((?>[^()]+)|\([^()]*\))+/
- ((abc(ade)ufh()()x
-
-/a\Z/
- *** Failers
- aaab
- a\nb\n
-
-/b\Z/
- a\nb\n
-
-/b\z/
-
-/b\Z/
- a\nb
-
-/b\z/
- a\nb
- *** Failers
-
-/^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
- a
- abc
- a-b
- 0-9
- a.b
- 5.6.7
- the.quick.brown.fox
- a100.b200.300c
- 12-ab.1245
- ***Failers
- \
- .a
- -a
- a-
- a.
- a_b
- a.-
- a..
- ab..bc
- the.quick.brown.fox-
- the.quick.brown.fox.
- the.quick.brown.fox_
- the.quick.brown.fox+
-
-/(?>.*)(?<=(abcd|wxyz))/
- alphabetabcd
- endingwxyz
- *** Failers
- a rather long string that doesn't end with one of them
-
-/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark otherword
- word cat dog elephant mussel cow horse canary baboon snake shark
-
-/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
-
-/(?<=\d{3}(?!999))foo/
- 999foo
- 123999foo
- *** Failers
- 123abcfoo
-
-/(?<=(?!...999)\d{3})foo/
- 999foo
- 123999foo
- *** Failers
- 123abcfoo
-
-/(?<=\d{3}(?!999)...)foo/
- 123abcfoo
- 123456foo
- *** Failers
- 123999foo
-
-/(?<=\d{3}...)(?<!999)foo/
- 123abcfoo
- 123456foo
- *** Failers
- 123999foo
-
-/<a[\s]+href[\s]*=[\s]* # find <a href=
- ([\"\'])? # find single or double quote
- (?(1) (.*?)\1 | ([^\s]+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- <a href=\"abcd xyz pqr\" cats
- <a href=\'abcd xyz pqr\' cats
-
-/<a\s+href\s*=\s* # find <a href=
- (["'])? # find single or double quote
- (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- <a href=\"abcd xyz pqr\" cats
- <a href = \'abcd xyz pqr\' cats
-
-/<a\s+href(?>\s*)=(?>\s*) # find <a href=
- (["'])? # find single or double quote
- (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- <a href=\"abcd xyz pqr\" cats
- <a href = \'abcd xyz pqr\' cats
-
-/((Z)+|A)*/
- ZABCDEFG
-
-/(Z()|A)*/
- ZABCDEFG
-
-/(Z(())|A)*/
- ZABCDEFG
-
-/((?>Z)+|A)*/
- ZABCDEFG
-
-/((?>)+|A)*/
- ZABCDEFG
-
-/a*/g
- abbab
-
-/^[a-\d]/
- abcde
- -things
- 0digit
- *** Failers
- bcdef
-
-/^[\d-a]/
- abcde
- -things
- 0digit
- *** Failers
- bcdef
+/^[\xc8-\xc9]/Lfr
+ École
+ *** Failers
+ école
-/ End of testinput3 /
+/ End of testinput3 /
diff --git a/testdata/testinput4 b/testdata/testinput4
index f287896..540660f 100644
--- a/testdata/testinput4
+++ b/testdata/testinput4
@@ -1,65 +1,485 @@
-/^[\w]+/
+/-- Do not use the \x{} construct except with patterns that have the --/
+/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/
+/-- that option is set. However, the latest Perls recognize them always. --/
+
+/a.b/8
+ acb
+ a\x7fb
+ a\x{100}b
+ *** Failers
+ a\nb
+
+/a(.{3})b/8
+ a\x{4000}xyb
+ a\x{4000}\x7fyb
+ a\x{4000}\x{100}yb
+ *** Failers
+ a\x{4000}b
+ ac\ncb
+
+/a(.*?)(.)/
+ a\xc0\x88b
+
+/a(.*?)(.)/8
+ a\x{100}b
+
+/a(.*)(.)/
+ a\xc0\x88b
+
+/a(.*)(.)/8
+ a\x{100}b
+
+/a(.)(.)/
+ a\xc0\x92bcd
+
+/a(.)(.)/8
+ a\x{240}bcd
+
+/a(.?)(.)/
+ a\xc0\x92bcd
+
+/a(.?)(.)/8
+ a\x{240}bcd
+
+/a(.??)(.)/
+ a\xc0\x92bcd
+
+/a(.??)(.)/8
+ a\x{240}bcd
+
+/a(.{3})b/8
+ a\x{1234}xyb
+ a\x{1234}\x{4321}yb
+ a\x{1234}\x{4321}\x{3412}b
+ *** Failers
+ a\x{1234}b
+ ac\ncb
+
+/a(.{3,})b/8
+ a\x{1234}xyb
+ a\x{1234}\x{4321}yb
+ a\x{1234}\x{4321}\x{3412}b
+ axxxxbcdefghijb
+ a\x{1234}\x{4321}\x{3412}\x{3421}b
+ *** Failers
+ a\x{1234}b
+
+/a(.{3,}?)b/8
+ a\x{1234}xyb
+ a\x{1234}\x{4321}yb
+ a\x{1234}\x{4321}\x{3412}b
+ axxxxbcdefghijb
+ a\x{1234}\x{4321}\x{3412}\x{3421}b
+ *** Failers
+ a\x{1234}b
+
+/a(.{3,5})b/8
+ a\x{1234}xyb
+ a\x{1234}\x{4321}yb
+ a\x{1234}\x{4321}\x{3412}b
+ axxxxbcdefghijb
+ a\x{1234}\x{4321}\x{3412}\x{3421}b
+ axbxxbcdefghijb
+ axxxxxbcdefghijb
+ *** Failers
+ a\x{1234}b
+ axxxxxxbcdefghijb
+
+/a(.{3,5}?)b/8
+ a\x{1234}xyb
+ a\x{1234}\x{4321}yb
+ a\x{1234}\x{4321}\x{3412}b
+ axxxxbcdefghijb
+ a\x{1234}\x{4321}\x{3412}\x{3421}b
+ axbxxbcdefghijb
+ axxxxxbcdefghijb
+ *** Failers
+ a\x{1234}b
+ axxxxxxbcdefghijb
+
+/^[a\x{c0}]/8
+ *** Failers
+ \x{100}
+
+/(?<=aXb)cd/8
+ aXbcd
+
+/(?<=a\x{100}b)cd/8
+ a\x{100}bcd
+
+/(?<=a\x{100000}b)cd/8
+ a\x{100000}bcd
+
+/(?:\x{100}){3}b/8
+ \x{100}\x{100}\x{100}b
+ *** Failers
+ \x{100}\x{100}b
+
+/\x{ab}/8
+ \x{ab}
+ \xc2\xab
+ *** Failers
+ \x00{ab}
+
+/(?<=(.))X/8
+ WXYZ
+ \x{256}XYZ
+ *** Failers
+ XYZ
+
+/X(\C{3})/8
+ X\x{1234}
+
+/X(\C{4})/8
+ X\x{1234}YZ
+
+/X\C*/8
+ XYZabcdce
+
+/X\C*?/8
+ XYZabcde
+
+/X\C{3,5}/8
+ Xabcdefg
+ X\x{1234}
+ X\x{1234}YZ
+ X\x{1234}\x{512}
+ X\x{1234}\x{512}YZ
+
+/X\C{3,5}?/8
+ Xabcdefg
+ X\x{1234}
+ X\x{1234}YZ
+ X\x{1234}\x{512}
+
+/[^a]+/8g
+ bcd
+ \x{100}aY\x{256}Z
+
+/^[^a]{2}/8
+ \x{100}bc
+
+/^[^a]{2,}/8
+ \x{100}bcAa
+
+/^[^a]{2,}?/8
+ \x{100}bca
+
+/[^a]+/8ig
+ bcd
+ \x{100}aY\x{256}Z
+
+/^[^a]{2}/8i
+ \x{100}bc
+
+/^[^a]{2,}/8i
+ \x{100}bcAa
+
+/^[^a]{2,}?/8i
+ \x{100}bca
+
+/\x{100}{0,0}/8
+ abcd
+
+/\x{100}?/8
+ abcd
+ \x{100}\x{100}
+
+/\x{100}{0,3}/8
+ \x{100}\x{100}
+ \x{100}\x{100}\x{100}\x{100}
+
+/\x{100}*/8
+ abce
+ \x{100}\x{100}\x{100}\x{100}
+
+/\x{100}{1,1}/8
+ abcd\x{100}\x{100}\x{100}\x{100}
+
+/\x{100}{1,3}/8
+ abcd\x{100}\x{100}\x{100}\x{100}
+
+/\x{100}+/8
+ abcd\x{100}\x{100}\x{100}\x{100}
+
+/\x{100}{3}/8
+ abcd\x{100}\x{100}\x{100}XX
+
+/\x{100}{3,5}/8
+ abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+
+/\x{100}{3,}/8
+ abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+
+/(?<=a\x{100}{2}b)X/8+
+ Xyyya\x{100}\x{100}bXzzz
+
+/\D*/8
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/\D*/8
+ \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+
+/\D/8
+ 1X2
+ 1\x{100}2
+
+/>\S/8
+ > >X Y
+ > >\x{100} Y
+
+/\W/8
+ A.B
+ A\x{100}B
+
+/\d/8
+ \x{100}3
+
+/\s/8
+ \x{100} X
+
+/\w/8
+ \x{100}X
+
+/\D+/8
+ 12abcd34
*** Failers
- École
+ 1234
-/^[\w]+/Lfr
- École
+/\D{2,3}/8
+ 12abcd34
+ 12ab34
+ *** Failers
+ 1234
+ 12a34
-/^[\w]+/
+/\D{2,3}?/8
+ 12abcd34
+ 12ab34
+ *** Failers
+ 1234
+ 12a34
+
+/\d+/8
+ 12abcd34
*** Failers
- École
-/^[\W]+/
- École
+/\d{2,3}/8
+ 12abcd34
+ 1234abcd
+ *** Failers
+ 1.4
+
+/\d{2,3}?/8
+ 12abcd34
+ 1234abcd
+ *** Failers
+ 1.4
-/^[\W]+/Lfr
+/\S+/8
+ 12abcd34
*** Failers
- École
+ \ \
-/[\b]/
- \b
+/\S{2,3}/8
+ 12abcd34
+ 1234abcd
*** Failers
- a
+ \ \
-/[\b]/Lfr
- \b
+/\S{2,3}?/8
+ 12abcd34
+ 1234abcd
*** Failers
- a
+ \ \
-/^\w+/
+/>\s+</8+
+ 12> <34
*** Failers
- École
-/^\w+/Lfr
- École
+/>\s{2,3}</8+
+ ab> <cd
+ ab> <ce
+ *** Failers
+ ab> <cd
-/(.+)\b(.+)/
- École
+/>\s{2,3}?</8+
+ ab> <cd
+ ab> <ce
+ *** Failers
+ ab> <cd
-/(.+)\b(.+)/Lfr
+/\w+/8
+ 12 34
*** Failers
- École
+ +++=*!
-/École/i
- École
+/\w{2,3}/8
+ ab cd
+ abcd ce
*** Failers
- école
+ a.b.c
-/École/iLfr
- École
- école
+/\w{2,3}?/8
+ ab cd
+ abcd ce
+ *** Failers
+ a.b.c
-/\w/IS
+/\W+/8
+ 12====34
+ *** Failers
+ abcd
-/\w/ISLfr
+/\W{2,3}/8
+ ab====cd
+ ab==cd
+ *** Failers
+ a.b.c
-/^[\xc8-\xc9]/iLfr
- École
- école
+/\W{2,3}?/8
+ ab====cd
+ ab==cd
+ *** Failers
+ a.b.c
-/^[\xc8-\xc9]/Lfr
- École
+/[\x{100}]/8
+ \x{100}
+ Z\x{100}
+ \x{100}Z
*** Failers
- école
+
+/[Z\x{100}]/8
+ Z\x{100}
+ \x{100}
+ \x{100}Z
+ *** Failers
+
+/[\x{100}\x{200}]/8
+ ab\x{100}cd
+ ab\x{200}cd
+ *** Failers
+
+/[\x{100}-\x{200}]/8
+ ab\x{100}cd
+ ab\x{200}cd
+ ab\x{111}cd
+ *** Failers
+
+/[z-\x{200}]/8
+ ab\x{100}cd
+ ab\x{200}cd
+ ab\x{111}cd
+ abzcd
+ ab|cd
+ *** Failers
+
+/[Q\x{100}\x{200}]/8
+ ab\x{100}cd
+ ab\x{200}cd
+ Q?
+ *** Failers
+
+/[Q\x{100}-\x{200}]/8
+ ab\x{100}cd
+ ab\x{200}cd
+ ab\x{111}cd
+ Q?
+ *** Failers
+
+/[Qz-\x{200}]/8
+ ab\x{100}cd
+ ab\x{200}cd
+ ab\x{111}cd
+ abzcd
+ ab|cd
+ Q?
+ *** Failers
+
+/[\x{100}\x{200}]{1,3}/8
+ ab\x{100}cd
+ ab\x{200}cd
+ ab\x{200}\x{100}\x{200}\x{100}cd
+ *** Failers
+
+/[\x{100}\x{200}]{1,3}?/8
+ ab\x{100}cd
+ ab\x{200}cd
+ ab\x{200}\x{100}\x{200}\x{100}cd
+ *** Failers
+
+/[Q\x{100}\x{200}]{1,3}/8
+ ab\x{100}cd
+ ab\x{200}cd
+ ab\x{200}\x{100}\x{200}\x{100}cd
+ *** Failers
+
+/[Q\x{100}\x{200}]{1,3}?/8
+ ab\x{100}cd
+ ab\x{200}cd
+ ab\x{200}\x{100}\x{200}\x{100}cd
+ *** Failers
+
+/(?<=[\x{100}\x{200}])X/8
+ abc\x{200}X
+ abc\x{100}X
+ *** Failers
+ X
+
+/(?<=[Q\x{100}\x{200}])X/8
+ abc\x{200}X
+ abc\x{100}X
+ abQX
+ *** Failers
+ X
+
+/(?<=[\x{100}\x{200}]{3})X/8
+ abc\x{100}\x{200}\x{100}X
+ *** Failers
+ abc\x{200}X
+ X
+
+/[^\x{100}\x{200}]X/8
+ AX
+ \x{150}X
+ \x{500}X
+ *** Failers
+ \x{100}X
+ \x{200}X
+
+/[^Q\x{100}\x{200}]X/8
+ AX
+ \x{150}X
+ \x{500}X
+ *** Failers
+ \x{100}X
+ \x{200}X
+ QX
+
+/[^\x{100}-\x{200}]X/8
+ AX
+ \x{500}X
+ *** Failers
+ \x{100}X
+ \x{150}X
+ \x{200}X
+
+/a\Cb/
+ aXb
+ a\nb
+
+/a\Cb/8
+ aXb
+ a\nb
+ *** Failers
+ a\x{100}b
+
+/[z-\x{100}]/8i
+ z
+ Z
+ \x{100}
+ *** Failers
+ \x{101}
+ y
/ End of testinput4 /
diff --git a/testdata/testinput5 b/testdata/testinput5
index d66cfbd..ec1aa9a 100644
--- a/testdata/testinput5
+++ b/testdata/testinput5
@@ -1,118 +1,185 @@
-/-- Because of problems with Perl 5.6 in handling UTF-8 vs non UTF-8 --/
-/-- strings automatically, do not use the \x{} construct except with --/
-/-- patterns that have the /8 option set, and don't use them without! --/
-
-/a.b/8
- acb
- a\x7fb
- a\x{100}b
- *** Failers
- a\nb
+/\x{100}/8DM
-/a(.{3})b/8
- a\x{4000}xyb
- a\x{4000}\x7fyb
- a\x{4000}\x{100}yb
- *** Failers
- a\x{4000}b
- ac\ncb
+/\x{1000}/8DM
-/a(.*?)(.)/
- a\xc0\x88b
+/\x{10000}/8DM
-/a(.*?)(.)/8
- a\x{100}b
+/\x{100000}/8DM
-/a(.*)(.)/
- a\xc0\x88b
+/\x{1000000}/8DM
-/a(.*)(.)/8
- a\x{100}b
+/\x{4000000}/8DM
-/a(.)(.)/
- a\xc0\x92bcd
+/\x{7fffFFFF}/8DM
-/a(.)(.)/8
- a\x{240}bcd
+/[\x{ff}]/8DM
-/a(.?)(.)/
- a\xc0\x92bcd
+/[\x{100}]/8DM
-/a(.?)(.)/8
- a\x{240}bcd
+/\x{ffffffff}/8
-/a(.??)(.)/
- a\xc0\x92bcd
+/\x{100000000}/8
-/a(.??)(.)/8
- a\x{240}bcd
+/^\x{100}a\x{1234}/8
+ \x{100}a\x{1234}bcd
-/a(.{3})b/8
- a\x{1234}xyb
- a\x{1234}\x{4321}yb
- a\x{1234}\x{4321}\x{3412}b
- *** Failers
- a\x{1234}b
- ac\ncb
-
-/a(.{3,})b/8
- a\x{1234}xyb
- a\x{1234}\x{4321}yb
- a\x{1234}\x{4321}\x{3412}b
- axxxxbcdefghijb
- a\x{1234}\x{4321}\x{3412}\x{3421}b
- *** Failers
- a\x{1234}b
-
-/a(.{3,}?)b/8
- a\x{1234}xyb
- a\x{1234}\x{4321}yb
- a\x{1234}\x{4321}\x{3412}b
- axxxxbcdefghijb
- a\x{1234}\x{4321}\x{3412}\x{3421}b
- *** Failers
- a\x{1234}b
-
-/a(.{3,5})b/8
- a\x{1234}xyb
- a\x{1234}\x{4321}yb
- a\x{1234}\x{4321}\x{3412}b
- axxxxbcdefghijb
- a\x{1234}\x{4321}\x{3412}\x{3421}b
- axbxxbcdefghijb
- axxxxxbcdefghijb
- *** Failers
- a\x{1234}b
- axxxxxxbcdefghijb
-
-/a(.{3,5}?)b/8
- a\x{1234}xyb
- a\x{1234}\x{4321}yb
- a\x{1234}\x{4321}\x{3412}b
- axxxxbcdefghijb
- a\x{1234}\x{4321}\x{3412}\x{3421}b
- axbxxbcdefghijb
- axxxxxbcdefghijb
- *** Failers
- a\x{1234}b
- axxxxxxbcdefghijb
+/\x80/8D
+
+/\xff/8D
+
+/\x{0041}\x{2262}\x{0391}\x{002e}/D8
+ \x{0041}\x{2262}\x{0391}\x{002e}
+
+/\x{D55c}\x{ad6d}\x{C5B4}/D8
+ \x{D55c}\x{ad6d}\x{C5B4}
+
+/\x{65e5}\x{672c}\x{8a9e}/D8
+ \x{65e5}\x{672c}\x{8a9e}
+
+/\x{80}/D8
+
+/\x{084}/D8
+
+/\x{104}/D8
+
+/\x{861}/D8
-/^[a\x{c0}]/8
+/\x{212ab}/D8
+
+/.{3,5}X/D8
+ \x{212ab}\x{212ab}\x{212ab}\x{861}X
+
+
+/.{3,5}?/D8
+ \x{212ab}\x{212ab}\x{212ab}\x{861}
+
+/-- These tests are here rather than in testinput4 because Perl 5.6 has --/
+/-- some problems with UTF-8 support, in the area of \x{..} where the --/
+/-- value is < 255. It grumbles about invalid UTF-8 strings. --/
+
+/^[a\x{c0}]b/8
+ \x{c0}b
+
+/^([a\x{c0}]*?)aa/8
+ a\x{c0}aaaa/
+
+/^([a\x{c0}]*?)aa/8
+ a\x{c0}aaaa/
+ a\x{c0}a\x{c0}aaa/
+
+/^([a\x{c0}]*)aa/8
+ a\x{c0}aaaa/
+ a\x{c0}a\x{c0}aaa/
+
+/^([a\x{c0}]*)a\x{c0}/8
+ a\x{c0}aaaa/
+ a\x{c0}a\x{c0}aaa/
+
+/-- --/
+
+/(?<=\C)X/8
+ Should produce an error diagnostic
+
+/-- This one is here not because it's different to Perl, but because the --/
+/-- way the captured single-byte is displayed. (In Perl it becomes a --/
+/-- character, and you can't tell the difference.) --/
+
+/X(\C)(.*)/8
+ X\x{1234}
+ X\nabc
+
+/^[ab]/8D
+ bar
*** Failers
+ c
+ \x{ff}
+ \x{100}
+
+/^[^ab]/8D
+ c
+ \x{ff}
+ \x{100}
+ *** Failers
+ aaa
+
+/[^ab\xC0-\xF0]/8SD
+ \x{f1}
+ \x{bf}
\x{100}
+ \x{1000}
+ *** Failers
+ \x{c0}
+ \x{f0}
-/(?<=aXb)cd/8
- aXbcd
+/Ä€{3,4}/8SD
+ \x{100}\x{100}\x{100}\x{100\x{100}
-/(?<=a\x{100}b)cd/8
- a\x{100}bcd
+/(\x{100}+|x)/8SD
-/(?<=a\x{100000}b)cd/8
- a\x{100000}bcd
-
-/(?:\x{100}){3}b/8
- \x{100}\x{100}\x{100}b
+/(\x{100}*a|x)/8SD
+
+/(\x{100}{0,2}a|x)/8SD
+
+/(\x{100}{1,2}a|x)/8SD
+
+/\x{100}*(\d+|"(?1)")/8
+ 1234
+ "1234"
+ \x{100}1234
+ "\x{100}1234"
+ \x{100}\x{100}12ab
+ \x{100}\x{100}"12"
*** Failers
- \x{100}\x{100}b
+ \x{100}\x{100}abcd
+
+/\x{100}/8D
+
+/\x{100}*/8D
+
+/a\x{100}*/8D
+
+/ab\x{100}*/8D
+
+/a\x{100}\x{101}*/8D
+
+/a\x{100}\x{101}+/8D
+
+/\x{100}*A/8D
+ A
+
+/\x{100}*\d(?R)/8D
+
+/[^\x{c4}]/D
+
+/[^\x{c4}]/8D
+
+/[\x{100}]/8DM
+ \x{100}
+ Z\x{100}
+ \x{100}Z
+ *** Failers
+
+/[Z\x{100}]/8DM
+ Z\x{100}
+ \x{100}
+ \x{100}Z
+ *** Failers
+
+/[\x{200}-\x{100}]/8
+
+/[Ä€-Ä„]/8
+ \x{100}
+ \x{104}
+ *** Failers
+ \x{105}
+ \x{ff}
+
+/[z-\x{100}]/8D
+
+/[z-\x{100}]/8Di
+
+/[z\Qa-d]Ä€\E]/8D
+ \x{100}
+ Ā
/ End of testinput5 /
diff --git a/testdata/testinput6 b/testdata/testinput6
deleted file mode 100644
index 0074851..0000000
--- a/testdata/testinput6
+++ /dev/null
@@ -1,78 +0,0 @@
-/\x{100}/8DM
-
-/\x{1000}/8DM
-
-/\x{10000}/8DM
-
-/\x{100000}/8DM
-
-/\x{1000000}/8DM
-
-/\x{4000000}/8DM
-
-/\x{7fffFFFF}/8DM
-
-/[\x{ff}]/8DM
-
-/[\x{100}]/8DM
-
-/\x{ffffffff}/8
-
-/\x{100000000}/8
-
-/^\x{100}a\x{1234}/8
- \x{100}a\x{1234}bcd
-
-/\x80/8D
-
-/\xff/8D
-
-/\x{0041}\x{2262}\x{0391}\x{002e}/D8
- \x{0041}\x{2262}\x{0391}\x{002e}
-
-/\x{D55c}\x{ad6d}\x{C5B4}/D8
- \x{D55c}\x{ad6d}\x{C5B4}
-
-/\x{65e5}\x{672c}\x{8a9e}/D8
- \x{65e5}\x{672c}\x{8a9e}
-
-/\x{80}/D8
-
-/\x{084}/D8
-
-/\x{104}/D8
-
-/\x{861}/D8
-
-/\x{212ab}/D8
-
-/.{3,5}X/D8
- \x{212ab}\x{212ab}\x{212ab}\x{861}X
-
-
-/.{3,5}?/D8
- \x{212ab}\x{212ab}\x{212ab}\x{861}
-
-/-- These tests are here rather than in testinput5 because Perl 5.6 has --/
-/-- some problems with UTF-8 support, in the area of \x{..} where the --/
-/-- value is < 255. It grumbles about invalid UTF-8 strings. --/
-
-/^[a\x{c0}]b/8
- \x{c0}b
-
-/^([a\x{c0}]*?)aa/8
- a\x{c0}aaaa/
-
-/^([a\x{c0}]*?)aa/8
- a\x{c0}aaaa/
- a\x{c0}a\x{c0}aaa/
-
-/^([a\x{c0}]*)aa/8
- a\x{c0}aaaa/
- a\x{c0}a\x{c0}aaa/
-
-/^([a\x{c0}]*)a\x{c0}/8
- a\x{c0}aaaa/
- a\x{c0}a\x{c0}aaa/
-
-/ End of testinput6 /
diff --git a/testdata/testoutput1 b/testdata/testoutput1
index f0047ff..a01bb93 100644
--- a/testdata/testoutput1
+++ b/testdata/testoutput1
@@ -1,4 +1,4 @@
-PCRE version 3.9 02-Jan-2002
+PCRE version 4.0 17-Feb-2003
/the quick brown fox/
the quick brown fox
@@ -1941,7 +1941,7 @@ No match
/^[W-c]+$/
WXY_^abc
0: WXY_^abc
- ***Failers
+ *** Failers
No match
wxy
No match
@@ -2224,7 +2224,7 @@ No match
0: abc\x01de
1: abc
-/a.b(?s)/
+/(?s)a.b/
a\nb
0: a\x0ab
@@ -3014,5 +3014,3234 @@ No match
0: ABABAB
1: AB
+/(?<!bar)foo/
+ foo
+ 0: foo
+ catfood
+ 0: foo
+ arfootle
+ 0: foo
+ rfoosh
+ 0: foo
+ *** Failers
+No match
+ barfoo
+No match
+ towbarfoo
+No match
+
+/\w{3}(?<!bar)foo/
+ catfood
+ 0: catfoo
+ *** Failers
+No match
+ foo
+No match
+ barfoo
+No match
+ towbarfoo
+No match
+
+/(?<=(foo)a)bar/
+ fooabar
+ 0: bar
+ 1: foo
+ *** Failers
+No match
+ bar
+No match
+ foobbar
+No match
+
+/\Aabc\z/m
+ abc
+ 0: abc
+ *** Failers
+No match
+ abc\n
+No match
+ qqq\nabc
+No match
+ abc\nzzz
+No match
+ qqq\nabc\nzzz
+No match
+
+"(?>.*/)foo"
+ /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
+No match
+
+"(?>.*/)foo"
+ /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
+ 0: /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
+
+/(?>(\.\d\d[1-9]?))\d+/
+ 1.230003938
+ 0: .230003938
+ 1: .23
+ 1.875000282
+ 0: .875000282
+ 1: .875
+ *** Failers
+No match
+ 1.235
+No match
+
+/^((?>\w+)|(?>\s+))*$/
+ now is the time for all good men to come to the aid of the party
+ 0: now is the time for all good men to come to the aid of the party
+ 1: party
+ *** Failers
+No match
+ this is not a line with only words and spaces!
+No match
+
+/(\d+)(\w)/
+ 12345a
+ 0: 12345a
+ 1: 12345
+ 2: a
+ 12345+
+ 0: 12345
+ 1: 1234
+ 2: 5
+
+/((?>\d+))(\w)/
+ 12345a
+ 0: 12345a
+ 1: 12345
+ 2: a
+ *** Failers
+No match
+ 12345+
+No match
+
+/(?>a+)b/
+ aaab
+ 0: aaab
+
+/((?>a+)b)/
+ aaab
+ 0: aaab
+ 1: aaab
+
+/(?>(a+))b/
+ aaab
+ 0: aaab
+ 1: aaa
+
+/(?>b)+/
+ aaabbbccc
+ 0: bbb
+
+/(?>a+|b+|c+)*c/
+ aaabbbbccccd
+ 0: aaabbbbc
+
+/((?>[^()]+)|\([^()]*\))+/
+ ((abc(ade)ufh()()x
+ 0: abc(ade)ufh()()x
+ 1: x
+
+/\(((?>[^()]+)|\([^()]+\))+\)/
+ (abc)
+ 0: (abc)
+ 1: abc
+ (abc(def)xyz)
+ 0: (abc(def)xyz)
+ 1: xyz
+ *** Failers
+No match
+ ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+
+/a(?-i)b/i
+ ab
+ 0: ab
+ Ab
+ 0: Ab
+ *** Failers
+No match
+ aB
+No match
+ AB
+No match
+
+/(a (?x)b c)d e/
+ a bcd e
+ 0: a bcd e
+ 1: a bc
+ *** Failers
+No match
+ a b cd e
+No match
+ abcd e
+No match
+ a bcde
+No match
+
+/(a b(?x)c d (?-x)e f)/
+ a bcde f
+ 0: a bcde f
+ 1: a bcde f
+ *** Failers
+No match
+ abcdef
+No match
+
+/(a(?i)b)c/
+ abc
+ 0: abc
+ 1: ab
+ aBc
+ 0: aBc
+ 1: aB
+ *** Failers
+No match
+ abC
+No match
+ aBC
+No match
+ Abc
+No match
+ ABc
+No match
+ ABC
+No match
+ AbC
+No match
+
+/a(?i:b)c/
+ abc
+ 0: abc
+ aBc
+ 0: aBc
+ *** Failers
+No match
+ ABC
+No match
+ abC
+No match
+ aBC
+No match
+
+/a(?i:b)*c/
+ aBc
+ 0: aBc
+ aBBc
+ 0: aBBc
+ *** Failers
+No match
+ aBC
+No match
+ aBBC
+No match
+
+/a(?=b(?i)c)\w\wd/
+ abcd
+ 0: abcd
+ abCd
+ 0: abCd
+ *** Failers
+No match
+ aBCd
+No match
+ abcD
+No match
+
+/(?s-i:more.*than).*million/i
+ more than million
+ 0: more than million
+ more than MILLION
+ 0: more than MILLION
+ more \n than Million
+ 0: more \x0a than Million
+ *** Failers
+No match
+ MORE THAN MILLION
+No match
+ more \n than \n million
+No match
+
+/(?:(?s-i)more.*than).*million/i
+ more than million
+ 0: more than million
+ more than MILLION
+ 0: more than MILLION
+ more \n than Million
+ 0: more \x0a than Million
+ *** Failers
+No match
+ MORE THAN MILLION
+No match
+ more \n than \n million
+No match
+
+/(?>a(?i)b+)+c/
+ abc
+ 0: abc
+ aBbc
+ 0: aBbc
+ aBBc
+ 0: aBBc
+ *** Failers
+No match
+ Abc
+No match
+ abAb
+No match
+ abbC
+No match
+
+/(?=a(?i)b)\w\wc/
+ abc
+ 0: abc
+ aBc
+ 0: aBc
+ *** Failers
+No match
+ Ab
+No match
+ abC
+No match
+ aBC
+No match
+
+/(?<=a(?i)b)(\w\w)c/
+ abxxc
+ 0: xxc
+ 1: xx
+ aBxxc
+ 0: xxc
+ 1: xx
+ *** Failers
+No match
+ Abxxc
+No match
+ ABxxc
+No match
+ abxxC
+No match
+
+/(?:(a)|b)(?(1)A|B)/
+ aA
+ 0: aA
+ 1: a
+ bB
+ 0: bB
+ *** Failers
+No match
+ aB
+No match
+ bA
+No match
+
+/^(a)?(?(1)a|b)+$/
+ aa
+ 0: aa
+ 1: a
+ b
+ 0: b
+ bb
+ 0: bb
+ *** Failers
+No match
+ ab
+No match
+
+/^(?(?=abc)\w{3}:|\d\d)$/
+ abc:
+ 0: abc:
+ 12
+ 0: 12
+ *** Failers
+No match
+ 123
+No match
+ xyz
+No match
+
+/^(?(?!abc)\d\d|\w{3}:)$/
+ abc:
+ 0: abc:
+ 12
+ 0: 12
+ *** Failers
+No match
+ 123
+No match
+ xyz
+No match
+
+/(?(?<=foo)bar|cat)/
+ foobar
+ 0: bar
+ cat
+ 0: cat
+ fcat
+ 0: cat
+ focat
+ 0: cat
+ *** Failers
+No match
+ foocat
+No match
+
+/(?(?<!foo)cat|bar)/
+ foobar
+ 0: bar
+ cat
+ 0: cat
+ fcat
+ 0: cat
+ focat
+ 0: cat
+ *** Failers
+No match
+ foocat
+No match
+
+/( \( )? [^()]+ (?(1) \) |) /x
+ abcd
+ 0: abcd
+ (abcd)
+ 0: (abcd)
+ 1: (
+ the quick (abcd) fox
+ 0: the quick
+ (abcd
+ 0: abcd
+
+/( \( )? [^()]+ (?(1) \) ) /x
+ abcd
+ 0: abcd
+ (abcd)
+ 0: (abcd)
+ 1: (
+ the quick (abcd) fox
+ 0: the quick
+ (abcd
+ 0: abcd
+
+/^(?(2)a|(1)(2))+$/
+ 12
+ 0: 12
+ 1: 1
+ 2: 2
+ 12a
+ 0: 12a
+ 1: 1
+ 2: 2
+ 12aa
+ 0: 12aa
+ 1: 1
+ 2: 2
+ *** Failers
+No match
+ 1234
+No match
+
+/((?i)blah)\s+\1/
+ blah blah
+ 0: blah blah
+ 1: blah
+ BLAH BLAH
+ 0: BLAH BLAH
+ 1: BLAH
+ Blah Blah
+ 0: Blah Blah
+ 1: Blah
+ blaH blaH
+ 0: blaH blaH
+ 1: blaH
+ *** Failers
+No match
+ blah BLAH
+No match
+ Blah blah
+No match
+ blaH blah
+No match
+
+/((?i)blah)\s+(?i:\1)/
+ blah blah
+ 0: blah blah
+ 1: blah
+ BLAH BLAH
+ 0: BLAH BLAH
+ 1: BLAH
+ Blah Blah
+ 0: Blah Blah
+ 1: Blah
+ blaH blaH
+ 0: blaH blaH
+ 1: blaH
+ blah BLAH
+ 0: blah BLAH
+ 1: blah
+ Blah blah
+ 0: Blah blah
+ 1: Blah
+ blaH blah
+ 0: blaH blah
+ 1: blaH
+
+/(?>a*)*/
+ a
+ 0: a
+ aa
+ 0: aa
+ aaaa
+ 0: aaaa
+
+/(abc|)+/
+ abc
+ 0: abc
+ 1:
+ abcabc
+ 0: abcabc
+ 1:
+ abcabcabc
+ 0: abcabcabc
+ 1:
+ xyz
+ 0:
+ 1:
+
+/([a]*)*/
+ a
+ 0: a
+ 1:
+ aaaaa
+ 0: aaaaa
+ 1:
+
+/([ab]*)*/
+ a
+ 0: a
+ 1:
+ b
+ 0: b
+ 1:
+ ababab
+ 0: ababab
+ 1:
+ aaaabcde
+ 0: aaaab
+ 1:
+ bbbb
+ 0: bbbb
+ 1:
+
+/([^a]*)*/
+ b
+ 0: b
+ 1:
+ bbbb
+ 0: bbbb
+ 1:
+ aaa
+ 0:
+ 1:
+
+/([^ab]*)*/
+ cccc
+ 0: cccc
+ 1:
+ abab
+ 0:
+ 1:
+
+/([a]*?)*/
+ a
+ 0:
+ 1:
+ aaaa
+ 0:
+ 1:
+
+/([ab]*?)*/
+ a
+ 0:
+ 1:
+ b
+ 0:
+ 1:
+ abab
+ 0:
+ 1:
+ baba
+ 0:
+ 1:
+
+/([^a]*?)*/
+ b
+ 0:
+ 1:
+ bbbb
+ 0:
+ 1:
+ aaa
+ 0:
+ 1:
+
+/([^ab]*?)*/
+ c
+ 0:
+ 1:
+ cccc
+ 0:
+ 1:
+ baba
+ 0:
+ 1:
+
+/(?>a*)*/
+ a
+ 0: a
+ aaabcde
+ 0: aaa
+
+/((?>a*))*/
+ aaaaa
+ 0: aaaaa
+ 1:
+ aabbaa
+ 0: aa
+ 1:
+
+/((?>a*?))*/
+ aaaaa
+ 0:
+ 1:
+ aabbaa
+ 0:
+ 1:
+
+/(?(?=[^a-z]+[a-z]) \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} ) /x
+ 12-sep-98
+ 0: 12-sep-98
+ 12-09-98
+ 0: 12-09-98
+ *** Failers
+No match
+ sep-12-98
+No match
+
+/(?<=(foo))bar\1/
+ foobarfoo
+ 0: barfoo
+ 1: foo
+ foobarfootling
+ 0: barfoo
+ 1: foo
+ *** Failers
+No match
+ foobar
+No match
+ barfoo
+No match
+
+/(?i:saturday|sunday)/
+ saturday
+ 0: saturday
+ sunday
+ 0: sunday
+ Saturday
+ 0: Saturday
+ Sunday
+ 0: Sunday
+ SATURDAY
+ 0: SATURDAY
+ SUNDAY
+ 0: SUNDAY
+ SunDay
+ 0: SunDay
+
+/(a(?i)bc|BB)x/
+ abcx
+ 0: abcx
+ 1: abc
+ aBCx
+ 0: aBCx
+ 1: aBC
+ bbx
+ 0: bbx
+ 1: bb
+ BBx
+ 0: BBx
+ 1: BB
+ *** Failers
+No match
+ abcX
+No match
+ aBCX
+No match
+ bbX
+No match
+ BBX
+No match
+
+/^([ab](?i)[cd]|[ef])/
+ ac
+ 0: ac
+ 1: ac
+ aC
+ 0: aC
+ 1: aC
+ bD
+ 0: bD
+ 1: bD
+ elephant
+ 0: e
+ 1: e
+ Europe
+ 0: E
+ 1: E
+ frog
+ 0: f
+ 1: f
+ France
+ 0: F
+ 1: F
+ *** Failers
+No match
+ Africa
+No match
+
+/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
+ ab
+ 0: ab
+ 1: ab
+ aBd
+ 0: aBd
+ 1: aBd
+ xy
+ 0: xy
+ 1: xy
+ xY
+ 0: xY
+ 1: xY
+ zebra
+ 0: z
+ 1: z
+ Zambesi
+ 0: Z
+ 1: Z
+ *** Failers
+No match
+ aCD
+No match
+ XY
+No match
+
+/(?<=foo\n)^bar/m
+ foo\nbar
+ 0: bar
+ *** Failers
+No match
+ bar
+No match
+ baz\nbar
+No match
+
+/(?<=(?<!foo)bar)baz/
+ barbaz
+ 0: baz
+ barbarbaz
+ 0: baz
+ koobarbaz
+ 0: baz
+ *** Failers
+No match
+ baz
+No match
+ foobarbaz
+No match
+
+/The case of aaaaaa is missed out below because I think Perl 5.005_02 gets/
+/it wrong; it sets $1 to aaa rather than aa. Compare the following test,/
+No match
+/where it does set $1 to aa when matching aaaaaa./
+No match
+
+/^(a\1?){4}$/
+ a
+No match
+ aa
+No match
+ aaa
+No match
+ aaaa
+ 0: aaaa
+ 1: a
+ aaaaa
+ 0: aaaaa
+ 1: a
+ aaaaaaa
+ 0: aaaaaaa
+ 1: a
+ aaaaaaaa
+No match
+ aaaaaaaaa
+No match
+ aaaaaaaaaa
+ 0: aaaaaaaaaa
+ 1: aaaa
+ aaaaaaaaaaa
+No match
+ aaaaaaaaaaaa
+No match
+ aaaaaaaaaaaaa
+No match
+ aaaaaaaaaaaaaa
+No match
+ aaaaaaaaaaaaaaa
+No match
+ aaaaaaaaaaaaaaaa
+No match
+
+/^(a\1?)(a\1?)(a\2?)(a\3?)$/
+ a
+No match
+ aa
+No match
+ aaa
+No match
+ aaaa
+ 0: aaaa
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ aaaaa
+ 0: aaaaa
+ 1: a
+ 2: aa
+ 3: a
+ 4: a
+ aaaaaa
+ 0: aaaaaa
+ 1: a
+ 2: aa
+ 3: a
+ 4: aa
+ aaaaaaa
+ 0: aaaaaaa
+ 1: a
+ 2: aa
+ 3: aaa
+ 4: a
+ aaaaaaaa
+No match
+ aaaaaaaaa
+No match
+ aaaaaaaaaa
+ 0: aaaaaaaaaa
+ 1: a
+ 2: aa
+ 3: aaa
+ 4: aaaa
+ aaaaaaaaaaa
+No match
+ aaaaaaaaaaaa
+No match
+ aaaaaaaaaaaaa
+No match
+ aaaaaaaaaaaaaa
+No match
+ aaaaaaaaaaaaaaa
+No match
+ aaaaaaaaaaaaaaaa
+No match
+
+/The following tests are taken from the Perl 5.005 test suite; some of them/
+/are compatible with 5.004, but I'd rather not have to sort them out./
+No match
+
+/abc/
+ abc
+ 0: abc
+ xabcy
+ 0: abc
+ ababc
+ 0: abc
+ *** Failers
+No match
+ xbc
+No match
+ axc
+No match
+ abx
+No match
+
+/ab*c/
+ abc
+ 0: abc
+
+/ab*bc/
+ abc
+ 0: abc
+ abbc
+ 0: abbc
+ abbbbc
+ 0: abbbbc
+
+/.{1}/
+ abbbbc
+ 0: a
+
+/.{3,4}/
+ abbbbc
+ 0: abbb
+
+/ab{0,}bc/
+ abbbbc
+ 0: abbbbc
+
+/ab+bc/
+ abbc
+ 0: abbc
+ *** Failers
+No match
+ abc
+No match
+ abq
+No match
+
+/ab{1,}bc/
+
+/ab+bc/
+ abbbbc
+ 0: abbbbc
+
+/ab{1,}bc/
+ abbbbc
+ 0: abbbbc
+
+/ab{1,3}bc/
+ abbbbc
+ 0: abbbbc
+
+/ab{3,4}bc/
+ abbbbc
+ 0: abbbbc
+
+/ab{4,5}bc/
+ *** Failers
+No match
+ abq
+No match
+ abbbbc
+No match
+
+/ab?bc/
+ abbc
+ 0: abbc
+ abc
+ 0: abc
+
+/ab{0,1}bc/
+ abc
+ 0: abc
+
+/ab?bc/
+
+/ab?c/
+ abc
+ 0: abc
+
+/ab{0,1}c/
+ abc
+ 0: abc
+
+/^abc$/
+ abc
+ 0: abc
+ *** Failers
+No match
+ abbbbc
+No match
+ abcc
+No match
+
+/^abc/
+ abcc
+ 0: abc
+
+/^abc$/
+
+/abc$/
+ aabc
+ 0: abc
+ *** Failers
+No match
+ aabc
+ 0: abc
+ aabcd
+No match
+
+/^/
+ abc
+ 0:
+
+/$/
+ abc
+ 0:
+
+/a.c/
+ abc
+ 0: abc
+ axc
+ 0: axc
+
+/a.*c/
+ axyzc
+ 0: axyzc
+
+/a[bc]d/
+ abd
+ 0: abd
+ *** Failers
+No match
+ axyzd
+No match
+ abc
+No match
+
+/a[b-d]e/
+ ace
+ 0: ace
+
+/a[b-d]/
+ aac
+ 0: ac
+
+/a[-b]/
+ a-
+ 0: a-
+
+/a[b-]/
+ a-
+ 0: a-
+
+/a]/
+ a]
+ 0: a]
+
+/a[]]b/
+ a]b
+ 0: a]b
+
+/a[^bc]d/
+ aed
+ 0: aed
+ *** Failers
+No match
+ abd
+No match
+ abd
+No match
+
+/a[^-b]c/
+ adc
+ 0: adc
+
+/a[^]b]c/
+ adc
+ 0: adc
+ *** Failers
+No match
+ a-c
+ 0: a-c
+ a]c
+No match
+
+/\ba\b/
+ a-
+ 0: a
+ -a
+ 0: a
+ -a-
+ 0: a
+
+/\by\b/
+ *** Failers
+No match
+ xy
+No match
+ yz
+No match
+ xyz
+No match
+
+/\Ba\B/
+ *** Failers
+ 0: a
+ a-
+No match
+ -a
+No match
+ -a-
+No match
+
+/\By\b/
+ xy
+ 0: y
+
+/\by\B/
+ yz
+ 0: y
+
+/\By\B/
+ xyz
+ 0: y
+
+/\w/
+ a
+ 0: a
+
+/\W/
+ -
+ 0: -
+ *** Failers
+ 0: *
+ -
+ 0: -
+ a
+No match
+
+/a\sb/
+ a b
+ 0: a b
+
+/a\Sb/
+ a-b
+ 0: a-b
+ *** Failers
+No match
+ a-b
+ 0: a-b
+ a b
+No match
+
+/\d/
+ 1
+ 0: 1
+
+/\D/
+ -
+ 0: -
+ *** Failers
+ 0: *
+ -
+ 0: -
+ 1
+No match
+
+/[\w]/
+ a
+ 0: a
+
+/[\W]/
+ -
+ 0: -
+ *** Failers
+ 0: *
+ -
+ 0: -
+ a
+No match
+
+/a[\s]b/
+ a b
+ 0: a b
+
+/a[\S]b/
+ a-b
+ 0: a-b
+ *** Failers
+No match
+ a-b
+ 0: a-b
+ a b
+No match
+
+/[\d]/
+ 1
+ 0: 1
+
+/[\D]/
+ -
+ 0: -
+ *** Failers
+ 0: *
+ -
+ 0: -
+ 1
+No match
+
+/ab|cd/
+ abc
+ 0: ab
+ abcd
+ 0: ab
+
+/()ef/
+ def
+ 0: ef
+ 1:
+
+/$b/
+
+/a\(b/
+ a(b
+ 0: a(b
+
+/a\(*b/
+ ab
+ 0: ab
+ a((b
+ 0: a((b
+
+/a\\b/
+ a\b
+No match
+
+/((a))/
+ abc
+ 0: a
+ 1: a
+ 2: a
+
+/(a)b(c)/
+ abc
+ 0: abc
+ 1: a
+ 2: c
+
+/a+b+c/
+ aabbabc
+ 0: abc
+
+/a{1,}b{1,}c/
+ aabbabc
+ 0: abc
+
+/a.+?c/
+ abcabc
+ 0: abc
+
+/(a+|b)*/
+ ab
+ 0: ab
+ 1: b
+
+/(a+|b){0,}/
+ ab
+ 0: ab
+ 1: b
+
+/(a+|b)+/
+ ab
+ 0: ab
+ 1: b
+
+/(a+|b){1,}/
+ ab
+ 0: ab
+ 1: b
+
+/(a+|b)?/
+ ab
+ 0: a
+ 1: a
+
+/(a+|b){0,1}/
+ ab
+ 0: a
+ 1: a
+
+/[^ab]*/
+ cde
+ 0: cde
+
+/abc/
+ *** Failers
+No match
+ b
+No match
+
+
+/a*/
+
+
+/([abc])*d/
+ abbbcd
+ 0: abbbcd
+ 1: c
+
+/([abc])*bcd/
+ abcd
+ 0: abcd
+ 1: a
+
+/a|b|c|d|e/
+ e
+ 0: e
+
+/(a|b|c|d|e)f/
+ ef
+ 0: ef
+ 1: e
+
+/abcd*efg/
+ abcdefg
+ 0: abcdefg
+
+/ab*/
+ xabyabbbz
+ 0: ab
+ xayabbbz
+ 0: a
+
+/(ab|cd)e/
+ abcde
+ 0: cde
+ 1: cd
+
+/[abhgefdc]ij/
+ hij
+ 0: hij
+
+/^(ab|cd)e/
+
+/(abc|)ef/
+ abcdef
+ 0: ef
+ 1:
+
+/(a|b)c*d/
+ abcd
+ 0: bcd
+ 1: b
+
+/(ab|ab*)bc/
+ abc
+ 0: abc
+ 1: a
+
+/a([bc]*)c*/
+ abc
+ 0: abc
+ 1: bc
+
+/a([bc]*)(c*d)/
+ abcd
+ 0: abcd
+ 1: bc
+ 2: d
+
+/a([bc]+)(c*d)/
+ abcd
+ 0: abcd
+ 1: bc
+ 2: d
+
+/a([bc]*)(c+d)/
+ abcd
+ 0: abcd
+ 1: b
+ 2: cd
+
+/a[bcd]*dcdcde/
+ adcdcde
+ 0: adcdcde
+
+/a[bcd]+dcdcde/
+ *** Failers
+No match
+ abcde
+No match
+ adcdcde
+No match
+
+/(ab|a)b*c/
+ abc
+ 0: abc
+ 1: ab
+
+/((a)(b)c)(d)/
+ abcd
+ 0: abcd
+ 1: abc
+ 2: a
+ 3: b
+ 4: d
+
+/[a-zA-Z_][a-zA-Z0-9_]*/
+ alpha
+ 0: alpha
+
+/^a(bc+|b[eh])g|.h$/
+ abh
+ 0: bh
+
+/(bc+d$|ef*g.|h?i(j|k))/
+ effgz
+ 0: effgz
+ 1: effgz
+ ij
+ 0: ij
+ 1: ij
+ 2: j
+ reffgz
+ 0: effgz
+ 1: effgz
+ *** Failers
+No match
+ effg
+No match
+ bcdd
+No match
+
+/((((((((((a))))))))))/
+ a
+ 0: a
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+10: a
+
+/((((((((((a))))))))))\10/
+ aa
+ 0: aa
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+10: a
+
+/(((((((((a)))))))))/
+ a
+ 0: a
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+
+/multiple words of text/
+ *** Failers
+No match
+ aa
+No match
+ uh-uh
+No match
+
+/multiple words/
+ multiple words, yeah
+ 0: multiple words
+
+/(.*)c(.*)/
+ abcde
+ 0: abcde
+ 1: ab
+ 2: de
+
+/\((.*), (.*)\)/
+ (a, b)
+ 0: (a, b)
+ 1: a
+ 2: b
+
+/[k]/
+
+/abcd/
+ abcd
+ 0: abcd
+
+/a(bc)d/
+ abcd
+ 0: abcd
+ 1: bc
+
+/a[-]?c/
+ ac
+ 0: ac
+
+/(abc)\1/
+ abcabc
+ 0: abcabc
+ 1: abc
+
+/([a-c]*)\1/
+ abcabc
+ 0: abcabc
+ 1: abc
+
+/(a)|\1/
+ a
+ 0: a
+ 1: a
+ *** Failers
+ 0: a
+ 1: a
+ ab
+ 0: a
+ 1: a
+ x
+No match
+
+/(([a-c])b*?\2)*/
+ ababbbcbc
+ 0: ababb
+ 1: bb
+ 2: b
+
+/(([a-c])b*?\2){3}/
+ ababbbcbc
+ 0: ababbbcbc
+ 1: cbc
+ 2: c
+
+/((\3|b)\2(a)x)+/
+ aaaxabaxbaaxbbax
+ 0: bbax
+ 1: bbax
+ 2: b
+ 3: a
+
+/((\3|b)\2(a)){2,}/
+ bbaababbabaaaaabbaaaabba
+ 0: bbaaaabba
+ 1: bba
+ 2: b
+ 3: a
+
+/abc/i
+ ABC
+ 0: ABC
+ XABCY
+ 0: ABC
+ ABABC
+ 0: ABC
+ *** Failers
+No match
+ aaxabxbaxbbx
+No match
+ XBC
+No match
+ AXC
+No match
+ ABX
+No match
+
+/ab*c/i
+ ABC
+ 0: ABC
+
+/ab*bc/i
+ ABC
+ 0: ABC
+ ABBC
+ 0: ABBC
+
+/ab*?bc/i
+ ABBBBC
+ 0: ABBBBC
+
+/ab{0,}?bc/i
+ ABBBBC
+ 0: ABBBBC
+
+/ab+?bc/i
+ ABBC
+ 0: ABBC
+
+/ab+bc/i
+ *** Failers
+No match
+ ABC
+No match
+ ABQ
+No match
+
+/ab{1,}bc/i
+
+/ab+bc/i
+ ABBBBC
+ 0: ABBBBC
+
+/ab{1,}?bc/i
+ ABBBBC
+ 0: ABBBBC
+
+/ab{1,3}?bc/i
+ ABBBBC
+ 0: ABBBBC
+
+/ab{3,4}?bc/i
+ ABBBBC
+ 0: ABBBBC
+
+/ab{4,5}?bc/i
+ *** Failers
+No match
+ ABQ
+No match
+ ABBBBC
+No match
+
+/ab??bc/i
+ ABBC
+ 0: ABBC
+ ABC
+ 0: ABC
+
+/ab{0,1}?bc/i
+ ABC
+ 0: ABC
+
+/ab??bc/i
+
+/ab??c/i
+ ABC
+ 0: ABC
+
+/ab{0,1}?c/i
+ ABC
+ 0: ABC
+
+/^abc$/i
+ ABC
+ 0: ABC
+ *** Failers
+No match
+ ABBBBC
+No match
+ ABCC
+No match
+
+/^abc/i
+ ABCC
+ 0: ABC
+
+/^abc$/i
+
+/abc$/i
+ AABC
+ 0: ABC
+
+/^/i
+ ABC
+ 0:
+
+/$/i
+ ABC
+ 0:
+
+/a.c/i
+ ABC
+ 0: ABC
+ AXC
+ 0: AXC
+
+/a.*?c/i
+ AXYZC
+ 0: AXYZC
+
+/a.*c/i
+ *** Failers
+No match
+ AABC
+ 0: AABC
+ AXYZD
+No match
+
+/a[bc]d/i
+ ABD
+ 0: ABD
+
+/a[b-d]e/i
+ ACE
+ 0: ACE
+ *** Failers
+No match
+ ABC
+No match
+ ABD
+No match
+
+/a[b-d]/i
+ AAC
+ 0: AC
+
+/a[-b]/i
+ A-
+ 0: A-
+
+/a[b-]/i
+ A-
+ 0: A-
+
+/a]/i
+ A]
+ 0: A]
+
+/a[]]b/i
+ A]B
+ 0: A]B
+
+/a[^bc]d/i
+ AED
+ 0: AED
+
+/a[^-b]c/i
+ ADC
+ 0: ADC
+ *** Failers
+No match
+ ABD
+No match
+ A-C
+No match
+
+/a[^]b]c/i
+ ADC
+ 0: ADC
+
+/ab|cd/i
+ ABC
+ 0: AB
+ ABCD
+ 0: AB
+
+/()ef/i
+ DEF
+ 0: EF
+ 1:
+
+/$b/i
+ *** Failers
+No match
+ A]C
+No match
+ B
+No match
+
+/a\(b/i
+ A(B
+ 0: A(B
+
+/a\(*b/i
+ AB
+ 0: AB
+ A((B
+ 0: A((B
+
+/a\\b/i
+ A\B
+No match
+
+/((a))/i
+ ABC
+ 0: A
+ 1: A
+ 2: A
+
+/(a)b(c)/i
+ ABC
+ 0: ABC
+ 1: A
+ 2: C
+
+/a+b+c/i
+ AABBABC
+ 0: ABC
+
+/a{1,}b{1,}c/i
+ AABBABC
+ 0: ABC
+
+/a.+?c/i
+ ABCABC
+ 0: ABC
+
+/a.*?c/i
+ ABCABC
+ 0: ABC
+
+/a.{0,5}?c/i
+ ABCABC
+ 0: ABC
+
+/(a+|b)*/i
+ AB
+ 0: AB
+ 1: B
+
+/(a+|b){0,}/i
+ AB
+ 0: AB
+ 1: B
+
+/(a+|b)+/i
+ AB
+ 0: AB
+ 1: B
+
+/(a+|b){1,}/i
+ AB
+ 0: AB
+ 1: B
+
+/(a+|b)?/i
+ AB
+ 0: A
+ 1: A
+
+/(a+|b){0,1}/i
+ AB
+ 0: A
+ 1: A
+
+/(a+|b){0,1}?/i
+ AB
+ 0:
+
+/[^ab]*/i
+ CDE
+ 0: CDE
+
+/abc/i
+
+/a*/i
+
+
+/([abc])*d/i
+ ABBBCD
+ 0: ABBBCD
+ 1: C
+
+/([abc])*bcd/i
+ ABCD
+ 0: ABCD
+ 1: A
+
+/a|b|c|d|e/i
+ E
+ 0: E
+
+/(a|b|c|d|e)f/i
+ EF
+ 0: EF
+ 1: E
+
+/abcd*efg/i
+ ABCDEFG
+ 0: ABCDEFG
+
+/ab*/i
+ XABYABBBZ
+ 0: AB
+ XAYABBBZ
+ 0: A
+
+/(ab|cd)e/i
+ ABCDE
+ 0: CDE
+ 1: CD
+
+/[abhgefdc]ij/i
+ HIJ
+ 0: HIJ
+
+/^(ab|cd)e/i
+ ABCDE
+No match
+
+/(abc|)ef/i
+ ABCDEF
+ 0: EF
+ 1:
+
+/(a|b)c*d/i
+ ABCD
+ 0: BCD
+ 1: B
+
+/(ab|ab*)bc/i
+ ABC
+ 0: ABC
+ 1: A
+
+/a([bc]*)c*/i
+ ABC
+ 0: ABC
+ 1: BC
+
+/a([bc]*)(c*d)/i
+ ABCD
+ 0: ABCD
+ 1: BC
+ 2: D
+
+/a([bc]+)(c*d)/i
+ ABCD
+ 0: ABCD
+ 1: BC
+ 2: D
+
+/a([bc]*)(c+d)/i
+ ABCD
+ 0: ABCD
+ 1: B
+ 2: CD
+
+/a[bcd]*dcdcde/i
+ ADCDCDE
+ 0: ADCDCDE
+
+/a[bcd]+dcdcde/i
+
+/(ab|a)b*c/i
+ ABC
+ 0: ABC
+ 1: AB
+
+/((a)(b)c)(d)/i
+ ABCD
+ 0: ABCD
+ 1: ABC
+ 2: A
+ 3: B
+ 4: D
+
+/[a-zA-Z_][a-zA-Z0-9_]*/i
+ ALPHA
+ 0: ALPHA
+
+/^a(bc+|b[eh])g|.h$/i
+ ABH
+ 0: BH
+
+/(bc+d$|ef*g.|h?i(j|k))/i
+ EFFGZ
+ 0: EFFGZ
+ 1: EFFGZ
+ IJ
+ 0: IJ
+ 1: IJ
+ 2: J
+ REFFGZ
+ 0: EFFGZ
+ 1: EFFGZ
+ *** Failers
+No match
+ ADCDCDE
+No match
+ EFFG
+No match
+ BCDD
+No match
+
+/((((((((((a))))))))))/i
+ A
+ 0: A
+ 1: A
+ 2: A
+ 3: A
+ 4: A
+ 5: A
+ 6: A
+ 7: A
+ 8: A
+ 9: A
+10: A
+
+/((((((((((a))))))))))\10/i
+ AA
+ 0: AA
+ 1: A
+ 2: A
+ 3: A
+ 4: A
+ 5: A
+ 6: A
+ 7: A
+ 8: A
+ 9: A
+10: A
+
+/(((((((((a)))))))))/i
+ A
+ 0: A
+ 1: A
+ 2: A
+ 3: A
+ 4: A
+ 5: A
+ 6: A
+ 7: A
+ 8: A
+ 9: A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
+ A
+ 0: A
+ 1: A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
+ C
+ 0: C
+ 1: C
+
+/multiple words of text/i
+ *** Failers
+No match
+ AA
+No match
+ UH-UH
+No match
+
+/multiple words/i
+ MULTIPLE WORDS, YEAH
+ 0: MULTIPLE WORDS
+
+/(.*)c(.*)/i
+ ABCDE
+ 0: ABCDE
+ 1: AB
+ 2: DE
+
+/\((.*), (.*)\)/i
+ (A, B)
+ 0: (A, B)
+ 1: A
+ 2: B
+
+/[k]/i
+
+/abcd/i
+ ABCD
+ 0: ABCD
+
+/a(bc)d/i
+ ABCD
+ 0: ABCD
+ 1: BC
+
+/a[-]?c/i
+ AC
+ 0: AC
+
+/(abc)\1/i
+ ABCABC
+ 0: ABCABC
+ 1: ABC
+
+/([a-c]*)\1/i
+ ABCABC
+ 0: ABCABC
+ 1: ABC
+
+/a(?!b)./
+ abad
+ 0: ad
+
+/a(?=d)./
+ abad
+ 0: ad
+
+/a(?=c|d)./
+ abad
+ 0: ad
+
+/a(?:b|c|d)(.)/
+ ace
+ 0: ace
+ 1: e
+
+/a(?:b|c|d)*(.)/
+ ace
+ 0: ace
+ 1: e
+
+/a(?:b|c|d)+?(.)/
+ ace
+ 0: ace
+ 1: e
+ acdbcdbe
+ 0: acd
+ 1: d
+
+/a(?:b|c|d)+(.)/
+ acdbcdbe
+ 0: acdbcdbe
+ 1: e
+
+/a(?:b|c|d){2}(.)/
+ acdbcdbe
+ 0: acdb
+ 1: b
+
+/a(?:b|c|d){4,5}(.)/
+ acdbcdbe
+ 0: acdbcdb
+ 1: b
+
+/a(?:b|c|d){4,5}?(.)/
+ acdbcdbe
+ 0: acdbcd
+ 1: d
+
+/((foo)|(bar))*/
+ foobar
+ 0: foobar
+ 1: bar
+ 2: foo
+ 3: bar
+
+/a(?:b|c|d){6,7}(.)/
+ acdbcdbe
+ 0: acdbcdbe
+ 1: e
+
+/a(?:b|c|d){6,7}?(.)/
+ acdbcdbe
+ 0: acdbcdbe
+ 1: e
+
+/a(?:b|c|d){5,6}(.)/
+ acdbcdbe
+ 0: acdbcdbe
+ 1: e
+
+/a(?:b|c|d){5,6}?(.)/
+ acdbcdbe
+ 0: acdbcdb
+ 1: b
+
+/a(?:b|c|d){5,7}(.)/
+ acdbcdbe
+ 0: acdbcdbe
+ 1: e
+
+/a(?:b|c|d){5,7}?(.)/
+ acdbcdbe
+ 0: acdbcdb
+ 1: b
+
+/a(?:b|(c|e){1,2}?|d)+?(.)/
+ ace
+ 0: ace
+ 1: c
+ 2: e
+
+/^(.+)?B/
+ AB
+ 0: AB
+ 1: A
+
+/^([^a-z])|(\^)$/
+ .
+ 0: .
+ 1: .
+
+/^[<>]&/
+ <&OUT
+ 0: <&
+
+/^(a\1?){4}$/
+ aaaaaaaaaa
+ 0: aaaaaaaaaa
+ 1: aaaa
+ *** Failers
+No match
+ AB
+No match
+ aaaaaaaaa
+No match
+ aaaaaaaaaaa
+No match
+
+/^(a(?(1)\1)){4}$/
+ aaaaaaaaaa
+ 0: aaaaaaaaaa
+ 1: aaaa
+ *** Failers
+No match
+ aaaaaaaaa
+No match
+ aaaaaaaaaaa
+No match
+
+/(?:(f)(o)(o)|(b)(a)(r))*/
+ foobar
+ 0: foobar
+ 1: f
+ 2: o
+ 3: o
+ 4: b
+ 5: a
+ 6: r
+
+/(?<=a)b/
+ ab
+ 0: b
+ *** Failers
+No match
+ cb
+No match
+ b
+No match
+
+/(?<!c)b/
+ ab
+ 0: b
+ b
+ 0: b
+ b
+ 0: b
+
+/(?:..)*a/
+ aba
+ 0: aba
+
+/(?:..)*?a/
+ aba
+ 0: a
+
+/^(?:b|a(?=(.)))*\1/
+ abc
+ 0: ab
+ 1: b
+
+/^(){3,5}/
+ abc
+ 0:
+ 1:
+
+/^(a+)*ax/
+ aax
+ 0: aax
+ 1: a
+
+/^((a|b)+)*ax/
+ aax
+ 0: aax
+ 1: a
+ 2: a
+
+/^((a|bc)+)*ax/
+ aax
+ 0: aax
+ 1: a
+ 2: a
+
+/(a|x)*ab/
+ cab
+ 0: ab
+
+/(a)*ab/
+ cab
+ 0: ab
+
+/(?:(?i)a)b/
+ ab
+ 0: ab
+
+/((?i)a)b/
+ ab
+ 0: ab
+ 1: a
+
+/(?:(?i)a)b/
+ Ab
+ 0: Ab
+
+/((?i)a)b/
+ Ab
+ 0: Ab
+ 1: A
+
+/(?:(?i)a)b/
+ *** Failers
+No match
+ cb
+No match
+ aB
+No match
+
+/((?i)a)b/
+
+/(?i:a)b/
+ ab
+ 0: ab
+
+/((?i:a))b/
+ ab
+ 0: ab
+ 1: a
+
+/(?i:a)b/
+ Ab
+ 0: Ab
+
+/((?i:a))b/
+ Ab
+ 0: Ab
+ 1: A
+
+/(?i:a)b/
+ *** Failers
+No match
+ aB
+No match
+ aB
+No match
+
+/((?i:a))b/
+
+/(?:(?-i)a)b/i
+ ab
+ 0: ab
+
+/((?-i)a)b/i
+ ab
+ 0: ab
+ 1: a
+
+/(?:(?-i)a)b/i
+ aB
+ 0: aB
+
+/((?-i)a)b/i
+ aB
+ 0: aB
+ 1: a
+
+/(?:(?-i)a)b/i
+ *** Failers
+No match
+ aB
+ 0: aB
+ Ab
+No match
+
+/((?-i)a)b/i
+
+/(?:(?-i)a)b/i
+ aB
+ 0: aB
+
+/((?-i)a)b/i
+ aB
+ 0: aB
+ 1: a
+
+/(?:(?-i)a)b/i
+ *** Failers
+No match
+ Ab
+No match
+ AB
+No match
+
+/((?-i)a)b/i
+
+/(?-i:a)b/i
+ ab
+ 0: ab
+
+/((?-i:a))b/i
+ ab
+ 0: ab
+ 1: a
+
+/(?-i:a)b/i
+ aB
+ 0: aB
+
+/((?-i:a))b/i
+ aB
+ 0: aB
+ 1: a
+
+/(?-i:a)b/i
+ *** Failers
+No match
+ AB
+No match
+ Ab
+No match
+
+/((?-i:a))b/i
+
+/(?-i:a)b/i
+ aB
+ 0: aB
+
+/((?-i:a))b/i
+ aB
+ 0: aB
+ 1: a
+
+/(?-i:a)b/i
+ *** Failers
+No match
+ Ab
+No match
+ AB
+No match
+
+/((?-i:a))b/i
+
+/((?-i:a.))b/i
+ *** Failers
+No match
+ AB
+No match
+ a\nB
+No match
+
+/((?s-i:a.))b/i
+ a\nB
+ 0: a\x0aB
+ 1: a\x0a
+
+/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
+ cabbbb
+ 0: cabbbb
+
+/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
+ caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ 0: caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+/(ab)\d\1/i
+ Ab4ab
+ 0: Ab4ab
+ 1: Ab
+ ab4Ab
+ 0: ab4Ab
+ 1: ab
+
+/foo\w*\d{4}baz/
+ foobar1234baz
+ 0: foobar1234baz
+
+/x(~~)*(?:(?:F)?)?/
+ x~~
+ 0: x~~
+ 1: ~~
+
+/^a(?#xxx){3}c/
+ aaac
+ 0: aaac
+
+/^a (?#xxx) (?#yyy) {3}c/x
+ aaac
+ 0: aaac
+
+/(?<![cd])b/
+ *** Failers
+No match
+ B\nB
+No match
+ dbcb
+No match
+
+/(?<![cd])[ab]/
+ dbaacb
+ 0: a
+
+/(?<!(c|d))b/
+
+/(?<!(c|d))[ab]/
+ dbaacb
+ 0: a
+
+/(?<!cd)[ab]/
+ cdaccb
+ 0: b
+
+/^(?:a?b?)*$/
+ *** Failers
+No match
+ dbcb
+No match
+ a--
+No match
+
+/((?s)^a(.))((?m)^b$)/
+ a\nb\nc\n
+ 0: a\x0ab
+ 1: a\x0a
+ 2: \x0a
+ 3: b
+
+/((?m)^b$)/
+ a\nb\nc\n
+ 0: b
+ 1: b
+
+/(?m)^b/
+ a\nb\n
+ 0: b
+
+/(?m)^(b)/
+ a\nb\n
+ 0: b
+ 1: b
+
+/((?m)^b)/
+ a\nb\n
+ 0: b
+ 1: b
+
+/\n((?m)^b)/
+ a\nb\n
+ 0: \x0ab
+ 1: b
+
+/((?s).)c(?!.)/
+ a\nb\nc\n
+ 0: \x0ac
+ 1: \x0a
+ a\nb\nc\n
+ 0: \x0ac
+ 1: \x0a
+
+/((?s)b.)c(?!.)/
+ a\nb\nc\n
+ 0: b\x0ac
+ 1: b\x0a
+ a\nb\nc\n
+ 0: b\x0ac
+ 1: b\x0a
+
+/^b/
+
+/()^b/
+ *** Failers
+No match
+ a\nb\nc\n
+No match
+ a\nb\nc\n
+No match
+
+/((?m)^b)/
+ a\nb\nc\n
+ 0: b
+ 1: b
+
+/(?(1)a|b)/
+
+/(?(1)b|a)/
+ a
+ 0: a
+
+/(x)?(?(1)a|b)/
+ *** Failers
+No match
+ a
+No match
+ a
+No match
+
+/(x)?(?(1)b|a)/
+ a
+ 0: a
+
+/()?(?(1)b|a)/
+ a
+ 0: a
+
+/()(?(1)b|a)/
+
+/()?(?(1)a|b)/
+ a
+ 0: a
+ 1:
+
+/^(\()?blah(?(1)(\)))$/
+ (blah)
+ 0: (blah)
+ 1: (
+ 2: )
+ blah
+ 0: blah
+ *** Failers
+No match
+ a
+No match
+ blah)
+No match
+ (blah
+No match
+
+/^(\(+)?blah(?(1)(\)))$/
+ (blah)
+ 0: (blah)
+ 1: (
+ 2: )
+ blah
+ 0: blah
+ *** Failers
+No match
+ blah)
+No match
+ (blah
+No match
+
+/(?(?!a)a|b)/
+
+/(?(?!a)b|a)/
+ a
+ 0: a
+
+/(?(?=a)b|a)/
+ *** Failers
+No match
+ a
+No match
+ a
+No match
+
+/(?(?=a)a|b)/
+ a
+ 0: a
+
+/(?=(a+?))(\1ab)/
+ aaab
+ 0: aab
+ 1: a
+ 2: aab
+
+/^(?=(a+?))\1ab/
+
+/(\w+:)+/
+ one:
+ 0: one:
+ 1: one:
+
+/$(?<=^(a))/
+ a
+ 0:
+ 1: a
+
+/(?=(a+?))(\1ab)/
+ aaab
+ 0: aab
+ 1: a
+ 2: aab
+
+/^(?=(a+?))\1ab/
+ *** Failers
+No match
+ aaab
+No match
+ aaab
+No match
+
+/([\w:]+::)?(\w+)$/
+ abcd
+ 0: abcd
+ 1: <unset>
+ 2: abcd
+ xy:z:::abcd
+ 0: xy:z:::abcd
+ 1: xy:z:::
+ 2: abcd
+
+/^[^bcd]*(c+)/
+ aexycd
+ 0: aexyc
+ 1: c
+
+/(a*)b+/
+ caab
+ 0: aab
+ 1: aa
+
+/([\w:]+::)?(\w+)$/
+ abcd
+ 0: abcd
+ 1: <unset>
+ 2: abcd
+ xy:z:::abcd
+ 0: xy:z:::abcd
+ 1: xy:z:::
+ 2: abcd
+ *** Failers
+ 0: Failers
+ 1: <unset>
+ 2: Failers
+ abcd:
+No match
+ abcd:
+No match
+
+/^[^bcd]*(c+)/
+ aexycd
+ 0: aexyc
+ 1: c
+
+/(>a+)ab/
+
+/(?>a+)b/
+ aaab
+ 0: aaab
+
+/([[:]+)/
+ a:[b]:
+ 0: :[
+ 1: :[
+
+/([[=]+)/
+ a=[b]=
+ 0: =[
+ 1: =[
+
+/([[.]+)/
+ a.[b].
+ 0: .[
+ 1: .[
+
+/((?>a+)b)/
+ aaab
+ 0: aaab
+ 1: aaab
+
+/(?>(a+))b/
+ aaab
+ 0: aaab
+ 1: aaa
+
+/((?>[^()]+)|\([^()]*\))+/
+ ((abc(ade)ufh()()x
+ 0: abc(ade)ufh()()x
+ 1: x
+
+/a\Z/
+ *** Failers
+No match
+ aaab
+No match
+ a\nb\n
+No match
+
+/b\Z/
+ a\nb\n
+ 0: b
+
+/b\z/
+
+/b\Z/
+ a\nb
+ 0: b
+
+/b\z/
+ a\nb
+ 0: b
+ *** Failers
+No match
+
+/^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
+ a
+ 0: a
+ 1:
+ abc
+ 0: abc
+ 1:
+ a-b
+ 0: a-b
+ 1:
+ 0-9
+ 0: 0-9
+ 1:
+ a.b
+ 0: a.b
+ 1:
+ 5.6.7
+ 0: 5.6.7
+ 1:
+ the.quick.brown.fox
+ 0: the.quick.brown.fox
+ 1:
+ a100.b200.300c
+ 0: a100.b200.300c
+ 1:
+ 12-ab.1245
+ 0: 12-ab.1245
+ 1:
+ *** Failers
+No match
+ \
+No match
+ .a
+No match
+ -a
+No match
+ a-
+No match
+ a.
+No match
+ a_b
+No match
+ a.-
+No match
+ a..
+No match
+ ab..bc
+No match
+ the.quick.brown.fox-
+No match
+ the.quick.brown.fox.
+No match
+ the.quick.brown.fox_
+No match
+ the.quick.brown.fox+
+No match
+
+/(?>.*)(?<=(abcd|wxyz))/
+ alphabetabcd
+ 0: alphabetabcd
+ 1: abcd
+ endingwxyz
+ 0: endingwxyz
+ 1: wxyz
+ *** Failers
+No match
+ a rather long string that doesn't end with one of them
+No match
+
+/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
+ word cat dog elephant mussel cow horse canary baboon snake shark otherword
+ 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
+ word cat dog elephant mussel cow horse canary baboon snake shark
+No match
+
+/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
+ word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
+No match
+
+/(?<=\d{3}(?!999))foo/
+ 999foo
+ 0: foo
+ 123999foo
+ 0: foo
+ *** Failers
+No match
+ 123abcfoo
+No match
+
+/(?<=(?!...999)\d{3})foo/
+ 999foo
+ 0: foo
+ 123999foo
+ 0: foo
+ *** Failers
+No match
+ 123abcfoo
+No match
+
+/(?<=\d{3}(?!999)...)foo/
+ 123abcfoo
+ 0: foo
+ 123456foo
+ 0: foo
+ *** Failers
+No match
+ 123999foo
+No match
+
+/(?<=\d{3}...)(?<!999)foo/
+ 123abcfoo
+ 0: foo
+ 123456foo
+ 0: foo
+ *** Failers
+No match
+ 123999foo
+No match
+
+/<a[\s]+href[\s]*=[\s]* # find <a href=
+ ([\"\'])? # find single or double quote
+ (?(1) (.*?)\1 | ([^\s]+)) # if quote found, match up to next matching
+ # quote, otherwise match up to next space
+/isx
+ <a href=abcd xyz
+ 0: <a href=abcd
+ 1: <unset>
+ 2: <unset>
+ 3: abcd
+ <a href=\"abcd xyz pqr\" cats
+ 0: <a href="abcd xyz pqr"
+ 1: "
+ 2: abcd xyz pqr
+ <a href=\'abcd xyz pqr\' cats
+ 0: <a href='abcd xyz pqr'
+ 1: '
+ 2: abcd xyz pqr
+
+/<a\s+href\s*=\s* # find <a href=
+ (["'])? # find single or double quote
+ (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
+ # quote, otherwise match up to next space
+/isx
+ <a href=abcd xyz
+ 0: <a href=abcd
+ 1: <unset>
+ 2: <unset>
+ 3: abcd
+ <a href=\"abcd xyz pqr\" cats
+ 0: <a href="abcd xyz pqr"
+ 1: "
+ 2: abcd xyz pqr
+ <a href = \'abcd xyz pqr\' cats
+ 0: <a href = 'abcd xyz pqr'
+ 1: '
+ 2: abcd xyz pqr
+
+/<a\s+href(?>\s*)=(?>\s*) # find <a href=
+ (["'])? # find single or double quote
+ (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
+ # quote, otherwise match up to next space
+/isx
+ <a href=abcd xyz
+ 0: <a href=abcd
+ 1: <unset>
+ 2: <unset>
+ 3: abcd
+ <a href=\"abcd xyz pqr\" cats
+ 0: <a href="abcd xyz pqr"
+ 1: "
+ 2: abcd xyz pqr
+ <a href = \'abcd xyz pqr\' cats
+ 0: <a href = 'abcd xyz pqr'
+ 1: '
+ 2: abcd xyz pqr
+
+/((Z)+|A)*/
+ ZABCDEFG
+ 0: ZA
+ 1: A
+ 2: Z
+
+/(Z()|A)*/
+ ZABCDEFG
+ 0: ZA
+ 1: A
+ 2:
+
+/(Z(())|A)*/
+ ZABCDEFG
+ 0: ZA
+ 1: A
+ 2:
+ 3:
+
+/((?>Z)+|A)*/
+ ZABCDEFG
+ 0: ZA
+ 1: A
+
+/((?>)+|A)*/
+ ZABCDEFG
+ 0:
+ 1:
+
+/a*/g
+ abbab
+ 0: a
+ 0:
+ 0:
+ 0: a
+ 0:
+ 0:
+
+/^[a-\d]/
+ abcde
+ 0: a
+ -things
+ 0: -
+ 0digit
+ 0: 0
+ *** Failers
+No match
+ bcdef
+No match
+
+/^[\d-a]/
+ abcde
+ 0: a
+ -things
+ 0: -
+ 0digit
+ 0: 0
+ *** Failers
+No match
+ bcdef
+No match
+
+/[[:space:]]+/
+ > \x09\x0a\x0c\x0d\x0b<
+ 0: \x09\x0a\x0c\x0d\x0b
+
+/[[:blank:]]+/
+ > \x09\x0a\x0c\x0d\x0b<
+ 0: \x09
+
+/[\s]+/
+ > \x09\x0a\x0c\x0d\x0b<
+ 0: \x09\x0a\x0c\x0d
+
+/\s+/
+ > \x09\x0a\x0c\x0d\x0b<
+ 0: \x09\x0a\x0c\x0d
+
+/a b/x
+ ab
+No match
+
+/(?!\A)x/m
+ a\nxb\n
+ 0: x
+
+/(?!^)x/m
+ a\nxb\n
+No match
+
+/abc\Qabc\Eabc/
+ abcabcabc
+ 0: abcabcabc
+
+/abc\Q(*+|\Eabc/
+ abc(*+|abc
+ 0: abc(*+|abc
+
+/ abc\Q abc\Eabc/x
+ abc abcabc
+ 0: abc abcabc
+ *** Failers
+No match
+ abcabcabc
+No match
+
+/abc#comment
+ \Q#not comment
+ literal\E/x
+ abc#not comment\n literal
+ 0: abc#not comment\x0a literal
+
+/abc#comment
+ \Q#not comment
+ literal/x
+ abc#not comment\n literal
+ 0: abc#not comment\x0a literal
+
+/abc#comment
+ \Q#not comment
+ literal\E #more comment
+ /x
+ abc#not comment\n literal
+ 0: abc#not comment\x0a literal
+
+/abc#comment
+ \Q#not comment
+ literal\E #more comment/x
+ abc#not comment\n literal
+ 0: abc#not comment\x0a literal
+
+/\Qabc\$xyz\E/
+ abc\\\$xyz
+ 0: abc\$xyz
+
+/\Qabc\E\$\Qxyz\E/
+ abc\$xyz
+ 0: abc$xyz
+
+/\Gabc/
+ abc
+ 0: abc
+ *** Failers
+No match
+ xyzabc
+No match
+
+/\Gabc./g
+ abc1abc2xyzabc3
+ 0: abc1
+ 0: abc2
+
+/abc./g
+ abc1abc2xyzabc3
+ 0: abc1
+ 0: abc2
+ 0: abc3
+
+/a(?x: b c )d/
+ XabcdY
+ 0: abcd
+ *** Failers
+No match
+ Xa b c d Y
+No match
+
+/((?x)x y z | a b c)/
+ XabcY
+ 0: abc
+ 1: abc
+ AxyzB
+ 0: xyz
+ 1: xyz
+
+/(?i)AB(?-i)C/
+ XabCY
+ 0: abC
+ *** Failers
+No match
+ XabcY
+No match
+
+/((?i)AB(?-i)C|D)E/
+ abCE
+ 0: abCE
+ 1: abC
+ DE
+ 0: DE
+ 1: D
+ *** Failers
+No match
+ abcE
+No match
+ abCe
+No match
+ dE
+No match
+ De
+No match
+
+/(.*)\d+\1/
+ abc123abc
+ 0: abc123abc
+ 1: abc
+ abc123bc
+ 0: bc123bc
+ 1: bc
+
+/(.*)\d+\1/s
+ abc123abc
+ 0: abc123abc
+ 1: abc
+ abc123bc
+ 0: bc123bc
+ 1: bc
+
+/((.*))\d+\1/
+ abc123abc
+ 0: abc123abc
+ 1: abc
+ 2: abc
+ abc123bc
+ 0: bc123bc
+ 1: bc
+ 2: bc
+
+/-- This tests for an IPv6 address in the form where it can have up to --/
+/-- eight components, one and only one of which is empty. This must be --/
+No match
+/-- an internal component. --/
+No match
+
+/^(?!:) # colon disallowed at start
+ (?: # start of item
+ (?: [0-9a-f]{1,4} | # 1-4 hex digits or
+ (?(1)0 | () ) ) # if null previously matched, fail; else null
+ : # followed by colon
+ ){1,7} # end item; 1-7 of them required
+ [0-9a-f]{1,4} $ # final hex number at end of string
+ (?(1)|.) # check that there was an empty component
+ /xi
+ a123::a123
+ 0: a123::a123
+ 1:
+ a123:b342::abcd
+ 0: a123:b342::abcd
+ 1:
+ a123:b342::324e:abcd
+ 0: a123:b342::324e:abcd
+ 1:
+ a123:ddde:b342::324e:abcd
+ 0: a123:ddde:b342::324e:abcd
+ 1:
+ a123:ddde:b342::324e:dcba:abcd
+ 0: a123:ddde:b342::324e:dcba:abcd
+ 1:
+ a123:ddde:9999:b342::324e:dcba:abcd
+ 0: a123:ddde:9999:b342::324e:dcba:abcd
+ 1:
+ *** Failers
+No match
+ 1:2:3:4:5:6:7:8
+No match
+ a123:bce:ddde:9999:b342::324e:dcba:abcd
+No match
+ a123::9999:b342::324e:dcba:abcd
+No match
+ abcde:2:3:4:5:6:7:8
+No match
+ ::1
+No match
+ abcd:fee0:123::
+No match
+ :1
+No match
+ 1:
+No match
+
+/[z\Qa-d]\E]/
+ z
+ 0: z
+ a
+ 0: a
+ -
+ 0: -
+ d
+ 0: d
+ ]
+ 0: ]
+ *** Failers
+ 0: a
+ b
+No match
+
+/[\z\C]/
+ z
+ 0: z
+ C
+ 0: C
+
+/\M/
+ M
+ 0: M
+
/ End of testinput1 /
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index e8844d2..3f38522 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -1,4 +1,4 @@
-PCRE version 3.9 02-Jan-2002
+PCRE version 4.0 17-Feb-2003
/(a)b|/
Capturing subpattern count = 1
@@ -91,8 +91,8 @@ Failed: number too big in {} quantifier at offset 7
/[abcd/
Failed: missing terminating ] for character class at offset 5
-/[\B]/
-Failed: invalid escape sequence in character class at offset 2
+/(?X)[\B]/
+Failed: invalid escape sequence in character class at offset 6
/[z-a]/
Failed: range out of order in character class at offset 3
@@ -136,6 +136,7 @@ Capturing subpattern count = 0
No options
No first char
No need char
+Study size = 40
Starting character set: c d e
this sentence eventually mentions a cat
0: cat
@@ -147,6 +148,7 @@ Capturing subpattern count = 0
Options: caseless
No first char
No need char
+Study size = 40
Starting character set: C D E c d e
this sentence eventually mentions a CAT cat
0: CAT
@@ -158,6 +160,7 @@ Capturing subpattern count = 0
No options
No first char
No need char
+Study size = 40
Starting character set: a b c d
/(a|[^\dZ])/S
@@ -165,6 +168,7 @@ Capturing subpattern count = 1
No options
No first char
No need char
+Study size = 40
Starting character set: \x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0a
\x0b \x0c \x0d \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19
\x1a \x1b \x1c \x1d \x1e \x1f \x20 ! " # $ % & ' ( ) * + , - . / : ; < = >
@@ -185,10 +189,11 @@ Capturing subpattern count = 1
No options
No first char
No need char
-Starting character set: \x09 \x0a \x0b \x0c \x0d \x20 a b
+Study size = 40
+Starting character set: \x09 \x0a \x0c \x0d \x20 a b
/(ab\2)/
-Failed: back reference to non-existent subpattern at offset 6
+Failed: reference to non-existent subpattern at offset 6
/{4,5}abc/
Failed: nothing to repeat at offset 4
@@ -281,7 +286,7 @@ No match
No match
/(a)(b)(c)(d)(e)\6/
-Failed: back reference to non-existent subpattern at offset 17
+Failed: reference to non-existent subpattern at offset 17
/the quick brown fox/
Capturing subpattern count = 0
@@ -426,7 +431,7 @@ Need char = '>'
abc<def>ghi<klm>nop
0: <def>
-/<.*>(?U)/
+/(?U)<.*>/
Capturing subpattern count = 0
Options: ungreedy
First char = '<'
@@ -486,8 +491,8 @@ Failed: lookbehind assertion is not fixed length at offset 12
/(?i)abc/
Capturing subpattern count = 0
Options: caseless
-First char = 'a'
-Need char = 'c'
+First char = 'a' (caseless)
+Need char = 'c' (caseless)
/(a|(?m)a)/
Capturing subpattern count = 1
@@ -519,6 +524,7 @@ Capturing subpattern count = 0
No options
No first char
No need char
+Study size = 40
Starting character set: a b c d
/(?i)[abcd]/S
@@ -526,6 +532,7 @@ Capturing subpattern count = 0
Options: caseless
No first char
No need char
+Study size = 40
Starting character set: A B C D a b c d
/(?m)[xy]|(b|c)/S
@@ -533,6 +540,7 @@ Capturing subpattern count = 1
Options: multiline
No first char
No need char
+Study size = 40
Starting character set: b c x y
/(^a|^b)/m
@@ -563,7 +571,7 @@ Failed: assertion expected after (?( at offset 3
Failed: assertion expected after (?( at offset 3
/(?(?<ab))/
-Failed: unrecognized character after (?< at offset 2
+Failed: unrecognized character after (?< at offset 5
/((?s)blah)\s+\1/
Capturing subpattern count = 1
@@ -577,8 +585,8 @@ Capturing subpattern count = 1
Max back reference = 1
No options
Case state changes
-No first char
-Need char = 'h'
+First char = 'b' (caseless)
+Need char = 'h' (caseless)
/((?i)b)/DS
------------------------------------------------------------------
@@ -594,9 +602,9 @@ Need char = 'h'
Capturing subpattern count = 1
No options
Case state changes
-No first char
-Need char = 'b'
-Starting character set: B b
+First char = 'b' (caseless)
+No need char
+Study returned NULL
/(a*b|(?i:c*(?-i)d))/S
Capturing subpattern count = 1
@@ -604,6 +612,7 @@ No options
Case state changes
No first char
No need char
+Study size = 40
Starting character set: C a b c d
/a$/
@@ -668,6 +677,7 @@ Capturing subpattern count = 0
No options
No first char
No need char
+Study size = 40
Starting character set: a b
/(?<!foo)(alpha|omega)/S
@@ -675,6 +685,7 @@ Capturing subpattern count = 1
No options
No first char
Need char = 'a'
+Study size = 40
Starting character set: a o
/(?!alphabet)[ab]/S
@@ -682,6 +693,7 @@ Capturing subpattern count = 0
No options
No first char
No need char
+Study size = 40
Starting character set: a b
/(?<=foo\n)^bar/m
@@ -864,13 +876,13 @@ Failed: nothing to repeat at offset 2
Failed: unmatched parentheses at offset 0
/\1/
-Failed: back reference to non-existent subpattern at offset 2
+Failed: reference to non-existent subpattern at offset 2
/\2/
-Failed: back reference to non-existent subpattern at offset 2
+Failed: reference to non-existent subpattern at offset 2
/(a)|\2/
-Failed: back reference to non-existent subpattern at offset 6
+Failed: reference to non-existent subpattern at offset 6
/a[b-a]/i
Failed: range out of order in character class at offset 4
@@ -903,7 +915,7 @@ Failed: unmatched parentheses at offset 0
Failed: missing ) at offset 4
/(?<%)b/
-Failed: unrecognized character after (?< at offset 0
+Failed: unrecognized character after (?< at offset 3
/a(?{)b/
Failed: unrecognized character after (? at offset 3
@@ -1483,7 +1495,7 @@ Need char = 'a'
Capturing subpattern count = 0
No options
First char = 'a'
-No need char
+Need char = 'a'
/(?=a)a.*/
Capturing subpattern count = 0
@@ -1787,7 +1799,7 @@ Need char = ')'
0: (abcd(xyz<p>qrs)123)
1: abcd(xyz<p>qrs)123
2: 123
- 3: <p>qrs
+ 3: <unset>
/\( ( ( (?>[^()]+) | ((?R)) )* ) \) /x
Capturing subpattern count = 3
@@ -1844,6 +1856,19 @@ Options: anchored
No first char
No need char
+/^[[:blank:]]/D
+------------------------------------------------------------------
+ 0 37 Bra 0
+ 3 ^
+ 4 [\x09 ]
+ 37 37 Ket
+ 40 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
/^[[:cntrl:]]/D
------------------------------------------------------------------
0 37 Bra 0
@@ -2000,6 +2025,19 @@ Options: anchored
No first char
No need char
+/^[[:^blank:]]/D
+------------------------------------------------------------------
+ 0 37 Bra 0
+ 3 ^
+ 4 [\x00-\x08\x0a-\x1f!-\xff]
+ 37 37 Ket
+ 40 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
/[01[:alpha:]%]/D
------------------------------------------------------------------
0 36 Bra 0
@@ -2372,6 +2410,2004 @@ Need char = 'n'
1: main
2: O
+/These are all cases where Perl does it differently (nested captures)/
+Capturing subpattern count = 1
+No options
+First char = 'T'
+Need char = 's'
+
+/^(a(b)?)+$/
+Capturing subpattern count = 2
+Options: anchored
+No first char
+Need char = 'a'
+ aba
+ 0: aba
+ 1: a
+ 2: b
+
+/^(aa(bb)?)+$/
+Capturing subpattern count = 2
+Options: anchored
+No first char
+Need char = 'a'
+ aabbaa
+ 0: aabbaa
+ 1: aa
+ 2: bb
+
+/^(aa|aa(bb))+$/
+Capturing subpattern count = 2
+Options: anchored
+No first char
+Need char = 'a'
+ aabbaa
+ 0: aabbaa
+ 1: aa
+ 2: bb
+
+/^(aa(bb)??)+$/
+Capturing subpattern count = 2
+Options: anchored
+No first char
+Need char = 'a'
+ aabbaa
+ 0: aabbaa
+ 1: aa
+ 2: bb
+
+/^(?:aa(bb)?)+$/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = 'a'
+ aabbaa
+ 0: aabbaa
+ 1: bb
+
+/^(aa(b(b))?)+$/
+Capturing subpattern count = 3
+Options: anchored
+No first char
+Need char = 'a'
+ aabbaa
+ 0: aabbaa
+ 1: aa
+ 2: bb
+ 3: b
+
+/^(?:aa(b(b))?)+$/
+Capturing subpattern count = 2
+Options: anchored
+No first char
+Need char = 'a'
+ aabbaa
+ 0: aabbaa
+ 1: bb
+ 2: b
+
+/^(?:aa(b(?:b))?)+$/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = 'a'
+ aabbaa
+ 0: aabbaa
+ 1: bb
+
+/^(?:aa(bb(?:b))?)+$/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = 'a'
+ aabbbaa
+ 0: aabbbaa
+ 1: bbb
+
+/^(?:aa(b(?:bb))?)+$/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = 'a'
+ aabbbaa
+ 0: aabbbaa
+ 1: bbb
+
+/^(?:aa(?:b(b))?)+$/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = 'a'
+ aabbaa
+ 0: aabbaa
+ 1: b
+
+/^(?:aa(?:b(bb))?)+$/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = 'a'
+ aabbbaa
+ 0: aabbbaa
+ 1: bb
+
+/^(aa(b(bb))?)+$/
+Capturing subpattern count = 3
+Options: anchored
+No first char
+Need char = 'a'
+ aabbbaa
+ 0: aabbbaa
+ 1: aa
+ 2: bbb
+ 3: bb
+
+/^(aa(bb(bb))?)+$/
+Capturing subpattern count = 3
+Options: anchored
+No first char
+Need char = 'a'
+ aabbbbaa
+ 0: aabbbbaa
+ 1: aa
+ 2: bbbb
+ 3: bb
+
+/--------------------------------------------------------------------/
+Capturing subpattern count = 0
+No options
+First char = '-'
+Need char = '-'
+
+/#/xMD
+Memory allocation (code space): 7
+------------------------------------------------------------------
+ 0 3 Bra 0
+ 3 3 Ket
+ 6 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: extended
+No first char
+No need char
+
+/a#/xMD
+Memory allocation (code space): 13
+------------------------------------------------------------------
+ 0 6 Bra 0
+ 3 1 a
+ 6 6 Ket
+ 9 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: extended
+First char = 'a'
+No need char
+
+/[\s]/D
+------------------------------------------------------------------
+ 0 36 Bra 0
+ 3 [\x09-\x0a\x0c-\x0d ]
+ 36 36 Ket
+ 39 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[\S]/D
+------------------------------------------------------------------
+ 0 36 Bra 0
+ 3 [\x00-\x08\x0b\x0e-\x1f!-\xff]
+ 36 36 Ket
+ 39 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/a(?i)b/D
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 1 a
+ 6 01 Opt
+ 8 1 b
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+Case state changes
+First char = 'a'
+Need char = 'b' (caseless)
+ ab
+ 0: ab
+ aB
+ 0: aB
+ *** Failers
+No match
+ AB
+No match
+
+/(a(?i)b)/D
+------------------------------------------------------------------
+ 0 19 Bra 0
+ 3 11 Bra 1
+ 6 1 a
+ 9 01 Opt
+ 11 1 b
+ 14 11 Ket
+ 17 00 Opt
+ 19 19 Ket
+ 22 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+Case state changes
+First char = 'a'
+Need char = 'b' (caseless)
+ ab
+ 0: ab
+ 1: ab
+ aB
+ 0: aB
+ 1: aB
+ *** Failers
+No match
+ AB
+No match
+
+/ (?i)abc/xD
+------------------------------------------------------------------
+ 0 8 Bra 0
+ 3 3 abc
+ 8 8 Ket
+ 11 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: caseless extended
+First char = 'a' (caseless)
+Need char = 'c' (caseless)
+
+/#this is a comment
+ (?i)abc/xD
+------------------------------------------------------------------
+ 0 8 Bra 0
+ 3 3 abc
+ 8 8 Ket
+ 11 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: caseless extended
+First char = 'a' (caseless)
+Need char = 'c' (caseless)
+
+/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/D
+------------------------------------------------------------------
+ 0 307 Bra 0
+ 3 250 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
+255 50 12345678901234567890123456789012345678901234567890
+307 307 Ket
+310 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = '1'
+Need char = '0'
+
+/\Q123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/D
+------------------------------------------------------------------
+ 0 307 Bra 0
+ 3 250 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
+255 50 12345678901234567890123456789012345678901234567890
+307 307 Ket
+310 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = '1'
+Need char = '0'
+
+/\Q\E/D
+------------------------------------------------------------------
+ 0 3 Bra 0
+ 3 3 Ket
+ 6 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+ \
+ 0:
+
+/\Q\Ex/D
+------------------------------------------------------------------
+ 0 6 Bra 0
+ 3 1 x
+ 6 6 Ket
+ 9 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'x'
+No need char
+
+/ \Q\E/D
+------------------------------------------------------------------
+ 0 6 Bra 0
+ 3 1
+ 6 6 Ket
+ 9 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = ' '
+No need char
+
+/a\Q\E/D
+------------------------------------------------------------------
+ 0 6 Bra 0
+ 3 1 a
+ 6 6 Ket
+ 9 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+ abc
+ 0: a
+ bca
+ 0: a
+ bac
+ 0: a
+
+/a\Q\Eb/D
+------------------------------------------------------------------
+ 0 9 Bra 0
+ 3 1 a
+ 6 1 b
+ 9 9 Ket
+ 12 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+ abc
+ 0: ab
+
+/\Q\Eabc/D
+------------------------------------------------------------------
+ 0 8 Bra 0
+ 3 3 abc
+ 8 8 Ket
+ 11 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+
+/x*+\w/D
+------------------------------------------------------------------
+ 0 12 Bra 0
+ 3 5 Once
+ 6 x*
+ 8 5 Ket
+ 11 \w
+ 12 12 Ket
+ 15 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+ *** Failers
+ 0: F
+ xxxxx
+No match
+
+/x?+/D
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 5 Once
+ 6 x?
+ 8 5 Ket
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/x++/D
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 5 Once
+ 6 x+
+ 8 5 Ket
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'x'
+No need char
+
+/x{1,3}+/D
+------------------------------------------------------------------
+ 0 16 Bra 0
+ 3 10 Once
+ 6 1 x
+ 9 x{,2}
+ 13 10 Ket
+ 16 16 Ket
+ 19 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'x'
+No need char
+
+/(x)*+/D
+------------------------------------------------------------------
+ 0 19 Bra 0
+ 3 13 Once
+ 6 Brazero
+ 7 6 Bra 1
+ 10 1 x
+ 13 6 KetRmax
+ 16 13 Ket
+ 19 19 Ket
+ 22 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+
+/^(\w++|\s++)*$/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+ now is the time for all good men to come to the aid of the party
+ 0: now is the time for all good men to come to the aid of the party
+ 1: party
+ *** Failers
+No match
+ this is not a line with only words and spaces!
+No match
+
+/(\d++)(\w)/
+Capturing subpattern count = 2
+No options
+No first char
+No need char
+ 12345a
+ 0: 12345a
+ 1: 12345
+ 2: a
+ *** Failers
+No match
+ 12345+
+No match
+
+/a++b/
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+ aaab
+ 0: aaab
+
+/(a++b)/
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+ aaab
+ 0: aaab
+ 1: aaab
+
+/(a++)b/
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+ aaab
+ 0: aaab
+ 1: aaa
+
+/([^()]++|\([^()]*\))+/
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+ ((abc(ade)ufh()()x
+ 0: abc(ade)ufh()()x
+ 1: x
+
+/\(([^()]++|\([^()]+\))+\)/
+Capturing subpattern count = 1
+No options
+First char = '('
+Need char = ')'
+ (abc)
+ 0: (abc)
+ 1: abc
+ (abc(def)xyz)
+ 0: (abc(def)xyz)
+ 1: xyz
+ *** Failers
+No match
+ ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+
+/(abc){1,3}+/D
+------------------------------------------------------------------
+ 0 50 Bra 0
+ 3 44 Once
+ 6 8 Bra 1
+ 9 3 abc
+ 14 8 Ket
+ 17 Brazero
+ 18 26 Bra 0
+ 21 8 Bra 1
+ 24 3 abc
+ 29 8 Ket
+ 32 Brazero
+ 33 8 Bra 1
+ 36 3 abc
+ 41 8 Ket
+ 44 26 Ket
+ 47 44 Ket
+ 50 50 Ket
+ 53 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'c'
+
+/a+?+/
+Failed: nothing to repeat at offset 3
+
+/a{2,3}?+b/
+Failed: nothing to repeat at offset 7
+
+/(?U)a+?+/
+Failed: nothing to repeat at offset 7
+
+/a{2,3}?+b/U
+Failed: nothing to repeat at offset 7
+
+/x(?U)a++b/D
+------------------------------------------------------------------
+ 0 17 Bra 0
+ 3 1 x
+ 6 5 Once
+ 9 a+
+ 11 5 Ket
+ 14 1 b
+ 17 17 Ket
+ 20 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'x'
+Need char = 'b'
+ xaaaab
+ 0: xaaaab
+
+/(?U)xa++b/D
+------------------------------------------------------------------
+ 0 17 Bra 0
+ 3 1 x
+ 6 5 Once
+ 9 a+
+ 11 5 Ket
+ 14 1 b
+ 17 17 Ket
+ 20 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: ungreedy
+First char = 'x'
+Need char = 'b'
+ xaaaab
+ 0: xaaaab
+
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/D
+------------------------------------------------------------------
+ 0 106 Bra 0
+ 3 ^
+ 4 99 Bra 1
+ 7 5 Bra 2
+ 10 a+
+ 12 5 Ket
+ 15 37 Bra 3
+ 18 [a-b]+?
+ 52 37 Ket
+ 55 37 Bra 4
+ 58 [b-c]+
+ 92 37 Ket
+ 95 5 Bra 5
+ 98 \w*
+100 5 Ket
+103 99 Ket
+106 106 Ket
+109 End
+------------------------------------------------------------------
+Capturing subpattern count = 5
+Options: anchored
+No first char
+Need char = 'a'
+
+/^x(?U)a+b/D
+------------------------------------------------------------------
+ 0 12 Bra 0
+ 3 ^
+ 4 1 x
+ 7 a+?
+ 9 1 b
+ 12 12 Ket
+ 15 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+Need char = 'b'
+
+/^x(?U)(a+)b/D
+------------------------------------------------------------------
+ 0 18 Bra 0
+ 3 ^
+ 4 1 x
+ 7 5 Bra 1
+ 10 a+?
+ 12 5 Ket
+ 15 1 b
+ 18 18 Ket
+ 21 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = 'b'
+
+/[.x.]/
+Failed: POSIX collating elements are not supported at offset 0
+
+/[=x=]/
+Failed: POSIX collating elements are not supported at offset 0
+
+/[:x:]/
+Failed: POSIX named classes are supported only within a class at offset 0
+
+/\l/
+Failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
+
+/\L/
+Failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
+
+/\N{name}/
+Failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
+
+/\pP/
+Failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
+
+/\PP/
+Failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
+
+/\p{prop}/
+Failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
+
+/\P{prop}/
+Failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
+
+/\u/
+Failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
+
+/\U/
+Failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
+
+/\X/
+Failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
+
+/[/
+Failed: missing terminating ] for character class at offset 1
+
+/[a-/
+Failed: missing terminating ] for character class at offset 3
+
+/[[:space:]/
+Failed: missing terminating ] for character class at offset 10
+
+/[\s]/DM
+Memory allocation (code space): 40
+------------------------------------------------------------------
+ 0 36 Bra 0
+ 3 [\x09-\x0a\x0c-\x0d ]
+ 36 36 Ket
+ 39 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[[:space:]]/DM
+Memory allocation (code space): 40
+------------------------------------------------------------------
+ 0 36 Bra 0
+ 3 [\x09-\x0d ]
+ 36 36 Ket
+ 39 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[[:space:]abcde]/DM
+Memory allocation (code space): 40
+------------------------------------------------------------------
+ 0 36 Bra 0
+ 3 [\x09-\x0d a-e]
+ 36 36 Ket
+ 39 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/< (?: (?(R) \d++ | [^<>]*+) | (?R)) * >/x
+Capturing subpattern count = 0
+Options: extended
+First char = '<'
+Need char = '>'
+ <>
+ 0: <>
+ <abcd>
+ 0: <abcd>
+ <abc <123> hij>
+ 0: <abc <123> hij>
+ <abc <def> hij>
+ 0: <def>
+ <abc<>def>
+ 0: <abc<>def>
+ <abc<>
+ 0: <>
+ *** Failers
+No match
+ <abc
+No match
+
+|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|DM
+Memory allocation (code space): 421
+------------------------------------------------------------------
+ 0 417 Bra 0
+ 3 250 8J$WE<.rX+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:
+255 159 x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
+416 \b
+417 417 Ket
+420 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = '8'
+Need char = 'X'
+
+|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|DM
+Memory allocation (code space): 416
+------------------------------------------------------------------
+ 0 412 Bra 0
+ 3 250 $<.X+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[
+255 154 %z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
+411 \b
+412 412 Ket
+415 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = '$'
+Need char = 'X'
+
+/(.*)\d+\1/I
+Capturing subpattern count = 1
+Max back reference = 1
+No options
+No first char
+No need char
+
+/(.*)\d+/I
+Capturing subpattern count = 1
+No options
+First char at start or follows \n
+No need char
+
+/(.*)\d+\1/Is
+Capturing subpattern count = 1
+Max back reference = 1
+Options: dotall
+No first char
+No need char
+
+/(.*)\d+/Is
+Capturing subpattern count = 1
+Options: anchored dotall
+No first char
+No need char
+
+/(.*(xyz))\d+\2/I
+Capturing subpattern count = 2
+Max back reference = 2
+No options
+First char at start or follows \n
+Need char = 'z'
+
+/((.*))\d+\1/I
+Capturing subpattern count = 2
+Max back reference = 1
+No options
+No first char
+No need char
+ abc123bc
+ 0: bc123bc
+ 1: bc
+ 2: bc
+
+/a[b]/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+
+/(?=a).*/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+
+/(?=abc).xyz/iI
+Capturing subpattern count = 0
+Options: caseless
+First char = 'a' (caseless)
+Need char = 'z' (caseless)
+
+/(?=abc)(?i).xyz/I
+Capturing subpattern count = 0
+No options
+Case state changes
+First char = 'a'
+Need char = 'z' (caseless)
+
+/(?=a)(?=b)/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+
+/(?=.)a/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+
+/((?=abcda)a)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'a'
+
+/((?=abcda)ab)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+
+/()a/I
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'a'
+
+/(?(1)ab|ac)/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+
+/(?(1)abz|acz)/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'z'
+
+/(?(1)abz)/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/(?(1)abz)123/I
+Capturing subpattern count = 0
+No options
+No first char
+Need char = '3'
+
+/(a)+/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+No need char
+
+/(a){2,3}/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'a'
+
+/(a)*/I
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+
+/[a]/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+
+/[ab]/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[ab]/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Study size = 40
+Starting character set: a b
+
+/[^a]/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/\d456/I
+Capturing subpattern count = 0
+No options
+No first char
+Need char = '6'
+
+/\d456/IS
+Capturing subpattern count = 0
+No options
+No first char
+Need char = '6'
+Study size = 40
+Starting character set: 0 1 2 3 4 5 6 7 8 9
+
+/a^b/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+
+/^a/mI
+Capturing subpattern count = 0
+Options: multiline
+First char at start or follows \n
+Need char = 'a'
+ abcde
+ 0: a
+ xy\nabc
+ 0: a
+ *** Failers
+No match
+ xyabc
+No match
+
+/c|abc/I
+Capturing subpattern count = 0
+No options
+No first char
+Need char = 'c'
+
+/(?i)[ab]/IS
+Capturing subpattern count = 0
+Options: caseless
+No first char
+No need char
+Study size = 40
+Starting character set: A B a b
+
+/[ab](?i)cd/IS
+Capturing subpattern count = 0
+No options
+Case state changes
+No first char
+Need char = 'd' (caseless)
+Study size = 40
+Starting character set: a b
+
+/abc(?C)def/
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'f'
+ abcdef
+--->abcdef
+ 0 ^ ^
+ 0: abcdef
+ 1234abcdef
+--->1234abcdef
+ 0 ^ ^
+ 0: abcdef
+ *** Failers
+No match
+ abcxyz
+No match
+ abcxyzf
+--->abcxyzf
+ 0 ^ ^
+No match
+
+/abc(?C)de(?C1)f/
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'f'
+ 123abcdef
+--->123abcdef
+ 0 ^ ^
+ 1 ^ ^
+ 0: abcdef
+
+/(?C1)\dabc(?C2)def/
+Capturing subpattern count = 0
+No options
+No first char
+Need char = 'f'
+ 1234abcdef
+--->1234abcdef
+ 1 ^
+ 1 ^
+ 1 ^
+ 1 ^
+ 2 ^ ^
+ 0: 4abcdef
+ *** Failers
+No match
+ abcdef
+--->abcdef
+ 1 ^
+ 1 ^
+ 1 ^
+ 1 ^
+ 1 ^
+ 1 ^
+No match
+
+/(?C255)ab/
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+
+/(?C256)ab/
+Failed: number after (?C is > 255 at offset 6
+
+/(?Cab)xx/
+Failed: closing ) for (?C expected at offset 3
+
+/(?C12vr)x/
+Failed: closing ) for (?C expected at offset 5
+
+/abc(?C)def/
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'f'
+ *** Failers
+No match
+ \x83\x0\x61bcdef
+--->\x83\x00abcdef
+ 0 ^ ^
+ 0: abcdef
+
+/(abc)(?C)de(?C1)f/
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'f'
+ 123abcdef
+--->123abcdef
+ 0 ^ ^
+ 1 ^ ^
+ 0: abcdef
+ 1: abc
+ 123abcdef\C+
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: abc
+--->123abcdef
+ ^ ^
+Callout 1: last capture = 1
+ 0: <unset>
+ 1: abc
+--->123abcdef
+ ^ ^
+ 0: abcdef
+ 1: abc
+ 123abcdef\C-
+ 0: abcdef
+ 1: abc
+ *** Failers
+No match
+ 123abcdef\C!1
+--->123abcdef
+ 0 ^ ^
+ 1 ^ ^
+No match
+
+/(?C0)(abc(?C1))*/
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+ abcabcabc
+--->abcabcabc
+ 0 ^
+ 1 ^ ^
+ 1 ^ ^
+ 1 ^ ^
+ 0: abcabcabc
+ 1: abc
+ abcabc\C!1!3
+--->abcabc
+ 0 ^
+ 1 ^ ^
+ 1 ^ ^
+ 0: abcabc
+ 1: abc
+ *** Failers
+--->*** Failers
+ 0 ^
+ 0:
+ abcabcabc\C!1!3
+--->abcabcabc
+ 0 ^
+ 1 ^ ^
+ 1 ^ ^
+ 1 ^ ^
+ 0: abcabc
+ 1: abc
+
+/(\d{3}(?C))*/
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+ 123\C+
+Callout 0: last capture = -1
+ 0: <unset>
+--->123
+ ^ ^
+ 0: 123
+ 1: 123
+ 123456\C+
+Callout 0: last capture = -1
+ 0: <unset>
+--->123456
+ ^ ^
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: 123
+--->123456
+ ^ ^
+ 0: 123456
+ 1: 456
+ 123456789\C+
+Callout 0: last capture = -1
+ 0: <unset>
+--->123456789
+ ^ ^
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: 123
+--->123456789
+ ^ ^
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: 456
+--->123456789
+ ^ ^
+ 0: 123456789
+ 1: 789
+
+/((xyz)(?C)p|(?C1)xyzabc)/
+Capturing subpattern count = 2
+No options
+First char = 'x'
+No need char
+ xyzabc\C+
+Callout 0: last capture = 2
+ 0: <unset>
+ 1: <unset>
+ 2: xyz
+--->xyzabc
+ ^ ^
+Callout 1: last capture = -1
+ 0: <unset>
+--->xyzabc
+ ^
+ 0: xyzabc
+ 1: xyzabc
+
+/(X)((xyz)(?C)p|(?C1)xyzabc)/
+Capturing subpattern count = 3
+No options
+First char = 'X'
+Need char = 'x'
+ Xxyzabc\C+
+Callout 0: last capture = 3
+ 0: <unset>
+ 1: X
+ 2: <unset>
+ 3: xyz
+--->Xxyzabc
+ ^ ^
+Callout 1: last capture = 1
+ 0: <unset>
+ 1: X
+--->Xxyzabc
+ ^^
+ 0: Xxyzabc
+ 1: X
+ 2: xyzabc
+
+/(?=(abc))(?C)abcdef/
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'f'
+ abcdef\C+
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: abc
+--->abcdef
+ ^
+ 0: abcdef
+ 1: abc
+
+/(?!(abc)(?C1)d)(?C2)abcxyz/
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'z'
+ abcxyz\C+
+Callout 1: last capture = 1
+ 0: <unset>
+ 1: abc
+--->abcxyz
+ ^ ^
+Callout 2: last capture = -1
+ 0: <unset>
+--->abcxyz
+ ^
+ 0: abcxyz
+
+/(?<=(abc)(?C))xyz/
+Capturing subpattern count = 1
+No options
+First char = 'x'
+Need char = 'z'
+ abcxyz\C+
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: abc
+--->abcxyz
+ ^
+ 0: xyz
+ 1: abc
+
+/(?C)abc/
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+
+/(?C)^abc/
+Capturing subpattern count = 0
+Options: anchored
+No first char
+Need char = 'c'
+
+/(?C)a|b/S
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Study size = 40
+Starting character set: a b
+
+/(?R)/
+Failed: recursive call could loop indefinitely at offset 3
+
+/(a|(?R))/
+Failed: recursive call could loop indefinitely at offset 6
+
+/(ab|(bc|(de|(?R))))/
+Failed: recursive call could loop indefinitely at offset 15
+
+/x(ab|(bc|(de|(?R))))/
+Capturing subpattern count = 3
+No options
+First char = 'x'
+No need char
+ xab
+ 0: xab
+ 1: ab
+ xbc
+ 0: xbc
+ 1: bc
+ 2: bc
+ xde
+ 0: xde
+ 1: de
+ 2: de
+ 3: de
+ xxab
+ 0: xxab
+ 1: xab
+ 2: xab
+ 3: xab
+ xxxab
+ 0: xxxab
+ 1: xxab
+ 2: xxab
+ 3: xxab
+ *** Failers
+No match
+ xyab
+No match
+
+/(ab|(bc|(de|(?1))))/
+Failed: recursive call could loop indefinitely at offset 15
+
+/x(ab|(bc|(de|(?1)x)x)x)/
+Failed: recursive call could loop indefinitely at offset 16
+
+/^([^()]|\((?1)*\))*$/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+ abc
+ 0: abc
+ 1: c
+ a(b)c
+ 0: a(b)c
+ 1: c
+ a(b(c))d
+ 0: a(b(c))d
+ 1: d
+ *** Failers)
+No match
+ a(b(c)d
+No match
+
+/^>abc>([^()]|\((?1)*\))*<xyz<$/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = '<'
+ >abc>123<xyz<
+ 0: >abc>123<xyz<
+ 1: 3
+ >abc>1(2)3<xyz<
+ 0: >abc>1(2)3<xyz<
+ 1: 3
+ >abc>(1(2)3)<xyz<
+ 0: >abc>(1(2)3)<xyz<
+ 1: (1(2)3)
+
+/(a(?1)b)/D
+------------------------------------------------------------------
+ 0 18 Bra 0
+ 3 12 Bra 1
+ 6 1 a
+ 9 3 Recurse
+ 12 1 b
+ 15 12 Ket
+ 18 18 Ket
+ 21 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+
+/(a(?1)+b)/D
+------------------------------------------------------------------
+ 0 24 Bra 0
+ 3 18 Bra 1
+ 6 1 a
+ 9 6 Bra 0
+ 12 3 Recurse
+ 15 6 KetRmax
+ 18 1 b
+ 21 18 Ket
+ 24 24 Ket
+ 27 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+
+/^\W*(?:((.)\W*(?1)\W*\2|)|((.)\W*(?3)\W*\4|\W*.\W*))\W*$/i
+Capturing subpattern count = 4
+Max back reference = 4
+Options: anchored caseless
+No first char
+No need char
+ 1221
+ 0: 1221
+ 1: 1221
+ 2: 1
+ Satan, oscillate my metallic sonatas!
+ 0: Satan, oscillate my metallic sonatas!
+ 1: <unset>
+ 2: <unset>
+ 3: Satan, oscillate my metallic sonatas
+ 4: S
+ A man, a plan, a canal: Panama!
+ 0: A man, a plan, a canal: Panama!
+ 1: <unset>
+ 2: <unset>
+ 3: A man, a plan, a canal: Panama
+ 4: A
+ Able was I ere I saw Elba.
+ 0: Able was I ere I saw Elba.
+ 1: <unset>
+ 2: <unset>
+ 3: Able was I ere I saw Elba
+ 4: A
+ *** Failers
+No match
+ The quick brown fox
+No match
+
+/^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/
+Capturing subpattern count = 2
+Options: anchored
+No first char
+No need char
+ 12
+ 0: 12
+ 1: 12
+ (((2+2)*-3)-7)
+ 0: (((2+2)*-3)-7)
+ 1: (((2+2)*-3)-7)
+ 2: -
+ -12
+ 0: -12
+ 1: -12
+ *** Failers
+No match
+ ((2+2)*-3)-7)
+No match
+
+/^(x(y|(?1){2})z)/
+Capturing subpattern count = 2
+Options: anchored
+No first char
+Need char = 'z'
+ xyz
+ 0: xyz
+ 1: xyz
+ 2: y
+ xxyzxyzz
+ 0: xxyzxyzz
+ 1: xxyzxyzz
+ 2: xyzxyz
+ *** Failers
+No match
+ xxyzz
+No match
+ xxyzxyzxyzz
+No match
+
+/((< (?: (?(R) \d++ | [^<>]*+) | (?2)) * >))/x
+Capturing subpattern count = 2
+Options: extended
+First char = '<'
+Need char = '>'
+ <>
+ 0: <>
+ 1: <>
+ 2: <>
+ <abcd>
+ 0: <abcd>
+ 1: <abcd>
+ 2: <abcd>
+ <abc <123> hij>
+ 0: <abc <123> hij>
+ 1: <abc <123> hij>
+ 2: <abc <123> hij>
+ <abc <def> hij>
+ 0: <def>
+ 1: <def>
+ 2: <def>
+ <abc<>def>
+ 0: <abc<>def>
+ 1: <abc<>def>
+ 2: <abc<>def>
+ <abc<>
+ 0: <>
+ 1: <>
+ 2: <>
+ *** Failers
+No match
+ <abc
+No match
+
+/(?1)/
+Failed: reference to non-existent subpattern at offset 3
+
+/((?2)(abc)/
+Failed: reference to non-existent subpattern at offset 4
+
+/^(abc)def(?1)/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = 'f'
+ abcdefabc
+ 0: abcdefabc
+ 1: abc
+
+/^(a|b|c)=(?1)+/
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = '='
+ a=a
+ 0: a=a
+ 1: a
+ a=b
+ 0: a=b
+ 1: a
+ a=bc
+ 0: a=bc
+ 1: a
+
+/^(a|b|c)=((?1))+/
+Capturing subpattern count = 2
+Options: anchored
+No first char
+Need char = '='
+ a=a
+ 0: a=a
+ 1: a
+ 2: a
+ a=b
+ 0: a=b
+ 1: a
+ 2: b
+ a=bc
+ 0: a=bc
+ 1: a
+ 2: c
+
+/a(?P<name1>b|c)d(?P<longername2>e)/D
+------------------------------------------------------------------
+ 0 33 Bra 0
+ 3 1 a
+ 6 6 Bra 1
+ 9 1 b
+ 12 6 Alt
+ 15 1 c
+ 18 12 Ket
+ 21 1 d
+ 24 6 Bra 2
+ 27 1 e
+ 30 6 Ket
+ 33 33 Ket
+ 36 End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+Named capturing subpatterns:
+ longername2 2
+ name1 1
+No options
+First char = 'a'
+Need char = 'e'
+ abde
+ 0: abde
+ 1: b
+ 2: e
+ acde
+ 0: acde
+ 1: c
+ 2: e
+
+/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/D
+------------------------------------------------------------------
+ 0 39 Bra 0
+ 3 24 Bra 0
+ 6 1 a
+ 9 15 Bra 1
+ 12 1 c
+ 15 6 Bra 2
+ 18 1 d
+ 21 6 Ket
+ 24 15 Ket
+ 27 24 Ket
+ 30 6 Bra 3
+ 33 1 a
+ 36 6 Ket
+ 39 39 Ket
+ 42 End
+------------------------------------------------------------------
+Capturing subpattern count = 3
+Named capturing subpatterns:
+ a 3
+ c 1
+ d 2
+No options
+First char = 'a'
+Need char = 'a'
+
+/(?P<a>a)...(?P=a)bbb(?P>a)d/D
+------------------------------------------------------------------
+ 0 29 Bra 0
+ 3 6 Bra 1
+ 6 1 a
+ 9 6 Ket
+ 12 Any
+ 13 Any
+ 14 Any
+ 15 \1
+ 18 3 bbb
+ 23 3 Recurse
+ 26 1 d
+ 29 29 Ket
+ 32 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Max back reference = 1
+Named capturing subpatterns:
+ a 1
+No options
+First char = 'a'
+Need char = 'd'
+
+/^\W*(?:(?P<one>(?P<two>.)\W*(?P>one)\W*(?P=two)|)|(?P<three>(?P<four>.)\W*(?P>three)\W*(?P=four)|\W*.\W*))\W*$/i
+Capturing subpattern count = 4
+Max back reference = 4
+Named capturing subpatterns:
+ four 4
+ one 1
+ three 3
+ two 2
+Options: anchored caseless
+No first char
+No need char
+ 1221
+ 0: 1221
+ 1: 1221
+ 2: 1
+ Satan, oscillate my metallic sonatas!
+ 0: Satan, oscillate my metallic sonatas!
+ 1: <unset>
+ 2: <unset>
+ 3: Satan, oscillate my metallic sonatas
+ 4: S
+ A man, a plan, a canal: Panama!
+ 0: A man, a plan, a canal: Panama!
+ 1: <unset>
+ 2: <unset>
+ 3: A man, a plan, a canal: Panama
+ 4: A
+ Able was I ere I saw Elba.
+ 0: Able was I ere I saw Elba.
+ 1: <unset>
+ 2: <unset>
+ 3: Able was I ere I saw Elba
+ 4: A
+ *** Failers
+No match
+ The quick brown fox
+No match
+
+/((?(R)a|b))\1(?1)?/
+Capturing subpattern count = 1
+Max back reference = 1
+No options
+No first char
+No need char
+ bb
+ 0: bb
+ 1: b
+ bbaa
+ 0: bba
+ 1: b
+
+/(.*)a/sI
+Capturing subpattern count = 1
+Options: anchored dotall
+No first char
+Need char = 'a'
+
+/(.*)a\1/sI
+Capturing subpattern count = 1
+Max back reference = 1
+Options: dotall
+No first char
+Need char = 'a'
+
+/(.*)a(b)\2/sI
+Capturing subpattern count = 2
+Max back reference = 2
+Options: anchored dotall
+No first char
+Need char = 'b'
+
+/((.*)a|(.*)b)z/sI
+Capturing subpattern count = 3
+Options: anchored dotall
+No first char
+Need char = 'z'
+
+/((.*)a|(.*)b)z\1/sI
+Capturing subpattern count = 3
+Max back reference = 1
+Options: dotall
+No first char
+Need char = 'z'
+
+/((.*)a|(.*)b)z\2/sI
+Capturing subpattern count = 3
+Max back reference = 2
+Options: dotall
+No first char
+Need char = 'z'
+
+/((.*)a|(.*)b)z\3/sI
+Capturing subpattern count = 3
+Max back reference = 3
+Options: dotall
+No first char
+Need char = 'z'
+
+/((.*)a|^(.*)b)z\3/sI
+Capturing subpattern count = 3
+Max back reference = 3
+Options: anchored dotall
+No first char
+Need char = 'z'
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a/sI
+Capturing subpattern count = 31
+Options: anchored dotall
+No first char
+No need char
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\31/sI
+Capturing subpattern count = 31
+Max back reference = 31
+Options: dotall
+No first char
+No need char
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\32/sI
+Capturing subpattern count = 32
+Max back reference = 32
+Options: dotall
+No first char
+No need char
+
+/(a)(bc)/ND
+------------------------------------------------------------------
+ 0 22 Bra 0
+ 3 6 Bra 0
+ 6 1 a
+ 9 6 Ket
+ 12 7 Bra 0
+ 15 2 bc
+ 19 7 Ket
+ 22 22 Ket
+ 25 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options:
+First char = 'a'
+Need char = 'c'
+ abc
+ 0: abc
+
+/(?P<one>a)(bc)/ND
+------------------------------------------------------------------
+ 0 22 Bra 0
+ 3 6 Bra 1
+ 6 1 a
+ 9 6 Ket
+ 12 7 Bra 0
+ 15 2 bc
+ 19 7 Ket
+ 22 22 Ket
+ 25 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Named capturing subpatterns:
+ one 1
+Options:
+First char = 'a'
+Need char = 'c'
+ abc
+ 0: abc
+ 1: a
+
+/(a)(?P<named>bc)/ND
+------------------------------------------------------------------
+ 0 22 Bra 0
+ 3 6 Bra 0
+ 6 1 a
+ 9 6 Ket
+ 12 7 Bra 1
+ 15 2 bc
+ 19 7 Ket
+ 22 22 Ket
+ 25 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Named capturing subpatterns:
+ named 1
+Options:
+First char = 'a'
+Need char = 'c'
+
+/(a+)*zz/
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'z'
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzbbbbbb\M
+Minimum match limit = 8
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazz
+ 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaz\M
+Minimum match limit = 32768
+No match
+
+/(aaa(?C1)bbb|ab)/
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+ aaabbb
+--->aaabbb
+ 1 ^ ^
+ 0: aaabbb
+ 1: aaabbb
+ aaabbb\C*0
+--->aaabbb
+ 1 ^ ^
+ 0: aaabbb
+ 1: aaabbb
+ aaabbb\C*1
+--->aaabbb
+ 1 ^ ^
+Callout data = 1
+ 0: ab
+ 1: ab
+ aaabbb\C*-1
+--->aaabbb
+ 1 ^ ^
+Callout data = -1
+No match
+
+/ab(?P<one>cd)ef(?P<two>gh)/
+Capturing subpattern count = 2
+Named capturing subpatterns:
+ one 1
+ two 2
+No options
+First char = 'a'
+Need char = 'h'
+ abcdefgh
+ 0: abcdefgh
+ 1: cd
+ 2: gh
+ abcdefgh\C1\Gtwo
+ 0: abcdefgh
+ 1: cd
+ 2: gh
+ 1C cd (2)
+ 2G gh (2)
+ abcdefgh\Cone\Ctwo
+ 0: abcdefgh
+ 1: cd
+ 2: gh
+ 1C cd (2)
+ 2C gh (2)
+ abcdefgh\Cthree
+no parentheses with name "three"
+ 0: abcdefgh
+ 1: cd
+ 2: gh
+
+/(?P<Tes>)(?P<Test>)/D
+------------------------------------------------------------------
+ 0 15 Bra 0
+ 3 3 Bra 1
+ 6 3 Ket
+ 9 3 Bra 2
+ 12 3 Ket
+ 15 15 Ket
+ 18 End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+Named capturing subpatterns:
+ Tes 1
+ Test 2
+No options
+No first char
+No need char
+
+/(?P<Test>)(?P<Tes>)/D
+------------------------------------------------------------------
+ 0 15 Bra 0
+ 3 3 Bra 1
+ 6 3 Ket
+ 9 3 Bra 2
+ 12 3 Ket
+ 15 15 Ket
+ 18 End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+Named capturing subpatterns:
+ Tes 2
+ Test 1
+No options
+No first char
+No need char
+
+/(?P<Z>zz)(?P<A>aa)/
+Capturing subpattern count = 2
+Named capturing subpatterns:
+ A 2
+ Z 1
+No options
+First char = 'z'
+Need char = 'a'
+ zzaa\CZ
+ 0: zzaa
+ 1: zz
+ 2: aa
+ 1C zz (2)
+ zzaa\CA
+ 0: zzaa
+ 1: zz
+ 2: aa
+ 2C aa (2)
+
/ End of testinput2 /
Capturing subpattern count = 0
No options
diff --git a/testdata/testoutput3 b/testdata/testoutput3
index cbe9aaa..6fdb681 100644
--- a/testdata/testoutput3
+++ b/testdata/testoutput3
@@ -1,2991 +1,118 @@
-PCRE version 3.9 02-Jan-2002
+PCRE version 4.0 17-Feb-2003
-/(?<!bar)foo/
- foo
- 0: foo
- catfood
- 0: foo
- arfootle
- 0: foo
- rfoosh
- 0: foo
+/^[\w]+/
*** Failers
No match
- barfoo
-No match
- towbarfoo
-No match
-
-/\w{3}(?<!bar)foo/
- catfood
- 0: catfoo
- *** Failers
-No match
- foo
-No match
- barfoo
-No match
- towbarfoo
-No match
-
-/(?<=(foo)a)bar/
- fooabar
- 0: bar
- 1: foo
- *** Failers
-No match
- bar
-No match
- foobbar
-No match
-
-/\Aabc\z/m
- abc
- 0: abc
- *** Failers
-No match
- abc\n
-No match
- qqq\nabc
-No match
- abc\nzzz
-No match
- qqq\nabc\nzzz
-No match
-
-"(?>.*/)foo"
- /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
-No match
-
-"(?>.*/)foo"
- /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
- 0: /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
-
-/(?>(\.\d\d[1-9]?))\d+/
- 1.230003938
- 0: .230003938
- 1: .23
- 1.875000282
- 0: .875000282
- 1: .875
- *** Failers
-No match
- 1.235
-No match
-
-/^((?>\w+)|(?>\s+))*$/
- now is the time for all good men to come to the aid of the party
- 0: now is the time for all good men to come to the aid of the party
- 1: party
- *** Failers
-No match
- this is not a line with only words and spaces!
-No match
-
-/(\d+)(\w)/
- 12345a
- 0: 12345a
- 1: 12345
- 2: a
- 12345+
- 0: 12345
- 1: 1234
- 2: 5
-
-/((?>\d+))(\w)/
- 12345a
- 0: 12345a
- 1: 12345
- 2: a
- *** Failers
-No match
- 12345+
-No match
-
-/(?>a+)b/
- aaab
- 0: aaab
-
-/((?>a+)b)/
- aaab
- 0: aaab
- 1: aaab
-
-/(?>(a+))b/
- aaab
- 0: aaab
- 1: aaa
-
-/(?>b)+/
- aaabbbccc
- 0: bbb
-
-/(?>a+|b+|c+)*c/
- aaabbbbccccd
- 0: aaabbbbc
-
-/((?>[^()]+)|\([^()]*\))+/
- ((abc(ade)ufh()()x
- 0: abc(ade)ufh()()x
- 1: x
-
-/\(((?>[^()]+)|\([^()]+\))+\)/
- (abc)
- 0: (abc)
- 1: abc
- (abc(def)xyz)
- 0: (abc(def)xyz)
- 1: xyz
- *** Failers
-No match
- ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-No match
-
-/a(?-i)b/i
- ab
- 0: ab
- *** Failers
-No match
- Ab
-No match
- aB
-No match
- AB
-No match
-
-/(a (?x)b c)d e/
- a bcd e
- 0: a bcd e
- 1: a bc
- *** Failers
-No match
- a b cd e
-No match
- abcd e
-No match
- a bcde
-No match
-
-/(a b(?x)c d (?-x)e f)/
- a bcde f
- 0: a bcde f
- 1: a bcde f
- *** Failers
-No match
- abcdef
-No match
-
-/(a(?i)b)c/
- abc
- 0: abc
- 1: ab
- aBc
- 0: aBc
- 1: aB
- *** Failers
-No match
- abC
-No match
- aBC
-No match
- Abc
-No match
- ABc
-No match
- ABC
-No match
- AbC
-No match
-
-/a(?i:b)c/
- abc
- 0: abc
- aBc
- 0: aBc
- *** Failers
-No match
- ABC
-No match
- abC
-No match
- aBC
-No match
-
-/a(?i:b)*c/
- aBc
- 0: aBc
- aBBc
- 0: aBBc
- *** Failers
-No match
- aBC
-No match
- aBBC
-No match
-
-/a(?=b(?i)c)\w\wd/
- abcd
- 0: abcd
- abCd
- 0: abCd
- *** Failers
-No match
- aBCd
-No match
- abcD
-No match
-
-/(?s-i:more.*than).*million/i
- more than million
- 0: more than million
- more than MILLION
- 0: more than MILLION
- more \n than Million
- 0: more \x0a than Million
- *** Failers
-No match
- MORE THAN MILLION
-No match
- more \n than \n million
-No match
-
-/(?:(?s-i)more.*than).*million/i
- more than million
- 0: more than million
- more than MILLION
- 0: more than MILLION
- more \n than Million
- 0: more \x0a than Million
- *** Failers
-No match
- MORE THAN MILLION
-No match
- more \n than \n million
-No match
-
-/(?>a(?i)b+)+c/
- abc
- 0: abc
- aBbc
- 0: aBbc
- aBBc
- 0: aBBc
- *** Failers
-No match
- Abc
-No match
- abAb
-No match
- abbC
-No match
-
-/(?=a(?i)b)\w\wc/
- abc
- 0: abc
- aBc
- 0: aBc
- *** Failers
-No match
- Ab
-No match
- abC
-No match
- aBC
-No match
-
-/(?<=a(?i)b)(\w\w)c/
- abxxc
- 0: xxc
- 1: xx
- aBxxc
- 0: xxc
- 1: xx
- *** Failers
-No match
- Abxxc
-No match
- ABxxc
-No match
- abxxC
-No match
-
-/(?:(a)|b)(?(1)A|B)/
- aA
- 0: aA
- 1: a
- bB
- 0: bB
- *** Failers
-No match
- aB
-No match
- bA
-No match
-
-/^(a)?(?(1)a|b)+$/
- aa
- 0: aa
- 1: a
- b
- 0: b
- bb
- 0: bb
- *** Failers
-No match
- ab
-No match
-
-/^(?(?=abc)\w{3}:|\d\d)$/
- abc:
- 0: abc:
- 12
- 0: 12
- *** Failers
-No match
- 123
-No match
- xyz
-No match
-
-/^(?(?!abc)\d\d|\w{3}:)$/
- abc:
- 0: abc:
- 12
- 0: 12
- *** Failers
-No match
- 123
-No match
- xyz
-No match
-
-/(?(?<=foo)bar|cat)/
- foobar
- 0: bar
- cat
- 0: cat
- fcat
- 0: cat
- focat
- 0: cat
- *** Failers
-No match
- foocat
-No match
-
-/(?(?<!foo)cat|bar)/
- foobar
- 0: bar
- cat
- 0: cat
- fcat
- 0: cat
- focat
- 0: cat
- *** Failers
-No match
- foocat
-No match
-
-/( \( )? [^()]+ (?(1) \) |) /x
- abcd
- 0: abcd
- (abcd)
- 0: (abcd)
- 1: (
- the quick (abcd) fox
- 0: the quick
- (abcd
- 0: abcd
-
-/( \( )? [^()]+ (?(1) \) ) /x
- abcd
- 0: abcd
- (abcd)
- 0: (abcd)
- 1: (
- the quick (abcd) fox
- 0: the quick
- (abcd
- 0: abcd
-
-/^(?(2)a|(1)(2))+$/
- 12
- 0: 12
- 1: 1
- 2: 2
- 12a
- 0: 12a
- 1: 1
- 2: 2
- 12aa
- 0: 12aa
- 1: 1
- 2: 2
- *** Failers
-No match
- 1234
-No match
-
-/((?i)blah)\s+\1/
- blah blah
- 0: blah blah
- 1: blah
- BLAH BLAH
- 0: BLAH BLAH
- 1: BLAH
- Blah Blah
- 0: Blah Blah
- 1: Blah
- blaH blaH
- 0: blaH blaH
- 1: blaH
- *** Failers
-No match
- blah BLAH
-No match
- Blah blah
-No match
- blaH blah
-No match
-
-/((?i)blah)\s+(?i:\1)/
- blah blah
- 0: blah blah
- 1: blah
- BLAH BLAH
- 0: BLAH BLAH
- 1: BLAH
- Blah Blah
- 0: Blah Blah
- 1: Blah
- blaH blaH
- 0: blaH blaH
- 1: blaH
- blah BLAH
- 0: blah BLAH
- 1: blah
- Blah blah
- 0: Blah blah
- 1: Blah
- blaH blah
- 0: blaH blah
- 1: blaH
-
-/(?>a*)*/
- a
- 0: a
- aa
- 0: aa
- aaaa
- 0: aaaa
-
-/(abc|)+/
- abc
- 0: abc
- 1:
- abcabc
- 0: abcabc
- 1:
- abcabcabc
- 0: abcabcabc
- 1:
- xyz
- 0:
- 1:
-
-/([a]*)*/
- a
- 0: a
- 1:
- aaaaa
- 0: aaaaa
- 1:
-
-/([ab]*)*/
- a
- 0: a
- 1:
- b
- 0: b
- 1:
- ababab
- 0: ababab
- 1:
- aaaabcde
- 0: aaaab
- 1:
- bbbb
- 0: bbbb
- 1:
-
-/([^a]*)*/
- b
- 0: b
- 1:
- bbbb
- 0: bbbb
- 1:
- aaa
- 0:
- 1:
-
-/([^ab]*)*/
- cccc
- 0: cccc
- 1:
- abab
- 0:
- 1:
-
-/([a]*?)*/
- a
- 0:
- 1:
- aaaa
- 0:
- 1:
-
-/([ab]*?)*/
- a
- 0:
- 1:
- b
- 0:
- 1:
- abab
- 0:
- 1:
- baba
- 0:
- 1:
-
-/([^a]*?)*/
- b
- 0:
- 1:
- bbbb
- 0:
- 1:
- aaa
- 0:
- 1:
-
-/([^ab]*?)*/
- c
- 0:
- 1:
- cccc
- 0:
- 1:
- baba
- 0:
- 1:
-
-/(?>a*)*/
- a
- 0: a
- aaabcde
- 0: aaa
-
-/((?>a*))*/
- aaaaa
- 0: aaaaa
- 1:
- aabbaa
- 0: aa
- 1:
-
-/((?>a*?))*/
- aaaaa
- 0:
- 1:
- aabbaa
- 0:
- 1:
-
-/(?(?=[^a-z]+[a-z]) \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} ) /x
- 12-sep-98
- 0: 12-sep-98
- 12-09-98
- 0: 12-09-98
- *** Failers
-No match
- sep-12-98
-No match
-
-/(?<=(foo))bar\1/
- foobarfoo
- 0: barfoo
- 1: foo
- foobarfootling
- 0: barfoo
- 1: foo
- *** Failers
-No match
- foobar
-No match
- barfoo
-No match
-
-/(?i:saturday|sunday)/
- saturday
- 0: saturday
- sunday
- 0: sunday
- Saturday
- 0: Saturday
- Sunday
- 0: Sunday
- SATURDAY
- 0: SATURDAY
- SUNDAY
- 0: SUNDAY
- SunDay
- 0: SunDay
-
-/(a(?i)bc|BB)x/
- abcx
- 0: abcx
- 1: abc
- aBCx
- 0: aBCx
- 1: aBC
- bbx
- 0: bbx
- 1: bb
- BBx
- 0: BBx
- 1: BB
- *** Failers
-No match
- abcX
-No match
- aBCX
-No match
- bbX
-No match
- BBX
-No match
-
-/^([ab](?i)[cd]|[ef])/
- ac
- 0: ac
- 1: ac
- aC
- 0: aC
- 1: aC
- bD
- 0: bD
- 1: bD
- elephant
- 0: e
- 1: e
- Europe
- 0: E
- 1: E
- frog
- 0: f
- 1: f
- France
- 0: F
- 1: F
- *** Failers
-No match
- Africa
-No match
-
-/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
- ab
- 0: ab
- 1: ab
- aBd
- 0: aBd
- 1: aBd
- xy
- 0: xy
- 1: xy
- xY
- 0: xY
- 1: xY
- zebra
- 0: z
- 1: z
- Zambesi
- 0: Z
- 1: Z
- *** Failers
-No match
- aCD
-No match
- XY
-No match
-
-/(?<=foo\n)^bar/m
- foo\nbar
- 0: bar
- *** Failers
-No match
- bar
-No match
- baz\nbar
-No match
-
-/(?<=(?<!foo)bar)baz/
- barbaz
- 0: baz
- barbarbaz
- 0: baz
- koobarbaz
- 0: baz
- *** Failers
-No match
- baz
-No match
- foobarbaz
-No match
-
-/The case of aaaaaa is missed out below because I think Perl 5.005_02 gets/
-/it wrong; it sets $1 to aaa rather than aa. Compare the following test,/
-No match
-/where it does set $1 to aa when matching aaaaaa./
-No match
-
-/^(a\1?){4}$/
- a
-No match
- aa
-No match
- aaa
-No match
- aaaa
- 0: aaaa
- 1: a
- aaaaa
- 0: aaaaa
- 1: a
- aaaaaaa
- 0: aaaaaaa
- 1: a
- aaaaaaaa
-No match
- aaaaaaaaa
-No match
- aaaaaaaaaa
- 0: aaaaaaaaaa
- 1: aaaa
- aaaaaaaaaaa
-No match
- aaaaaaaaaaaa
-No match
- aaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaaaa
-No match
-
-/^(a\1?)(a\1?)(a\2?)(a\3?)$/
- a
-No match
- aa
-No match
- aaa
-No match
- aaaa
- 0: aaaa
- 1: a
- 2: a
- 3: a
- 4: a
- aaaaa
- 0: aaaaa
- 1: a
- 2: aa
- 3: a
- 4: a
- aaaaaa
- 0: aaaaaa
- 1: a
- 2: aa
- 3: a
- 4: aa
- aaaaaaa
- 0: aaaaaaa
- 1: a
- 2: aa
- 3: aaa
- 4: a
- aaaaaaaa
-No match
- aaaaaaaaa
-No match
- aaaaaaaaaa
- 0: aaaaaaaaaa
- 1: a
- 2: aa
- 3: aaa
- 4: aaaa
- aaaaaaaaaaa
-No match
- aaaaaaaaaaaa
-No match
- aaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaaa
-No match
- aaaaaaaaaaaaaaaa
-No match
-
-/The following tests are taken from the Perl 5.005 test suite; some of them/
-/are compatible with 5.004, but I'd rather not have to sort them out./
-No match
-
-/abc/
- abc
- 0: abc
- xabcy
- 0: abc
- ababc
- 0: abc
- *** Failers
-No match
- xbc
-No match
- axc
-No match
- abx
-No match
-
-/ab*c/
- abc
- 0: abc
-
-/ab*bc/
- abc
- 0: abc
- abbc
- 0: abbc
- abbbbc
- 0: abbbbc
-
-/.{1}/
- abbbbc
- 0: a
-
-/.{3,4}/
- abbbbc
- 0: abbb
-
-/ab{0,}bc/
- abbbbc
- 0: abbbbc
-
-/ab+bc/
- abbc
- 0: abbc
- *** Failers
-No match
- abc
-No match
- abq
-No match
-
-/ab{1,}bc/
-
-/ab+bc/
- abbbbc
- 0: abbbbc
-
-/ab{1,}bc/
- abbbbc
- 0: abbbbc
-
-/ab{1,3}bc/
- abbbbc
- 0: abbbbc
-
-/ab{3,4}bc/
- abbbbc
- 0: abbbbc
-
-/ab{4,5}bc/
- *** Failers
-No match
- abq
-No match
- abbbbc
-No match
-
-/ab?bc/
- abbc
- 0: abbc
- abc
- 0: abc
-
-/ab{0,1}bc/
- abc
- 0: abc
-
-/ab?bc/
-
-/ab?c/
- abc
- 0: abc
-
-/ab{0,1}c/
- abc
- 0: abc
-
-/^abc$/
- abc
- 0: abc
- *** Failers
-No match
- abbbbc
-No match
- abcc
+ École
No match
-/^abc/
- abcc
- 0: abc
+/^[\w]+/Lfr
+ École
+ 0: École
-/^abc$/
-
-/abc$/
- aabc
- 0: abc
- *** Failers
-No match
- aabc
- 0: abc
- aabcd
-No match
-
-/^/
- abc
- 0:
-
-/$/
- abc
- 0:
-
-/a.c/
- abc
- 0: abc
- axc
- 0: axc
-
-/a.*c/
- axyzc
- 0: axyzc
-
-/a[bc]d/
- abd
- 0: abd
- *** Failers
-No match
- axyzd
-No match
- abc
-No match
-
-/a[b-d]e/
- ace
- 0: ace
-
-/a[b-d]/
- aac
- 0: ac
-
-/a[-b]/
- a-
- 0: a-
-
-/a[b-]/
- a-
- 0: a-
-
-/a]/
- a]
- 0: a]
-
-/a[]]b/
- a]b
- 0: a]b
-
-/a[^bc]d/
- aed
- 0: aed
- *** Failers
-No match
- abd
-No match
- abd
-No match
-
-/a[^-b]c/
- adc
- 0: adc
-
-/a[^]b]c/
- adc
- 0: adc
+/^[\w]+/
*** Failers
No match
- a-c
- 0: a-c
- a]c
+ École
No match
-/\ba\b/
- a-
- 0: a
- -a
- 0: a
- -a-
- 0: a
+/^[\W]+/
+ École
+ 0: \xc9
-/\by\b/
+/^[\W]+/Lfr
*** Failers
-No match
- xy
-No match
- yz
-No match
- xyz
+ 0: ***
+ École
No match
-/\Ba\B/
+/[\b]/
+ \b
+ 0: \x08
*** Failers
- 0: a
- a-
No match
- -a
-No match
- -a-
-No match
-
-/\By\b/
- xy
- 0: y
-
-/\by\B/
- yz
- 0: y
-
-/\By\B/
- xyz
- 0: y
-
-/\w/
- a
- 0: a
-
-/\W/
- -
- 0: -
- *** Failers
- 0: *
- -
- 0: -
- a
-No match
-
-/a\sb/
- a b
- 0: a b
-
-/a\Sb/
- a-b
- 0: a-b
- *** Failers
-No match
- a-b
- 0: a-b
- a b
-No match
-
-/\d/
- 1
- 0: 1
-
-/\D/
- -
- 0: -
- *** Failers
- 0: *
- -
- 0: -
- 1
-No match
-
-/[\w]/
a
- 0: a
-
-/[\W]/
- -
- 0: -
- *** Failers
- 0: *
- -
- 0: -
- a
-No match
-
-/a[\s]b/
- a b
- 0: a b
-
-/a[\S]b/
- a-b
- 0: a-b
- *** Failers
-No match
- a-b
- 0: a-b
- a b
-No match
-
-/[\d]/
- 1
- 0: 1
-
-/[\D]/
- -
- 0: -
- *** Failers
- 0: *
- -
- 0: -
- 1
-No match
-
-/ab|cd/
- abc
- 0: ab
- abcd
- 0: ab
-
-/()ef/
- def
- 0: ef
- 1:
-
-/$b/
-
-/a\(b/
- a(b
- 0: a(b
-
-/a\(*b/
- ab
- 0: ab
- a((b
- 0: a((b
-
-/a\\b/
- a\b
-No match
-
-/((a))/
- abc
- 0: a
- 1: a
- 2: a
-
-/(a)b(c)/
- abc
- 0: abc
- 1: a
- 2: c
-
-/a+b+c/
- aabbabc
- 0: abc
-
-/a{1,}b{1,}c/
- aabbabc
- 0: abc
-
-/a.+?c/
- abcabc
- 0: abc
-
-/(a+|b)*/
- ab
- 0: ab
- 1: b
-
-/(a+|b){0,}/
- ab
- 0: ab
- 1: b
-
-/(a+|b)+/
- ab
- 0: ab
- 1: b
-
-/(a+|b){1,}/
- ab
- 0: ab
- 1: b
-
-/(a+|b)?/
- ab
- 0: a
- 1: a
-
-/(a+|b){0,1}/
- ab
- 0: a
- 1: a
-
-/[^ab]*/
- cde
- 0: cde
-
-/abc/
- *** Failers
-No match
- b
-No match
-
-
-/a*/
-
-
-/([abc])*d/
- abbbcd
- 0: abbbcd
- 1: c
-
-/([abc])*bcd/
- abcd
- 0: abcd
- 1: a
-
-/a|b|c|d|e/
- e
- 0: e
-
-/(a|b|c|d|e)f/
- ef
- 0: ef
- 1: e
-
-/abcd*efg/
- abcdefg
- 0: abcdefg
-
-/ab*/
- xabyabbbz
- 0: ab
- xayabbbz
- 0: a
-
-/(ab|cd)e/
- abcde
- 0: cde
- 1: cd
-
-/[abhgefdc]ij/
- hij
- 0: hij
-
-/^(ab|cd)e/
-
-/(abc|)ef/
- abcdef
- 0: ef
- 1:
-
-/(a|b)c*d/
- abcd
- 0: bcd
- 1: b
-
-/(ab|ab*)bc/
- abc
- 0: abc
- 1: a
-
-/a([bc]*)c*/
- abc
- 0: abc
- 1: bc
-
-/a([bc]*)(c*d)/
- abcd
- 0: abcd
- 1: bc
- 2: d
-
-/a([bc]+)(c*d)/
- abcd
- 0: abcd
- 1: bc
- 2: d
-
-/a([bc]*)(c+d)/
- abcd
- 0: abcd
- 1: b
- 2: cd
-
-/a[bcd]*dcdcde/
- adcdcde
- 0: adcdcde
-
-/a[bcd]+dcdcde/
- *** Failers
-No match
- abcde
No match
- adcdcde
-No match
-
-/(ab|a)b*c/
- abc
- 0: abc
- 1: ab
-
-/((a)(b)c)(d)/
- abcd
- 0: abcd
- 1: abc
- 2: a
- 3: b
- 4: d
-/[a-zA-Z_][a-zA-Z0-9_]*/
- alpha
- 0: alpha
-
-/^a(bc+|b[eh])g|.h$/
- abh
- 0: bh
-
-/(bc+d$|ef*g.|h?i(j|k))/
- effgz
- 0: effgz
- 1: effgz
- ij
- 0: ij
- 1: ij
- 2: j
- reffgz
- 0: effgz
- 1: effgz
+/[\b]/Lfr
+ \b
+ 0: \x08
*** Failers
No match
- effg
-No match
- bcdd
-No match
-
-/((((((((((a))))))))))/
- a
- 0: a
- 1: a
- 2: a
- 3: a
- 4: a
- 5: a
- 6: a
- 7: a
- 8: a
- 9: a
-10: a
-
-/((((((((((a))))))))))\10/
- aa
- 0: aa
- 1: a
- 2: a
- 3: a
- 4: a
- 5: a
- 6: a
- 7: a
- 8: a
- 9: a
-10: a
-
-/(((((((((a)))))))))/
- a
- 0: a
- 1: a
- 2: a
- 3: a
- 4: a
- 5: a
- 6: a
- 7: a
- 8: a
- 9: a
-
-/multiple words of text/
- *** Failers
-No match
- aa
-No match
- uh-uh
-No match
-
-/multiple words/
- multiple words, yeah
- 0: multiple words
-
-/(.*)c(.*)/
- abcde
- 0: abcde
- 1: ab
- 2: de
-
-/\((.*), (.*)\)/
- (a, b)
- 0: (a, b)
- 1: a
- 2: b
-
-/[k]/
-
-/abcd/
- abcd
- 0: abcd
-
-/a(bc)d/
- abcd
- 0: abcd
- 1: bc
-
-/a[-]?c/
- ac
- 0: ac
-
-/(abc)\1/
- abcabc
- 0: abcabc
- 1: abc
-
-/([a-c]*)\1/
- abcabc
- 0: abcabc
- 1: abc
-
-/(a)|\1/
a
- 0: a
- 1: a
- *** Failers
- 0: a
- 1: a
- ab
- 0: a
- 1: a
- x
No match
-/(([a-c])b*?\2)*/
- ababbbcbc
- 0: ababb
- 1: bb
- 2: b
-
-/(([a-c])b*?\2){3}/
- ababbbcbc
- 0: ababbbcbc
- 1: cbc
- 2: c
-
-/((\3|b)\2(a)x)+/
- aaaxabaxbaaxbbax
- 0: bbax
- 1: bbax
- 2: b
- 3: a
-
-/((\3|b)\2(a)){2,}/
- bbaababbabaaaaabbaaaabba
- 0: bbaaaabba
- 1: bba
- 2: b
- 3: a
-
-/abc/i
- ABC
- 0: ABC
- XABCY
- 0: ABC
- ABABC
- 0: ABC
+/^\w+/
*** Failers
No match
- aaxabxbaxbbx
-No match
- XBC
-No match
- AXC
+ École
No match
- ABX
-No match
-
-/ab*c/i
- ABC
- 0: ABC
-
-/ab*bc/i
- ABC
- 0: ABC
- ABBC
- 0: ABBC
-/ab*?bc/i
- ABBBBC
- 0: ABBBBC
+/^\w+/Lfr
+ École
+ 0: École
-/ab{0,}?bc/i
- ABBBBC
- 0: ABBBBC
+/(.+)\b(.+)/
+ École
+ 0: \xc9cole
+ 1: \xc9
+ 2: cole
-/ab+?bc/i
- ABBC
- 0: ABBC
-
-/ab+bc/i
+/(.+)\b(.+)/Lfr
*** Failers
-No match
- ABC
-No match
- ABQ
-No match
-
-/ab{1,}bc/i
-
-/ab+bc/i
- ABBBBC
- 0: ABBBBC
-
-/ab{1,}?bc/i
- ABBBBC
- 0: ABBBBC
-
-/ab{1,3}?bc/i
- ABBBBC
- 0: ABBBBC
-
-/ab{3,4}?bc/i
- ABBBBC
- 0: ABBBBC
-
-/ab{4,5}?bc/i
- *** Failers
-No match
- ABQ
-No match
- ABBBBC
-No match
-
-/ab??bc/i
- ABBC
- 0: ABBC
- ABC
- 0: ABC
-
-/ab{0,1}?bc/i
- ABC
- 0: ABC
-
-/ab??bc/i
-
-/ab??c/i
- ABC
- 0: ABC
-
-/ab{0,1}?c/i
- ABC
- 0: ABC
-
-/^abc$/i
- ABC
- 0: ABC
- *** Failers
-No match
- ABBBBC
-No match
- ABCC
-No match
-
-/^abc/i
- ABCC
- 0: ABC
-
-/^abc$/i
-
-/abc$/i
- AABC
- 0: ABC
-
-/^/i
- ABC
- 0:
-
-/$/i
- ABC
- 0:
-
-/a.c/i
- ABC
- 0: ABC
- AXC
- 0: AXC
-
-/a.*?c/i
- AXYZC
- 0: AXYZC
-
-/a.*c/i
- *** Failers
-No match
- AABC
- 0: AABC
- AXYZD
-No match
-
-/a[bc]d/i
- ABD
- 0: ABD
-
-/a[b-d]e/i
- ACE
- 0: ACE
- *** Failers
-No match
- ABC
-No match
- ABD
-No match
-
-/a[b-d]/i
- AAC
- 0: AC
-
-/a[-b]/i
- A-
- 0: A-
-
-/a[b-]/i
- A-
- 0: A-
-
-/a]/i
- A]
- 0: A]
-
-/a[]]b/i
- A]B
- 0: A]B
-
-/a[^bc]d/i
- AED
- 0: AED
-
-/a[^-b]c/i
- ADC
- 0: ADC
- *** Failers
-No match
- ABD
-No match
- A-C
-No match
-
-/a[^]b]c/i
- ADC
- 0: ADC
-
-/ab|cd/i
- ABC
- 0: AB
- ABCD
- 0: AB
-
-/()ef/i
- DEF
- 0: EF
- 1:
-
-/$b/i
- *** Failers
-No match
- A]C
-No match
- B
-No match
-
-/a\(b/i
- A(B
- 0: A(B
-
-/a\(*b/i
- AB
- 0: AB
- A((B
- 0: A((B
-
-/a\\b/i
- A\B
-No match
-
-/((a))/i
- ABC
- 0: A
- 1: A
- 2: A
-
-/(a)b(c)/i
- ABC
- 0: ABC
- 1: A
- 2: C
-
-/a+b+c/i
- AABBABC
- 0: ABC
-
-/a{1,}b{1,}c/i
- AABBABC
- 0: ABC
-
-/a.+?c/i
- ABCABC
- 0: ABC
-
-/a.*?c/i
- ABCABC
- 0: ABC
-
-/a.{0,5}?c/i
- ABCABC
- 0: ABC
-
-/(a+|b)*/i
- AB
- 0: AB
- 1: B
-
-/(a+|b){0,}/i
- AB
- 0: AB
- 1: B
-
-/(a+|b)+/i
- AB
- 0: AB
- 1: B
-
-/(a+|b){1,}/i
- AB
- 0: AB
- 1: B
-
-/(a+|b)?/i
- AB
- 0: A
- 1: A
-
-/(a+|b){0,1}/i
- AB
- 0: A
- 1: A
-
-/(a+|b){0,1}?/i
- AB
- 0:
-
-/[^ab]*/i
- CDE
- 0: CDE
-
-/abc/i
-
-/a*/i
-
-
-/([abc])*d/i
- ABBBCD
- 0: ABBBCD
- 1: C
-
-/([abc])*bcd/i
- ABCD
- 0: ABCD
- 1: A
-
-/a|b|c|d|e/i
- E
- 0: E
-
-/(a|b|c|d|e)f/i
- EF
- 0: EF
- 1: E
-
-/abcd*efg/i
- ABCDEFG
- 0: ABCDEFG
-
-/ab*/i
- XABYABBBZ
- 0: AB
- XAYABBBZ
- 0: A
-
-/(ab|cd)e/i
- ABCDE
- 0: CDE
- 1: CD
-
-/[abhgefdc]ij/i
- HIJ
- 0: HIJ
-
-/^(ab|cd)e/i
- ABCDE
-No match
-
-/(abc|)ef/i
- ABCDEF
- 0: EF
- 1:
-
-/(a|b)c*d/i
- ABCD
- 0: BCD
- 1: B
-
-/(ab|ab*)bc/i
- ABC
- 0: ABC
- 1: A
-
-/a([bc]*)c*/i
- ABC
- 0: ABC
- 1: BC
-
-/a([bc]*)(c*d)/i
- ABCD
- 0: ABCD
- 1: BC
- 2: D
-
-/a([bc]+)(c*d)/i
- ABCD
- 0: ABCD
- 1: BC
- 2: D
-
-/a([bc]*)(c+d)/i
- ABCD
- 0: ABCD
- 1: B
- 2: CD
-
-/a[bcd]*dcdcde/i
- ADCDCDE
- 0: ADCDCDE
-
-/a[bcd]+dcdcde/i
-
-/(ab|a)b*c/i
- ABC
- 0: ABC
- 1: AB
-
-/((a)(b)c)(d)/i
- ABCD
- 0: ABCD
- 1: ABC
- 2: A
- 3: B
- 4: D
-
-/[a-zA-Z_][a-zA-Z0-9_]*/i
- ALPHA
- 0: ALPHA
-
-/^a(bc+|b[eh])g|.h$/i
- ABH
- 0: BH
-
-/(bc+d$|ef*g.|h?i(j|k))/i
- EFFGZ
- 0: EFFGZ
- 1: EFFGZ
- IJ
- 0: IJ
- 1: IJ
- 2: J
- REFFGZ
- 0: EFFGZ
- 1: EFFGZ
- *** Failers
-No match
- ADCDCDE
-No match
- EFFG
-No match
- BCDD
-No match
-
-/((((((((((a))))))))))/i
- A
- 0: A
- 1: A
- 2: A
- 3: A
- 4: A
- 5: A
- 6: A
- 7: A
- 8: A
- 9: A
-10: A
-
-/((((((((((a))))))))))\10/i
- AA
- 0: AA
- 1: A
- 2: A
- 3: A
- 4: A
- 5: A
- 6: A
- 7: A
- 8: A
- 9: A
-10: A
-
-/(((((((((a)))))))))/i
- A
- 0: A
- 1: A
- 2: A
- 3: A
- 4: A
- 5: A
- 6: A
- 7: A
- 8: A
- 9: A
-
-/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
- A
- 0: A
- 1: A
-
-/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
- C
- 0: C
- 1: C
-
-/multiple words of text/i
- *** Failers
-No match
- AA
-No match
- UH-UH
-No match
-
-/multiple words/i
- MULTIPLE WORDS, YEAH
- 0: MULTIPLE WORDS
-
-/(.*)c(.*)/i
- ABCDE
- 0: ABCDE
- 1: AB
- 2: DE
-
-/\((.*), (.*)\)/i
- (A, B)
- 0: (A, B)
- 1: A
- 2: B
-
-/[k]/i
-
-/abcd/i
- ABCD
- 0: ABCD
-
-/a(bc)d/i
- ABCD
- 0: ABCD
- 1: BC
-
-/a[-]?c/i
- AC
- 0: AC
-
-/(abc)\1/i
- ABCABC
- 0: ABCABC
- 1: ABC
-
-/([a-c]*)\1/i
- ABCABC
- 0: ABCABC
- 1: ABC
-
-/a(?!b)./
- abad
- 0: ad
-
-/a(?=d)./
- abad
- 0: ad
-
-/a(?=c|d)./
- abad
- 0: ad
-
-/a(?:b|c|d)(.)/
- ace
- 0: ace
- 1: e
-
-/a(?:b|c|d)*(.)/
- ace
- 0: ace
- 1: e
-
-/a(?:b|c|d)+?(.)/
- ace
- 0: ace
- 1: e
- acdbcdbe
- 0: acd
- 1: d
-
-/a(?:b|c|d)+(.)/
- acdbcdbe
- 0: acdbcdbe
- 1: e
-
-/a(?:b|c|d){2}(.)/
- acdbcdbe
- 0: acdb
- 1: b
-
-/a(?:b|c|d){4,5}(.)/
- acdbcdbe
- 0: acdbcdb
- 1: b
-
-/a(?:b|c|d){4,5}?(.)/
- acdbcdbe
- 0: acdbcd
- 1: d
-
-/((foo)|(bar))*/
- foobar
- 0: foobar
- 1: bar
- 2: foo
- 3: bar
-
-/a(?:b|c|d){6,7}(.)/
- acdbcdbe
- 0: acdbcdbe
- 1: e
-
-/a(?:b|c|d){6,7}?(.)/
- acdbcdbe
- 0: acdbcdbe
- 1: e
-
-/a(?:b|c|d){5,6}(.)/
- acdbcdbe
- 0: acdbcdbe
- 1: e
-
-/a(?:b|c|d){5,6}?(.)/
- acdbcdbe
- 0: acdbcdb
- 1: b
-
-/a(?:b|c|d){5,7}(.)/
- acdbcdbe
- 0: acdbcdbe
- 1: e
-
-/a(?:b|c|d){5,7}?(.)/
- acdbcdbe
- 0: acdbcdb
- 1: b
-
-/a(?:b|(c|e){1,2}?|d)+?(.)/
- ace
- 0: ace
- 1: c
- 2: e
-
-/^(.+)?B/
- AB
- 0: AB
- 1: A
-
-/^([^a-z])|(\^)$/
- .
- 0: .
- 1: .
-
-/^[<>]&/
- <&OUT
- 0: <&
-
-/^(a\1?){4}$/
- aaaaaaaaaa
- 0: aaaaaaaaaa
- 1: aaaa
- *** Failers
-No match
- AB
-No match
- aaaaaaaaa
-No match
- aaaaaaaaaaa
-No match
-
-/^(a(?(1)\1)){4}$/
- aaaaaaaaaa
- 0: aaaaaaaaaa
- 1: aaaa
- *** Failers
-No match
- aaaaaaaaa
-No match
- aaaaaaaaaaa
-No match
-
-/(?:(f)(o)(o)|(b)(a)(r))*/
- foobar
- 0: foobar
- 1: f
- 2: o
- 3: o
- 4: b
- 5: a
- 6: r
-
-/(?<=a)b/
- ab
- 0: b
- *** Failers
-No match
- cb
-No match
- b
-No match
-
-/(?<!c)b/
- ab
- 0: b
- b
- 0: b
- b
- 0: b
-
-/(?:..)*a/
- aba
- 0: aba
-
-/(?:..)*?a/
- aba
- 0: a
-
-/^(?:b|a(?=(.)))*\1/
- abc
- 0: ab
- 1: b
-
-/^(){3,5}/
- abc
- 0:
- 1:
-
-/^(a+)*ax/
- aax
- 0: aax
- 1: a
-
-/^((a|b)+)*ax/
- aax
- 0: aax
- 1: a
- 2: a
-
-/^((a|bc)+)*ax/
- aax
- 0: aax
- 1: a
- 2: a
-
-/(a|x)*ab/
- cab
- 0: ab
-
-/(a)*ab/
- cab
- 0: ab
-
-/(?:(?i)a)b/
- ab
- 0: ab
-
-/((?i)a)b/
- ab
- 0: ab
- 1: a
-
-/(?:(?i)a)b/
- Ab
- 0: Ab
-
-/((?i)a)b/
- Ab
- 0: Ab
- 1: A
-
-/(?:(?i)a)b/
- *** Failers
-No match
- cb
-No match
- aB
-No match
-
-/((?i)a)b/
-
-/(?i:a)b/
- ab
- 0: ab
-
-/((?i:a))b/
- ab
- 0: ab
- 1: a
-
-/(?i:a)b/
- Ab
- 0: Ab
-
-/((?i:a))b/
- Ab
- 0: Ab
- 1: A
-
-/(?i:a)b/
- *** Failers
-No match
- aB
-No match
- aB
-No match
-
-/((?i:a))b/
-
-/(?:(?-i)a)b/i
- ab
- 0: ab
-
-/((?-i)a)b/i
- ab
- 0: ab
- 1: a
-
-/(?:(?-i)a)b/i
- aB
- 0: aB
-
-/((?-i)a)b/i
- aB
- 0: aB
- 1: a
-
-/(?:(?-i)a)b/i
- *** Failers
-No match
- aB
- 0: aB
- Ab
-No match
-
-/((?-i)a)b/i
-
-/(?:(?-i)a)b/i
- aB
- 0: aB
-
-/((?-i)a)b/i
- aB
- 0: aB
- 1: a
-
-/(?:(?-i)a)b/i
- *** Failers
-No match
- Ab
-No match
- AB
-No match
-
-/((?-i)a)b/i
-
-/(?-i:a)b/i
- ab
- 0: ab
-
-/((?-i:a))b/i
- ab
- 0: ab
- 1: a
-
-/(?-i:a)b/i
- aB
- 0: aB
-
-/((?-i:a))b/i
- aB
- 0: aB
- 1: a
-
-/(?-i:a)b/i
- *** Failers
-No match
- AB
-No match
- Ab
-No match
-
-/((?-i:a))b/i
-
-/(?-i:a)b/i
- aB
- 0: aB
-
-/((?-i:a))b/i
- aB
- 0: aB
- 1: a
-
-/(?-i:a)b/i
- *** Failers
-No match
- Ab
-No match
- AB
-No match
-
-/((?-i:a))b/i
-
-/((?-i:a.))b/i
- *** Failers
-No match
- AB
-No match
- a\nB
-No match
-
-/((?s-i:a.))b/i
- a\nB
- 0: a\x0aB
- 1: a\x0a
-
-/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
- cabbbb
- 0: cabbbb
-
-/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
- caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
- 0: caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
-
-/(ab)\d\1/i
- Ab4ab
- 0: Ab4ab
- 1: Ab
- ab4Ab
- 0: ab4Ab
- 1: ab
-
-/foo\w*\d{4}baz/
- foobar1234baz
- 0: foobar1234baz
-
-/x(~~)*(?:(?:F)?)?/
- x~~
- 0: x~~
- 1: ~~
-
-/^a(?#xxx){3}c/
- aaac
- 0: aaac
-
-/^a (?#xxx) (?#yyy) {3}c/x
- aaac
- 0: aaac
-
-/(?<![cd])b/
- *** Failers
-No match
- B\nB
-No match
- dbcb
-No match
-
-/(?<![cd])[ab]/
- dbaacb
- 0: a
-
-/(?<!(c|d))b/
-
-/(?<!(c|d))[ab]/
- dbaacb
- 0: a
-
-/(?<!cd)[ab]/
- cdaccb
- 0: b
-
-/^(?:a?b?)*$/
- *** Failers
-No match
- dbcb
-No match
- a--
-No match
-
-/((?s)^a(.))((?m)^b$)/
- a\nb\nc\n
- 0: a\x0ab
- 1: a\x0a
- 2: \x0a
- 3: b
-
-/((?m)^b$)/
- a\nb\nc\n
- 0: b
- 1: b
-
-/(?m)^b/
- a\nb\n
- 0: b
-
-/(?m)^(b)/
- a\nb\n
- 0: b
- 1: b
-
-/((?m)^b)/
- a\nb\n
- 0: b
- 1: b
-
-/\n((?m)^b)/
- a\nb\n
- 0: \x0ab
- 1: b
-
-/((?s).)c(?!.)/
- a\nb\nc\n
- 0: \x0ac
- 1: \x0a
- a\nb\nc\n
- 0: \x0ac
- 1: \x0a
-
-/((?s)b.)c(?!.)/
- a\nb\nc\n
- 0: b\x0ac
- 1: b\x0a
- a\nb\nc\n
- 0: b\x0ac
- 1: b\x0a
-
-/^b/
-
-/()^b/
- *** Failers
-No match
- a\nb\nc\n
-No match
- a\nb\nc\n
-No match
-
-/((?m)^b)/
- a\nb\nc\n
- 0: b
- 1: b
-
-/(?(1)a|b)/
-
-/(?(1)b|a)/
- a
- 0: a
-
-/(x)?(?(1)a|b)/
- *** Failers
-No match
- a
-No match
- a
-No match
-
-/(x)?(?(1)b|a)/
- a
- 0: a
-
-/()?(?(1)b|a)/
- a
- 0: a
-
-/()(?(1)b|a)/
-
-/()?(?(1)a|b)/
- a
- 0: a
- 1:
-
-/^(\()?blah(?(1)(\)))$/
- (blah)
- 0: (blah)
- 1: (
- 2: )
- blah
- 0: blah
- *** Failers
-No match
- a
-No match
- blah)
-No match
- (blah
-No match
-
-/^(\(+)?blah(?(1)(\)))$/
- (blah)
- 0: (blah)
- 1: (
- 2: )
- blah
- 0: blah
- *** Failers
-No match
- blah)
-No match
- (blah
-No match
-
-/(?(?!a)a|b)/
-
-/(?(?!a)b|a)/
- a
- 0: a
-
-/(?(?=a)b|a)/
- *** Failers
-No match
- a
-No match
- a
-No match
-
-/(?(?=a)a|b)/
- a
- 0: a
-
-/(?=(a+?))(\1ab)/
- aaab
- 0: aab
- 1: a
- 2: aab
-
-/^(?=(a+?))\1ab/
-
-/(\w+:)+/
- one:
- 0: one:
- 1: one:
-
-/$(?<=^(a))/
- a
- 0:
- 1: a
-
-/(?=(a+?))(\1ab)/
- aaab
- 0: aab
- 1: a
- 2: aab
-
-/^(?=(a+?))\1ab/
- *** Failers
-No match
- aaab
-No match
- aaab
-No match
-
-/([\w:]+::)?(\w+)$/
- abcd
- 0: abcd
- 1: <unset>
- 2: abcd
- xy:z:::abcd
- 0: xy:z:::abcd
- 1: xy:z:::
- 2: abcd
-
-/^[^bcd]*(c+)/
- aexycd
- 0: aexyc
- 1: c
-
-/(a*)b+/
- caab
- 0: aab
- 1: aa
-
-/([\w:]+::)?(\w+)$/
- abcd
- 0: abcd
- 1: <unset>
- 2: abcd
- xy:z:::abcd
- 0: xy:z:::abcd
- 1: xy:z:::
- 2: abcd
- *** Failers
- 0: Failers
- 1: <unset>
+ 0: *** Failers
+ 1: ***
2: Failers
- abcd:
-No match
- abcd:
-No match
-
-/^[^bcd]*(c+)/
- aexycd
- 0: aexyc
- 1: c
-
-/(>a+)ab/
-
-/(?>a+)b/
- aaab
- 0: aaab
-
-/([[:]+)/
- a:[b]:
- 0: :[
- 1: :[
-
-/([[=]+)/
- a=[b]=
- 0: =[
- 1: =[
-
-/([[.]+)/
- a.[b].
- 0: .[
- 1: .[
-
-/((?>a+)b)/
- aaab
- 0: aaab
- 1: aaab
-
-/(?>(a+))b/
- aaab
- 0: aaab
- 1: aaa
-
-/((?>[^()]+)|\([^()]*\))+/
- ((abc(ade)ufh()()x
- 0: abc(ade)ufh()()x
- 1: x
-
-/a\Z/
- *** Failers
-No match
- aaab
-No match
- a\nb\n
-No match
-
-/b\Z/
- a\nb\n
- 0: b
-
-/b\z/
-
-/b\Z/
- a\nb
- 0: b
-
-/b\z/
- a\nb
- 0: b
- *** Failers
-No match
-
-/^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
- a
- 0: a
- 1:
- abc
- 0: abc
- 1:
- a-b
- 0: a-b
- 1:
- 0-9
- 0: 0-9
- 1:
- a.b
- 0: a.b
- 1:
- 5.6.7
- 0: 5.6.7
- 1:
- the.quick.brown.fox
- 0: the.quick.brown.fox
- 1:
- a100.b200.300c
- 0: a100.b200.300c
- 1:
- 12-ab.1245
- 0: 12-ab.1245
- 1:
- ***Failers
-No match
- \
-No match
- .a
-No match
- -a
-No match
- a-
-No match
- a.
-No match
- a_b
-No match
- a.-
-No match
- a..
-No match
- ab..bc
-No match
- the.quick.brown.fox-
-No match
- the.quick.brown.fox.
-No match
- the.quick.brown.fox_
-No match
- the.quick.brown.fox+
-No match
-
-/(?>.*)(?<=(abcd|wxyz))/
- alphabetabcd
- 0: alphabetabcd
- 1: abcd
- endingwxyz
- 0: endingwxyz
- 1: wxyz
- *** Failers
-No match
- a rather long string that doesn't end with one of them
-No match
-
-/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark otherword
- 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
- word cat dog elephant mussel cow horse canary baboon snake shark
-No match
-
-/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
- word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
-No match
-
-/(?<=\d{3}(?!999))foo/
- 999foo
- 0: foo
- 123999foo
- 0: foo
- *** Failers
-No match
- 123abcfoo
-No match
-
-/(?<=(?!...999)\d{3})foo/
- 999foo
- 0: foo
- 123999foo
- 0: foo
- *** Failers
-No match
- 123abcfoo
-No match
-
-/(?<=\d{3}(?!999)...)foo/
- 123abcfoo
- 0: foo
- 123456foo
- 0: foo
- *** Failers
-No match
- 123999foo
-No match
-
-/(?<=\d{3}...)(?<!999)foo/
- 123abcfoo
- 0: foo
- 123456foo
- 0: foo
- *** Failers
-No match
- 123999foo
-No match
-
-/<a[\s]+href[\s]*=[\s]* # find <a href=
- ([\"\'])? # find single or double quote
- (?(1) (.*?)\1 | ([^\s]+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- 0: <a href=abcd
- 1: <unset>
- 2: <unset>
- 3: abcd
- <a href=\"abcd xyz pqr\" cats
- 0: <a href="abcd xyz pqr"
- 1: "
- 2: abcd xyz pqr
- <a href=\'abcd xyz pqr\' cats
- 0: <a href='abcd xyz pqr'
- 1: '
- 2: abcd xyz pqr
-
-/<a\s+href\s*=\s* # find <a href=
- (["'])? # find single or double quote
- (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- 0: <a href=abcd
- 1: <unset>
- 2: <unset>
- 3: abcd
- <a href=\"abcd xyz pqr\" cats
- 0: <a href="abcd xyz pqr"
- 1: "
- 2: abcd xyz pqr
- <a href = \'abcd xyz pqr\' cats
- 0: <a href = 'abcd xyz pqr'
- 1: '
- 2: abcd xyz pqr
-
-/<a\s+href(?>\s*)=(?>\s*) # find <a href=
- (["'])? # find single or double quote
- (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
- # quote, otherwise match up to next space
-/isx
- <a href=abcd xyz
- 0: <a href=abcd
- 1: <unset>
- 2: <unset>
- 3: abcd
- <a href=\"abcd xyz pqr\" cats
- 0: <a href="abcd xyz pqr"
- 1: "
- 2: abcd xyz pqr
- <a href = \'abcd xyz pqr\' cats
- 0: <a href = 'abcd xyz pqr'
- 1: '
- 2: abcd xyz pqr
-
-/((Z)+|A)*/
- ZABCDEFG
- 0: ZA
- 1: A
- 2: Z
-
-/(Z()|A)*/
- ZABCDEFG
- 0: ZA
- 1: A
- 2:
-
-/(Z(())|A)*/
- ZABCDEFG
- 0: ZA
- 1: A
- 2:
- 3:
-
-/((?>Z)+|A)*/
- ZABCDEFG
- 0: ZA
- 1: A
-
-/((?>)+|A)*/
- ZABCDEFG
- 0:
- 1:
-
-/a*/g
- abbab
- 0: a
- 0:
- 0:
- 0: a
- 0:
- 0:
-
-/^[a-\d]/
- abcde
- 0: a
- -things
- 0: -
- 0digit
- 0: 0
- *** Failers
-No match
- bcdef
-No match
-
-/^[\d-a]/
- abcde
- 0: a
- -things
- 0: -
- 0digit
- 0: 0
- *** Failers
+ École
+No match
+
+/École/i
+ École
+ 0: \xc9cole
+ *** Failers
+No match
+ école
+No match
+
+/École/iLfr
+ École
+ 0: École
+ école
+ 0: école
+
+/\w/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Study size = 40
+Starting character set: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
+ Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
+
+/\w/ISLfr
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Study size = 40
+Starting character set: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
+ Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
+ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å
+ æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ø ù ú û ü ý þ ÿ
+
+/^[\xc8-\xc9]/iLfr
+ École
+ 0: É
+ école
+ 0: é
+
+/^[\xc8-\xc9]/Lfr
+ École
+ 0: É
+ *** Failers
No match
- bcdef
+ école
No match
-/ End of testinput3 /
+/ End of testinput3 /
diff --git a/testdata/testoutput4 b/testdata/testoutput4
index df81a0f..82c5e2a 100644
--- a/testdata/testoutput4
+++ b/testdata/testoutput4
@@ -1,115 +1,839 @@
-PCRE version 3.9 02-Jan-2002
+PCRE version 4.0 17-Feb-2003
-/^[\w]+/
+/-- Do not use the \x{} construct except with patterns that have the --/
+/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/
+No match
+/-- that option is set. However, the latest Perls recognize them always. --/
+No match
+
+/a.b/8
+ acb
+ 0: acb
+ a\x7fb
+ 0: a\x{7f}b
+ a\x{100}b
+ 0: a\x{100}b
*** Failers
No match
- École
+ a\nb
+No match
+
+/a(.{3})b/8
+ a\x{4000}xyb
+ 0: a\x{4000}xyb
+ 1: \x{4000}xy
+ a\x{4000}\x7fyb
+ 0: a\x{4000}\x{7f}yb
+ 1: \x{4000}\x{7f}y
+ a\x{4000}\x{100}yb
+ 0: a\x{4000}\x{100}yb
+ 1: \x{4000}\x{100}y
+ *** Failers
No match
+ a\x{4000}b
+No match
+ ac\ncb
+No match
+
+/a(.*?)(.)/
+ a\xc0\x88b
+ 0: a\xc0
+ 1:
+ 2: \xc0
+
+/a(.*?)(.)/8
+ a\x{100}b
+ 0: a\x{100}
+ 1:
+ 2: \x{100}
+
+/a(.*)(.)/
+ a\xc0\x88b
+ 0: a\xc0\x88b
+ 1: \xc0\x88
+ 2: b
-/^[\w]+/Lfr
- École
- 0: École
+/a(.*)(.)/8
+ a\x{100}b
+ 0: a\x{100}b
+ 1: \x{100}
+ 2: b
-/^[\w]+/
+/a(.)(.)/
+ a\xc0\x92bcd
+ 0: a\xc0\x92
+ 1: \xc0
+ 2: \x92
+
+/a(.)(.)/8
+ a\x{240}bcd
+ 0: a\x{240}b
+ 1: \x{240}
+ 2: b
+
+/a(.?)(.)/
+ a\xc0\x92bcd
+ 0: a\xc0\x92
+ 1: \xc0
+ 2: \x92
+
+/a(.?)(.)/8
+ a\x{240}bcd
+ 0: a\x{240}b
+ 1: \x{240}
+ 2: b
+
+/a(.??)(.)/
+ a\xc0\x92bcd
+ 0: a\xc0
+ 1:
+ 2: \xc0
+
+/a(.??)(.)/8
+ a\x{240}bcd
+ 0: a\x{240}
+ 1:
+ 2: \x{240}
+
+/a(.{3})b/8
+ a\x{1234}xyb
+ 0: a\x{1234}xyb
+ 1: \x{1234}xy
+ a\x{1234}\x{4321}yb
+ 0: a\x{1234}\x{4321}yb
+ 1: \x{1234}\x{4321}y
+ a\x{1234}\x{4321}\x{3412}b
+ 0: a\x{1234}\x{4321}\x{3412}b
+ 1: \x{1234}\x{4321}\x{3412}
*** Failers
No match
- École
+ a\x{1234}b
+No match
+ ac\ncb
No match
-/^[\W]+/
- École
- 0: \xc9
+/a(.{3,})b/8
+ a\x{1234}xyb
+ 0: a\x{1234}xyb
+ 1: \x{1234}xy
+ a\x{1234}\x{4321}yb
+ 0: a\x{1234}\x{4321}yb
+ 1: \x{1234}\x{4321}y
+ a\x{1234}\x{4321}\x{3412}b
+ 0: a\x{1234}\x{4321}\x{3412}b
+ 1: \x{1234}\x{4321}\x{3412}
+ axxxxbcdefghijb
+ 0: axxxxbcdefghijb
+ 1: xxxxbcdefghij
+ a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 1: \x{1234}\x{4321}\x{3412}\x{3421}
+ *** Failers
+No match
+ a\x{1234}b
+No match
-/^[\W]+/Lfr
+/a(.{3,}?)b/8
+ a\x{1234}xyb
+ 0: a\x{1234}xyb
+ 1: \x{1234}xy
+ a\x{1234}\x{4321}yb
+ 0: a\x{1234}\x{4321}yb
+ 1: \x{1234}\x{4321}y
+ a\x{1234}\x{4321}\x{3412}b
+ 0: a\x{1234}\x{4321}\x{3412}b
+ 1: \x{1234}\x{4321}\x{3412}
+ axxxxbcdefghijb
+ 0: axxxxb
+ 1: xxxx
+ a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 1: \x{1234}\x{4321}\x{3412}\x{3421}
*** Failers
- 0: ***
- École
+No match
+ a\x{1234}b
No match
-/[\b]/
- \b
- 0: \x08
+/a(.{3,5})b/8
+ a\x{1234}xyb
+ 0: a\x{1234}xyb
+ 1: \x{1234}xy
+ a\x{1234}\x{4321}yb
+ 0: a\x{1234}\x{4321}yb
+ 1: \x{1234}\x{4321}y
+ a\x{1234}\x{4321}\x{3412}b
+ 0: a\x{1234}\x{4321}\x{3412}b
+ 1: \x{1234}\x{4321}\x{3412}
+ axxxxbcdefghijb
+ 0: axxxxb
+ 1: xxxx
+ a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 1: \x{1234}\x{4321}\x{3412}\x{3421}
+ axbxxbcdefghijb
+ 0: axbxxb
+ 1: xbxx
+ axxxxxbcdefghijb
+ 0: axxxxxb
+ 1: xxxxx
*** Failers
No match
- a
+ a\x{1234}b
+No match
+ axxxxxxbcdefghijb
No match
-/[\b]/Lfr
- \b
- 0: \x08
+/a(.{3,5}?)b/8
+ a\x{1234}xyb
+ 0: a\x{1234}xyb
+ 1: \x{1234}xy
+ a\x{1234}\x{4321}yb
+ 0: a\x{1234}\x{4321}yb
+ 1: \x{1234}\x{4321}y
+ a\x{1234}\x{4321}\x{3412}b
+ 0: a\x{1234}\x{4321}\x{3412}b
+ 1: \x{1234}\x{4321}\x{3412}
+ axxxxbcdefghijb
+ 0: axxxxb
+ 1: xxxx
+ a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 1: \x{1234}\x{4321}\x{3412}\x{3421}
+ axbxxbcdefghijb
+ 0: axbxxb
+ 1: xbxx
+ axxxxxbcdefghijb
+ 0: axxxxxb
+ 1: xxxxx
*** Failers
No match
- a
+ a\x{1234}b
+No match
+ axxxxxxbcdefghijb
No match
-/^\w+/
+/^[a\x{c0}]/8
*** Failers
No match
- École
+ \x{100}
No match
-/^\w+/Lfr
- École
- 0: École
+/(?<=aXb)cd/8
+ aXbcd
+ 0: cd
-/(.+)\b(.+)/
- École
- 0: \xc9cole
- 1: \xc9
- 2: cole
+/(?<=a\x{100}b)cd/8
+ a\x{100}bcd
+ 0: cd
+
+/(?<=a\x{100000}b)cd/8
+ a\x{100000}bcd
+ 0: cd
+
+/(?:\x{100}){3}b/8
+ \x{100}\x{100}\x{100}b
+ 0: \x{100}\x{100}\x{100}b
+ *** Failers
+No match
+ \x{100}\x{100}b
+No match
+
+/\x{ab}/8
+ \x{ab}
+ 0: \x{ab}
+ \xc2\xab
+ 0: \x{ab}
+ *** Failers
+No match
+ \x00{ab}
+No match
-/(.+)\b(.+)/Lfr
+/(?<=(.))X/8
+ WXYZ
+ 0: X
+ 1: W
+ \x{256}XYZ
+ 0: X
+ 1: \x{256}
+ *** Failers
+No match
+ XYZ
+No match
+
+/X(\C{3})/8
+ X\x{1234}
+ 0: X\x{1234}
+ 1: \x{1234}
+
+/X(\C{4})/8
+ X\x{1234}YZ
+ 0: X\x{1234}Y
+ 1: \x{1234}Y
+
+/X\C*/8
+ XYZabcdce
+ 0: XYZabcdce
+
+/X\C*?/8
+ XYZabcde
+ 0: X
+
+/X\C{3,5}/8
+ Xabcdefg
+ 0: Xabcde
+ X\x{1234}
+ 0: X\x{1234}
+ X\x{1234}YZ
+ 0: X\x{1234}YZ
+ X\x{1234}\x{512}
+ 0: X\x{1234}\x{512}
+ X\x{1234}\x{512}YZ
+ 0: X\x{1234}\x{512}
+
+/X\C{3,5}?/8
+ Xabcdefg
+ 0: Xabc
+ X\x{1234}
+ 0: X\x{1234}
+ X\x{1234}YZ
+ 0: X\x{1234}
+ X\x{1234}\x{512}
+ 0: X\x{1234}
+
+/[^a]+/8g
+ bcd
+ 0: bcd
+ \x{100}aY\x{256}Z
+ 0: \x{100}
+ 0: Y\x{256}Z
+
+/^[^a]{2}/8
+ \x{100}bc
+ 0: \x{100}b
+
+/^[^a]{2,}/8
+ \x{100}bcAa
+ 0: \x{100}bcA
+
+/^[^a]{2,}?/8
+ \x{100}bca
+ 0: \x{100}b
+
+/[^a]+/8ig
+ bcd
+ 0: bcd
+ \x{100}aY\x{256}Z
+ 0: \x{100}
+ 0: Y\x{256}Z
+
+/^[^a]{2}/8i
+ \x{100}bc
+ 0: \x{100}b
+
+/^[^a]{2,}/8i
+ \x{100}bcAa
+ 0: \x{100}bc
+
+/^[^a]{2,}?/8i
+ \x{100}bca
+ 0: \x{100}b
+
+/\x{100}{0,0}/8
+ abcd
+ 0:
+
+/\x{100}?/8
+ abcd
+ 0:
+ \x{100}\x{100}
+ 0: \x{100}
+
+/\x{100}{0,3}/8
+ \x{100}\x{100}
+ 0: \x{100}\x{100}
+ \x{100}\x{100}\x{100}\x{100}
+ 0: \x{100}\x{100}\x{100}
+
+/\x{100}*/8
+ abce
+ 0:
+ \x{100}\x{100}\x{100}\x{100}
+ 0: \x{100}\x{100}\x{100}\x{100}
+
+/\x{100}{1,1}/8
+ abcd\x{100}\x{100}\x{100}\x{100}
+ 0: \x{100}
+
+/\x{100}{1,3}/8
+ abcd\x{100}\x{100}\x{100}\x{100}
+ 0: \x{100}\x{100}\x{100}
+
+/\x{100}+/8
+ abcd\x{100}\x{100}\x{100}\x{100}
+ 0: \x{100}\x{100}\x{100}\x{100}
+
+/\x{100}{3}/8
+ abcd\x{100}\x{100}\x{100}XX
+ 0: \x{100}\x{100}\x{100}
+
+/\x{100}{3,5}/8
+ abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+ 0: \x{100}\x{100}\x{100}\x{100}\x{100}
+
+/\x{100}{3,}/8
+ abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+ 0: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+
+/(?<=a\x{100}{2}b)X/8+
+ Xyyya\x{100}\x{100}bXzzz
+ 0: X
+ 0+ zzz
+
+/\D*/8
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/\D*/8
+ \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 0: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+
+/\D/8
+ 1X2
+ 0: X
+ 1\x{100}2
+ 0: \x{100}
+
+/>\S/8
+ > >X Y
+ 0: >X
+ > >\x{100} Y
+ 0: >\x{100}
+
+/\W/8
+ A.B
+ 0: .
+ A\x{100}B
+ 0: \x{100}
+
+/\d/8
+ \x{100}3
+ 0: 3
+
+/\s/8
+ \x{100} X
+ 0:
+
+/\w/8
+ \x{100}X
+ 0: X
+
+/\D+/8
+ 12abcd34
+ 0: abcd
*** Failers
0: *** Failers
- 1: ***
- 2: Failers
- École
-No match
-
-/École/i
- École
- 0: \xc9cole
- *** Failers
-No match
- école
-No match
-
-/École/iLfr
- École
- 0: École
- école
- 0: école
-
-/\w/IS
-Capturing subpattern count = 0
-No options
-No first char
-No need char
-Starting character set: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
- Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
-
-/\w/ISLfr
-Capturing subpattern count = 0
-No options
-No first char
-No need char
-Starting character set: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P
- Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z
- À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å
- æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ø ù ú û ü ý þ ÿ
-
-/^[\xc8-\xc9]/iLfr
- École
- 0: É
- école
- 0: é
-
-/^[\xc8-\xc9]/Lfr
- École
- 0: É
+ 1234
+No match
+
+/\D{2,3}/8
+ 12abcd34
+ 0: abc
+ 12ab34
+ 0: ab
+ *** Failers
+ 0: ***
+ 1234
+No match
+ 12a34
+No match
+
+/\D{2,3}?/8
+ 12abcd34
+ 0: ab
+ 12ab34
+ 0: ab
+ *** Failers
+ 0: **
+ 1234
+No match
+ 12a34
+No match
+
+/\d+/8
+ 12abcd34
+ 0: 12
+ *** Failers
+No match
+
+/\d{2,3}/8
+ 12abcd34
+ 0: 12
+ 1234abcd
+ 0: 123
+ *** Failers
+No match
+ 1.4
+No match
+
+/\d{2,3}?/8
+ 12abcd34
+ 0: 12
+ 1234abcd
+ 0: 12
+ *** Failers
+No match
+ 1.4
+No match
+
+/\S+/8
+ 12abcd34
+ 0: 12abcd34
+ *** Failers
+ 0: ***
+ \ \
+No match
+
+/\S{2,3}/8
+ 12abcd34
+ 0: 12a
+ 1234abcd
+ 0: 123
+ *** Failers
+ 0: ***
+ \ \
+No match
+
+/\S{2,3}?/8
+ 12abcd34
+ 0: 12
+ 1234abcd
+ 0: 12
+ *** Failers
+ 0: **
+ \ \
+No match
+
+/>\s+</8+
+ 12> <34
+ 0: > <
+ 0+ 34
+ *** Failers
+No match
+
+/>\s{2,3}</8+
+ ab> <cd
+ 0: > <
+ 0+ cd
+ ab> <ce
+ 0: > <
+ 0+ ce
+ *** Failers
+No match
+ ab> <cd
+No match
+
+/>\s{2,3}?</8+
+ ab> <cd
+ 0: > <
+ 0+ cd
+ ab> <ce
+ 0: > <
+ 0+ ce
+ *** Failers
+No match
+ ab> <cd
+No match
+
+/\w+/8
+ 12 34
+ 0: 12
+ *** Failers
+ 0: Failers
+ +++=*!
+No match
+
+/\w{2,3}/8
+ ab cd
+ 0: ab
+ abcd ce
+ 0: abc
+ *** Failers
+ 0: Fai
+ a.b.c
+No match
+
+/\w{2,3}?/8
+ ab cd
+ 0: ab
+ abcd ce
+ 0: ab
+ *** Failers
+ 0: Fa
+ a.b.c
+No match
+
+/\W+/8
+ 12====34
+ 0: ====
+ *** Failers
+ 0: ***
+ abcd
+No match
+
+/\W{2,3}/8
+ ab====cd
+ 0: ===
+ ab==cd
+ 0: ==
+ *** Failers
+ 0: ***
+ a.b.c
+No match
+
+/\W{2,3}?/8
+ ab====cd
+ 0: ==
+ ab==cd
+ 0: ==
+ *** Failers
+ 0: **
+ a.b.c
+No match
+
+/[\x{100}]/8
+ \x{100}
+ 0: \x{100}
+ Z\x{100}
+ 0: \x{100}
+ \x{100}Z
+ 0: \x{100}
+ *** Failers
+No match
+
+/[Z\x{100}]/8
+ Z\x{100}
+ 0: Z
+ \x{100}
+ 0: \x{100}
+ \x{100}Z
+ 0: \x{100}
+ *** Failers
+No match
+
+/[\x{100}\x{200}]/8
+ ab\x{100}cd
+ 0: \x{100}
+ ab\x{200}cd
+ 0: \x{200}
+ *** Failers
+No match
+
+/[\x{100}-\x{200}]/8
+ ab\x{100}cd
+ 0: \x{100}
+ ab\x{200}cd
+ 0: \x{200}
+ ab\x{111}cd
+ 0: \x{111}
+ *** Failers
+No match
+
+/[z-\x{200}]/8
+ ab\x{100}cd
+ 0: \x{100}
+ ab\x{200}cd
+ 0: \x{200}
+ ab\x{111}cd
+ 0: \x{111}
+ abzcd
+ 0: z
+ ab|cd
+ 0: |
+ *** Failers
+No match
+
+/[Q\x{100}\x{200}]/8
+ ab\x{100}cd
+ 0: \x{100}
+ ab\x{200}cd
+ 0: \x{200}
+ Q?
+ 0: Q
+ *** Failers
+No match
+
+/[Q\x{100}-\x{200}]/8
+ ab\x{100}cd
+ 0: \x{100}
+ ab\x{200}cd
+ 0: \x{200}
+ ab\x{111}cd
+ 0: \x{111}
+ Q?
+ 0: Q
+ *** Failers
+No match
+
+/[Qz-\x{200}]/8
+ ab\x{100}cd
+ 0: \x{100}
+ ab\x{200}cd
+ 0: \x{200}
+ ab\x{111}cd
+ 0: \x{111}
+ abzcd
+ 0: z
+ ab|cd
+ 0: |
+ Q?
+ 0: Q
+ *** Failers
+No match
+
+/[\x{100}\x{200}]{1,3}/8
+ ab\x{100}cd
+ 0: \x{100}
+ ab\x{200}cd
+ 0: \x{200}
+ ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}\x{100}\x{200}
+ *** Failers
+No match
+
+/[\x{100}\x{200}]{1,3}?/8
+ ab\x{100}cd
+ 0: \x{100}
+ ab\x{200}cd
+ 0: \x{200}
+ ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}
+ *** Failers
+No match
+
+/[Q\x{100}\x{200}]{1,3}/8
+ ab\x{100}cd
+ 0: \x{100}
+ ab\x{200}cd
+ 0: \x{200}
+ ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}\x{100}\x{200}
+ *** Failers
+No match
+
+/[Q\x{100}\x{200}]{1,3}?/8
+ ab\x{100}cd
+ 0: \x{100}
+ ab\x{200}cd
+ 0: \x{200}
+ ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}
+ *** Failers
+No match
+
+/(?<=[\x{100}\x{200}])X/8
+ abc\x{200}X
+ 0: X
+ abc\x{100}X
+ 0: X
+ *** Failers
+No match
+ X
+No match
+
+/(?<=[Q\x{100}\x{200}])X/8
+ abc\x{200}X
+ 0: X
+ abc\x{100}X
+ 0: X
+ abQX
+ 0: X
+ *** Failers
+No match
+ X
+No match
+
+/(?<=[\x{100}\x{200}]{3})X/8
+ abc\x{100}\x{200}\x{100}X
+ 0: X
+ *** Failers
+No match
+ abc\x{200}X
+No match
+ X
+No match
+
+/[^\x{100}\x{200}]X/8
+ AX
+ 0: AX
+ \x{150}X
+ 0: \x{150}X
+ \x{500}X
+ 0: \x{500}X
+ *** Failers
+No match
+ \x{100}X
+No match
+ \x{200}X
+No match
+
+/[^Q\x{100}\x{200}]X/8
+ AX
+ 0: AX
+ \x{150}X
+ 0: \x{150}X
+ \x{500}X
+ 0: \x{500}X
+ *** Failers
+No match
+ \x{100}X
+No match
+ \x{200}X
+No match
+ QX
+No match
+
+/[^\x{100}-\x{200}]X/8
+ AX
+ 0: AX
+ \x{500}X
+ 0: \x{500}X
+ *** Failers
+No match
+ \x{100}X
+No match
+ \x{150}X
+No match
+ \x{200}X
+No match
+
+/a\Cb/
+ aXb
+ 0: aXb
+ a\nb
+ 0: a\x0ab
+
+/a\Cb/8
+ aXb
+ 0: aXb
+ a\nb
+ 0: a\x{0a}b
*** Failers
No match
- école
+ a\x{100}b
+No match
+
+/[z-\x{100}]/8i
+ z
+ 0: z
+ Z
+ 0: Z
+ \x{100}
+ 0: \x{100}
+ *** Failers
+No match
+ \x{101}
+No match
+ y
No match
/ End of testinput4 /
diff --git a/testdata/testoutput5 b/testdata/testoutput5
index 6bb9ad3..3491576 100644
--- a/testdata/testoutput5
+++ b/testdata/testoutput5
@@ -1,242 +1,778 @@
-PCRE version 3.9 02-Jan-2002
+PCRE version 4.0 17-Feb-2003
-/-- Because of problems with Perl 5.6 in handling UTF-8 vs non UTF-8 --/
-/-- strings automatically, do not use the \x{} construct except with --/
-No match
-/-- patterns that have the /8 option set, and don't use them without! --/
-No match
+/\x{100}/8DM
+Memory allocation (code space): 11
+------------------------------------------------------------------
+ 0 7 Bra 0
+ 3 2 \x{100}
+ 7 7 Ket
+ 10 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 196
+Need char = 128
-/a.b/8
- acb
- 0: acb
- a\x7fb
- 0: a\x{7f}b
- a\x{100}b
- 0: a\x{100}b
- *** Failers
-No match
- a\nb
-No match
+/\x{1000}/8DM
+Memory allocation (code space): 12
+------------------------------------------------------------------
+ 0 8 Bra 0
+ 3 3 \x{1000}
+ 8 8 Ket
+ 11 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 225
+Need char = 128
-/a(.{3})b/8
- a\x{4000}xyb
- 0: a\x{4000}xyb
- 1: \x{4000}xy
- a\x{4000}\x7fyb
- 0: a\x{4000}\x{7f}yb
- 1: \x{4000}\x{7f}y
- a\x{4000}\x{100}yb
- 0: a\x{4000}\x{100}yb
- 1: \x{4000}\x{100}y
- *** Failers
-No match
- a\x{4000}b
+/\x{10000}/8DM
+Memory allocation (code space): 13
+------------------------------------------------------------------
+ 0 9 Bra 0
+ 3 4 \x{10000}
+ 9 9 Ket
+ 12 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 240
+Need char = 128
+
+/\x{100000}/8DM
+Memory allocation (code space): 13
+------------------------------------------------------------------
+ 0 9 Bra 0
+ 3 4 \x{100000}
+ 9 9 Ket
+ 12 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 244
+Need char = 128
+
+/\x{1000000}/8DM
+Memory allocation (code space): 14
+------------------------------------------------------------------
+ 0 10 Bra 0
+ 3 5 \x{1000000}
+ 10 10 Ket
+ 13 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 249
+Need char = 128
+
+/\x{4000000}/8DM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 6 \x{4000000}
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 252
+Need char = 128
+
+/\x{7fffFFFF}/8DM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 6 \x{7fffffff}
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 253
+Need char = 191
+
+/[\x{ff}]/8DM
+Memory allocation (code space): 40
+------------------------------------------------------------------
+ 0 36 Bra 0
+ 3 [\xff]
+ 36 36 Ket
+ 39 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/[\x{100}]/8DM
+Memory allocation (code space): 47
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 [\x{100}]
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/\x{ffffffff}/8
+Failed: character value in \x{...} sequence is too large at offset 11
+
+/\x{100000000}/8
+Failed: character value in \x{...} sequence is too large at offset 12
+
+/^\x{100}a\x{1234}/8
+ \x{100}a\x{1234}bcd
+ 0: \x{100}a\x{1234}
+
+/\x80/8D
+------------------------------------------------------------------
+ 0 7 Bra 0
+ 3 2 \x{80}
+ 7 7 Ket
+ 10 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 194
+Need char = 128
+
+/\xff/8D
+------------------------------------------------------------------
+ 0 7 Bra 0
+ 3 2 \x{ff}
+ 7 7 Ket
+ 10 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 195
+Need char = 191
+
+/\x{0041}\x{2262}\x{0391}\x{002e}/D8
+------------------------------------------------------------------
+ 0 12 Bra 0
+ 3 7 A\x{2262}\x{391}.
+ 12 12 Ket
+ 15 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 'A'
+Need char = '.'
+ \x{0041}\x{2262}\x{0391}\x{002e}
+ 0: A\x{2262}\x{391}.
+
+/\x{D55c}\x{ad6d}\x{C5B4}/D8
+------------------------------------------------------------------
+ 0 14 Bra 0
+ 3 9 \x{d55c}\x{ad6d}\x{c5b4}
+ 14 14 Ket
+ 17 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 237
+Need char = 180
+ \x{D55c}\x{ad6d}\x{C5B4}
+ 0: \x{d55c}\x{ad6d}\x{c5b4}
+
+/\x{65e5}\x{672c}\x{8a9e}/D8
+------------------------------------------------------------------
+ 0 14 Bra 0
+ 3 9 \x{65e5}\x{672c}\x{8a9e}
+ 14 14 Ket
+ 17 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 230
+Need char = 158
+ \x{65e5}\x{672c}\x{8a9e}
+ 0: \x{65e5}\x{672c}\x{8a9e}
+
+/\x{80}/D8
+------------------------------------------------------------------
+ 0 7 Bra 0
+ 3 2 \x{80}
+ 7 7 Ket
+ 10 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 194
+Need char = 128
+
+/\x{084}/D8
+------------------------------------------------------------------
+ 0 7 Bra 0
+ 3 2 \x{84}
+ 7 7 Ket
+ 10 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 194
+Need char = 132
+
+/\x{104}/D8
+------------------------------------------------------------------
+ 0 7 Bra 0
+ 3 2 \x{104}
+ 7 7 Ket
+ 10 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 196
+Need char = 132
+
+/\x{861}/D8
+------------------------------------------------------------------
+ 0 8 Bra 0
+ 3 3 \x{861}
+ 8 8 Ket
+ 11 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 224
+Need char = 161
+
+/\x{212ab}/D8
+------------------------------------------------------------------
+ 0 9 Bra 0
+ 3 4 \x{212ab}
+ 9 9 Ket
+ 12 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 240
+Need char = 171
+
+/.{3,5}X/D8
+------------------------------------------------------------------
+ 0 14 Bra 0
+ 3 Any{3}
+ 7 Any{0,2}
+ 11 1 X
+ 14 14 Ket
+ 17 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+Need char = 'X'
+ \x{212ab}\x{212ab}\x{212ab}\x{861}X
+ 0: \x{212ab}\x{212ab}\x{212ab}\x{861}X
+
+
+/.{3,5}?/D8
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 Any{3}
+ 7 Any{0,2}?
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+ \x{212ab}\x{212ab}\x{212ab}\x{861}
+ 0: \x{212ab}\x{212ab}\x{212ab}
+
+/-- These tests are here rather than in testinput4 because Perl 5.6 has --/
+/-- some problems with UTF-8 support, in the area of \x{..} where the --/
No match
- ac\ncb
+/-- value is < 255. It grumbles about invalid UTF-8 strings. --/
No match
-/a(.*?)(.)/
- a\xc0\x88b
- 0: a\xc0
- 1:
- 2: \xc0
+/^[a\x{c0}]b/8
+ \x{c0}b
+ 0: \x{c0}b
+
+/^([a\x{c0}]*?)aa/8
+ a\x{c0}aaaa/
+ 0: a\x{c0}aa
+ 1: a\x{c0}
-/a(.*?)(.)/8
- a\x{100}b
- 0: a\x{100}
- 1:
- 2: \x{100}
-
-/a(.*)(.)/
- a\xc0\x88b
- 0: a\xc0\x88b
- 1: \xc0\x88
- 2: b
-
-/a(.*)(.)/8
- a\x{100}b
- 0: a\x{100}b
- 1: \x{100}
- 2: b
-
-/a(.)(.)/
- a\xc0\x92bcd
- 0: a\xc0\x92
- 1: \xc0
- 2: \x92
-
-/a(.)(.)/8
- a\x{240}bcd
- 0: a\x{240}b
- 1: \x{240}
- 2: b
-
-/a(.?)(.)/
- a\xc0\x92bcd
- 0: a\xc0\x92
- 1: \xc0
- 2: \x92
-
-/a(.?)(.)/8
- a\x{240}bcd
- 0: a\x{240}b
- 1: \x{240}
- 2: b
-
-/a(.??)(.)/
- a\xc0\x92bcd
- 0: a\xc0
- 1:
- 2: \xc0
+/^([a\x{c0}]*?)aa/8
+ a\x{c0}aaaa/
+ 0: a\x{c0}aa
+ 1: a\x{c0}
+ a\x{c0}a\x{c0}aaa/
+ 0: a\x{c0}a\x{c0}aa
+ 1: a\x{c0}a\x{c0}
-/a(.??)(.)/8
- a\x{240}bcd
- 0: a\x{240}
+/^([a\x{c0}]*)aa/8
+ a\x{c0}aaaa/
+ 0: a\x{c0}aaaa
+ 1: a\x{c0}aa
+ a\x{c0}a\x{c0}aaa/
+ 0: a\x{c0}a\x{c0}aaa
+ 1: a\x{c0}a\x{c0}a
+
+/^([a\x{c0}]*)a\x{c0}/8
+ a\x{c0}aaaa/
+ 0: a\x{c0}
1:
- 2: \x{240}
-
-/a(.{3})b/8
- a\x{1234}xyb
- 0: a\x{1234}xyb
- 1: \x{1234}xy
- a\x{1234}\x{4321}yb
- 0: a\x{1234}\x{4321}yb
- 1: \x{1234}\x{4321}y
- a\x{1234}\x{4321}\x{3412}b
- 0: a\x{1234}\x{4321}\x{3412}b
- 1: \x{1234}\x{4321}\x{3412}
- *** Failers
-No match
- a\x{1234}b
-No match
- ac\ncb
-No match
-
-/a(.{3,})b/8
- a\x{1234}xyb
- 0: a\x{1234}xyb
- 1: \x{1234}xy
- a\x{1234}\x{4321}yb
- 0: a\x{1234}\x{4321}yb
- 1: \x{1234}\x{4321}y
- a\x{1234}\x{4321}\x{3412}b
- 0: a\x{1234}\x{4321}\x{3412}b
- 1: \x{1234}\x{4321}\x{3412}
- axxxxbcdefghijb
- 0: axxxxbcdefghijb
- 1: xxxxbcdefghij
- a\x{1234}\x{4321}\x{3412}\x{3421}b
- 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
- 1: \x{1234}\x{4321}\x{3412}\x{3421}
- *** Failers
+ a\x{c0}a\x{c0}aaa/
+ 0: a\x{c0}a\x{c0}
+ 1: a\x{c0}
+
+/-- --/
+
+/(?<=\C)X/8
+Failed: \C not allowed in lookbehind assertion at offset 6
+
+/-- This one is here not because it's different to Perl, but because the --/
+/-- way the captured single-byte is displayed. (In Perl it becomes a --/
No match
- a\x{1234}b
-No match
-
-/a(.{3,}?)b/8
- a\x{1234}xyb
- 0: a\x{1234}xyb
- 1: \x{1234}xy
- a\x{1234}\x{4321}yb
- 0: a\x{1234}\x{4321}yb
- 1: \x{1234}\x{4321}y
- a\x{1234}\x{4321}\x{3412}b
- 0: a\x{1234}\x{4321}\x{3412}b
- 1: \x{1234}\x{4321}\x{3412}
- axxxxbcdefghijb
- 0: axxxxb
- 1: xxxx
- a\x{1234}\x{4321}\x{3412}\x{3421}b
- 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
- 1: \x{1234}\x{4321}\x{3412}\x{3421}
- *** Failers
+/-- character, and you can't tell the difference.) --/
No match
- a\x{1234}b
-No match
-
-/a(.{3,5})b/8
- a\x{1234}xyb
- 0: a\x{1234}xyb
- 1: \x{1234}xy
- a\x{1234}\x{4321}yb
- 0: a\x{1234}\x{4321}yb
- 1: \x{1234}\x{4321}y
- a\x{1234}\x{4321}\x{3412}b
- 0: a\x{1234}\x{4321}\x{3412}b
- 1: \x{1234}\x{4321}\x{3412}
- axxxxbcdefghijb
- 0: axxxxb
- 1: xxxx
- a\x{1234}\x{4321}\x{3412}\x{3421}b
- 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
- 1: \x{1234}\x{4321}\x{3412}\x{3421}
- axbxxbcdefghijb
- 0: axbxxb
- 1: xbxx
- axxxxxbcdefghijb
- 0: axxxxxb
- 1: xxxxx
+
+/X(\C)(.*)/8
+ X\x{1234}
+ 0: X\x{1234}
+ 1: \xe1
+ 2: \x88\xb4
+ X\nabc
+ 0: X\x{0a}abc
+ 1: \x{0a}
+ 2: abc
+
+/^[ab]/8D
+------------------------------------------------------------------
+ 0 37 Bra 0
+ 3 ^
+ 4 [a-b]
+ 37 37 Ket
+ 40 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored utf8
+No first char
+No need char
+ bar
+ 0: b
*** Failers
No match
- a\x{1234}b
-No match
- axxxxxxbcdefghijb
-No match
-
-/a(.{3,5}?)b/8
- a\x{1234}xyb
- 0: a\x{1234}xyb
- 1: \x{1234}xy
- a\x{1234}\x{4321}yb
- 0: a\x{1234}\x{4321}yb
- 1: \x{1234}\x{4321}y
- a\x{1234}\x{4321}\x{3412}b
- 0: a\x{1234}\x{4321}\x{3412}b
- 1: \x{1234}\x{4321}\x{3412}
- axxxxbcdefghijb
- 0: axxxxb
- 1: xxxx
- a\x{1234}\x{4321}\x{3412}\x{3421}b
- 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
- 1: \x{1234}\x{4321}\x{3412}\x{3421}
- axbxxbcdefghijb
- 0: axbxxb
- 1: xbxx
- axxxxxbcdefghijb
- 0: axxxxxb
- 1: xxxxx
- *** Failers
+ c
No match
- a\x{1234}b
+ \x{ff}
No match
- axxxxxxbcdefghijb
+ \x{100}
No match
-/^[a\x{c0}]/8
- *** Failers
+/^[^ab]/8D
+------------------------------------------------------------------
+ 0 37 Bra 0
+ 3 ^
+ 4 [\x00-`c-\xff] (neg)
+ 37 37 Ket
+ 40 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored utf8
+No first char
+No need char
+ c
+ 0: c
+ \x{ff}
+ 0: \x{ff}
+ \x{100}
+ 0: \x{100}
+ *** Failers
+ 0: *
+ aaa
No match
+
+/[^ab\xC0-\xF0]/8SD
+------------------------------------------------------------------
+ 0 36 Bra 0
+ 3 [\x00-`c-\xbf\xf1-\xff] (neg)
+ 36 36 Ket
+ 39 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+Study size = 40
+Starting character set: \x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0a
+ \x0b \x0c \x0d \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19
+ \x1a \x1b \x1c \x1d \x1e \x1f \x20 ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4
+ 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y
+ Z [ \ ] ^ _ ` c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ \x7f
+ \x80 \x81 \x82 \x83 \x84 \x85 \x86 \x87 \x88 \x89 \x8a \x8b \x8c \x8d \x8e
+ \x8f \x90 \x91 \x92 \x93 \x94 \x95 \x96 \x97 \x98 \x99 \x9a \x9b \x9c \x9d
+ \x9e \x9f \xa0 \xa1 \xa2 \xa3 \xa4 \xa5 \xa6 \xa7 \xa8 \xa9 \xaa \xab \xac
+ \xad \xae \xaf \xb0 \xb1 \xb2 \xb3 \xb4 \xb5 \xb6 \xb7 \xb8 \xb9 \xba \xbb
+ \xbc \xbd \xbe \xbf \xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca
+ \xcb \xcc \xcd \xce \xcf \xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9
+ \xda \xdb \xdc \xdd \xde \xdf \xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8
+ \xe9 \xea \xeb \xec \xed \xee \xef \xf0 \xf1 \xf2 \xf3 \xf4 \xf5 \xf6 \xf7
+ \xf8 \xf9 \xfa \xfb \xfc \xfd \xfe \xff
+ \x{f1}
+ 0: \x{f1}
+ \x{bf}
+ 0: \x{bf}
\x{100}
+ 0: \x{100}
+ \x{1000}
+ 0: \x{1000}
+ *** Failers
+ 0: *
+ \x{c0}
+No match
+ \x{f0}
No match
-/(?<=aXb)cd/8
- aXbcd
- 0: cd
+/Ä€{3,4}/8SD
+------------------------------------------------------------------
+ 0 13 Bra 0
+ 3 \x{100}{3}
+ 8 \x{100}{,1}
+ 13 13 Ket
+ 16 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 196
+Need char = 128
+Study returned NULL
+ \x{100}\x{100}\x{100}\x{100\x{100}
+ 0: \x{100}\x{100}\x{100}
-/(?<=a\x{100}b)cd/8
- a\x{100}bcd
- 0: cd
+/(\x{100}+|x)/8SD
+------------------------------------------------------------------
+ 0 18 Bra 0
+ 3 6 Bra 1
+ 6 \x{100}+
+ 9 6 Alt
+ 12 1 x
+ 15 12 Ket
+ 18 18 Ket
+ 21 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Options: utf8
+No first char
+No need char
+Study size = 40
+Starting character set: x \xc4
-/(?<=a\x{100000}b)cd/8
- a\x{100000}bcd
- 0: cd
-
-/(?:\x{100}){3}b/8
- \x{100}\x{100}\x{100}b
- 0: \x{100}\x{100}\x{100}b
+/(\x{100}*a|x)/8SD
+------------------------------------------------------------------
+ 0 21 Bra 0
+ 3 9 Bra 1
+ 6 \x{100}*
+ 9 1 a
+ 12 6 Alt
+ 15 1 x
+ 18 15 Ket
+ 21 21 Ket
+ 24 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Options: utf8
+No first char
+No need char
+Study size = 40
+Starting character set: a x \xc4
+
+/(\x{100}{0,2}a|x)/8SD
+------------------------------------------------------------------
+ 0 23 Bra 0
+ 3 11 Bra 1
+ 6 \x{100}{,2}
+ 11 1 a
+ 14 6 Alt
+ 17 1 x
+ 20 17 Ket
+ 23 23 Ket
+ 26 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Options: utf8
+No first char
+No need char
+Study size = 40
+Starting character set: a x \xc4
+
+/(\x{100}{1,2}a|x)/8SD
+------------------------------------------------------------------
+ 0 27 Bra 0
+ 3 15 Bra 1
+ 6 2 \x{100}
+ 10 \x{100}{,1}
+ 15 1 a
+ 18 6 Alt
+ 21 1 x
+ 24 21 Ket
+ 27 27 Ket
+ 30 End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Options: utf8
+No first char
+No need char
+Study size = 40
+Starting character set: x \xc4
+
+/\x{100}*(\d+|"(?1)")/8
+ 1234
+ 0: 1234
+ 1: 1234
+ "1234"
+ 0: "1234"
+ 1: "1234"
+ \x{100}1234
+ 0: \x{100}1234
+ 1: 1234
+ "\x{100}1234"
+ 0: \x{100}1234
+ 1: 1234
+ \x{100}\x{100}12ab
+ 0: \x{100}\x{100}12
+ 1: 12
+ \x{100}\x{100}"12"
+ 0: \x{100}\x{100}"12"
+ 1: "12"
*** Failers
No match
- \x{100}\x{100}b
+ \x{100}\x{100}abcd
No match
+/\x{100}/8D
+------------------------------------------------------------------
+ 0 7 Bra 0
+ 3 2 \x{100}
+ 7 7 Ket
+ 10 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 196
+Need char = 128
+
+/\x{100}*/8D
+------------------------------------------------------------------
+ 0 6 Bra 0
+ 3 \x{100}*
+ 6 6 Ket
+ 9 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/a\x{100}*/8D
+------------------------------------------------------------------
+ 0 9 Bra 0
+ 3 1 a
+ 6 \x{100}*
+ 9 9 Ket
+ 12 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 'a'
+No need char
+
+/ab\x{100}*/8D
+------------------------------------------------------------------
+ 0 10 Bra 0
+ 3 2 ab
+ 7 \x{100}*
+ 10 10 Ket
+ 13 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 'a'
+Need char = 'b'
+
+/a\x{100}\x{101}*/8D
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 3 a\x{100}
+ 8 \x{101}*
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 'a'
+Need char = 128
+
+/a\x{100}\x{101}+/8D
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 3 a\x{100}
+ 8 \x{101}+
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 'a'
+Need char = 129
+
+/\x{100}*A/8D
+------------------------------------------------------------------
+ 0 9 Bra 0
+ 3 \x{100}*
+ 6 1 A
+ 9 9 Ket
+ 12 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+Need char = 'A'
+ A
+ 0: A
+
+/\x{100}*\d(?R)/8D
+------------------------------------------------------------------
+ 0 10 Bra 0
+ 3 \x{100}*
+ 6 \d
+ 7 0 Recurse
+ 10 10 Ket
+ 13 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/[^\x{c4}]/D
+------------------------------------------------------------------
+ 0 36 Bra 0
+ 3 [\x01-35-bd-z|~-\xff] (neg)
+ 36 36 Ket
+ 39 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[^\x{c4}]/8D
+------------------------------------------------------------------
+ 0 36 Bra 0
+ 3 [\x00-\xc3\xc5-\xff] (neg)
+ 36 36 Ket
+ 39 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/[\x{100}]/8DM
+Memory allocation (code space): 47
+------------------------------------------------------------------
+ 0 11 Bra 0
+ 3 [\x{100}]
+ 11 11 Ket
+ 14 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+ \x{100}
+ 0: \x{100}
+ Z\x{100}
+ 0: \x{100}
+ \x{100}Z
+ 0: \x{100}
+ *** Failers
+No match
+
+/[Z\x{100}]/8DM
+Memory allocation (code space): 47
+------------------------------------------------------------------
+ 0 43 Bra 0
+ 3 [Z\x{100}]
+ 43 43 Ket
+ 46 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+ Z\x{100}
+ 0: Z
+ \x{100}
+ 0: \x{100}
+ \x{100}Z
+ 0: \x{100}
+ *** Failers
+No match
+
+/[\x{200}-\x{100}]/8
+Failed: range out of order in character class at offset 15
+
+/[Ä€-Ä„]/8
+ \x{100}
+ 0: \x{100}
+ \x{104}
+ 0: \x{104}
+ *** Failers
+No match
+ \x{105}
+No match
+ \x{ff}
+No match
+
+/[z-\x{100}]/8D
+------------------------------------------------------------------
+ 0 12 Bra 0
+ 3 [z-\x{100}]
+ 12 12 Ket
+ 15 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/[z-\x{100}]/8Di
+------------------------------------------------------------------
+ 0 45 Bra 0
+ 3 [Zz-\xff\x{100}-\x{100}]
+ 45 45 Ket
+ 48 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: caseless utf8
+No first char
+No need char
+
+/[z\Qa-d]Ä€\E]/8D
+------------------------------------------------------------------
+ 0 43 Bra 0
+ 3 [\-\]adz\x{100}]
+ 43 43 Ket
+ 46 End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+ \x{100}
+ 0: \x{100}
+ Ā
+ 0: \x{100}
+
/ End of testinput5 /
diff --git a/testdata/testoutput6 b/testdata/testoutput6
deleted file mode 100644
index fcf0846..0000000
--- a/testdata/testoutput6
+++ /dev/null
@@ -1,319 +0,0 @@
-PCRE version 3.9 02-Jan-2002
-
-/\x{100}/8DM
-Memory allocation (code space): 11
-------------------------------------------------------------------
- 0 7 Bra 0
- 3 2 \xc4\x80
- 7 7 Ket
- 10 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 196
-Need char = 128
-
-/\x{1000}/8DM
-Memory allocation (code space): 12
-------------------------------------------------------------------
- 0 8 Bra 0
- 3 3 \xe1\x80\x80
- 8 8 Ket
- 11 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 225
-Need char = 128
-
-/\x{10000}/8DM
-Memory allocation (code space): 13
-------------------------------------------------------------------
- 0 9 Bra 0
- 3 4 \xf0\x90\x80\x80
- 9 9 Ket
- 12 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 240
-Need char = 128
-
-/\x{100000}/8DM
-Memory allocation (code space): 13
-------------------------------------------------------------------
- 0 9 Bra 0
- 3 4 \xf4\x80\x80\x80
- 9 9 Ket
- 12 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 244
-Need char = 128
-
-/\x{1000000}/8DM
-Memory allocation (code space): 14
-------------------------------------------------------------------
- 0 10 Bra 0
- 3 5 \xf9\x80\x80\x80\x80
- 10 10 Ket
- 13 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 249
-Need char = 128
-
-/\x{4000000}/8DM
-Memory allocation (code space): 15
-------------------------------------------------------------------
- 0 11 Bra 0
- 3 6 \xfc\x84\x80\x80\x80\x80
- 11 11 Ket
- 14 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 252
-Need char = 128
-
-/\x{7fffFFFF}/8DM
-Memory allocation (code space): 15
-------------------------------------------------------------------
- 0 11 Bra 0
- 3 6 \xfd\xbf\xbf\xbf\xbf\xbf
- 11 11 Ket
- 14 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 253
-Need char = 191
-
-/[\x{ff}]/8DM
-Memory allocation (code space): 40
-------------------------------------------------------------------
- 0 6 Bra 0
- 3 1 \xff
- 6 6 Ket
- 9 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 255
-No need char
-
-/[\x{100}]/8DM
-Memory allocation (code space): 40
-Failed: characters with values > 255 are not yet supported in classes at offset 7
-
-/\x{ffffffff}/8
-Failed: character value in \x{...} sequence is too large at offset 11
-
-/\x{100000000}/8
-Failed: character value in \x{...} sequence is too large at offset 12
-
-/^\x{100}a\x{1234}/8
- \x{100}a\x{1234}bcd
- 0: \x{100}a\x{1234}
-
-/\x80/8D
-------------------------------------------------------------------
- 0 7 Bra 0
- 3 2 \xc2\x80
- 7 7 Ket
- 10 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 194
-Need char = 128
-
-/\xff/8D
-------------------------------------------------------------------
- 0 7 Bra 0
- 3 2 \xc3\xbf
- 7 7 Ket
- 10 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 195
-Need char = 191
-
-/\x{0041}\x{2262}\x{0391}\x{002e}/D8
-------------------------------------------------------------------
- 0 12 Bra 0
- 3 7 A\xe2\x89\xa2\xce\x91.
- 12 12 Ket
- 15 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 'A'
-Need char = '.'
- \x{0041}\x{2262}\x{0391}\x{002e}
- 0: A\x{2262}\x{391}.
-
-/\x{D55c}\x{ad6d}\x{C5B4}/D8
-------------------------------------------------------------------
- 0 14 Bra 0
- 3 9 \xed\x95\x9c\xea\xb5\xad\xec\x96\xb4
- 14 14 Ket
- 17 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 237
-Need char = 180
- \x{D55c}\x{ad6d}\x{C5B4}
- 0: \x{d55c}\x{ad6d}\x{c5b4}
-
-/\x{65e5}\x{672c}\x{8a9e}/D8
-------------------------------------------------------------------
- 0 14 Bra 0
- 3 9 \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e
- 14 14 Ket
- 17 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 230
-Need char = 158
- \x{65e5}\x{672c}\x{8a9e}
- 0: \x{65e5}\x{672c}\x{8a9e}
-
-/\x{80}/D8
-------------------------------------------------------------------
- 0 7 Bra 0
- 3 2 \xc2\x80
- 7 7 Ket
- 10 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 194
-Need char = 128
-
-/\x{084}/D8
-------------------------------------------------------------------
- 0 7 Bra 0
- 3 2 \xc2\x84
- 7 7 Ket
- 10 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 194
-Need char = 132
-
-/\x{104}/D8
-------------------------------------------------------------------
- 0 7 Bra 0
- 3 2 \xc4\x84
- 7 7 Ket
- 10 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 196
-Need char = 132
-
-/\x{861}/D8
-------------------------------------------------------------------
- 0 8 Bra 0
- 3 3 \xe0\xa1\xa1
- 8 8 Ket
- 11 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 224
-Need char = 161
-
-/\x{212ab}/D8
-------------------------------------------------------------------
- 0 9 Bra 0
- 3 4 \xf0\xa1\x8a\xab
- 9 9 Ket
- 12 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-First char = 240
-Need char = 171
-
-/.{3,5}X/D8
-------------------------------------------------------------------
- 0 14 Bra 0
- 3 Any{3}
- 7 Any{0,2}
- 11 1 X
- 14 14 Ket
- 17 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-No first char
-Need char = 'X'
- \x{212ab}\x{212ab}\x{212ab}\x{861}X
- 0: \x{212ab}\x{212ab}\x{212ab}\x{861}X
-
-
-/.{3,5}?/D8
-------------------------------------------------------------------
- 0 11 Bra 0
- 3 Any{3}
- 7 Any{0,2}?
- 11 11 Ket
- 14 End
-------------------------------------------------------------------
-Capturing subpattern count = 0
-Options: utf8
-No first char
-No need char
- \x{212ab}\x{212ab}\x{212ab}\x{861}
- 0: \x{212ab}\x{212ab}\x{212ab}
-
-/-- These tests are here rather than in testinput5 because Perl 5.6 has --/
-/-- some problems with UTF-8 support, in the area of \x{..} where the --/
-No match
-/-- value is < 255. It grumbles about invalid UTF-8 strings. --/
-No match
-
-/^[a\x{c0}]b/8
- \x{c0}b
- 0: \x{c0}b
-
-/^([a\x{c0}]*?)aa/8
- a\x{c0}aaaa/
- 0: a\x{c0}aa
- 1: a\x{c0}
-
-/^([a\x{c0}]*?)aa/8
- a\x{c0}aaaa/
- 0: a\x{c0}aa
- 1: a\x{c0}
- a\x{c0}a\x{c0}aaa/
- 0: a\x{c0}a\x{c0}aa
- 1: a\x{c0}a\x{c0}
-
-/^([a\x{c0}]*)aa/8
- a\x{c0}aaaa/
- 0: a\x{c0}aaaa
- 1: a\x{c0}aa
- a\x{c0}a\x{c0}aaa/
- 0: a\x{c0}a\x{c0}aaa
- 1: a\x{c0}a\x{c0}a
-
-/^([a\x{c0}]*)a\x{c0}/8
- a\x{c0}aaaa/
- 0: a\x{c0}
- 1:
- a\x{c0}a\x{c0}aaa/
- 0: a\x{c0}a\x{c0}
- 1: a\x{c0}
-
-/ End of testinput6 /
-