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

Unified Diff: core/fpdfapi/fpdf_parser/fpdf_parser_utility.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 | « core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp ('k') | core/fxcrt/include/fx_system.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: 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 a4cc85ae7da5da65471c117a3ee6a692cea4295a..caffb6861b0c4aaa75291e5ea0131e1203c0cc89 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;
}
« no previous file with comments | « core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp ('k') | core/fxcrt/include/fx_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698