bump SkStrAppendScalar_MaxSize to 14 to accomodate the largest string now that
scalar->string uses %.8g. Floats have at most 8 significant digits, plus we add
more space for sign, decimal point and exponent.
add tests to check these limits.
git-svn-id: http://skia.googlecode.com/svn/trunk@872 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp
index 7f490cc..ca97e0b 100644
--- a/src/core/SkString.cpp
+++ b/src/core/SkString.cpp
@@ -139,7 +139,13 @@
SkDEBUGCODE(char* start = string;)
#ifdef SK_SCALAR_IS_FLOAT
- return string + SNPRINTF(string, SkStrAppendScalar_MaxSize, "%g", value);
+ // since floats have at most 8 significant digits, we limit our %g to that.
+ static const char gFormat[] = "%.8g";
+ // make it 1 larger for the terminating 0
+ char buffer[SkStrAppendScalar_MaxSize + 1];
+ int len = SNPRINTF(buffer, sizeof(buffer), gFormat, value);
+ memcpy(string, buffer, len);
+ return string + len;
#else
SkFixed x = SkScalarToFixed(value);