diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-03-24 10:43:11 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-03-24 10:43:11 -0700 |
commit | 282cee1b5ef000c8b03f53f5cbb243893d4440d1 (patch) | |
tree | 685106a00d32efdf59639babb9404d23f598d2b5 /core/fpdfapi/fpdf_page | |
parent | 2e8798f5b93dac2fab4980b9c4862f13711809e6 (diff) | |
download | pdfium-282cee1b5ef000c8b03f53f5cbb243893d4440d1.tar.xz |
Remove strange integral constants for "true", "false", "%PDF".
Compilers have good inline memcmp nowadays, so we don't
have to resort to old tricks.
Remove FXDWORD_FROM_LSBFIRST and FXDWORD_FROM_MSBFIRST
while we're at it. MSBFIRST was technically wrong due
to promotion to int.
R=dsinclair@chromium.org
Review URL: https://codereview.chromium.org/1834553002 .
Diffstat (limited to 'core/fpdfapi/fpdf_page')
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 04211041fe..9995038def 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -248,9 +248,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(); @@ -311,20 +309,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; } @@ -453,14 +452,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); } } |