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

Side by Side Diff: base/json/json_writer.cc

Issue 179373003: Fix build issues in base/ for Android x64 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use static_cast<size_t> directly Created 6 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 unified diff | Download patch
« no previous file with comments | « base/i18n/rtl.cc ('k') | no next file » | 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/json/json_writer.h" 5 #include "base/json/json_writer.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/json/string_escape.h" 9 #include "base/json/string_escape.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // makes sure that when we read the JSON back, it's interpreted as a 89 // makes sure that when we read the JSON back, it's interpreted as a
90 // real rather than an int. 90 // real rather than an int.
91 if (real.find('.') == std::string::npos && 91 if (real.find('.') == std::string::npos &&
92 real.find('e') == std::string::npos && 92 real.find('e') == std::string::npos &&
93 real.find('E') == std::string::npos) { 93 real.find('E') == std::string::npos) {
94 real.append(".0"); 94 real.append(".0");
95 } 95 }
96 // The JSON spec requires that non-integer values in the range (-1,1) 96 // The JSON spec requires that non-integer values in the range (-1,1)
97 // have a zero before the decimal point - ".52" is not valid, "0.52" is. 97 // have a zero before the decimal point - ".52" is not valid, "0.52" is.
98 if (real[0] == '.') { 98 if (real[0] == '.') {
99 real.insert(0U, 1U, '0'); 99 real.insert(static_cast<size_t>(0), static_cast<size_t>(1), '0');
100 } else if (real.length() > 1 && real[0] == '-' && real[1] == '.') { 100 } else if (real.length() > 1 && real[0] == '-' && real[1] == '.') {
101 // "-.1" bad "-0.1" good 101 // "-.1" bad "-0.1" good
102 real.insert(1U, 1U, '0'); 102 real.insert(static_cast<size_t>(1), static_cast<size_t>(1), '0');
103 } 103 }
104 json_string_->append(real); 104 json_string_->append(real);
105 return result; 105 return result;
106 } 106 }
107 107
108 case Value::TYPE_STRING: { 108 case Value::TYPE_STRING: {
109 std::string value; 109 std::string value;
110 bool result = node->GetAsString(&value); 110 bool result = node->GetAsString(&value);
111 DCHECK(result); 111 DCHECK(result);
112 EscapeJSONString(value, true, json_string_); 112 EscapeJSONString(value, true, json_string_);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 NOTREACHED(); 199 NOTREACHED();
200 return false; 200 return false;
201 } 201 }
202 202
203 void JSONWriter::IndentLine(size_t depth) { 203 void JSONWriter::IndentLine(size_t depth) {
204 json_string_->append(depth * 3U, ' '); 204 json_string_->append(depth * 3U, ' ');
205 } 205 }
206 206
207 } // namespace base 207 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/rtl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698