From 282cee1b5ef000c8b03f53f5cbb243893d4440d1 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 24 Mar 2016 10:43:11 -0700 Subject: 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 . --- core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp') diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index a4cc85ae7d..caffb6861b 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -69,20 +69,14 @@ const char PDF_CharType[256] = { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W'}; int32_t GetHeaderOffset(IFX_FileRead* pFile) { - // TODO(dsinclair): This is a complicated way of saying %PDF, simplify? - const FX_DWORD tag = FXDWORD_FROM_LSBFIRST(0x46445025); - const size_t kBufSize = 4; uint8_t buf[kBufSize]; - int32_t offset = 0; - while (offset <= 1024) { + for (int32_t offset = 0; offset <= 1024; ++offset) { if (!pFile->ReadBlock(buf, offset, kBufSize)) return -1; - if (*(FX_DWORD*)buf == tag) + if (memcmp(buf, "%PDF", 4) == 0) return offset; - - ++offset; } return -1; } -- cgit v1.2.3