From b6b01cb2cbaf6b38736f4dfebb9b6cdc243960f9 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 20 Jun 2018 16:10:13 +0000 Subject: Re-work some more c_str() usage. Many of these are converting ByteString => c_str => ByteStringView, since the ByteStringView ctor is implicit. This is unfortunate, since that involves a strlen() which the ByteString already knows if we use AsStringView() instead. This changed one test result where we can now return the string "\0" instead of "" -- since strlen no longer eats the NUL. This seems consistent, say, with String.fromCharCode(). Change-Id: I17f68d1a1f4b352960208f9148e68ab4c4d78bd2 Reviewed-on: https://pdfium-review.googlesource.com/35590 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 2 +- fpdfsdk/pwl/cpwl_appstream.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index 386ea95f5e..3f9f3038fe 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -405,7 +405,7 @@ void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc, WideString& wsTitle) { return; ByteString csTitle = pInfoDict->GetStringFor("Title"); - wsTitle = WideString::FromLocal(csTitle.c_str()); + wsTitle = WideString::FromLocal(csTitle.AsStringView()); } void CPDFXFA_DocEnvironment::SetTitle(CXFA_FFDoc* hDoc, diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp index aa612f0c07..c17c146d20 100644 --- a/fpdfsdk/pwl/cpwl_appstream.cpp +++ b/fpdfsdk/pwl/cpwl_appstream.cpp @@ -1949,8 +1949,7 @@ void CPWL_AppStream::Write(const ByteString& sAPType, } pStreamDict->SetMatrixFor("Matrix", widget_->GetMatrix()); pStreamDict->SetRectFor("BBox", widget_->GetRotatedRect()); - pStream->SetDataAndRemoveFilter((uint8_t*)(sContents.c_str()), - sContents.GetLength()); + pStream->SetDataAndRemoveFilter(sContents.raw_str(), sContents.GetLength()); } void CPWL_AppStream::Remove(const ByteString& sAPType) { -- cgit v1.2.3