diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-11-16 12:28:39 -0500 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-11-16 12:28:39 -0500 |
commit | 3f148915d12f54a946a0c0bf526162b79c39d650 (patch) | |
tree | 17a95f27c8a6a07356b68ac41b5fbcc0f2358ab9 /core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | |
parent | 76c6d639f46c37ba955569f507201eb3f1b613fc (diff) | |
download | pdfium-3f148915d12f54a946a0c0bf526162b79c39d650.tar.xz |
Reland "Cleanup some numeric code.""chromium/2567
This reverts commit 0569ab0b11b723d9bca4ddd642b0cf8828c4bdd1.
This changes the various comparisons of char >= '0' && char <= '9' and
char < '0' || char > '9' to use std::isdigit checks. It also cleans up
a handful of hex to digit conversions to call one common method.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1449873003 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp')
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 89a5deb62d..9729bab942 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]; |