| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fpdfapi/parser/cpdf_syntax_parser.h" | 7 #include "core/fpdfapi/parser/cpdf_syntax_parser.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 } | 412 } |
| 413 if (word == "[") { | 413 if (word == "[") { |
| 414 std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>(); | 414 std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>(); |
| 415 while (std::unique_ptr<CPDF_Object> pObj = | 415 while (std::unique_ptr<CPDF_Object> pObj = |
| 416 GetObject(pObjList, objnum, gennum, true)) { | 416 GetObject(pObjList, objnum, gennum, true)) { |
| 417 pArray->Add(std::move(pObj)); | 417 pArray->Add(std::move(pObj)); |
| 418 } | 418 } |
| 419 return std::move(pArray); | 419 return std::move(pArray); |
| 420 } | 420 } |
| 421 if (word[0] == '/') { | 421 if (word[0] == '/') { |
| 422 return pdfium::MakeUnique<CPDF_Name>(MaybeIntern( | 422 return pdfium::MakeUnique<CPDF_Name>( |
| 423 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)))); | 423 m_pPool, |
| 424 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))); |
| 424 } | 425 } |
| 425 if (word == "<<") { | 426 if (word == "<<") { |
| 426 int32_t nKeys = 0; | 427 int32_t nKeys = 0; |
| 427 FX_FILESIZE dwSignValuePos = 0; | 428 FX_FILESIZE dwSignValuePos = 0; |
| 428 std::unique_ptr<CPDF_Dictionary> pDict = | 429 std::unique_ptr<CPDF_Dictionary> pDict = |
| 429 pdfium::MakeUnique<CPDF_Dictionary>(m_pPool); | 430 pdfium::MakeUnique<CPDF_Dictionary>(m_pPool); |
| 430 while (1) { | 431 while (1) { |
| 431 CFX_ByteString key = GetNextWord(nullptr); | 432 CFX_ByteString key = GetNextWord(nullptr); |
| 432 if (key.IsEmpty()) | 433 if (key.IsEmpty()) |
| 433 return nullptr; | 434 return nullptr; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 } | 533 } |
| 533 if (word == "[") { | 534 if (word == "[") { |
| 534 std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>(); | 535 std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>(); |
| 535 while (std::unique_ptr<CPDF_Object> pObj = | 536 while (std::unique_ptr<CPDF_Object> pObj = |
| 536 GetObject(pObjList, objnum, gennum, true)) { | 537 GetObject(pObjList, objnum, gennum, true)) { |
| 537 pArray->Add(std::move(pObj)); | 538 pArray->Add(std::move(pObj)); |
| 538 } | 539 } |
| 539 return m_WordBuffer[0] == ']' ? std::move(pArray) : nullptr; | 540 return m_WordBuffer[0] == ']' ? std::move(pArray) : nullptr; |
| 540 } | 541 } |
| 541 if (word[0] == '/') { | 542 if (word[0] == '/') { |
| 542 return pdfium::MakeUnique<CPDF_Name>(MaybeIntern( | 543 return pdfium::MakeUnique<CPDF_Name>( |
| 543 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)))); | 544 m_pPool, |
| 545 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1))); |
| 544 } | 546 } |
| 545 if (word == "<<") { | 547 if (word == "<<") { |
| 546 std::unique_ptr<CPDF_Dictionary> pDict = | 548 std::unique_ptr<CPDF_Dictionary> pDict = |
| 547 pdfium::MakeUnique<CPDF_Dictionary>(m_pPool); | 549 pdfium::MakeUnique<CPDF_Dictionary>(m_pPool); |
| 548 while (1) { | 550 while (1) { |
| 549 FX_FILESIZE SavedPos = m_Pos; | 551 FX_FILESIZE SavedPos = m_Pos; |
| 550 CFX_ByteString key = GetNextWord(nullptr); | 552 CFX_ByteString key = GetNextWord(nullptr); |
| 551 if (key.IsEmpty()) | 553 if (key.IsEmpty()) |
| 552 return nullptr; | 554 return nullptr; |
| 553 | 555 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 } | 915 } |
| 914 | 916 |
| 915 void CPDF_SyntaxParser::SetEncrypt( | 917 void CPDF_SyntaxParser::SetEncrypt( |
| 916 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) { | 918 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) { |
| 917 m_pCryptoHandler = std::move(pCryptoHandler); | 919 m_pCryptoHandler = std::move(pCryptoHandler); |
| 918 } | 920 } |
| 919 | 921 |
| 920 CFX_ByteString CPDF_SyntaxParser::MaybeIntern(const CFX_ByteString& str) { | 922 CFX_ByteString CPDF_SyntaxParser::MaybeIntern(const CFX_ByteString& str) { |
| 921 return m_pPool ? m_pPool->Intern(str) : str; | 923 return m_pPool ? m_pPool->Intern(str) : str; |
| 922 } | 924 } |
| OLD | NEW |