diff options
author | Daniel Hosseinian <dhoss@chromium.org> | 2020-01-28 19:52:32 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2020-01-28 19:52:32 +0000 |
commit | a9a704ed821f7038e56da259166dfe17d95a1cf3 (patch) | |
tree | 36dd7ed7c5b2f73c29d26dfc94dca2fdd983cb87 /core | |
parent | 90f68856f14fc641fa884eca72c0b52a1e723845 (diff) | |
download | pdfium-a9a704ed821f7038e56da259166dfe17d95a1cf3.tar.gz |
Rename Left() and Right() in {Byte,Wide}String{,View} classes
Rename to First() and Last().
Bug: pdfium:1406
Change-Id: I786313c4ea044c9e27e532d9d25ba6c26f9228f4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/65613
Auto-Submit: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core')
23 files changed, 94 insertions, 94 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp index 96bf30bcb..62c3df569 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp @@ -211,9 +211,9 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) { // Color RGB values used are integers divided by 255. EXPECT_EQ("q 0.501961 0.701961 0.34902 rg 1 0.901961 0 RG /", - pathString.Left(48)); + pathString.First(48)); 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)); + pathString.Last(43)); ASSERT_GT(pathString.GetLength(), 91U); CPDF_Dictionary* externalGS = TestGetResource(&generator, "ExtGState", @@ -228,9 +228,9 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) { TestProcessPath(&generator, &buf, pPathObj.get()); ByteString pathString2(buf); EXPECT_EQ("q 0.501961 0.701961 0.34902 rg 1 0.901961 0 RG 10.5 w /", - pathString2.Left(55)); + pathString2.First(55)); EXPECT_EQ(" gs 1 0 0 1 0 0 cm 1 2 m 3 4 l 5 6 l h B Q\n", - pathString2.Right(43)); + pathString2.Last(43)); // Compare with the previous (should use same dictionary for gs) EXPECT_EQ(pathString.GetLength() + 7, pathString2.GetLength()); @@ -273,12 +273,12 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessStandardText) { auto secondResourceAt = textString.ReverseFind('/'); ASSERT_TRUE(secondResourceAt.has_value()); secondResourceAt = secondResourceAt.value() + 1; - ByteString firstString = textString.Left(firstResourceAt.value()); + ByteString firstString = textString.First(firstResourceAt.value()); ByteString midString = textString.Substr(firstResourceAt.value(), secondResourceAt.value() - firstResourceAt.value()); ByteString lastString = - textString.Right(textString.GetLength() - secondResourceAt.value()); + textString.Last(textString.GetLength() - secondResourceAt.value()); // q and Q must be outside the BT .. ET operations ByteString compareString1 = "q 0.501961 0.701961 0.34902 rg 1 0.901961 0 RG /"; @@ -288,18 +288,18 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessStandardText) { EXPECT_LT(compareString1.GetLength() + compareString2.GetLength() + compareString3.GetLength(), textString.GetLength()); - EXPECT_EQ(compareString1, firstString.Left(compareString1.GetLength())); - EXPECT_EQ(compareString2, midString.Right(compareString2.GetLength())); - EXPECT_EQ(compareString3, lastString.Right(compareString3.GetLength())); + EXPECT_EQ(compareString1, firstString.First(compareString1.GetLength())); + EXPECT_EQ(compareString2, midString.Last(compareString2.GetLength())); + EXPECT_EQ(compareString3, lastString.Last(compareString3.GetLength())); CPDF_Dictionary* externalGS = TestGetResource( &generator, "ExtGState", - midString.Left(midString.GetLength() - compareString2.GetLength())); + midString.First(midString.GetLength() - compareString2.GetLength())); ASSERT_TRUE(externalGS); EXPECT_EQ(0.5f, externalGS->GetNumberFor("ca")); EXPECT_EQ(0.8f, externalGS->GetNumberFor("CA")); CPDF_Dictionary* fontDict = TestGetResource( &generator, "Font", - lastString.Left(lastString.GetLength() - compareString3.GetLength())); + lastString.First(lastString.GetLength() - compareString3.GetLength())); ASSERT_TRUE(fontDict); EXPECT_EQ("Font", fontDict->GetStringFor("Type")); EXPECT_EQ("Type1", fontDict->GetStringFor("Subtype")); @@ -346,16 +346,16 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessText) { auto firstResourceAt = textString.Find('/'); ASSERT_TRUE(firstResourceAt.has_value()); firstResourceAt = firstResourceAt.value() + 1; - ByteString firstString = textString.Left(firstResourceAt.value()); + ByteString firstString = textString.First(firstResourceAt.value()); ByteString lastString = - textString.Right(textString.GetLength() - firstResourceAt.value()); + textString.Last(textString.GetLength() - firstResourceAt.value()); // q and Q must be outside the BT .. ET operations ByteString compareString1 = "q BT 1 0 0 1 0 0 Tm /"; ByteString compareString2 = " 15.5 Tf <4920616D20696E646972656374> Tj ET Q\n"; EXPECT_LT(compareString1.GetLength() + compareString2.GetLength(), textString.GetLength()); - EXPECT_EQ(compareString1, textString.Left(compareString1.GetLength())); - EXPECT_EQ(compareString2, textString.Right(compareString2.GetLength())); + EXPECT_EQ(compareString1, textString.First(compareString1.GetLength())); + EXPECT_EQ(compareString2, textString.Last(compareString2.GetLength())); CPDF_Dictionary* fontDict = TestGetResource( &generator, "Font", textString.Substr(compareString1.GetLength(), diff --git a/core/fpdfapi/font/cpdf_cmap.cpp b/core/fpdfapi/font/cpdf_cmap.cpp index 35cf8bba9..9d1603b2f 100644 --- a/core/fpdfapi/font/cpdf_cmap.cpp +++ b/core/fpdfapi/font/cpdf_cmap.cpp @@ -184,7 +184,7 @@ constexpr PredefinedCMap kPredefinedCMaps[] = { const PredefinedCMap* GetPredefinedCMap(const ByteString& bsPredefinedName) { ByteString cmapid = bsPredefinedName; if (cmapid.GetLength() > 2) - cmapid = cmapid.Left(cmapid.GetLength() - 2); + cmapid = cmapid.First(cmapid.GetLength() - 2); for (const auto& map : kPredefinedCMaps) { if (cmapid == ByteStringView(map.m_pName)) return ↦ diff --git a/core/fpdfapi/font/cpdf_cmapmanager.cpp b/core/fpdfapi/font/cpdf_cmapmanager.cpp index 653af0c71..412971625 100644 --- a/core/fpdfapi/font/cpdf_cmapmanager.cpp +++ b/core/fpdfapi/font/cpdf_cmapmanager.cpp @@ -16,7 +16,7 @@ namespace { RetainPtr<const CPDF_CMap> LoadPredefinedCMap(ByteString name) { if (!name.IsEmpty() && name[0] == '/') - name = name.Right(name.GetLength() - 1); + name = name.Last(name.GetLength() - 1); return pdfium::MakeRetain<CPDF_CMap>(name); } diff --git a/core/fpdfapi/font/cpdf_cmapparser.cpp b/core/fpdfapi/font/cpdf_cmapparser.cpp index 2f44dd96f..7407a42e3 100644 --- a/core/fpdfapi/font/cpdf_cmapparser.cpp +++ b/core/fpdfapi/font/cpdf_cmapparser.cpp @@ -21,7 +21,7 @@ namespace { ByteStringView CMap_GetString(ByteStringView word) { if (word.GetLength() <= 2) return ByteStringView(); - return word.Right(word.GetLength() - 2); + return word.Last(word.GetLength() - 2); } } // namespace diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp index 106ab6aaf..326bc6edf 100644 --- a/core/fpdfapi/font/cpdf_font.cpp +++ b/core/fpdfapi/font/cpdf_font.cpp @@ -315,7 +315,7 @@ RetainPtr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc, ByteString type = pFontDict->GetStringFor("Subtype"); RetainPtr<CPDF_Font> pFont; if (type == "TrueType") { - ByteString tag = pFontDict->GetStringFor("BaseFont").Left(4); + ByteString tag = pFontDict->GetStringFor("BaseFont").First(4); for (size_t i = 0; i < FX_ArraySize(kChineseFontNames); ++i) { if (tag == ByteString(kChineseFontNames[i], kChineseFontNameSize)) { const CPDF_Dictionary* pFontDesc = diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp index 937167869..c0fd4e0c5 100644 --- a/core/fpdfapi/font/cpdf_simplefont.cpp +++ b/core/fpdfapi/font/cpdf_simplefont.cpp @@ -213,7 +213,7 @@ bool CPDF_SimpleFont::LoadCommon() { } if (m_pFontFile) { if (m_BaseFontName.GetLength() > 8 && m_BaseFontName[7] == '+') - m_BaseFontName = m_BaseFontName.Right(m_BaseFontName.GetLength() - 8); + m_BaseFontName = m_BaseFontName.Last(m_BaseFontName.GetLength() - 8); } else { LoadSubstFont(); } diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 420bf701d..a18bead85 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -612,7 +612,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { break; } auto word = m_pSyntax->GetWord(); - ByteString key(word.Right(word.GetLength() - 1)); + ByteString key(word.Last(word.GetLength() - 1)); auto pObj = m_pSyntax->ReadNextObject(false, false, 0); if (!key.IsEmpty()) { if (pObj && !pObj->IsInline()) { @@ -1168,7 +1168,7 @@ RetainPtr<CPDF_ColorSpace> CPDF_StreamContentParser::FindColorSpace( if (name == "DeviceGray" || name == "DeviceCMYK" || name == "DeviceRGB") { ByteString defname = "Default"; - defname += name.Right(name.GetLength() - 7); + defname += name.Last(name.GetLength() - 7); const CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname); if (!pDefObj) { if (name == "DeviceGray") @@ -1533,7 +1533,7 @@ uint32_t CPDF_StreamContentParser::Parse( break; case CPDF_StreamParser::Name: { auto word = syntax.GetWord(); - AddNameParam(word.Right(word.GetLength() - 1)); + AddNameParam(word.Last(word.GetLength() - 1)); break; } default: diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp index 70d6d5e32..506e17674 100644 --- a/core/fpdfdoc/cpdf_filespec.cpp +++ b/core/fpdfdoc/cpdf_filespec.cpp @@ -70,7 +70,7 @@ WideString CPDF_FileSpec::DecodeFileName(const WideString& filepath) { return WideString(); #if defined(OS_MACOSX) - if (filepath.Left(sizeof("/Mac") - 1) == WideStringView(L"/Mac")) + if (filepath.First(sizeof("/Mac") - 1) == WideStringView(L"/Mac")) return ChangeSlashToPlatform(filepath.c_str() + 1); return ChangeSlashToPlatform(filepath.c_str()); #elif defined(OS_WIN) @@ -191,7 +191,7 @@ WideString CPDF_FileSpec::EncodeFileName(const WideString& filepath) { return L'/' + ChangeSlashToPDF(filepath.c_str()); return ChangeSlashToPDF(filepath.c_str()); #elif defined(OS_MACOSX) - if (filepath.Left(sizeof("Mac") - 1).EqualsASCII("Mac")) + if (filepath.First(sizeof("Mac") - 1).EqualsASCII("Mac")) return L'/' + ChangeSlashToPDF(filepath.c_str()); return ChangeSlashToPDF(filepath.c_str()); #else diff --git a/core/fpdftext/cpdf_linkextract.cpp b/core/fpdftext/cpdf_linkextract.cpp index 001ff1d11..f822f3bcc 100644 --- a/core/fpdftext/cpdf_linkextract.cpp +++ b/core/fpdftext/cpdf_linkextract.cpp @@ -156,7 +156,7 @@ void CPDF_LinkExtract::ExtractLinks() { if (ch != L')' && ch != L',' && ch != L'>' && ch != L'.') break; - strBeCheck = strBeCheck.Left(strBeCheck.GetLength() - 1); + strBeCheck = strBeCheck.First(strBeCheck.GetLength() - 1); nCount--; } @@ -249,7 +249,7 @@ bool CPDF_LinkExtract::CheckMailLink(WideString* str) { // End extracting for other invalid chars, '.' at the beginning, or // consecutive '.'. size_t removed_len = i == pPos ? i + 1 : i; - *str = str->Right(str->GetLength() - removed_len); + *str = str->Last(str->GetLength() - removed_len); break; } // Found a valid '.'. @@ -282,7 +282,7 @@ bool CPDF_LinkExtract::CheckMailLink(WideString* str) { size_t host_end = i == pPos + 1 ? i - 2 : i - 1; if (pPos > 0 && host_end - aPos.value() >= 3) { // Trim the ending invalid chars if there is at least one '.' and name. - *str = str->Left(host_end + 1); + *str = str->First(host_end + 1); break; } return false; diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp index d40967007..3df499f73 100644 --- a/core/fpdftext/cpdf_textpagefind.cpp +++ b/core/fpdftext/cpdf_textpagefind.cpp @@ -147,13 +147,13 @@ std::vector<WideString> ExtractFindWhat(const WideString& findwhat) { continue; } if (pos > 0) - findwhat_array.push_back(word->Left(pos)); + findwhat_array.push_back(word->First(pos)); findwhat_array.push_back(curStr); if (pos == word->GetLength() - 1) { word->clear(); break; } - word.emplace(word->Right(word->GetLength() - pos - 1)); + word.emplace(word->Last(word->GetLength() - pos - 1)); pos = 0; continue; } diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp index a353064ca..0778bc260 100644 --- a/core/fxcrt/bytestring.cpp +++ b/core/fxcrt/bytestring.cpp @@ -490,13 +490,13 @@ ByteString ByteString::Substr(size_t first, size_t count) const { return dest; } -ByteString ByteString::Left(size_t count) const { +ByteString ByteString::First(size_t count) const { if (count == 0 || !IsValidLength(count)) return ByteString(); return Substr(0, count); } -ByteString ByteString::Right(size_t count) const { +ByteString ByteString::Last(size_t count) const { if (count == 0 || !IsValidLength(count)) return ByteString(); return Substr(GetLength() - count, count); diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h index c01708706..7c7f2ee37 100644 --- a/core/fxcrt/bytestring.h +++ b/core/fxcrt/bytestring.h @@ -164,8 +164,8 @@ class ByteString { void ReleaseBuffer(size_t nNewLength); ByteString Substr(size_t first, size_t count) const; - ByteString Left(size_t count) const; - ByteString Right(size_t count) const; + ByteString First(size_t count) const; + ByteString Last(size_t count) const; Optional<size_t> Find(ByteStringView subStr, size_t start = 0) const; Optional<size_t> Find(char ch, size_t start = 0) const; diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp index 61b4ae172..e2e87f00c 100644 --- a/core/fxcrt/bytestring_unittest.cpp +++ b/core/fxcrt/bytestring_unittest.cpp @@ -626,34 +626,34 @@ TEST(ByteString, Substr) { EXPECT_EQ("", empty.Substr(0, 0)); } -TEST(ByteString, Left) { +TEST(ByteString, First) { ByteString fred("FRED"); - EXPECT_EQ("", fred.Left(0)); - EXPECT_EQ("F", fred.Left(1)); - EXPECT_EQ("FR", fred.Left(2)); - EXPECT_EQ("FRE", fred.Left(3)); - EXPECT_EQ("FRED", fred.Left(4)); + EXPECT_EQ("", fred.First(0)); + EXPECT_EQ("F", fred.First(1)); + EXPECT_EQ("FR", fred.First(2)); + EXPECT_EQ("FRE", fred.First(3)); + EXPECT_EQ("FRED", fred.First(4)); - EXPECT_EQ("", fred.Left(5)); + EXPECT_EQ("", fred.First(5)); ByteString empty; - EXPECT_EQ("", empty.Left(0)); - EXPECT_EQ("", empty.Left(1)); + EXPECT_EQ("", empty.First(0)); + EXPECT_EQ("", empty.First(1)); } -TEST(ByteString, Right) { +TEST(ByteString, Last) { ByteString fred("FRED"); - EXPECT_EQ("", fred.Right(0)); - EXPECT_EQ("D", fred.Right(1)); - EXPECT_EQ("ED", fred.Right(2)); - EXPECT_EQ("RED", fred.Right(3)); - EXPECT_EQ("FRED", fred.Right(4)); + EXPECT_EQ("", fred.Last(0)); + EXPECT_EQ("D", fred.Last(1)); + EXPECT_EQ("ED", fred.Last(2)); + EXPECT_EQ("RED", fred.Last(3)); + EXPECT_EQ("FRED", fred.Last(4)); - EXPECT_EQ("", fred.Right(5)); + EXPECT_EQ("", fred.Last(5)); ByteString empty; - EXPECT_EQ("", empty.Right(0)); - EXPECT_EQ("", empty.Right(1)); + EXPECT_EQ("", empty.Last(0)); + EXPECT_EQ("", empty.Last(1)); } TEST(ByteString, Find) { diff --git a/core/fxcrt/fx_string.h b/core/fxcrt/fx_string.h index 4db1cea37..e27f43af7 100644 --- a/core/fxcrt/fx_string.h +++ b/core/fxcrt/fx_string.h @@ -39,8 +39,8 @@ std::vector<StrType> Split(const StrType& that, typename StrType::CharType ch) { Optional<size_t> index = remaining.Find(ch); if (!index.has_value()) break; - result.emplace_back(remaining.Left(index.value())); - remaining = remaining.Right(remaining.GetLength() - index.value() - 1); + result.emplace_back(remaining.First(index.value())); + remaining = remaining.Last(remaining.GetLength() - index.value() - 1); } result.emplace_back(remaining); return result; diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h index f4180f7f8..e50a71d68 100644 --- a/core/fxcrt/string_view_template.h +++ b/core/fxcrt/string_view_template.h @@ -21,7 +21,7 @@ namespace fxcrt { // 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 Substr(), Left(), and Right() methods) is copy-free. +// extraction (via the Substr(), First(), and Last() 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. @@ -213,13 +213,13 @@ class StringViewTemplate { return StringViewTemplate(m_Span.data() + first, count); } - StringViewTemplate Left(size_t count) const { + StringViewTemplate First(size_t count) const { if (count == 0 || !IsValidLength(count)) return StringViewTemplate(); return Substr(0, count); } - StringViewTemplate Right(size_t count) const { + StringViewTemplate Last(size_t count) const { if (count == 0 || !IsValidLength(count)) return StringViewTemplate(); return Substr(GetLength() - count, count); diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp index 79fe3b0ca..10a31c3fa 100644 --- a/core/fxcrt/widestring.cpp +++ b/core/fxcrt/widestring.cpp @@ -715,13 +715,13 @@ WideString WideString::Substr(size_t first, size_t count) const { return dest; } -WideString WideString::Left(size_t count) const { +WideString WideString::First(size_t count) const { if (count == 0 || !IsValidLength(count)) return WideString(); return Substr(0, count); } -WideString WideString::Right(size_t count) const { +WideString WideString::Last(size_t count) const { if (count == 0 || !IsValidLength(count)) return WideString(); return Substr(GetLength() - count, count); diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h index d240a9d72..58e75449f 100644 --- a/core/fxcrt/widestring.h +++ b/core/fxcrt/widestring.h @@ -151,8 +151,8 @@ class WideString { int CompareNoCase(const wchar_t* str) const; WideString Substr(size_t first, size_t count) const; - WideString Left(size_t count) const; - WideString Right(size_t count) const; + WideString First(size_t count) const; + WideString Last(size_t count) const; size_t Insert(size_t index, wchar_t ch); size_t InsertAtFront(wchar_t ch) { return Insert(0, ch); } diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp index b71c9373e..2445a47f1 100644 --- a/core/fxcrt/widestring_unittest.cpp +++ b/core/fxcrt/widestring_unittest.cpp @@ -634,34 +634,34 @@ TEST(WideString, Substr) { EXPECT_EQ(L"", empty.Substr(0, 0)); } -TEST(WideString, Left) { +TEST(WideString, First) { WideString fred(L"FRED"); - EXPECT_EQ(L"", fred.Left(0)); - EXPECT_EQ(L"F", fred.Left(1)); - EXPECT_EQ(L"FR", fred.Left(2)); - EXPECT_EQ(L"FRE", fred.Left(3)); - EXPECT_EQ(L"FRED", fred.Left(4)); + EXPECT_EQ(L"", fred.First(0)); + EXPECT_EQ(L"F", fred.First(1)); + EXPECT_EQ(L"FR", fred.First(2)); + EXPECT_EQ(L"FRE", fred.First(3)); + EXPECT_EQ(L"FRED", fred.First(4)); - EXPECT_EQ(L"", fred.Left(5)); + EXPECT_EQ(L"", fred.First(5)); WideString empty; - EXPECT_EQ(L"", empty.Left(0)); - EXPECT_EQ(L"", empty.Left(1)); + EXPECT_EQ(L"", empty.First(0)); + EXPECT_EQ(L"", empty.First(1)); } -TEST(WideString, Right) { +TEST(WideString, Last) { WideString fred(L"FRED"); - EXPECT_EQ(L"", fred.Right(0)); - EXPECT_EQ(L"D", fred.Right(1)); - EXPECT_EQ(L"ED", fred.Right(2)); - EXPECT_EQ(L"RED", fred.Right(3)); - EXPECT_EQ(L"FRED", fred.Right(4)); + EXPECT_EQ(L"", fred.Last(0)); + EXPECT_EQ(L"D", fred.Last(1)); + EXPECT_EQ(L"ED", fred.Last(2)); + EXPECT_EQ(L"RED", fred.Last(3)); + EXPECT_EQ(L"FRED", fred.Last(4)); - EXPECT_EQ(L"", fred.Right(5)); + EXPECT_EQ(L"", fred.Last(5)); WideString empty; - EXPECT_EQ(L"", empty.Right(0)); - EXPECT_EQ(L"", empty.Right(1)); + EXPECT_EQ(L"", empty.Last(0)); + EXPECT_EQ(L"", empty.Last(1)); } TEST(WideString, Find) { diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp index a294b5f30..b999f5cda 100644 --- a/core/fxcrt/xml/cfx_xmlelement.cpp +++ b/core/fxcrt/xml/cfx_xmlelement.cpp @@ -40,13 +40,13 @@ CFX_XMLNode* CFX_XMLElement::Clone(CFX_XMLDocument* doc) { WideString CFX_XMLElement::GetLocalTagName() const { auto pos = name_.Find(L':'); - return pos.has_value() ? name_.Right(name_.GetLength() - pos.value() - 1) + return pos.has_value() ? name_.Last(name_.GetLength() - pos.value() - 1) : name_; } WideString CFX_XMLElement::GetNamespacePrefix() const { auto pos = name_.Find(L':'); - return pos.has_value() ? name_.Left(pos.value()) : WideString(); + return pos.has_value() ? name_.First(pos.value()) : WideString(); } WideString CFX_XMLElement::GetNamespaceURI() const { diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp index 2420ea580..b5e7a20ae 100644 --- a/core/fxge/android/cfpf_skiafontmgr.cpp +++ b/core/fxge/android/cfpf_skiafontmgr.cpp @@ -370,7 +370,7 @@ void CFPF_SkiaFontMgr::ScanPath(const ByteString& path) { if (filename == "." || filename == "..") continue; } else { - ByteString ext = filename.Right(4); + ByteString ext = filename.Last(4); ext.MakeLower(); if (ext != ".ttf" && ext != ".ttc" && ext != ".otf") continue; diff --git a/core/fxge/cfx_folderfontinfo.cpp b/core/fxge/cfx_folderfontinfo.cpp index 05d7ec973..032d4de17 100644 --- a/core/fxge/cfx_folderfontinfo.cpp +++ b/core/fxge/cfx_folderfontinfo.cpp @@ -154,7 +154,7 @@ void CFX_FolderFontInfo::ScanPath(const ByteString& path) { if (filename == "." || filename == "..") continue; } else { - ByteString ext = filename.Right(4); + ByteString ext = filename.Last(4); ext.MakeLower(); if (ext != ".ttf" && ext != ".ttc" && ext != ".otf") continue; diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp index 04fb77d3f..3b0bcae03 100644 --- a/core/fxge/cfx_fontmapper.cpp +++ b/core/fxge/cfx_fontmapper.cpp @@ -168,7 +168,7 @@ ByteString TT_NormalizeName(const char* family) { norm.Remove(','); auto pos = norm.Find('+'); if (pos.has_value() && pos.value() != 0) - norm = norm.Left(pos.value()); + norm = norm.First(pos.value()); norm.MakeLower(); return norm; } @@ -230,10 +230,10 @@ std::tuple<bool, uint32_t, size_t> GetStyleType(const ByteString& bsStyle, continue; if (bReverse) { - if (bsStyle.Right(pStyle->len).Compare(pStyle->name) == 0) + if (bsStyle.Last(pStyle->len).Compare(pStyle->name) == 0) return std::make_tuple(true, pStyle->style, pStyle->len); } else { - if (bsStyle.Left(pStyle->len).Compare(pStyle->name) == 0) + if (bsStyle.First(pStyle->len).Compare(pStyle->name) == 0) return std::make_tuple(true, pStyle->style, pStyle->len); } } @@ -399,7 +399,7 @@ RetainPtr<CFX_Face> CFX_FontMapper::FindSubstFont(const ByteString& name, ByteString SubstName = name; SubstName.Remove(' '); if (bTrueType && name.GetLength() > 0 && name[0] == '@') - SubstName = name.Right(name.GetLength() - 1); + SubstName = name.Last(name.GetLength() - 1); GetStandardFontName(&SubstName); if (SubstName == "Symbol" && !bTrueType) { pSubstFont->m_Family = "Chrome Symbol"; @@ -419,9 +419,9 @@ RetainPtr<CFX_Face> CFX_FontMapper::FindSubstFont(const ByteString& name, { Optional<size_t> pos = SubstName.Find(",", 0); if (pos.has_value()) { - family = SubstName.Left(pos.value()); + family = SubstName.First(pos.value()); GetStandardFontName(&family); - style = SubstName.Right(SubstName.GetLength() - (pos.value() + 1)); + style = SubstName.Last(SubstName.GetLength() - (pos.value() + 1)); bHasComma = true; } else { family = SubstName; @@ -448,8 +448,8 @@ RetainPtr<CFX_Face> CFX_FontMapper::FindSubstFont(const ByteString& name, if (!bHasComma) { Optional<size_t> pos = family.ReverseFind('-'); if (pos.has_value()) { - style = family.Right(family.GetLength() - (pos.value() + 1)); - family = family.Left(pos.value()); + style = family.Last(family.GetLength() - (pos.value() + 1)); + family = family.First(pos.value()); bHasHyphen = true; } } @@ -460,7 +460,7 @@ RetainPtr<CFX_Face> CFX_FontMapper::FindSubstFont(const ByteString& name, size_t len; std::tie(hasStyleType, styleType, len) = GetStyleType(family, true); if (hasStyleType) { - family = family.Left(nLen - len); + family = family.First(nLen - len); nStyle |= styleType; } } diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 9c38d5879..58cb504c3 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -442,12 +442,12 @@ ByteString CFX_Win32FontInfo::FindFont(const ByteString& name) { for (size_t i = 0; i < m_pMapper->m_InstalledTTFonts.size(); ++i) { ByteString thisname = m_pMapper->m_InstalledTTFonts[i]; - if (thisname.Left(name.GetLength()) == name) + if (thisname.First(name.GetLength()) == name) return m_pMapper->m_InstalledTTFonts[i]; } for (size_t i = 0; i < m_pMapper->m_LocalizedTTFonts.size(); ++i) { ByteString thisname = m_pMapper->m_LocalizedTTFonts[i].first; - if (thisname.Left(name.GetLength()) == name) + if (thisname.First(name.GetLength()) == name) return m_pMapper->m_LocalizedTTFonts[i].second; } return ByteString(); |