diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-05-09 08:54:11 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-05-09 08:54:11 +0000 |
commit | 339ac59e31f61abddbda53e1d6c67aa363465a51 (patch) | |
tree | cfdea15ff585d2a0373a629cc4eb0301feeb982e /pcre_exec.c | |
parent | 6e984a51d76bc59296b1f97fd7ec5d420bbc2cfd (diff) | |
download | pcre-339ac59e31f61abddbda53e1d6c67aa363465a51.tar.gz |
Fix backup bug for \R with greedy quantifier.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@600 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_exec.c')
-rw-r--r-- | pcre_exec.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/pcre_exec.c b/pcre_exec.c index 8e965ba..44e4f8c 100644 --- a/pcre_exec.c +++ b/pcre_exec.c @@ -2017,6 +2017,7 @@ for (;;) switch(c) { default: MRRETURN(MATCH_NOMATCH); + case 0x000d: if (eptr < md->end_subject && *eptr == 0x0a) eptr++; break; @@ -3791,6 +3792,7 @@ for (;;) switch(c) { default: MRRETURN(MATCH_NOMATCH); + case 0x000d: if (eptr < md->end_subject && *eptr == 0x0a) eptr++; break; @@ -4067,9 +4069,11 @@ for (;;) switch(*eptr++) { default: MRRETURN(MATCH_NOMATCH); + case 0x000d: if (eptr < md->end_subject && *eptr == 0x0a) eptr++; break; + case 0x000a: break; @@ -5258,7 +5262,11 @@ for (;;) RRETURN(PCRE_ERROR_INTERNAL); } - /* eptr is now past the end of the maximum run */ + /* eptr is now past the end of the maximum run. If possessive, we are + done (no backing up). Otherwise, match at this position; anything other + than no match is immediately returned. For nomatch, back up one + character, unless we are matching \R and the last thing matched was + \r\n, in which case, back up two bytes. */ if (possessive) continue; for(;;) @@ -5267,6 +5275,8 @@ for (;;) if (rrc != MATCH_NOMATCH) RRETURN(rrc); if (eptr-- == pp) break; /* Stop if tried at original pos */ BACKCHAR(eptr); + if (ctype == OP_ANYNL && eptr > pp && *eptr == '\n' && + eptr[-1] == '\r') eptr--; } } else @@ -5465,14 +5475,20 @@ for (;;) RRETURN(PCRE_ERROR_INTERNAL); } - /* eptr is now past the end of the maximum run */ + /* eptr is now past the end of the maximum run. If possessive, we are + done (no backing up). Otherwise, match at this position; anything other + than no match is immediately returned. For nomatch, back up one + character (byte), unless we are matching \R and the last thing matched + was \r\n, in which case, back up two bytes. */ if (possessive) continue; while (eptr >= pp) { RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM47); - eptr--; if (rrc != MATCH_NOMATCH) RRETURN(rrc); + eptr--; + if (ctype == OP_ANYNL && eptr > pp && *eptr == '\n' && + eptr[-1] == '\r') eptr--; } } |