summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-29 14:56:26 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-29 14:56:26 -0400
commit589f7e0a57675efce9810c15a3e9b7c49bf0bc90 (patch)
tree6839707c05c00f227744ffc3788665cb1cb5b7bd /core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
parent6ed0028f1cf12ee53e9e7f657b7ba186c77a42f3 (diff)
downloadpdfium-589f7e0a57675efce9810c15a3e9b7c49bf0bc90.tar.xz
Cleanup some numeric code.
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=thestig@chromium.org Review URL: https://codereview.chromium.org/1415933005 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index 1fa27e3805..88e2269c7a 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -7,6 +7,7 @@
#include "../../../include/fpdfapi/fpdf_page.h"
#include "../../../include/fpdfapi/fpdf_module.h"
#include "../../../include/fxcodec/fx_codec.h"
+#include "../../../include/fxcrt/fx_ext.h"
#include "pageint.h"
#include <limits.h>
@@ -875,34 +876,20 @@ CFX_ByteString CPDF_StreamParser::ReadHexString() {
FX_BOOL bFirst = TRUE;
int code = 0;
while (1) {
- if (ch == '>') {
+ if (ch == '>')
break;
- }
- if (ch >= '0' && ch <= '9') {
- if (bFirst) {
- code = (ch - '0') * 16;
- } else {
- code += ch - '0';
- buf.AppendChar((char)code);
- }
- bFirst = !bFirst;
- } else if (ch >= 'A' && ch <= 'F') {
- if (bFirst) {
- code = (ch - 'A' + 10) * 16;
- } else {
- code += ch - 'A' + 10;
- buf.AppendChar((char)code);
- }
- bFirst = !bFirst;
- } else if (ch >= 'a' && ch <= 'f') {
+
+ if (std::isxdigit(ch)) {
+ int val = HexCharToDigit(ch);
if (bFirst) {
- code = (ch - 'a' + 10) * 16;
+ code = val * 16;
} else {
- code += ch - 'a' + 10;
- buf.AppendChar((char)code);
+ code += val;
+ buf.AppendByte((uint8_t)code);
}
bFirst = !bFirst;
}
+
if (!PositionIsInBounds())
break;