summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-04-17 08:22:40 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-04-17 08:22:40 +0000
commitc2ca0181556e8224559ea493ebe08ad3ab1e986d (patch)
tree102a51f4c58b029b4245299e060f3d2a2a04a8a6
parent99c49a95b9892e71ec8cd69cd1bcb3a96964ba15 (diff)
downloadpcre-c2ca0181556e8224559ea493ebe08ad3ab1e986d.tar.gz
Update HTML documentation.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@150 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog10
-rw-r--r--configure.ac2
-rw-r--r--doc/html/pcre_compile.html1
-rw-r--r--doc/html/pcre_compile2.html1
-rw-r--r--doc/html/pcre_config.html1
-rw-r--r--doc/html/pcre_dfa_exec.html1
-rw-r--r--doc/html/pcre_exec.html1
-rw-r--r--doc/html/pcreapi.html44
-rw-r--r--doc/html/pcrebuild.html9
-rw-r--r--doc/html/pcregrep.html19
-rw-r--r--doc/html/pcretest.html28
-rw-r--r--doc/pcre.txt552
-rw-r--r--doc/pcre_compile.32
-rw-r--r--doc/pcre_exec.32
-rw-r--r--doc/pcreapi.34
-rw-r--r--doc/pcregrep.12
-rw-r--r--doc/pcregrep.txt129
-rw-r--r--doc/pcretest.txt29
-rw-r--r--pcre_compile.c4
-rw-r--r--pcre_dfa_exec.c8
-rw-r--r--pcre_exec.c8
-rw-r--r--pcre_internal.h4
-rw-r--r--pcre_newline.c10
-rw-r--r--pcregrep.c12
-rw-r--r--pcretest.c8
25 files changed, 462 insertions, 429 deletions
diff --git a/ChangeLog b/ChangeLog
index 4696346..44a1d4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -135,13 +135,13 @@ Version 7.1 12-Mar-07
was because its rules for how to advance for /g after matching an empty
string at the end of a line did not allow for this case. They now check for
it specially.
-
-20. pcretest is supposed to handle patterns and data of any length, by
- extending its buffers when necessary. It was getting this wrong when the
+
+20. pcretest is supposed to handle patterns and data of any length, by
+ extending its buffers when necessary. It was getting this wrong when the
buffer for a data line had to be extended.
-
+
21. Added PCRE_NEWLINE_ANYCRLF which is like ANY, but matches only CR, LF, or
- CRLF as a newline sequence.
+ CRLF as a newline sequence.
Version 7.0 19-Dec-06
diff --git a/configure.ac b/configure.ac
index 38cb057..5578a35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -170,7 +170,7 @@ case "$enable_newline" in
lf) ac_pcre_newline_value=10 ;;
cr) ac_pcre_newline_value=13 ;;
crlf) ac_pcre_newline_value=3338 ;;
- anycrlf) ac_pcre_newline_value=-2 ;;
+ anycrlf) ac_pcre_newline_value=-2 ;;
any) ac_pcre_newline_value=-1 ;;
*)
AC_MSG_ERROR([invalid argument \"$enable_newline\" to --enable-newline option])
diff --git a/doc/html/pcre_compile.html b/doc/html/pcre_compile.html
index e69078c..e43f9fe 100644
--- a/doc/html/pcre_compile.html
+++ b/doc/html/pcre_compile.html
@@ -53,6 +53,7 @@ The option bits are:
PCRE_FIRSTLINE Force matching to be before newline
PCRE_MULTILINE ^ and $ match newlines within data
PCRE_NEWLINE_ANY Recognize any Unicode newline sequence
+ PCRE_NEWLINE_ANYCRLF Recognize CR, LF, and CRLF as newline sequences
PCRE_NEWLINE_CR Set CR as the newline sequence
PCRE_NEWLINE_CRLF Set CRLF as the newline sequence
PCRE_NEWLINE_LF Set LF as the newline sequence
diff --git a/doc/html/pcre_compile2.html b/doc/html/pcre_compile2.html
index e17a698..a71c4d7 100644
--- a/doc/html/pcre_compile2.html
+++ b/doc/html/pcre_compile2.html
@@ -57,6 +57,7 @@ The option bits are:
PCRE_FIRSTLINE Force matching to be before newline
PCRE_MULTILINE ^ and $ match newlines within data
PCRE_NEWLINE_ANY Recognize any Unicode newline sequence
+ PCRE_NEWLINE_ANYCRLF Recognize CR, LF, and CRLF as newline sequences
PCRE_NEWLINE_CR Set CR as the newline sequence
PCRE_NEWLINE_CRLF Set CRLF as the newline sequence
PCRE_NEWLINE_LF Set LF as the newline sequence
diff --git a/doc/html/pcre_config.html b/doc/html/pcre_config.html
index d362cd6..3e8e79d 100644
--- a/doc/html/pcre_config.html
+++ b/doc/html/pcre_config.html
@@ -42,6 +42,7 @@ The available codes are:
13 (0x000d) for CR
10 (0x000a) for LF
3338 (0x0d0a) for CRLF
+ -2 for ANYCRLF
-1 for ANY
PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
Threshold of return slots, above
diff --git a/doc/html/pcre_dfa_exec.html b/doc/html/pcre_dfa_exec.html
index 92b444f..eedbf8c 100644
--- a/doc/html/pcre_dfa_exec.html
+++ b/doc/html/pcre_dfa_exec.html
@@ -50,6 +50,7 @@ The options are:
<pre>
PCRE_ANCHORED Match only at the first position
PCRE_NEWLINE_ANY Recognize any Unicode newline sequence
+ PCRE_NEWLINE_ANYCRLF Recognize CR, LF, and CRLF as newline sequences
PCRE_NEWLINE_CR Set CR as the newline sequence
PCRE_NEWLINE_CRLF Set CRLF as the newline sequence
PCRE_NEWLINE_LF Set LF as the newline sequence
diff --git a/doc/html/pcre_exec.html b/doc/html/pcre_exec.html
index 9da31a1..c67544e 100644
--- a/doc/html/pcre_exec.html
+++ b/doc/html/pcre_exec.html
@@ -46,6 +46,7 @@ The options are:
<pre>
PCRE_ANCHORED Match only at the first position
PCRE_NEWLINE_ANY Recognize any Unicode newline sequence
+ PCRE_NEWLINE_ANYCRLF Recognize CR, LF, and CRLF as newline sequences
PCRE_NEWLINE_CR Set CR as the newline sequence
PCRE_NEWLINE_CRLF Set CRLF as the newline sequence
PCRE_NEWLINE_LF Set LF as the newline sequence
diff --git a/doc/html/pcreapi.html b/doc/html/pcreapi.html
index ce393a8..34011a8 100644
--- a/doc/html/pcreapi.html
+++ b/doc/html/pcreapi.html
@@ -246,12 +246,13 @@ documentation.
</P>
<br><a name="SEC3" href="#TOC1">NEWLINES</a><br>
<P>
-PCRE supports four different conventions for indicating line breaks in
+PCRE supports five different conventions for indicating line breaks in
strings: a single CR (carriage return) character, a single LF (linefeed)
-character, the two-character sequence CRLF, or any Unicode newline sequence.
-The Unicode newline sequences are the three just mentioned, plus the single
-characters VT (vertical tab, U+000B), FF (formfeed, U+000C), NEL (next line,
-U+0085), LS (line separator, U+2028), and PS (paragraph separator, U+2029).
+character, the two-character sequence CRLF, any of the three preceding, or any
+Unicode newline sequence. The Unicode newline sequences are the three just
+mentioned, plus the single characters VT (vertical tab, U+000B), FF (formfeed,
+U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS
+(paragraph separator, U+2029).
</P>
<P>
Each of the first three conventions is used by at least one operating system as
@@ -317,8 +318,8 @@ properties is available; otherwise it is set to zero.
</pre>
The output is an integer whose value specifies the default character sequence
that is recognized as meaning "newline". The four values that are supported
-are: 10 for LF, 13 for CR, 3338 for CRLF, and -1 for ANY. The default should
-normally be the standard sequence for your operating system.
+are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF, and -1 for ANY. The
+default should normally be the standard sequence for your operating system.
<pre>
PCRE_CONFIG_LINK_SIZE
</pre>
@@ -546,25 +547,28 @@ occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect.
PCRE_NEWLINE_CR
PCRE_NEWLINE_LF
PCRE_NEWLINE_CRLF
+ PCRE_NEWLINE_ANYCRLF
PCRE_NEWLINE_ANY
</pre>
These options override the default newline definition that was chosen when PCRE
was built. Setting the first or the second specifies that a newline is
indicated by a single character (CR or LF, respectively). Setting
PCRE_NEWLINE_CRLF specifies that a newline is indicated by the two-character
-CRLF sequence. Setting PCRE_NEWLINE_ANY specifies that any Unicode newline
-sequence should be recognized. The Unicode newline sequences are the three just
-mentioned, plus the single characters VT (vertical tab, U+000B), FF (formfeed,
-U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS
-(paragraph separator, U+2029). The last two are recognized only in UTF-8 mode.
+CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies that any of the three
+preceding sequences should be recognized. Setting PCRE_NEWLINE_ANY specifies
+that any Unicode newline sequence should be recognized. The Unicode newline
+sequences are the three just mentioned, plus the single characters VT (vertical
+tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS (line
+separator, U+2028), and PS (paragraph separator, U+2029). The last two are
+recognized only in UTF-8 mode.
</P>
<P>
The newline setting in the options word uses three bits that are treated
-as a number, giving eight possibilities. Currently only five are used (default
-plus the four values above). This means that if you set more than one newline
+as a number, giving eight possibilities. Currently only six are used (default
+plus the five values above). This means that if you set more than one newline
option, the combination may or may not be sensible. For example,
PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to PCRE_NEWLINE_CRLF, but
-other combinations yield unused numbers and cause an error.
+other combinations may yield unused numbers and cause an error.
</P>
<P>
The only time that a line break is specially recognized when compiling a
@@ -1166,6 +1170,7 @@ matching time.
PCRE_NEWLINE_CR
PCRE_NEWLINE_LF
PCRE_NEWLINE_CRLF
+ PCRE_NEWLINE_ANYCRLF
PCRE_NEWLINE_ANY
</pre>
These options override the newline definition that was chosen or defaulted when
@@ -1173,9 +1178,10 @@ the pattern was compiled. For details, see the description of
<b>pcre_compile()</b> above. During matching, the newline choice affects the
behaviour of the dot, circumflex, and dollar metacharacters. It may also alter
the way the match position is advanced after a match failure for an unanchored
-pattern. When PCRE_NEWLINE_CRLF or PCRE_NEWLINE_ANY is set, and a match attempt
-fails when the current position is at a CRLF sequence, the match position is
-advanced by two characters instead of one, in other words, to after the CRLF.
+pattern. When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is
+set, and a match attempt fails when the current position is at a CRLF sequence,
+the match position is advanced by two characters instead of one, in other
+words, to after the CRLF.
<pre>
PCRE_NOTBOL
</pre>
@@ -1851,7 +1857,7 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC22" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 06 March 2007
+Last updated: 16 April 2007
<br>
Copyright &copy; 1997-2007 University of Cambridge.
<br>
diff --git a/doc/html/pcrebuild.html b/doc/html/pcrebuild.html
index 63635aa..1284646 100644
--- a/doc/html/pcrebuild.html
+++ b/doc/html/pcrebuild.html
@@ -106,9 +106,14 @@ character sequence CRLF. If you want this, add
</pre>
to the <b>configure</b> command. There is a fourth option, specified by
<pre>
+ --enable-newline-is-anycrlf
+</pre>
+which causes PCRE to recognize any of the three sequences CR, LF, or CRLF as
+indicating a line ending. Finally, a fifth option, specified by
+<pre>
--enable-newline-is-any
</pre>
-which causes PCRE to recognize any Unicode newline sequence.
+causes PCRE to recognize any Unicode newline sequence.
</P>
<P>
Whatever line ending convention is selected when PCRE is built can be
@@ -255,7 +260,7 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC15" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 20 March 2007
+Last updated: 16 April 2007
<br>
Copyright &copy; 1997-2007 University of Cambridge.
<br>
diff --git a/doc/html/pcregrep.html b/doc/html/pcregrep.html
index 12eee36..dd84780 100644
--- a/doc/html/pcregrep.html
+++ b/doc/html/pcregrep.html
@@ -270,23 +270,24 @@ are guaranteed to be available for lookbehind assertions.
</P>
<P>
<b>-N</b> <i>newline-type</i>, <b>--newline=</b><i>newline-type</i>
-The PCRE library supports four different conventions for indicating
+The PCRE library supports five different conventions for indicating
the ends of lines. They are the single-character sequences CR (carriage return)
-and LF (linefeed), the two-character sequence CRLF, and an "any" convention, in
+and LF (linefeed), the two-character sequence CRLF, an "anycrlf" convention,
+which recognizes any of the preceding three types, and an "any" convention, in
which any Unicode line ending sequence is assumed to end a line. The Unicode
sequences are the three just mentioned, plus VT (vertical tab, U+000B), FF
(formfeed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and
-PS (paragraph separator, U+0029).
+PS (paragraph separator, U+2029).
<br>
<br>
When the PCRE library is built, a default line-ending sequence is specified.
This is normally the standard sequence for the operating system. Unless
otherwise specified by this option, <b>pcregrep</b> uses the library's default.
-The possible values for this option are CR, LF, CRLF, or ANY. This makes it
-possible to use <b>pcregrep</b> on files that have come from other environments
-without having to modify their line endings. If the data that is being scanned
-does not agree with the convention set by this option, <b>pcregrep</b> may
-behave in strange ways.
+The possible values for this option are CR, LF, CRLF, ANYCRLF, or ANY. This
+makes it possible to use <b>pcregrep</b> on files that have come from other
+environments without having to modify their line endings. If the data that is
+being scanned does not agree with the convention set by this option,
+<b>pcregrep</b> may behave in strange ways.
</P>
<P>
<b>-n</b>, <b>--line-number</b>
@@ -431,7 +432,7 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC12" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 06 March 2007
+Last updated: 16 April 2007
<br>
Copyright &copy; 1997-2007 University of Cambridge.
<br>
diff --git a/doc/html/pcretest.html b/doc/html/pcretest.html
index e35f732..680a4d2 100644
--- a/doc/html/pcretest.html
+++ b/doc/html/pcretest.html
@@ -191,18 +191,19 @@ effect as they do in Perl. For example:
The following table shows additional modifiers for setting PCRE options that do
not correspond to anything in Perl:
<pre>
- <b>/A</b> PCRE_ANCHORED
- <b>/C</b> PCRE_AUTO_CALLOUT
- <b>/E</b> PCRE_DOLLAR_ENDONLY
- <b>/f</b> PCRE_FIRSTLINE
- <b>/J</b> PCRE_DUPNAMES
- <b>/N</b> PCRE_NO_AUTO_CAPTURE
- <b>/U</b> PCRE_UNGREEDY
- <b>/X</b> PCRE_EXTRA
- <b>/&#60;cr&#62;</b> PCRE_NEWLINE_CR
- <b>/&#60;lf&#62;</b> PCRE_NEWLINE_LF
- <b>/&#60;crlf&#62;</b> PCRE_NEWLINE_CRLF
- <b>/&#60;any&#62;</b> PCRE_NEWLINE_ANY
+ <b>/A</b> PCRE_ANCHORED
+ <b>/C</b> PCRE_AUTO_CALLOUT
+ <b>/E</b> PCRE_DOLLAR_ENDONLY
+ <b>/f</b> PCRE_FIRSTLINE
+ <b>/J</b> PCRE_DUPNAMES
+ <b>/N</b> PCRE_NO_AUTO_CAPTURE
+ <b>/U</b> PCRE_UNGREEDY
+ <b>/X</b> PCRE_EXTRA
+ <b>/&#60;cr&#62;</b> PCRE_NEWLINE_CR
+ <b>/&#60;lf&#62;</b> PCRE_NEWLINE_LF
+ <b>/&#60;crlf&#62;</b> PCRE_NEWLINE_CRLF
+ <b>/&#60;anycrlf&#62;</b> PCRE_NEWLINE_ANY
+ <b>/&#60;any&#62;</b> PCRE_NEWLINE_ANY
</pre>
Those specifying line ending sequencess are literal strings as shown. This
example sets multiline matching with CRLF as the line ending sequence:
@@ -365,6 +366,7 @@ recognized:
\&#60;cr&#62; pass the PCRE_NEWLINE_CR option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
\&#60;lf&#62; pass the PCRE_NEWLINE_LF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
\&#60;crlf&#62; pass the PCRE_NEWLINE_CRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+ \&#60;anycrlf&#62; pass the PCRE_NEWLINE_ANYCRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
\&#60;any&#62; pass the PCRE_NEWLINE_ANY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
</pre>
The escapes that specify line ending sequences are literal strings, exactly as
@@ -666,7 +668,7 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC15" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 06 March 2007
+Last updated: 16 April 2007
<br>
Copyright &copy; 1997-2007 University of Cambridge.
<br>
diff --git a/doc/pcre.txt b/doc/pcre.txt
index 3adee5d..658f750 100644
--- a/doc/pcre.txt
+++ b/doc/pcre.txt
@@ -312,9 +312,14 @@ CODE VALUE OF NEWLINE
to the configure command. There is a fourth option, specified by
+ --enable-newline-is-anycrlf
+
+ which causes PCRE to recognize any of the three sequences CR, LF, or
+ CRLF as indicating a line ending. Finally, a fifth option, specified by
+
--enable-newline-is-any
- which causes PCRE to recognize any Unicode newline sequence.
+ causes PCRE to recognize any Unicode newline sequence.
Whatever line ending convention is selected when PCRE is built can be
overridden when the library functions are called. At build time it is
@@ -468,7 +473,7 @@ AUTHOR
REVISION
- Last updated: 20 March 2007
+ Last updated: 16 April 2007
Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
@@ -841,13 +846,13 @@ PCRE API OVERVIEW
NEWLINES
- PCRE supports four different conventions for indicating line breaks in
+ PCRE supports five different conventions for indicating line breaks in
strings: a single CR (carriage return) character, a single LF (line-
- feed) character, the two-character sequence CRLF, or any Unicode new-
- line sequence. The Unicode newline sequences are the three just men-
- tioned, plus the single characters VT (vertical tab, U+000B), FF (form-
- feed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028),
- and PS (paragraph separator, U+2029).
+ feed) character, the two-character sequence CRLF, any of the three pre-
+ ceding, or any Unicode newline sequence. The Unicode newline sequences
+ are the three just mentioned, plus the single characters VT (vertical
+ tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS (line
+ separator, U+2028), and PS (paragraph separator, U+2029).
Each of the first three conventions is used by at least one operating
system as its standard newline sequence. When PCRE is built, a default
@@ -912,9 +917,9 @@ CHECKING BUILD-TIME OPTIONS
The output is an integer whose value specifies the default character
sequence that is recognized as meaning "newline". The four values that
- are supported are: 10 for LF, 13 for CR, 3338 for CRLF, and -1 for ANY.
- The default should normally be the standard sequence for your operating
- system.
+ are supported are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF,
+ and -1 for ANY. The default should normally be the standard sequence
+ for your operating system.
PCRE_CONFIG_LINK_SIZE
@@ -1138,26 +1143,29 @@ COMPILING A PATTERN
PCRE_NEWLINE_CR
PCRE_NEWLINE_LF
PCRE_NEWLINE_CRLF
+ PCRE_NEWLINE_ANYCRLF
PCRE_NEWLINE_ANY
These options override the default newline definition that was chosen
when PCRE was built. Setting the first or the second specifies that a
newline is indicated by a single character (CR or LF, respectively).
Setting PCRE_NEWLINE_CRLF specifies that a newline is indicated by the
- two-character CRLF sequence. Setting PCRE_NEWLINE_ANY specifies that
- any Unicode newline sequence should be recognized. The Unicode newline
- sequences are the three just mentioned, plus the single characters VT
- (vertical tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085),
- LS (line separator, U+2028), and PS (paragraph separator, U+2029). The
- last two are recognized only in UTF-8 mode.
+ two-character CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies
+ that any of the three preceding sequences should be recognized. Setting
+ PCRE_NEWLINE_ANY specifies that any Unicode newline sequence should be
+ recognized. The Unicode newline sequences are the three just mentioned,
+ plus the single characters VT (vertical tab, U+000B), FF (formfeed,
+ U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS
+ (paragraph separator, U+2029). The last two are recognized only in
+ UTF-8 mode.
The newline setting in the options word uses three bits that are
- treated as a number, giving eight possibilities. Currently only five
- are used (default plus the four values above). This means that if you
- set more than one newline option, the combination may or may not be
- sensible. For example, PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equiva-
- lent to PCRE_NEWLINE_CRLF, but other combinations yield unused numbers
- and cause an error.
+ treated as a number, giving eight possibilities. Currently only six are
+ used (default plus the five values above). This means that if you set
+ more than one newline option, the combination may or may not be sensi-
+ ble. For example, PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to
+ PCRE_NEWLINE_CRLF, but other combinations may yield unused numbers and
+ cause an error.
The only time that a line break is specially recognized when compiling
a pattern is if PCRE_EXTENDED is set, and an unescaped # outside a
@@ -1725,6 +1733,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
PCRE_NEWLINE_CR
PCRE_NEWLINE_LF
PCRE_NEWLINE_CRLF
+ PCRE_NEWLINE_ANYCRLF
PCRE_NEWLINE_ANY
These options override the newline definition that was chosen or
@@ -1732,190 +1741,191 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
tion of pcre_compile() above. During matching, the newline choice
affects the behaviour of the dot, circumflex, and dollar metacharac-
ters. It may also alter the way the match position is advanced after a
- match failure for an unanchored pattern. When PCRE_NEWLINE_CRLF or
- PCRE_NEWLINE_ANY is set, and a match attempt fails when the current
- position is at a CRLF sequence, the match position is advanced by two
- characters instead of one, in other words, to after the CRLF.
+ match failure for an unanchored pattern. When PCRE_NEWLINE_CRLF,
+ PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is set, and a match attempt
+ fails when the current position is at a CRLF sequence, the match posi-
+ tion is advanced by two characters instead of one, in other words, to
+ after the CRLF.
PCRE_NOTBOL
This option specifies that first character of the subject string is not
- the beginning of a line, so the circumflex metacharacter should not
- match before it. Setting this without PCRE_MULTILINE (at compile time)
- causes circumflex never to match. This option affects only the behav-
+ the beginning of a line, so the circumflex metacharacter should not
+ match before it. Setting this without PCRE_MULTILINE (at compile time)
+ causes circumflex never to match. This option affects only the behav-
iour of the circumflex metacharacter. It does not affect \A.
PCRE_NOTEOL
This option specifies that the end of the subject string is not the end
- of a line, so the dollar metacharacter should not match it nor (except
- in multiline mode) a newline immediately before it. Setting this with-
+ of a line, so the dollar metacharacter should not match it nor (except
+ in multiline mode) a newline immediately before it. Setting this with-
out PCRE_MULTILINE (at compile time) causes dollar never to match. This
- option affects only the behaviour of the dollar metacharacter. It does
+ option affects only the behaviour of the dollar metacharacter. It does
not affect \Z or \z.
PCRE_NOTEMPTY
An empty string is not considered to be a valid match if this option is
- set. If there are alternatives in the pattern, they are tried. If all
- the alternatives match the empty string, the entire match fails. For
+ set. If there are alternatives in the pattern, they are tried. If all
+ the alternatives match the empty string, the entire match fails. For
example, if the pattern
a?b?
- is applied to a string not beginning with "a" or "b", it matches the
- empty string at the start of the subject. With PCRE_NOTEMPTY set, this
+ is applied to a string not beginning with "a" or "b", it matches the
+ empty string at the start of the subject. With PCRE_NOTEMPTY set, this
match is not valid, so PCRE searches further into the string for occur-
rences of "a" or "b".
Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a spe-
- cial case of a pattern match of the empty string within its split()
- function, and when using the /g modifier. It is possible to emulate
+ cial case of a pattern match of the empty string within its split()
+ function, and when using the /g modifier. It is possible to emulate
Perl's behaviour after matching a null string by first trying the match
again at the same offset with PCRE_NOTEMPTY and PCRE_ANCHORED, and then
- if that fails by advancing the starting offset (see below) and trying
+ if that fails by advancing the starting offset (see below) and trying
an ordinary match again. There is some code that demonstrates how to do
this in the pcredemo.c sample program.
PCRE_NO_UTF8_CHECK
When PCRE_UTF8 is set at compile time, the validity of the subject as a
- UTF-8 string is automatically checked when pcre_exec() is subsequently
- called. The value of startoffset is also checked to ensure that it
- points to the start of a UTF-8 character. If an invalid UTF-8 sequence
+ UTF-8 string is automatically checked when pcre_exec() is subsequently
+ called. The value of startoffset is also checked to ensure that it
+ points to the start of a UTF-8 character. If an invalid UTF-8 sequence
of bytes is found, pcre_exec() returns the error PCRE_ERROR_BADUTF8. If
- startoffset contains an invalid value, PCRE_ERROR_BADUTF8_OFFSET is
+ startoffset contains an invalid value, PCRE_ERROR_BADUTF8_OFFSET is
returned.
- If you already know that your subject is valid, and you want to skip
- these checks for performance reasons, you can set the
- PCRE_NO_UTF8_CHECK option when calling pcre_exec(). You might want to
- do this for the second and subsequent calls to pcre_exec() if you are
- making repeated calls to find all the matches in a single subject
- string. However, you should be sure that the value of startoffset
- points to the start of a UTF-8 character. When PCRE_NO_UTF8_CHECK is
- set, the effect of passing an invalid UTF-8 string as a subject, or a
- value of startoffset that does not point to the start of a UTF-8 char-
+ If you already know that your subject is valid, and you want to skip
+ these checks for performance reasons, you can set the
+ PCRE_NO_UTF8_CHECK option when calling pcre_exec(). You might want to
+ do this for the second and subsequent calls to pcre_exec() if you are
+ making repeated calls to find all the matches in a single subject
+ string. However, you should be sure that the value of startoffset
+ points to the start of a UTF-8 character. When PCRE_NO_UTF8_CHECK is
+ set, the effect of passing an invalid UTF-8 string as a subject, or a
+ value of startoffset that does not point to the start of a UTF-8 char-
acter, is undefined. Your program may crash.
PCRE_PARTIAL
- This option turns on the partial matching feature. If the subject
- string fails to match the pattern, but at some point during the match-
- ing process the end of the subject was reached (that is, the subject
- partially matches the pattern and the failure to match occurred only
- because there were not enough subject characters), pcre_exec() returns
- PCRE_ERROR_PARTIAL instead of PCRE_ERROR_NOMATCH. When PCRE_PARTIAL is
- used, there are restrictions on what may appear in the pattern. These
+ This option turns on the partial matching feature. If the subject
+ string fails to match the pattern, but at some point during the match-
+ ing process the end of the subject was reached (that is, the subject
+ partially matches the pattern and the failure to match occurred only
+ because there were not enough subject characters), pcre_exec() returns
+ PCRE_ERROR_PARTIAL instead of PCRE_ERROR_NOMATCH. When PCRE_PARTIAL is
+ used, there are restrictions on what may appear in the pattern. These
are discussed in the pcrepartial documentation.
The string to be matched by pcre_exec()
- The subject string is passed to pcre_exec() as a pointer in subject, a
- length in length, and a starting byte offset in startoffset. In UTF-8
- mode, the byte offset must point to the start of a UTF-8 character.
- Unlike the pattern string, the subject may contain binary zero bytes.
- When the starting offset is zero, the search for a match starts at the
+ The subject string is passed to pcre_exec() as a pointer in subject, a
+ length in length, and a starting byte offset in startoffset. In UTF-8
+ mode, the byte offset must point to the start of a UTF-8 character.
+ Unlike the pattern string, the subject may contain binary zero bytes.
+ When the starting offset is zero, the search for a match starts at the
beginning of the subject, and this is by far the most common case.
- A non-zero starting offset is useful when searching for another match
- in the same subject by calling pcre_exec() again after a previous suc-
- cess. Setting startoffset differs from just passing over a shortened
- string and setting PCRE_NOTBOL in the case of a pattern that begins
+ A non-zero starting offset is useful when searching for another match
+ in the same subject by calling pcre_exec() again after a previous suc-
+ cess. Setting startoffset differs from just passing over a shortened
+ string and setting PCRE_NOTBOL in the case of a pattern that begins
with any kind of lookbehind. For example, consider the pattern
\Biss\B
- which finds occurrences of "iss" in the middle of words. (\B matches
- only if the current position in the subject is not a word boundary.)
- When applied to the string "Mississipi" the first call to pcre_exec()
- finds the first occurrence. If pcre_exec() is called again with just
- the remainder of the subject, namely "issipi", it does not match,
+ which finds occurrences of "iss" in the middle of words. (\B matches
+ only if the current position in the subject is not a word boundary.)
+ When applied to the string "Mississipi" the first call to pcre_exec()
+ finds the first occurrence. If pcre_exec() is called again with just
+ the remainder of the subject, namely "issipi", it does not match,
because \B is always false at the start of the subject, which is deemed
- to be a word boundary. However, if pcre_exec() is passed the entire
+ to be a word boundary. However, if pcre_exec() is passed the entire
string again, but with startoffset set to 4, it finds the second occur-
- rence of "iss" because it is able to look behind the starting point to
+ rence of "iss" because it is able to look behind the starting point to
discover that it is preceded by a letter.
- If a non-zero starting offset is passed when the pattern is anchored,
+ If a non-zero starting offset is passed when the pattern is anchored,
one attempt to match at the given offset is made. This can only succeed
- if the pattern does not require the match to be at the start of the
+ if the pattern does not require the match to be at the start of the
subject.
How pcre_exec() returns captured substrings
- In general, a pattern matches a certain portion of the subject, and in
- addition, further substrings from the subject may be picked out by
- parts of the pattern. Following the usage in Jeffrey Friedl's book,
- this is called "capturing" in what follows, and the phrase "capturing
- subpattern" is used for a fragment of a pattern that picks out a sub-
- string. PCRE supports several other kinds of parenthesized subpattern
+ In general, a pattern matches a certain portion of the subject, and in
+ addition, further substrings from the subject may be picked out by
+ parts of the pattern. Following the usage in Jeffrey Friedl's book,
+ this is called "capturing" in what follows, and the phrase "capturing
+ subpattern" is used for a fragment of a pattern that picks out a sub-
+ string. PCRE supports several other kinds of parenthesized subpattern
that do not cause substrings to be captured.
- Captured substrings are returned to the caller via a vector of integer
- offsets whose address is passed in ovector. The number of elements in
- the vector is passed in ovecsize, which must be a non-negative number.
+ Captured substrings are returned to the caller via a vector of integer
+ offsets whose address is passed in ovector. The number of elements in
+ the vector is passed in ovecsize, which must be a non-negative number.
Note: this argument is NOT the size of ovector in bytes.
- The first two-thirds of the vector is used to pass back captured sub-
- strings, each substring using a pair of integers. The remaining third
- of the vector is used as workspace by pcre_exec() while matching cap-
- turing subpatterns, and is not available for passing back information.
- The length passed in ovecsize should always be a multiple of three. If
+ The first two-thirds of the vector is used to pass back captured sub-
+ strings, each substring using a pair of integers. The remaining third
+ of the vector is used as workspace by pcre_exec() while matching cap-
+ turing subpatterns, and is not available for passing back information.
+ The length passed in ovecsize should always be a multiple of three. If
it is not, it is rounded down.
- When a match is successful, information about captured substrings is
- returned in pairs of integers, starting at the beginning of ovector,
- and continuing up to two-thirds of its length at the most. The first
+ When a match is successful, information about captured substrings is
+ returned in pairs of integers, starting at the beginning of ovector,
+ and continuing up to two-thirds of its length at the most. The first
element of a pair is set to the offset of the first character in a sub-
- string, and the second is set to the offset of the first character
- after the end of a substring. The first pair, ovector[0] and ovec-
- tor[1], identify the portion of the subject string matched by the
- entire pattern. The next pair is used for the first capturing subpat-
+ string, and the second is set to the offset of the first character
+ after the end of a substring. The first pair, ovector[0] and ovec-
+ tor[1], identify the portion of the subject string matched by the
+ entire pattern. The next pair is used for the first capturing subpat-
tern, and so on. The value returned by pcre_exec() is one more than the
highest numbered pair that has been set. For example, if two substrings
- have been captured, the returned value is 3. If there are no capturing
- subpatterns, the return value from a successful match is 1, indicating
+ have been captured, the returned value is 3. If there are no capturing
+ subpatterns, the return value from a successful match is 1, indicating
that just the first pair of offsets has been set.
If a capturing subpattern is matched repeatedly, it is the last portion
of the string that it matched that is returned.
- If the vector is too small to hold all the captured substring offsets,
+ If the vector is too small to hold all the captured substring offsets,
it is used as far as possible (up to two-thirds of its length), and the
- function returns a value of zero. In particular, if the substring off-
+ function returns a value of zero. In particular, if the substring off-
sets are not of interest, pcre_exec() may be called with ovector passed
- as NULL and ovecsize as zero. However, if the pattern contains back
- references and the ovector is not big enough to remember the related
- substrings, PCRE has to get additional memory for use during matching.
+ as NULL and ovecsize as zero. However, if the pattern contains back
+ references and the ovector is not big enough to remember the related
+ substrings, PCRE has to get additional memory for use during matching.
Thus it is usually advisable to supply an ovector.
- The pcre_info() function can be used to find out how many capturing
- subpatterns there are in a compiled pattern. The smallest size for
- ovector that will allow for n captured substrings, in addition to the
+ The pcre_info() function can be used to find out how many capturing
+ subpatterns there are in a compiled pattern. The smallest size for
+ ovector that will allow for n captured substrings, in addition to the
offsets of the substring matched by the whole pattern, is (n+1)*3.
- It is possible for capturing subpattern number n+1 to match some part
+ It is possible for capturing subpattern number n+1 to match some part
of the subject when subpattern n has not been used at all. For example,
- if the string "abc" is matched against the pattern (a|(z))(bc) the
+ if the string "abc" is matched against the pattern (a|(z))(bc) the
return from the function is 4, and subpatterns 1 and 3 are matched, but
- 2 is not. When this happens, both values in the offset pairs corre-
+ 2 is not. When this happens, both values in the offset pairs corre-
sponding to unused subpatterns are set to -1.
- Offset values that correspond to unused subpatterns at the end of the
- expression are also set to -1. For example, if the string "abc" is
- matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not
- matched. The return from the function is 2, because the highest used
+ Offset values that correspond to unused subpatterns at the end of the
+ expression are also set to -1. For example, if the string "abc" is
+ matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not
+ matched. The return from the function is 2, because the highest used
capturing subpattern number is 1. However, you can refer to the offsets
- for the second and third capturing subpatterns if you wish (assuming
+ for the second and third capturing subpatterns if you wish (assuming
the vector is large enough, of course).
- Some convenience functions are provided for extracting the captured
+ Some convenience functions are provided for extracting the captured
substrings as separate strings. These are described below.
Error return values from pcre_exec()
- If pcre_exec() fails, it returns a negative number. The following are
+ If pcre_exec() fails, it returns a negative number. The following are
defined in the header file:
PCRE_ERROR_NOMATCH (-1)
@@ -1924,7 +1934,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
PCRE_ERROR_NULL (-2)
- Either code or subject was passed as NULL, or ovector was NULL and
+ Either code or subject was passed as NULL, or ovector was NULL and
ovecsize was not zero.
PCRE_ERROR_BADOPTION (-3)
@@ -1933,87 +1943,87 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
PCRE_ERROR_BADMAGIC (-4)
- PCRE stores a 4-byte "magic number" at the start of the compiled code,
+ PCRE stores a 4-byte "magic number" at the start of the compiled code,
to catch the case when it is passed a junk pointer and to detect when a
pattern that was compiled in an environment of one endianness is run in
- an environment with the other endianness. This is the error that PCRE
+ an environment with the other endianness. This is the error that PCRE
gives when the magic number is not present.
PCRE_ERROR_UNKNOWN_OPCODE (-5)
While running the pattern match, an unknown item was encountered in the
- compiled pattern. This error could be caused by a bug in PCRE or by
+ compiled pattern. This error could be caused by a bug in PCRE or by
overwriting of the compiled pattern.
PCRE_ERROR_NOMEMORY (-6)
- If a pattern contains back references, but the ovector that is passed
+ If a pattern contains back references, but the ovector that is passed
to pcre_exec() is not big enough to remember the referenced substrings,
- PCRE gets a block of memory at the start of matching to use for this
- purpose. If the call via pcre_malloc() fails, this error is given. The
+ PCRE gets a block of memory at the start of matching to use for this
+ purpose. If the call via pcre_malloc() fails, this error is given. The
memory is automatically freed at the end of matching.
PCRE_ERROR_NOSUBSTRING (-7)
- This error is used by the pcre_copy_substring(), pcre_get_substring(),
+ This error is used by the pcre_copy_substring(), pcre_get_substring(),
and pcre_get_substring_list() functions (see below). It is never
returned by pcre_exec().
PCRE_ERROR_MATCHLIMIT (-8)
- The backtracking limit, as specified by the match_limit field in a
- pcre_extra structure (or defaulted) was reached. See the description
+ The backtracking limit, as specified by the match_limit field in a
+ pcre_extra structure (or defaulted) was reached. See the description
above.
PCRE_ERROR_CALLOUT (-9)
This error is never generated by pcre_exec() itself. It is provided for
- use by callout functions that want to yield a distinctive error code.
+ use by callout functions that want to yield a distinctive error code.
See the pcrecallout documentation for details.
PCRE_ERROR_BADUTF8 (-10)
- A string that contains an invalid UTF-8 byte sequence was passed as a
+ A string that contains an invalid UTF-8 byte sequence was passed as a
subject.
PCRE_ERROR_BADUTF8_OFFSET (-11)
The UTF-8 byte sequence that was passed as a subject was valid, but the
- value of startoffset did not point to the beginning of a UTF-8 charac-
+ value of startoffset did not point to the beginning of a UTF-8 charac-
ter.
PCRE_ERROR_PARTIAL (-12)
- The subject string did not match, but it did match partially. See the
+ The subject string did not match, but it did match partially. See the
pcrepartial documentation for details of partial matching.
PCRE_ERROR_BADPARTIAL (-13)
- The PCRE_PARTIAL option was used with a compiled pattern containing
- items that are not supported for partial matching. See the pcrepartial
+ The PCRE_PARTIAL option was used with a compiled pattern containing
+ items that are not supported for partial matching. See the pcrepartial
documentation for details of partial matching.
PCRE_ERROR_INTERNAL (-14)
- An unexpected internal error has occurred. This error could be caused
+ An unexpected internal error has occurred. This error could be caused
by a bug in PCRE or by overwriting of the compiled pattern.
PCRE_ERROR_BADCOUNT (-15)
- This error is given if the value of the ovecsize argument is negative.
+ This error is given if the value of the ovecsize argument is negative.
PCRE_ERROR_RECURSIONLIMIT (-21)
The internal recursion limit, as specified by the match_limit_recursion
- field in a pcre_extra structure (or defaulted) was reached. See the
+ field in a pcre_extra structure (or defaulted) was reached. See the
description above.
PCRE_ERROR_NULLWSLIMIT (-22)
- When a group that can match an empty substring is repeated with an
- unbounded upper limit, the subject position at the start of the group
+ When a group that can match an empty substring is repeated with an
+ unbounded upper limit, the subject position at the start of the group
must be remembered, so that a test for an empty string can be made when
- the end of the group is reached. Some workspace is required for this;
+ the end of the group is reached. Some workspace is required for this;
if it runs out, this error is given.
PCRE_ERROR_BADNEWLINE (-23)
@@ -2036,78 +2046,78 @@ EXTRACTING CAPTURED SUBSTRINGS BY NUMBER
int pcre_get_substring_list(const char *subject,
int *ovector, int stringcount, const char ***listptr);
- Captured substrings can be accessed directly by using the offsets
- returned by pcre_exec() in ovector. For convenience, the functions
+ Captured substrings can be accessed directly by using the offsets
+ returned by pcre_exec() in ovector. For convenience, the functions
pcre_copy_substring(), pcre_get_substring(), and pcre_get_sub-
- string_list() are provided for extracting captured substrings as new,
- separate, zero-terminated strings. These functions identify substrings
- by number. The next section describes functions for extracting named
+ string_list() are provided for extracting captured substrings as new,
+ separate, zero-terminated strings. These functions identify substrings
+ by number. The next section describes functions for extracting named
substrings.
- A substring that contains a binary zero is correctly extracted and has
- a further zero added on the end, but the result is not, of course, a C
- string. However, you can process such a string by referring to the
- length that is returned by pcre_copy_substring() and pcre_get_sub-
+ A substring that contains a binary zero is correctly extracted and has
+ a further zero added on the end, but the result is not, of course, a C
+ string. However, you can process such a string by referring to the
+ length that is returned by pcre_copy_substring() and pcre_get_sub-
string(). Unfortunately, the interface to pcre_get_substring_list() is
- not adequate for handling strings containing binary zeros, because the
+ not adequate for handling strings containing binary zeros, because the
end of the final string is not independently indicated.
- The first three arguments are the same for all three of these func-
- tions: subject is the subject string that has just been successfully
+ The first three arguments are the same for all three of these func-
+ tions: subject is the subject string that has just been successfully
matched, ovector is a pointer to the vector of integer offsets that was
passed to pcre_exec(), and stringcount is the number of substrings that
- were captured by the match, including the substring that matched the
+ were captured by the match, including the substring that matched the
entire regular expression. This is the value returned by pcre_exec() if
- it is greater than zero. If pcre_exec() returned zero, indicating that
- it ran out of space in ovector, the value passed as stringcount should
+ it is greater than zero. If pcre_exec() returned zero, indicating that
+ it ran out of space in ovector, the value passed as stringcount should
be the number of elements in the vector divided by three.
- The functions pcre_copy_substring() and pcre_get_substring() extract a
- single substring, whose number is given as stringnumber. A value of
- zero extracts the substring that matched the entire pattern, whereas
- higher values extract the captured substrings. For pcre_copy_sub-
- string(), the string is placed in buffer, whose length is given by
- buffersize, while for pcre_get_substring() a new block of memory is
- obtained via pcre_malloc, and its address is returned via stringptr.
- The yield of the function is the length of the string, not including
+ The functions pcre_copy_substring() and pcre_get_substring() extract a
+ single substring, whose number is given as stringnumber. A value of
+ zero extracts the substring that matched the entire pattern, whereas
+ higher values extract the captured substrings. For pcre_copy_sub-
+ string(), the string is placed in buffer, whose length is given by
+ buffersize, while for pcre_get_substring() a new block of memory is
+ obtained via pcre_malloc, and its address is returned via stringptr.
+ The yield of the function is the length of the string, not including
the terminating zero, or one of these error codes:
PCRE_ERROR_NOMEMORY (-6)
- The buffer was too small for pcre_copy_substring(), or the attempt to
+ The buffer was too small for pcre_copy_substring(), or the attempt to
get memory failed for pcre_get_substring().
PCRE_ERROR_NOSUBSTRING (-7)
There is no substring whose number is stringnumber.
- The pcre_get_substring_list() function extracts all available sub-
- strings and builds a list of pointers to them. All this is done in a
+ The pcre_get_substring_list() function extracts all available sub-
+ strings and builds a list of pointers to them. All this is done in a
single block of memory that is obtained via pcre_malloc. The address of
- the memory block is returned via listptr, which is also the start of
- the list of string pointers. The end of the list is marked by a NULL
- pointer. The yield of the function is zero if all went well, or the
+ the memory block is returned via listptr, which is also the start of
+ the list of string pointers. The end of the list is marked by a NULL
+ pointer. The yield of the function is zero if all went well, or the
error code
PCRE_ERROR_NOMEMORY (-6)
if the attempt to get the memory block failed.
- When any of these functions encounter a substring that is unset, which
- can happen when capturing subpattern number n+1 matches some part of
- the subject, but subpattern n has not been used at all, they return an
+ When any of these functions encounter a substring that is unset, which
+ can happen when capturing subpattern number n+1 matches some part of
+ the subject, but subpattern n has not been used at all, they return an
empty string. This can be distinguished from a genuine zero-length sub-
- string by inspecting the appropriate offset in ovector, which is nega-
+ string by inspecting the appropriate offset in ovector, which is nega-
tive for unset substrings.
- The two convenience functions pcre_free_substring() and pcre_free_sub-
- string_list() can be used to free the memory returned by a previous
+ The two convenience functions pcre_free_substring() and pcre_free_sub-
+ string_list() can be used to free the memory returned by a previous
call of pcre_get_substring() or pcre_get_substring_list(), respec-
- tively. They do nothing more than call the function pointed to by
- pcre_free, which of course could be called directly from a C program.
- However, PCRE is used in some situations where it is linked via a spe-
- cial interface to another programming language that cannot use
- pcre_free directly; it is for these cases that the functions are pro-
+ tively. They do nothing more than call the function pointed to by
+ pcre_free, which of course could be called directly from a C program.
+ However, PCRE is used in some situations where it is linked via a spe-
+ cial interface to another programming language that cannot use
+ pcre_free directly; it is for these cases that the functions are pro-
vided.
@@ -2126,7 +2136,7 @@ EXTRACTING CAPTURED SUBSTRINGS BY NAME
int stringcount, const char *stringname,
const char **stringptr);
- To extract a substring by name, you first have to find associated num-
+ To extract a substring by name, you first have to find associated num-
ber. For example, for this pattern
(a+)b(?<xxx>\d+)...
@@ -2135,27 +2145,27 @@ EXTRACTING CAPTURED SUBSTRINGS BY NAME
be unique (PCRE_DUPNAMES was not set), you can find the number from the
name by calling pcre_get_stringnumber(). The first argument is the com-
piled pattern, and the second is the name. The yield of the function is
- the subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if there is no
+ the subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if there is no
subpattern of that name.
Given the number, you can extract the substring directly, or use one of
the functions described in the previous section. For convenience, there
are also two functions that do the whole job.
- Most of the arguments of pcre_copy_named_substring() and
- pcre_get_named_substring() are the same as those for the similarly
- named functions that extract by number. As these are described in the
- previous section, they are not re-described here. There are just two
+ Most of the arguments of pcre_copy_named_substring() and
+ pcre_get_named_substring() are the same as those for the similarly
+ named functions that extract by number. As these are described in the
+ previous section, they are not re-described here. There are just two
differences:
- First, instead of a substring number, a substring name is given. Sec-
+ First, instead of a substring number, a substring name is given. Sec-
ond, there is an extra argument, given at the start, which is a pointer
- to the compiled pattern. This is needed in order to gain access to the
+ to the compiled pattern. This is needed in order to gain access to the
name-to-number translation table.
- These functions call pcre_get_stringnumber(), and if it succeeds, they
- then call pcre_copy_substring() or pcre_get_substring(), as appropri-
- ate. NOTE: If PCRE_DUPNAMES is set and there are duplicate names, the
+ These functions call pcre_get_stringnumber(), and if it succeeds, they
+ then call pcre_copy_substring() or pcre_get_substring(), as appropri-
+ ate. NOTE: If PCRE_DUPNAMES is set and there are duplicate names, the
behaviour may not be what you want (see the next section).
@@ -2164,45 +2174,45 @@ DUPLICATE SUBPATTERN NAMES
int pcre_get_stringtable_entries(const pcre *code,
const char *name, char **first, char **last);
- When a pattern is compiled with the PCRE_DUPNAMES option, names for
- subpatterns are not required to be unique. Normally, patterns with
- duplicate names are such that in any one match, only one of the named
- subpatterns participates. An example is shown in the pcrepattern docu-
+ When a pattern is compiled with the PCRE_DUPNAMES option, names for
+ subpatterns are not required to be unique. Normally, patterns with
+ duplicate names are such that in any one match, only one of the named
+ subpatterns participates. An example is shown in the pcrepattern docu-
mentation. When duplicates are present, pcre_copy_named_substring() and
- pcre_get_named_substring() return the first substring corresponding to
- the given name that is set. If none are set, an empty string is
+ pcre_get_named_substring() return the first substring corresponding to
+ the given name that is set. If none are set, an empty string is
returned. The pcre_get_stringnumber() function returns one of the num-
- bers that are associated with the name, but it is not defined which it
+ bers that are associated with the name, but it is not defined which it
is.
- If you want to get full details of all captured substrings for a given
- name, you must use the pcre_get_stringtable_entries() function. The
+ If you want to get full details of all captured substrings for a given
+ name, you must use the pcre_get_stringtable_entries() function. The
first argument is the compiled pattern, and the second is the name. The
- third and fourth are pointers to variables which are updated by the
+ third and fourth are pointers to variables which are updated by the
function. After it has run, they point to the first and last entries in
- the name-to-number table for the given name. The function itself
- returns the length of each entry, or PCRE_ERROR_NOSUBSTRING (-7) if
- there are none. The format of the table is described above in the sec-
- tion entitled Information about a pattern. Given all the relevant
- entries for the name, you can extract each of their numbers, and hence
+ the name-to-number table for the given name. The function itself
+ returns the length of each entry, or PCRE_ERROR_NOSUBSTRING (-7) if
+ there are none. The format of the table is described above in the sec-
+ tion entitled Information about a pattern. Given all the relevant
+ entries for the name, you can extract each of their numbers, and hence
the captured data, if any.
FINDING ALL POSSIBLE MATCHES
- The traditional matching function uses a similar algorithm to Perl,
+ The traditional matching function uses a similar algorithm to Perl,
which stops when it finds the first match, starting at a given point in
- the subject. If you want to find all possible matches, or the longest
- possible match, consider using the alternative matching function (see
- below) instead. If you cannot use the alternative function, but still
- need to find all possible matches, you can kludge it up by making use
+ the subject. If you want to find all possible matches, or the longest
+ possible match, consider using the alternative matching function (see
+ below) instead. If you cannot use the alternative function, but still
+ need to find all possible matches, you can kludge it up by making use
of the callout facility, which is described in the pcrecallout documen-
tation.
What you have to do is to insert a callout right at the end of the pat-
- tern. When your callout function is called, extract and save the cur-
- rent matched substring. Then return 1, which forces pcre_exec() to
- backtrack and try other alternatives. Ultimately, when it runs out of
+ tern. When your callout function is called, extract and save the cur-
+ rent matched substring. Then return 1, which forces pcre_exec() to
+ backtrack and try other alternatives. Ultimately, when it runs out of
matches, pcre_exec() will yield PCRE_ERROR_NOMATCH.
@@ -2213,25 +2223,25 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
int options, int *ovector, int ovecsize,
int *workspace, int wscount);
- The function pcre_dfa_exec() is called to match a subject string
- against a compiled pattern, using a matching algorithm that scans the
- subject string just once, and does not backtrack. This has different
- characteristics to the normal algorithm, and is not compatible with
- Perl. Some of the features of PCRE patterns are not supported. Never-
- theless, there are times when this kind of matching can be useful. For
+ The function pcre_dfa_exec() is called to match a subject string
+ against a compiled pattern, using a matching algorithm that scans the
+ subject string just once, and does not backtrack. This has different
+ characteristics to the normal algorithm, and is not compatible with
+ Perl. Some of the features of PCRE patterns are not supported. Never-
+ theless, there are times when this kind of matching can be useful. For
a discussion of the two matching algorithms, see the pcrematching docu-
mentation.
- The arguments for the pcre_dfa_exec() function are the same as for
+ The arguments for the pcre_dfa_exec() function are the same as for
pcre_exec(), plus two extras. The ovector argument is used in a differ-
- ent way, and this is described below. The other common arguments are
- used in the same way as for pcre_exec(), so their description is not
+ ent way, and this is described below. The other common arguments are
+ used in the same way as for pcre_exec(), so their description is not
repeated here.
- The two additional arguments provide workspace for the function. The
- workspace vector should contain at least 20 elements. It is used for
+ The two additional arguments provide workspace for the function. The
+ workspace vector should contain at least 20 elements. It is used for
keeping track of multiple paths through the pattern tree. More
- workspace will be needed for patterns and subjects where there are a
+ workspace will be needed for patterns and subjects where there are a
lot of potential matches.
Here is an example of a simple call to pcre_dfa_exec():
@@ -2253,47 +2263,47 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
Option bits for pcre_dfa_exec()
- The unused bits of the options argument for pcre_dfa_exec() must be
- zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NEW-
- LINE_xxx, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK,
+ The unused bits of the options argument for pcre_dfa_exec() must be
+ zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NEW-
+ LINE_xxx, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK,
PCRE_PARTIAL, PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last
three of these are the same as for pcre_exec(), so their description is
not repeated here.
PCRE_PARTIAL
- This has the same general effect as it does for pcre_exec(), but the
- details are slightly different. When PCRE_PARTIAL is set for
- pcre_dfa_exec(), the return code PCRE_ERROR_NOMATCH is converted into
- PCRE_ERROR_PARTIAL if the end of the subject is reached, there have
+ This has the same general effect as it does for pcre_exec(), but the
+ details are slightly different. When PCRE_PARTIAL is set for
+ pcre_dfa_exec(), the return code PCRE_ERROR_NOMATCH is converted into
+ PCRE_ERROR_PARTIAL if the end of the subject is reached, there have
been no complete matches, but there is still at least one matching pos-
- sibility. The portion of the string that provided the partial match is
+ sibility. The portion of the string that provided the partial match is
set as the first matching string.
PCRE_DFA_SHORTEST
- Setting the PCRE_DFA_SHORTEST option causes the matching algorithm to
+ Setting the PCRE_DFA_SHORTEST option causes the matching algorithm to
stop as soon as it has found one match. Because of the way the alterna-
- tive algorithm works, this is necessarily the shortest possible match
+ tive algorithm works, this is necessarily the shortest possible match
at the first possible matching point in the subject string.
PCRE_DFA_RESTART
- When pcre_dfa_exec() is called with the PCRE_PARTIAL option, and
- returns a partial match, it is possible to call it again, with addi-
- tional subject characters, and have it continue with the same match.
- The PCRE_DFA_RESTART option requests this action; when it is set, the
- workspace and wscount options must reference the same vector as before
- because data about the match so far is left in them after a partial
- match. There is more discussion of this facility in the pcrepartial
+ When pcre_dfa_exec() is called with the PCRE_PARTIAL option, and
+ returns a partial match, it is possible to call it again, with addi-
+ tional subject characters, and have it continue with the same match.
+ The PCRE_DFA_RESTART option requests this action; when it is set, the
+ workspace and wscount options must reference the same vector as before
+ because data about the match so far is left in them after a partial
+ match. There is more discussion of this facility in the pcrepartial
documentation.
Successful returns from pcre_dfa_exec()
- When pcre_dfa_exec() succeeds, it may have matched more than one sub-
+ When pcre_dfa_exec() succeeds, it may have matched more than one sub-
string in the subject. Note, however, that all the matches from one run
- of the function start at the same point in the subject. The shorter
- matches are all initial substrings of the longer matches. For example,
+ of the function start at the same point in the subject. The shorter
+ matches are all initial substrings of the longer matches. For example,
if the pattern
<.*>
@@ -2308,62 +2318,62 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
<something> <something else>
<something> <something else> <something further>
- On success, the yield of the function is a number greater than zero,
- which is the number of matched substrings. The substrings themselves
- are returned in ovector. Each string uses two elements; the first is
- the offset to the start, and the second is the offset to the end. In
- fact, all the strings have the same start offset. (Space could have
- been saved by giving this only once, but it was decided to retain some
- compatibility with the way pcre_exec() returns data, even though the
+ On success, the yield of the function is a number greater than zero,
+ which is the number of matched substrings. The substrings themselves
+ are returned in ovector. Each string uses two elements; the first is
+ the offset to the start, and the second is the offset to the end. In
+ fact, all the strings have the same start offset. (Space could have
+ been saved by giving this only once, but it was decided to retain some
+ compatibility with the way pcre_exec() returns data, even though the
meaning of the strings is different.)
The strings are returned in reverse order of length; that is, the long-
- est matching string is given first. If there were too many matches to
- fit into ovector, the yield of the function is zero, and the vector is
+ est matching string is given first. If there were too many matches to
+ fit into ovector, the yield of the function is zero, and the vector is
filled with the longest matches.
Error returns from pcre_dfa_exec()
- The pcre_dfa_exec() function returns a negative number when it fails.
- Many of the errors are the same as for pcre_exec(), and these are
- described above. There are in addition the following errors that are
+ The pcre_dfa_exec() function returns a negative number when it fails.
+ Many of the errors are the same as for pcre_exec(), and these are
+ described above. There are in addition the following errors that are
specific to pcre_dfa_exec():
PCRE_ERROR_DFA_UITEM (-16)
- This return is given if pcre_dfa_exec() encounters an item in the pat-
- tern that it does not support, for instance, the use of \C or a back
+ This return is given if pcre_dfa_exec() encounters an item in the pat-
+ tern that it does not support, for instance, the use of \C or a back
reference.
PCRE_ERROR_DFA_UCOND (-17)
- This return is given if pcre_dfa_exec() encounters a condition item
- that uses a back reference for the condition, or a test for recursion
+ This return is given if pcre_dfa_exec() encounters a condition item
+ that uses a back reference for the condition, or a test for recursion
in a specific group. These are not supported.
PCRE_ERROR_DFA_UMLIMIT (-18)
- This return is given if pcre_dfa_exec() is called with an extra block
+ This return is given if pcre_dfa_exec() is called with an extra block
that contains a setting of the match_limit field. This is not supported
(it is meaningless).
PCRE_ERROR_DFA_WSSIZE (-19)
- This return is given if pcre_dfa_exec() runs out of space in the
+ This return is given if pcre_dfa_exec() runs out of space in the
workspace vector.
PCRE_ERROR_DFA_RECURSE (-20)
- When a recursive subpattern is processed, the matching function calls
- itself recursively, using private vectors for ovector and workspace.
- This error is given if the output vector is not large enough. This
+ When a recursive subpattern is processed, the matching function calls
+ itself recursively, using private vectors for ovector and workspace.
+ This error is given if the output vector is not large enough. This
should be extremely rare, as a vector of size 1000 is used.
SEE ALSO
- pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3), pcrepar-
- tial(3), pcreposix(3), pcreprecompile(3), pcresample(3), pcrestack(3).
+ pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3), pcrepar-
+ tial(3), pcreposix(3), pcreprecompile(3), pcresample(3), pcrestack(3).
AUTHOR
@@ -2375,7 +2385,7 @@ AUTHOR
REVISION
- Last updated: 06 March 2007
+ Last updated: 16 April 2007
Copyright (c) 1997-2007 University of Cambridge.
------------------------------------------------------------------------------
diff --git a/doc/pcre_compile.3 b/doc/pcre_compile.3
index dbab684..03e7e62 100644
--- a/doc/pcre_compile.3
+++ b/doc/pcre_compile.3
@@ -42,7 +42,7 @@ The option bits are:
PCRE_FIRSTLINE Force matching to be before newline
PCRE_MULTILINE ^ and $ match newlines within data
PCRE_NEWLINE_ANY Recognize any Unicode newline sequence
- PCRE_NEWLINE_ANYCRLF Recognize CR, LF, and CRLF as newline sequences
+ PCRE_NEWLINE_ANYCRLF Recognize CR, LF, and CRLF as newline sequences
PCRE_NEWLINE_CR Set CR as the newline sequence
PCRE_NEWLINE_CRLF Set CRLF as the newline sequence
PCRE_NEWLINE_LF Set LF as the newline sequence
diff --git a/doc/pcre_exec.3 b/doc/pcre_exec.3
index 497c329..755904d 100644
--- a/doc/pcre_exec.3
+++ b/doc/pcre_exec.3
@@ -35,7 +35,7 @@ The options are:
.sp
PCRE_ANCHORED Match only at the first position
PCRE_NEWLINE_ANY Recognize any Unicode newline sequence
- PCRE_NEWLINE_ANYCRLF Recognize CR, LF, and CRLF as newline sequences
+ PCRE_NEWLINE_ANYCRLF Recognize CR, LF, and CRLF as newline sequences
PCRE_NEWLINE_CR Set CR as the newline sequence
PCRE_NEWLINE_CRLF Set CRLF as the newline sequence
PCRE_NEWLINE_LF Set LF as the newline sequence
diff --git a/doc/pcreapi.3 b/doc/pcreapi.3
index 49132ea..035da07 100644
--- a/doc/pcreapi.3
+++ b/doc/pcreapi.3
@@ -533,7 +533,7 @@ occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect.
PCRE_NEWLINE_CR
PCRE_NEWLINE_LF
PCRE_NEWLINE_CRLF
- PCRE_NEWLINE_ANYCRLF
+ PCRE_NEWLINE_ANYCRLF
PCRE_NEWLINE_ANY
.sp
These options override the default newline definition that was chosen when PCRE
@@ -1154,7 +1154,7 @@ matching time.
PCRE_NEWLINE_CR
PCRE_NEWLINE_LF
PCRE_NEWLINE_CRLF
- PCRE_NEWLINE_ANYCRLF
+ PCRE_NEWLINE_ANYCRLF
PCRE_NEWLINE_ANY
.sp
These options override the newline definition that was chosen or defaulted when
diff --git a/doc/pcregrep.1 b/doc/pcregrep.1
index 3f34b2b..8d723c3 100644
--- a/doc/pcregrep.1
+++ b/doc/pcregrep.1
@@ -222,7 +222,7 @@ are guaranteed to be available for lookbehind assertions.
\fB-N\fP \fInewline-type\fP, \fB--newline=\fP\fInewline-type\fP
The PCRE library supports five different conventions for indicating
the ends of lines. They are the single-character sequences CR (carriage return)
-and LF (linefeed), the two-character sequence CRLF, an "anycrlf" convention,
+and LF (linefeed), the two-character sequence CRLF, an "anycrlf" convention,
which recognizes any of the preceding three types, and an "any" convention, in
which any Unicode line ending sequence is assumed to end a line. The Unicode
sequences are the three just mentioned, plus VT (vertical tab, U+000B), FF
diff --git a/doc/pcregrep.txt b/doc/pcregrep.txt
index abd839e..50a5fa2 100644
--- a/doc/pcregrep.txt
+++ b/doc/pcregrep.txt
@@ -245,67 +245,68 @@ OPTIONS
lookbehind assertions.
-N newline-type, --newline=newline-type
- The PCRE library supports four different conventions for
+ The PCRE library supports five different conventions for
indicating the ends of lines. They are the single-character
sequences CR (carriage return) and LF (linefeed), the two-
- character sequence CRLF, and an "any" convention, in which
- any Unicode line ending sequence is assumed to end a line.
- The Unicode sequences are the three just mentioned, plus VT
- (vertical tab, U+000B), FF (formfeed, U+000C), NEL (next
- line, U+0085), LS (line separator, U+2028), and PS (paragraph
- separator, U+0029).
+ character sequence CRLF, an "anycrlf" convention, which rec-
+ ognizes any of the preceding three types, and an "any" con-
+ vention, in which any Unicode line ending sequence is assumed
+ to end a line. The Unicode sequences are the three just men-
+ tioned, plus VT (vertical tab, U+000B), FF (formfeed,
+ U+000C), NEL (next line, U+0085), LS (line separator,
+ U+2028), and PS (paragraph separator, U+2029).
When the PCRE library is built, a default line-ending
- sequence is specified. This is normally the standard
+ sequence is specified. This is normally the standard
sequence for the operating system. Unless otherwise specified
- by this option, pcregrep uses the library's default. The
- possible values for this option are CR, LF, CRLF, or ANY.
- This makes it possible to use pcregrep on files that have
- come from other environments without having to modify their
- line endings. If the data that is being scanned does not
- agree with the convention set by this option, pcregrep may
- behave in strange ways.
+ by this option, pcregrep uses the library's default. The
+ possible values for this option are CR, LF, CRLF, ANYCRLF, or
+ ANY. This makes it possible to use pcregrep on files that
+ have come from other environments without having to modify
+ their line endings. If the data that is being scanned does
+ not agree with the convention set by this option, pcregrep
+ may behave in strange ways.
-n, --line-number
Precede each output line by its line number in the file, fol-
- lowed by a colon and a space for matching lines or a hyphen
- and a space for context lines. If the filename is also being
+ lowed by a colon and a space for matching lines or a hyphen
+ and a space for context lines. If the filename is also being
output, it precedes the line number.
-o, --only-matching
- Show only the part of the line that matched a pattern. In
- this mode, no context is shown. That is, the -A, -B, and -C
+ Show only the part of the line that matched a pattern. In
+ this mode, no context is shown. That is, the -A, -B, and -C
options are ignored.
-q, --quiet
Work quietly, that is, display nothing except error messages.
- The exit status indicates whether or not any matches were
+ The exit status indicates whether or not any matches were
found.
-r, --recursive
- If any given path is a directory, recursively scan the files
- it contains, taking note of any --include and --exclude set-
- tings. By default, a directory is read as a normal file; in
- some operating systems this gives an immediate end-of-file.
- This option is a shorthand for setting the -d option to
+ If any given path is a directory, recursively scan the files
+ it contains, taking note of any --include and --exclude set-
+ tings. By default, a directory is read as a normal file; in
+ some operating systems this gives an immediate end-of-file.
+ This option is a shorthand for setting the -d option to
"recurse".
-s, --no-messages
- Suppress error messages about non-existent or unreadable
- files. Such files are quietly skipped. However, the return
+ Suppress error messages about non-existent or unreadable
+ files. Such files are quietly skipped. However, the return
code is still 2, even if matches were found in other files.
-u, --utf-8
- Operate in UTF-8 mode. This option is available only if PCRE
- has been compiled with UTF-8 support. Both patterns and sub-
+ Operate in UTF-8 mode. This option is available only if PCRE
+ has been compiled with UTF-8 support. Both patterns and sub-
ject lines must be valid strings of UTF-8 characters.
-V, --version
- Write the version numbers of pcregrep and the PCRE library
+ Write the version numbers of pcregrep and the PCRE library
that is being used to the standard error stream.
-v, --invert-match
- Invert the sense of the match, so that lines which do not
+ Invert the sense of the match, so that lines which do not
match any of the patterns are the ones that are found.
-w, --word-regex, --word-regexp
@@ -313,86 +314,86 @@ OPTIONS
lent to having \b at the start and end of the pattern.
-x, --line-regex, --line-regexp
- Force the patterns to be anchored (each must start matching
- at the beginning of a line) and in addition, require them to
- match entire lines. This is equivalent to having ^ and $
+ Force the patterns to be anchored (each must start matching
+ at the beginning of a line) and in addition, require them to
+ match entire lines. This is equivalent to having ^ and $
characters at the start and end of each alternative branch in
every pattern.
ENVIRONMENT VARIABLES
- The environment variables LC_ALL and LC_CTYPE are examined, in that
- order, for a locale. The first one that is set is used. This can be
- overridden by the --locale option. If no locale is set, the PCRE
+ The environment variables LC_ALL and LC_CTYPE are examined, in that
+ order, for a locale. The first one that is set is used. This can be
+ overridden by the --locale option. If no locale is set, the PCRE
library's default (usually the "C" locale) is used.
NEWLINES
- The -N (--newline) option allows pcregrep to scan files with different
- newline conventions from the default. However, the setting of this
- option does not affect the way in which pcregrep writes information to
- the standard error and output streams. It uses the string "\n" in C
- printf() calls to indicate newlines, relying on the C I/O library to
- convert this to an appropriate sequence if the output is sent to a
+ The -N (--newline) option allows pcregrep to scan files with different
+ newline conventions from the default. However, the setting of this
+ option does not affect the way in which pcregrep writes information to
+ the standard error and output streams. It uses the string "\n" in C
+ printf() calls to indicate newlines, relying on the C I/O library to
+ convert this to an appropriate sequence if the output is sent to a
file.
OPTIONS COMPATIBILITY
The majority of short and long forms of pcregrep's options are the same
- as in the GNU grep program. Any long option of the form --xxx-regexp
- (GNU terminology) is also available as --xxx-regex (PCRE terminology).
- However, the --locale, -M, --multiline, -u, and --utf-8 options are
+ as in the GNU grep program. Any long option of the form --xxx-regexp
+ (GNU terminology) is also available as --xxx-regex (PCRE terminology).
+ However, the --locale, -M, --multiline, -u, and --utf-8 options are
specific to pcregrep.
OPTIONS WITH DATA
There are four different ways in which an option with data can be spec-
- ified. If a short form option is used, the data may follow immedi-
+ ified. If a short form option is used, the data may follow immedi-
ately, or in the next command line item. For example:
-f/some/file
-f /some/file
- If a long form option is used, the data may appear in the same command
+ If a long form option is used, the data may appear in the same command
line item, separated by an equals character, or (with one exception) it
may appear in the next command line item. For example:
--file=/some/file
--file /some/file
- Note, however, that if you want to supply a file name beginning with ~
- as data in a shell command, and have the shell expand ~ to a home
+ Note, however, that if you want to supply a file name beginning with ~
+ as data in a shell command, and have the shell expand ~ to a home
directory, you must separate the file name from the option, because the
- shell does not treat ~ specially unless it is at the start of an item.
+ shell does not treat ~ specially unless it is at the start of an item.
- The exception to the above is the --colour (or --color) option, for
- which the data is optional. If this option does have data, it must be
- given in the first form, using an equals character. Otherwise it will
+ The exception to the above is the --colour (or --color) option, for
+ which the data is optional. If this option does have data, it must be
+ given in the first form, using an equals character. Otherwise it will
be assumed that it has no data.
MATCHING ERRORS
- It is possible to supply a regular expression that takes a very long
- time to fail to match certain lines. Such patterns normally involve
- nested indefinite repeats, for example: (a+)*\d when matched against a
- line of a's with no final digit. The PCRE matching function has a
- resource limit that causes it to abort in these circumstances. If this
+ It is possible to supply a regular expression that takes a very long
+ time to fail to match certain lines. Such patterns normally involve
+ nested indefinite repeats, for example: (a+)*\d when matched against a
+ line of a's with no final digit. The PCRE matching function has a
+ resource limit that causes it to abort in these circumstances. If this
happens, pcregrep outputs an error message and the line that caused the
- problem to the standard error stream. If there are more than 20 such
+ problem to the standard error stream. If there are more than 20 such
errors, pcregrep gives up.
DIAGNOSTICS
Exit status is 0 if any matches were found, 1 if no matches were found,
- and 2 for syntax errors and non-existent or inacessible files (even if
- matches were found in other files) or too many matching errors. Using
- the -s option to suppress error messages about inaccessble files does
+ and 2 for syntax errors and non-existent or inacessible files (even if
+ matches were found in other files) or too many matching errors. Using
+ the -s option to suppress error messages about inaccessble files does
not affect the return code.
@@ -410,5 +411,5 @@ AUTHOR
REVISION
- Last updated: 06 March 2007
+ Last updated: 16 April 2007
Copyright (c) 1997-2007 University of Cambridge.
diff --git a/doc/pcretest.txt b/doc/pcretest.txt
index 8c16c74..c071b03 100644
--- a/doc/pcretest.txt
+++ b/doc/pcretest.txt
@@ -146,18 +146,19 @@ PATTERN MODIFIERS
The following table shows additional modifiers for setting PCRE options
that do not correspond to anything in Perl:
- /A PCRE_ANCHORED
- /C PCRE_AUTO_CALLOUT
- /E PCRE_DOLLAR_ENDONLY
- /f PCRE_FIRSTLINE
- /J PCRE_DUPNAMES
- /N PCRE_NO_AUTO_CAPTURE
- /U PCRE_UNGREEDY
- /X PCRE_EXTRA
- /<cr> PCRE_NEWLINE_CR
- /<lf> PCRE_NEWLINE_LF
- /<crlf> PCRE_NEWLINE_CRLF
- /<any> PCRE_NEWLINE_ANY
+ /A PCRE_ANCHORED
+ /C PCRE_AUTO_CALLOUT
+ /E PCRE_DOLLAR_ENDONLY
+ /f PCRE_FIRSTLINE
+ /J PCRE_DUPNAMES
+ /N PCRE_NO_AUTO_CAPTURE
+ /U PCRE_UNGREEDY
+ /X PCRE_EXTRA
+ /<cr> PCRE_NEWLINE_CR
+ /<lf> PCRE_NEWLINE_LF
+ /<crlf> PCRE_NEWLINE_CRLF
+ /<anycrlf> PCRE_NEWLINE_ANY
+ /<any> PCRE_NEWLINE_ANY
Those specifying line ending sequencess are literal strings as shown.
This example sets multiline matching with CRLF as the line ending
@@ -330,6 +331,8 @@ DATA LINES
or pcre_dfa_exec()
\<crlf> pass the PCRE_NEWLINE_CRLF option to pcre_exec()
or pcre_dfa_exec()
+ \<anycrlf> pass the PCRE_NEWLINE_ANYCRLF option to pcre_exec()
+ or pcre_dfa_exec()
\<any> pass the PCRE_NEWLINE_ANY option to pcre_exec()
or pcre_dfa_exec()
@@ -618,5 +621,5 @@ AUTHOR
REVISION
- Last updated: 06 March 2007
+ Last updated: 16 April 2007
Copyright (c) 1997-2007 University of Cambridge.
diff --git a/pcre_compile.c b/pcre_compile.c
index 46d6d8d..dd94473 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -5138,7 +5138,7 @@ cd->cbits = tables + cbits_offset;
cd->ctypes = tables + ctypes_offset;
/* Handle different types of newline. The three bits give seven cases. The
-current code allows for fixed one- or two-byte sequences, plus "any" and
+current code allows for fixed one- or two-byte sequences, plus "any" and
"anycrlf". */
switch (options & (PCRE_NEWLINE_CRLF | PCRE_NEWLINE_ANY))
@@ -5149,7 +5149,7 @@ switch (options & (PCRE_NEWLINE_CRLF | PCRE_NEWLINE_ANY))
case PCRE_NEWLINE_CR+
PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
case PCRE_NEWLINE_ANY: newline = -1; break;
- case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
+ case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN;
}
diff --git a/pcre_dfa_exec.c b/pcre_dfa_exec.c
index 40ea80c..93ac1fd 100644
--- a/pcre_dfa_exec.c
+++ b/pcre_dfa_exec.c
@@ -2175,7 +2175,7 @@ switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)option
case PCRE_NEWLINE_CR+
PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
case PCRE_NEWLINE_ANY: newline = -1; break;
- case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
+ case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
default: return PCRE_ERROR_BADNEWLINE;
}
@@ -2431,13 +2431,13 @@ for (;;)
}
if (current_subject > end_subject) break;
- /* If we have just passed a CR and the newline option is CRLF or ANY or
+ /* If we have just passed a CR and the newline option is CRLF or ANY or
ANYCRLF, and we are now at a LF, advance the match position by one more
character. */
if (current_subject[-1] == '\r' &&
- (md->nltype == NLTYPE_ANY ||
- md->nltype == NLTYPE_ANYCRLF ||
+ (md->nltype == NLTYPE_ANY ||
+ md->nltype == NLTYPE_ANYCRLF ||
md->nllen == 2) &&
current_subject < end_subject &&
*current_subject == '\n')
diff --git a/pcre_exec.c b/pcre_exec.c
index cabe66c..b4d3a46 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -3840,7 +3840,7 @@ switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)option
case PCRE_NEWLINE_CR+
PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
case PCRE_NEWLINE_ANY: newline = -1; break;
- case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
+ case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
default: return PCRE_ERROR_BADNEWLINE;
}
@@ -4148,13 +4148,13 @@ for(;;)
if (anchored || start_match > end_subject) break;
- /* If we have just passed a CR and the newline option is CRLF or ANY or
+ /* If we have just passed a CR and the newline option is CRLF or ANY or
ANYCRLF, and we are now at a LF, advance the match position by one more
character. */
if (start_match[-1] == '\r' &&
- (md->nltype == NLTYPE_ANY ||
- md->nltype == NLTYPE_ANYCRLF ||
+ (md->nltype == NLTYPE_ANY ||
+ md->nltype == NLTYPE_ANYCRLF ||
md->nllen == 2) &&
start_match < end_subject &&
*start_match == '\n')
diff --git a/pcre_internal.h b/pcre_internal.h
index c38a849..b3f687a 100644
--- a/pcre_internal.h
+++ b/pcre_internal.h
@@ -1089,7 +1089,7 @@ extern const uschar _pcre_OP_lengths[];
one of the exported public functions. They have to be "external" in the C
sense, but are not part of the PCRE public API. */
-extern BOOL _pcre_is_newline(const uschar *, int, const uschar *,
+extern BOOL _pcre_is_newline(const uschar *, int, const uschar *,
int *, BOOL);
extern int _pcre_ord2utf8(int, uschar *);
extern real_pcre *_pcre_try_flipped(const real_pcre *, real_pcre *,
@@ -1097,7 +1097,7 @@ extern real_pcre *_pcre_try_flipped(const real_pcre *, real_pcre *,
extern int _pcre_ucp_findprop(const unsigned int, int *, int *);
extern unsigned int _pcre_ucp_othercase(const unsigned int);
extern int _pcre_valid_utf8(const uschar *, int);
-extern BOOL _pcre_was_newline(const uschar *, int, const uschar *,
+extern BOOL _pcre_was_newline(const uschar *, int, const uschar *,
int *, BOOL);
extern BOOL _pcre_xclass(int, const uschar *);
diff --git a/pcre_newline.c b/pcre_newline.c
index 3a5db61..ae66c73 100644
--- a/pcre_newline.c
+++ b/pcre_newline.c
@@ -38,10 +38,10 @@ POSSIBILITY OF SUCH DAMAGE.
*/
-/* This module contains internal functions for testing newlines when more than
+/* This module contains internal functions for testing newlines when more than
one kind of newline is to be recognized. When a newline is found, its length is
-returned. In principle, we could implement several newline "types", each
-referring to a different set of newline characters. At present, PCRE supports
+returned. In principle, we could implement several newline "types", each
+referring to a different set of newline characters. At present, PCRE supports
only NLTYPE_FIXED, which gets handled without these functions, NLTYPE_ANYCRLF,
and NLTYPE_ANY. The full list of Unicode newline characters is taken from
http://unicode.org/unicode/reports/tr18/. */
@@ -69,7 +69,7 @@ Returns: TRUE or FALSE
*/
BOOL
-_pcre_is_newline(const uschar *ptr, int type, const uschar *endptr,
+_pcre_is_newline(const uschar *ptr, int type, const uschar *endptr,
int *lenptr, BOOL utf8)
{
int c;
@@ -119,7 +119,7 @@ Returns: TRUE or FALSE
*/
BOOL
-_pcre_was_newline(const uschar *ptr, int type, const uschar *startptr,
+_pcre_was_newline(const uschar *ptr, int type, const uschar *startptr,
int *lenptr, BOOL utf8)
{
int c;
diff --git a/pcregrep.c b/pcregrep.c
index a6b9c3f..9bc0930 100644
--- a/pcregrep.c
+++ b/pcregrep.c
@@ -580,12 +580,12 @@ switch(endlinetype)
}
else *lenptr = 1;
return p;
-
+
default:
break;
}
} /* End of loop for ANYCRLF case */
-
+
*lenptr = 0; /* Must have hit the end */
return endptr;
@@ -687,7 +687,7 @@ switch(endlinetype)
return p; /* But control should never get here */
case EL_ANY:
- case EL_ANYCRLF:
+ case EL_ANYCRLF:
if (*(--p) == '\n' && p > startptr && p[-1] == '\r') p--;
if (utf8) while ((*p & 0xc0) == 0x80) p--;
@@ -721,10 +721,10 @@ switch(endlinetype)
case 0x0a: /* LF */
case 0x0d: /* CR */
return p;
-
+
default:
break;
- }
+ }
else switch (c)
{
@@ -1567,7 +1567,7 @@ switch(i)
case '\r': newline = (char *)"cr"; break;
case ('\r' << 8) | '\n': newline = (char *)"crlf"; break;
case -1: newline = (char *)"any"; break;
- case -2: newline = (char *)"anycrlf"; break;
+ case -2: newline = (char *)"anycrlf"; break;
}
/* Process the options */
diff --git a/pcretest.c b/pcretest.c
index 7a6b1d3..980d404 100644
--- a/pcretest.c
+++ b/pcretest.c
@@ -852,7 +852,7 @@ while (argc > 1 && argv[op][0] == '-')
(void)pcre_config(PCRE_CONFIG_NEWLINE, &rc);
printf(" Newline sequence is %s\n", (rc == '\r')? "CR" :
(rc == '\n')? "LF" : (rc == ('\r'<<8 | '\n'))? "CRLF" :
- (rc == -2)? "ANYCRLF" :
+ (rc == -2)? "ANYCRLF" :
(rc == -1)? "ANY" : "???");
(void)pcre_config(PCRE_CONFIG_LINK_SIZE, &rc);
printf(" Internal link size = %d\n", rc);
@@ -2225,7 +2225,7 @@ while (!done)
to advance the start offset, and continue. We won't be at the end of the
string - that was checked before setting g_notempty.
- Complication arises in the case when the newline option is "any" or
+ Complication arises in the case when the newline option is "any" or
"anycrlf". If the previous match was at the end of a line terminated by
CRLF, an advance of one character just passes the \r, whereas we should
prefer the longer newline sequence, as does the code in pcre_exec().
@@ -2248,11 +2248,11 @@ while (!done)
obits = (d == '\r')? PCRE_NEWLINE_CR :
(d == '\n')? PCRE_NEWLINE_LF :
(d == ('\r'<<8 | '\n'))? PCRE_NEWLINE_CRLF :
- (d == -2)? PCRE_NEWLINE_ANYCRLF :
+ (d == -2)? PCRE_NEWLINE_ANYCRLF :
(d == -1)? PCRE_NEWLINE_ANY : 0;
}
if (((obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANY ||
- (obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANYCRLF)
+ (obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANYCRLF)
&&
start_offset < len - 1 &&
bptr[start_offset] == '\r' &&