Prefer ByteString() over "".
Narrow string version of previous CL.
Change-Id: I551d8e0d58be9912855ec07d76ef328aad54fb6c
Reviewed-on: https://pdfium-review.googlesource.com/c/46370
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp
index cb94630..38e029c 100644
--- a/core/fpdfapi/parser/cpdf_security_handler.cpp
+++ b/core/fpdfapi/parser/cpdf_security_handler.cpp
@@ -99,7 +99,10 @@
bool CPDF_SecurityHandler::OnInit(const CPDF_Dictionary* pEncryptDict,
const CPDF_Array* pIdArray,
const ByteString& password) {
- m_FileId = pIdArray ? pIdArray->GetStringAt(0) : "";
+ if (pIdArray)
+ m_FileId = pIdArray->GetStringAt(0);
+ else
+ m_FileId.clear();
if (!LoadDict(pEncryptDict))
return false;
if (m_Cipher == FXCIPHER_NONE)
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index 597e5fb..e9829b0 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -376,7 +376,7 @@
return "RichMedia";
if (nSubtype == CPDF_Annot::Subtype::XFAWIDGET)
return "XFAWidget";
- return "";
+ return ByteString();
}
// static
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index c44e28a..d5a6530 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -315,7 +315,7 @@
ByteString CPDF_FormField::GetDefaultStyle() const {
const CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "DS");
- return pObj ? pObj->GetString() : "";
+ return pObj ? pObj->GetString() : ByteString();
}
void CPDF_FormField::SetOpt(std::unique_ptr<CPDF_Object> pOpt) {
diff --git a/core/fpdfdoc/cpdf_interactiveform.cpp b/core/fpdfdoc/cpdf_interactiveform.cpp
index 1c0a8e9..a148ac4 100644
--- a/core/fpdfdoc/cpdf_interactiveform.cpp
+++ b/core/fpdfdoc/cpdf_interactiveform.cpp
@@ -930,7 +930,7 @@
if (pClone)
pDict->SetFor("T", std::move(pClone));
else
- pDict->SetNewFor<CPDF_Name>("T", "");
+ pDict->SetNewFor<CPDF_Name>("T", ByteString());
}
if (!m_pFieldTree->SetField(csWName, std::move(newField)))
return;
diff --git a/core/fpdfdoc/cpdf_pagelabel.cpp b/core/fpdfdoc/cpdf_pagelabel.cpp
index 192e142..8985def 100644
--- a/core/fpdfdoc/cpdf_pagelabel.cpp
+++ b/core/fpdfdoc/cpdf_pagelabel.cpp
@@ -110,7 +110,7 @@
if (pLabel->KeyExist("P"))
label += pLabel->GetUnicodeTextFor("P");
- ByteString bsNumberingStyle = pLabel->GetStringFor("S", "");
+ ByteString bsNumberingStyle = pLabel->GetStringFor("S", ByteString());
int nLabelNum = nPage - n + pLabel->GetIntegerFor("St", 1);
WideString wsNumPortion = GetLabelNumPortion(nLabelNum, bsNumberingStyle);
label += wsNumPortion;
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 2dc491b..107bed1 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -51,11 +51,11 @@
return ByteString::Format("%c", SubWord);
if (!pFontMap)
- return "";
+ return ByteString();
CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex);
if (!pPDFFont)
- return "";
+ return ByteString();
if (pPDFFont->GetBaseFont().Compare("Symbol") == 0 ||
pPDFFont->GetBaseFont().Compare("ZapfDingbats") == 0) {
@@ -72,7 +72,7 @@
ByteString GetWordRenderString(const ByteString& strWords) {
if (strWords.GetLength() > 0)
return PDF_EncodeString(strWords, false) + " Tj\n";
- return "";
+ return ByteString();
}
ByteString GetFontSetString(IPVT_FontMap* pFontMap,
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h
index 4520a21..23e2522 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.h
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.h
@@ -202,7 +202,7 @@
WideString JS_docGetFilePath();
void JS_docSubmitForm(void* formData, int length, const WideString& URL);
- ByteString GetAppName() const { return ""; }
+ ByteString GetAppName() const { return ByteString(); }
CFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); }
FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; }
diff --git a/fpdfsdk/fpdf_ppo.cpp b/fpdfsdk/fpdf_ppo.cpp
index 5f1de23..d8c7747 100644
--- a/fpdfsdk/fpdf_ppo.cpp
+++ b/fpdfsdk/fpdf_ppo.cpp
@@ -322,7 +322,7 @@
pDocInfoDict->SetNewFor<CPDF_String>("Producer", "PDFium", false);
- ByteString cbRootType = pNewRoot->GetStringFor("Type", "");
+ ByteString cbRootType = pNewRoot->GetStringFor("Type", ByteString());
if (cbRootType.IsEmpty())
pNewRoot->SetNewFor<CPDF_Name>("Type", "Catalog");
@@ -334,7 +334,7 @@
pNewRoot->SetFor("Pages", pNewPages->MakeReference(dest()));
}
- ByteString cbPageType = pNewPages->GetStringFor("Type", "");
+ ByteString cbPageType = pNewPages->GetStringFor("Type", ByteString());
if (cbPageType.IsEmpty())
pNewPages->SetNewFor<CPDF_Name>("Type", "Pages");
diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp
index a81a4eb..137022a 100644
--- a/fpdfsdk/pwl/cpwl_appstream.cpp
+++ b/fpdfsdk/pwl/cpwl_appstream.cpp
@@ -1248,7 +1248,7 @@
&font_map, pNormalIcon, iconFit, csNormalCaption,
crText, fFontSize, nLayout);
- Write("N", csAP, "");
+ Write("N", csAP, ByteString());
if (pNormalIcon)
AddImage("N", pNormalIcon);
@@ -1269,7 +1269,7 @@
&font_map, pRolloverIcon, iconFit,
csRolloverCaption, crText, fFontSize, nLayout);
- Write("R", csAP, "");
+ Write("R", csAP, ByteString());
if (pRolloverIcon)
AddImage("R", pRolloverIcon);
@@ -1304,7 +1304,7 @@
&font_map, pDownIcon, iconFit, csDownCaption,
crText, fFontSize, nLayout);
- Write("D", csAP, "");
+ Write("D", csAP, ByteString());
if (pDownIcon)
AddImage("D", pDownIcon);
} else {
@@ -1649,7 +1649,7 @@
sBody << GetDropButtonAppStream(rcButton);
Write("N",
GetBackgroundAppStream() + GetBorderAppStream() + ByteString(sBody),
- "");
+ ByteString());
}
void CPWL_AppStream::SetAsListBox() {
@@ -1734,7 +1734,7 @@
}
Write("N",
GetBackgroundAppStream() + GetBorderAppStream() + ByteString(sBody),
- "");
+ ByteString());
}
void CPWL_AppStream::SetAsTextField(Optional<WideString> sValue) {
@@ -1884,7 +1884,7 @@
Write("N",
GetBackgroundAppStream() + GetBorderAppStream() + ByteString(sLines) +
ByteString(sBody),
- "");
+ ByteString());
}
void CPWL_AppStream::AddImage(const ByteString& sAPType, CPDF_Stream* pImage) {
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 57c5849..8f67887 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -273,12 +273,12 @@
ByteString sPropName = WideString(propname).ToDefANSI();
if (vp->IsNumber()) {
return SetGlobalVariables(sPropName, CFX_Value::DataType::NUMBER,
- pRuntime->ToDouble(vp), false, "",
+ pRuntime->ToDouble(vp), false, ByteString(),
v8::Local<v8::Object>(), false);
}
if (vp->IsBoolean()) {
return SetGlobalVariables(sPropName, CFX_Value::DataType::BOOLEAN, 0,
- pRuntime->ToBoolean(vp), "",
+ pRuntime->ToBoolean(vp), ByteString(),
v8::Local<v8::Object>(), false);
}
if (vp->IsString()) {
@@ -288,11 +288,11 @@
}
if (vp->IsObject()) {
return SetGlobalVariables(sPropName, CFX_Value::DataType::OBJECT, 0, false,
- "", pRuntime->ToObject(vp), false);
+ ByteString(), pRuntime->ToObject(vp), false);
}
if (vp->IsNull()) {
return SetGlobalVariables(sPropName, CFX_Value::DataType::NULLOBJ, 0, false,
- "", v8::Local<v8::Object>(), false);
+ ByteString(), v8::Local<v8::Object>(), false);
}
if (vp->IsUndefined()) {
DelProperty(pRuntime, propname);
@@ -325,7 +325,7 @@
switch (pData->data.nType) {
case CFX_Value::DataType::NUMBER:
SetGlobalVariables(pData->data.sKey, CFX_Value::DataType::NUMBER,
- pData->data.dData, false, "",
+ pData->data.dData, false, ByteString(),
v8::Local<v8::Object>(), pData->bPersistent == 1);
pRuntime->PutObjectProperty(
ToV8Object(), WideString::FromUTF8(pData->data.sKey.AsStringView()),
@@ -333,8 +333,8 @@
break;
case CFX_Value::DataType::BOOLEAN:
SetGlobalVariables(pData->data.sKey, CFX_Value::DataType::BOOLEAN, 0,
- pData->data.bData == 1, "", v8::Local<v8::Object>(),
- pData->bPersistent == 1);
+ pData->data.bData == 1, ByteString(),
+ v8::Local<v8::Object>(), pData->bPersistent == 1);
pRuntime->PutObjectProperty(
ToV8Object(), WideString::FromUTF8(pData->data.sKey.AsStringView()),
pRuntime->NewBoolean(pData->data.bData == 1));
@@ -354,7 +354,8 @@
if (!pObj.IsEmpty()) {
PutObjectProperty(pObj, &pData->data);
SetGlobalVariables(pData->data.sKey, CFX_Value::DataType::OBJECT, 0,
- false, "", pObj, pData->bPersistent == 1);
+ false, ByteString(), pObj,
+ pData->bPersistent == 1);
pRuntime->PutObjectProperty(
ToV8Object(),
WideString::FromUTF8(pData->data.sKey.AsStringView()), pObj);
@@ -362,7 +363,7 @@
} break;
case CFX_Value::DataType::NULLOBJ:
SetGlobalVariables(pData->data.sKey, CFX_Value::DataType::NULLOBJ, 0,
- false, "", v8::Local<v8::Object>(),
+ false, ByteString(), v8::Local<v8::Object>(),
pData->bPersistent == 1);
pRuntime->PutObjectProperty(
ToV8Object(), WideString::FromUTF8(pData->data.sKey.AsStringView()),
diff --git a/xfa/fgas/font/cfx_fontsourceenum_file.cpp b/xfa/fgas/font/cfx_fontsourceenum_file.cpp
index 395d9d2..6cdf3dc 100644
--- a/xfa/fgas/font/cfx_fontsourceenum_file.cpp
+++ b/xfa/fgas/font/cfx_fontsourceenum_file.cpp
@@ -35,7 +35,7 @@
!m_FolderQueue.empty() ? m_FolderQueue.back().pFileHandle : nullptr;
if (!pCurHandle) {
if (m_FolderPaths.empty())
- return "";
+ return ByteString();
pCurHandle = FX_OpenFolder(m_FolderPaths.back().c_str());
HandleParentPath hpp;
hpp.pFileHandle = pCurHandle;
@@ -52,7 +52,7 @@
if (m_FolderQueue.empty()) {
if (!m_FolderPaths.empty())
m_FolderPaths.pop_back();
- return !m_FolderPaths.empty() ? GetNextFile() : "";
+ return !m_FolderPaths.empty() ? GetNextFile() : ByteString();
}
pCurHandle = m_FolderQueue.back().pFileHandle;
continue;