summaryrefslogtreecommitdiff
path: root/core/src/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fxcrt')
-rw-r--r--core/src/fxcrt/fx_basic_bstring.cpp4
-rw-r--r--core/src/fxcrt/fx_basic_gcc.cpp11
-rw-r--r--core/src/fxcrt/fx_basic_util.cpp8
-rw-r--r--core/src/fxcrt/fx_basic_wstring.cpp4
-rw-r--r--core/src/fxcrt/fx_extension.cpp9
-rw-r--r--core/src/fxcrt/fx_extension_unittest.cpp14
6 files changed, 14 insertions, 36 deletions
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp
index d5ffcddb6d..c706912d9d 100644
--- a/core/src/fxcrt/fx_basic_bstring.cpp
+++ b/core/src/fxcrt/fx_basic_bstring.cpp
@@ -493,7 +493,7 @@ void CFX_ByteString::FormatV(const FX_CHAR* lpszFormat, va_list argList) {
}
if (nWidth == 0) {
nWidth = FXSYS_atoi(lpsz);
- for (; std::isdigit(*lpsz); lpsz++)
+ for (; (*lpsz) >= '0' && (*lpsz) <= '9'; lpsz++)
;
}
if (nWidth < 0 || nWidth > 128 * 1024) {
@@ -509,7 +509,7 @@ void CFX_ByteString::FormatV(const FX_CHAR* lpszFormat, va_list argList) {
lpsz++;
} else {
nPrecision = FXSYS_atoi(lpsz);
- for (; std::isdigit(*lpsz); lpsz++)
+ for (; (*lpsz) >= '0' && (*lpsz) <= '9'; lpsz++)
;
}
}
diff --git a/core/src/fxcrt/fx_basic_gcc.cpp b/core/src/fxcrt/fx_basic_gcc.cpp
index 71f5fe322f..6f17482156 100644
--- a/core/src/fxcrt/fx_basic_gcc.cpp
+++ b/core/src/fxcrt/fx_basic_gcc.cpp
@@ -12,20 +12,21 @@
template <class T, class STR_T>
T FXSYS_StrToInt(STR_T str) {
FX_BOOL neg = FALSE;
- if (!str)
+ if (str == NULL) {
return 0;
-
+ }
if (*str == '-') {
neg = TRUE;
str++;
}
T num = 0;
while (*str) {
- if (!std::isdigit(*str))
+ if ((*str) < '0' || (*str) > '9') {
break;
- if (num > (std::numeric_limits<T>::max() - 9) / 10)
+ }
+ if (num > (std::numeric_limits<T>::max() - 9) / 10) {
break;
-
+ }
num = num * 10 + (*str) - '0';
str++;
}
diff --git a/core/src/fxcrt/fx_basic_util.cpp b/core/src/fxcrt/fx_basic_util.cpp
index 71119082a2..46a0dec1e5 100644
--- a/core/src/fxcrt/fx_basic_util.cpp
+++ b/core/src/fxcrt/fx_basic_util.cpp
@@ -101,13 +101,13 @@ void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) {
cc++;
}
while (cc < len) {
- if (!std::isdigit(str[cc]))
+ if (str[cc] < '0' || str[cc] > '9') {
break;
-
+ }
integer = integer * 10 + str[cc] - '0';
- if (integer < 0)
+ if (integer < 0) {
break;
-
+ }
cc++;
}
if (bNegative) {
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index 3310df7062..c097e1fc09 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -765,7 +765,7 @@ void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) {
}
if (nWidth == 0) {
nWidth = FXSYS_wtoi(lpsz);
- for (; *lpsz != 0 && std::isdigit(*lpsz); lpsz++)
+ for (; *lpsz != 0 && (*lpsz) <= '9' && (*lpsz) >= '0'; lpsz++)
;
}
if (nWidth < 0 || nWidth > 128 * 1024) {
@@ -781,7 +781,7 @@ void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) {
lpsz++;
} else {
nPrecision = FXSYS_wtoi(lpsz);
- for (; *lpsz != 0 && std::isdigit(*lpsz); lpsz++)
+ for (; *lpsz != 0 && (*lpsz) >= '0' && (*lpsz) <= '9'; lpsz++)
;
}
}
diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp
index a75cfb48df..d64a06d08b 100644
--- a/core/src/fxcrt/fx_extension.cpp
+++ b/core/src/fxcrt/fx_extension.cpp
@@ -13,15 +13,6 @@
#include <ctime>
#endif
-#include <cctype>
-
-int HexCharToDigit(char c) {
- if (!std::isxdigit(c))
- return 0;
- char upchar = std::toupper(c);
- return upchar > '9' ? upchar - 'A' + 10 : upchar - '0';
-}
-
IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) {
IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
if (!pFA) {
diff --git a/core/src/fxcrt/fx_extension_unittest.cpp b/core/src/fxcrt/fx_extension_unittest.cpp
deleted file mode 100644
index e2017fc3ed..0000000000
--- a/core/src/fxcrt/fx_extension_unittest.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2015 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-#include "../../include/fxcrt/fx_ext.h"
-
-TEST(fxcrt, HexCharToDigit) {
- EXPECT_EQ(10, HexCharToDigit('a'));
- EXPECT_EQ(10, HexCharToDigit('A'));
- EXPECT_EQ(7, HexCharToDigit('7'));
- EXPECT_EQ(0, HexCharToDigit('i'));
-}