summaryrefslogtreecommitdiff
path: root/pcrecpp.cc
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-09-17 10:51:30 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-09-17 10:51:30 +0000
commit539e389c4c32a1f46a6e2ef079f7c79d56e6d130 (patch)
tree1a509896fb38a13c0661f42ef4410cf424e656d8 /pcrecpp.cc
parent8a7a081f2b2148dd7d4fa320dee17cd5bf146e6f (diff)
downloadpcre-539e389c4c32a1f46a6e2ef079f7c79d56e6d130.tar.gz
Added checks for ANY and ANYCRLF to pcrecpp.cc where previously it checked only
for CRLF. git-svn-id: svn://vcs.exim.org/pcre/code/trunk@253 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcrecpp.cc')
-rw-r--r--pcrecpp.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/pcrecpp.cc b/pcrecpp.cc
index a3bf373..a369140 100644
--- a/pcrecpp.cc
+++ b/pcrecpp.cc
@@ -337,13 +337,17 @@ bool RE::Replace(const StringPiece& rewrite,
// Returns PCRE_NEWLINE_CRLF, PCRE_NEWLINE_CR, or PCRE_NEWLINE_LF.
// Note that PCRE_NEWLINE_CRLF is defined to be P_N_CR | P_N_LF.
+// Modified by PH to add PCRE_NEWLINE_ANY and PCRE_NEWLINE_ANYCRLF.
+
static int NewlineMode(int pcre_options) {
// TODO: if we can make it threadsafe, cache this var
int newline_mode = 0;
/* if (newline_mode) return newline_mode; */ // do this once it's cached
- if (pcre_options & (PCRE_NEWLINE_CRLF|PCRE_NEWLINE_CR|PCRE_NEWLINE_LF)) {
+ if (pcre_options & (PCRE_NEWLINE_CRLF|PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|
+ PCRE_NEWLINE_ANY|PCRE_NEWLINE_ANYCRLF)) {
newline_mode = (pcre_options &
- (PCRE_NEWLINE_CRLF|PCRE_NEWLINE_CR|PCRE_NEWLINE_LF));
+ (PCRE_NEWLINE_CRLF|PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|
+ PCRE_NEWLINE_ANY|PCRE_NEWLINE_ANYCRLF));
} else {
int newline;
pcre_config(PCRE_CONFIG_NEWLINE, &newline);
@@ -353,6 +357,10 @@ static int NewlineMode(int pcre_options) {
newline_mode = PCRE_NEWLINE_CR;
else if (newline == 3338)
newline_mode = PCRE_NEWLINE_CRLF;
+ else if (newline == -1)
+ newline_mode = PCRE_NEWLINE_ANY;
+ else if (newline == -2)
+ newline_mode = PCRE_NEWLINE_ANYCRLF;
else
assert("" == "Unexpected return value from pcre_config(NEWLINE)");
}
@@ -382,9 +390,13 @@ int RE::GlobalReplace(const StringPiece& rewrite,
// Note it's better to call pcre_fullinfo() than to examine
// all_options(), since options_ could have changed bewteen
// compile-time and now, but this is simpler and safe enough.
+ // Modified by PH to add ANY and ANYCRLF.
if (start+1 < static_cast<int>(str->length()) &&
(*str)[start] == '\r' && (*str)[start+1] == '\n' &&
- NewlineMode(options_.all_options()) == PCRE_NEWLINE_CRLF) {
+ (NewlineMode(options_.all_options()) == PCRE_NEWLINE_CRLF ||
+ NewlineMode(options_.all_options()) == PCRE_NEWLINE_ANY ||
+ NewlineMode(options_.all_options()) == PCRE_NEWLINE_ANYCRLF)
+ ) {
matchend++;
}
// We also need to advance more than one char if we're in utf8 mode.