--- code/trunk/pcre_dfa_exec.c 2007/03/02 13:10:43 96 +++ code/trunk/pcre_dfa_exec.c 2007/04/16 15:28:08 149 @@ -6,7 +6,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2006 University of Cambridge + Copyright (c) 1997-2007 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -2057,7 +2057,7 @@ Arguments: argument_re points to the compiled expression - extra_data points to extra data or is NULL (not currently used) + extra_data points to extra data or is NULL subject points to the subject string length length of subject string (may contain binary zeros) start_offset where to start in the subject string @@ -2073,7 +2073,7 @@ < -1 => some kind of unexpected problem */ -PCRE_DATA_SCOPE int +PCRE_EXP_DEFN int pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data, const char *subject, int length, int start_offset, int options, int *offsets, int offsetcount, int *workspace, int wscount) @@ -2163,10 +2163,10 @@ md->moptions = options; md->poptions = re->options; -/* Handle different types of newline. The two bits give four cases. If nothing -is set at run time, whatever was used at compile time applies. */ +/* 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. */ -switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : options) & +switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)options) & PCRE_NEWLINE_BITS) { case 0: newline = NEWLINE; break; /* Compile-time default */ @@ -2175,10 +2175,15 @@ 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; default: return PCRE_ERROR_BADNEWLINE; } -if (newline < 0) +if (newline == -2) + { + md->nltype = NLTYPE_ANYCRLF; + } +else if (newline < 0) { md->nltype = NLTYPE_ANY; } @@ -2308,6 +2313,16 @@ { while (current_subject <= end_subject && !WAS_NEWLINE(current_subject)) current_subject++; + + /* If we have just passed a CR and the newline option is 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) && + current_subject < end_subject && + *current_subject == '\n') + current_subject++; } } @@ -2416,11 +2431,14 @@ } if (current_subject > end_subject) break; - /* If we have just passed a CR and the newline option is CRLF or ANY, and we - are now at a LF, advance the match position by one more character. */ + /* 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->nllen == 2) && + (md->nltype == NLTYPE_ANY || + md->nltype == NLTYPE_ANYCRLF || + md->nllen == 2) && current_subject < end_subject && *current_subject == '\n') current_subject++;