summaryrefslogtreecommitdiff
path: root/xfa/fgas/crt/cfgas_formatstring.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-06-07 09:36:31 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-06-07 13:48:30 +0000
commit52998a4ce205708f6e00a007f3d1e57b24eb1c8b (patch)
treeedb693bd9ea5c08fd9379345f476a85b797ac6d1 /xfa/fgas/crt/cfgas_formatstring.cpp
parentd9d6c29879780db829694d0023a377581bbc9769 (diff)
downloadpdfium-52998a4ce205708f6e00a007f3d1e57b24eb1c8b.tar.xz
Even more CFGAS_FormatString tests.
Change-Id: Ied2a169a3e7e9b178d746b04c67286d7a51fa635 Reviewed-on: https://pdfium-review.googlesource.com/6330 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'xfa/fgas/crt/cfgas_formatstring.cpp')
-rw-r--r--xfa/fgas/crt/cfgas_formatstring.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp
index 5c15135d9a..6e2952a7cc 100644
--- a/xfa/fgas/crt/cfgas_formatstring.cpp
+++ b/xfa/fgas/crt/cfgas_formatstring.cpp
@@ -1040,21 +1040,11 @@ bool FX_TimeFromCanonical(const CFX_WideStringC& wsTime,
}
}
+ // Skip until we find a + or - for the time zone.
while (cc < len) {
- // Skip until we find a + or - for the time zone.
- if (str[cc] != '+' && str[cc] != '-') {
- ++cc;
- continue;
- }
-
- FX_TIMEZONE tzDiff;
- tzDiff.tzHour = 0;
- tzDiff.tzMinute = 0;
- if (str[cc] != 'Z')
- cc += ParseTimeZone(str + cc, len - cc, &tzDiff);
-
- ResolveZone(tzDiff, pLocale, &hour, &minute);
- break;
+ if (str[cc] == '+' || str[cc] == '-')
+ break;
+ ++cc;
}
if (cc < len) {
@@ -1183,9 +1173,9 @@ CFX_WideString CFGAS_FormatString::GetTextFormat(
while (ccf < iLenf) {
if (pStr[ccf] == '(') {
ccf++;
- CFX_WideString wsLCID;
+ // Skip over the encoding name.
while (ccf < iLenf && pStr[ccf] != ')')
- wsLCID += pStr[ccf++];
+ ccf++;
} else if (pStr[ccf] == '{') {
bBrackOpen = true;
break;
@@ -1410,11 +1400,22 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
bool bNeg = false;
bool bReverseParse = false;
int32_t dot_index = 0;
+
+ // If we're looking for a '.', 'V' or 'v' and the input string does not
+ // have a dot index for one of those, then we disable parsing the decimal.
if (!GetNumericDotIndex(wsSrcNum, wsDotSymbol, &dot_index) &&
(dwFormatStyle & FX_NUMSTYLE_DotVorv)) {
bReverseParse = true;
}
- bReverseParse = false;
+
+ // This parse is broken into two parts based on the '.' in the number
+ // (or 'V' or 'v'). |dot_index_f| is the location of the dot in the format and
+ // |dot_index| is the location of the dot in the number.
+ //
+ // This first while() starts at the '.' and walks backwards to the start of
+ // the number. The second while() walks from the dot forwards to the end of
+ // the decimal.
+
int ccf = dot_index_f - 1;
int cc = dot_index - 1;
while (ccf >= 0 && cc >= 0) {
@@ -1483,9 +1484,6 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
ccf--;
break;
case 'E': {
- if (cc >= dot_index)
- return false;
-
bool bExpSign = false;
while (cc >= 0) {
if (str[cc] == 'E' || str[cc] == 'e')
@@ -1539,7 +1537,7 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
case 'R':
if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') {
if (str[cc] == ' ') {
- cc++;
+ cc -= 2;
} else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') {
bNeg = true;
cc -= 2;
@@ -1563,7 +1561,7 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
case 'B':
if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') {
if (str[cc] == ' ') {
- cc++;
+ cc -= 2;
} else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') {
bNeg = true;
cc -= 2;