summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/PublicMethods.cpp
diff options
context:
space:
mode:
authorWei Li <weili@chromium.org>2016-03-15 13:55:12 -0700
committerWei Li <weili@chromium.org>2016-03-15 13:55:12 -0700
commit614d20a64195e64c047432251e3fb3e7b5142425 (patch)
tree6e23743b19bb501defd07146c3164168a5520908 /fpdfsdk/javascript/PublicMethods.cpp
parent744da70149c450d2f387a1fa325a3074ac2edb0c (diff)
downloadpdfium-614d20a64195e64c047432251e3fb3e7b5142425.tar.xz
Fix CJS_PublicMethods::IsNumber() with unit test and some cleanup
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1797423002 .
Diffstat (limited to 'fpdfsdk/javascript/PublicMethods.cpp')
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index d154fc1766..6097369430 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -62,44 +62,44 @@ static const FX_WCHAR* const fullmonths[] = {
L"May", L"June", L"July", L"August",
L"September", L"October", L"November", L"December"};
-FX_BOOL CJS_PublicMethods::IsNumber(const FX_WCHAR* str) {
+bool CJS_PublicMethods::IsNumber(const FX_WCHAR* str) {
CFX_WideString sTrim = StrTrim(str);
const FX_WCHAR* pTrim = sTrim.c_str();
const FX_WCHAR* p = pTrim;
- FX_BOOL bDot = FALSE;
- FX_BOOL bKXJS = FALSE;
+ bool bDot = false;
+ bool bKXJS = false;
wchar_t c;
- while ((c = *p)) {
- if (c == '.' || c == ',') {
+ while ((c = *p) != L'\0') {
+ if (c == L'.' || c == L',') {
if (bDot)
- return FALSE;
- bDot = TRUE;
- } else if (c == '-' || c == '+') {
+ return false;
+ bDot = true;
+ } else if (c == L'-' || c == L'+') {
if (p != pTrim)
- return FALSE;
- } else if (c == 'e' || c == 'E') {
+ return false;
+ } else if (c == L'e' || c == L'E') {
if (bKXJS)
- return FALSE;
+ return false;
p++;
c = *p;
- if (c == '+' || c == '-') {
- bKXJS = TRUE;
+ if (c == L'+' || c == L'-') {
+ bKXJS = true;
} else {
- return FALSE;
+ return false;
}
} else if (!FXSYS_iswdigit(c)) {
- return FALSE;
+ return false;
}
p++;
}
- return TRUE;
+ return true;
}
-FX_BOOL CJS_PublicMethods::maskSatisfied(wchar_t c_Change, wchar_t c_Mask) {
+bool CJS_PublicMethods::maskSatisfied(wchar_t c_Change, wchar_t c_Mask) {
switch (c_Mask) {
case L'9':
return FXSYS_iswdigit(c_Change);
@@ -108,13 +108,13 @@ FX_BOOL CJS_PublicMethods::maskSatisfied(wchar_t c_Change, wchar_t c_Mask) {
case L'O':
return FXSYS_iswalnum(c_Change);
case L'X':
- return TRUE;
+ return true;
default:
return (c_Change == c_Mask);
}
}
-FX_BOOL CJS_PublicMethods::isReservedMaskChar(wchar_t ch) {
+bool CJS_PublicMethods::isReservedMaskChar(wchar_t ch) {
return ch == L'9' || ch == L'A' || ch == L'O' || ch == L'X';
}