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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index c0d7c08ee1ebc2d4c552a518a16b0e0d9778a415..e1420bc4bbf039e4d54af74e0eef578ee3a5fc22 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -245,9 +245,7 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
#define MAX_WORD_BUFFER 256
#define MAX_STRING_LENGTH 32767
-#define FXDWORD_TRUE FXDWORD_FROM_LSBFIRST(0x65757274)
-#define FXDWORD_NULL FXDWORD_FROM_LSBFIRST(0x6c6c756e)
-#define FXDWORD_FALS FXDWORD_FROM_LSBFIRST(0x736c6166)
+
CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
if (m_pLastObj) {
m_pLastObj->Release();
@@ -308,20 +306,21 @@ CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
m_WordBuffer[m_WordSize] = 0;
if (bIsNumber)
return Number;
+
if (m_WordBuffer[0] == '/')
return Name;
if (m_WordSize == 4) {
- if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) {
+ if (memcmp(m_WordBuffer, "true", 4) == 0) {
m_pLastObj = new CPDF_Boolean(TRUE);
return Others;
}
- if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) {
+ if (memcmp(m_WordBuffer, "null", 4) == 0) {
m_pLastObj = new CPDF_Null;
return Others;
}
} else if (m_WordSize == 5) {
- if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e') {
+ if (memcmp(m_WordBuffer, "false", 5) == 0) {
m_pLastObj = new CPDF_Boolean(FALSE);
return Others;
}
@@ -450,14 +449,14 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(FX_BOOL bAllowNestedArray,
return pArray;
}
if (m_WordSize == 4) {
- if (*(FX_DWORD*)m_WordBuffer == FXDWORD_TRUE) {
+ if (memcmp(m_WordBuffer, "true", 4) == 0) {
return new CPDF_Boolean(TRUE);
}
- if (*(FX_DWORD*)m_WordBuffer == FXDWORD_NULL) {
+ if (memcmp(m_WordBuffer, "null", 4) == 0) {
return new CPDF_Null;
}
} else if (m_WordSize == 5) {
- if (*(FX_DWORD*)m_WordBuffer == FXDWORD_FALS && m_WordBuffer[4] == 'e') {
+ if (memcmp(m_WordBuffer, "false", 5) == 0) {
return new CPDF_Boolean(FALSE);
}
}
« 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