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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 const size_t kBufferSize = 50; | 368 const size_t kBufferSize = 50; |
369 char buffer[kBufferSize]; | 369 char buffer[kBufferSize]; |
370 v8::base::OS::SNPrintF(buffer, kBufferSize, "%d", number); | 370 v8::base::OS::SNPrintF(buffer, kBufferSize, "%d", number); |
371 return String16(buffer); | 371 return String16(buffer); |
372 } | 372 } |
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 std::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) { |
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 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 // There should be room left, since one UChar hasn't been | 514 // There should be room left, since one UChar hasn't been |
515 // converted. | 515 // converted. |
516 DCHECK((buffer + 3) <= (buffer + bufferVector.size())); | 516 DCHECK((buffer + 3) <= (buffer + bufferVector.size())); |
517 putUTF8Triple(buffer, *characters); | 517 putUTF8Triple(buffer, *characters); |
518 } | 518 } |
519 | 519 |
520 return std::string(bufferVector.data(), buffer - bufferVector.data()); | 520 return std::string(bufferVector.data(), buffer - bufferVector.data()); |
521 } | 521 } |
522 | 522 |
523 } // namespace v8_inspector | 523 } // namespace v8_inspector |
OLD | NEW |