diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-04-16 15:28:08 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2007-04-16 15:28:08 +0000 |
commit | 99c49a95b9892e71ec8cd69cd1bcb3a96964ba15 (patch) | |
tree | 5b2b9bf5d6fb86e4d3851650956920f7557632d8 /pcretest.c | |
parent | 88e1c64afcd55068b44b441995139eb18c36bb01 (diff) | |
download | pcre-99c49a95b9892e71ec8cd69cd1bcb3a96964ba15.tar.gz |
Add PCRE_NEWLINE_ANYCRLF.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@149 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcretest.c')
-rw-r--r-- | pcretest.c | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -663,7 +663,8 @@ return count; *************************************************/ /* This is used both at compile and run-time to check for <xxx> escapes, where -xxx is LF, CR, CRLF, or ANY. Print a message and return 0 if there is no match. +xxx is LF, CR, CRLF, ANYCRLF, or ANY. Print a message and return 0 if there is +no match. Arguments: p points after the leading '<' @@ -678,6 +679,7 @@ check_newline(uschar *p, FILE *f) if (strncmp((char *)p, "cr>", 3) == 0) return PCRE_NEWLINE_CR; if (strncmp((char *)p, "lf>", 3) == 0) return PCRE_NEWLINE_LF; if (strncmp((char *)p, "crlf>", 5) == 0) return PCRE_NEWLINE_CRLF; +if (strncmp((char *)p, "anycrlf>", 8) == 0) return PCRE_NEWLINE_ANYCRLF; if (strncmp((char *)p, "any>", 4) == 0) return PCRE_NEWLINE_ANY; fprintf(f, "Unknown newline type at: <%s\n", p); return 0; @@ -850,6 +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 == -1)? "ANY" : "???"); (void)pcre_config(PCRE_CONFIG_LINK_SIZE, &rc); printf(" Internal link size = %d\n", rc); @@ -1445,6 +1448,10 @@ while (!done) fprintf(outfile, "Forced newline sequence: CRLF\n"); break; + case PCRE_NEWLINE_ANYCRLF: + fprintf(outfile, "Forced newline sequence: ANYCRLF\n"); + break; + case PCRE_NEWLINE_ANY: fprintf(outfile, "Forced newline sequence: ANY\n"); break; @@ -2218,11 +2225,11 @@ 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". - 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(). Fudge the - offset value to achieve this. + 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(). + Fudge the offset value to achieve this. Otherwise, in the case of UTF-8 matching, the advance must be one character, not one byte. */ @@ -2241,9 +2248,12 @@ 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 == -1)? PCRE_NEWLINE_ANY : 0; } - if ((obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANY && + if (((obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANY || + (obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANYCRLF) + && start_offset < len - 1 && bptr[start_offset] == '\r' && bptr[start_offset+1] == '\n') |