summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/Field.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-14 17:25:08 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-14 17:25:08 -0800
commit4cd5b80e70e5fc50d8bd805cfa3c7b54878a0a35 (patch)
treecb9465e37aa1495d01adbed07d351ab36930e8e2 /fpdfsdk/src/javascript/Field.cpp
parent5b2bc895384749493f2ec2ca818c485797448cae (diff)
downloadpdfium-4cd5b80e70e5fc50d8bd805cfa3c7b54878a0a35.tar.xz
Cleanup CJS_PublicMethods::ParseNumber
Original patch by tombergan. The old version of this function was basically strtod with a few quirks: 1. It always interpreted ',' as '.' independent of locale. I kept this behavior, to be conservative. 2. It interpreted the first non-number character as a decimal point, unless there was a prior decimal point, in which case all characters up to that point are ignored. This would parse "123z4" as "123.4" and "123xy6" as "6". I did not keep this behavior -- in the new code, these examples all fail to parse. The new ParseNumber was inlined into ConvertStringToNumber, which returns true on success and (false, 0) on failure. BUG=pdfium:361 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1582013002 .
Diffstat (limited to 'fpdfsdk/src/javascript/Field.cpp')
-rw-r--r--fpdfsdk/src/javascript/Field.cpp22
1 files changed, 5 insertions, 17 deletions
diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp
index 959e8dcadd..ebd3d331f5 100644
--- a/fpdfsdk/src/javascript/Field.cpp
+++ b/fpdfsdk/src/javascript/Field.cpp
@@ -2741,13 +2741,8 @@ FX_BOOL Field::value(IJS_Context* cc,
CFX_WideString swValue = pFormField->GetValue();
double dRet;
- FX_BOOL bDot;
- if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet,
- bDot)) {
- if (bDot)
- vp << dRet;
- else
- vp << dRet;
+ if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet)) {
+ vp << dRet;
} else {
vp << swValue;
}
@@ -2769,13 +2764,8 @@ FX_BOOL Field::value(IJS_Context* cc,
CFX_WideString swValue = pFormField->GetValue();
double dRet;
- FX_BOOL bDot;
- if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet,
- bDot)) {
- if (bDot)
- vp << dRet;
- else
- vp << dRet;
+ if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet)) {
+ vp << dRet;
} else {
vp << swValue;
}
@@ -2790,9 +2780,7 @@ FX_BOOL Field::value(IJS_Context* cc,
CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue();
double dRet;
- FX_BOOL bDotDummy;
- if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet,
- bDotDummy)) {
+ if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet)) {
vp << dRet;
} else {
vp << swValue;