| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/include/fxcrt/fx_basic.h" | 7 #include "core/include/fxcrt/fx_basic.h" |
| 8 #include "core/include/fxcrt/fx_ext.h" |
| 9 |
| 10 #include <cctype> |
| 8 | 11 |
| 9 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 12 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 10 #include <sys/types.h> | 13 #include <sys/types.h> |
| 11 #include <dirent.h> | 14 #include <dirent.h> |
| 12 #else | 15 #else |
| 13 #include <direct.h> | 16 #include <direct.h> |
| 14 #endif | 17 #endif |
| 15 | 18 |
| 16 CFX_PrivateData::~CFX_PrivateData() { | 19 CFX_PrivateData::~CFX_PrivateData() { |
| 17 ClearAll(); | 20 ClearAll(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 int cc = 0, integer = 0; | 98 int cc = 0, integer = 0; |
| 96 const FX_CHAR* str = strc.GetCStr(); | 99 const FX_CHAR* str = strc.GetCStr(); |
| 97 int len = strc.GetLength(); | 100 int len = strc.GetLength(); |
| 98 FX_BOOL bNegative = FALSE; | 101 FX_BOOL bNegative = FALSE; |
| 99 if (str[0] == '+') { | 102 if (str[0] == '+') { |
| 100 cc++; | 103 cc++; |
| 101 } else if (str[0] == '-') { | 104 } else if (str[0] == '-') { |
| 102 bNegative = TRUE; | 105 bNegative = TRUE; |
| 103 cc++; | 106 cc++; |
| 104 } | 107 } |
| 105 while (cc < len) { | 108 while (cc < len && std::isdigit(str[cc])) { |
| 106 if (str[cc] < '0' || str[cc] > '9') { | 109 // TODO(dsinclair): This is not the right way to handle overflow. |
| 110 integer = integer * 10 + FXSYS_toDecimalDigit(str[cc]); |
| 111 if (integer < 0) |
| 107 break; | 112 break; |
| 108 } | |
| 109 integer = integer * 10 + str[cc] - '0'; | |
| 110 if (integer < 0) { | |
| 111 break; | |
| 112 } | |
| 113 cc++; | 113 cc++; |
| 114 } | 114 } |
| 115 if (bNegative) { | 115 if (bNegative) { |
| 116 integer = -integer; | 116 integer = -integer; |
| 117 } | 117 } |
| 118 *(int*)pData = integer; | 118 *(int*)pData = integer; |
| 119 } else { | 119 } else { |
| 120 bInteger = FALSE; | 120 bInteger = FALSE; |
| 121 *(FX_FLOAT*)pData = FX_atof(strc); | 121 *(FX_FLOAT*)pData = FX_atof(strc); |
| 122 } | 122 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 139 if (str[cc] != '+' && str[cc] != '-') { | 139 if (str[cc] != '+' && str[cc] != '-') { |
| 140 break; | 140 break; |
| 141 } | 141 } |
| 142 cc++; | 142 cc++; |
| 143 } | 143 } |
| 144 FX_FLOAT value = 0; | 144 FX_FLOAT value = 0; |
| 145 while (cc < len) { | 145 while (cc < len) { |
| 146 if (str[cc] == '.') { | 146 if (str[cc] == '.') { |
| 147 break; | 147 break; |
| 148 } | 148 } |
| 149 value = value * 10 + str[cc] - '0'; | 149 value = value * 10 + FXSYS_toDecimalDigit(str[cc]); |
| 150 cc++; | 150 cc++; |
| 151 } | 151 } |
| 152 static const FX_FLOAT fraction_scales[] = { | 152 static const FX_FLOAT fraction_scales[] = { |
| 153 0.1f, 0.01f, 0.001f, 0.0001f, | 153 0.1f, 0.01f, 0.001f, 0.0001f, |
| 154 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, | 154 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, |
| 155 0.000000001f, 0.0000000001f, 0.00000000001f}; | 155 0.000000001f, 0.0000000001f, 0.00000000001f}; |
| 156 int scale = 0; | 156 int scale = 0; |
| 157 if (cc < len && str[cc] == '.') { | 157 if (cc < len && str[cc] == '.') { |
| 158 cc++; | 158 cc++; |
| 159 while (cc < len) { | 159 while (cc < len) { |
| 160 value += fraction_scales[scale] * (str[cc] - '0'); | 160 value += fraction_scales[scale] * FXSYS_toDecimalDigit(str[cc]); |
| 161 scale++; | 161 scale++; |
| 162 if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { | 162 if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { |
| 163 break; | 163 break; |
| 164 } | 164 } |
| 165 cc++; | 165 cc++; |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 return bNegative ? -value : value; | 168 return bNegative ? -value : value; |
| 169 } | 169 } |
| 170 | 170 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 d * m.b + e * m.e + f * m.h, d * m.c + e * m.f + f * m.i, | 366 d * m.b + e * m.e + f * m.h, d * m.c + e * m.f + f * m.i, |
| 367 g * m.a + h * m.d + i * m.g, g * m.b + h * m.e + i * m.h, | 367 g * m.a + h * m.d + i * m.g, g * m.b + h * m.e + i * m.h, |
| 368 g * m.c + h * m.f + i * m.i); | 368 g * m.c + h * m.f + i * m.i); |
| 369 } | 369 } |
| 370 | 370 |
| 371 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1& v) { | 371 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1& v) { |
| 372 return CFX_Vector_3by1(a * v.a + b * v.b + c * v.c, | 372 return CFX_Vector_3by1(a * v.a + b * v.b + c * v.c, |
| 373 d * v.a + e * v.b + f * v.c, | 373 d * v.a + e * v.b + f * v.c, |
| 374 g * v.a + h * v.b + i * v.c); | 374 g * v.a + h * v.b + i * v.c); |
| 375 } | 375 } |
| OLD | NEW |