diff --git a/pcre_compile.c b/pcre_compile.c index 4d3b313..3360a8b 100644 --- a/pcre_compile.c +++ b/pcre_compile.c @@ -4699,6 +4699,23 @@ for (;; ptr++) } } + /* Skip over (?# comments. We need to do this here because we want to know if + the next thing is a quantifier, and these comments may come between an item + and its quantifier. */ + + if (c == CHAR_LEFT_PARENTHESIS && ptr[1] == CHAR_QUESTION_MARK && + ptr[2] == CHAR_NUMBER_SIGN) + { + ptr += 3; + while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++; + if (*ptr == CHAR_NULL) + { + *errorcodeptr = ERR18; + goto FAILED; + } + continue; + } + /* See if the next thing is a quantifier. */ is_quantifier = @@ -6529,21 +6546,6 @@ for (;; ptr++) case CHAR_LEFT_PARENTHESIS: ptr++; - /* First deal with comments. Putting this code right at the start ensures - that comments have no bad side effects. */ - - if (ptr[0] == CHAR_QUESTION_MARK && ptr[1] == CHAR_NUMBER_SIGN) - { - ptr += 2; - while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++; - if (*ptr == CHAR_NULL) - { - *errorcodeptr = ERR18; - goto FAILED; - } - continue; - } - /* Now deal with various "verbs" that can be introduced by '*'. */ if (ptr[0] == CHAR_ASTERISK && (ptr[1] == ':' diff --git a/testdata/testinput2 b/testdata/testinput2 index e2e520f..92e3359 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -4217,4 +4217,12 @@ backtracking verbs. --/ /a[[:punct:]b]/BZ +/L(?#(|++