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

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp

Issue 1405253007: Revert "Revert "Cleanup some numeric code."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix mac build Created 5 years, 2 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
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index 255d0ce29cade6840340e5ac51253341f1a0985e..eaff29d8125680515dd0401880a003bf0350554a 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -8,6 +8,7 @@
#include "../../../include/fpdfapi/fpdf_parser.h"
#include "../../../include/fpdfapi/fpdf_module.h"
#include "../../../include/fxcodec/fx_codec.h"
+#include "../../../include/fxcrt/fx_ext.h"
#define _STREAM_MAX_SIZE_ 20 * 1024 * 1024
@@ -135,23 +136,20 @@ FX_DWORD _HexDecode(const uint8_t* src_buf,
continue;
int digit;
- if (ch <= '9' && ch >= '0') {
- digit = ch - '0';
- } else if (ch <= 'f' && ch >= 'a') {
- digit = ch - 'a' + 10;
- } else if (ch <= 'F' && ch >= 'A') {
- digit = ch - 'A' + 10;
+ if (std::isxdigit(ch)) {
+ digit = HexCharToDigit(ch);
} else if (ch == '>') {
i++;
break;
} else {
continue;
}
- if (bFirstDigit) {
+
+ if (bFirstDigit)
dest_buf[dest_size] = digit * 16;
- } else {
+ else
dest_buf[dest_size++] += digit;
- }
+
bFirstDigit = !bFirstDigit;
}
if (!bFirstDigit) {

Powered by Google App Engine
This is Rietveld 408576698