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

Unified Diff: src/core/SkString.cpp

Issue 1908423002: Revert of SkStringPrintf and SkString::printf now are no longer limted by a static buffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/pdf/SkPDFMetadata.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkString.cpp
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp
index 9331665dcbcd4656f1a7e29d907926bc3883de54..24b1b8fb6229f01d251529348c17956a29ccf1e7 100644
--- a/src/core/SkString.cpp
+++ b/src/core/SkString.cpp
@@ -32,56 +32,6 @@
SkASSERT(written >= 0 && written < SkToInt(size)); \
va_end(args); \
} while (0)
-
-#ifdef SK_BUILD_FOR_WIN
-#define V_SKSTRING_PRINTF(output, format) \
- do { \
- va_list args; \
- va_start(args, format); \
- char buffer[kBufferSize]; \
- int length = _vsnprintf_s(buffer, sizeof(buffer), \
- _TRUNCATE, format, args); \
- va_end(args); \
- if (length >= 0 && length < (int)sizeof(buffer)) { \
- output.set(buffer, length); \
- break; \
- } \
- va_start(args, format); \
- length = _vscprintf(format, args); \
- va_end(args); \
- output.resize((size_t)length); \
- va_start(args, format); \
- SkDEBUGCODE(int check = ) _vsnprintf_s(output.writable_str(), \
- length + 1, _TRUNCATE, \
- format, args); \
- va_end(args); \
- SkASSERT(check == length); \
- SkASSERT(output[length] == '\0'); \
- } while (false)
-#else
-#define V_SKSTRING_PRINTF(output, format) \
- do { \
- va_list args; \
- va_start(args, format); \
- char buffer[kBufferSize]; \
- int length = vsnprintf(buffer, sizeof(buffer), format, args); \
- va_end(args); \
- if (length < 0) { \
- break; \
- } \
- if (length < (int)sizeof(buffer)) { \
- output.set(buffer, length); \
- break; \
- } \
- output.resize((size_t)length); \
- va_start(args, format); \
- SkDEBUGCODE(int check = ) vsnprintf(output.writable_str(), \
- length + 1, format, args); \
- va_end(args); \
- SkASSERT(check == length); \
- SkASSERT(output[length] == '\0'); \
- } while (false)
-#endif
///////////////////////////////////////////////////////////////////////////////
@@ -563,7 +513,11 @@
}
void SkString::printf(const char format[], ...) {
- V_SKSTRING_PRINTF((*this), format);
+ char buffer[kBufferSize];
+ int length;
+ ARGS_TO_BUFFER(format, buffer, kBufferSize, length);
+
+ this->set(buffer, length);
}
void SkString::appendf(const char format[], ...) {
@@ -639,7 +593,10 @@
SkString SkStringPrintf(const char* format, ...) {
SkString formattedOutput;
- V_SKSTRING_PRINTF(formattedOutput, format);
+ char buffer[kBufferSize];
+ SK_UNUSED int length;
+ ARGS_TO_BUFFER(format, buffer, kBufferSize, length);
+ formattedOutput.set(buffer);
return formattedOutput;
}
« no previous file with comments | « no previous file | src/pdf/SkPDFMetadata.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698