Use some FXSYS methods instead of duplicating
This CL uses the FXSYS_isDecimalDigit in place of a few custom IsDigit methods.
It also creates an iswspace and some fractional math helper methods to share
some code.
Review-Url: https://codereview.chromium.org/2094453004
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index b9cf470..12d3aef 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -47,6 +47,18 @@
}
}
+static const FX_FLOAT fraction_scales[] = {
+ 0.1f, 0.01f, 0.001f, 0.0001f,
+ 0.00001f, 0.000001f, 0.0000001f, 0.00000001f,
+ 0.000000001f, 0.0000000001f, 0.00000000001f};
+int FXSYS_FractionalScaleCount() {
+ return FX_ArraySize(fraction_scales);
+}
+
+FX_FLOAT FXSYS_FractionalScale(size_t scale_factor, int value) {
+ return fraction_scales[scale_factor] * value;
+}
+
FX_FLOAT FX_atof(const CFX_ByteStringC& strc) {
if (strc.IsEmpty())
return 0.0;
@@ -74,17 +86,14 @@
value = value * 10 + FXSYS_toDecimalDigit(strc.CharAt(cc));
cc++;
}
- static const FX_FLOAT fraction_scales[] = {
- 0.1f, 0.01f, 0.001f, 0.0001f,
- 0.00001f, 0.000001f, 0.0000001f, 0.00000001f,
- 0.000000001f, 0.0000000001f, 0.00000000001f};
int scale = 0;
if (cc < len && strc[cc] == '.') {
cc++;
while (cc < len) {
- value += fraction_scales[scale] * FXSYS_toDecimalDigit(strc.CharAt(cc));
+ value +=
+ FXSYS_FractionalScale(scale, FXSYS_toDecimalDigit(strc.CharAt(cc)));
scale++;
- if (scale == FX_ArraySize(fraction_scales))
+ if (scale == FXSYS_FractionalScaleCount())
break;
cc++;
}
diff --git a/core/fxcrt/include/fx_ext.h b/core/fxcrt/include/fx_ext.h
index d37db67..f7aca68 100644
--- a/core/fxcrt/include/fx_ext.h
+++ b/core/fxcrt/include/fx_ext.h
@@ -53,6 +53,9 @@
inline bool FXSYS_iswalnum(wchar_t wch) {
return FXSYS_iswalpha(wch) || FXSYS_iswdigit(wch);
}
+inline bool FXSYS_iswspace(FX_WCHAR c) {
+ return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09);
+}
inline int FXSYS_toHexDigit(const FX_CHAR c) {
if (!std::isxdigit(c))
@@ -77,6 +80,9 @@
return std::iswdigit(c) ? c - L'0' : 0;
}
+FX_FLOAT FXSYS_FractionalScale(size_t scale_factor, int value);
+int FXSYS_FractionalScaleCount();
+
uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase);
uint32_t FX_HashCode_GetW(const CFX_WideStringC& Str, bool bIgnoreCase);
diff --git a/xfa/fgas/localization/fgas_locale.cpp b/xfa/fgas/localization/fgas_locale.cpp
index d61f6b5..2a77bbe 100644
--- a/xfa/fgas/localization/fgas_locale.cpp
+++ b/xfa/fgas/localization/fgas_locale.cpp
@@ -86,22 +86,6 @@
return iStart;
}
-static FX_BOOL FX_IsDigit(FX_WCHAR c) {
- return c >= '0' && c <= '9';
-}
-static FX_BOOL FX_IsAlpha(FX_WCHAR c) {
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
-}
-static FX_BOOL FX_IsSpace(FX_WCHAR c) {
- return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09);
-}
-static const FX_FLOAT gs_fraction_scales[] = {
- 0.1f, 0.01f, 0.001f, 0.0001f,
- 0.00001f, 0.000001f, 0.0000001f, 0.00000001f,
- 0.000000001f, 0.0000000001f, 0.00000000001f};
-static const int32_t gs_fraction_count =
- sizeof(gs_fraction_scales) / sizeof(FX_FLOAT);
-
class CFX_LCNumeric {
public:
CFX_LCNumeric();
@@ -137,7 +121,7 @@
bool bExpSign = false;
const FX_WCHAR* str = wsValue.c_str();
int32_t len = wsValue.GetLength();
- while (cc < len && FX_IsSpace(str[cc]))
+ while (cc < len && FXSYS_iswspace(str[cc]))
cc++;
if (cc >= len)
@@ -154,11 +138,10 @@
if (str[cc] == '.')
break;
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
if ((str[cc] == 'E' || str[cc] == 'e'))
break;
- else
- return FALSE;
+ return FALSE;
}
if (nIntegralLen < nIntegralMaxLen) {
lcnum.m_Integral = lcnum.m_Integral * 10 + str[cc] - '0';
@@ -173,20 +156,19 @@
double fraction = 0.0;
cc++;
while (cc < len) {
- if (scale >= gs_fraction_count) {
+ if (scale >= FXSYS_FractionalScaleCount()) {
while (cc < len) {
- if (!FX_IsDigit(str[cc]))
+ if (!FXSYS_isDecimalDigit(str[cc]))
break;
cc++;
}
}
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
if ((str[cc] == 'E' || str[cc] == 'e'))
break;
- else
- return FALSE;
+ return FALSE;
}
- fraction += gs_fraction_scales[scale] * (str[cc] - '0');
+ fraction += FXSYS_FractionalScale(scale, FXSYS_toDecimalDigit(str[cc]));
scale++;
cc++;
}
@@ -203,7 +185,7 @@
}
}
while (cc < len) {
- if (FX_IsDigit(str[cc]))
+ if (FXSYS_isDecimalDigit(str[cc]))
return FALSE;
lcnum.m_Exponent = lcnum.m_Exponent * 10 + str[cc] - '0';
cc++;
@@ -291,7 +273,8 @@
CFX_WideString sub(pToken, pStr - pToken);
wsPatterns.Add(sub);
return;
- } else if (*pStr == '\'') {
+ }
+ if (*pStr == '\'') {
iQuote = !iQuote;
} else if (*pStr == L'|' && !iQuote) {
CFX_WideString sub(pToken, pStr - pToken);
@@ -358,9 +341,8 @@
if (iPattern - 1 >= 0 ||
((pStrPattern[iPattern - 1] != '\'') && (iQuote % 2 == 0))) {
break;
- } else {
- iQuote++;
}
+ iQuote++;
iPattern--;
} else if (pStrPattern[iPattern] == '\\' &&
pStrPattern[iPattern + 1] == 'u') {
@@ -690,7 +672,7 @@
break;
}
case 'A':
- if (FX_IsAlpha(pStrText[iText])) {
+ if (FXSYS_iswalpha(pStrText[iText])) {
wsValue += pStrText[iText];
iText++;
}
@@ -703,14 +685,15 @@
break;
case 'O':
case '0':
- if (FX_IsDigit(pStrText[iText]) || FX_IsAlpha(pStrText[iText])) {
+ if (FXSYS_isDecimalDigit(pStrText[iText]) ||
+ FXSYS_iswalpha(pStrText[iText])) {
wsValue += pStrText[iText];
iText++;
}
iPattern++;
break;
case '9':
- if (FX_IsDigit(pStrText[iText])) {
+ if (FXSYS_isDecimalDigit(pStrText[iText])) {
wsValue += pStrText[iText];
iText++;
}
@@ -786,7 +769,7 @@
break;
}
case '9':
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1;
@@ -845,7 +828,7 @@
if (str[cc] == 'E' || str[cc] == 'e') {
break;
}
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
iExponent = iExponent + (str[cc] - '0') * 10;
cc--;
continue;
@@ -946,7 +929,7 @@
while (ccf < lenf && strf[ccf] == '8') {
ccf++;
}
- while (cc < len && FX_IsDigit(str[cc])) {
+ while (cc < len && FXSYS_isDecimalDigit(str[cc])) {
dbRetValue = (str[cc] - '0') * coeff + dbRetValue;
coeff *= 0.1;
cc++;
@@ -1010,7 +993,7 @@
break;
}
case '9':
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
dbRetValue = dbRetValue + (str[cc] - '0') * coeff;
@@ -1019,7 +1002,7 @@
ccf--;
break;
case 'z':
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
dbRetValue = dbRetValue + (str[cc] - '0') * coeff;
coeff *= 10;
cc--;
@@ -1028,7 +1011,7 @@
break;
case 'Z':
if (str[cc] != ' ') {
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
dbRetValue = dbRetValue + (str[cc] - '0') * coeff;
coeff *= 10;
cc--;
@@ -1073,7 +1056,7 @@
if (str[cc] == 'E' || str[cc] == 'e') {
break;
}
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
iExponent = iExponent + (str[cc] - '0') * 10;
cc--;
continue;
@@ -1229,7 +1212,7 @@
break;
}
case '9':
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
{
@@ -1240,7 +1223,7 @@
ccf++;
break;
case 'z':
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
dbRetValue = dbRetValue + (str[cc] - '0') * coeff;
coeff *= 0.1;
cc++;
@@ -1249,7 +1232,7 @@
break;
case 'Z':
if (str[cc] != ' ') {
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
dbRetValue = dbRetValue + (str[cc] - '0') * coeff;
coeff *= 0.1;
cc++;
@@ -1300,7 +1283,7 @@
}
}
while (cc < len) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
break;
}
iExponent = iExponent * 10 + str[cc] - '0';
@@ -1380,7 +1363,7 @@
while (ccf < lenf && strf[ccf] == '8') {
ccf++;
}
- while (cc < len && FX_IsDigit(str[cc])) {
+ while (cc < len && FXSYS_isDecimalDigit(str[cc])) {
dbRetValue = (str[cc] - '0') * coeff + dbRetValue;
coeff *= 0.1;
cc++;
@@ -1490,7 +1473,7 @@
break;
}
case '9':
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
wsValue = str[cc] + wsValue;
@@ -1498,7 +1481,7 @@
ccf--;
break;
case 'z':
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
wsValue = str[cc] + wsValue;
cc--;
}
@@ -1506,7 +1489,7 @@
break;
case 'Z':
if (str[cc] != ' ') {
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
wsValue = str[cc] + wsValue;
cc--;
}
@@ -1550,7 +1533,7 @@
if (str[cc] == 'E' || str[cc] == 'e') {
break;
}
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
iExponent = iExponent + (str[cc] - '0') * 10;
cc--;
continue;
@@ -1714,7 +1697,7 @@
break;
}
case '9':
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
{ wsValue += str[cc]; }
@@ -1722,7 +1705,7 @@
ccf++;
break;
case 'z':
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
wsValue += str[cc];
cc++;
}
@@ -1730,7 +1713,7 @@
break;
case 'Z':
if (str[cc] != ' ') {
- if (FX_IsDigit(str[cc])) {
+ if (FXSYS_isDecimalDigit(str[cc])) {
wsValue += str[cc];
cc++;
}
@@ -1780,7 +1763,7 @@
}
}
while (cc < len) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
break;
}
iExponent = iExponent * 10 + str[cc] - '0';
@@ -1860,7 +1843,7 @@
while (ccf < lenf && strf[ccf] == '8') {
ccf++;
}
- while (cc < len && FX_IsDigit(str[cc])) {
+ while (cc < len && FXSYS_isDecimalDigit(str[cc])) {
wsValue += str[cc];
cc++;
}
@@ -2095,15 +2078,15 @@
}
uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0');
if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
day = str[cc++] - '0';
- if (cc < len && FX_IsDigit(str[cc])) {
+ if (cc < len && FXSYS_isDecimalDigit(str[cc])) {
day = day * 10 + str[cc++] - '0';
}
} else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
day = str[cc++] - '0';
@@ -2112,22 +2095,22 @@
}
} else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '1')) {
int i = 0;
- while (cc < len && i < 3 && FX_IsDigit(str[cc])) {
+ while (cc < len && i < 3 && FXSYS_isDecimalDigit(str[cc])) {
cc++;
i++;
}
} else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '3')) {
cc += 3;
} else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
month = str[cc++] - '0';
- if (cc < len && FX_IsDigit(str[cc])) {
+ if (cc < len && FXSYS_isDecimalDigit(str[cc])) {
month = month * 10 + str[cc++] - '0';
}
} else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
month = str[cc++] - '0';
@@ -2210,11 +2193,11 @@
if (cc + 2 > len) {
return FALSE;
}
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
year = str[cc++] - '0';
- if (cc >= len || !FX_IsDigit(str[cc])) {
+ if (cc >= len || !FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
year = year * 10 + str[cc++] - '0';
@@ -2230,7 +2213,7 @@
return FALSE;
}
while (i < 4) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
year = year * 10 + str[cc] - '0';
@@ -2317,11 +2300,11 @@
dwSymbol == FXBSTR_ID(0, 0, 'H', '1') ||
dwSymbol == FXBSTR_ID(0, 0, 'h', '1') ||
dwSymbol == FXBSTR_ID(0, 0, 'K', '1')) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
hour = str[cc++] - '0';
- if (cc < len && FX_IsDigit(str[cc])) {
+ if (cc < len && FXSYS_isDecimalDigit(str[cc])) {
hour = hour * 10 + str[cc++] - '0';
}
if (dwSymbol == FXBSTR_ID(0, 0, 'K', '1') && hour == 24) {
@@ -2331,14 +2314,14 @@
dwSymbol == FXBSTR_ID(0, 0, 'H', '2') ||
dwSymbol == FXBSTR_ID(0, 0, 'h', '2') ||
dwSymbol == FXBSTR_ID(0, 0, 'K', '2')) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
hour = str[cc++] - '0';
if (cc >= len) {
return FALSE;
}
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
hour = hour * 10 + str[cc++] - '0';
@@ -2346,42 +2329,42 @@
hour = 0;
}
} else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
minute = str[cc++] - '0';
- if (cc < len && FX_IsDigit(str[cc])) {
+ if (cc < len && FXSYS_isDecimalDigit(str[cc])) {
minute = minute * 10 + str[cc++] - '0';
}
} else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
minute = str[cc++] - '0';
if (cc >= len) {
return FALSE;
}
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
minute = minute * 10 + str[cc++] - '0';
} else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '1')) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
second = str[cc++] - '0';
- if (cc < len && FX_IsDigit(str[cc])) {
+ if (cc < len && FXSYS_isDecimalDigit(str[cc])) {
second = second * 10 + str[cc++] - '0';
}
} else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '2')) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
second = str[cc++] - '0';
if (cc >= len) {
return FALSE;
}
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
second = second * 10 + str[cc++] - '0';
@@ -2391,7 +2374,7 @@
}
int i = 0;
while (i < 3) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
millisecond = millisecond * 10 + str[cc++] - '0';
@@ -2597,7 +2580,7 @@
break;
}
case 'A':
- if (iText >= iLenText || !FX_IsAlpha(pStrText[iText])) {
+ if (iText >= iLenText || !FXSYS_iswalpha(pStrText[iText])) {
return FALSE;
}
wsOutput += pStrText[iText++];
@@ -2612,15 +2595,15 @@
break;
case 'O':
case '0':
- if (iText >= iLenText ||
- (!FX_IsDigit(pStrText[iText]) && !FX_IsAlpha(pStrText[iText]))) {
+ if (iText >= iLenText || (!FXSYS_isDecimalDigit(pStrText[iText]) &&
+ !FXSYS_iswalpha(pStrText[iText]))) {
return FALSE;
}
wsOutput += pStrText[iText++];
iPattern++;
break;
case '9':
- if (iText >= iLenText || !FX_IsDigit(pStrText[iText])) {
+ if (iText >= iLenText || !FXSYS_isDecimalDigit(pStrText[iText])) {
return FALSE;
}
wsOutput += pStrText[iText++];
@@ -2747,7 +2730,7 @@
switch (strf[ccf]) {
case '9':
if (cc >= 0) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
wsOutput = str[cc] + wsOutput;
@@ -2759,7 +2742,7 @@
break;
case 'z':
if (cc >= 0) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
if (str[0] != '0') {
@@ -2771,7 +2754,7 @@
break;
case 'Z':
if (cc >= 0) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
if (str[0] == '0') {
@@ -2951,7 +2934,7 @@
break;
case '9':
if (cc < len) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
wsOutput += str[cc];
@@ -2963,7 +2946,7 @@
break;
case 'z':
if (cc < len) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
wsOutput += str[cc];
@@ -2973,7 +2956,7 @@
break;
case 'Z':
if (cc < len) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
wsOutput += str[cc];
@@ -3048,7 +3031,7 @@
while (ccf < lenf && strf[ccf] == '8') {
ccf++;
}
- while (cc < len && FX_IsDigit(str[cc])) {
+ while (cc < len && FXSYS_isDecimalDigit(str[cc])) {
wsOutput += str[cc];
cc++;
}
@@ -3456,7 +3439,7 @@
while (ccf < lenf && strf[ccf] == '8') {
ccf++;
}
- while (cc < len && FX_IsDigit(str[cc])) {
+ while (cc < len && FXSYS_isDecimalDigit(str[cc])) {
wsOutput += str[cc];
cc++;
}
@@ -3524,7 +3507,7 @@
return FALSE;
}
while (cc < len && cc < 4) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
wYear = wYear * 10 + str[cc++] - '0';
@@ -3540,7 +3523,7 @@
cc_start = cc;
uint8_t tmpM = 0;
while (cc < len && cc < cc_start + 2) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
tmpM = tmpM * 10 + str[cc++] - '0';
@@ -3556,7 +3539,7 @@
uint8_t tmpD = 0;
cc_start = cc;
while (cc < len && cc < cc_start + 2) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
tmpD = tmpD * 10 + str[cc++] - '0';
@@ -3604,7 +3587,7 @@
const FX_WCHAR* str = wsTime.c_str();
int len = wsTime.GetLength();
while (cc < len && cc < 2) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
hour = hour * 10 + str[cc++] - '0';
@@ -3618,7 +3601,7 @@
}
cc_start = cc;
while (cc < len && cc < cc_start + 2) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
minute = minute * 10 + str[cc++] - '0';
@@ -3632,7 +3615,7 @@
}
cc_start = cc;
while (cc < len && cc < cc_start + 2) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
second = second * 10 + str[cc++] - '0';
@@ -3645,7 +3628,7 @@
cc++;
cc_start = cc;
while (cc < len && cc < cc_start + 3) {
- if (!FX_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return FALSE;
}
millisecond = millisecond * 10 + str[cc++] - '0';
diff --git a/xfa/fxfa/parser/cxfa_data.cpp b/xfa/fxfa/parser/cxfa_data.cpp
index 7a21851..0589adf 100644
--- a/xfa/fxfa/parser/cxfa_data.cpp
+++ b/xfa/fxfa/parser/cxfa_data.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/parser/cxfa_data.h"
+#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fxfa/parser/xfa_object.h"
// Static.
@@ -17,14 +18,14 @@
int cc = 0;
const FX_WCHAR* str = wsValue.c_str();
int len = wsValue.GetLength();
- while (XFA_IsSpace(str[cc]) && cc < len)
+ while (FXSYS_iswspace(str[cc]) && cc < len)
cc++;
if (cc >= len)
return 0xff000000;
while (cc < len) {
- if (str[cc] == ',' || !XFA_IsDigit(str[cc]))
+ if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc]))
break;
r = r * 10 + str[cc] - '0';
@@ -32,11 +33,11 @@
}
if (cc < len && str[cc] == ',') {
cc++;
- while (XFA_IsSpace(str[cc]) && cc < len)
+ while (FXSYS_iswspace(str[cc]) && cc < len)
cc++;
while (cc < len) {
- if (str[cc] == ',' || !XFA_IsDigit(str[cc]))
+ if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc]))
break;
g = g * 10 + str[cc] - '0';
@@ -44,11 +45,11 @@
}
if (cc < len && str[cc] == ',') {
cc++;
- while (XFA_IsSpace(str[cc]) && cc < len)
+ while (FXSYS_iswspace(str[cc]) && cc < len)
cc++;
while (cc < len) {
- if (str[cc] == ',' || !XFA_IsDigit(str[cc]))
+ if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc]))
break;
b = b * 10 + str[cc] - '0';
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index d241772..1dd78e1 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -1753,7 +1753,7 @@
}
for (; i < iCount; i++) {
FX_WCHAR wc = wsValue[i];
- if (XFA_IsDigit(wc)) {
+ if (FXSYS_isDecimalDigit(wc)) {
if (iLead >= 0) {
iLead_++;
if (iLead_ > iLead)
diff --git a/xfa/fxfa/parser/xfa_localevalue.cpp b/xfa/fxfa/parser/xfa_localevalue.cpp
index 0aa646d..c7f78b3 100644
--- a/xfa/fxfa/parser/xfa_localevalue.cpp
+++ b/xfa/fxfa/parser/xfa_localevalue.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/parser/xfa_localevalue.h"
+#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fgas/localization/fgas_localeimp.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
@@ -219,7 +220,7 @@
FX_BOOL bNegative = FALSE, bExpSign = FALSE;
const FX_WCHAR* str = m_wsValue.c_str();
int len = m_wsValue.GetLength();
- while (XFA_IsSpace(str[cc]) && cc < len) {
+ while (FXSYS_iswspace(str[cc]) && cc < len) {
cc++;
}
if (cc >= len) {
@@ -233,7 +234,8 @@
}
int nIntegralLen = 0;
while (cc < len) {
- if (str[cc] == '.' || !XFA_IsDigit(str[cc]) || nIntegralLen > 17) {
+ if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc]) ||
+ nIntegralLen > 17) {
break;
}
nIntegral = nIntegral * 10 + str[cc] - '0';
@@ -250,7 +252,7 @@
scale++;
cc++;
if (scale == sizeof fraction_scales / sizeof(double) ||
- !XFA_IsDigit(str[cc])) {
+ !FXSYS_isDecimalDigit(str[cc])) {
break;
}
}
@@ -267,7 +269,7 @@
}
}
while (cc < len) {
- if (str[cc] == '.' || !XFA_IsDigit(str[cc])) {
+ if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc])) {
break;
}
nExponent = nExponent * 10 + str[cc] - '0';
@@ -294,7 +296,7 @@
FX_BOOL bNegative = FALSE, bExpSign = FALSE;
const FX_WCHAR* str = m_wsValue.c_str();
int len = m_wsValue.GetLength();
- while (XFA_IsSpace(str[cc]) && cc < len) {
+ while (FXSYS_iswspace(str[cc]) && cc < len) {
cc++;
}
if (cc >= len) {
@@ -308,7 +310,8 @@
}
int32_t nIntegralLen = 0;
while (cc < len) {
- if (str[cc] == '.' || !XFA_IsDigit(str[cc]) || nIntegralLen > 17) {
+ if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc]) ||
+ nIntegralLen > 17) {
break;
}
nIntegral = nIntegral * 10 + str[cc] - '0';
@@ -325,7 +328,7 @@
scale++;
cc++;
if (scale == sizeof fraction_scales / sizeof(FX_DOUBLE) ||
- !XFA_IsDigit(str[cc])) {
+ !FXSYS_isDecimalDigit(str[cc])) {
break;
}
}
@@ -342,7 +345,7 @@
}
}
while (cc < len) {
- if (str[cc] == '.' || !XFA_IsDigit(str[cc])) {
+ if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc])) {
break;
}
nExponent = nExponent * 10 + str[cc] - '0';
@@ -616,7 +619,7 @@
const FX_WCHAR* pDate = wsDate.c_str();
int nIndex = 0, nStart = 0;
while (pDate[nIndex] != '\0' && nIndex < wCountY) {
- if (!XFA_IsDigit(pDate[nIndex])) {
+ if (!FXSYS_isDecimalDigit(pDate[nIndex])) {
return FALSE;
}
wYear = (pDate[nIndex] - '0') + wYear * 10;
@@ -630,7 +633,7 @@
}
nStart = nIndex;
while (pDate[nIndex] != '\0' && nIndex - nStart < wCountM && nIndex < nLen) {
- if (!XFA_IsDigit(pDate[nIndex])) {
+ if (!FXSYS_isDecimalDigit(pDate[nIndex])) {
return FALSE;
}
wMonth = (pDate[nIndex] - '0') + wMonth * 10;
@@ -644,7 +647,7 @@
}
nStart = nIndex;
while (pDate[nIndex] != '\0' && nIndex - nStart < wCountD && nIndex < nLen) {
- if (!XFA_IsDigit(pDate[nIndex])) {
+ if (!FXSYS_isDecimalDigit(pDate[nIndex])) {
return FALSE;
}
wDay = (pDate[nIndex] - '0') + wDay * 10;
@@ -703,7 +706,7 @@
int nIndex = 0;
int nStart = 0;
while (nIndex - nStart < wCountH && pTime[nIndex]) {
- if (!XFA_IsDigit(pTime[nIndex]))
+ if (!FXSYS_isDecimalDigit(pTime[nIndex]))
return FALSE;
wHour = pTime[nIndex] - '0' + wHour * 10;
nIndex++;
@@ -715,7 +718,7 @@
}
nStart = nIndex;
while (nIndex - nStart < wCountM && nIndex < nLen && pTime[nIndex]) {
- if (!XFA_IsDigit(pTime[nIndex]))
+ if (!FXSYS_isDecimalDigit(pTime[nIndex]))
return FALSE;
wMinute = pTime[nIndex] - '0' + wMinute * 10;
nIndex++;
@@ -727,7 +730,7 @@
}
nStart = nIndex;
while (nIndex - nStart < wCountS && nIndex < nLen && pTime[nIndex]) {
- if (!XFA_IsDigit(pTime[nIndex]))
+ if (!FXSYS_isDecimalDigit(pTime[nIndex]))
return FALSE;
wSecond = pTime[nIndex] - '0' + wSecond * 10;
nIndex++;
@@ -738,7 +741,7 @@
nIndex++;
nStart = nIndex;
while (nIndex - nStart < wCountF && nIndex < nLen && pTime[nIndex]) {
- if (!XFA_IsDigit(pTime[nIndex]))
+ if (!FXSYS_isDecimalDigit(pTime[nIndex]))
return FALSE;
wFraction = pTime[nIndex] - '0' + wFraction * 10;
nIndex++;
@@ -753,7 +756,7 @@
nIndex++;
nStart = nIndex;
while (nIndex - nStart < wCountH && nIndex < nLen && pTime[nIndex]) {
- if (!XFA_IsDigit(pTime[nIndex]))
+ if (!FXSYS_isDecimalDigit(pTime[nIndex]))
return FALSE;
nOffsetH = pTime[nIndex] - '0' + nOffsetH * 10;
nIndex++;
@@ -765,7 +768,7 @@
}
nStart = nIndex;
while (nIndex - nStart < wCountM && nIndex < nLen && pTime[nIndex]) {
- if (!XFA_IsDigit(pTime[nIndex]))
+ if (!FXSYS_isDecimalDigit(pTime[nIndex]))
return FALSE;
nOffsetM = pTime[nIndex] - '0' + nOffsetM * 10;
nIndex++;
@@ -943,7 +946,7 @@
int32_t nCount = wsNumeric.GetLength();
int32_t nCountFmt = wsFormat.GetLength();
while (n < nCount && (bLimit ? nf < nCountFmt : TRUE) &&
- XFA_IsDigit(c = pNum[n])) {
+ FXSYS_isDecimalDigit(c = pNum[n])) {
if (bLimit == TRUE) {
if ((cf = pFmt[nf]) == L'*') {
bLimit = FALSE;
@@ -981,7 +984,7 @@
++n;
bLimit = TRUE;
while (n < nCount && (bLimit ? nf < nCountFmt : TRUE) &&
- XFA_IsDigit(c = pNum[n])) {
+ FXSYS_isDecimalDigit(c = pNum[n])) {
if (bLimit == TRUE) {
if ((cf = pFmt[nf]) == L'*') {
bLimit = FALSE;
diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h
index 1036d93..a910109 100644
--- a/xfa/fxfa/parser/xfa_utils.h
+++ b/xfa/fxfa/parser/xfa_utils.h
@@ -18,17 +18,11 @@
class CXFA_Node;
class CXFA_WidgetData;
-inline FX_BOOL XFA_IsSpace(FX_WCHAR c) {
- return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09);
-}
-inline FX_BOOL XFA_IsDigit(FX_WCHAR c) {
- return c >= '0' && c <= '9';
-}
-
FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier(
CFDE_XMLElement* pNode,
const CFX_WideStringC& wsQualifier,
CFX_WideString& wsNamespaceURI);
+
template <class NodeType, class TraverseStrategy>
class CXFA_NodeIteratorTemplate {
public:
diff --git a/xfa/fxfa/parser/xfa_utils_imp.cpp b/xfa/fxfa/parser/xfa_utils_imp.cpp
index b1fe7b3..f5da036 100644
--- a/xfa/fxfa/parser/xfa_utils_imp.cpp
+++ b/xfa/fxfa/parser/xfa_utils_imp.cpp
@@ -303,7 +303,7 @@
nIntegralLen > 17) {
break;
}
- if (!XFA_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return 0;
}
nIntegral = nIntegral * 10 + str[cc] - '0';
@@ -326,7 +326,7 @@
str[cc] == 'E' || str[cc] == 'e') {
break;
}
- if (!XFA_IsDigit(str[cc])) {
+ if (!FXSYS_isDecimalDigit(str[cc])) {
return 0;
}
}
@@ -343,7 +343,7 @@
}
}
while (cc < len) {
- if (str[cc] == '.' || !XFA_IsDigit(str[cc])) {
+ if (str[cc] == '.' || !FXSYS_isDecimalDigit(str[cc])) {
return 0;
}
nExponent = nExponent * 10 + str[cc] - '0';