aboutsummaryrefslogtreecommitdiff
path: root/re2
diff options
context:
space:
mode:
authorPaul Wankadia <junyer@google.com>2016-02-14 12:56:31 +1100
committerPaul Wankadia <junyer@google.com>2016-02-14 02:01:52 +0000
commit6ce490f820e7cc5097baae2e1ed1337cbeb90305 (patch)
tree861f8f5254befecbc8eaf86ec0999b8c7ed10615 /re2
parent14c7fafc9d68005b06fb958302f57990f33f8a88 (diff)
downloadregex-re2-6ce490f820e7cc5097baae2e1ed1337cbeb90305.tar.gz
Fix bug in the BitState execution of the Fail instruction.
Change-Id: I209a846c67149dad2daed965e6a657a202522306 Reviewed-on: https://code-review.googlesource.com/4171 Reviewed-by: Paul Wankadia <junyer@google.com>
Diffstat (limited to 're2')
-rw-r--r--re2/bitstate.cc8
-rw-r--r--re2/testing/re2_test.cc6
2 files changed, 6 insertions, 8 deletions
diff --git a/re2/bitstate.cc b/re2/bitstate.cc
index 5740daa..0cfa480 100644
--- a/re2/bitstate.cc
+++ b/re2/bitstate.cc
@@ -169,13 +169,13 @@ bool BitState::TrySearch(int id0, const char* p0) {
// << (p - text_.begin()) << " " << arg;
Prog::Inst* ip = prog_->inst(id);
switch (ip->opcode()) {
- case kInstFail:
- return false;
-
default:
LOG(DFATAL) << "Unexpected opcode: " << ip->opcode() << " arg " << arg;
return false;
+ case kInstFail:
+ continue;
+
case kInstAlt:
// Cannot just
// Push(ip->out1(), p, 0);
@@ -196,7 +196,7 @@ bool BitState::TrySearch(int id0, const char* p0) {
id = ip->out1();
goto CheckAndLoop;
}
- LOG(DFATAL) << "Bad arg in kInstCapture: " << arg;
+ LOG(DFATAL) << "Bad arg in kInstAlt: " << arg;
continue;
case kInstAltMatch:
diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc
index e201c1e..ca561fb 100644
--- a/re2/testing/re2_test.cc
+++ b/re2/testing/re2_test.cc
@@ -17,8 +17,6 @@
#include "re2/re2.h"
#include "re2/regexp.h"
-DECLARE_bool(logtostderr);
-
namespace re2 {
TEST(RE2, HexTests) {
@@ -1540,7 +1538,7 @@ TEST(RE2, Bug18458852) {
}
TEST(RE2, Bug18523943) {
- // Bug in bitstate: case kFailInst was merged into the default with LOG(DFATAL).
+ // Bug in BitState: case kFailInst failed the match entirely.
RE2::Options opt;
const char a[] = {
@@ -1559,7 +1557,7 @@ TEST(RE2, Bug18523943) {
RE2 re((const char*)b, opt);
CHECK(re.ok());
string s1;
- CHECK(!RE2::PartialMatch((const char*)a, re, &s1));
+ CHECK(RE2::PartialMatch((const char*)a, re, &s1));
}
TEST(RE2, Bug21371806) {