summaryrefslogtreecommitdiff
path: root/core/src/fxcrt/fx_basic_wstring.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-11-03 15:08:31 -0500
committerDan Sinclair <dsinclair@chromium.org>2015-11-03 15:08:31 -0500
commitda06e60fb5a095a91c9a4f509466667878624cb3 (patch)
treecf9af9e6cc40e05cdbcf3ee7271ccc684e805f20 /core/src/fxcrt/fx_basic_wstring.cpp
parente0e922db5fb77df9a5a9cc802096f484ed21da1c (diff)
downloadpdfium-da06e60fb5a095a91c9a4f509466667878624cb3.tar.xz
Revert "Revert "Revert "Cleanup some numeric code."""
This reverts commit e0e922db5fb77df9a5a9cc802096f484ed21da1c. Broke Windows build. FAILED: ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\core\src\fxcrt\fxcrt.fx_basic_gcc.obj.rsp /c ..\..\core\src\fxcrt\fx_basic_gcc.cpp /Foobj\core\src\fxcrt\fxcrt.fx_basic_gcc.obj /Fdobj\fxcrt.cc.pdb e:\b\build\slave\windows\build\pdfium\core\src\fxcrt\fx_basic_gcc.cpp(28) : error C2220: warning treated as error - no 'object' file generated e:\b\build\slave\windows\build\pdfium\core\src\fxcrt\fx_basic_gcc.cpp(75) : see reference to function template instantiation 'T FXSYS_StrToInt<int32_t,const FX_WCHAR*>(STR_T)' being compiled with [ T=int32_t , STR_T=const FX_WCHAR * ] e:\b\build\slave\windows\build\pdfium\core\src\fxcrt\fx_basic_gcc.cpp(28) : warning C4244: 'argument' : conversion from 'const FX_WCHAR' to 'char', possible loss of data FAILED: ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\core\src\fpdftext\fpdftext.fpdf_text.obj.rsp /c ..\..\core\src\fpdftext\fpdf_text.cpp /Foobj\core\src\fpdftext\fpdftext.fpdf_text.obj /Fdobj\fpdftext.cc.pdb e:\b\build\slave\windows\build\pdfium\core\src\fpdftext\fpdf_text.cpp(439) : error C2039: 'isdigit' : is not a member of 'std' FAILED: ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\core\src\fxcrt\fxcrt.fx_basic_wstring.obj.rsp /c ..\..\core\src\fxcrt\fx_basic_wstring.cpp /Foobj\core\src\fxcrt\fxcrt.fx_basic_wstring.obj /Fdobj\fxcrt.cc.pdb e:\b\build\slave\windows\build\pdfium\core\src\fxcrt\fx_basic_wstring.cpp(973) : error C2220: warning treated as error - no 'object' file generated e:\b\build\slave\windows\build\pdfium\core\src\fxcrt\fx_basic_wstring.cpp(973) : warning C4244: 'argument' : conversion from 'const FX_WCHAR' to 'char', possible loss of data e:\b\build\slave\windows\build\pdfium\core\src\fxcrt\fx_basic_wstring.cpp(981) : warning C4244: 'argument' : conversion from 'const FX_WCHAR' to 'char', possible loss of data FAILED: ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\core\src\fpdftext\fpdftext.fpdf_text_int.obj.rsp /c ..\..\core\src\fpdftext\fpdf_text_int.cpp /Foobj\core\src\fpdftext\fpdftext.fpdf_text_int.obj /Fdobj\fpdftext.cc.pdb e:\b\build\slave\windows\build\pdfium\core\src\fpdftext\fpdf_text_int.cpp(2436) : error C2039: 'isdigit' : is not a member of 'std' e:\b\build\slave\windows\build\pdfium\core\src\fpdftext\fpdf_text_int.cpp(2440) : error C2039: 'isdigit' : is not a member of 'std' ninja: build stopped: subcommand failed. TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1431683008 .
Diffstat (limited to 'core/src/fxcrt/fx_basic_wstring.cpp')
-rw-r--r--core/src/fxcrt/fx_basic_wstring.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index cb94d81196..c097e1fc09 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -5,10 +5,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include <stddef.h> // For offsetof().
-#include <cctype>
#include "../../include/fxcrt/fx_basic.h"
-#include "../../include/fxcrt/fx_ext.h"
#include "../../../third_party/base/numerics/safe_math.h"
// static
@@ -767,8 +765,8 @@ void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) {
}
if (nWidth == 0) {
nWidth = FXSYS_wtoi(lpsz);
- while (std::isdigit(*lpsz))
- ++lpsz;
+ for (; *lpsz != 0 && (*lpsz) <= '9' && (*lpsz) >= '0'; lpsz++)
+ ;
}
if (nWidth < 0 || nWidth > 128 * 1024) {
lpszFormat = L"Bad width";
@@ -783,8 +781,8 @@ void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) {
lpsz++;
} else {
nPrecision = FXSYS_wtoi(lpsz);
- while (std::isdigit(*lpsz))
- ++lpsz;
+ for (; *lpsz != 0 && (*lpsz) >= '0' && (*lpsz) <= '9'; lpsz++)
+ ;
}
}
if (nPrecision < 0 || nPrecision > 128 * 1024) {
@@ -970,7 +968,7 @@ FX_FLOAT FX_wtof(const FX_WCHAR* str, int len) {
if (str[cc] == '.') {
break;
}
- integer = integer * 10 + FXSYS_toDecimalDigit(str[cc]);
+ integer = integer * 10 + str[cc] - '0';
cc++;
}
FX_FLOAT fraction = 0;
@@ -978,7 +976,7 @@ FX_FLOAT FX_wtof(const FX_WCHAR* str, int len) {
cc++;
FX_FLOAT scale = 0.1f;
while (cc < len) {
- fraction += scale * FXSYS_toDecimalDigit(str[cc]);
+ fraction += scale * (str[cc] - '0');
scale *= 0.1f;
cc++;
}