Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp

Issue 2027273002: Fix all the code which has duplicate variable declarations (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/fpdf_parser/cpdf_syntax_parser.h" 7 #include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 374 }
375 375
376 CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, 376 CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
377 uint32_t objnum, 377 uint32_t objnum,
378 uint32_t gennum, 378 uint32_t gennum,
379 FX_BOOL bDecrypt) { 379 FX_BOOL bDecrypt) {
380 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); 380 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth);
381 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) 381 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth)
382 return nullptr; 382 return nullptr;
383 383
384 FX_FILESIZE SavedPos = m_Pos; 384 FX_FILESIZE SavedObjPos = m_Pos;
385 bool bIsNumber; 385 bool bIsNumber;
386 CFX_ByteString word = GetNextWord(&bIsNumber); 386 CFX_ByteString word = GetNextWord(&bIsNumber);
387 if (word.GetLength() == 0) 387 if (word.GetLength() == 0)
388 return nullptr; 388 return nullptr;
389 389
390 if (bIsNumber) { 390 if (bIsNumber) {
391 FX_FILESIZE SavedPos = m_Pos; 391 FX_FILESIZE SavedPos = m_Pos;
392 CFX_ByteString nextword = GetNextWord(&bIsNumber); 392 CFX_ByteString nextword = GetNextWord(&bIsNumber);
393 if (bIsNumber) { 393 if (bIsNumber) {
394 CFX_ByteString nextword2 = GetNextWord(nullptr); 394 CFX_ByteString nextword2 = GetNextWord(nullptr);
395 if (nextword2 == "R") { 395 if (nextword2 == "R")
396 uint32_t objnum = FXSYS_atoui(word.c_str()); 396 return new CPDF_Reference(pObjList, FXSYS_atoui(word.c_str()));
397 return new CPDF_Reference(pObjList, objnum);
398 }
399 } 397 }
400 m_Pos = SavedPos; 398 m_Pos = SavedPos;
401 return new CPDF_Number(word.AsStringC()); 399 return new CPDF_Number(word.AsStringC());
402 } 400 }
403 401
404 if (word == "true" || word == "false") 402 if (word == "true" || word == "false")
405 return new CPDF_Boolean(word == "true"); 403 return new CPDF_Boolean(word == "true");
406 404
407 if (word == "null") 405 if (word == "null")
408 return new CPDF_Null; 406 return new CPDF_Null;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 FX_FILESIZE SavedPos = m_Pos; 483 FX_FILESIZE SavedPos = m_Pos;
486 CFX_ByteString nextword = GetNextWord(nullptr); 484 CFX_ByteString nextword = GetNextWord(nullptr);
487 if (nextword != "stream") { 485 if (nextword != "stream") {
488 m_Pos = SavedPos; 486 m_Pos = SavedPos;
489 return pDict.release(); 487 return pDict.release();
490 } 488 }
491 return ReadStream(pDict.release(), objnum, gennum); 489 return ReadStream(pDict.release(), objnum, gennum);
492 } 490 }
493 491
494 if (word == ">>") 492 if (word == ">>")
495 m_Pos = SavedPos; 493 m_Pos = SavedObjPos;
496 494
497 return nullptr; 495 return nullptr;
498 } 496 }
499 497
500 CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( 498 CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
501 CPDF_IndirectObjectHolder* pObjList, 499 CPDF_IndirectObjectHolder* pObjList,
502 uint32_t objnum, 500 uint32_t objnum,
503 uint32_t gennum) { 501 uint32_t gennum) {
504 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); 502 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth);
505 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) 503 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth)
506 return nullptr; 504 return nullptr;
507 505
508 FX_FILESIZE SavedPos = m_Pos; 506 FX_FILESIZE SavedObjPos = m_Pos;
509 bool bIsNumber; 507 bool bIsNumber;
510 CFX_ByteString word = GetNextWord(&bIsNumber); 508 CFX_ByteString word = GetNextWord(&bIsNumber);
511 if (word.GetLength() == 0) 509 if (word.GetLength() == 0)
512 return nullptr; 510 return nullptr;
513 511
514 if (bIsNumber) { 512 if (bIsNumber) {
515 FX_FILESIZE SavedPos = m_Pos; 513 FX_FILESIZE SavedPos = m_Pos;
516 CFX_ByteString nextword = GetNextWord(&bIsNumber); 514 CFX_ByteString nextword = GetNextWord(&bIsNumber);
517 if (bIsNumber) { 515 if (bIsNumber) {
518 CFX_ByteString nextword2 = GetNextWord(nullptr); 516 CFX_ByteString nextword2 = GetNextWord(nullptr);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 CFX_ByteString nextword = GetNextWord(nullptr); 596 CFX_ByteString nextword = GetNextWord(nullptr);
599 if (nextword != "stream") { 597 if (nextword != "stream") {
600 m_Pos = SavedPos; 598 m_Pos = SavedPos;
601 return pDict.release(); 599 return pDict.release();
602 } 600 }
603 601
604 return ReadStream(pDict.release(), objnum, gennum); 602 return ReadStream(pDict.release(), objnum, gennum);
605 } 603 }
606 604
607 if (word == ">>") 605 if (word == ">>")
608 m_Pos = SavedPos; 606 m_Pos = SavedObjPos;
609 607
610 return nullptr; 608 return nullptr;
611 } 609 }
612 610
613 unsigned int CPDF_SyntaxParser::ReadEOLMarkers(FX_FILESIZE pos) { 611 unsigned int CPDF_SyntaxParser::ReadEOLMarkers(FX_FILESIZE pos) {
614 unsigned char byte1 = 0; 612 unsigned char byte1 = 0;
615 unsigned char byte2 = 0; 613 unsigned char byte2 = 0;
616 614
617 GetCharAt(pos, byte1); 615 GetCharAt(pos, byte1);
618 GetCharAt(pos + 1, byte2); 616 GetCharAt(pos + 1, byte2);
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 if (limit && m_Pos == limit) 980 if (limit && m_Pos == limit)
983 return -1; 981 return -1;
984 } 982 }
985 return -1; 983 return -1;
986 } 984 }
987 985
988 void CPDF_SyntaxParser::SetEncrypt( 986 void CPDF_SyntaxParser::SetEncrypt(
989 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) { 987 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) {
990 m_pCryptoHandler = std::move(pCryptoHandler); 988 m_pCryptoHandler = std::move(pCryptoHandler);
991 } 989 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp ('k') | core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698