diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_font.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/fpdf_font.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 9 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_bstring.cpp | 3 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_gcc.cpp | 5 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_util.cpp | 42 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.cpp | 12 | ||||
-rw-r--r-- | core/fxcrt/fx_xml_composer.cpp | 20 | ||||
-rw-r--r-- | core/fxcrt/include/fx_string.h | 3 |
9 files changed, 44 insertions, 56 deletions
diff --git a/core/fpdfapi/fpdf_font/cpdf_font.cpp b/core/fpdfapi/fpdf_font/cpdf_font.cpp index f143bed541..9fb54a828b 100644 --- a/core/fpdfapi/fpdf_font/cpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp @@ -149,7 +149,7 @@ FX_BOOL CPDF_Font::IsVertWriting() const { } int CPDF_Font::AppendChar(FX_CHAR* buf, uint32_t charcode) const { - *buf = (FX_CHAR)charcode; + *buf = static_cast<FX_CHAR>(charcode); return 1; } diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp index dccce5656b..9f7b127d60 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp @@ -139,12 +139,12 @@ uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) { int result = 0; if (str[0] == '<') { for (int i = 1; i < len && std::isxdigit(str[i]); ++i) - result = result * 16 + FXSYS_toHexDigit(str[i]); + result = result * 16 + FXSYS_toHexDigit(str.CharAt(i)); return result; } for (int i = 0; i < len && std::isdigit(str[i]); ++i) - result = result * 10 + FXSYS_toDecimalDigit(static_cast<FX_CHAR>(str[i])); + result = result * 10 + FXSYS_toDecimalDigit(str.CharAt(i)); return result; } diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 03975149b0..1e9252fa82 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -87,21 +87,20 @@ int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key) { } CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) { - int size = bstr.GetLength(); - const FX_CHAR* pSrc = bstr.c_str(); if (bstr.Find('#') == -1) return bstr; + int size = bstr.GetLength(); CFX_ByteString result; FX_CHAR* pDestStart = result.GetBuffer(size); FX_CHAR* pDest = pDestStart; for (int i = 0; i < size; i++) { - if (pSrc[i] == '#' && i < size - 2) { + if (bstr[i] == '#' && i < size - 2) { *pDest++ = - FXSYS_toHexDigit(pSrc[i + 1]) * 16 + FXSYS_toHexDigit(pSrc[i + 2]); + FXSYS_toHexDigit(bstr[i + 1]) * 16 + FXSYS_toHexDigit(bstr[i + 2]); i += 2; } else { - *pDest++ = pSrc[i]; + *pDest++ = bstr[i]; } } result.ReleaseBuffer((FX_STRSIZE)(pDest - pDestStart)); diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp index 18e240bc84..e035dd53d1 100644 --- a/core/fxcrt/fx_basic_bstring.cpp +++ b/core/fxcrt/fx_basic_bstring.cpp @@ -99,9 +99,8 @@ CFX_ByteString::CFX_ByteString(char ch) { } CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) { - if (!stringSrc.IsEmpty()) { + if (!stringSrc.IsEmpty()) m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength())); - } } CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1, diff --git a/core/fxcrt/fx_basic_gcc.cpp b/core/fxcrt/fx_basic_gcc.cpp index ddbdcd5881..a55a486293 100644 --- a/core/fxcrt/fx_basic_gcc.cpp +++ b/core/fxcrt/fx_basic_gcc.cpp @@ -226,9 +226,8 @@ int FXSYS_WideCharToMultiByte(uint32_t codepage, int len = 0; for (int i = 0; i < wlen; i++) { if (wstr[i] < 0x100) { - if (buf && len < buflen) { - buf[len] = (FX_CHAR)wstr[i]; - } + if (buf && len < buflen) + buf[len] = static_cast<FX_CHAR>(wstr[i]); len++; } } diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp index f69185653f..abb2b9472a 100644 --- a/core/fxcrt/fx_basic_util.cpp +++ b/core/fxcrt/fx_basic_util.cpp @@ -97,19 +97,19 @@ void CFX_PrivateData::ClearAll() { void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) { if (strc.Find('.') == -1) { bInteger = TRUE; - int cc = 0, integer = 0; - const FX_CHAR* str = strc.c_str(); - int len = strc.GetLength(); - FX_BOOL bNegative = FALSE; - if (str[0] == '+') { + int cc = 0; + int integer = 0; + FX_STRSIZE len = strc.GetLength(); + bool bNegative = false; + if (strc[0] == '+') { cc++; - } else if (str[0] == '-') { - bNegative = TRUE; + } else if (strc[0] == '-') { + bNegative = true; cc++; } - while (cc < len && std::isdigit(str[cc])) { + while (cc < len && std::isdigit(strc[cc])) { // TODO(dsinclair): This is not the right way to handle overflow. - integer = integer * 10 + FXSYS_toDecimalDigit(str[cc]); + integer = integer * 10 + FXSYS_toDecimalDigit(strc.CharAt(cc)); if (integer < 0) break; cc++; @@ -124,31 +124,30 @@ void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) { } } FX_FLOAT FX_atof(const CFX_ByteStringC& strc) { - if (strc.GetLength() == 0) { + if (strc.IsEmpty()) return 0.0; - } + int cc = 0; - FX_BOOL bNegative = FALSE; - const FX_CHAR* str = strc.c_str(); + bool bNegative = false; int len = strc.GetLength(); - if (str[0] == '+') { + if (strc[0] == '+') { cc++; - } else if (str[0] == '-') { + } else if (strc[0] == '-') { bNegative = TRUE; cc++; } while (cc < len) { - if (str[cc] != '+' && str[cc] != '-') { + if (strc[cc] != '+' && strc[cc] != '-') { break; } cc++; } FX_FLOAT value = 0; while (cc < len) { - if (str[cc] == '.') { + if (strc[cc] == '.') { break; } - value = value * 10 + FXSYS_toDecimalDigit(str[cc]); + value = value * 10 + FXSYS_toDecimalDigit(strc.CharAt(cc)); cc++; } static const FX_FLOAT fraction_scales[] = { @@ -156,14 +155,13 @@ FX_FLOAT FX_atof(const CFX_ByteStringC& strc) { 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f, 0.0000000001f, 0.00000000001f}; int scale = 0; - if (cc < len && str[cc] == '.') { + if (cc < len && strc[cc] == '.') { cc++; while (cc < len) { - value += fraction_scales[scale] * FXSYS_toDecimalDigit(str[cc]); + value += fraction_scales[scale] * FXSYS_toDecimalDigit(strc.CharAt(cc)); scale++; - if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { + if (scale == FX_ArraySize(fraction_scales)) break; - } cc++; } } diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index 0b55fc91dd..315e33fd7e 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -219,17 +219,13 @@ int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count) { } uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase) { - const FX_CHAR* pStr = str.c_str(); - const FX_CHAR* pStrEnd = pStr + str.GetLength(); uint32_t dwHashCode = 0; if (bIgnoreCase) { - while (pStr < pStrEnd) { - dwHashCode = 31 * dwHashCode + FXSYS_tolower(*pStr++); - } + for (FX_STRSIZE i = 0; i < str.GetLength(); ++i) + dwHashCode = 31 * dwHashCode + FXSYS_tolower(str.CharAt(i)); } else { - while (pStr < pStrEnd) { - dwHashCode = 31 * dwHashCode + *pStr++; - } + for (FX_STRSIZE i = 0; i < str.GetLength(); ++i) + dwHashCode = 31 * dwHashCode + str.CharAt(i); } return dwHashCode; } diff --git a/core/fxcrt/fx_xml_composer.cpp b/core/fxcrt/fx_xml_composer.cpp index 576ff95432..1bad069c34 100644 --- a/core/fxcrt/fx_xml_composer.cpp +++ b/core/fxcrt/fx_xml_composer.cpp @@ -11,24 +11,18 @@ void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, CFX_ByteStringC& bsSpace, CFX_ByteStringC& bsName) { - if (bsFullName.IsEmpty()) { + if (bsFullName.IsEmpty()) return; - } - int32_t iStart = 0; - for (; iStart < bsFullName.GetLength(); iStart++) { - if (bsFullName.GetAt(iStart) == ':') { - break; - } - } - if (iStart >= bsFullName.GetLength()) { + + FX_STRSIZE iStart = bsFullName.Find(':'); + if (iStart == -1) { bsName = bsFullName; } else { - bsSpace = CFX_ByteStringC(bsFullName.c_str(), iStart); - iStart++; - bsName = CFX_ByteStringC(bsFullName.c_str() + iStart, - bsFullName.GetLength() - iStart); + bsSpace = bsFullName.Mid(0, iStart); + bsName = bsFullName.Mid(iStart + 1); } } + void CXML_Element::SetTag(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagname) { m_QSpaceName = qSpace; diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h index 8c1a6174b2..617e02ee5a 100644 --- a/core/fxcrt/include/fx_string.h +++ b/core/fxcrt/include/fx_string.h @@ -94,6 +94,9 @@ class CFX_ByteStringC { bool IsEmpty() const { return m_Length == 0; } uint8_t GetAt(FX_STRSIZE index) const { return m_Ptr[index]; } + FX_CHAR CharAt(FX_STRSIZE index) const { + return static_cast<FX_CHAR>(m_Ptr[index]); + } FX_STRSIZE Find(FX_CHAR ch) const { const uint8_t* found = |