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

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

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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/include/cpdf_simple_parser.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" 9 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
10 10
11 CPDF_SimpleParser::CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize) 11 CPDF_SimpleParser::CPDF_SimpleParser(const uint8_t* pData, uint32_t dwSize)
12 : m_pData(pData), m_dwSize(dwSize), m_dwCurPos(0) {} 12 : m_pData(pData), m_dwSize(dwSize), m_dwCurPos(0) {}
13 13
14 CPDF_SimpleParser::CPDF_SimpleParser(const CFX_ByteStringC& str) 14 CPDF_SimpleParser::CPDF_SimpleParser(const CFX_ByteStringC& str)
15 : m_pData(str.GetPtr()), m_dwSize(str.GetLength()), m_dwCurPos(0) {} 15 : m_pData(str.GetPtr()), m_dwSize(str.GetLength()), m_dwCurPos(0) {}
16 16
17 void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, FX_DWORD& dwSize) { 17 void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, uint32_t& dwSize) {
18 pStart = nullptr; 18 pStart = nullptr;
19 dwSize = 0; 19 dwSize = 0;
20 uint8_t ch; 20 uint8_t ch;
21 while (1) { 21 while (1) {
22 if (m_dwSize <= m_dwCurPos) 22 if (m_dwSize <= m_dwCurPos)
23 return; 23 return;
24 ch = m_pData[m_dwCurPos++]; 24 ch = m_pData[m_dwCurPos++];
25 while (PDFCharIsWhitespace(ch)) { 25 while (PDFCharIsWhitespace(ch)) {
26 if (m_dwSize <= m_dwCurPos) 26 if (m_dwSize <= m_dwCurPos)
27 return; 27 return;
28 ch = m_pData[m_dwCurPos++]; 28 ch = m_pData[m_dwCurPos++];
29 } 29 }
30 30
31 if (ch != '%') 31 if (ch != '%')
32 break; 32 break;
33 33
34 while (1) { 34 while (1) {
35 if (m_dwSize <= m_dwCurPos) 35 if (m_dwSize <= m_dwCurPos)
36 return; 36 return;
37 ch = m_pData[m_dwCurPos++]; 37 ch = m_pData[m_dwCurPos++];
38 if (PDFCharIsLineEnding(ch)) 38 if (PDFCharIsLineEnding(ch))
39 break; 39 break;
40 } 40 }
41 } 41 }
42 42
43 FX_DWORD start_pos = m_dwCurPos - 1; 43 uint32_t start_pos = m_dwCurPos - 1;
44 pStart = m_pData + start_pos; 44 pStart = m_pData + start_pos;
45 if (PDFCharIsDelimiter(ch)) { 45 if (PDFCharIsDelimiter(ch)) {
46 if (ch == '/') { 46 if (ch == '/') {
47 while (1) { 47 while (1) {
48 if (m_dwSize <= m_dwCurPos) 48 if (m_dwSize <= m_dwCurPos)
49 return; 49 return;
50 ch = m_pData[m_dwCurPos++]; 50 ch = m_pData[m_dwCurPos++];
51 if (!PDFCharIsOther(ch) && !PDFCharIsNumeric(ch)) { 51 if (!PDFCharIsOther(ch) && !PDFCharIsNumeric(ch)) {
52 m_dwCurPos--; 52 m_dwCurPos--;
53 dwSize = m_dwCurPos - start_pos; 53 dwSize = m_dwCurPos - start_pos;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 if (PDFCharIsDelimiter(ch) || PDFCharIsWhitespace(ch)) { 86 if (PDFCharIsDelimiter(ch) || PDFCharIsWhitespace(ch)) {
87 m_dwCurPos--; 87 m_dwCurPos--;
88 break; 88 break;
89 } 89 }
90 dwSize++; 90 dwSize++;
91 } 91 }
92 } 92 }
93 93
94 CFX_ByteStringC CPDF_SimpleParser::GetWord() { 94 CFX_ByteStringC CPDF_SimpleParser::GetWord() {
95 const uint8_t* pStart; 95 const uint8_t* pStart;
96 FX_DWORD dwSize; 96 uint32_t dwSize;
97 ParseWord(pStart, dwSize); 97 ParseWord(pStart, dwSize);
98 if (dwSize == 1 && pStart[0] == '<') { 98 if (dwSize == 1 && pStart[0] == '<') {
99 while (m_dwCurPos < m_dwSize && m_pData[m_dwCurPos] != '>') { 99 while (m_dwCurPos < m_dwSize && m_pData[m_dwCurPos] != '>') {
100 m_dwCurPos++; 100 m_dwCurPos++;
101 } 101 }
102 if (m_dwCurPos < m_dwSize) { 102 if (m_dwCurPos < m_dwSize) {
103 m_dwCurPos++; 103 m_dwCurPos++;
104 } 104 }
105 return CFX_ByteStringC(pStart, 105 return CFX_ByteStringC(pStart,
106 (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData))); 106 (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData)));
(...skipping 25 matching lines...) Expand all
132 } 132 }
133 return CFX_ByteStringC(pStart, 133 return CFX_ByteStringC(pStart,
134 (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData))); 134 (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData)));
135 } 135 }
136 return CFX_ByteStringC(pStart, dwSize); 136 return CFX_ByteStringC(pStart, dwSize);
137 } 137 }
138 138
139 bool CPDF_SimpleParser::FindTagParamFromStart(const CFX_ByteStringC& token, 139 bool CPDF_SimpleParser::FindTagParamFromStart(const CFX_ByteStringC& token,
140 int nParams) { 140 int nParams) {
141 nParams++; 141 nParams++;
142 FX_DWORD* pBuf = FX_Alloc(FX_DWORD, nParams); 142 uint32_t* pBuf = FX_Alloc(uint32_t, nParams);
143 int buf_index = 0; 143 int buf_index = 0;
144 int buf_count = 0; 144 int buf_count = 0;
145 m_dwCurPos = 0; 145 m_dwCurPos = 0;
146 while (1) { 146 while (1) {
147 pBuf[buf_index++] = m_dwCurPos; 147 pBuf[buf_index++] = m_dwCurPos;
148 if (buf_index == nParams) { 148 if (buf_index == nParams) {
149 buf_index = 0; 149 buf_index = 0;
150 } 150 }
151 buf_count++; 151 buf_count++;
152 if (buf_count > nParams) { 152 if (buf_count > nParams) {
153 buf_count = nParams; 153 buf_count = nParams;
154 } 154 }
155 CFX_ByteStringC word = GetWord(); 155 CFX_ByteStringC word = GetWord();
156 if (word.IsEmpty()) { 156 if (word.IsEmpty()) {
157 FX_Free(pBuf); 157 FX_Free(pBuf);
158 return false; 158 return false;
159 } 159 }
160 if (word == token) { 160 if (word == token) {
161 if (buf_count < nParams) { 161 if (buf_count < nParams) {
162 continue; 162 continue;
163 } 163 }
164 m_dwCurPos = pBuf[buf_index]; 164 m_dwCurPos = pBuf[buf_index];
165 FX_Free(pBuf); 165 FX_Free(pBuf);
166 return true; 166 return true;
167 } 167 }
168 } 168 }
169 return false; 169 return false;
170 } 170 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_reference.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698