From 4db6e37b18648dfe2c94b672276c7bf6554fd9d4 Mon Sep 17 00:00:00 2001 From: Artem Strygin Date: Mon, 2 Oct 2017 21:03:05 +0300 Subject: Simplify CPDF_DataAvail::ParseIndirectObjectAt Change-Id: I072df58730f323bb5d77d180382ea209cf47f930 Reviewed-on: https://pdfium-review.googlesource.com/13832 Reviewed-by: dsinclair Commit-Queue: Art Snake --- core/fpdfapi/parser/cpdf_data_avail.cpp | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index aaec4c7708..38e857f22f 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -634,30 +634,14 @@ std::unique_ptr CPDF_DataAvail::ParseIndirectObjectAt( FX_FILESIZE pos, uint32_t objnum, CPDF_IndirectObjectHolder* pObjList) { - FX_FILESIZE SavedPos = m_syntaxParser.GetPos(); + const FX_FILESIZE SavedPos = m_syntaxParser.GetPos(); m_syntaxParser.SetPos(pos); - - bool bIsNumber; - ByteString word = m_syntaxParser.GetNextWord(&bIsNumber); - if (!bIsNumber) - return nullptr; - - uint32_t parser_objnum = FXSYS_atoui(word.c_str()); - if (objnum && parser_objnum != objnum) - return nullptr; - - word = m_syntaxParser.GetNextWord(&bIsNumber); - if (!bIsNumber) - return nullptr; - - if (m_syntaxParser.GetKeyword() != "obj") { - m_syntaxParser.SetPos(SavedPos); - return nullptr; - } - - std::unique_ptr pObj = m_syntaxParser.GetObjectBody(pObjList); + std::unique_ptr result = m_syntaxParser.GetIndirectObject( + pObjList, CPDF_SyntaxParser::ParseType::kLoose); m_syntaxParser.SetPos(SavedPos); - return pObj; + return (result && (!objnum || result->GetObjNum() == objnum)) + ? std::move(result) + : nullptr; } CPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() { -- cgit v1.2.3