Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/base/parse_number.h" | |
| 6 | |
| 7 #include "base/strings/string_number_conversions.h" | |
| 8 | |
| 9 namespace net { | |
| 10 | |
| 11 bool ParseNonNegativeDecimalInt(const base::StringPiece& input, int* output) { | |
| 12 if (input.empty() || input[0] == '+' || input[0] == '-') | |
|
mmenke
2016/03/23 19:32:28
Can we just check if it's not between 0 and 9? Sa
eroman
2016/03/23 19:50:30
Done.
(I had same intuition, but somehow rejected
| |
| 13 return false; | |
| 14 | |
| 15 int result; | |
| 16 if (!base::StringToInt(input, &result)) | |
| 17 return false; | |
| 18 | |
| 19 *output = result; | |
| 20 return true; | |
| 21 } | |
| 22 | |
| 23 } // namespace net | |
| OLD | NEW |