diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-03-15 12:22:48 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-15 16:48:44 +0000 |
commit | 42059a389449665cdd4056648f9551103bb9c72e (patch) | |
tree | 5b0fc3d3df02b3e6b380783911727c48e277a2ae /xfa/fxfa/parser/xfa_utils.cpp | |
parent | 2b63ae28236f71e4df9c26b66cfca2905ceec512 (diff) | |
download | pdfium-42059a389449665cdd4056648f9551103bb9c72e.tar.xz |
Cleanup nits from prior CLs
Change-Id: Ie69dfc32e7b526eca2ac6ae621eed879ad98476e
Reviewed-on: https://pdfium-review.googlesource.com/3054
Commit-Queue: dsinclair <dsinclair@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/xfa_utils.cpp')
-rw-r--r-- | xfa/fxfa/parser/xfa_utils.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index 101a6cf90e..5216d0cdd5 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -71,21 +71,19 @@ double WideStringToDouble(const CFX_WideString& wsStringVal) { if (cc < len && str[cc] == '.') { cc++; while (cc < len) { - fraction += fraction_scales[scale] * (str[cc] - '0'); + fraction += XFA_GetFractionalScale(scale) * (str[cc] - '0'); scale++; cc++; - if (cc == len) { + if (cc == len) break; - } - if (scale == sizeof(fraction_scales) / sizeof(double) || str[cc] == 'E' || + if (scale == XFA_GetMaxFractionalScale() || str[cc] == 'E' || str[cc] == 'e') { break; } - if (!FXSYS_isDecimalDigit(str[cc])) { + if (!FXSYS_isDecimalDigit(str[cc])) return 0; - } } - dwFractional = (uint32_t)(fraction * 4294967296.0); + dwFractional = static_cast<uint32_t>(fraction * 4294967296.0); } if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { cc++; @@ -98,24 +96,33 @@ double WideStringToDouble(const CFX_WideString& wsStringVal) { } } while (cc < len) { - if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc])) { + if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc])) return 0; - } + nExponent = nExponent * 10 + str[cc] - '0'; cc++; } nExponent = bExpSign ? -nExponent : nExponent; } - double dValue = (dwFractional / 4294967296.0); + + double dValue = dwFractional / 4294967296.0; dValue = nIntegral + (nIntegral >= 0 ? dValue : -dValue); - if (nExponent != 0) { - dValue *= FXSYS_pow(10, (float)nExponent); - } + if (nExponent != 0) + dValue *= FXSYS_pow(10, static_cast<float>(nExponent)); + return dValue; } } // namespace +double XFA_GetFractionalScale(uint32_t idx) { + return fraction_scales[idx]; +} + +int XFA_GetMaxFractionalScale() { + return FX_ArraySize(fraction_scales); +} + CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) { CXFA_Node* pNodeValue = pWidgetData->GetNode()->GetChild(0, XFA_Element::Value); |