OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 "src/inspector/string-16.h" | 5 #include "src/inspector/string-16.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cctype> | 8 #include <cctype> |
9 #include <cstdlib> | 9 #include <cstdlib> |
10 #include <cstring> | 10 #include <cstring> |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 | 373 |
374 // static | 374 // static |
375 String16 String16::fromInteger(size_t number) { | 375 String16 String16::fromInteger(size_t number) { |
376 const size_t kBufferSize = 50; | 376 const size_t kBufferSize = 50; |
377 char buffer[kBufferSize]; | 377 char buffer[kBufferSize]; |
378 v8::base::OS::SNPrintF(buffer, kBufferSize, "%zu", number); | 378 v8::base::OS::SNPrintF(buffer, kBufferSize, "%zu", number); |
379 return String16(buffer); | 379 return String16(buffer); |
380 } | 380 } |
381 | 381 |
382 // static | 382 // static |
383 String16 String16::fromDouble(double number) { | 383 String16 String16::fromDouble(double number) { |
dgozman
2016/10/11 19:35:07
I don't think we ever want this method, so leave o
kozy
2016/10/11 20:55:52
Done.
| |
384 const size_t kBufferSize = 100; | 384 const size_t kBufferSize = 100; |
385 char buffer[kBufferSize]; | 385 char buffer[kBufferSize]; |
386 v8::base::OS::SNPrintF(buffer, kBufferSize, "%f", number); | 386 v8::base::OS::SNPrintF(buffer, kBufferSize, "%f", number); |
387 return String16(buffer); | 387 return String16(buffer); |
388 } | 388 } |
389 | 389 |
390 // static | 390 // static |
391 String16 String16::fromDoubleForcePointAsSeparator(double number) { | |
392 const size_t kBufferSize = 100; | |
393 char buffer[kBufferSize]; | |
394 std::string prev_locale = setlocale(LC_NUMERIC, NULL); | |
395 setlocale(LC_NUMERIC, "C"); | |
396 v8::base::OS::SNPrintF(buffer, kBufferSize, "%f", number); | |
397 setlocale(LC_NUMERIC, prev_locale.c_str()); | |
398 return String16(buffer); | |
399 } | |
400 | |
401 // static | |
391 String16 String16::fromDoublePrecision3(double number) { | 402 String16 String16::fromDoublePrecision3(double number) { |
392 const size_t kBufferSize = 100; | 403 const size_t kBufferSize = 100; |
393 char buffer[kBufferSize]; | 404 char buffer[kBufferSize]; |
394 v8::base::OS::SNPrintF(buffer, kBufferSize, "%.3g", number); | 405 v8::base::OS::SNPrintF(buffer, kBufferSize, "%.3g", number); |
395 return String16(buffer); | 406 return String16(buffer); |
396 } | 407 } |
397 | 408 |
398 // static | 409 // static |
399 String16 String16::fromDoublePrecision6(double number) { | 410 String16 String16::fromDoublePrecision6(double number) { |
400 const size_t kBufferSize = 100; | 411 const size_t kBufferSize = 100; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 // There should be room left, since one UChar hasn't been | 525 // There should be room left, since one UChar hasn't been |
515 // converted. | 526 // converted. |
516 DCHECK((buffer + 3) <= (buffer + bufferVector.size())); | 527 DCHECK((buffer + 3) <= (buffer + bufferVector.size())); |
517 putUTF8Triple(buffer, *characters); | 528 putUTF8Triple(buffer, *characters); |
518 } | 529 } |
519 | 530 |
520 return std::string(bufferVector.data(), buffer - bufferVector.data()); | 531 return std::string(bufferVector.data(), buffer - bufferVector.data()); |
521 } | 532 } |
522 | 533 |
523 } // namespace v8_inspector | 534 } // namespace v8_inspector |
OLD | NEW |