Use scoping to avoid needing val2 in CFXJSE_FormCalcContext::Parse().
Also make the two blocks more consistent with each other.
Change-Id: I74b53b10bc5ebddea8d8d6c3c1be567bbf65b4d8
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/51791
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 4c512be..d3fe086 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -3948,23 +3948,27 @@
return;
}
default: {
- WideString wsTestPattern = L"num{" + wsPattern + L"}";
- CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsTestPattern,
- pLocale, pMgr);
- if (localeValue.IsValid()) {
- args.GetReturnValue()->SetDouble(localeValue.GetDoubleNum());
- return;
+ {
+ WideString wsTestPattern = L"num{" + wsPattern + L"}";
+ CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsTestPattern,
+ pLocale, pMgr);
+ if (localeValue.IsValid()) {
+ args.GetReturnValue()->SetDouble(localeValue.GetDoubleNum());
+ return;
+ }
}
- wsTestPattern = L"text{" + wsPattern + L"}";
- CXFA_LocaleValue localeValue2(XFA_VT_TEXT, wsValue, wsTestPattern,
- pLocale, pMgr);
- if (!localeValue2.IsValid()) {
- args.GetReturnValue()->SetString("");
- return;
+ {
+ WideString wsTestPattern = L"text{" + wsPattern + L"}";
+ CXFA_LocaleValue localeValue(XFA_VT_TEXT, wsValue, wsTestPattern,
+ pLocale, pMgr);
+ if (localeValue.IsValid()) {
+ args.GetReturnValue()->SetString(
+ localeValue.GetValue().ToUTF8().AsStringView());
+ return;
+ }
}
- args.GetReturnValue()->SetString(
- localeValue2.GetValue().ToUTF8().AsStringView());
+ args.GetReturnValue()->SetString("");
return;
}
}