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

Unified Diff: third_party/re2/util/pcre.cc

Issue 1530113002: Revert of Update re2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/util/pcre.h ('k') | third_party/re2/util/rune.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/re2/util/pcre.cc
diff --git a/third_party/re2/util/pcre.cc b/third_party/re2/util/pcre.cc
index 9a3f32d25a370d65193e4f0a68e6de106903a9d9..160213335ea12f3f46e85604d8efd053afd7d3f6 100644
--- a/third_party/re2/util/pcre.cc
+++ b/third_party/re2/util/pcre.cc
@@ -7,10 +7,14 @@
// compilation as PCRE in namespace re2.
#include <errno.h>
-#include <limits>
#include "util/util.h"
#include "util/flags.h"
#include "util/pcre.h"
+
+#ifdef WIN32
+#define strtoll _strtoi64
+#define strtoull _strtoui64
+#endif
#define PCREPORT(level) LOG(level)
@@ -22,42 +26,6 @@
DEFINE_int32(regexp_stack_limit, 256<<10, "default PCRE stack limit (bytes)");
DEFINE_int32(regexp_match_limit, 1000000,
"default PCRE match limit (function calls)");
-
-#ifndef USEPCRE
-
-// Fake just enough of the PCRE API to allow this file to build. :)
-
-struct pcre_extra {
- int flags;
- int match_limit;
- int match_limit_recursion;
-};
-
-#define PCRE_EXTRA_MATCH_LIMIT 0
-#define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0
-#define PCRE_ANCHORED 0
-#define PCRE_NOTEMPTY 0
-#define PCRE_ERROR_NOMATCH 1
-#define PCRE_ERROR_MATCHLIMIT 2
-#define PCRE_ERROR_RECURSIONLIMIT 3
-#define PCRE_INFO_CAPTURECOUNT 0
-
-void pcre_free(void*) {
-}
-
-pcre* pcre_compile(const char*, int, const char**, int*, const unsigned char*) {
- return NULL;
-}
-
-int pcre_exec(const pcre*, const pcre_extra*, const char*, int, int, int, int*, int) {
- return 0;
-}
-
-int pcre_fullinfo(const pcre*, const pcre_extra*, int, void*) {
- return 0;
-}
-
-#endif
namespace re2 {
@@ -150,7 +118,7 @@
// ANCHOR_BOTH Tack a "\z" to the end of the original pattern
// and use a pcre anchored match.
- const char* error = "";
+ const char* error;
int eoffset;
pcre* re;
if (anchor != ANCHOR_BOTH) {
@@ -215,7 +183,7 @@
done:
int consumed;
- int vec[kVecSize] = {};
+ int vec[kVecSize];
return re.DoMatchImpl(text, ANCHOR_BOTH, &consumed, args, n, vec, kVecSize);
}
@@ -258,7 +226,7 @@
done:
int consumed;
- int vec[kVecSize] = {};
+ int vec[kVecSize];
return re.DoMatchImpl(text, UNANCHORED, &consumed, args, n, vec, kVecSize);
}
@@ -301,7 +269,7 @@
done:
int consumed;
- int vec[kVecSize] = {};
+ int vec[kVecSize];
if (pattern.DoMatchImpl(*input, ANCHOR_START, &consumed,
args, n, vec, kVecSize)) {
input->remove_prefix(consumed);
@@ -350,7 +318,7 @@
done:
int consumed;
- int vec[kVecSize] = {};
+ int vec[kVecSize];
if (pattern.DoMatchImpl(*input, UNANCHORED, &consumed,
args, n, vec, kVecSize)) {
input->remove_prefix(consumed);
@@ -363,7 +331,7 @@
bool PCRE::Replace(string *str,
const PCRE& pattern,
const StringPiece& rewrite) {
- int vec[kVecSize] = {};
+ int vec[kVecSize];
int matches = pattern.TryMatch(*str, 0, UNANCHORED, true, vec, kVecSize);
if (matches == 0)
return false;
@@ -382,12 +350,12 @@
const PCRE& pattern,
const StringPiece& rewrite) {
int count = 0;
- int vec[kVecSize] = {};
+ int vec[kVecSize];
string out;
int start = 0;
bool last_match_was_empty_string = false;
- while (start <= static_cast<int>(str->size())) {
+ for (; start <= str->length();) {
// If the previous match was for the empty string, we shouldn't
// just match again: we'll match in the same way and get an
// infinite loop. Instead, we do the match in a special way:
@@ -403,15 +371,14 @@
matches = pattern.TryMatch(*str, start, ANCHOR_START, false,
vec, kVecSize);
if (matches <= 0) {
- if (start < static_cast<int>(str->size()))
+ if (start < str->length())
out.push_back((*str)[start]);
start++;
last_match_was_empty_string = false;
continue;
}
} else {
- matches = pattern.TryMatch(*str, start, UNANCHORED, true,
- vec, kVecSize);
+ matches = pattern.TryMatch(*str, start, UNANCHORED, true, vec, kVecSize);
if (matches <= 0)
break;
}
@@ -429,8 +396,8 @@
if (count == 0)
return 0;
- if (start < static_cast<int>(str->size()))
- out.append(*str, start, static_cast<int>(str->size()) - start);
+ if (start < str->length())
+ out.append(*str, start, str->length() - start);
swap(out, *str);
return count;
}
@@ -439,7 +406,7 @@
const PCRE& pattern,
const StringPiece &rewrite,
string *out) {
- int vec[kVecSize] = {};
+ int vec[kVecSize];
int matches = pattern.TryMatch(text, 0, UNANCHORED, true, vec, kVecSize);
if (matches == 0)
return false;
@@ -485,7 +452,7 @@
/***** Actual matching and rewriting code *****/
bool PCRE::HitLimit() {
- return hit_limit_ != 0;
+ return hit_limit_;
}
void PCRE::ClearHitLimit() {
@@ -633,9 +600,9 @@
const Arg* const args[],
int n) const {
assert(n >= 0);
- const int vecsize = (1 + n) * 3; // results + PCRE workspace
- // (as for kVecSize)
- int* vec = new int[vecsize];
+ size_t const vecsize = (1 + n) * 3; // results + PCRE workspace
+ // (as for kVecSize)
+ int *vec = new int[vecsize];
bool b = DoMatchImpl(text, anchor, consumed, args, n, vec, vecsize);
delete[] vec;
return b;
@@ -841,7 +808,7 @@
if (!parse_long_radix(str, n, &r, radix)) return false; // Could not parse
if ((short)r != r) return false; // Out of range
if (dest == NULL) return true;
- *(reinterpret_cast<short*>(dest)) = (short)r;
+ *(reinterpret_cast<short*>(dest)) = r;
return true;
}
@@ -853,7 +820,7 @@
if (!parse_ulong_radix(str, n, &r, radix)) return false; // Could not parse
if ((ushort)r != r) return false; // Out of range
if (dest == NULL) return true;
- *(reinterpret_cast<unsigned short*>(dest)) = (ushort)r;
+ *(reinterpret_cast<unsigned short*>(dest)) = r;
return true;
}
@@ -931,7 +898,7 @@
char* end;
double r = strtod(buf, &end);
if (end != buf + n) {
-#ifdef _WIN32
+#ifdef COMPILER_MSVC
// Microsoft's strtod() doesn't handle inf and nan, so we have to
// handle it explicitly. Speed is not important here because this
// code is only called in unit tests.
@@ -944,11 +911,11 @@
++i;
}
if (0 == stricmp(i, "inf") || 0 == stricmp(i, "infinity")) {
- r = std::numeric_limits<double>::infinity();
+ r = numeric_limits<double>::infinity();
if (!pos)
r = -r;
} else if (0 == stricmp(i, "nan")) {
- r = std::numeric_limits<double>::quiet_NaN();
+ r = numeric_limits<double>::quiet_NaN();
} else {
return false;
}
« no previous file with comments | « third_party/re2/util/pcre.h ('k') | third_party/re2/util/rune.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698