summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp9
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp2
-rw-r--r--core/fpdfapi/parser/fpdf_parser_utility.cpp4
-rw-r--r--core/fpdfdoc/cpdf_action.cpp3
-rw-r--r--core/fpdftext/cpdf_linkextract.cpp20
-rw-r--r--core/fpdftext/cpdf_textpagefind.cpp2
-rw-r--r--core/fxcrt/cfx_bytestring.cpp16
-rw-r--r--core/fxcrt/cfx_bytestring_unittest.cpp14
-rw-r--r--core/fxcrt/cfx_string_c_template.h2
-rw-r--r--core/fxcrt/cfx_widestring.cpp18
-rw-r--r--core/fxcrt/cfx_widestring_unittest.cpp14
-rw-r--r--core/fxcrt/fx_basic_util.cpp2
-rw-r--r--core/fxcrt/fx_system.h4
-rw-r--r--core/fxcrt/xml/cfx_xmlelement.cpp4
-rw-r--r--core/fxcrt/xml/cxml_parser.cpp2
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.cpp4
-rw-r--r--core/fxge/apple/fx_mac_imp.cpp4
-rw-r--r--core/fxge/cfx_folderfontinfo.cpp8
-rw-r--r--core/fxge/cfx_font.cpp2
-rw-r--r--core/fxge/cfx_fontmapper.cpp6
-rw-r--r--core/fxge/cfx_renderdevice.cpp2
-rw-r--r--core/fxge/fx_ge_linux.cpp15
-rw-r--r--core/fxge/win32/fx_win32_device.cpp33
-rw-r--r--fpdfsdk/fpdfedittext.cpp2
-rw-r--r--fpdfsdk/fpdfppo.cpp12
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp22
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp9
-rw-r--r--fxbarcode/oned/BC_OneDimWriter.cpp2
-rw-r--r--xfa/fgas/crt/cfgas_formatstring.cpp26
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp2
-rw-r--r--xfa/fxfa/cxfa_pdffontmgr.cpp16
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_localevalue.cpp13
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp10
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp27
40 files changed, 186 insertions, 169 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index 62b10c9149..e9676b1115 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -186,8 +186,10 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessStandardText) {
std::ostringstream buf;
TestProcessText(&generator, &buf, pTextObj.get());
CFX_ByteString textString(buf);
- int firstResourceAt = textString.Find('/') + 1;
- int secondResourceAt = textString.ReverseFind('/') + 1;
+ FX_STRSIZE firstResourceAt = textString.Find('/') + 1;
+ FX_STRSIZE secondResourceAt = textString.ReverseFind('/') + 1;
+ EXPECT_NE(FX_STRNPOS, firstResourceAt);
+ EXPECT_NE(FX_STRNPOS, secondResourceAt);
CFX_ByteString firstString = textString.Left(firstResourceAt);
CFX_ByteString midString =
textString.Mid(firstResourceAt, secondResourceAt - firstResourceAt);
@@ -252,7 +254,8 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessText) {
}
CFX_ByteString textString(buf);
- int firstResourceAt = textString.Find('/') + 1;
+ FX_STRSIZE firstResourceAt = textString.Find('/') + 1;
+ EXPECT_NE(FX_STRNPOS, firstResourceAt);
CFX_ByteString firstString = textString.Left(firstResourceAt);
CFX_ByteString lastString =
textString.Right(textString.GetLength() - firstResourceAt);
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 288f9d57a8..692de0f5eb 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -316,7 +316,7 @@ void CPDF_StreamContentParser::AddNameParam(const CFX_ByteStringC& bsName) {
m_pDocument->GetByteStringPool(), PDF_NameDecode(bsName));
} else {
param.m_Type = ContentParam::NAME;
- if (bsName.Find('#') == -1) {
+ if (bsName.Find('#') == FX_STRNPOS) {
memcpy(param.m_Name.m_Buffer, bsName.raw_str(), bsName.GetLength());
param.m_Name.m_Len = bsName.GetLength();
} else {
diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp
index 0cd4ca9225..7025b3e7d8 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp
@@ -89,7 +89,7 @@ int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteString& key) {
}
CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
- if (bstr.Find('#') == -1)
+ if (bstr.Find('#') == FX_STRNPOS)
return CFX_ByteString(bstr);
int size = bstr.GetLength();
@@ -110,7 +110,7 @@ CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
}
CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) {
- if (orig.Find('#') == -1)
+ if (orig.Find('#') == FX_STRNPOS)
return orig;
return PDF_NameDecode(orig.AsStringC());
}
diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp
index 2357580548..dae7a7180e 100644
--- a/core/fpdfdoc/cpdf_action.cpp
+++ b/core/fpdfdoc/cpdf_action.cpp
@@ -96,7 +96,8 @@ CFX_ByteString CPDF_Action::GetURI(CPDF_Document* pDoc) const {
CPDF_Dictionary* pRoot = pDoc->GetRoot();
CPDF_Dictionary* pURI = pRoot->GetDictFor("URI");
if (pURI) {
- if (csURI.Find(":", 0) < 1)
+ FX_STRSIZE ret = csURI.Find(":");
+ if (ret == 0 || ret == FX_STRNPOS)
csURI = pURI->GetStringFor("Base") + csURI;
}
return csURI;
diff --git a/core/fpdftext/cpdf_linkextract.cpp b/core/fpdftext/cpdf_linkextract.cpp
index e0bd4ae49f..d795e71639 100644
--- a/core/fpdftext/cpdf_linkextract.cpp
+++ b/core/fpdftext/cpdf_linkextract.cpp
@@ -22,7 +22,7 @@ namespace {
FX_STRSIZE FindWebLinkEnding(const CFX_WideString& str,
FX_STRSIZE start,
FX_STRSIZE end) {
- if (str.Find(L'/', start) != -1) {
+ if (str.Find(L'/', start) != FX_STRNPOS) {
// When there is a path and query after '/', most ASCII chars are allowed.
// We don't sanitize in this case.
return end;
@@ -197,7 +197,7 @@ bool CPDF_LinkExtract::CheckWebLink(CFX_WideString* strBeCheck,
FX_STRSIZE len = str.GetLength();
// First, try to find the scheme.
FX_STRSIZE start = str.Find(kHttpScheme);
- if (start != -1) {
+ if (start != FX_STRNPOS) {
FX_STRSIZE off = start + kHttpSchemeLen; // move after "http".
if (len > off + 4) { // At least "://<char>" follows.
if (str[off] == L's') // "https" scheme is accepted.
@@ -219,7 +219,7 @@ bool CPDF_LinkExtract::CheckWebLink(CFX_WideString* strBeCheck,
// When there is no scheme, try to find url starting with "www.".
start = str.Find(kWWWAddrStart);
- if (start != -1 && len > start + kWWWAddrStartLen) {
+ if (start != FX_STRNPOS && len > start + kWWWAddrStartLen) {
FX_STRSIZE end =
TrimExternalBracketsFromWebLink(str, start, str.GetLength() - 1);
end = FindWebLinkEnding(str, start, end);
@@ -234,9 +234,9 @@ bool CPDF_LinkExtract::CheckWebLink(CFX_WideString* strBeCheck,
}
bool CPDF_LinkExtract::CheckMailLink(CFX_WideString* str) {
- int aPos = str->Find(L'@');
- // Invalid when no '@'.
- if (aPos < 1)
+ FX_STRSIZE aPos = str->Find(L'@');
+ // Invalid when no '@' or when starts/ends with '@'.
+ if (aPos == FX_STRNPOS || aPos == 0 || aPos == str->GetLength() - 1)
return false;
// Check the local part.
@@ -263,15 +263,15 @@ bool CPDF_LinkExtract::CheckMailLink(CFX_WideString* str) {
// Check the domain name part.
aPos = str->Find(L'@');
- if (aPos < 1)
+ if (aPos < 1 || aPos == FX_STRNPOS)
return false;
str->TrimRight(L'.');
// At least one '.' in domain name, but not at the beginning.
// TODO(weili): RFC5322 allows domain names to be a local name without '.'.
// Check whether we should remove this check.
- int ePos = str->Find(L'.', aPos + 1);
- if (ePos == -1 || ePos == aPos + 1)
+ FX_STRSIZE ePos = str->Find(L'.', aPos + 1);
+ if (ePos == FX_STRNPOS || ePos == aPos + 1)
return false;
// Validate all other chars in domain name.
@@ -295,7 +295,7 @@ bool CPDF_LinkExtract::CheckMailLink(CFX_WideString* str) {
pPos = i;
}
- if (str->Find(L"mailto:") == -1)
+ if (str->Find(L"mailto:") == FX_STRNPOS)
*str = L"mailto:" + *str;
return true;
diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp
index fe610abcd4..adef9f6c0c 100644
--- a/core/fpdftext/cpdf_textpagefind.cpp
+++ b/core/fpdftext/cpdf_textpagefind.cpp
@@ -164,7 +164,7 @@ bool CPDF_TextPageFind::FindNext() {
}
int endIndex;
nResultPos = m_strText.Find(csWord.c_str(), nStartPos);
- if (nResultPos == -1) {
+ if (nResultPos == FX_STRNPOS) {
m_IsFind = false;
return m_IsFind;
}
diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp
index e7e55de8e3..6e01933682 100644
--- a/core/fxcrt/cfx_bytestring.cpp
+++ b/core/fxcrt/cfx_bytestring.cpp
@@ -562,41 +562,41 @@ CFX_ByteString CFX_ByteString::Left(FX_STRSIZE nCount) const {
FX_STRSIZE CFX_ByteString::Find(char ch, FX_STRSIZE nStart) const {
if (!m_pData)
- return -1;
+ return FX_STRNPOS;
if (nStart < 0 || nStart >= m_pData->m_nDataLength)
- return -1;
+ return FX_STRNPOS;
const char* pStr = static_cast<const char*>(
memchr(m_pData->m_String + nStart, ch, m_pData->m_nDataLength - nStart));
- return pStr ? pStr - m_pData->m_String : -1;
+ return pStr ? pStr - m_pData->m_String : FX_STRNPOS;
}
FX_STRSIZE CFX_ByteString::ReverseFind(char ch) const {
if (!m_pData)
- return -1;
+ return FX_STRNPOS;
FX_STRSIZE nLength = m_pData->m_nDataLength;
while (nLength--) {
if (m_pData->m_String[nLength] == ch)
return nLength;
}
- return -1;
+ return FX_STRNPOS;
}
FX_STRSIZE CFX_ByteString::Find(const CFX_ByteStringC& pSub,
FX_STRSIZE nStart) const {
if (!m_pData)
- return -1;
+ return FX_STRNPOS;
FX_STRSIZE nLength = m_pData->m_nDataLength;
if (nStart > nLength)
- return -1;
+ return FX_STRNPOS;
const char* pStr =
FX_strstr(m_pData->m_String + nStart, m_pData->m_nDataLength - nStart,
pSub.unterminated_c_str(), pSub.GetLength());
- return pStr ? (int)(pStr - m_pData->m_String) : -1;
+ return pStr ? (int)(pStr - m_pData->m_String) : FX_STRNPOS;
}
void CFX_ByteString::MakeLower() {
diff --git a/core/fxcrt/cfx_bytestring_unittest.cpp b/core/fxcrt/cfx_bytestring_unittest.cpp
index bcf6f7495e..d7f265e32a 100644
--- a/core/fxcrt/cfx_bytestring_unittest.cpp
+++ b/core/fxcrt/cfx_bytestring_unittest.cpp
@@ -826,22 +826,22 @@ TEST(fxcrt, ByteStringCGetID) {
TEST(fxcrt, ByteStringCFind) {
CFX_ByteStringC null_string;
- EXPECT_EQ(-1, null_string.Find('a'));
- EXPECT_EQ(-1, null_string.Find(0));
+ EXPECT_EQ(FX_STRNPOS, null_string.Find('a'));
+ EXPECT_EQ(FX_STRNPOS, null_string.Find(0));
CFX_ByteStringC empty_string("");
- EXPECT_EQ(-1, empty_string.Find('a'));
- EXPECT_EQ(-1, empty_string.Find(0));
+ EXPECT_EQ(FX_STRNPOS, empty_string.Find('a'));
+ EXPECT_EQ(FX_STRNPOS, empty_string.Find(0));
CFX_ByteStringC single_string("a");
EXPECT_EQ(0, single_string.Find('a'));
- EXPECT_EQ(-1, single_string.Find('b'));
- EXPECT_EQ(-1, single_string.Find(0));
+ EXPECT_EQ(FX_STRNPOS, single_string.Find('b'));
+ EXPECT_EQ(FX_STRNPOS, single_string.Find(0));
CFX_ByteStringC longer_string("abccc");
EXPECT_EQ(0, longer_string.Find('a'));
EXPECT_EQ(2, longer_string.Find('c'));
- EXPECT_EQ(-1, longer_string.Find(0));
+ EXPECT_EQ(FX_STRNPOS, longer_string.Find(0));
CFX_ByteStringC hibyte_string(
"ab\x8c"
diff --git a/core/fxcrt/cfx_string_c_template.h b/core/fxcrt/cfx_string_c_template.h
index 77f34f638e..b87b65991e 100644
--- a/core/fxcrt/cfx_string_c_template.h
+++ b/core/fxcrt/cfx_string_c_template.h
@@ -127,7 +127,7 @@ class CFX_StringCTemplate {
FX_STRSIZE Find(CharType ch) const {
const UnsignedType* found = reinterpret_cast<const UnsignedType*>(FXSYS_chr(
reinterpret_cast<const CharType*>(m_Ptr.Get()), ch, m_Length));
- return found ? found - m_Ptr.Get() : -1;
+ return found ? found - m_Ptr.Get() : FX_STRNPOS;
}
CFX_StringCTemplate Mid(FX_STRSIZE index, FX_STRSIZE count) const {
diff --git a/core/fxcrt/cfx_widestring.cpp b/core/fxcrt/cfx_widestring.cpp
index d7c1ef23ea..8937783863 100644
--- a/core/fxcrt/cfx_widestring.cpp
+++ b/core/fxcrt/cfx_widestring.cpp
@@ -78,7 +78,7 @@ FX_STRSIZE GuessSizeForVSWPrintf(const wchar_t* pFormat, va_list argList) {
++pStr;
}
if (nWidth < 0 || nWidth > 128 * 1024)
- return -1;
+ return FX_STRNPOS;
int nPrecision = 0;
if (*pStr == '.') {
pStr++;
@@ -92,7 +92,7 @@ FX_STRSIZE GuessSizeForVSWPrintf(const wchar_t* pFormat, va_list argList) {
}
}
if (nPrecision < 0 || nPrecision > 128 * 1024)
- return -1;
+ return FX_STRNPOS;
int nModifier = 0;
if (*pStr == L'I' && *(pStr + 1) == L'6' && *(pStr + 2) == L'4') {
pStr += 3;
@@ -662,7 +662,7 @@ void CFX_WideString::FormatV(const wchar_t* pFormat, va_list argList) {
va_end(argListCopy);
if (nMaxLen <= 0) {
nMaxLen = GuessSizeForVSWPrintf(pFormat, argListCopy);
- if (nMaxLen <= 0)
+ if (nMaxLen == FX_STRNPOS)
return;
}
while (nMaxLen < 32 * 1024) {
@@ -724,29 +724,29 @@ CFX_WideString CFX_WideString::Left(FX_STRSIZE nCount) const {
FX_STRSIZE CFX_WideString::Find(wchar_t ch, FX_STRSIZE nStart) const {
if (!m_pData)
- return -1;
+ return FX_STRNPOS;
if (nStart < 0 || nStart >= m_pData->m_nDataLength)
- return -1;
+ return FX_STRNPOS;
const wchar_t* pStr =
wmemchr(m_pData->m_String + nStart, ch, m_pData->m_nDataLength - nStart);
- return pStr ? pStr - m_pData->m_String : -1;
+ return pStr ? pStr - m_pData->m_String : FX_STRNPOS;
}
FX_STRSIZE CFX_WideString::Find(const CFX_WideStringC& pSub,
FX_STRSIZE nStart) const {
if (!m_pData)
- return -1;
+ return FX_STRNPOS;
FX_STRSIZE nLength = m_pData->m_nDataLength;
if (nStart > nLength)
- return -1;
+ return FX_STRNPOS;
const wchar_t* pStr =
FX_wcsstr(m_pData->m_String + nStart, m_pData->m_nDataLength - nStart,
pSub.unterminated_c_str(), pSub.GetLength());
- return pStr ? (int)(pStr - m_pData->m_String) : -1;
+ return pStr ? (int)(pStr - m_pData->m_String) : FX_STRNPOS;
}
void CFX_WideString::MakeLower() {
diff --git a/core/fxcrt/cfx_widestring_unittest.cpp b/core/fxcrt/cfx_widestring_unittest.cpp
index 1d6d110497..a53e9a35e2 100644
--- a/core/fxcrt/cfx_widestring_unittest.cpp
+++ b/core/fxcrt/cfx_widestring_unittest.cpp
@@ -853,22 +853,22 @@ TEST(fxcrt, WideStringCOperatorNE) {
TEST(fxcrt, WideStringCFind) {
CFX_WideStringC null_string;
- EXPECT_EQ(-1, null_string.Find(L'a'));
- EXPECT_EQ(-1, null_string.Find(0));
+ EXPECT_EQ(FX_STRNPOS, null_string.Find(L'a'));
+ EXPECT_EQ(FX_STRNPOS, null_string.Find(0));
CFX_WideStringC empty_string(L"");
- EXPECT_EQ(-1, empty_string.Find(L'a'));
- EXPECT_EQ(-1, empty_string.Find(0));
+ EXPECT_EQ(FX_STRNPOS, empty_string.Find(L'a'));
+ EXPECT_EQ(FX_STRNPOS, empty_string.Find(0));
CFX_WideStringC single_string(L"a");
EXPECT_EQ(0, single_string.Find(L'a'));
- EXPECT_EQ(-1, single_string.Find(L'b'));
- EXPECT_EQ(-1, single_string.Find(0));
+ EXPECT_EQ(FX_STRNPOS, single_string.Find(L'b'));
+ EXPECT_EQ(FX_STRNPOS, single_string.Find(0));
CFX_WideStringC longer_string(L"abccc");
EXPECT_EQ(0, longer_string.Find(L'a'));
EXPECT_EQ(2, longer_string.Find(L'c'));
- EXPECT_EQ(-1, longer_string.Find(0));
+ EXPECT_EQ(FX_STRNPOS, longer_string.Find(0));
CFX_WideStringC hibyte_string(
L"ab\xff08"
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index aef623ce92..7730866c73 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -14,7 +14,7 @@
#include "third_party/base/ptr_util.h"
bool FX_atonum(const CFX_ByteStringC& strc, void* pData) {
- if (strc.Find('.') != -1) {
+ if (strc.Find('.') != FX_STRNPOS) {
float* pFloat = static_cast<float*>(pData);
*pFloat = FX_atof(strc);
return false;
diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h
index 5e8aa6c0e6..e9288641b8 100644
--- a/core/fxcrt/fx_system.h
+++ b/core/fxcrt/fx_system.h
@@ -127,6 +127,10 @@ void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap);
#include "third_party/base/numerics/safe_conversions.h"
+// Constant used to indicate failure from find methods and other methods that
+// return FX_STRSIZE.
+constexpr FX_STRSIZE FX_STRNPOS = -1;
+
#define FXSYS_strlen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(strlen(ptr))
#define FXSYS_wcslen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(wcslen(ptr))
diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp
index 8c2442e765..75bf9ee593 100644
--- a/core/fxcrt/xml/cfx_xmlelement.cpp
+++ b/core/fxcrt/xml/cfx_xmlelement.cpp
@@ -43,14 +43,14 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLElement::Clone() {
CFX_WideString CFX_XMLElement::GetLocalTagName() const {
FX_STRSIZE iFind = GetName().Find(L':', 0);
- if (iFind < 0)
+ if (iFind == FX_STRNPOS)
return GetName();
return GetName().Right(GetName().GetLength() - iFind - 1);
}
CFX_WideString CFX_XMLElement::GetNamespacePrefix() const {
FX_STRSIZE iFind = GetName().Find(L':', 0);
- if (iFind < 0)
+ if (iFind == FX_STRNPOS)
return CFX_WideString();
return GetName().Left(iFind);
}
diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp
index 5ac1f82206..35eca527e6 100644
--- a/core/fxcrt/xml/cxml_parser.cpp
+++ b/core/fxcrt/xml/cxml_parser.cpp
@@ -83,7 +83,7 @@ void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
return;
FX_STRSIZE iStart = bsFullName.Find(':');
- if (iStart == -1) {
+ if (iStart == FX_STRNPOS) {
bsName = bsFullName;
} else {
bsSpace = bsFullName.Left(iStart);
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index 23fcd5bbec..3cee6decac 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -194,13 +194,13 @@ bool FPF_SkiaIsCJK(uint8_t uCharset) {
bool FPF_SkiaMaybeSymbol(const CFX_ByteStringC& bsFacename) {
CFX_ByteString bsName(bsFacename);
bsName.MakeLower();
- return bsName.Find("symbol") > -1;
+ return bsName.Find("symbol") != FX_STRNPOS;
}
bool FPF_SkiaMaybeArabic(const CFX_ByteStringC& bsFacename) {
CFX_ByteString bsName(bsFacename);
bsName.MakeLower();
- return bsName.Find("arabic") > -1;
+ return bsName.Find("arabic") != FX_STRNPOS;
}
const uint32_t g_FPFSkiaFontCharsets[] = {
diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp
index 78fe16459c..54aac7bfa6 100644
--- a/core/fxge/apple/fx_mac_imp.cpp
+++ b/core/fxge/apple/fx_mac_imp.cpp
@@ -52,7 +52,7 @@ const char JAPAN_GOTHIC[] = "Hiragino Kaku Gothic Pro W6";
const char JAPAN_MINCHO[] = "Hiragino Mincho Pro W6";
void GetJapanesePreference(CFX_ByteString* face, int weight, int pitch_family) {
- if (face->Find("Gothic") >= 0) {
+ if (face->Find("Gothic") != FX_STRNPOS) {
*face = JAPAN_GOTHIC;
return;
}
@@ -82,7 +82,7 @@ void* CFX_MacFontInfo::MapFont(int weight,
// Times New Roman. A more sophisticated approach would be to find all the
// fonts in |m_FontList| with |face| in the name, and examine the fonts to
// see which best matches the requested characteristics.
- if (face.Find("Bold") == -1 && face.Find("Italic") == -1) {
+ if (face.Find("Bold") == FX_STRNPOS && face.Find("Italic") == FX_STRNPOS) {
CFX_ByteString new_face = face;
if (weight > 400)
new_face += " Bold";
diff --git a/core/fxge/cfx_folderfontinfo.cpp b/core/fxge/cfx_folderfontinfo.cpp
index 12e7dd25fc..f16722c4d6 100644
--- a/core/fxge/cfx_folderfontinfo.cpp
+++ b/core/fxge/cfx_folderfontinfo.cpp
@@ -251,11 +251,11 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path,
m_pMapper->AddInstalledFont(facename, FX_CHARSET_ANSI);
pInfo->m_Charsets |= CHARSET_FLAG_ANSI;
pInfo->m_Styles = 0;
- if (style.Find("Bold") > -1)
+ if (style.Find("Bold") != FX_STRNPOS)
pInfo->m_Styles |= FXFONT_BOLD;
- if (style.Find("Italic") > -1 || style.Find("Oblique") > -1)
+ if (style.Find("Italic") != FX_STRNPOS || style.Find("Oblique") != FX_STRNPOS)
pInfo->m_Styles |= FXFONT_ITALIC;
- if (facename.Find("Serif") > -1)
+ if (facename.Find("Serif") != FX_STRNPOS)
pInfo->m_Styles |= FXFONT_SERIF;
m_FontList[facename] = std::move(pInfo);
@@ -289,7 +289,7 @@ void* CFX_FolderFontInfo::FindFont(int weight,
continue;
int32_t index = bsName.Find(family);
- if (bMatchName && index < 0)
+ if (bMatchName && index == FX_STRNPOS)
continue;
int32_t iSimilarValue =
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index a8e271dd9a..1fd08f2676 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -447,7 +447,7 @@ bool CFX_Font::IsItalic() const {
CFX_ByteString str(FXFT_Get_Face_Style_Name(m_Face));
str.MakeLower();
- return str.Find("italic") != -1;
+ return str.Find("italic") != FX_STRNPOS;
}
bool CFX_Font::IsBold() const {
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index 4c0073ab73..b8ffe047a3 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -172,7 +172,7 @@ const struct CODEPAGE_MAP {
int CompareFontFamilyString(const void* key, const void* element) {
CFX_ByteString str_key((const char*)key);
const AltFontFamily* family = reinterpret_cast<const AltFontFamily*>(element);
- if (str_key.Find(family->m_pFontName) != -1)
+ if (str_key.Find(family->m_pFontName) != FX_STRNPOS)
return 0;
return FXSYS_stricmp(reinterpret_cast<const char*>(key), family->m_pFontName);
}
@@ -187,8 +187,8 @@ CFX_ByteString TT_NormalizeName(const char* family) {
norm.Remove(' ');
norm.Remove('-');
norm.Remove(',');
- int pos = norm.Find('+');
- if (pos > 0)
+ FX_STRSIZE pos = norm.Find('+');
+ if (pos != 0 && pos != FX_STRNPOS)
norm = norm.Left(pos);
norm.MakeLower();
return norm;
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 279e720d1e..310a16512c 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -337,7 +337,7 @@ bool ShouldDrawDeviceText(const CFX_Font* pFont, uint32_t text_flags) {
return false;
const CFX_ByteString bsPsName = pFont->GetPsName();
- if (bsPsName.Find("+ZJHL") != -1)
+ if (bsPsName.Find("+ZJHL") != FX_STRNPOS)
return false;
if (bsPsName == "CNAAJI+cmex10")
diff --git a/core/fxge/fx_ge_linux.cpp b/core/fxge/fx_ge_linux.cpp
index d9fac3f54c..0552f1c58c 100644
--- a/core/fxge/fx_ge_linux.cpp
+++ b/core/fxge/fx_ge_linux.cpp
@@ -45,17 +45,18 @@ size_t GetJapanesePreference(const char* facearr,
int weight,
int pitch_family) {
CFX_ByteString face = facearr;
- if (face.Find("Gothic") >= 0 ||
- face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) {
- if (face.Find("PGothic") >= 0 ||
- face.Find("\x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) {
+ if (face.Find("Gothic") != FX_STRNPOS ||
+ face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e") != FX_STRNPOS) {
+ if (face.Find("PGothic") != FX_STRNPOS ||
+ face.Find("\x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e") != FX_STRNPOS) {
return 0;
}
return 1;
}
- if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
- if (face.Find("PMincho") >= 0 ||
- face.Find("\x82\x6f\x96\xbe\x92\xa9") >= 0) {
+ if (face.Find("Mincho") != FX_STRNPOS ||
+ face.Find("\x96\xbe\x92\xa9") != FX_STRNPOS) {
+ if (face.Find("PMincho") != FX_STRNPOS ||
+ face.Find("\x82\x6f\x96\xbe\x92\xa9") != FX_STRNPOS) {
return 2;
}
return 3;
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index 4427755cf5..b707a76c08 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -503,7 +503,7 @@ void* CFX_Win32FallbackFontInfo::MapFont(int weight,
void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face,
int weight,
int picth_family) {
- if (face.Find("KaiTi") >= 0 || face.Find("\xbf\xac") >= 0) {
+ if (face.Find("KaiTi") != FX_STRNPOS || face.Find("\xbf\xac") != FX_STRNPOS) {
if (m_KaiTi.IsEmpty()) {
m_KaiTi = FindFont("KaiTi");
if (m_KaiTi.IsEmpty()) {
@@ -511,7 +511,8 @@ void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face,
}
}
face = m_KaiTi;
- } else if (face.Find("FangSong") >= 0 || face.Find("\xb7\xc2\xcb\xce") >= 0) {
+ } else if (face.Find("FangSong") != FX_STRNPOS ||
+ face.Find("\xb7\xc2\xcb\xce") != FX_STRNPOS) {
if (m_FangSong.IsEmpty()) {
m_FangSong = FindFont("FangSong");
if (m_FangSong.IsEmpty()) {
@@ -519,9 +520,11 @@ void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face,
}
}
face = m_FangSong;
- } else if (face.Find("SimSun") >= 0 || face.Find("\xcb\xce") >= 0) {
+ } else if (face.Find("SimSun") != FX_STRNPOS ||
+ face.Find("\xcb\xce") != FX_STRNPOS) {
face = "SimSun";
- } else if (face.Find("SimHei") >= 0 || face.Find("\xba\xda") >= 0) {
+ } else if (face.Find("SimHei") != FX_STRNPOS ||
+ face.Find("\xba\xda") != FX_STRNPOS) {
face = "SimHei";
} else if (!(picth_family & FF_ROMAN) && weight > 550) {
face = "SimHei";
@@ -533,15 +536,16 @@ void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face,
void CFX_Win32FontInfo::GetJapanesePreference(CFX_ByteString& face,
int weight,
int picth_family) {
- if (face.Find("Gothic") >= 0 ||
- face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) {
- if (face.Find("PGothic") >= 0 ||
- face.Find("\x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) {
+ if (face.Find("Gothic") != FX_STRNPOS ||
+ face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e") != FX_STRNPOS) {
+ if (face.Find("PGothic") != FX_STRNPOS ||
+ face.Find("\x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e") != FX_STRNPOS) {
face = "MS PGothic";
- } else if (face.Find("UI Gothic") >= 0) {
+ } else if (face.Find("UI Gothic") != FX_STRNPOS) {
face = "MS UI Gothic";
} else {
- if (face.Find("HGSGothicM") >= 0 || face.Find("HGMaruGothicMPRO") >= 0) {
+ if (face.Find("HGSGothicM") != FX_STRNPOS ||
+ face.Find("HGMaruGothicMPRO") != FX_STRNPOS) {
face = "MS PGothic";
} else {
face = "MS Gothic";
@@ -549,9 +553,10 @@ void CFX_Win32FontInfo::GetJapanesePreference(CFX_ByteString& face,
}
return;
}
- if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
- if (face.Find("PMincho") >= 0 ||
- face.Find("\x82\x6f\x96\xbe\x92\xa9") >= 0) {
+ if (face.Find("Mincho") != FX_STRNPOS ||
+ face.Find("\x96\xbe\x92\xa9") != FX_STRNPOS) {
+ if (face.Find("PMincho") != FX_STRNPOS ||
+ face.Find("\x82\x6f\x96\xbe\x92\xa9") != FX_STRNPOS) {
face = "MS PMincho";
} else {
face = "MS Mincho";
@@ -635,7 +640,7 @@ void* CFX_Win32FontInfo::MapFont(int weight,
face = "Gulim";
break;
case FX_CHARSET_ChineseTraditional:
- if (face.Find("MSung") >= 0) {
+ if (face.Find("MSung") != FX_STRNPOS) {
face = "MingLiU";
} else {
face = "PMingLiU";
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp
index 02bf722462..f498917a19 100644
--- a/fpdfsdk/fpdfedittext.cpp
+++ b/fpdfsdk/fpdfedittext.cpp
@@ -39,7 +39,7 @@ CPDF_Dictionary* LoadFontDesc(CPDF_Document* pDoc,
int flags = 0;
if (FXFT_Is_Face_fixedwidth(pFont->GetFace()))
flags |= FXFONT_FIXED_PITCH;
- if (font_name.Find("Serif") > -1)
+ if (font_name.Find("Serif") != FX_STRNPOS)
flags |= FXFONT_SERIF;
if (FXFT_Is_Face_Italic(pFont->GetFace()))
flags |= FXFONT_ITALIC;
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index beab7d87d3..bf52932a1d 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -80,20 +80,20 @@ bool ParserPageRangeString(CFX_ByteString rangstring,
int nLength = rangstring.GetLength();
CFX_ByteString cbCompareString("0123456789-,");
for (int i = 0; i < nLength; ++i) {
- if (cbCompareString.Find(rangstring[i]) == -1)
+ if (cbCompareString.Find(rangstring[i]) == FX_STRNPOS)
return false;
}
CFX_ByteString cbMidRange;
- int nStringFrom = 0;
- int nStringTo = 0;
+ FX_STRSIZE nStringFrom = 0;
+ FX_STRSIZE nStringTo = 0;
while (nStringTo < nLength) {
nStringTo = rangstring.Find(',', nStringFrom);
- if (nStringTo == -1)
+ if (nStringTo == FX_STRNPOS)
nStringTo = nLength;
cbMidRange = rangstring.Mid(nStringFrom, nStringTo - nStringFrom);
- int nMid = cbMidRange.Find('-');
- if (nMid == -1) {
+ FX_STRSIZE nMid = cbMidRange.Find('-');
+ if (nMid == FX_STRNPOS) {
long lPageNum = atol(cbMidRange.c_str());
if (lPageNum <= 0 || lPageNum > nCount)
return false;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index 052bed55d2..7cccd2fb11 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -809,19 +809,19 @@ bool CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
void CPDFXFA_DocEnvironment::ToXFAContentFlags(CFX_WideString csSrcContent,
FPDF_DWORD& flag) {
- if (csSrcContent.Find(L" config ", 0) != -1)
+ if (csSrcContent.Find(L" config ", 0) != FX_STRNPOS)
flag |= FXFA_CONFIG;
- if (csSrcContent.Find(L" template ", 0) != -1)
+ if (csSrcContent.Find(L" template ", 0) != FX_STRNPOS)
flag |= FXFA_TEMPLATE;
- if (csSrcContent.Find(L" localeSet ", 0) != -1)
+ if (csSrcContent.Find(L" localeSet ", 0) != FX_STRNPOS)
flag |= FXFA_LOCALESET;
- if (csSrcContent.Find(L" datasets ", 0) != -1)
+ if (csSrcContent.Find(L" datasets ", 0) != FX_STRNPOS)
flag |= FXFA_DATASETS;
- if (csSrcContent.Find(L" xmpmeta ", 0) != -1)
+ if (csSrcContent.Find(L" xmpmeta ", 0) != FX_STRNPOS)
flag |= FXFA_XMPMETA;
- if (csSrcContent.Find(L" xfdf ", 0) != -1)
+ if (csSrcContent.Find(L" xfdf ", 0) != FX_STRNPOS)
flag |= FXFA_XFDF;
- if (csSrcContent.Find(L" form ", 0) != -1)
+ if (csSrcContent.Find(L" form ", 0) != FX_STRNPOS)
flag |= FXFA_FORM;
if (flag == 0) {
flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
@@ -840,11 +840,11 @@ bool CPDFXFA_DocEnvironment::MailToInfo(CFX_WideString& csURL,
if (srcURL.Left(7).CompareNoCase(L"mailto:") != 0)
return false;
- int pos = srcURL.Find(L'?', 0);
+ FX_STRSIZE pos = srcURL.Find(L'?', 0);
CFX_WideString tmp;
- if (pos == -1) {
+ if (pos == FX_STRNPOS) {
pos = srcURL.Find(L'@', 0);
- if (pos == -1)
+ if (pos == FX_STRNPOS)
return false;
tmp = srcURL.Right(csURL.GetLength() - 7);
@@ -863,7 +863,7 @@ bool CPDFXFA_DocEnvironment::MailToInfo(CFX_WideString& csURL,
srcURL.TrimRight();
pos = srcURL.Find(L'&', 0);
- tmp = (pos == -1) ? srcURL : srcURL.Left(pos);
+ tmp = (pos == FX_STRNPOS) ? srcURL : srcURL.Left(pos);
tmp.TrimLeft();
tmp.TrimRight();
if (tmp.GetLength() >= 3 && tmp.Left(3).CompareNoCase(L"cc=") == 0) {
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 06ed64c7cc..f5d3c68780 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -526,7 +526,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value,
CFX_WideString sFullMonths = fullmonths[m];
sFullMonths.MakeLower();
- if (sFullMonths.Find(sMonth.c_str(), 0) != -1) {
+ if (sFullMonths.Find(sMonth.c_str(), 0) != FX_STRNPOS) {
nMonth = m + 1;
i += 4;
j += nSkip;
@@ -932,7 +932,8 @@ bool CJS_PublicMethods::AFNumber_Keystroke(CJS_Runtime* pRuntime,
pEvent->SelEnd() - pEvent->SelStart());
}
- bool bHasSign = wstrValue.Find(L'-') != -1 && wstrSelected.Find(L'-') == -1;
+ bool bHasSign = wstrValue.Find(L'-') != FX_STRNPOS &&
+ wstrSelected.Find(L'-') == FX_STRNPOS;
if (bHasSign) {
// can't insert "change" in front to sign postion.
if (pEvent->SelStart() == 0) {
@@ -946,7 +947,7 @@ bool CJS_PublicMethods::AFNumber_Keystroke(CJS_Runtime* pRuntime,
iSepStyle = 0;
const wchar_t cSep = iSepStyle < 2 ? L'.' : L',';
- bool bHasSep = wstrValue.Find(cSep) != -1;
+ bool bHasSep = wstrValue.Find(cSep) != FX_STRNPOS;
for (FX_STRSIZE i = 0; i < wstrChange.GetLength(); ++i) {
if (wstrChange[i] == cSep) {
if (bHasSep) {
@@ -1111,7 +1112,7 @@ bool CJS_PublicMethods::AFDate_FormatEx(CJS_Runtime* pRuntime,
CFX_WideString sFormat = params[0].ToCFXWideString(pRuntime);
double dDate = 0.0f;
- if (strValue.Find(L"GMT") != -1) {
+ if (strValue.Find(L"GMT") != FX_STRNPOS) {
// for GMT format time
// such as "Tue Aug 11 14:24:16 GMT+08002009"
dDate = MakeInterDate(strValue);
diff --git a/fxbarcode/oned/BC_OneDimWriter.cpp b/fxbarcode/oned/BC_OneDimWriter.cpp
index 22cc09513f..cc0a6e5546 100644
--- a/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -280,7 +280,7 @@ bool CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device,
FXFILL_WINDING);
}
- return m_locTextLoc == BC_TEXT_LOC_NONE || contents.Find(' ') == -1 ||
+ return m_locTextLoc == BC_TEXT_LOC_NONE || contents.Find(' ') == FX_STRNPOS ||
ShowChars(contents, device, matrix, m_barWidth, m_multiple);
}
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp
index f07cce8fd2..d940247385 100644
--- a/xfa/fgas/crt/cfgas_formatstring.cpp
+++ b/xfa/fgas/crt/cfgas_formatstring.cpp
@@ -191,7 +191,7 @@ bool GetNumericDotIndex(const CFX_WideString& wsNum,
ccf++;
}
*iDotIndex = wsNum.Find('.');
- if (*iDotIndex >= 0)
+ if (*iDotIndex != FX_STRNPOS)
return true;
*iDotIndex = iLenf;
@@ -249,7 +249,7 @@ bool ParseLocaleDate(const CFX_WideString& wsDate,
*cc += iLiteralLen;
ccf++;
continue;
- } else if (wsDateSymbols.Find(strf[ccf]) == -1) {
+ } else if (wsDateSymbols.Find(strf[ccf]) == FX_STRNPOS) {
if (strf[ccf] != str[*cc])
return false;
(*cc)++;
@@ -370,7 +370,7 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
ccf++;
continue;
}
- if (wsTimeSymbols.Find(strf[ccf]) == -1) {
+ if (wsTimeSymbols.Find(strf[ccf]) == FX_STRNPOS) {
if (strf[ccf] != str[*cc])
return false;
(*cc)++;
@@ -577,7 +577,7 @@ CFX_WideString DateFormat(const CFX_WideString& wsDatePattern,
ccf++;
continue;
}
- if (wsDateSymbols.Find(strf[ccf]) == -1) {
+ if (wsDateSymbols.Find(strf[ccf]) == FX_STRNPOS) {
wsResult += strf[ccf++];
continue;
}
@@ -635,7 +635,7 @@ CFX_WideString TimeFormat(const CFX_WideString& wsTimePattern,
int32_t lenf = wsTimePattern.GetLength();
uint16_t wHour = hour;
bool bPM = false;
- if (wsTimePattern.Find('A') != -1) {
+ if (wsTimePattern.Find('A') != FX_STRNPOS) {
if (wHour >= 12)
bPM = true;
}
@@ -647,7 +647,7 @@ CFX_WideString TimeFormat(const CFX_WideString& wsTimePattern,
ccf++;
continue;
}
- if (wsTimeSymbols.Find(strf[ccf]) == -1) {
+ if (wsTimeSymbols.Find(strf[ccf]) == FX_STRNPOS) {
wsResult += strf[ccf++];
continue;
}
@@ -874,7 +874,7 @@ FX_LOCALECATEGORY CFGAS_FormatString::GetCategory(
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
GetLiteralText(pStr, &ccf, iLenf);
- } else if (!bBraceOpen && wsConstChars.Find(pStr[ccf]) == -1) {
+ } else if (!bBraceOpen && wsConstChars.Find(pStr[ccf]) == FX_STRNPOS) {
CFX_WideString wsCategory(pStr[ccf]);
ccf++;
while (true) {
@@ -932,7 +932,7 @@ CFX_WideString CFGAS_FormatString::GetTextFormat(
int32_t iCurChar = ccf;
GetLiteralText(pStr, &ccf, iLenf);
wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1);
- } else if (!bBrackOpen && wsConstChars.Find(pStr[ccf]) == -1) {
+ } else if (!bBrackOpen && wsConstChars.Find(pStr[ccf]) == FX_STRNPOS) {
CFX_WideString wsSearchCategory(pStr[ccf]);
ccf++;
while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' &&
@@ -984,7 +984,7 @@ IFX_Locale* CFGAS_FormatString::GetNumericFormat(
int32_t iCurChar = ccf;
GetLiteralText(pStr, &ccf, iLenf);
*wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1);
- } else if (!bBrackOpen && wsConstChars.Find(pStr[ccf]) == -1) {
+ } else if (!bBrackOpen && wsConstChars.Find(pStr[ccf]) == FX_STRNPOS) {
CFX_WideString wsCategory(pStr[ccf]);
ccf++;
while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' &&
@@ -1031,7 +1031,7 @@ IFX_Locale* CFGAS_FormatString::GetNumericFormat(
wsSubCategory = pLocale->GetNumPattern(eSubCategory);
*iDotIndex = wsSubCategory.Find('.');
- if (*iDotIndex > 0) {
+ if (*iDotIndex != 0 && *iDotIndex != FX_STRNPOS) {
*iDotIndex += wsPurgePattern->GetLength();
bFindDot = true;
*dwStyle |= FX_NUMSTYLE_DotVorv;
@@ -1570,7 +1570,7 @@ FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat(
GetLiteralText(pStr, &ccf, iLenf);
wsTempPattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1);
} else if (!bBraceOpen && iFindCategory != 3 &&
- wsConstChars.Find(pStr[ccf]) == -1) {
+ wsConstChars.Find(pStr[ccf]) == FX_STRNPOS) {
CFX_WideString wsCategory(pStr[ccf]);
ccf++;
while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' &&
@@ -1951,7 +1951,7 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
const wchar_t* str = wsSrcNum.c_str();
int len = wsSrcNum.GetLength();
int dot_index = wsSrcNum.Find('.');
- if (dot_index == -1)
+ if (dot_index == FX_STRNPOS)
dot_index = len;
ccf = dot_index_f - 1;
@@ -2282,7 +2282,7 @@ bool CFGAS_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime,
CFX_DateTime dt;
int32_t iT = wsSrcDateTime.Find(L"T");
- if (iT < 0) {
+ if (iT == FX_STRNPOS) {
if (eCategory == FX_DATETIMETYPE_Date &&
FX_DateFromCanonical(wsSrcDateTime, &dt)) {
*wsOutput = FormatDateTimeInternal(dt, wsDatePattern, wsTimePattern, true,
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 6f86c7ca07..813a91dc63 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -1267,7 +1267,7 @@ void CFGAS_FontMgr::GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB) {
int32_t CFGAS_FontMgr::IsPartName(const CFX_WideString& Name1,
const CFX_WideString& Name2) {
- if (Name1.Find(Name2.c_str()) != -1)
+ if (Name1.Find(Name2.c_str()) != FX_STRNPOS)
return 1;
return 0;
}
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 8d1ec2338a..ff20188a92 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -279,7 +279,7 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
wsValidateStr = pValidateNode->GetContent();
}
- if (wsValidateStr.Find(L"preSubmit") == -1)
+ if (wsValidateStr.Find(L"preSubmit") == FX_STRNPOS)
return XFA_EVENTERROR_Success;
}
diff --git a/xfa/fxfa/cxfa_pdffontmgr.cpp b/xfa/fxfa/cxfa_pdffontmgr.cpp
index 77c4433f98..6e7a2ede4b 100644
--- a/xfa/fxfa/cxfa_pdffontmgr.cpp
+++ b/xfa/fxfa/cxfa_pdffontmgr.cpp
@@ -120,9 +120,9 @@ bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName,
bool bStrictMatch) {
CFX_ByteString bsDRName = bsDRFontName;
bsDRName.Remove('-');
- int32_t iPsLen = bsPsName.GetLength();
- int32_t nIndex = bsDRName.Find(bsPsName);
- if (nIndex != -1 && !bStrictMatch)
+ FX_STRSIZE iPsLen = bsPsName.GetLength();
+ FX_STRSIZE nIndex = bsDRName.Find(bsPsName);
+ if (nIndex != FX_STRNPOS && !bStrictMatch)
return true;
if (nIndex != 0)
@@ -130,8 +130,8 @@ bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName,
int32_t iDifferLength = bsDRName.GetLength() - iPsLen;
if (iDifferLength > 1 || (bBold || bItalic)) {
- int32_t iBoldIndex = bsDRName.Find("Bold");
- bool bBoldFont = iBoldIndex > 0;
+ FX_STRSIZE iBoldIndex = bsDRName.Find("Bold");
+ bool bBoldFont = iBoldIndex != FX_STRNPOS;
if (bBold != bBoldFont)
return false;
@@ -140,11 +140,11 @@ bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName,
std::min(iDifferLength - 4, bsDRName.GetLength() - iBoldIndex - 4);
}
bool bItalicFont = true;
- if (bsDRName.Find("Italic") > 0) {
+ if (bsDRName.Find("Italic") != FX_STRNPOS) {
iDifferLength -= 6;
- } else if (bsDRName.Find("It") > 0) {
+ } else if (bsDRName.Find("It") != FX_STRNPOS) {
iDifferLength -= 2;
- } else if (bsDRName.Find("Oblique") > 0) {
+ } else if (bsDRName.Find("Oblique") != FX_STRNPOS) {
iDifferLength -= 7;
} else {
bItalicFont = false;
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index 84064efb45..9028642b76 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -374,7 +374,8 @@ bool PatternStringType(const CFX_ByteStringC& szPattern,
return true;
}
if (L"date" == wsPattern.Left(4)) {
- patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE;
+ FX_STRSIZE ret = wsPattern.Find(L"time");
+ patternType = ret != 0 && ret != FX_STRNPOS ? XFA_VT_DATETIME : XFA_VT_DATE;
return true;
}
if (L"time" == wsPattern.Left(4)) {
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 49a1f5857b..ff9e981e9f 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -225,10 +225,10 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
break;
std::vector<CFX_WideString> wsSelTextArray;
- int32_t iStart = 0;
- int32_t iEnd = wsRawValue.Find(L'\n', iStart);
- iEnd = (iEnd == -1) ? wsRawValue.GetLength() : iEnd;
- while (iEnd >= iStart) {
+ FX_STRSIZE iStart = 0;
+ FX_STRSIZE iEnd = wsRawValue.Find(L'\n', iStart);
+ iEnd = (iEnd == FX_STRNPOS) ? wsRawValue.GetLength() : iEnd;
+ while (iEnd != FX_STRNPOS && iEnd >= iStart) {
wsSelTextArray.push_back(wsRawValue.Mid(iStart, iEnd - iStart));
iStart = iEnd + 1;
if (iStart >= wsRawValue.GetLength())
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index 16b999b9e3..f43deaf145 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -306,7 +306,7 @@ XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber(
return XFA_VERSION_UNKNOWN;
}
FX_STRSIZE nDotPos = wsTemplateNS.Find('.', nPrefixLength);
- if (nDotPos == (FX_STRSIZE)-1)
+ if (nDotPos == FX_STRNPOS)
return XFA_VERSION_UNKNOWN;
int8_t iMajor = FXSYS_wtoi(
@@ -368,7 +368,7 @@ void CXFA_Document::DoProtoMerge() {
if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) &&
!wsUseVal.IsEmpty()) {
FX_STRSIZE uSharpPos = wsUseVal.Find('#');
- if (uSharpPos < 0) {
+ if (uSharpPos == FX_STRNPOS) {
wsURI = wsUseVal.AsStringC();
} else {
wsURI = CFX_WideStringC(wsUseVal.c_str(), uSharpPos);
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index 4d6886d7e1..55851bb34a 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -148,9 +148,10 @@ CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
bool bTargetAllFind = true;
while (iSplitIndex != -1) {
CFX_WideString wsExpr;
- int32_t iSplitNextIndex = 0;
+ FX_STRSIZE iSplitNextIndex = 0;
if (!bTargetAllFind) {
iSplitNextIndex = wsTargetAll.Find(' ', iSplitIndex);
+ ASSERT(iSplitNextIndex != FX_STRNPOS);
wsExpr = wsTargetAll.Mid(iSplitIndex, iSplitNextIndex - iSplitIndex);
} else {
wsExpr = wsTargetAll;
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index 5b5c27f1d4..aa0f74b170 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -49,10 +49,10 @@ bool ValueSplitDateTime(const CFX_WideString& wsDateTime,
if (wsDateTime.IsEmpty())
return false;
- int nSplitIndex = wsDateTime.Find('T');
- if (nSplitIndex < 0)
+ FX_STRSIZE nSplitIndex = wsDateTime.Find('T');
+ if (nSplitIndex == FX_STRNPOS)
nSplitIndex = wsDateTime.Find(' ');
- if (nSplitIndex < 0)
+ if (nSplitIndex == FX_STRNPOS)
return false;
wsDate = wsDateTime.Left(nSplitIndex);
@@ -444,7 +444,7 @@ bool CXFA_LocaleValue::ValidateCanonicalDate(const CFX_WideString& wsDate,
if (nLen < wCountY || nLen > wCountY + wCountM + wCountD + 2)
return false;
- const bool bSymbol = wsDate.Find(0x2D) != -1;
+ const bool bSymbol = wsDate.Find(0x2D) != FX_STRNPOS;
uint16_t wYear = 0;
uint16_t wMonth = 0;
uint16_t wDay = 0;
@@ -519,7 +519,7 @@ bool CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) {
const uint16_t wCountM = 2;
const uint16_t wCountS = 2;
const uint16_t wCountF = 3;
- const bool bSymbol = wsTime.Find(':') != -1;
+ const bool bSymbol = wsTime.Find(':') != FX_STRNPOS;
uint16_t wHour = 0;
uint16_t wMinute = 0;
uint16_t wSecond = 0;
@@ -558,7 +558,8 @@ bool CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) {
wSecond = pTime[nIndex] - '0' + wSecond * 10;
nIndex++;
}
- if (wsTime.Find('.') > 0) {
+ FX_STRSIZE ret = wsTime.Find('.');
+ if (ret && ret != FX_STRNPOS) {
if (pTime[nIndex] != '.')
return false;
nIndex++;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 261fee1971..8497e60a74 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -4043,10 +4043,10 @@ bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
std::vector<CFX_WideString> wsSaveTextArray;
size_t iSize = 0;
if (!wsContent.IsEmpty()) {
- int32_t iStart = 0;
- int32_t iLength = wsContent.GetLength();
- int32_t iEnd = wsContent.Find(L'\n', iStart);
- iEnd = (iEnd == -1) ? iLength : iEnd;
+ FX_STRSIZE iStart = 0;
+ FX_STRSIZE iLength = wsContent.GetLength();
+ FX_STRSIZE iEnd = wsContent.Find(L'\n', iStart);
+ iEnd = (iEnd == FX_STRNPOS) ? iLength : iEnd;
while (iEnd >= iStart) {
wsSaveTextArray.push_back(wsContent.Mid(iStart, iEnd - iStart));
iStart = iEnd + 1;
@@ -4054,7 +4054,7 @@ bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
break;
}
iEnd = wsContent.Find(L'\n', iStart);
- if (iEnd < 0) {
+ if (iEnd == FX_STRNPOS) {
wsSaveTextArray.push_back(
wsContent.Mid(iStart, iLength - iStart));
}
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 1b5cccf101..39dc858b9e 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -93,7 +93,7 @@ bool GetAttributeLocalName(const CFX_WideStringC& wsAttributeName,
CFX_WideString& wsLocalAttrName) {
CFX_WideString wsAttrName(wsAttributeName);
FX_STRSIZE iFind = wsAttrName.Find(L':', 0);
- if (iFind < 0) {
+ if (iFind == FX_STRNPOS) {
wsLocalAttrName = wsAttrName;
return false;
}
@@ -135,7 +135,7 @@ bool FindAttributeWithNS(CFX_XMLElement* pElement,
for (auto it : pElement->GetAttributes()) {
FX_STRSIZE iFind = it.first.Find(L':', 0);
CFX_WideString wsNSPrefix;
- if (iFind < 0) {
+ if (iFind == FX_STRNPOS) {
if (wsLocalAttributeName != it.first)
continue;
} else {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 5efc0ea481..34e3aeaf0f 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -42,11 +42,10 @@ bool SplitDateTime(const CFX_WideString& wsDateTime,
if (wsDateTime.IsEmpty())
return false;
- int nSplitIndex = -1;
- nSplitIndex = wsDateTime.Find('T');
- if (nSplitIndex < 0)
+ FX_STRSIZE nSplitIndex = wsDateTime.Find('T');
+ if (nSplitIndex == FX_STRNPOS)
nSplitIndex = wsDateTime.Find(' ');
- if (nSplitIndex < 0)
+ if (nSplitIndex == FX_STRNPOS)
return false;
wsDate = wsDateTime.Left(nSplitIndex);
@@ -848,17 +847,17 @@ std::vector<CFX_WideString> CXFA_WidgetData::GetSelectedItemsValue() {
CFX_WideString wsValue = GetRawValue();
if (GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
if (!wsValue.IsEmpty()) {
- int32_t iStart = 0;
- int32_t iLength = wsValue.GetLength();
- int32_t iEnd = wsValue.Find(L'\n', iStart);
- iEnd = (iEnd == -1) ? iLength : iEnd;
+ FX_STRSIZE iStart = 0;
+ FX_STRSIZE iLength = wsValue.GetLength();
+ FX_STRSIZE iEnd = wsValue.Find(L'\n', iStart);
+ iEnd = (iEnd == FX_STRNPOS) ? iLength : iEnd;
while (iEnd >= iStart) {
wsSelTextArray.push_back(wsValue.Mid(iStart, iEnd - iStart));
iStart = iEnd + 1;
if (iStart >= iLength)
break;
iEnd = wsValue.Find(L'\n', iStart);
- if (iEnd < 0)
+ if (iEnd == FX_STRNPOS)
wsSelTextArray.push_back(wsValue.Mid(iStart, iLength - iStart));
}
}
@@ -1318,7 +1317,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(float* val) {
if (pUIChild->TryCData(XFA_ATTRIBUTE_WideNarrowRatio, wsWideNarrowRatio)) {
FX_STRSIZE ptPos = wsWideNarrowRatio.Find(':');
float fRatio = 0;
- if (ptPos >= 0) {
+ if (ptPos != FX_STRNPOS) {
fRatio = (float)FXSYS_wtoi(wsWideNarrowRatio.c_str());
} else {
int32_t fA, fB;
@@ -1743,9 +1742,9 @@ void CXFA_WidgetData::NormalizeNumStr(const CFX_WideString& wsValue,
wsOutput = wsValue;
wsOutput.TrimLeft('0');
- int32_t dot_index = wsOutput.Find('.');
+ FX_STRSIZE dot_index = wsOutput.Find('.');
int32_t iFracDigits = 0;
- if (!wsOutput.IsEmpty() && dot_index >= 0 &&
+ if (!wsOutput.IsEmpty() && dot_index != FX_STRNPOS &&
(!GetFracDigits(iFracDigits) || iFracDigits != -1)) {
wsOutput.TrimRight(L"0");
wsOutput.TrimRight(L".");
@@ -1769,8 +1768,8 @@ void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
wsSrcNum.Delete(0, 1);
}
int32_t len = wsSrcNum.GetLength();
- int32_t dot_index = wsSrcNum.Find('.');
- if (dot_index == -1)
+ FX_STRSIZE dot_index = wsSrcNum.Find('.');
+ if (dot_index == FX_STRNPOS)
dot_index = len;
int32_t cc = dot_index - 1;