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

Unified Diff: third_party/re2/re2/tostring.cc

Issue 1516543002: Update re2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated update instructions Created 5 years 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 | « third_party/re2/re2/testing/unicode_test.py ('k') | third_party/re2/re2/unicode.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/re2/re2/tostring.cc
diff --git a/third_party/re2/re2/tostring.cc b/third_party/re2/re2/tostring.cc
index 555524f291bca34a4a3e6dba0a29c3f9a98e8a6a..0230c8c9ca141ea18c5b7ff273ccb45bce2c70df 100644
--- a/third_party/re2/re2/tostring.cc
+++ b/third_party/re2/re2/tostring.cc
@@ -42,7 +42,7 @@ class ToStringWalker : public Regexp::Walker<int> {
private:
string* t_; // The string the walker appends to.
- DISALLOW_EVIL_CONSTRUCTORS(ToStringWalker);
+ DISALLOW_COPY_AND_ASSIGN(ToStringWalker);
};
string Regexp::ToString() {
@@ -94,6 +94,8 @@ int ToStringWalker::PreVisit(Regexp* re, int parent_arg, bool* stop) {
case kRegexpCapture:
t_->append("(");
+ if (re->cap() == 0)
+ LOG(DFATAL) << "kRegexpCapture cap() == 0";
if (re->name()) {
t_->append("?P<");
t_->append(*re->name());
@@ -120,13 +122,13 @@ int ToStringWalker::PreVisit(Regexp* re, int parent_arg, bool* stop) {
static void AppendLiteral(string *t, Rune r, bool foldcase) {
if (r != 0 && r < 0x80 && strchr("(){}[]*+?|.^$\\", r)) {
t->append(1, '\\');
- t->append(1, r);
+ t->append(1, static_cast<char>(r));
} else if (foldcase && 'a' <= r && r <= 'z') {
if ('a' <= r && r <= 'z')
r += 'A' - 'a';
t->append(1, '[');
- t->append(1, r);
- t->append(1, r + 'a' - 'A');
+ t->append(1, static_cast<char>(r));
+ t->append(1, static_cast<char>(r) + 'a' - 'A');
t->append(1, ']');
} else {
AppendCCRange(t, r, r);
@@ -154,12 +156,14 @@ int ToStringWalker::PostVisit(Regexp* re, int parent_arg, int pre_arg,
break;
case kRegexpLiteral:
- AppendLiteral(t_, re->rune(), re->parse_flags() & Regexp::FoldCase);
+ AppendLiteral(t_, re->rune(),
+ (re->parse_flags() & Regexp::FoldCase) != 0);
break;
case kRegexpLiteralString:
for (int i = 0; i < re->nrunes(); i++)
- AppendLiteral(t_, re->runes()[i], re->parse_flags() & Regexp::FoldCase);
+ AppendLiteral(t_, re->runes()[i],
+ (re->parse_flags() & Regexp::FoldCase) != 0);
if (prec < PrecConcat)
t_->append(")");
break;
@@ -297,7 +301,7 @@ static void AppendCCChar(string* t, Rune r) {
if (0x20 <= r && r <= 0x7E) {
if (strchr("[]^-\\", r))
t->append("\\");
- t->append(1, r);
+ t->append(1, static_cast<char>(r));
return;
}
switch (r) {
« no previous file with comments | « third_party/re2/re2/testing/unicode_test.py ('k') | third_party/re2/re2/unicode.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698