diff options
author | dan sinclair <dsinclair@chromium.org> | 2015-11-10 13:17:58 -0500 |
---|---|---|
committer | dan sinclair <dsinclair@chromium.org> | 2015-11-10 13:17:58 -0500 |
commit | b27902b8995bb3e003daed6b0811ed746763c68d (patch) | |
tree | 26817dd2ff198b9c93db85724171766b87077a54 /core/src/fpdftext/fpdf_text.cpp | |
parent | c813e21d261c24867234107f2e2ca72e15cb2534 (diff) | |
download | pdfium-b27902b8995bb3e003daed6b0811ed746763c68d.tar.xz |
Revert "Revert "Revert "Revert "Cleanup some numeric code.""""
This reverts commit da06e60fb5a095a91c9a4f509466667878624cb3.
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=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1433513002 .
Diffstat (limited to 'core/src/fpdftext/fpdf_text.cpp')
-rw-r--r-- | core/src/fpdftext/fpdf_text.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp index 55ab483722..bef805189b 100644 --- a/core/src/fpdftext/fpdf_text.cpp +++ b/core/src/fpdftext/fpdf_text.cpp @@ -14,6 +14,8 @@ #include "third_party/base/nonstd_unique_ptr.h" #include "txtproc.h" +#include <cctype> + CFX_ByteString CharFromUnicodeAlt(FX_WCHAR unicode, int destcp, const FX_CHAR* defchar) { @@ -436,10 +438,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; } |