diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-09-11 11:15:33 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-09-11 11:15:33 +0000 |
commit | 1efcdd63835a98ad89649d4b0b89d6d875e54b2e (patch) | |
tree | d76b45cb414c6694d744369626e29c6cee14318d /pcre_dfa_exec.c | |
parent | 6daf21e6a650630d1ef31720c2f92f555127fe80 (diff) | |
download | pcre-1efcdd63835a98ad89649d4b0b89d6d875e54b2e.tar.gz |
Add facility to make \R match only CR, LF, or CRLF.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@231 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_dfa_exec.c')
-rw-r--r-- | pcre_dfa_exec.c | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/pcre_dfa_exec.c b/pcre_dfa_exec.c index dc1412b..b1d4c5e 100644 --- a/pcre_dfa_exec.c +++ b/pcre_dfa_exec.c @@ -1080,15 +1080,20 @@ for (;;) int ncount = 0; switch (c) { - case 0x000d: - if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; - /* Fall through */ - case 0x000a: case 0x000b: case 0x000c: case 0x0085: case 0x2028: case 0x2029: + if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break; + goto ANYNL01; + + case 0x000d: + if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; + /* Fall through */ + + ANYNL01: + case 0x000a: if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS) { active_count--; /* Remove non-match possibility */ @@ -1097,6 +1102,7 @@ for (;;) count++; ADD_NEW_DATA(-state_offset, count, ncount); break; + default: break; } @@ -1313,15 +1319,20 @@ for (;;) int ncount = 0; switch (c) { - case 0x000d: - if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; - /* Fall through */ - case 0x000a: case 0x000b: case 0x000c: case 0x0085: case 0x2028: case 0x2029: + if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break; + goto ANYNL02; + + case 0x000d: + if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; + /* Fall through */ + + ANYNL02: + case 0x000a: if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR || codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY) { @@ -1330,6 +1341,7 @@ for (;;) } ADD_NEW_DATA(-(state_offset + count), 0, ncount); break; + default: break; } @@ -1545,15 +1557,20 @@ for (;;) int ncount = 0; switch (c) { - case 0x000d: - if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; - /* Fall through */ - case 0x000a: case 0x000b: case 0x000c: case 0x0085: case 0x2028: case 0x2029: + if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break; + goto ANYNL03; + + case 0x000d: + if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1; + /* Fall through */ + + ANYNL03: + case 0x000a: if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO) { active_count--; /* Remove non-match possibility */ @@ -1564,6 +1581,7 @@ for (;;) else { ADD_NEW_DATA(-state_offset, count, ncount); } break; + default: break; } @@ -1744,14 +1762,17 @@ for (;;) case OP_ANYNL: if (clen > 0) switch(c) { - case 0x000a: case 0x000b: case 0x000c: case 0x0085: case 0x2028: case 0x2029: + if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break; + + case 0x000a: ADD_NEW(state_offset + 1, 0); break; + case 0x000d: if (ptr + 1 < end_subject && ptr[1] == 0x0a) { @@ -2574,6 +2595,18 @@ md->end_subject = end_subject; md->moptions = options; md->poptions = re->options; +/* If the BSR option is not set at match time, copy what was set +at compile time. */ + +if ((md->moptions & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) == 0) + { + if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0) + md->moptions |= re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE); +#ifdef BSR_ANYCRLF + else md->moptions |= PCRE_BSR_ANYCRLF; +#endif + } + /* Handle different types of newline. The three bits give eight cases. If nothing is set at run time, whatever was used at compile time applies. */ |