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

Side by Side Diff: runtime/vm/double_conversion.cc

Issue 13529014: Use locale insensitive method to parse double literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Srdjan's comments Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/double_conversion.h" 5 #include "vm/double_conversion.h"
6 6
7 #include "third_party/double-conversion/src/double-conversion.h" 7 #include "third_party/double-conversion/src/double-conversion.h"
8 8
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 kMaxTrailingPaddingZeroes); 159 kMaxTrailingPaddingZeroes);
160 160
161 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); 161 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize);
162 buffer[kBufferSize - 1] = '\0'; 162 buffer[kBufferSize - 1] = '\0';
163 double_conversion::StringBuilder builder(buffer, kBufferSize); 163 double_conversion::StringBuilder builder(buffer, kBufferSize);
164 bool status = converter.ToPrecision(d, precision, &builder); 164 bool status = converter.ToPrecision(d, precision, &builder);
165 ASSERT(status); 165 ASSERT(status);
166 return String::New(builder.Finalize()); 166 return String::New(builder.Finalize());
167 } 167 }
168 168
169
170 bool CStringToDouble(const char* str, intptr_t length, double* result) {
171 if (length == 0) {
172 return false;
173 }
174
175 double_conversion::StringToDoubleConverter converter(
176 double_conversion::StringToDoubleConverter::NO_FLAGS,
177 0.0,
178 0.0,
179 kDoubleToStringCommonInfinitySymbol,
180 kDoubleToStringCommonNaNSymbol);
181
182 int parsed_count = 0;
183 *result = converter.StringToDouble(str,
184 static_cast<int>(length),
185 &parsed_count);
186 return (parsed_count == length);
187 }
188
189
169 } // namespace dart 190 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698