From d70bdebcc62f48ae54bb2d7e7216d629bdc5dfcc Mon Sep 17 00:00:00 2001 From: ph10 Date: Fri, 11 Dec 2009 16:42:50 +0000 Subject: Fix options set and reset at top level bug. git-svn-id: svn://vcs.exim.org/pcre/code/trunk@472 2f5784b3-3f2a-0410-8824-cb99058d5e15 --- pcre_compile.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'pcre_compile.c') diff --git a/pcre_compile.c b/pcre_compile.c index c360c43..0605a6e 100644 --- a/pcre_compile.c +++ b/pcre_compile.c @@ -5248,7 +5248,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */ { cd->external_options = newoptions; } - else + else { if ((options & PCRE_IMS) != (newoptions & PCRE_IMS)) { @@ -5783,6 +5783,7 @@ int branchfirstbyte, branchreqbyte; int length; int orig_bracount; int max_bracount; +int old_external_options = cd->external_options; branch_chain bc; bc.outer = bcptr; @@ -5859,6 +5860,15 @@ for (;;) return FALSE; } + /* If the external options have changed during this branch, it means that we + are at the top level, and a leading option setting has been encountered. We + need to re-set the original option values to take account of this so that, + during the pre-compile phase, we know to allow for a re-set at the start of + subsequent branches. */ + + if (old_external_options != cd->external_options) + oldims = cd->external_options & PCRE_IMS; + /* Keep the highest bracket count in case (?| was used and some branch has fewer than the rest. */ @@ -5969,7 +5979,7 @@ for (;;) PUT(code, 1, code - start_bracket); code += 1 + LINK_SIZE; - /* Resetting option if needed */ + /* Reset options if needed. */ if ((options & PCRE_IMS) != oldims && *ptr == CHAR_RIGHT_PARENTHESIS) { -- cgit v1.2.1