Rename Mid() to Substr() in {Byte,Wide}String{,View} classes
Bug: pdfium:1406
Change-Id: I6bef1a83655bcd031e58b209539b865d5a5b4f68
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/65610
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index 58973d0..96bf30b 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -215,8 +215,9 @@
EXPECT_EQ(" gs 1 0 0 1 0 0 cm 1 2 m 3 4 l 5 6 l h B Q\n",
pathString.Right(43));
ASSERT_GT(pathString.GetLength(), 91U);
- CPDF_Dictionary* externalGS = TestGetResource(
- &generator, "ExtGState", pathString.Mid(48, pathString.GetLength() - 91));
+ CPDF_Dictionary* externalGS =
+ TestGetResource(&generator, "ExtGState",
+ pathString.Substr(48, pathString.GetLength() - 91));
ASSERT_TRUE(externalGS);
EXPECT_EQ(0.5f, externalGS->GetNumberFor("ca"));
EXPECT_EQ(0.8f, externalGS->GetNumberFor("CA"));
@@ -233,8 +234,8 @@
// Compare with the previous (should use same dictionary for gs)
EXPECT_EQ(pathString.GetLength() + 7, pathString2.GetLength());
- EXPECT_EQ(pathString.Mid(48, pathString.GetLength() - 76),
- pathString2.Mid(55, pathString2.GetLength() - 83));
+ EXPECT_EQ(pathString.Substr(48, pathString.GetLength() - 76),
+ pathString2.Substr(55, pathString2.GetLength() - 83));
}
TEST_F(CPDF_PageContentGeneratorTest, ProcessStandardText) {
@@ -274,8 +275,8 @@
secondResourceAt = secondResourceAt.value() + 1;
ByteString firstString = textString.Left(firstResourceAt.value());
ByteString midString =
- textString.Mid(firstResourceAt.value(),
- secondResourceAt.value() - firstResourceAt.value());
+ textString.Substr(firstResourceAt.value(),
+ secondResourceAt.value() - firstResourceAt.value());
ByteString lastString =
textString.Right(textString.GetLength() - secondResourceAt.value());
// q and Q must be outside the BT .. ET operations
@@ -357,9 +358,9 @@
EXPECT_EQ(compareString2, textString.Right(compareString2.GetLength()));
CPDF_Dictionary* fontDict = TestGetResource(
&generator, "Font",
- textString.Mid(compareString1.GetLength(),
- textString.GetLength() - compareString1.GetLength() -
- compareString2.GetLength()));
+ textString.Substr(compareString1.GetLength(),
+ textString.GetLength() - compareString1.GetLength() -
+ compareString2.GetLength()));
ASSERT_TRUE(fontDict);
EXPECT_TRUE(fontDict->GetObjNum());
EXPECT_EQ("Font", fontDict->GetStringFor("Type"));
diff --git a/core/fpdfapi/font/cpdf_tounicodemap.cpp b/core/fpdfapi/font/cpdf_tounicodemap.cpp
index 2bd5798..1872d5d 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap.cpp
+++ b/core/fpdfapi/font/cpdf_tounicodemap.cpp
@@ -60,7 +60,7 @@
size_t index = value >> 16;
if (!buf.IsValidIndex(index))
return WideString();
- return WideString(buf.Mid(index + 1, buf[index]));
+ return WideString(buf.Substr(index + 1, buf[index]));
}
uint32_t CPDF_ToUnicodeMap::ReverseLookup(wchar_t unicode) const {
@@ -78,7 +78,7 @@
return pdfium::nullopt;
FX_SAFE_UINT32 code = 0;
- for (char c : str.Mid(1, len - 2)) {
+ for (char c : str.Substr(1, len - 2)) {
if (!FXSYS_IsHexDigit(c))
return pdfium::nullopt;
@@ -98,7 +98,7 @@
WideString result;
int byte_pos = 0;
wchar_t ch = 0;
- for (char c : str.Mid(1, len - 2)) {
+ for (char c : str.Substr(1, len - 2)) {
if (!FXSYS_IsHexDigit(c))
break;
diff --git a/core/fpdftext/cpdf_linkextract.cpp b/core/fpdftext/cpdf_linkextract.cpp
index 6ac5f98..3a1e31f 100644
--- a/core/fpdftext/cpdf_linkextract.cpp
+++ b/core/fpdftext/cpdf_linkextract.cpp
@@ -141,7 +141,7 @@
continue;
}
- WideString strBeCheck = page_text.Mid(start, nCount);
+ WideString strBeCheck = page_text.Substr(start, nCount);
if (bLineBreak) {
strBeCheck.Remove(L'\n');
strBeCheck.Remove(L'\r');
@@ -205,7 +205,7 @@
if (end > off) { // Non-empty host name.
*nStart = start.value();
*nCount = end - start.value() + 1;
- *strBeCheck = strBeCheck->Mid(*nStart, *nCount);
+ *strBeCheck = strBeCheck->Substr(*nStart, *nCount);
return true;
}
}
@@ -221,7 +221,7 @@
if (end > start.value() + kWWWAddrStartLen) {
*nStart = start.value();
*nCount = end - start.value() + 1;
- *strBeCheck = L"http://" + strBeCheck->Mid(*nStart, *nCount);
+ *strBeCheck = L"http://" + strBeCheck->Substr(*nStart, *nCount);
return true;
}
}
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 677b5d2..8c79208 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -486,7 +486,7 @@
int text_count = text_last - text_start + 1;
- return WideString(m_TextBuf.AsStringView().Mid(text_start, text_count));
+ return WideString(m_TextBuf.AsStringView().Substr(text_start, text_count));
}
int CPDF_TextPage::CountRects(int start, int nCount) {
diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp
index 6fd179b..a821de0 100644
--- a/core/fpdftext/cpdf_textpagefind.cpp
+++ b/core/fpdftext/cpdf_textpagefind.cpp
@@ -139,7 +139,7 @@
size_t pos = 0;
while (pos < word->GetLength()) {
- WideString curStr = word->Mid(pos, 1);
+ WideString curStr = word->Substr(pos, 1);
wchar_t curChar = (*word)[pos];
if (IsIgnoreSpaceCharacter(curChar)) {
if (pos > 0 && curChar == 0x2019) {
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 8b07981..a353064 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -469,7 +469,7 @@
return m_pData ? m_pData->m_nRefs : 0;
}
-ByteString ByteString::Mid(size_t first, size_t count) const {
+ByteString ByteString::Substr(size_t first, size_t count) const {
if (!m_pData)
return ByteString();
@@ -493,13 +493,13 @@
ByteString ByteString::Left(size_t count) const {
if (count == 0 || !IsValidLength(count))
return ByteString();
- return Mid(0, count);
+ return Substr(0, count);
}
ByteString ByteString::Right(size_t count) const {
if (count == 0 || !IsValidLength(count))
return ByteString();
- return Mid(GetLength() - count, count);
+ return Substr(GetLength() - count, count);
}
void ByteString::AllocCopy(ByteString& dest,
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index 11c372b..c7d09aa 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -163,7 +163,7 @@
pdfium::span<char> GetBuffer(size_t nMinBufLength);
void ReleaseBuffer(size_t nNewLength);
- ByteString Mid(size_t first, size_t count) const;
+ ByteString Substr(size_t first, size_t count) const;
ByteString Left(size_t count) const;
ByteString Right(size_t count) const;
diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp
index d0eab1a..61b4ae1 100644
--- a/core/fxcrt/bytestring_unittest.cpp
+++ b/core/fxcrt/bytestring_unittest.cpp
@@ -603,27 +603,27 @@
EXPECT_EQ("", empty);
}
-TEST(ByteString, Mid) {
+TEST(ByteString, Substr) {
ByteString fred("FRED");
- EXPECT_EQ("", fred.Mid(0, 0));
- EXPECT_EQ("", fred.Mid(3, 0));
- EXPECT_EQ("FRED", fred.Mid(0, 4));
- EXPECT_EQ("RED", fred.Mid(1, 3));
- EXPECT_EQ("ED", fred.Mid(2, 2));
- EXPECT_EQ("D", fred.Mid(3, 1));
- EXPECT_EQ("F", fred.Mid(0, 1));
- EXPECT_EQ("R", fred.Mid(1, 1));
- EXPECT_EQ("E", fred.Mid(2, 1));
- EXPECT_EQ("D", fred.Mid(3, 1));
- EXPECT_EQ("FR", fred.Mid(0, 2));
- EXPECT_EQ("FRED", fred.Mid(0, 4));
- EXPECT_EQ("", fred.Mid(0, 10));
+ EXPECT_EQ("", fred.Substr(0, 0));
+ EXPECT_EQ("", fred.Substr(3, 0));
+ EXPECT_EQ("FRED", fred.Substr(0, 4));
+ EXPECT_EQ("RED", fred.Substr(1, 3));
+ EXPECT_EQ("ED", fred.Substr(2, 2));
+ EXPECT_EQ("D", fred.Substr(3, 1));
+ EXPECT_EQ("F", fred.Substr(0, 1));
+ EXPECT_EQ("R", fred.Substr(1, 1));
+ EXPECT_EQ("E", fred.Substr(2, 1));
+ EXPECT_EQ("D", fred.Substr(3, 1));
+ EXPECT_EQ("FR", fred.Substr(0, 2));
+ EXPECT_EQ("FRED", fred.Substr(0, 4));
+ EXPECT_EQ("", fred.Substr(0, 10));
- EXPECT_EQ("RED", fred.Mid(1, 3));
- EXPECT_EQ("", fred.Mid(4, 1));
+ EXPECT_EQ("RED", fred.Substr(1, 3));
+ EXPECT_EQ("", fred.Substr(4, 1));
ByteString empty;
- EXPECT_EQ("", empty.Mid(0, 0));
+ EXPECT_EQ("", empty.Substr(0, 0));
}
TEST(ByteString, Left) {
@@ -1260,34 +1260,34 @@
EXPECT_EQ(2u, result.value());
}
-TEST(ByteStringView, Mid) {
+TEST(ByteStringView, Substr) {
ByteStringView null_string;
- EXPECT_EQ(null_string, null_string.Mid(0, 1));
- EXPECT_EQ(null_string, null_string.Mid(1, 1));
+ EXPECT_EQ(null_string, null_string.Substr(0, 1));
+ EXPECT_EQ(null_string, null_string.Substr(1, 1));
ByteStringView empty_string("");
- EXPECT_EQ("", empty_string.Mid(0, 1));
- EXPECT_EQ("", empty_string.Mid(1, 1));
+ EXPECT_EQ("", empty_string.Substr(0, 1));
+ EXPECT_EQ("", empty_string.Substr(1, 1));
ByteStringView single_character("a");
- EXPECT_EQ("", single_character.Mid(0, 0));
- EXPECT_EQ(single_character, single_character.Mid(0, 1));
- EXPECT_EQ("", single_character.Mid(1, 0));
- EXPECT_EQ("", single_character.Mid(1, 1));
+ EXPECT_EQ("", single_character.Substr(0, 0));
+ EXPECT_EQ(single_character, single_character.Substr(0, 1));
+ EXPECT_EQ("", single_character.Substr(1, 0));
+ EXPECT_EQ("", single_character.Substr(1, 1));
ByteStringView longer_string("abcdef");
- EXPECT_EQ(longer_string, longer_string.Mid(0, 6));
- EXPECT_EQ("", longer_string.Mid(0, 187));
+ EXPECT_EQ(longer_string, longer_string.Substr(0, 6));
+ EXPECT_EQ("", longer_string.Substr(0, 187));
ByteStringView leading_substring("ab");
- EXPECT_EQ(leading_substring, longer_string.Mid(0, 2));
+ EXPECT_EQ(leading_substring, longer_string.Substr(0, 2));
ByteStringView middle_substring("bcde");
- EXPECT_EQ(middle_substring, longer_string.Mid(1, 4));
+ EXPECT_EQ(middle_substring, longer_string.Substr(1, 4));
ByteStringView trailing_substring("ef");
- EXPECT_EQ(trailing_substring, longer_string.Mid(4, 2));
- EXPECT_EQ("", longer_string.Mid(4, 3));
+ EXPECT_EQ(trailing_substring, longer_string.Substr(4, 2));
+ EXPECT_EQ("", longer_string.Substr(4, 3));
}
TEST(ByteStringView, TrimmedRight) {
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index 4a7c4a6..135b5a3 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -21,7 +21,7 @@
// An immutable string with caller-provided storage which must outlive the
// string itself. These are not necessarily nul-terminated, so that substring
-// extraction (via the Mid(), Left(), and Right() methods) is copy-free.
+// extraction (via the Substr(), Left(), and Right() methods) is copy-free.
//
// String view arguments should be passed by value, since they are small,
// rather than const-ref, even if they are not modified.
@@ -197,7 +197,7 @@
bool Contains(CharType ch) const { return Find(ch).has_value(); }
- StringViewTemplate Mid(size_t first, size_t count) const {
+ StringViewTemplate Substr(size_t first, size_t count) const {
if (!m_Span.data())
return StringViewTemplate();
@@ -216,13 +216,13 @@
StringViewTemplate Left(size_t count) const {
if (count == 0 || !IsValidLength(count))
return StringViewTemplate();
- return Mid(0, count);
+ return Substr(0, count);
}
StringViewTemplate Right(size_t count) const {
if (count == 0 || !IsValidLength(count))
return StringViewTemplate();
- return Mid(GetLength() - count, count);
+ return Substr(GetLength() - count, count);
}
StringViewTemplate TrimmedRight(CharType ch) const {
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index 8da9e8d..79fe3b0 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -694,7 +694,7 @@
return result;
}
-WideString WideString::Mid(size_t first, size_t count) const {
+WideString WideString::Substr(size_t first, size_t count) const {
if (!m_pData)
return WideString();
@@ -718,13 +718,13 @@
WideString WideString::Left(size_t count) const {
if (count == 0 || !IsValidLength(count))
return WideString();
- return Mid(0, count);
+ return Substr(0, count);
}
WideString WideString::Right(size_t count) const {
if (count == 0 || !IsValidLength(count))
return WideString();
- return Mid(GetLength() - count, count);
+ return Substr(GetLength() - count, count);
}
void WideString::AllocCopy(WideString& dest,
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index a9b10ce..10a86ba 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -150,7 +150,7 @@
int Compare(const WideString& str) const;
int CompareNoCase(const wchar_t* str) const;
- WideString Mid(size_t first, size_t count) const;
+ WideString Substr(size_t first, size_t count) const;
WideString Left(size_t count) const;
WideString Right(size_t count) const;
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index 8d25476..b71c937 100644
--- a/core/fxcrt/widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -611,27 +611,27 @@
EXPECT_EQ(L"", empty);
}
-TEST(WideString, Mid) {
+TEST(WideString, Substr) {
WideString fred(L"FRED");
- EXPECT_EQ(L"", fred.Mid(0, 0));
- EXPECT_EQ(L"", fred.Mid(3, 0));
- EXPECT_EQ(L"FRED", fred.Mid(0, 4));
- EXPECT_EQ(L"RED", fred.Mid(1, 3));
- EXPECT_EQ(L"ED", fred.Mid(2, 2));
- EXPECT_EQ(L"D", fred.Mid(3, 1));
- EXPECT_EQ(L"F", fred.Mid(0, 1));
- EXPECT_EQ(L"R", fred.Mid(1, 1));
- EXPECT_EQ(L"E", fred.Mid(2, 1));
- EXPECT_EQ(L"D", fred.Mid(3, 1));
- EXPECT_EQ(L"FR", fred.Mid(0, 2));
- EXPECT_EQ(L"FRED", fred.Mid(0, 4));
- EXPECT_EQ(L"", fred.Mid(0, 10));
+ EXPECT_EQ(L"", fred.Substr(0, 0));
+ EXPECT_EQ(L"", fred.Substr(3, 0));
+ EXPECT_EQ(L"FRED", fred.Substr(0, 4));
+ EXPECT_EQ(L"RED", fred.Substr(1, 3));
+ EXPECT_EQ(L"ED", fred.Substr(2, 2));
+ EXPECT_EQ(L"D", fred.Substr(3, 1));
+ EXPECT_EQ(L"F", fred.Substr(0, 1));
+ EXPECT_EQ(L"R", fred.Substr(1, 1));
+ EXPECT_EQ(L"E", fred.Substr(2, 1));
+ EXPECT_EQ(L"D", fred.Substr(3, 1));
+ EXPECT_EQ(L"FR", fred.Substr(0, 2));
+ EXPECT_EQ(L"FRED", fred.Substr(0, 4));
+ EXPECT_EQ(L"", fred.Substr(0, 10));
- EXPECT_EQ(L"", fred.Mid(1, 4));
- EXPECT_EQ(L"", fred.Mid(4, 1));
+ EXPECT_EQ(L"", fred.Substr(1, 4));
+ EXPECT_EQ(L"", fred.Substr(4, 1));
WideString empty;
- EXPECT_EQ(L"", empty.Mid(0, 0));
+ EXPECT_EQ(L"", empty.Substr(0, 0));
}
TEST(WideString, Left) {
diff --git a/fpdfsdk/fpdf_ppo.cpp b/fpdfsdk/fpdf_ppo.cpp
index 481b6b9..3cdf3d5 100644
--- a/fpdfsdk/fpdf_ppo.cpp
+++ b/fpdfsdk/fpdf_ppo.cpp
@@ -222,7 +222,8 @@
size_t nStringTo = 0;
while (nStringTo < nLength) {
nStringTo = bsStrippedPageRange.Find(',', nStringFrom).value_or(nLength);
- cbMidRange = bsStrippedPageRange.Mid(nStringFrom, nStringTo - nStringFrom);
+ cbMidRange =
+ bsStrippedPageRange.Substr(nStringFrom, nStringTo - nStringFrom);
Optional<size_t> nDashPosition = cbMidRange.Find('-');
if (nDashPosition) {
size_t nMid = nDashPosition.value();
@@ -237,7 +238,7 @@
return false;
uint32_t nEndPageNum = pdfium::base::checked_cast<uint32_t>(
- atoi(cbMidRange.Mid(nMid, nEnd).c_str()));
+ atoi(cbMidRange.Substr(nMid, nEnd).c_str()));
if (nStartPageNum < 0 || nStartPageNum > nEndPageNum ||
nEndPageNum > nCount) {
return false;
diff --git a/fxbarcode/oned/BC_OnedCode128Writer.cpp b/fxbarcode/oned/BC_OnedCode128Writer.cpp
index a7f8d0f..b01abb5 100644
--- a/fxbarcode/oned/BC_OnedCode128Writer.cpp
+++ b/fxbarcode/oned/BC_OnedCode128Writer.cpp
@@ -187,7 +187,7 @@
char ch = contents[position];
if (std::isdigit(ch)) {
patternIndex = FXSYS_atoi(
- contents.Mid(position, contents.IsValidIndex(position + 1) ? 2 : 1)
+ contents.Substr(position, contents.IsValidIndex(position + 1) ? 2 : 1)
.c_str());
++position;
if (position < contents.GetLength() && std::isdigit(contents[position]))
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index 82f9524..7fdab48 100644
--- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -141,7 +141,7 @@
std::vector<TextCharPos> charpos(length);
int32_t iFontSize = (int32_t)fabs(m_fFontSize);
int32_t iTextHeight = iFontSize + 1;
- ByteString tempStr = str.Mid(1, 6);
+ ByteString tempStr = str.Substr(1, 6);
int32_t strWidth = multiple * 42;
CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
@@ -181,7 +181,7 @@
static_cast<float>(iFontSize), affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
- tempStr = str.Mid(7, 6);
+ tempStr = str.Substr(7, 6);
length = tempStr.GetLength();
CalcTextInfo(tempStr, &charpos[7], m_pFont.Get(), (float)strWidth, iFontSize,
blank);
diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
index a924d7d..0f28bf8 100644
--- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
@@ -172,7 +172,7 @@
static_cast<float>(iFontSize), affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
- tempStr = str.Mid(4, 4);
+ tempStr = str.Substr(4, 4);
iLen = tempStr.GetLength();
CalcTextInfo(tempStr, &charpos[4], m_pFont.Get(), (float)strWidth, iFontSize,
blank);
diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index f897e48..cbe0ef6 100644
--- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -116,7 +116,7 @@
ByteString str = FX_UTF8Encode(contents);
size_t length = str.GetLength();
std::vector<TextCharPos> charpos(length);
- ByteString tempStr = str.Mid(1, 5);
+ ByteString tempStr = str.Substr(1, 5);
float strWidth = (float)35 * multiple;
float blank = 0.0;
@@ -166,7 +166,7 @@
static_cast<float>(iFontSize), affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
- tempStr = str.Mid(6, 5);
+ tempStr = str.Substr(6, 5);
length = tempStr.GetLength();
CalcTextInfo(tempStr, &charpos[6], m_pFont.Get(), strWidth, iFontSize, blank);
{
@@ -196,7 +196,7 @@
static_cast<float>(iFontSize), affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
- tempStr = str.Mid(11, 1);
+ tempStr = str.Substr(11, 1);
length = tempStr.GetLength();
CalcTextInfo(tempStr, &charpos[11], m_pFont.Get(), strWidth, iFontSize,
blank);
diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
index 2cee833..09cac1b 100644
--- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
+++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
@@ -295,7 +295,7 @@
while (idx < count) {
WideString tmp;
size_t len = 44 < count - idx ? 44 : count - idx;
- ByteString part = (L'1' + msg.Mid(startpos + idx, len)).ToUTF8();
+ ByteString part = (L'1' + msg.Substr(startpos + idx, len)).ToUTF8();
BigInteger bigint = stringToBigInteger(part.c_str());
do {
int32_t c = (bigint % num900).toInt();
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index c5b02fe..0666a64 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -720,8 +720,8 @@
WideString wstrSelected;
if (pEvent->SelStart() != -1) {
- wstrSelected = wstrValue.Mid(pEvent->SelStart(),
- pEvent->SelEnd() - pEvent->SelStart());
+ wstrSelected = wstrValue.Substr(pEvent->SelStart(),
+ pEvent->SelEnd() - pEvent->SelStart());
}
bool bHasSign = wstrValue.Contains(L'-') && !wstrSelected.Contains(L'-');
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index 9a85c8a..37d3932 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -117,7 +117,7 @@
}
unsafe_conversion_specifiers.push_back(
- unsafe_fmt_string.Mid(offset, offset_end.value() - offset));
+ unsafe_fmt_string.Substr(offset, offset_end.value() - offset));
offset = offset_end.value();
}
}
diff --git a/fxjs/fx_date_helpers.cpp b/fxjs/fx_date_helpers.cpp
index 1a78106..5256fb1 100644
--- a/fxjs/fx_date_helpers.cpp
+++ b/fxjs/fx_date_helpers.cpp
@@ -432,7 +432,7 @@
bool bFind = false;
nSkip = FindSubWordLength(value, j);
if (nSkip == KMonthAbbreviationLength) {
- WideString sMonth = value.Mid(j, KMonthAbbreviationLength);
+ WideString sMonth = value.Substr(j, KMonthAbbreviationLength);
for (size_t m = 0; m < FX_ArraySize(kMonths); ++m) {
if (sMonth.CompareNoCase(kMonths[m]) == 0) {
nMonth = m + 1;
@@ -468,7 +468,7 @@
bool bFind = false;
nSkip = FindSubWordLength(value, j);
if (nSkip <= kLongestFullMonthLength) {
- WideString sMonth = value.Mid(j, nSkip);
+ WideString sMonth = value.Substr(j, nSkip);
sMonth.MakeLower();
for (size_t m = 0; m < FX_ArraySize(kFullMonths); ++m) {
WideString sFullMonths = WideString(kFullMonths[m]);
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 9f78017..a12736e 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -338,13 +338,13 @@
return {true, XFA_VT_TEXT};
if (L"num" == wsPattern.Left(3)) {
uint32_t type;
- if (L"integer" == wsPattern.Mid(4, 7)) {
+ if (L"integer" == wsPattern.Substr(4, 7)) {
type = XFA_VT_INTEGER;
- } else if (L"decimal" == wsPattern.Mid(4, 7)) {
+ } else if (L"decimal" == wsPattern.Substr(4, 7)) {
type = XFA_VT_DECIMAL;
- } else if (L"currency" == wsPattern.Mid(4, 8)) {
+ } else if (L"currency" == wsPattern.Substr(4, 8)) {
type = XFA_VT_FLOAT;
- } else if (L"percent" == wsPattern.Mid(4, 7)) {
+ } else if (L"percent" == wsPattern.Substr(4, 7)) {
type = XFA_VT_FLOAT;
} else {
type = XFA_VT_FLOAT;
@@ -4295,7 +4295,8 @@
// Negative values are treated as 0. Can't clamp() due to sign mismatches.
size_t iCount = std::max(ValueToInteger(pThis, end_value.get()), 0);
iCount = std::min(iCount, iLength - iStart);
- args.GetReturnValue()->SetString(bsSource.Mid(iStart, iCount).AsStringView());
+ args.GetReturnValue()->SetString(
+ bsSource.Substr(iStart, iCount).AsStringView());
}
// static
diff --git a/fxjs/xfa/cfxjse_resolveprocessor.cpp b/fxjs/xfa/cfxjse_resolveprocessor.cpp
index 72dab41..7aa265d 100644
--- a/fxjs/xfa/cfxjse_resolveprocessor.cpp
+++ b/fxjs/xfa/cfxjse_resolveprocessor.cpp
@@ -40,7 +40,7 @@
else
return;
- wsExpression = wsCondition.Mid(2, wsCondition.GetLength() - 3);
+ wsExpression = wsCondition.Substr(2, wsCondition.GetLength() - 3);
for (size_t i = iFoundCount; i > 0; --i) {
auto pRetValue =
pdfium::MakeUnique<CFXJSE_Value>(pRnd->m_pSC->GetIsolate());
@@ -633,7 +633,7 @@
if (iFoundCount == 1 && !iLen)
return;
- int32_t iIndex = wsCondition.Mid(i, iLen - 1 - i).GetInteger();
+ int32_t iIndex = wsCondition.Substr(i, iLen - 1 - i).GetInteger();
if (bRelative)
iIndex += iCurIndex;
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 78aa74c..64006b3 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -1100,7 +1100,7 @@
WideString wsSOM;
if (!wsValue.IsEmpty()) {
if (wsValue[0] == '#')
- wsID = wsValue.Mid(1, wsValue.GetLength() - 1);
+ wsID = wsValue.Substr(1, wsValue.GetLength() - 1);
else
wsSOM = std::move(wsValue);
}
diff --git a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
index f6bce36..108bc00 100644
--- a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
+++ b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
@@ -187,8 +187,8 @@
iSplitNextIndex = pTargetAll->Find(' ', iSplitIndex);
if (!iSplitNextIndex.has_value())
return nullptr;
- wsExpr =
- pTargetAll->Mid(iSplitIndex, iSplitNextIndex.value() - iSplitIndex);
+ wsExpr = pTargetAll->Substr(iSplitIndex,
+ iSplitNextIndex.value() - iSplitIndex);
} else {
wsExpr = *pTargetAll;
}
@@ -205,7 +205,7 @@
} else if (bNewExprStyle) {
WideString wsProcessedTarget = wsExpr;
if (wsExpr.Left(4).EqualsASCII("som(") && wsExpr.Last() == L')')
- wsProcessedTarget = wsExpr.Mid(4, wsExpr.GetLength() - 5);
+ wsProcessedTarget = wsExpr.Substr(4, wsExpr.GetLength() - 5);
XFA_RESOLVENODE_RS rs;
bool bRet = pDocument->GetScriptContext()->ResolveObjects(
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index c341a69..1a2c5b9 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -1439,11 +1439,12 @@
return XFA_VERSION_UNKNOWN;
int8_t iMajor = FXSYS_wtoi(
- wsTemplateNS.Mid(prefixLength, nDotPos.value() - prefixLength).c_str());
+ wsTemplateNS.Substr(prefixLength, nDotPos.value() - prefixLength)
+ .c_str());
int8_t iMinor =
FXSYS_wtoi(wsTemplateNS
- .Mid(nDotPos.value() + 1,
- wsTemplateNS.GetLength() - nDotPos.value() - 2)
+ .Substr(nDotPos.value() + 1,
+ wsTemplateNS.GetLength() - nDotPos.value() - 2)
.c_str());
XFA_VERSION eVersion = (XFA_VERSION)((int32_t)iMajor * 100 + iMinor);
if (eVersion < XFA_VERSION_MIN || eVersion > XFA_VERSION_MAX)
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp
index 7f961f7..28d7aff 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.cpp
+++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp
@@ -48,7 +48,7 @@
m_iCreateFlag = XFA_ResolveNode_RSType_CreateNodeAll;
} else {
m_iCreateFlag = XFA_ResolveNode_RSType_CreateNodeOne;
- wsIndex = wsCondition.Mid(i, szLen - 1 - i);
+ wsIndex = wsCondition.Substr(i, szLen - 1 - i);
}
int32_t iCount = wsIndex.GetInteger();
if (iCount < 0)