Chromium Code Reviews| Index: base/version.cc |
| diff --git a/base/version.cc b/base/version.cc |
| index 933356ea77c2f4f2faedb603fd0634b3be3c24e4..c7e0e39973fe83800567562e4c420027a266a927 100644 |
| --- a/base/version.cc |
| +++ b/base/version.cc |
| @@ -23,7 +23,7 @@ namespace { |
| // is the resulting integer vector. Function returns true if all numbers were |
| // parsed successfully, false otherwise. |
| bool ParseVersionNumbers(const std::string& version_str, |
| - std::vector<uint16>* parsed) { |
| + std::vector<uint32>* parsed) { |
| std::vector<std::string> numbers; |
| SplitString(version_str, '.', &numbers); |
| if (numbers.empty()) |
| @@ -33,22 +33,22 @@ bool ParseVersionNumbers(const std::string& version_str, |
| it != numbers.end(); ++it) { |
| if (StartsWithASCII(*it, "+", false)) |
| return false; |
| - int num; |
| - if (!StringToInt(*it, &num)) |
| + int64 num; |
| + if (!StringToInt64(*it, &num)) |
|
grt (UTC plus 2)
2015/03/09 13:19:49
why not StringToUint? you could static_assert that
Nico
2015/03/09 14:21:57
Is anything wrong with this? It makes it much easi
Will Harris
2015/03/09 22:52:17
Done.
Will Harris
2015/03/09 22:52:17
grt's way makes the code far simpler - since Strin
|
| return false; |
| if (num < 0) |
| return false; |
| - const uint16 max = 0xFFFF; |
| + const int64 max = 0xFFFFFFFF; |
| if (num > max) |
| return false; |
| // This throws out leading zeros for the first item only. |
| - if (it == numbers.begin() && IntToString(num) != *it) |
| + if (it == numbers.begin() && Int64ToString(num) != *it) |
| return false; |
| - parsed->push_back(static_cast<uint16>(num)); |
| + parsed->push_back(static_cast<uint32>(num)); |
| } |
| return true; |
| } |
| @@ -56,8 +56,8 @@ bool ParseVersionNumbers(const std::string& version_str, |
| // Compares version components in |components1| with components in |
| // |components2|. Returns -1, 0 or 1 if |components1| is less than, equal to, |
| // or greater than |components2|, respectively. |
| -int CompareVersionComponents(const std::vector<uint16>& components1, |
| - const std::vector<uint16>& components2) { |
| +int CompareVersionComponents(const std::vector<uint32>& components1, |
| + const std::vector<uint32>& components2) { |
| const size_t count = std::min(components1.size(), components2.size()); |
| for (size_t i = 0; i < count; ++i) { |
| if (components1[i] > components2[i]) |
| @@ -88,7 +88,7 @@ Version::~Version() { |
| } |
| Version::Version(const std::string& version_str) { |
| - std::vector<uint16> parsed; |
| + std::vector<uint32> parsed; |
| if (!ParseVersionNumbers(version_str, &parsed)) |
| return; |
| @@ -127,7 +127,7 @@ int Version::CompareToWildcardString(const std::string& wildcard_string) const { |
| return CompareTo(version); |
| } |
| - std::vector<uint16> parsed; |
| + std::vector<uint32> parsed; |
| const bool success = ParseVersionNumbers( |
| wildcard_string.substr(0, wildcard_string.length() - 2), &parsed); |
| DCHECK(success); |