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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 880663003: Kill scattered extern _PDF_CharType declarations. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix typo in 'N' in fpdf_parser.h comment. Created 5 years, 10 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 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 "../../../include/fpdfapi/fpdf_parser.h" 7 #include "../../../include/fpdfapi/fpdf_parser.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fpdfapi/fpdf_page.h" 9 #include "../../../include/fpdfapi/fpdf_page.h"
10 #include "../../../../third_party/numerics/safe_math.h" 10 #include "../../../../third_party/numerics/safe_math.h"
11 #include "../fpdf_page/pageint.h" 11 #include "../fpdf_page/pageint.h"
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 extern const FX_LPCSTR _PDF_CharType;
16 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) 15 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict)
17 { 16 {
18 CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type")); 17 CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type"));
19 if (!pType) { 18 if (!pType) {
20 pType = pDict->GetElementValue(FX_BSTRC("FT")); 19 pType = pDict->GetElementValue(FX_BSTRC("FT"));
21 if (!pType) { 20 if (!pType) {
22 return FALSE; 21 return FALSE;
23 } 22 }
24 } 23 }
25 if (pType->GetString() == FX_BSTRC("Sig")) { 24 if (pType->GetString() == FX_BSTRC("Sig")) {
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 if (size > 4096) { 640 if (size > 4096) {
642 size = 4096; 641 size = 4096;
643 } 642 }
644 if (!m_Syntax.m_pFileAccess->ReadBlock(buffer, pos, size)) { 643 if (!m_Syntax.m_pFileAccess->ReadBlock(buffer, pos, size)) {
645 break; 644 break;
646 } 645 }
647 for (FX_DWORD i = 0; i < size; i ++) { 646 for (FX_DWORD i = 0; i < size; i ++) {
648 FX_BYTE byte = buffer[i]; 647 FX_BYTE byte = buffer[i];
649 switch (status) { 648 switch (status) {
650 case 0: 649 case 0:
651 if (_PDF_CharType[byte] == 'W') { 650 if (PDF_CharType[byte] == 'W') {
652 status = 1; 651 status = 1;
653 } 652 }
654 if (byte <= '9' && byte >= '0') { 653 if (byte <= '9' && byte >= '0') {
655 --i; 654 --i;
656 status = 1; 655 status = 1;
657 } 656 }
658 if (byte == '%') { 657 if (byte == '%') {
659 inside_index = 0; 658 inside_index = 0;
660 status = 9; 659 status = 9;
661 } 660 }
662 if (byte == '(') { 661 if (byte == '(') {
663 status = 10; 662 status = 10;
664 depth = 1; 663 depth = 1;
665 } 664 }
666 if (byte == '<') { 665 if (byte == '<') {
667 inside_index = 1; 666 inside_index = 1;
668 status = 11; 667 status = 11;
669 } 668 }
670 if (byte == '\\') { 669 if (byte == '\\') {
671 status = 13; 670 status = 13;
672 } 671 }
673 if (byte == 't') { 672 if (byte == 't') {
674 status = 7; 673 status = 7;
675 inside_index = 1; 674 inside_index = 1;
676 } 675 }
677 break; 676 break;
678 case 1: 677 case 1:
679 if (_PDF_CharType[byte] == 'W') { 678 if (PDF_CharType[byte] == 'W') {
680 break; 679 break;
681 } else if (byte <= '9' && byte >= '0') { 680 } else if (byte <= '9' && byte >= '0') {
682 start_pos = pos + i; 681 start_pos = pos + i;
683 status = 2; 682 status = 2;
684 objnum = byte - '0'; 683 objnum = byte - '0';
685 } else if (byte == 't') { 684 } else if (byte == 't') {
686 status = 7; 685 status = 7;
687 inside_index = 1; 686 inside_index = 1;
688 } else if (byte == 'x') { 687 } else if (byte == 'x') {
689 status = 8; 688 status = 8;
690 inside_index = 1; 689 inside_index = 1;
691 } else { 690 } else {
692 --i; 691 --i;
693 status = 0; 692 status = 0;
694 } 693 }
695 break; 694 break;
696 case 2: 695 case 2:
697 if (byte <= '9' && byte >= '0') { 696 if (byte <= '9' && byte >= '0') {
698 objnum = objnum * 10 + byte - '0'; 697 objnum = objnum * 10 + byte - '0';
699 break; 698 break;
700 } else if (_PDF_CharType[byte] == 'W') { 699 } else if (PDF_CharType[byte] == 'W') {
701 status = 3; 700 status = 3;
702 } else { 701 } else {
703 --i; 702 --i;
704 status = 14; 703 status = 14;
705 inside_index = 0; 704 inside_index = 0;
706 } 705 }
707 break; 706 break;
708 case 3: 707 case 3:
709 if (byte <= '9' && byte >= '0') { 708 if (byte <= '9' && byte >= '0') {
710 start_pos1 = pos + i; 709 start_pos1 = pos + i;
711 status = 4; 710 status = 4;
712 gennum = byte - '0'; 711 gennum = byte - '0';
713 } else if (_PDF_CharType[byte] == 'W') { 712 } else if (PDF_CharType[byte] == 'W') {
714 break; 713 break;
715 } else if (byte == 't') { 714 } else if (byte == 't') {
716 status = 7; 715 status = 7;
717 inside_index = 1; 716 inside_index = 1;
718 } else { 717 } else {
719 --i; 718 --i;
720 status = 0; 719 status = 0;
721 } 720 }
722 break; 721 break;
723 case 4: 722 case 4:
724 if (byte <= '9' && byte >= '0') { 723 if (byte <= '9' && byte >= '0') {
725 gennum = gennum * 10 + byte - '0'; 724 gennum = gennum * 10 + byte - '0';
726 break; 725 break;
727 } else if (_PDF_CharType[byte] == 'W') { 726 } else if (PDF_CharType[byte] == 'W') {
728 status = 5; 727 status = 5;
729 } else { 728 } else {
730 --i; 729 --i;
731 status = 0; 730 status = 0;
732 } 731 }
733 break; 732 break;
734 case 5: 733 case 5:
735 if (byte == 'o') { 734 if (byte == 'o') {
736 status = 6; 735 status = 6;
737 inside_index = 1; 736 inside_index = 1;
738 } else if (_PDF_CharType[byte] == 'W') { 737 } else if (PDF_CharType[byte] == 'W') {
739 break; 738 break;
740 } else if (byte <= '9' && byte >= '0') { 739 } else if (byte <= '9' && byte >= '0') {
741 objnum = gennum; 740 objnum = gennum;
742 gennum = byte - '0'; 741 gennum = byte - '0';
743 start_pos = start_pos1; 742 start_pos = start_pos1;
744 start_pos1 = pos + i; 743 start_pos1 = pos + i;
745 status = 4; 744 status = 4;
746 } else if (byte == 't') { 745 } else if (byte == 't') {
747 status = 7; 746 status = 7;
748 inside_index = 1; 747 inside_index = 1;
(...skipping 14 matching lines...) Expand all
763 break; 762 break;
764 case 2: 763 case 2:
765 if (byte != 'j') { 764 if (byte != 'j') {
766 --i; 765 --i;
767 status = 0; 766 status = 0;
768 } else { 767 } else {
769 inside_index ++; 768 inside_index ++;
770 } 769 }
771 break; 770 break;
772 case 3: 771 case 3:
773 if (_PDF_CharType[byte] == 'W' || _PDF_CharType[byte ] == 'D') { 772 if (PDF_CharType[byte] == 'W' || PDF_CharType[byte] == 'D') {
774 if (objnum > 0x1000000) { 773 if (objnum > 0x1000000) {
775 status = 0; 774 status = 0;
776 break; 775 break;
777 } 776 }
778 FX_FILESIZE obj_pos = start_pos - m_Syntax.m_Hea derOffset; 777 FX_FILESIZE obj_pos = start_pos - m_Syntax.m_Hea derOffset;
779 last_obj = start_pos; 778 last_obj = start_pos;
780 FX_LPVOID pResult = FXSYS_bsearch(&obj_pos, m_So rtedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFil eSize); 779 FX_LPVOID pResult = FXSYS_bsearch(&obj_pos, m_So rtedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFil eSize);
781 if (pResult == NULL) { 780 if (pResult == NULL) {
782 m_SortedOffset.Add(obj_pos); 781 m_SortedOffset.Add(obj_pos);
783 } 782 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 pObject->Release(); 836 pObject->Release();
838 } 837 }
839 } 838 }
840 --i; 839 --i;
841 status = 0; 840 status = 0;
842 break; 841 break;
843 } 842 }
844 break; 843 break;
845 case 7: 844 case 7:
846 if (inside_index == 7) { 845 if (inside_index == 7) {
847 if (_PDF_CharType[byte] == 'W' || _PDF_CharType[byte] == 'D') { 846 if (PDF_CharType[byte] == 'W' || PDF_CharType[byte] == ' D') {
848 last_trailer = pos + i - 7; 847 last_trailer = pos + i - 7;
849 m_Syntax.RestorePos(pos + i - m_Syntax.m_HeaderOffse t); 848 m_Syntax.RestorePos(pos + i - m_Syntax.m_HeaderOffse t);
850 CPDF_Object* pObj = m_Syntax.GetObject(m_pDocument, 0, 0, 0); 849 CPDF_Object* pObj = m_Syntax.GetObject(m_pDocument, 0, 0, 0);
851 if (pObj) { 850 if (pObj) {
852 if (pObj->GetType() != PDFOBJ_DICTIONARY && pObj ->GetType() != PDFOBJ_STREAM) { 851 if (pObj->GetType() != PDFOBJ_DICTIONARY && pObj ->GetType() != PDFOBJ_STREAM) {
853 pObj->Release(); 852 pObj->Release();
854 } else { 853 } else {
855 CPDF_Dictionary* pTrailer = NULL; 854 CPDF_Dictionary* pTrailer = NULL;
856 if (pObj->GetType() == PDFOBJ_STREAM) { 855 if (pObj->GetType() == PDFOBJ_STREAM) {
857 pTrailer = ((CPDF_Stream*)pObj)->GetDict (); 856 pTrailer = ((CPDF_Stream*)pObj)->GetDict ();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 } else if (byte == '>') { 941 } else if (byte == '>') {
943 status = 0; 942 status = 0;
944 } 943 }
945 inside_index = 0; 944 inside_index = 0;
946 break; 945 break;
947 case 12: 946 case 12:
948 --i; 947 --i;
949 status = 0; 948 status = 0;
950 break; 949 break;
951 case 13: 950 case 13:
952 if (_PDF_CharType[byte] == 'D' || _PDF_CharType[byte] == 'W' ) { 951 if (PDF_CharType[byte] == 'D' || PDF_CharType[byte] == 'W') {
953 --i; 952 --i;
954 status = 0; 953 status = 0;
955 } 954 }
956 break; 955 break;
957 case 14: 956 case 14:
958 if (_PDF_CharType[byte] == 'W') { 957 if (PDF_CharType[byte] == 'W') {
959 status = 0; 958 status = 0;
960 } else if (byte == '%' || byte == '(' || byte == '<' || byte == '\\') { 959 } else if (byte == '%' || byte == '(' || byte == '<' || byte == '\\') {
961 status = 0; 960 status = 0;
962 --i; 961 --i;
963 } else if (inside_index == 6) { 962 } else if (inside_index == 6) {
964 status = 0; 963 status = 0;
965 --i; 964 --i;
966 } else if (byte == "endobj"[inside_index]) { 965 } else if (byte == "endobj"[inside_index]) {
967 inside_index++; 966 inside_index++;
968 } 967 }
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 FX_DWORD dwSaveMetadataObjnum = m_Syntax.m_MetadataObjnum; 1641 FX_DWORD dwSaveMetadataObjnum = m_Syntax.m_MetadataObjnum;
1643 m_Syntax.m_MetadataObjnum = 0; 1642 m_Syntax.m_MetadataObjnum = 0;
1644 if (m_pTrailer) { 1643 if (m_pTrailer) {
1645 m_pTrailer->Release(); 1644 m_pTrailer->Release();
1646 m_pTrailer = NULL; 1645 m_pTrailer = NULL;
1647 } 1646 }
1648 m_Syntax.RestorePos(m_LastXRefOffset - m_Syntax.m_HeaderOffset); 1647 m_Syntax.RestorePos(m_LastXRefOffset - m_Syntax.m_HeaderOffset);
1649 FX_BYTE ch = 0; 1648 FX_BYTE ch = 0;
1650 FX_DWORD dwCount = 0; 1649 FX_DWORD dwCount = 0;
1651 m_Syntax.GetNextChar(ch); 1650 m_Syntax.GetNextChar(ch);
1652 FX_INT32 type = _PDF_CharType[ch]; 1651 FX_INT32 type = PDF_CharType[ch];
1653 while (type == 'W') { 1652 while (type == 'W') {
1654 ++dwCount; 1653 ++dwCount;
1655 if (m_Syntax.m_FileLen >= (FX_FILESIZE)(m_Syntax.SavePos() + m_Syntax.m_ HeaderOffset)) { 1654 if (m_Syntax.m_FileLen >= (FX_FILESIZE)(m_Syntax.SavePos() + m_Syntax.m_ HeaderOffset)) {
1656 break; 1655 break;
1657 } 1656 }
1658 m_Syntax.GetNextChar(ch); 1657 m_Syntax.GetNextChar(ch);
1659 type = _PDF_CharType[ch]; 1658 type = PDF_CharType[ch];
1660 } 1659 }
1661 m_LastXRefOffset += dwCount; 1660 m_LastXRefOffset += dwCount;
1662 FX_POSITION pos = m_ObjectStreamMap.GetStartPosition(); 1661 FX_POSITION pos = m_ObjectStreamMap.GetStartPosition();
1663 while (pos) { 1662 while (pos) {
1664 FX_LPVOID objnum; 1663 FX_LPVOID objnum;
1665 CPDF_StreamAcc* pStream; 1664 CPDF_StreamAcc* pStream;
1666 m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); 1665 m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream);
1667 delete pStream; 1666 delete pStream;
1668 } 1667 }
1669 m_ObjectStreamMap.RemoveAll(); 1668 m_ObjectStreamMap.RemoveAll();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 } 1773 }
1775 #define MAX_WORD_BUFFER 256 1774 #define MAX_WORD_BUFFER 256
1776 void CPDF_SyntaxParser::GetNextWord() 1775 void CPDF_SyntaxParser::GetNextWord()
1777 { 1776 {
1778 m_WordSize = 0; 1777 m_WordSize = 0;
1779 m_bIsNumber = TRUE; 1778 m_bIsNumber = TRUE;
1780 FX_BYTE ch; 1779 FX_BYTE ch;
1781 if (!GetNextChar(ch)) { 1780 if (!GetNextChar(ch)) {
1782 return; 1781 return;
1783 } 1782 }
1784 FX_BYTE type = _PDF_CharType[ch]; 1783 FX_BYTE type = PDF_CharType[ch];
1785 while (1) { 1784 while (1) {
1786 while (type == 'W') { 1785 while (type == 'W') {
1787 if (!GetNextChar(ch)) { 1786 if (!GetNextChar(ch)) {
1788 return; 1787 return;
1789 } 1788 }
1790 type = _PDF_CharType[ch]; 1789 type = PDF_CharType[ch];
1791 } 1790 }
1792 if (ch != '%') { 1791 if (ch != '%') {
1793 break; 1792 break;
1794 } 1793 }
1795 while (1) { 1794 while (1) {
1796 if (!GetNextChar(ch)) { 1795 if (!GetNextChar(ch)) {
1797 return; 1796 return;
1798 } 1797 }
1799 if (ch == '\r' || ch == '\n') { 1798 if (ch == '\r' || ch == '\n') {
1800 break; 1799 break;
1801 } 1800 }
1802 } 1801 }
1803 type = _PDF_CharType[ch]; 1802 type = PDF_CharType[ch];
1804 } 1803 }
1805 if (type == 'D') { 1804 if (type == 'D') {
1806 m_bIsNumber = FALSE; 1805 m_bIsNumber = FALSE;
1807 m_WordBuffer[m_WordSize++] = ch; 1806 m_WordBuffer[m_WordSize++] = ch;
1808 if (ch == '/') { 1807 if (ch == '/') {
1809 while (1) { 1808 while (1) {
1810 if (!GetNextChar(ch)) { 1809 if (!GetNextChar(ch)) {
1811 return; 1810 return;
1812 } 1811 }
1813 type = _PDF_CharType[ch]; 1812 type = PDF_CharType[ch];
1814 if (type != 'R' && type != 'N') { 1813 if (type != 'R' && type != 'N') {
1815 m_Pos --; 1814 m_Pos --;
1816 return; 1815 return;
1817 } 1816 }
1818 if (m_WordSize < MAX_WORD_BUFFER) { 1817 if (m_WordSize < MAX_WORD_BUFFER) {
1819 m_WordBuffer[m_WordSize++] = ch; 1818 m_WordBuffer[m_WordSize++] = ch;
1820 } 1819 }
1821 } 1820 }
1822 } else if (ch == '<') { 1821 } else if (ch == '<') {
1823 if (!GetNextChar(ch)) { 1822 if (!GetNextChar(ch)) {
(...skipping 19 matching lines...) Expand all
1843 while (1) { 1842 while (1) {
1844 if (m_WordSize < MAX_WORD_BUFFER) { 1843 if (m_WordSize < MAX_WORD_BUFFER) {
1845 m_WordBuffer[m_WordSize++] = ch; 1844 m_WordBuffer[m_WordSize++] = ch;
1846 } 1845 }
1847 if (type != 'N') { 1846 if (type != 'N') {
1848 m_bIsNumber = FALSE; 1847 m_bIsNumber = FALSE;
1849 } 1848 }
1850 if (!GetNextChar(ch)) { 1849 if (!GetNextChar(ch)) {
1851 return; 1850 return;
1852 } 1851 }
1853 type = _PDF_CharType[ch]; 1852 type = PDF_CharType[ch];
1854 if (type == 'D' || type == 'W') { 1853 if (type == 'D' || type == 'W') {
1855 m_Pos --; 1854 m_Pos --;
1856 break; 1855 break;
1857 } 1856 }
1858 } 1857 }
1859 } 1858 }
1860 CFX_ByteString CPDF_SyntaxParser::ReadString() 1859 CFX_ByteString CPDF_SyntaxParser::ReadString()
1861 { 1860 {
1862 FX_BYTE ch; 1861 FX_BYTE ch;
1863 if (!GetNextChar(ch)) { 1862 if (!GetNextChar(ch)) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 } 2010 }
2012 } 2011 }
2013 } 2012 }
2014 } 2013 }
2015 void CPDF_SyntaxParser::ToNextWord() 2014 void CPDF_SyntaxParser::ToNextWord()
2016 { 2015 {
2017 FX_BYTE ch; 2016 FX_BYTE ch;
2018 if (!GetNextChar(ch)) { 2017 if (!GetNextChar(ch)) {
2019 return; 2018 return;
2020 } 2019 }
2021 FX_BYTE type = _PDF_CharType[ch]; 2020 FX_BYTE type = PDF_CharType[ch];
2022 while (1) { 2021 while (1) {
2023 while (type == 'W') { 2022 while (type == 'W') {
2024 m_dwWordPos = m_Pos; 2023 m_dwWordPos = m_Pos;
2025 if (!GetNextChar(ch)) { 2024 if (!GetNextChar(ch)) {
2026 return; 2025 return;
2027 } 2026 }
2028 type = _PDF_CharType[ch]; 2027 type = PDF_CharType[ch];
2029 } 2028 }
2030 if (ch != '%') { 2029 if (ch != '%') {
2031 break; 2030 break;
2032 } 2031 }
2033 while (1) { 2032 while (1) {
2034 if (!GetNextChar(ch)) { 2033 if (!GetNextChar(ch)) {
2035 return; 2034 return;
2036 } 2035 }
2037 if (ch == '\r' || ch == '\n') { 2036 if (ch == '\r' || ch == '\n') {
2038 break; 2037 break;
2039 } 2038 }
2040 } 2039 }
2041 type = _PDF_CharType[ch]; 2040 type = PDF_CharType[ch];
2042 } 2041 }
2043 m_Pos --; 2042 m_Pos --;
2044 } 2043 }
2045 CFX_ByteString CPDF_SyntaxParser::GetNextWord(FX_BOOL& bIsNumber) 2044 CFX_ByteString CPDF_SyntaxParser::GetNextWord(FX_BOOL& bIsNumber)
2046 { 2045 {
2047 GetNextWord(); 2046 GetNextWord();
2048 bIsNumber = m_bIsNumber; 2047 bIsNumber = m_bIsNumber;
2049 return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize); 2048 return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize);
2050 } 2049 }
2051 CFX_ByteString CPDF_SyntaxParser::GetKeyword() 2050 CFX_ByteString CPDF_SyntaxParser::GetKeyword()
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2523 { 2522 {
2524 GetNextWord(); 2523 GetNextWord();
2525 if (!m_bIsNumber) { 2524 if (!m_bIsNumber) {
2526 return 0; 2525 return 0;
2527 } 2526 }
2528 m_WordBuffer[m_WordSize] = 0; 2527 m_WordBuffer[m_WordSize] = 0;
2529 return FXSYS_atoi((FX_LPCSTR)m_WordBuffer); 2528 return FXSYS_atoi((FX_LPCSTR)m_WordBuffer);
2530 } 2529 }
2531 FX_BOOL CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, FX_LPCBYTE tag, FX_DWORD taglen) 2530 FX_BOOL CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, FX_LPCBYTE tag, FX_DWORD taglen)
2532 { 2531 {
2533 FX_BYTE type = _PDF_CharType[tag[0]]; 2532 FX_BYTE type = PDF_CharType[tag[0]];
2534 FX_BOOL bCheckLeft = type != 'D' && type != 'W'; 2533 FX_BOOL bCheckLeft = type != 'D' && type != 'W';
2535 type = _PDF_CharType[tag[taglen - 1]]; 2534 type = PDF_CharType[tag[taglen - 1]];
2536 FX_BOOL bCheckRight = type != 'D' && type != 'W'; 2535 FX_BOOL bCheckRight = type != 'D' && type != 'W';
2537 FX_BYTE ch; 2536 FX_BYTE ch;
2538 if (bCheckRight && startpos + (FX_INT32)taglen <= limit && GetCharAt(startpo s + (FX_INT32)taglen, ch)) { 2537 if (bCheckRight && startpos + (FX_INT32)taglen <= limit && GetCharAt(startpo s + (FX_INT32)taglen, ch)) {
2539 FX_BYTE type = _PDF_CharType[ch]; 2538 FX_BYTE type = PDF_CharType[ch];
2540 if (type == 'N' || type == 'R') { 2539 if (type == 'N' || type == 'R') {
2541 return FALSE; 2540 return FALSE;
2542 } 2541 }
2543 } 2542 }
2544 if (bCheckLeft && startpos > 0 && GetCharAt(startpos - 1, ch)) { 2543 if (bCheckLeft && startpos > 0 && GetCharAt(startpos - 1, ch)) {
2545 FX_BYTE type = _PDF_CharType[ch]; 2544 FX_BYTE type = PDF_CharType[ch];
2546 if (type == 'N' || type == 'R') { 2545 if (type == 'N' || type == 'R') {
2547 return FALSE; 2546 return FALSE;
2548 } 2547 }
2549 } 2548 }
2550 return TRUE; 2549 return TRUE;
2551 } 2550 }
2552 FX_BOOL CPDF_SyntaxParser::SearchWord(FX_BSTR tag, FX_BOOL bWholeWord, FX_BOOL b Forward, FX_FILESIZE limit) 2551 FX_BOOL CPDF_SyntaxParser::SearchWord(FX_BSTR tag, FX_BOOL bWholeWord, FX_BOOL b Forward, FX_FILESIZE limit)
2553 { 2552 {
2554 FX_INT32 taglen = tag.GetLength(); 2553 FX_INT32 taglen = tag.GetLength();
2555 if (taglen == 0) { 2554 if (taglen == 0) {
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3821 m_Pos = dwOffset; 3820 m_Pos = dwOffset;
3822 } 3821 }
3823 #define MAX_WORD_BUFFER 256 3822 #define MAX_WORD_BUFFER 256
3824 FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token) 3823 FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token)
3825 { 3824 {
3826 m_WordSize = 0; 3825 m_WordSize = 0;
3827 FX_BYTE ch; 3826 FX_BYTE ch;
3828 if (!GetNextChar(ch)) { 3827 if (!GetNextChar(ch)) {
3829 return FALSE; 3828 return FALSE;
3830 } 3829 }
3831 FX_BYTE type = _PDF_CharType[ch]; 3830 FX_BYTE type = PDF_CharType[ch];
3832 while (1) { 3831 while (1) {
3833 while (type == 'W') { 3832 while (type == 'W') {
3834 if (!GetNextChar(ch)) { 3833 if (!GetNextChar(ch)) {
3835 return FALSE; 3834 return FALSE;
3836 } 3835 }
3837 type = _PDF_CharType[ch]; 3836 type = PDF_CharType[ch];
3838 } 3837 }
3839 if (ch != '%') { 3838 if (ch != '%') {
3840 break; 3839 break;
3841 } 3840 }
3842 while (1) { 3841 while (1) {
3843 if (!GetNextChar(ch)) { 3842 if (!GetNextChar(ch)) {
3844 return FALSE; 3843 return FALSE;
3845 } 3844 }
3846 if (ch == '\r' || ch == '\n') { 3845 if (ch == '\r' || ch == '\n') {
3847 break; 3846 break;
3848 } 3847 }
3849 } 3848 }
3850 type = _PDF_CharType[ch]; 3849 type = PDF_CharType[ch];
3851 } 3850 }
3852 if (type == 'D') { 3851 if (type == 'D') {
3853 m_WordBuffer[m_WordSize++] = ch; 3852 m_WordBuffer[m_WordSize++] = ch;
3854 if (ch == '/') { 3853 if (ch == '/') {
3855 while (1) { 3854 while (1) {
3856 if (!GetNextChar(ch)) { 3855 if (!GetNextChar(ch)) {
3857 return FALSE; 3856 return FALSE;
3858 } 3857 }
3859 type = _PDF_CharType[ch]; 3858 type = PDF_CharType[ch];
3860 if (type != 'R' && type != 'N') { 3859 if (type != 'R' && type != 'N') {
3861 m_Pos --; 3860 m_Pos --;
3862 CFX_ByteString ret(m_WordBuffer, m_WordSize); 3861 CFX_ByteString ret(m_WordBuffer, m_WordSize);
3863 token = ret; 3862 token = ret;
3864 return TRUE; 3863 return TRUE;
3865 } 3864 }
3866 if (m_WordSize < MAX_WORD_BUFFER) { 3865 if (m_WordSize < MAX_WORD_BUFFER) {
3867 m_WordBuffer[m_WordSize++] = ch; 3866 m_WordBuffer[m_WordSize++] = ch;
3868 } 3867 }
3869 } 3868 }
(...skipping 20 matching lines...) Expand all
3890 token = ret; 3889 token = ret;
3891 return TRUE; 3890 return TRUE;
3892 } 3891 }
3893 while (1) { 3892 while (1) {
3894 if (m_WordSize < MAX_WORD_BUFFER) { 3893 if (m_WordSize < MAX_WORD_BUFFER) {
3895 m_WordBuffer[m_WordSize++] = ch; 3894 m_WordBuffer[m_WordSize++] = ch;
3896 } 3895 }
3897 if (!GetNextChar(ch)) { 3896 if (!GetNextChar(ch)) {
3898 return FALSE; 3897 return FALSE;
3899 } 3898 }
3900 type = _PDF_CharType[ch]; 3899 type = PDF_CharType[ch];
3901 if (type == 'D' || type == 'W') { 3900 if (type == 'D' || type == 'W') {
3902 m_Pos --; 3901 m_Pos --;
3903 break; 3902 break;
3904 } 3903 }
3905 } 3904 }
3906 CFX_ByteString ret(m_WordBuffer, m_WordSize); 3905 CFX_ByteString ret(m_WordBuffer, m_WordSize);
3907 token = ret; 3906 token = ret;
3908 return TRUE; 3907 return TRUE;
3909 } 3908 }
3910 FX_BOOL CPDF_DataAvail::GetNextChar(FX_BYTE &ch) 3909 FX_BOOL CPDF_DataAvail::GetNextChar(FX_BYTE &ch)
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
4629 { 4628 {
4630 FX_INT32 iSize = m_childNode.GetSize(); 4629 FX_INT32 iSize = m_childNode.GetSize();
4631 for (FX_INT32 i = 0; i < iSize; ++i) { 4630 for (FX_INT32 i = 0; i < iSize; ++i) {
4632 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; 4631 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i];
4633 if (pNode) { 4632 if (pNode) {
4634 delete pNode; 4633 delete pNode;
4635 } 4634 }
4636 } 4635 }
4637 m_childNode.RemoveAll(); 4636 m_childNode.RemoveAll();
4638 } 4637 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698