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 <cctype> | |
8 | |
7 #include "../../include/fxcrt/fx_basic.h" | 9 #include "../../include/fxcrt/fx_basic.h" |
10 #include "../../include/fxcrt/fx_ext.h" | |
11 | |
8 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 12 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
9 #include <sys/types.h> | 13 #include <sys/types.h> |
10 #include <dirent.h> | 14 #include <dirent.h> |
11 #else | 15 #else |
12 #include <direct.h> | 16 #include <direct.h> |
13 #endif | 17 #endif |
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 // TODO(dsinclair): Are these two checks for overflow needed? |
110 if (integer > std::numeric_limits<int>::max() / 10) | |
105 break; | 111 break; |
106 } | 112 integer *= 10; |
107 integer = integer * 10 + str[cc] - '0'; | 113 |
108 if (integer < 0) { | 114 if (integer > std::numeric_limits<int>::max() - 9) |
Tom Sepez
2015/11/04 20:33:11
Sorry, I blew it. We should be able to parse 4294
dsinclair
2015/11/04 21:31:28
Actually, this code is just broken. If we did over
dsinclair
2015/11/10 00:47:03
I put it back to the wrong way as that was what th
| |
109 break; | 115 break; |
110 } | 116 integer += FXSYS_toDecimalDigit(str[cc]); |
117 | |
111 cc++; | 118 cc++; |
112 } | 119 } |
113 if (bNegative) { | 120 if (bNegative) { |
114 integer = -integer; | 121 integer = -integer; |
115 } | 122 } |
116 *(int*)pData = integer; | 123 *(int*)pData = integer; |
117 } else { | 124 } else { |
118 bInteger = FALSE; | 125 bInteger = FALSE; |
119 *(FX_FLOAT*)pData = FX_atof(strc); | 126 *(FX_FLOAT*)pData = FX_atof(strc); |
120 } | 127 } |
(...skipping 16 matching lines...) Expand all Loading... | |
137 if (str[cc] != '+' && str[cc] != '-') { | 144 if (str[cc] != '+' && str[cc] != '-') { |
138 break; | 145 break; |
139 } | 146 } |
140 cc++; | 147 cc++; |
141 } | 148 } |
142 FX_FLOAT value = 0; | 149 FX_FLOAT value = 0; |
143 while (cc < len) { | 150 while (cc < len) { |
144 if (str[cc] == '.') { | 151 if (str[cc] == '.') { |
145 break; | 152 break; |
146 } | 153 } |
147 value = value * 10 + str[cc] - '0'; | 154 value = value * 10 + FXSYS_toDecimalDigit(str[cc]); |
148 cc++; | 155 cc++; |
149 } | 156 } |
150 static const FX_FLOAT fraction_scales[] = { | 157 static const FX_FLOAT fraction_scales[] = { |
151 0.1f, 0.01f, 0.001f, 0.0001f, | 158 0.1f, 0.01f, 0.001f, 0.0001f, |
152 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, | 159 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, |
153 0.000000001f, 0.0000000001f, 0.00000000001f}; | 160 0.000000001f, 0.0000000001f, 0.00000000001f}; |
154 int scale = 0; | 161 int scale = 0; |
155 if (cc < len && str[cc] == '.') { | 162 if (cc < len && str[cc] == '.') { |
156 cc++; | 163 cc++; |
157 while (cc < len) { | 164 while (cc < len) { |
158 value += fraction_scales[scale] * (str[cc] - '0'); | 165 value += fraction_scales[scale] * FXSYS_toDecimalDigit(str[cc]); |
159 scale++; | 166 scale++; |
160 if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { | 167 if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { |
161 break; | 168 break; |
162 } | 169 } |
163 cc++; | 170 cc++; |
164 } | 171 } |
165 } | 172 } |
166 return bNegative ? -value : value; | 173 return bNegative ? -value : value; |
167 } | 174 } |
168 | 175 |
(...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, | 371 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, | 372 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); | 373 g * m.c + h * m.f + i * m.i); |
367 } | 374 } |
368 | 375 |
369 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1& v) { | 376 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, | 377 return CFX_Vector_3by1(a * v.a + b * v.b + c * v.c, |
371 d * v.a + e * v.b + f * v.c, | 378 d * v.a + e * v.b + f * v.c, |
372 g * v.a + h * v.b + i * v.c); | 379 g * v.a + h * v.b + i * v.c); |
373 } | 380 } |
OLD | NEW |