Remove ByteString PDF_NameDecode
This CL removes the ByteString version of PDF_NameDecode and forces the
callers to use the ByteStringView variant.
Change-Id: I5a955d8e909e2045ee45843af54b23e98abe00ed
Reviewed-on: https://pdfium-review.googlesource.com/29350
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index 624bde4..8b8e59f 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -420,23 +420,22 @@
std::unique_ptr<CPDF_Dictionary> pDict =
pdfium::MakeUnique<CPDF_Dictionary>(m_pPool);
while (1) {
- ByteString key = GetNextWord(nullptr);
- if (key.IsEmpty())
+ ByteString word = GetNextWord(nullptr);
+ if (word.IsEmpty())
return nullptr;
- FX_FILESIZE SavedPos = m_Pos - key.GetLength();
- if (key == ">>")
+ FX_FILESIZE SavedPos = m_Pos - word.GetLength();
+ if (word == ">>")
break;
- if (key == "endobj") {
+ if (word == "endobj") {
m_Pos = SavedPos;
break;
}
- if (key[0] != '/')
+ if (word[0] != '/')
continue;
- key = PDF_NameDecode(key);
-
+ ByteString key = PDF_NameDecode(word.AsStringView());
if (key.IsEmpty() && parse_type == ParseType::kLoose)
continue;
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h
index 6650b68..ab819c4 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.h
+++ b/core/fpdfapi/parser/fpdf_parser_decode.h
@@ -18,7 +18,6 @@
extern const uint16_t PDFDocEncoding[256];
ByteString PDF_NameDecode(const ByteStringView& orig);
-ByteString PDF_NameDecode(const ByteString& orig);
ByteString PDF_NameEncode(const ByteString& orig);
ByteString PDF_EncodeString(const ByteString& src, bool bHex);
WideString PDF_DecodeText(const uint8_t* pData, uint32_t size);
diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp
index 45284a4..c486a76 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp
@@ -110,10 +110,6 @@
return result;
}
-ByteString PDF_NameDecode(const ByteString& orig) {
- return orig.Contains("#") ? PDF_NameDecode(orig.AsStringView()) : orig;
-}
-
ByteString PDF_NameEncode(const ByteString& orig) {
uint8_t* src_buf = (uint8_t*)orig.c_str();
int src_len = orig.GetLength();
diff --git a/core/fpdfdoc/cpdf_defaultappearance.cpp b/core/fpdfdoc/cpdf_defaultappearance.cpp
index ba0679a..cae553a 100644
--- a/core/fpdfdoc/cpdf_defaultappearance.cpp
+++ b/core/fpdfdoc/cpdf_defaultappearance.cpp
@@ -32,7 +32,7 @@
csFontNameTag.Delete(0, 1);
*fFontSize = FX_atof(syntax.GetWord());
}
- return PDF_NameDecode(csFontNameTag);
+ return PDF_NameDecode(csFontNameTag.AsStringView());
}
bool CPDF_DefaultAppearance::HasColor() {
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index ac15aa6..c16c36e 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -101,7 +101,7 @@
CPDF_Font* GetFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
const ByteString& csNameTag) {
- ByteString csAlias = PDF_NameDecode(csNameTag);
+ ByteString csAlias = PDF_NameDecode(csNameTag.AsStringView());
if (!pFormDict || csAlias.IsEmpty())
return nullptr;
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index e2fbcc9..4138b21 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -925,7 +925,7 @@
CPDF_SimpleParser syntax(DA.AsStringView());
syntax.FindTagParamFromStart("Tf", 2);
ByteString sFontName(syntax.GetWord());
- sFontName = PDF_NameDecode(sFontName);
+ sFontName = PDF_NameDecode(sFontName.AsStringView());
if (sFontName.IsEmpty())
return;
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index d675676..8e4ac46 100644
--- a/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -219,8 +219,7 @@
CPDF_SimpleParser syntax(sDA.AsStringView());
syntax.FindTagParamFromStart("Tf", 2);
- ByteString sFontName(syntax.GetWord());
- ByteString sDecodedFontName = PDF_NameDecode(sFontName);
+ ByteString sDecodedFontName = PDF_NameDecode(syntax.GetWord());
*sAlias = sDecodedFontName.Right(sDecodedFontName.GetLength() - 1);
CPDF_Dictionary* pFontDict = nullptr;