diff options
-rw-r--r-- | core/fpdftext/cpdf_textpagefind.cpp | 9 | ||||
-rw-r--r-- | core/fxcrt/cfx_widestring.cpp | 1 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.cpp | 16 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.h | 6 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_xmlsyntaxparser.cpp | 12 | ||||
-rw-r--r-- | fpdfsdk/javascript/PublicMethods.cpp | 39 | ||||
-rw-r--r-- | fpdfsdk/javascript/util.cpp | 3 | ||||
-rw-r--r-- | fxbarcode/oned/BC_OnedEAN13Writer.cpp | 5 | ||||
-rw-r--r-- | xfa/fgas/crt/cfgas_formatstring.cpp | 2 |
9 files changed, 40 insertions, 53 deletions
diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp index 7eaac35194..a4f4a6e828 100644 --- a/core/fpdftext/cpdf_textpagefind.cpp +++ b/core/fpdftext/cpdf_textpagefind.cpp @@ -348,15 +348,10 @@ bool CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, return false; } if (char_count > 0) { - if (csPageText.GetAt(startPos) >= L'0' && - csPageText.GetAt(startPos) <= L'9' && char_left >= L'0' && - char_left <= L'9') { + if (std::iswdigit(char_left) && std::iswdigit(csPageText.GetAt(startPos))) return false; - } - if (csPageText.GetAt(endPos) >= L'0' && csPageText.GetAt(endPos) <= L'9' && - char_right >= L'0' && char_right <= L'9') { + if (std::iswdigit(char_right) && std::iswdigit(csPageText.GetAt(endPos))) return false; - } } return true; } diff --git a/core/fxcrt/cfx_widestring.cpp b/core/fxcrt/cfx_widestring.cpp index 2b98ce59a4..8cd4de6edd 100644 --- a/core/fxcrt/cfx_widestring.cpp +++ b/core/fxcrt/cfx_widestring.cpp @@ -10,6 +10,7 @@ #include <algorithm> #include <cctype> +#include <cwctype> #include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/fx_basic.h" diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index 47bd937ff8..209584b68d 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -6,6 +6,8 @@ #include "core/fxcrt/fx_extension.h" +#include <cwctype> + #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #include <wincrypt.h> #else @@ -67,11 +69,10 @@ float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) { float fValue = 0.0f; while (iUsedLen < iLength) { wchar_t wch = pwsStr[iUsedLen]; - if (wch >= L'0' && wch <= L'9') - fValue = fValue * 10.0f + (wch - L'0'); - else + if (!std::iswdigit(wch)) break; + fValue = fValue * 10.0f + (wch - L'0'); iUsedLen++; } @@ -79,12 +80,11 @@ float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) { float fPrecise = 0.1f; while (++iUsedLen < iLength) { wchar_t wch = pwsStr[iUsedLen]; - if (wch >= L'0' && wch <= L'9') { - fValue += (wch - L'0') * fPrecise; - fPrecise *= 0.1f; - } else { + if (!std::iswdigit(wch)) break; - } + + fValue += (wch - L'0') * fPrecise; + fPrecise *= 0.1f; } } if (pUsedLen) diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h index e9d16786a9..00604fb22c 100644 --- a/core/fxcrt/fx_extension.h +++ b/core/fxcrt/fx_extension.h @@ -41,12 +41,8 @@ inline bool FXSYS_iswalpha(wchar_t wch) { return (wch >= L'A' && wch <= L'Z') || (wch >= L'a' && wch <= L'z'); } -inline bool FXSYS_iswdigit(wchar_t wch) { - return wch >= L'0' && wch <= L'9'; -} - inline bool FXSYS_iswalnum(wchar_t wch) { - return FXSYS_iswalpha(wch) || FXSYS_iswdigit(wch); + return FXSYS_iswalpha(wch) || std::iswdigit(wch); } inline bool FXSYS_iswspace(wchar_t c) { diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp index ac3f1b5c5d..e3d690f5ab 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp @@ -7,6 +7,7 @@ #include "core/fxcrt/xml/cfx_xmlsyntaxparser.h" #include <algorithm> +#include <cwctype> #include <iterator> #include "core/fxcrt/fx_extension.h" @@ -633,20 +634,19 @@ void CFX_XMLSyntaxParser::ParseTextChar(wchar_t character) { if (iLen > 1 && csEntity[1] == L'x') { for (int32_t i = 2; i < iLen; i++) { w = csEntity[i]; - if (w >= L'0' && w <= L'9') { + if (std::iswdigit(w)) ch = (ch << 4) + w - L'0'; - } else if (w >= L'A' && w <= L'F') { + else if (w >= L'A' && w <= L'F') ch = (ch << 4) + w - 55; - } else if (w >= L'a' && w <= L'f') { + else if (w >= L'a' && w <= L'f') ch = (ch << 4) + w - 87; - } else { + else break; - } } } else { for (int32_t i = 1; i < iLen; i++) { w = csEntity[i]; - if (w < L'0' || w > L'9') + if (!std::iswdigit(w)) break; ch = ch * 10 + w - L'0'; } diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp index b3495375e0..759fd91a4d 100644 --- a/fpdfsdk/javascript/PublicMethods.cpp +++ b/fpdfsdk/javascript/PublicMethods.cpp @@ -7,6 +7,7 @@ #include "fpdfsdk/javascript/PublicMethods.h" #include <algorithm> +#include <cwctype> #include <iomanip> #include <limits> #include <sstream> @@ -135,12 +136,10 @@ bool CJS_PublicMethods::IsNumber(const CFX_WideString& str) { p++; c = *p; - if (c == L'+' || c == L'-') { - bKXJS = true; - } else { + if (c != L'+' && c != L'-') return false; - } - } else if (!FXSYS_iswdigit(c)) { + bKXJS = true; + } else if (!std::iswdigit(c)) { return false; } p++; @@ -152,7 +151,7 @@ bool CJS_PublicMethods::IsNumber(const CFX_WideString& str) { bool CJS_PublicMethods::maskSatisfied(wchar_t c_Change, wchar_t c_Mask) { switch (c_Mask) { case L'9': - return FXSYS_iswdigit(c_Change); + return !!std::iswdigit(c_Change); case L'A': return FXSYS_iswalpha(c_Change); case L'O': @@ -236,7 +235,7 @@ int CJS_PublicMethods::ParseStringInteger(const CFX_WideString& str, break; wchar_t c = str.GetAt(i); - if (!FXSYS_iswdigit(c)) + if (!std::iswdigit(c)) break; nRet = nRet * 10 + FXSYS_toDecimalDigit(c); @@ -255,7 +254,7 @@ CFX_WideString CJS_PublicMethods::ParseStringString(const CFX_WideString& str, nSkip = 0; for (int i = nStart, sz = str.GetLength(); i < sz; i++) { wchar_t c = str.GetAt(i); - if (!FXSYS_iswdigit(c)) + if (!std::iswdigit(c)) break; swRet += c; @@ -287,7 +286,7 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString& value, break; wchar_t c = value.GetAt(i); - if (FXSYS_iswdigit(c)) { + if (std::iswdigit(c)) { number[nIndex++] = ParseStringInteger(value, i, nSkip, 4); i += nSkip; } else { @@ -937,8 +936,7 @@ bool CJS_PublicMethods::AFNumber_Keystroke(CJS_Runtime* pRuntime, if (bHasSign) { // can't insert "change" in front to sign postion. if (pEvent->SelStart() == 0) { - bool& bRc = pEvent->Rc(); - bRc = false; + pEvent->Rc() = false; return true; } } @@ -952,8 +950,7 @@ bool CJS_PublicMethods::AFNumber_Keystroke(CJS_Runtime* pRuntime, for (FX_STRSIZE i = 0; i < wstrChange.GetLength(); ++i) { if (wstrChange[i] == cSep) { if (bHasSep) { - bool& bRc = pEvent->Rc(); - bRc = false; + pEvent->Rc() = false; return true; } bHasSep = true; @@ -961,28 +958,24 @@ bool CJS_PublicMethods::AFNumber_Keystroke(CJS_Runtime* pRuntime, } if (wstrChange[i] == L'-') { if (bHasSign) { - bool& bRc = pEvent->Rc(); - bRc = false; + pEvent->Rc() = false; return true; } // sign's position is not correct if (i != 0) { - bool& bRc = pEvent->Rc(); - bRc = false; + pEvent->Rc() = false; return true; } if (pEvent->SelStart() != 0) { - bool& bRc = pEvent->Rc(); - bRc = false; + pEvent->Rc() = false; return true; } bHasSign = true; continue; } - if (!FXSYS_iswdigit(wstrChange[i])) { - bool& bRc = pEvent->Rc(); - bRc = false; + if (!std::iswdigit(wstrChange[i])) { + pEvent->Rc() = false; return true; } } @@ -1775,7 +1768,7 @@ bool CJS_PublicMethods::AFExtractNums(CJS_Runtime* pRuntime, CJS_Array nums; int nIndex = 0; for (const auto& wc : str) { - if (FXSYS_iswdigit(wc)) { + if (std::iswdigit(wc)) { sPart += wc; } else if (sPart.GetLength() > 0) { nums.SetElement(pRuntime, nIndex, CJS_Value(pRuntime, sPart.c_str())); diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp index 4303342064..dc34119c38 100644 --- a/fpdfsdk/javascript/util.cpp +++ b/fpdfsdk/javascript/util.cpp @@ -9,6 +9,7 @@ #include <time.h> #include <algorithm> +#include <cwctype> #include <string> #include <vector> @@ -93,7 +94,7 @@ int ParseDataType(std::wstring* sFormat) { return UTIL_STRING; } if (c == L'.' || c == L'+' || c == L'-' || c == L'#' || c == L' ' || - FXSYS_iswdigit(c)) { + std::iswdigit(c)) { continue; } break; diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp index 7f38661079..d44eb39916 100644 --- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -22,6 +22,8 @@ #include "fxbarcode/oned/BC_OnedEAN13Writer.h" +#include <algorithm> +#include <cwctype> #include <memory> #include <vector> @@ -55,8 +57,7 @@ CBC_OnedEAN13Writer::~CBC_OnedEAN13Writer() {} bool CBC_OnedEAN13Writer::CheckContentValidity( const CFX_WideStringC& contents) { - return std::all_of(contents.begin(), contents.end(), - [](const wchar_t& w) { return w >= L'0' && w <= L'9'; }); + return std::all_of(contents.begin(), contents.end(), std::iswdigit); } CFX_WideString CBC_OnedEAN13Writer::FilterContents( diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp index 6d940d6c94..d4ac87c7bc 100644 --- a/xfa/fgas/crt/cfgas_formatstring.cpp +++ b/xfa/fgas/crt/cfgas_formatstring.cpp @@ -616,7 +616,7 @@ int32_t GetNumTrailingLimit(const CFX_WideString& wsFormat, wchar_t wc = wsFormat[iDotPos]; if (wc == L'z' || wc == L'9' || wc == 'Z') { iTreading++; - bTrimTailZeros = (wc == L'9' ? false : true); + bTrimTailZeros = wc != L'9'; } } return iTreading; |