summaryrefslogtreecommitdiff
path: root/core/src/fpdftext/fpdf_text.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-11-16 12:28:39 -0500
committerDan Sinclair <dsinclair@chromium.org>2015-11-16 12:28:39 -0500
commit3f148915d12f54a946a0c0bf526162b79c39d650 (patch)
tree17a95f27c8a6a07356b68ac41b5fbcc0f2358ab9 /core/src/fpdftext/fpdf_text.cpp
parent76c6d639f46c37ba955569f507201eb3f1b613fc (diff)
downloadpdfium-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/fpdftext/fpdf_text.cpp')
-rw-r--r--core/src/fpdftext/fpdf_text.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp
index 55ab483722..0b7a849c75 100644
--- a/core/src/fpdftext/fpdf_text.cpp
+++ b/core/src/fpdftext/fpdf_text.cpp
@@ -14,6 +14,9 @@
#include "third_party/base/nonstd_unique_ptr.h"
#include "txtproc.h"
+#include <cctype>
+#include <cwctype>
+
CFX_ByteString CharFromUnicodeAlt(FX_WCHAR unicode,
int destcp,
const FX_CHAR* defchar) {
@@ -436,10 +439,9 @@ void NormalizeString(CFX_WideString& str) {
static FX_BOOL IsNumber(CFX_WideString& str) {
for (int i = 0; i < str.GetLength(); i++) {
FX_WCHAR ch = str[i];
- if ((ch < '0' || ch > '9') && ch != '-' && ch != '+' && ch != '.' &&
- ch != ' ') {
+ // TODO(dsinclair): --.+ +.-- should probably not be a number.
+ if (!std::iswdigit(ch) && ch != '-' && ch != '+' && ch != '.' && ch != ' ')
return FALSE;
- }
}
return TRUE;
}