@@ -1077,21 +1077,40 @@ bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_
10771077 // Check for illegal following quantifier, we have to do this here, because
10781078 // the extra states we insert below circumvents our usual error checking :-(
10791079 //
1080- if ((this ->flags () & (regbase::main_option_type | regbase::mod_x | regbase::no_perl_ex)) == regbase::mod_x)
1080+ bool contin = false ;
1081+ do
10811082 {
1082- // whitespace skip:
1083- while ((m_position != m_end) && this ->m_traits .isctype (*m_position, this ->m_mask_space ))
1084- ++m_position;
1085- }
1086- switch (this ->m_traits .syntax_type (*m_position))
1087- {
1088- case regex_constants::syntax_star:
1089- case regex_constants::syntax_plus:
1090- case regex_constants::syntax_question:
1091- case regex_constants::syntax_open_brace:
1092- fail (regex_constants::error_badrepeat, m_position - m_base);
1093- return false ;
1094- }
1083+ if ((this ->flags () & (regbase::main_option_type | regbase::mod_x | regbase::no_perl_ex)) == regbase::mod_x)
1084+ {
1085+ // whitespace skip:
1086+ while ((m_position != m_end) && this ->m_traits .isctype (*m_position, this ->m_mask_space ))
1087+ ++m_position;
1088+ }
1089+ if (m_position != m_end)
1090+ {
1091+ switch (this ->m_traits .syntax_type (*m_position))
1092+ {
1093+ case regex_constants::syntax_star:
1094+ case regex_constants::syntax_plus:
1095+ case regex_constants::syntax_question:
1096+ case regex_constants::syntax_open_brace:
1097+ fail (regex_constants::error_badrepeat, m_position - m_base);
1098+ return false ;
1099+ case regex_constants::syntax_open_mark:
1100+ // Do we have a comment? If so we need to skip it here...
1101+ if ((m_position + 2 < m_end) && this ->m_traits .syntax_type (*(m_position + 1 )) == regex_constants::syntax_question
1102+ && this ->m_traits .syntax_type (*(m_position + 2 )) == regex_constants::syntax_hash)
1103+ {
1104+ while ((m_position != m_end)
1105+ && (this ->m_traits .syntax_type (*m_position++) != regex_constants::syntax_close_mark)) {
1106+ }
1107+ }
1108+ contin = true ;
1109+ }
1110+ }
1111+ else
1112+ contin = false ;
1113+ } while (contin);
10951114 }
10961115 re_brace* pb = static_cast <re_brace*>(this ->insert_state (insert_point, syntax_element_startmark, sizeof (re_brace)));
10971116 pb->index = -3 ;
@@ -2010,7 +2029,7 @@ bool basic_regex_parser<charT, traits>::parse_perl_extension()
20102029 {
20112030 while ((m_position != m_end)
20122031 && (this ->m_traits .syntax_type (*m_position++) != regex_constants::syntax_close_mark))
2013- {}
2032+ {}
20142033 return true ;
20152034 }
20162035 //
0 commit comments