diff options
author | halcanary <halcanary@google.com> | 2016-04-22 08:19:04 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-22 08:19:04 -0700 |
commit | 3361e6248b415bb3054b5af6462666f1608e0765 (patch) | |
tree | dc4edd54d4d7c8ad273be7246a2216f0f8dafe64 /src/core | |
parent | 606cadd5aac62299ef2e277709b3684cae2bf96c (diff) |
Revert of SkStringPrintf and SkString::printf now are no longer limted by a static buffer (patchset #5 id:80001 of https://codereview.chromium.org/1403803002/ )
Reason for revert:
breaking something
Original issue's description:
> SkStringPrintf and SkString::printf now are no longer limted by a static buffer
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1403803002
>
> Committed: https://skia.googlesource.com/skia/+/606cadd5aac62299ef2e277709b3684cae2bf96c
TBR=tomhudson@google.com,reed@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1908423002
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkString.cpp | 61 |
1 files changed, 9 insertions, 52 deletions
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp index 9331665dcb..24b1b8fb62 100644 --- a/src/core/SkString.cpp +++ b/src/core/SkString.cpp @@ -33,56 +33,6 @@ static const size_t kBufferSize = 1024; 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 - /////////////////////////////////////////////////////////////////////////////// bool SkStrEndsWith(const char string[], const char suffixStr[]) { @@ -563,7 +513,11 @@ void SkString::insertScalar(size_t offset, SkScalar value) { } 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 @@ void SkString::swap(SkString& other) { 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; } |