Make SkFloatToDecimal() param name match declaration.
In SkFloatToDecimal.cpp, the |output| parameter for SkFloatToDecimal()
is named |result|. Change it to |output| and change the local variable
|output| to |output_ptr|. Fix some typos along the way.
Change-Id: Id34848f4823e69fcbd5203618ea90083fc157b6c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225014
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
diff --git a/src/utils/SkFloatToDecimal.cpp b/src/utils/SkFloatToDecimal.cpp
index ead72de..4bfcdad 100644
--- a/src/utils/SkFloatToDecimal.cpp
+++ b/src/utils/SkFloatToDecimal.cpp
@@ -58,16 +58,16 @@
}
}
-/** Write a string into result, includeing a terminating '\0' (for
- unit testing). Return strlen(result) (for SkWStream::write) The
+/** Write a string into output, including a terminating '\0' (for
+ unit testing). Return strlen(output) (for SkWStream::write) The
resulting string will be in the form /[-]?([0-9]*.)?[0-9]+/ and
- sscanf(result, "%f", &x) will return the original value iff the
+ sscanf(output, "%f", &x) will return the original value iff the
value is finite. This function accepts all possible input values.
Motivation: "PDF does not support [numbers] in exponential format
(such as 6.02e23)." Otherwise, this function would rely on a
sprintf-type function from the standard library. */
-unsigned SkFloatToDecimal(float value, char result[kMaximumSkFloatToDecimalLength]) {
+unsigned SkFloatToDecimal(float value, char output[kMaximumSkFloatToDecimalLength]) {
/* The longest result is -FLT_MIN.
We serialize it as "-.0000000000000000000000000000000000000117549435"
which has 48 characters plus a terminating '\0'. */
@@ -87,13 +87,13 @@
Experimentally, rasterizers such as pdfium do seem to benefit
from this. Rasterizers that rely on fixed-point scalars should
gracefully ignore these values that they can not parse. */
- char* output = &result[0];
- const char* const end = &result[kMaximumSkFloatToDecimalLength - 1];
+ char* output_ptr = &output[0];
+ const char* const end = &output[kMaximumSkFloatToDecimalLength - 1];
// subtract one to leave space for '\0'.
/* This function is written to accept any possible input value,
including non-finite values such as INF and NAN. In that case,
- we ignore value-correctness and and output a syntacticly-valid
+ we ignore value-correctness and output a syntacticly-valid
number. */
if (value == INFINITY) {
value = FLT_MAX; // nearest finite float.
@@ -104,12 +104,12 @@
if (!std::isfinite(value) || value == 0.0f) {
// NAN is unsupported in PDF. Always output a valid number.
// Also catch zero here, as a special case.
- *output++ = '0';
- *output = '\0';
- return static_cast<unsigned>(output - result);
+ *output_ptr++ = '0';
+ *output_ptr = '\0';
+ return static_cast<unsigned>(output_ptr - output);
}
if (value < 0.0) {
- *output++ = '-';
+ *output_ptr++ = '-';
value = -value;
}
SkASSERT(value >= 0.0f);
@@ -148,37 +148,37 @@
if (decimalShift >= 0) {
do {
--bufferIndex;
- *output++ = '0' + buffer[bufferIndex];
+ *output_ptr++ = '0' + buffer[bufferIndex];
} while (bufferIndex);
for (int i = 0; i < decimalShift; ++i) {
- *output++ = '0';
+ *output_ptr++ = '0';
}
} else {
int placesBeforeDecimal = bufferIndex + decimalShift;
if (placesBeforeDecimal > 0) {
while (placesBeforeDecimal-- > 0) {
--bufferIndex;
- *output++ = '0' + buffer[bufferIndex];
+ *output_ptr++ = '0' + buffer[bufferIndex];
}
- *output++ = '.';
+ *output_ptr++ = '.';
} else {
- *output++ = '.';
+ *output_ptr++ = '.';
int placesAfterDecimal = -placesBeforeDecimal;
while (placesAfterDecimal-- > 0) {
- *output++ = '0';
+ *output_ptr++ = '0';
}
}
while (bufferIndex > 0) {
--bufferIndex;
- *output++ = '0' + buffer[bufferIndex];
- if (output == end) {
+ *output_ptr++ = '0' + buffer[bufferIndex];
+ if (output_ptr == end) {
break; // denormalized: don't need extra precision.
// Note: denormalized numbers will not have the same number of
// significantDigits, but do not need them to round-trip.
}
}
}
- SkASSERT(output <= end);
- *output = '\0';
- return static_cast<unsigned>(output - result);
+ SkASSERT(output_ptr <= end);
+ *output_ptr = '\0';
+ return static_cast<unsigned>(output_ptr - output);
}