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

Side by Side Diff: sky/engine/wtf/text/WTFString.cpp

Issue 719063002: Revert "Remove support for MSVC" (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007-2009 Torch Mobile, Inc. 4 * Copyright (C) 2007-2009 Torch Mobile, Inc.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 462 }
463 463
464 String String::format(const char *format, ...) 464 String String::format(const char *format, ...)
465 { 465 {
466 va_list args; 466 va_list args;
467 va_start(args, format); 467 va_start(args, format);
468 468
469 Vector<char, 256> buffer; 469 Vector<char, 256> buffer;
470 470
471 // Do the format once to get the length. 471 // Do the format once to get the length.
472 #if COMPILER(MSVC)
473 int result = _vscprintf(format, args);
474 #else
472 char ch; 475 char ch;
473 int result = vsnprintf(&ch, 1, format, args); 476 int result = vsnprintf(&ch, 1, format, args);
474 // We need to call va_end() and then va_start() again here, as the 477 // We need to call va_end() and then va_start() again here, as the
475 // contents of args is undefined after the call to vsnprintf 478 // contents of args is undefined after the call to vsnprintf
476 // according to http://man.cx/snprintf(3) 479 // according to http://man.cx/snprintf(3)
477 // 480 //
478 // Not calling va_end/va_start here happens to work on lots of 481 // Not calling va_end/va_start here happens to work on lots of
479 // systems, but fails e.g. on 64bit Linux. 482 // systems, but fails e.g. on 64bit Linux.
480 va_end(args); 483 va_end(args);
481 va_start(args, format); 484 va_start(args, format);
485 #endif
482 486
483 if (result == 0) 487 if (result == 0)
484 return String(""); 488 return String("");
485 if (result < 0) 489 if (result < 0)
486 return String(); 490 return String();
487 unsigned len = result; 491 unsigned len = result;
488 buffer.grow(len + 1); 492 buffer.grow(len + 1);
489 493
490 // Now do the formatting again, guaranteed to fit. 494 // Now do the formatting again, guaranteed to fit.
491 vsnprintf(buffer.data(), buffer.size(), format, args); 495 vsnprintf(buffer.data(), buffer.size(), format, args);
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 else 1008 else
1005 digitValue = c - 'A' + 10; 1009 digitValue = c - 'A' + 10;
1006 1010
1007 if (value > maxMultiplier || (value == maxMultiplier && digitValue > (in tegralMax % base) + isNegative)) 1011 if (value > maxMultiplier || (value == maxMultiplier && digitValue > (in tegralMax % base) + isNegative))
1008 goto bye; 1012 goto bye;
1009 1013
1010 value = base * value + digitValue; 1014 value = base * value + digitValue;
1011 ++data; 1015 ++data;
1012 } 1016 }
1013 1017
1018 #if COMPILER(MSVC)
1019 #pragma warning(push, 0)
1020 #pragma warning(disable:4146)
1021 #endif
1022
1014 if (isNegative) 1023 if (isNegative)
1015 value = -value; 1024 value = -value;
1016 1025
1026 #if COMPILER(MSVC)
1027 #pragma warning(pop)
1028 #endif
1029
1017 // skip trailing space 1030 // skip trailing space
1018 while (length && isSpaceOrNewline(*data)) { 1031 while (length && isSpaceOrNewline(*data)) {
1019 --length; 1032 --length;
1020 ++data; 1033 ++data;
1021 } 1034 }
1022 1035
1023 if (!length) 1036 if (!length)
1024 isOk = true; 1037 isOk = true;
1025 bye: 1038 bye:
1026 if (ok) 1039 if (ok)
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 buffer.append('\0'); 1271 buffer.append('\0');
1259 return buffer; 1272 return buffer;
1260 } 1273 }
1261 1274
1262 Vector<char> asciiDebug(String& string) 1275 Vector<char> asciiDebug(String& string)
1263 { 1276 {
1264 return asciiDebug(string.impl()); 1277 return asciiDebug(string.impl());
1265 } 1278 }
1266 1279
1267 #endif 1280 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698