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

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp

Issue 1834553002: Remove strange integral constants for "true", "false", "%PDF". (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "core/fpdfapi/fpdf_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize); 238 FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize);
239 m_Pos += dwStreamSize; 239 m_Pos += dwStreamSize;
240 } 240 }
241 } 241 }
242 pDict->SetAtInteger("Length", (int)dwStreamSize); 242 pDict->SetAtInteger("Length", (int)dwStreamSize);
243 return new CPDF_Stream(pData, dwStreamSize, pDict); 243 return new CPDF_Stream(pData, dwStreamSize, pDict);
244 } 244 }
245 245
246 #define MAX_WORD_BUFFER 256 246 #define MAX_WORD_BUFFER 256
247 #define MAX_STRING_LENGTH 32767 247 #define MAX_STRING_LENGTH 32767
248 #define FXDWORD_TRUE FXDWORD_FROM_LSBFIRST(0x65757274) 248
249 #define FXDWORD_NULL FXDWORD_FROM_LSBFIRST(0x6c6c756e)
250 #define FXDWORD_FALS FXDWORD_FROM_LSBFIRST(0x736c6166)
251 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() { 249 CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
252 if (m_pLastObj) { 250 if (m_pLastObj) {
253 m_pLastObj->Release(); 251 m_pLastObj->Release();
254 m_pLastObj = nullptr; 252 m_pLastObj = nullptr;
255 } 253 }
256 254
257 m_WordSize = 0; 255 m_WordSize = 0;
258 FX_BOOL bIsNumber = TRUE; 256 FX_BOOL bIsNumber = TRUE;
259 if (!PositionIsInBounds()) 257 if (!PositionIsInBounds())
260 return EndOfData; 258 return EndOfData;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 299
302 if (PDFCharIsDelimiter(ch) || PDFCharIsWhitespace(ch)) { 300 if (PDFCharIsDelimiter(ch) || PDFCharIsWhitespace(ch)) {
303 m_Pos--; 301 m_Pos--;
304 break; 302 break;
305 } 303 }
306 } 304 }
307 305
308 m_WordBuffer[m_WordSize] = 0; 306 m_WordBuffer[m_WordSize] = 0;
309 if (bIsNumber) 307 if (bIsNumber)
310 return Number; 308 return Number;
309
311 if (m_WordBuffer[0] == '/') 310 if (m_WordBuffer[0] == '/')
312 return Name; 311 return Name;
313 312
314 if (m_WordSize == 4) { 313 if (m_WordSize == 4) {
315 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) { 314 if (memcmp(m_WordBuffer, "true", 4) == 0) {
316 m_pLastObj = new CPDF_Boolean(TRUE); 315 m_pLastObj = new CPDF_Boolean(TRUE);
317 return Others; 316 return Others;
318 } 317 }
319 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) { 318 if (memcmp(m_WordBuffer, "null", 4) == 0) {
320 m_pLastObj = new CPDF_Null; 319 m_pLastObj = new CPDF_Null;
321 return Others; 320 return Others;
322 } 321 }
323 } else if (m_WordSize == 5) { 322 } else if (m_WordSize == 5) {
324 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e') { 323 if (memcmp(m_WordBuffer, "false", 5) == 0) {
325 m_pLastObj = new CPDF_Boolean(FALSE); 324 m_pLastObj = new CPDF_Boolean(FALSE);
326 return Others; 325 return Others;
327 } 326 }
328 } 327 }
329 return Keyword; 328 return Keyword;
330 } 329 }
331 330
332 void CPDF_StreamParser::SkipPathObject() { 331 void CPDF_StreamParser::SkipPathObject() {
333 FX_DWORD command_startpos = m_Pos; 332 FX_DWORD command_startpos = m_Pos;
334 if (!PositionIsInBounds()) 333 if (!PositionIsInBounds())
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 pArray->Add(pObj); 442 pArray->Add(pObj);
444 continue; 443 continue;
445 } 444 }
446 445
447 if (m_WordSize == 0 || m_WordBuffer[0] == ']') 446 if (m_WordSize == 0 || m_WordBuffer[0] == ']')
448 break; 447 break;
449 } 448 }
450 return pArray; 449 return pArray;
451 } 450 }
452 if (m_WordSize == 4) { 451 if (m_WordSize == 4) {
453 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) { 452 if (memcmp(m_WordBuffer, "true", 4) == 0) {
454 return new CPDF_Boolean(TRUE); 453 return new CPDF_Boolean(TRUE);
455 } 454 }
456 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) { 455 if (memcmp(m_WordBuffer, "null", 4) == 0) {
457 return new CPDF_Null; 456 return new CPDF_Null;
458 } 457 }
459 } else if (m_WordSize == 5) { 458 } else if (m_WordSize == 5) {
460 if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e') { 459 if (memcmp(m_WordBuffer, "false", 5) == 0) {
461 return new CPDF_Boolean(FALSE); 460 return new CPDF_Boolean(FALSE);
462 } 461 }
463 } 462 }
464 return NULL; 463 return NULL;
465 } 464 }
466 465
467 void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) { 466 void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) {
468 m_WordSize = 0; 467 m_WordSize = 0;
469 bIsNumber = TRUE; 468 bIsNumber = TRUE;
470 if (!PositionIsInBounds()) 469 if (!PositionIsInBounds())
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 } 882 }
884 m_Status = Done; 883 m_Status = Done;
885 return; 884 return;
886 } 885 }
887 steps++; 886 steps++;
888 if (pPause && pPause->NeedToPauseNow()) { 887 if (pPause && pPause->NeedToPauseNow()) {
889 break; 888 break;
890 } 889 }
891 } 890 }
892 } 891 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698