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