Chromium Code Reviews| Index: tools/gn/parse_tree.cc |
| diff --git a/tools/gn/parse_tree.cc b/tools/gn/parse_tree.cc |
| index f5897065548f01b102328c3edaa41a7f31a27af6..b77b58633a49d96ddf2edea1df08cb780741a987 100644 |
| --- a/tools/gn/parse_tree.cc |
| +++ b/tools/gn/parse_tree.cc |
| @@ -634,8 +634,16 @@ Value LiteralNode::Execute(Scope* scope, Err* err) const { |
| case Token::FALSE_TOKEN: |
| return Value(this, false); |
| case Token::INTEGER: { |
| + const auto& s = value_.value(); |
|
tfarina
2015/03/27 00:02:54
could you not use auto here?
mdempsky
2015/03/27 00:12:17
Done.
mdempsky
2015/03/27 00:14:17
Hm, was that a question about why I didn't just us
|
| + if ((s.starts_with("0") && s.size() > 1) || s.starts_with("-0")) { |
| + if (s == "-0") |
| + *err = MakeErrorDescribing("Negative zero doesn't make sense"); |
| + else |
| + *err = MakeErrorDescribing("Leading zeros not allowed"); |
| + return Value(); |
| + } |
| int64 result_int; |
| - if (!base::StringToInt64(value_.value(), &result_int)) { |
| + if (!base::StringToInt64(s, &result_int)) { |
| *err = MakeErrorDescribing("This does not look like an integer"); |
| return Value(); |
| } |