From f7fe678a4ada859a2e4fbbeeb0b1dff5b5887227 Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 11 May 2016 17:35:35 -0700 Subject: Add much-needed Find() method for CFX_*StringC BUG=pdfium:493 Review-Url: https://codereview.chromium.org/1968233002 --- core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 8 ++++---- core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index a13fb5021d..da1355724f 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -271,18 +271,18 @@ int CPDF_StreamContentParser::GetNextParamPos() { } void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) { + CFX_ByteStringC bsName(name, len); int index = GetNextParamPos(); if (len > 32) { m_ParamBuf[index].m_Type = ContentParam::OBJECT; - m_ParamBuf[index].m_pObject = - new CPDF_Name(PDF_NameDecode(CFX_ByteStringC(name, len))); + m_ParamBuf[index].m_pObject = new CPDF_Name(PDF_NameDecode(bsName)); } else { m_ParamBuf[index].m_Type = ContentParam::NAME; - if (!FXSYS_memchr(name, '#', len)) { + if (bsName.Find('#') == -1) { FXSYS_memcpy(m_ParamBuf[index].m_Name.m_Buffer, name, len); m_ParamBuf[index].m_Name.m_Len = len; } else { - CFX_ByteString str = PDF_NameDecode(CFX_ByteStringC(name, len)); + CFX_ByteString str = PDF_NameDecode(bsName); FXSYS_memcpy(m_ParamBuf[index].m_Name.m_Buffer, str.c_str(), str.GetLength()); m_ParamBuf[index].m_Name.m_Len = str.GetLength(); diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 466ccaffa5..03975149b0 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -89,9 +89,9 @@ int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key) { CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) { int size = bstr.GetLength(); const FX_CHAR* pSrc = bstr.c_str(); - if (!FXSYS_memchr(pSrc, '#', size)) { + if (bstr.Find('#') == -1) return bstr; - } + CFX_ByteString result; FX_CHAR* pDestStart = result.GetBuffer(size); FX_CHAR* pDest = pDestStart; @@ -109,9 +109,8 @@ CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) { } CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) { - if (!FXSYS_memchr(orig.c_str(), '#', orig.GetLength())) { + if (orig.Find('#') == -1) return orig; - } return PDF_NameDecode(orig.AsStringC()); } -- cgit v1.2.3