Fix for grep and egrep syntax types, plus tests.

[SVN r36470]
This commit is contained in:
John Maddock
2006-12-20 17:19:25 +00:00
parent 107d4d5f63
commit 2a87146c18
4 changed files with 16 additions and 2 deletions

View File

@ -24,7 +24,7 @@
</P> </P>
<HR> <HR>
<p></p> <p></p>
<P>Often there is more that one way of matching a regular expression at a <P>Often there is more than one way of matching a regular expression at a
particular location, for POSIX basic and extended regular expressions, the particular location, for POSIX basic and extended regular expressions, the
"best" match is determined as follows:</P> "best" match is determined as follows:</P>
<OL> <OL>

View File

@ -24,7 +24,7 @@
</P> </P>
<HR> <HR>
<p></p> <p></p>
<P>Often there is more that one way of matching a regular expression at a <P>Often there is more than one way of matching a regular expression at a
particular location, for POSIX basic and extended regular expressions, the particular location, for POSIX basic and extended regular expressions, the
"best" match is determined as follows:</P> "best" match is determined as follows:</P>
<OL> <OL>

View File

@ -222,6 +222,11 @@ bool basic_regex_parser<charT, traits>::parse_basic()
} }
case regex_constants::syntax_open_set: case regex_constants::syntax_open_set:
return parse_set(); return parse_set();
case regex_constants::syntax_newline:
if(this->flags() & regbase::newline_alt)
return parse_alt();
else
return parse_literal();
default: default:
return parse_literal(); return parse_literal();
} }
@ -286,6 +291,11 @@ bool basic_regex_parser<charT, traits>::parse_extended()
return parse_alt(); return parse_alt();
case regex_constants::syntax_open_set: case regex_constants::syntax_open_set:
return parse_set(); return parse_set();
case regex_constants::syntax_newline:
if(this->flags() & regbase::newline_alt)
return parse_alt();
else
return parse_literal();
case regex_constants::syntax_hash: case regex_constants::syntax_hash:
// //
// If we have a mod_x flag set, then skip until // If we have a mod_x flag set, then skip until

View File

@ -42,5 +42,9 @@ void test_alt()
TEST_REGEX_SEARCH("a|", basic|bk_vbar, "a|", match_default, make_array(0, 2, -2, -2)); TEST_REGEX_SEARCH("a|", basic|bk_vbar, "a|", match_default, make_array(0, 2, -2, -2));
TEST_REGEX_SEARCH("a\\|b", basic|bk_vbar, "a", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("a\\|b", basic|bk_vbar, "a", match_default, make_array(0, 1, -2, -2));
TEST_REGEX_SEARCH("a\\|b", basic|bk_vbar, "b", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("a\\|b", basic|bk_vbar, "b", match_default, make_array(0, 1, -2, -2));
TEST_REGEX_SEARCH("a\nb", grep, "b", match_default, make_array(0, 1, -2, -2));
TEST_REGEX_SEARCH("a\nb", grep, "a", match_default, make_array(0, 1, -2, -2));
TEST_REGEX_SEARCH("a\nb", egrep, "b", match_default, make_array(0, 1, -2, -2));
TEST_REGEX_SEARCH("a\nb", egrep, "a", match_default, make_array(0, 1, -2, -2));
} }