Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: regexp2000/src/parser.cc

Issue 9692: * Fix bug in regexp parser. (Closed)
Patch Set: Addressed review comments Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « regexp2000/src/jsregexp.cc ('k') | regexp2000/test/cctest/test-regexp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: regexp2000/src/parser.cc
diff --git a/regexp2000/src/parser.cc b/regexp2000/src/parser.cc
index d2e05c2632fb6575a7fb41d62537ad319beb75b1..b5ed926db8e5bd42d4c3110c41f89cc844c4b8cb 100644
--- a/regexp2000/src/parser.cc
+++ b/regexp2000/src/parser.cc
@@ -4064,27 +4064,27 @@ RegExpTree* RegExpParser::ParseCharacterClass(bool* ok) {
}
ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2);
while (has_more() && current() != ']') {
- if (current() == '-') {
- Advance();
- ranges->Add(CharacterRange::Singleton('-'));
- } else {
- bool is_char_class = false;
- CharacterRange first = ParseClassAtom(&is_char_class, ranges, CHECK_OK);
- if (!is_char_class) {
- if (current() == '-') {
- Advance();
- CharacterRange next =
- ParseClassAtom(&is_char_class, ranges, CHECK_OK);
- if (is_char_class) {
- return ReportError(CStrVector(kIllegal), CHECK_OK);
- }
- if (first.from() > next.to()) {
- return ReportError(CStrVector(kRangeOutOfOrder), CHECK_OK);
- }
- ranges->Add(CharacterRange::Range(first.from(), next.to()));
- } else {
+ bool is_char_class = false;
+ CharacterRange first = ParseClassAtom(&is_char_class, ranges, CHECK_OK);
+ if (!is_char_class) {
+ if (current() == '-') {
+ Advance();
+ if (current() == ']') {
ranges->Add(first);
+ ranges->Add(CharacterRange::Singleton('-'));
+ break;
+ }
+ CharacterRange next =
+ ParseClassAtom(&is_char_class, ranges, CHECK_OK);
+ if (is_char_class) {
+ return ReportError(CStrVector(kIllegal), CHECK_OK);
}
+ if (first.from() > next.to()) {
+ return ReportError(CStrVector(kRangeOutOfOrder), CHECK_OK);
+ }
+ ranges->Add(CharacterRange::Range(first.from(), next.to()));
+ } else {
+ ranges->Add(first);
}
}
}
« no previous file with comments | « regexp2000/src/jsregexp.cc ('k') | regexp2000/test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698