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> |
dsinclair
2015/11/04 20:16:24
Should these also be moved up?
| |
13 #endif | 15 #endif |
16 | |
17 #include <cctype> | |
Tom Sepez
2015/11/04 18:42:46
nit: this goes at line 6.
dsinclair
2015/11/04 20:16:24
Done.
| |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 int cc = 0, integer = 0; | 98 int cc = 0, integer = 0; |
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 && std::isdigit(str[cc])) { |
104 if (str[cc] < '0' || str[cc] > '9') { | 109 integer = integer * 10 + FXSYS_toDecimalDigit(str[cc]); |
110 if (integer < 0) | |
Tom Sepez
2015/11/04 18:42:46
argh. You can't detect overflow this way. Signed i
dsinclair
2015/11/04 20:16:24
I'm assuming you meant std::numeric_limits<int>::m
| |
105 break; | 111 break; |
106 } | 112 |
107 integer = integer * 10 + str[cc] - '0'; | |
108 if (integer < 0) { | |
109 break; | |
110 } | |
111 cc++; | 113 cc++; |
112 } | 114 } |
113 if (bNegative) { | 115 if (bNegative) { |
114 integer = -integer; | 116 integer = -integer; |
115 } | 117 } |
116 *(int*)pData = integer; | 118 *(int*)pData = integer; |
117 } else { | 119 } else { |
118 bInteger = FALSE; | 120 bInteger = FALSE; |
119 *(FX_FLOAT*)pData = FX_atof(strc); | 121 *(FX_FLOAT*)pData = FX_atof(strc); |
120 } | 122 } |
(...skipping 16 matching lines...) Expand all Loading... | |
137 if (str[cc] != '+' && str[cc] != '-') { | 139 if (str[cc] != '+' && str[cc] != '-') { |
138 break; | 140 break; |
139 } | 141 } |
140 cc++; | 142 cc++; |
141 } | 143 } |
142 FX_FLOAT value = 0; | 144 FX_FLOAT value = 0; |
143 while (cc < len) { | 145 while (cc < len) { |
144 if (str[cc] == '.') { | 146 if (str[cc] == '.') { |
145 break; | 147 break; |
146 } | 148 } |
147 value = value * 10 + str[cc] - '0'; | 149 value = value * 10 + FXSYS_toDecimalDigit(str[cc]); |
148 cc++; | 150 cc++; |
149 } | 151 } |
150 static const FX_FLOAT fraction_scales[] = { | 152 static const FX_FLOAT fraction_scales[] = { |
151 0.1f, 0.01f, 0.001f, 0.0001f, | 153 0.1f, 0.01f, 0.001f, 0.0001f, |
152 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, | 154 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, |
153 0.000000001f, 0.0000000001f, 0.00000000001f}; | 155 0.000000001f, 0.0000000001f, 0.00000000001f}; |
154 int scale = 0; | 156 int scale = 0; |
155 if (cc < len && str[cc] == '.') { | 157 if (cc < len && str[cc] == '.') { |
156 cc++; | 158 cc++; |
157 while (cc < len) { | 159 while (cc < len) { |
158 value += fraction_scales[scale] * (str[cc] - '0'); | 160 value += fraction_scales[scale] * FXSYS_toDecimalDigit(str[cc]); |
159 scale++; | 161 scale++; |
160 if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { | 162 if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { |
161 break; | 163 break; |
162 } | 164 } |
163 cc++; | 165 cc++; |
164 } | 166 } |
165 } | 167 } |
166 return bNegative ? -value : value; | 168 return bNegative ? -value : value; |
167 } | 169 } |
168 | 170 |
(...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, | 366 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, | 367 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); | 368 g * m.c + h * m.f + i * m.i); |
367 } | 369 } |
368 | 370 |
369 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) { |
370 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, |
371 d * v.a + e * v.b + f * v.c, | 373 d * v.a + e * v.b + f * v.c, |
372 g * v.a + h * v.b + i * v.c); | 374 g * v.a + h * v.b + i * v.c); |
373 } | 375 } |
OLD | NEW |