Changeset View
Changeset View
Standalone View
Standalone View
src/leveldb/util/logging.cc
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | std::string EscapeString(const Slice& value) { | ||||
AppendEscapedStringTo(&r, value); | AppendEscapedStringTo(&r, value); | ||||
return r; | return r; | ||||
} | } | ||||
bool ConsumeDecimalNumber(Slice* in, uint64_t* val) { | bool ConsumeDecimalNumber(Slice* in, uint64_t* val) { | ||||
uint64_t v = 0; | uint64_t v = 0; | ||||
int digits = 0; | int digits = 0; | ||||
while (!in->empty()) { | while (!in->empty()) { | ||||
char c = (*in)[0]; | unsigned char c = (*in)[0]; | ||||
if (c >= '0' && c <= '9') { | if (c >= '0' && c <= '9') { | ||||
++digits; | ++digits; | ||||
const int delta = (c - '0'); | const int delta = (c - '0'); | ||||
static const uint64_t kMaxUint64 = ~static_cast<uint64_t>(0); | static const uint64_t kMaxUint64 = ~static_cast<uint64_t>(0); | ||||
if (v > kMaxUint64/10 || | if (v > kMaxUint64/10 || | ||||
(v == kMaxUint64/10 && delta > kMaxUint64%10)) { | (v == kMaxUint64/10 && delta > kMaxUint64%10)) { | ||||
// Overflow | // Overflow | ||||
return false; | return false; | ||||
Show All 12 Lines |