From 0569ab0b11b723d9bca4ddd642b0cf8828c4bdd1 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 10 Nov 2015 13:33:04 -0500 Subject: Revert x4 "Cleanup some numeric code." This reverts commit b27902b8995bb3e003daed6b0811ed746763c68d. 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. TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1432973003 . --- core/src/fpdftext/fpdf_text.cpp | 7 +++---- core/src/fpdftext/fpdf_text_int.cpp | 11 ++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'core/src/fpdftext') diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp index bef805189b..55ab483722 100644 --- a/core/src/fpdftext/fpdf_text.cpp +++ b/core/src/fpdftext/fpdf_text.cpp @@ -14,8 +14,6 @@ #include "third_party/base/nonstd_unique_ptr.h" #include "txtproc.h" -#include - CFX_ByteString CharFromUnicodeAlt(FX_WCHAR unicode, int destcp, const FX_CHAR* defchar) { @@ -438,9 +436,10 @@ 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]; - // TODO(dsinclair): --.+ +.-- should probably not be a number. - if (!std::iswdigit(ch) && ch != '-' && ch != '+' && ch != '.' && ch != ' ') + if ((ch < '0' || ch > '9') && ch != '-' && ch != '+' && ch != '.' && + ch != ' ') { return FALSE; + } } return TRUE; } diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp index 7a1000ef8c..dd6be313ba 100644 --- a/core/src/fpdftext/fpdf_text_int.cpp +++ b/core/src/fpdftext/fpdf_text_int.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include +#include #include #include "core/include/fpdfapi/fpdf_module.h" @@ -2416,8 +2416,8 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) { FX_BOOL CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, int startPos, int endPos) { - FX_WCHAR char_left = 0; - FX_WCHAR char_right = 0; + int char_left = 0; + int char_right = 0; int char_count = endPos - startPos + 1; if (char_count < 1) { return FALSE; @@ -2433,11 +2433,12 @@ FX_BOOL CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, } if ((char_left > 'A' && char_left < 'a') || (char_left > 'a' && char_left < 'z') || - (char_left > 0xfb00 && char_left < 0xfb06) || std::iswdigit(char_left) || + (char_left > 0xfb00 && char_left < 0xfb06) || + (char_left >= '0' && char_left <= '9') || (char_right > 'A' && char_right < 'a') || (char_right > 'a' && char_right < 'z') || (char_right > 0xfb00 && char_right < 0xfb06) || - std::iswdigit(char_right)) { + (char_right >= '0' && char_right <= '9')) { return FALSE; } if (!(('A' > char_left || char_left > 'Z') && -- cgit v1.2.3