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

Unified Diff: tools/gn/parse_tree.cc

Issue 1038233002: tools/gn: disallow non-canonical integer literals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Just "auto"; it's cleaner Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gn/parse_tree_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parse_tree.cc
diff --git a/tools/gn/parse_tree.cc b/tools/gn/parse_tree.cc
index f5897065548f01b102328c3edaa41a7f31a27af6..88aa0a90bab9bb243f05437782106dba2db2431d 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: {
+ auto s = value_.value();
tfarina 2015/03/27 00:17:17 to not use it at all. I don't like to have to go t
mdempsky 2015/03/27 00:18:54 Done.
+ 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();
}
« no previous file with comments | « no previous file | tools/gn/parse_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698