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

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

Issue 1171733003: Remove typdefs for pointer types in fx_system.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual fixes. Created 5 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 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 const char PDF_CharType[256] = { 8 const char PDF_CharType[256] = {
9 //NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO S I 9 //NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO S I
10 'W', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W', 'W', 'R', 'W', 'W', 'R', ' R', 10 'W', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W', 'W', 'R', 'W', 'W', 'R', ' R',
(...skipping 25 matching lines...) Expand all
36 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', ' R', 36 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', ' R',
37 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', ' R', 37 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', ' R',
38 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', ' R', 38 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', ' R',
39 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', ' R', 39 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', ' R',
40 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', ' W' 40 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', ' W'
41 }; 41 };
42 42
43 #ifndef MAX_PATH 43 #ifndef MAX_PATH
44 #define MAX_PATH 4096 44 #define MAX_PATH 4096
45 #endif 45 #endif
46 CPDF_SimpleParser::CPDF_SimpleParser(FX_LPCBYTE pData, FX_DWORD dwSize) 46 CPDF_SimpleParser::CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize)
47 { 47 {
48 m_pData = pData; 48 m_pData = pData;
49 m_dwSize = dwSize; 49 m_dwSize = dwSize;
50 m_dwCurPos = 0; 50 m_dwCurPos = 0;
51 } 51 }
52 CPDF_SimpleParser::CPDF_SimpleParser(FX_BSTR str) 52 CPDF_SimpleParser::CPDF_SimpleParser(FX_BSTR str)
53 { 53 {
54 m_pData = str.GetPtr(); 54 m_pData = str.GetPtr();
55 m_dwSize = str.GetLength(); 55 m_dwSize = str.GetLength();
56 m_dwCurPos = 0; 56 m_dwCurPos = 0;
57 } 57 }
58 void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& typ e) 58 void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, FX_DWORD& dwSize, int& type)
59 { 59 {
60 pStart = NULL; 60 pStart = NULL;
61 dwSize = 0; 61 dwSize = 0;
62 type = PDFWORD_EOF; 62 type = PDFWORD_EOF;
63 uint8_t ch; 63 uint8_t ch;
64 char chartype; 64 char chartype;
65 while (1) { 65 while (1) {
66 if (m_dwSize <= m_dwCurPos) { 66 if (m_dwSize <= m_dwCurPos) {
67 return; 67 return;
68 } 68 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 chartype = PDF_CharType[ch]; 146 chartype = PDF_CharType[ch];
147 if (chartype == 'D' || chartype == 'W') { 147 if (chartype == 'D' || chartype == 'W') {
148 m_dwCurPos --; 148 m_dwCurPos --;
149 break; 149 break;
150 } 150 }
151 dwSize ++; 151 dwSize ++;
152 } 152 }
153 } 153 }
154 CFX_ByteStringC CPDF_SimpleParser::GetWord() 154 CFX_ByteStringC CPDF_SimpleParser::GetWord()
155 { 155 {
156 FX_LPCBYTE pStart; 156 const uint8_t* pStart;
157 FX_DWORD dwSize; 157 FX_DWORD dwSize;
158 int type; 158 int type;
159 ParseWord(pStart, dwSize, type); 159 ParseWord(pStart, dwSize, type);
160 if (dwSize == 1 && pStart[0] == '<') { 160 if (dwSize == 1 && pStart[0] == '<') {
161 while (m_dwCurPos < m_dwSize && m_pData[m_dwCurPos] != '>') { 161 while (m_dwCurPos < m_dwSize && m_pData[m_dwCurPos] != '>') {
162 m_dwCurPos ++; 162 m_dwCurPos ++;
163 } 163 }
164 if (m_dwCurPos < m_dwSize) { 164 if (m_dwCurPos < m_dwSize) {
165 m_dwCurPos ++; 165 m_dwCurPos ++;
166 } 166 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return ch - 'a' + 10; 283 return ch - 'a' + 10;
284 } 284 }
285 if (ch >= 'A' && ch <= 'F') { 285 if (ch >= 'A' && ch <= 'F') {
286 return ch - 'A' + 10; 286 return ch - 'A' + 10;
287 } 287 }
288 return 0; 288 return 0;
289 } 289 }
290 CFX_ByteString PDF_NameDecode(FX_BSTR bstr) 290 CFX_ByteString PDF_NameDecode(FX_BSTR bstr)
291 { 291 {
292 int size = bstr.GetLength(); 292 int size = bstr.GetLength();
293 FX_LPCSTR pSrc = bstr.GetCStr(); 293 const FX_CHAR* pSrc = bstr.GetCStr();
294 if (FXSYS_memchr(pSrc, '#', size) == NULL) { 294 if (FXSYS_memchr(pSrc, '#', size) == NULL) {
295 return bstr; 295 return bstr;
296 } 296 }
297 CFX_ByteString result; 297 CFX_ByteString result;
298 FX_LPSTR pDestStart = result.GetBuffer(size); 298 FX_CHAR* pDestStart = result.GetBuffer(size);
299 FX_LPSTR pDest = pDestStart; 299 FX_CHAR* pDest = pDestStart;
300 for (int i = 0; i < size; i ++) { 300 for (int i = 0; i < size; i ++) {
301 if (pSrc[i] == '#' && i < size - 2) { 301 if (pSrc[i] == '#' && i < size - 2) {
302 *pDest ++ = _hex2dec(pSrc[i + 1]) * 16 + _hex2dec(pSrc[i + 2]); 302 *pDest ++ = _hex2dec(pSrc[i + 1]) * 16 + _hex2dec(pSrc[i + 2]);
303 i += 2; 303 i += 2;
304 } else { 304 } else {
305 *pDest ++ = pSrc[i]; 305 *pDest ++ = pSrc[i];
306 } 306 }
307 } 307 }
308 result.ReleaseBuffer((FX_STRSIZE)(pDest - pDestStart)); 308 result.ReleaseBuffer((FX_STRSIZE)(pDest - pDestStart));
309 return result; 309 return result;
310 } 310 }
311 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) 311 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig)
312 { 312 {
313 if (FXSYS_memchr(orig.c_str(), '#', orig.GetLength()) == NULL) { 313 if (FXSYS_memchr(orig.c_str(), '#', orig.GetLength()) == NULL) {
314 return orig; 314 return orig;
315 } 315 }
316 return PDF_NameDecode(CFX_ByteStringC(orig)); 316 return PDF_NameDecode(CFX_ByteStringC(orig));
317 } 317 }
318 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) 318 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig)
319 { 319 {
320 FX_LPBYTE src_buf = (FX_LPBYTE)orig.c_str(); 320 uint8_t* src_buf = (uint8_t*)orig.c_str();
321 int src_len = orig.GetLength(); 321 int src_len = orig.GetLength();
322 int dest_len = 0; 322 int dest_len = 0;
323 int i; 323 int i;
324 for (i = 0; i < src_len; i ++) { 324 for (i = 0; i < src_len; i ++) {
325 uint8_t ch = src_buf[i]; 325 uint8_t ch = src_buf[i];
326 if (ch >= 0x80 || PDF_CharType[ch] == 'W' || ch == '#' || 326 if (ch >= 0x80 || PDF_CharType[ch] == 'W' || ch == '#' ||
327 PDF_CharType[ch] == 'D') { 327 PDF_CharType[ch] == 'D') {
328 dest_len += 3; 328 dest_len += 3;
329 } else { 329 } else {
330 dest_len ++; 330 dest_len ++;
331 } 331 }
332 } 332 }
333 if (dest_len == src_len) { 333 if (dest_len == src_len) {
334 return orig; 334 return orig;
335 } 335 }
336 CFX_ByteString res; 336 CFX_ByteString res;
337 FX_LPSTR dest_buf = res.GetBuffer(dest_len); 337 FX_CHAR* dest_buf = res.GetBuffer(dest_len);
338 dest_len = 0; 338 dest_len = 0;
339 for (i = 0; i < src_len; i ++) { 339 for (i = 0; i < src_len; i ++) {
340 uint8_t ch = src_buf[i]; 340 uint8_t ch = src_buf[i];
341 if (ch >= 0x80 || PDF_CharType[ch] == 'W' || ch == '#' || 341 if (ch >= 0x80 || PDF_CharType[ch] == 'W' || ch == '#' ||
342 PDF_CharType[ch] == 'D') { 342 PDF_CharType[ch] == 'D') {
343 dest_buf[dest_len++] = '#'; 343 dest_buf[dest_len++] = '#';
344 dest_buf[dest_len++] = "0123456789ABCDEF"[ch / 16]; 344 dest_buf[dest_len++] = "0123456789ABCDEF"[ch / 16];
345 dest_buf[dest_len++] = "0123456789ABCDEF"[ch % 16]; 345 dest_buf[dest_len++] = "0123456789ABCDEF"[ch % 16];
346 } else { 346 } else {
347 dest_buf[dest_len++] = ch; 347 dest_buf[dest_len++] = ch;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 if (pFound) { 470 if (pFound) {
471 return pFound; 471 return pFound;
472 } 472 }
473 } 473 }
474 return NULL; 474 return NULL;
475 } 475 }
476 CPDF_Object* CPDF_NumberTree::LookupValue(int num) 476 CPDF_Object* CPDF_NumberTree::LookupValue(int num)
477 { 477 {
478 return SearchNumberNode(m_pRoot, num); 478 return SearchNumberNode(m_pRoot, num);
479 } 479 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698