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

Side by Side Diff: src/inspector/String16.cpp

Issue 2336023002: [inspector] replaced std::snprintf with base::OS::SNPrintf (Closed)
Patch Set: Created 4 years, 3 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 | « src/inspector/DEPS ('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 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/String16.h" 5 #include "src/inspector/String16.h"
6 6
7 #include "src/base/platform/platform.h"
7 #include "src/inspector/ProtocolPlatform.h" 8 #include "src/inspector/ProtocolPlatform.h"
8 9
9 #include <algorithm> 10 #include <algorithm>
10 #include <cctype> 11 #include <cctype>
11 #include <cstdio>
12 #include <cstdlib> 12 #include <cstdlib>
13 #include <cstring> 13 #include <cstring>
14 #include <locale> 14 #include <locale>
15 #include <string> 15 #include <string>
16 16
17 namespace v8_inspector { 17 namespace v8_inspector {
18 18
19 namespace { 19 namespace {
20 20
21 bool isASCII(UChar c) { return !(c & ~0x7F); } 21 bool isASCII(UChar c) { return !(c & ~0x7F); }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 *buffer++ = static_cast<char>(((ch >> 6) & 0x3F) | 0x80); 355 *buffer++ = static_cast<char>(((ch >> 6) & 0x3F) | 0x80);
356 *buffer++ = static_cast<char>((ch & 0x3F) | 0x80); 356 *buffer++ = static_cast<char>((ch & 0x3F) | 0x80);
357 } 357 }
358 358
359 } // namespace 359 } // namespace
360 360
361 // static 361 // static
362 String16 String16::fromInteger(int number) { 362 String16 String16::fromInteger(int number) {
363 const size_t kBufferSize = 50; 363 const size_t kBufferSize = 50;
364 char buffer[kBufferSize]; 364 char buffer[kBufferSize];
365 std::snprintf(buffer, kBufferSize, "%d", number); 365 v8::base::OS::SNPrintF(buffer, kBufferSize, "%d", number);
366 return String16(buffer); 366 return String16(buffer);
367 } 367 }
368 368
369 // static 369 // static
370 String16 String16::fromDouble(double number) { 370 String16 String16::fromDouble(double number) {
371 const size_t kBufferSize = 100; 371 const size_t kBufferSize = 100;
372 char buffer[kBufferSize]; 372 char buffer[kBufferSize];
373 std::snprintf(buffer, kBufferSize, "%f", number); 373 v8::base::OS::SNPrintF(buffer, kBufferSize, "%f", number);
374 return String16(buffer); 374 return String16(buffer);
375 } 375 }
376 376
377 // static 377 // static
378 String16 String16::fromDoublePrecision3(double number) { 378 String16 String16::fromDoublePrecision3(double number) {
379 const size_t kBufferSize = 100; 379 const size_t kBufferSize = 100;
380 char buffer[kBufferSize]; 380 char buffer[kBufferSize];
381 std::snprintf(buffer, kBufferSize, "%.3g", number); 381 v8::base::OS::SNPrintF(buffer, kBufferSize, "%.3g", number);
382 return String16(buffer); 382 return String16(buffer);
383 } 383 }
384 384
385 // static 385 // static
386 String16 String16::fromDoublePrecision6(double number) { 386 String16 String16::fromDoublePrecision6(double number) {
387 const size_t kBufferSize = 100; 387 const size_t kBufferSize = 100;
388 char buffer[kBufferSize]; 388 char buffer[kBufferSize];
389 std::snprintf(buffer, kBufferSize, "%.6g", number); 389 v8::base::OS::SNPrintF(buffer, kBufferSize, "%.6g", number);
390 return String16(buffer); 390 return String16(buffer);
391 } 391 }
392 392
393 int String16::toInteger(bool* ok) const { 393 int String16::toInteger(bool* ok) const {
394 return charactersToInteger(characters16(), length(), ok); 394 return charactersToInteger(characters16(), length(), ok);
395 } 395 }
396 396
397 String16 String16::stripWhiteSpace() const { 397 String16 String16::stripWhiteSpace() const {
398 if (!length()) return String16(); 398 if (!length()) return String16();
399 399
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // There should be room left, since one UChar hasn't been 501 // There should be room left, since one UChar hasn't been
502 // converted. 502 // converted.
503 DCHECK((buffer + 3) <= (buffer + bufferVector.size())); 503 DCHECK((buffer + 3) <= (buffer + bufferVector.size()));
504 putUTF8Triple(buffer, *characters); 504 putUTF8Triple(buffer, *characters);
505 } 505 }
506 506
507 return std::string(bufferVector.data(), buffer - bufferVector.data()); 507 return std::string(bufferVector.data(), buffer - bufferVector.data());
508 } 508 }
509 509
510 } // namespace v8_inspector 510 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698