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_parser | |
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_parser')
-rw-r--r-- | core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
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; } |