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

Side by Side Diff: base/version.cc

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « base/trace_event/trace_event_synthetic_delay.cc ('k') | base/version_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/version.h" 5 #include "base/version.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 13 matching lines...) Expand all
24 // parsed successfully, false otherwise. 24 // parsed successfully, false otherwise.
25 bool ParseVersionNumbers(const std::string& version_str, 25 bool ParseVersionNumbers(const std::string& version_str,
26 std::vector<uint16>* parsed) { 26 std::vector<uint16>* parsed) {
27 std::vector<std::string> numbers; 27 std::vector<std::string> numbers;
28 SplitString(version_str, '.', &numbers); 28 SplitString(version_str, '.', &numbers);
29 if (numbers.empty()) 29 if (numbers.empty())
30 return false; 30 return false;
31 31
32 for (std::vector<std::string>::const_iterator it = numbers.begin(); 32 for (std::vector<std::string>::const_iterator it = numbers.begin();
33 it != numbers.end(); ++it) { 33 it != numbers.end(); ++it) {
34 if (StartsWithASCII(*it, "+", false))
35 return false;
36 int num; 34 int num;
37 if (!StringToInt(*it, &num)) 35 if (!StringToInt(*it, &num))
38 return false; 36 return false;
39 37
40 if (num < 0) 38 if (num < 0)
41 return false; 39 return false;
42 40
43 const uint16 max = 0xFFFF; 41 const uint16 max = 0xFFFF;
44 if (num > max) 42 if (num > max)
45 return false; 43 return false;
46 44
47 // This throws out leading zeros for the first item only. 45 // This throws out things like +3, or 032.
48 if (it == numbers.begin() && IntToString(num) != *it) 46 if (IntToString(num) != *it)
49 return false; 47 return false;
50 48
51 parsed->push_back(static_cast<uint16>(num)); 49 parsed->push_back(static_cast<uint16>(num));
52 } 50 }
53 return true; 51 return true;
54 } 52 }
55 53
56 // Compares version components in |components1| with components in 54 // Compares version components in |components1| with components in
57 // |components2|. Returns -1, 0 or 1 if |components1| is less than, equal to, 55 // |components2|. Returns -1, 0 or 1 if |components1| is less than, equal to,
58 // or greater than |components2|, respectively. 56 // or greater than |components2|, respectively.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 size_t count = components_.size(); 169 size_t count = components_.size();
172 for (size_t i = 0; i < count - 1; ++i) { 170 for (size_t i = 0; i < count - 1; ++i) {
173 version_str.append(IntToString(components_[i])); 171 version_str.append(IntToString(components_[i]));
174 version_str.append("."); 172 version_str.append(".");
175 } 173 }
176 version_str.append(IntToString(components_[count - 1])); 174 version_str.append(IntToString(components_[count - 1]));
177 return version_str; 175 return version_str;
178 } 176 }
179 177
180 } // namespace base 178 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_synthetic_delay.cc ('k') | base/version_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698