summaryrefslogtreecommitdiff
path: root/core/src/fxcodec/codec
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/fxcodec/codec
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/fxcodec/codec')
-rw-r--r--core/src/fxcodec/codec/fx_codec.cpp48
1 files changed, 22 insertions, 26 deletions
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index 08b2d2d985..46f479e0b1 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -9,7 +9,6 @@
#include <cmath>
#include "../../../../third_party/base/logging.h"
-#include "../../../include/fxcrt/fx_ext.h"
#include "../../../include/fxcrt/fx_safe_types.h"
#include "codec_int.h"
@@ -148,20 +147,6 @@ FX_BOOL CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf,
FX_DWORD& dest_size) {
return FALSE;
}
-
-#define EXPONENT_DETECT(ptr) \
- for (;; ptr++) { \
- if (!std::isdigit(*ptr)) { \
- if (endptr) \
- *endptr = (char*)ptr; \
- break; \
- } else { \
- exp_ret *= 10; \
- exp_ret += FXSYS_toDecimalDigit(*ptr); \
- continue; \
- } \
- }
-
extern "C" double FXstrtod(const char* nptr, char** endptr) {
double ret = 0.0;
const char* ptr = nptr;
@@ -172,20 +157,20 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) {
return 0.0;
}
for (;; ptr++) {
- if (!e_number && !e_point && (*ptr == '\t' || *ptr == ' '))
+ if (!e_number && !e_point && (*ptr == '\t' || *ptr == ' ')) {
continue;
-
- if (std::isdigit(*ptr)) {
- if (!e_number)
+ }
+ if (*ptr >= '0' && *ptr <= '9') {
+ if (!e_number) {
e_number = 1;
-
+ }
if (!e_point) {
ret *= 10;
- ret += FXSYS_toDecimalDigit(*ptr);
+ ret += (*ptr - '0');
} else {
fra_count++;
fra_ret *= 10;
- fra_ret += FXSYS_toDecimalDigit(*ptr);
+ fra_ret += (*ptr - '0');
}
continue;
}
@@ -203,17 +188,29 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) {
}
}
if (e_number && (*ptr == 'e' || *ptr == 'E')) {
+#define EXPONENT_DETECT(ptr) \
+ for (;; ptr++) { \
+ if (*ptr < '0' || *ptr > '9') { \
+ if (endptr) \
+ *endptr = (char*)ptr; \
+ break; \
+ } else { \
+ exp_ret *= 10; \
+ exp_ret += (*ptr - '0'); \
+ continue; \
+ } \
+ }
exp_ptr = ptr++;
if (*ptr == '+' || *ptr == '-') {
exp_sig = (*ptr++ == '+') ? 1 : -1;
- if (!std::isdigit(*ptr)) {
+ if (*ptr < '0' || *ptr > '9') {
if (endptr) {
*endptr = (char*)exp_ptr;
}
break;
}
EXPONENT_DETECT(ptr);
- } else if (std::isdigit(*ptr)) {
+ } else if (*ptr >= '0' && *ptr <= '9') {
EXPONENT_DETECT(ptr);
} else {
if (endptr) {
@@ -221,6 +218,7 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) {
}
break;
}
+#undef EXPONENT_DETECT
break;
}
if (ptr != nptr && !e_number) {
@@ -249,8 +247,6 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) {
}
return is_negative ? -ret : ret;
}
-#undef EXPONENT_DETECT
-
FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf,
FX_DWORD src_size,
uint8_t*& dest_buf,