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

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

Issue 1449873003: Reland "Cleanup some numeric code."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix windows build Created 5 years, 1 month 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/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | core/src/fpdftext/fpdf_text.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
index 89a5deb62d03655fd0c3d0d0997e8e30ba1891ed..9729bab9424888ebb7291d066984690879746eb0 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -5,6 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/include/fpdfapi/fpdf_parser.h"
+#include "core/include/fxcrt/fx_ext.h"
// Indexed by 8-bit character code, contains either:
// 'W' - for whitespace: NUL, TAB, CR, LF, FF, 0x80, 0xff
@@ -279,18 +280,7 @@ FX_BOOL CPDF_SimpleParser::FindTagParam(const CFX_ByteStringC& token,
}
return FALSE;
}
-static int _hex2dec(char ch) {
- if (ch >= '0' && ch <= '9') {
- return ch - '0';
- }
- if (ch >= 'a' && ch <= 'f') {
- return ch - 'a' + 10;
- }
- if (ch >= 'A' && ch <= 'F') {
- return ch - 'A' + 10;
- }
- return 0;
-}
+
CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
int size = bstr.GetLength();
const FX_CHAR* pSrc = bstr.GetCStr();
@@ -302,7 +292,8 @@ CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
FX_CHAR* pDest = pDestStart;
for (int i = 0; i < size; i++) {
if (pSrc[i] == '#' && i < size - 2) {
- *pDest++ = _hex2dec(pSrc[i + 1]) * 16 + _hex2dec(pSrc[i + 2]);
+ *pDest++ =
+ FXSYS_toHexDigit(pSrc[i + 1]) * 16 + FXSYS_toHexDigit(pSrc[i + 2]);
i += 2;
} else {
*pDest++ = pSrc[i];
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | core/src/fpdftext/fpdf_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698