| 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 "../../include/fxcrt/fx_basic.h" | 7 #include "../../include/fxcrt/fx_basic.h" |
| 8 #include "../../include/fxcrt/fx_ext.h" |
| 9 |
| 8 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 10 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 9 #include <sys/types.h> | 11 #include <sys/types.h> |
| 10 #include <dirent.h> | 12 #include <dirent.h> |
| 11 #else | 13 #else |
| 12 #include <direct.h> | 14 #include <direct.h> |
| 13 #endif | 15 #endif |
| 16 |
| 17 #include <cctype> |
| 18 |
| 14 CFX_PrivateData::~CFX_PrivateData() { | 19 CFX_PrivateData::~CFX_PrivateData() { |
| 15 ClearAll(); | 20 ClearAll(); |
| 16 } | 21 } |
| 17 void FX_PRIVATEDATA::FreeData() { | 22 void FX_PRIVATEDATA::FreeData() { |
| 18 if (m_pData == NULL) { | 23 if (m_pData == NULL) { |
| 19 return; | 24 return; |
| 20 } | 25 } |
| 21 if (m_bSelfDestruct) { | 26 if (m_bSelfDestruct) { |
| 22 delete (CFX_DestructObject*)m_pData; | 27 delete (CFX_DestructObject*)m_pData; |
| 23 } else if (m_pCallback) { | 28 } else if (m_pCallback) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const FX_CHAR* str = strc.GetCStr(); | 99 const FX_CHAR* str = strc.GetCStr(); |
| 95 int len = strc.GetLength(); | 100 int len = strc.GetLength(); |
| 96 FX_BOOL bNegative = FALSE; | 101 FX_BOOL bNegative = FALSE; |
| 97 if (str[0] == '+') { | 102 if (str[0] == '+') { |
| 98 cc++; | 103 cc++; |
| 99 } else if (str[0] == '-') { | 104 } else if (str[0] == '-') { |
| 100 bNegative = TRUE; | 105 bNegative = TRUE; |
| 101 cc++; | 106 cc++; |
| 102 } | 107 } |
| 103 while (cc < len) { | 108 while (cc < len) { |
| 104 if (str[cc] < '0' || str[cc] > '9') { | 109 if (!std::isdigit(str[cc])) |
| 105 break; | 110 break; |
| 106 } | 111 |
| 107 integer = integer * 10 + str[cc] - '0'; | 112 integer = integer * 10 + FXSYS_toDecimalDigit(str[cc]); |
| 108 if (integer < 0) { | 113 if (integer < 0) |
| 109 break; | 114 break; |
| 110 } | 115 |
| 111 cc++; | 116 cc++; |
| 112 } | 117 } |
| 113 if (bNegative) { | 118 if (bNegative) { |
| 114 integer = -integer; | 119 integer = -integer; |
| 115 } | 120 } |
| 116 *(int*)pData = integer; | 121 *(int*)pData = integer; |
| 117 } else { | 122 } else { |
| 118 bInteger = FALSE; | 123 bInteger = FALSE; |
| 119 *(FX_FLOAT*)pData = FX_atof(strc); | 124 *(FX_FLOAT*)pData = FX_atof(strc); |
| 120 } | 125 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 137 if (str[cc] != '+' && str[cc] != '-') { | 142 if (str[cc] != '+' && str[cc] != '-') { |
| 138 break; | 143 break; |
| 139 } | 144 } |
| 140 cc++; | 145 cc++; |
| 141 } | 146 } |
| 142 FX_FLOAT value = 0; | 147 FX_FLOAT value = 0; |
| 143 while (cc < len) { | 148 while (cc < len) { |
| 144 if (str[cc] == '.') { | 149 if (str[cc] == '.') { |
| 145 break; | 150 break; |
| 146 } | 151 } |
| 147 value = value * 10 + str[cc] - '0'; | 152 value = value * 10 + FXSYS_toDecimalDigit(str[cc]); |
| 148 cc++; | 153 cc++; |
| 149 } | 154 } |
| 150 static const FX_FLOAT fraction_scales[] = { | 155 static const FX_FLOAT fraction_scales[] = { |
| 151 0.1f, 0.01f, 0.001f, 0.0001f, | 156 0.1f, 0.01f, 0.001f, 0.0001f, |
| 152 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, | 157 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, |
| 153 0.000000001f, 0.0000000001f, 0.00000000001f}; | 158 0.000000001f, 0.0000000001f, 0.00000000001f}; |
| 154 int scale = 0; | 159 int scale = 0; |
| 155 if (cc < len && str[cc] == '.') { | 160 if (cc < len && str[cc] == '.') { |
| 156 cc++; | 161 cc++; |
| 157 while (cc < len) { | 162 while (cc < len) { |
| 158 value += fraction_scales[scale] * (str[cc] - '0'); | 163 value += fraction_scales[scale] * FXSYS_toDecimalDigit(str[cc]); |
| 159 scale++; | 164 scale++; |
| 160 if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { | 165 if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { |
| 161 break; | 166 break; |
| 162 } | 167 } |
| 163 cc++; | 168 cc++; |
| 164 } | 169 } |
| 165 } | 170 } |
| 166 return bNegative ? -value : value; | 171 return bNegative ? -value : value; |
| 167 } | 172 } |
| 168 | 173 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 d * m.b + e * m.e + f * m.h, d * m.c + e * m.f + f * m.i, | 369 d * m.b + e * m.e + f * m.h, d * m.c + e * m.f + f * m.i, |
| 365 g * m.a + h * m.d + i * m.g, g * m.b + h * m.e + i * m.h, | 370 g * m.a + h * m.d + i * m.g, g * m.b + h * m.e + i * m.h, |
| 366 g * m.c + h * m.f + i * m.i); | 371 g * m.c + h * m.f + i * m.i); |
| 367 } | 372 } |
| 368 | 373 |
| 369 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1& v) { | 374 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1& v) { |
| 370 return CFX_Vector_3by1(a * v.a + b * v.b + c * v.c, | 375 return CFX_Vector_3by1(a * v.a + b * v.b + c * v.c, |
| 371 d * v.a + e * v.b + f * v.c, | 376 d * v.a + e * v.b + f * v.c, |
| 372 g * v.a + h * v.b + i * v.c); | 377 g * v.a + h * v.b + i * v.c); |
| 373 } | 378 } |
| OLD | NEW |