| 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/fxcrt/include/fx_basic.h" | 7 #include "core/fxcrt/include/fx_basic.h" |
| 8 #include "core/fxcrt/include/fx_ext.h" | 8 #include "core/fxcrt/include/fx_ext.h" |
| 9 | 9 |
| 10 #include <cctype> | 10 #include <cctype> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 return NULL; | 87 return NULL; |
| 88 } | 88 } |
| 89 void CFX_PrivateData::ClearAll() { | 89 void CFX_PrivateData::ClearAll() { |
| 90 FX_PRIVATEDATA* pList = m_DataList.GetData(); | 90 FX_PRIVATEDATA* pList = m_DataList.GetData(); |
| 91 int count = m_DataList.GetSize(); | 91 int count = m_DataList.GetSize(); |
| 92 for (int i = 0; i < count; i++) { | 92 for (int i = 0; i < count; i++) { |
| 93 pList[i].FreeData(); | 93 pList[i].FreeData(); |
| 94 } | 94 } |
| 95 m_DataList.RemoveAll(); | 95 m_DataList.RemoveAll(); |
| 96 } | 96 } |
| 97 |
| 97 void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) { | 98 void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) { |
| 98 if (strc.Find('.') == -1) { | 99 if (strc.Find('.') == -1) { |
| 99 bInteger = TRUE; | 100 bInteger = TRUE; |
| 100 int cc = 0; | 101 int cc = 0; |
| 101 int integer = 0; | 102 pdfium::base::CheckedNumeric<int> integer = 0; |
| 102 FX_STRSIZE len = strc.GetLength(); | 103 FX_STRSIZE len = strc.GetLength(); |
| 103 bool bNegative = false; | 104 bool bNegative = false; |
| 104 if (strc[0] == '+') { | 105 if (strc[0] == '+') { |
| 105 cc++; | 106 cc++; |
| 106 } else if (strc[0] == '-') { | 107 } else if (strc[0] == '-') { |
| 107 bNegative = true; | 108 bNegative = true; |
| 108 cc++; | 109 cc++; |
| 109 } | 110 } |
| 110 while (cc < len && std::isdigit(strc[cc])) { | 111 while (cc < len && std::isdigit(strc[cc])) { |
| 111 // TODO(dsinclair): This is not the right way to handle overflow. | |
| 112 integer = integer * 10 + FXSYS_toDecimalDigit(strc.CharAt(cc)); | 112 integer = integer * 10 + FXSYS_toDecimalDigit(strc.CharAt(cc)); |
| 113 if (integer < 0) | 113 if (!integer.IsValid()) |
| 114 break; | 114 break; |
| 115 cc++; | 115 cc++; |
| 116 } | 116 } |
| 117 if (bNegative) { | 117 if (bNegative) { |
| 118 integer = -integer; | 118 integer = -integer; |
| 119 } | 119 } |
| 120 *(int*)pData = integer; | 120 *(int*)pData = integer.ValueOrDefault(0); |
| 121 } else { | 121 } else { |
| 122 bInteger = FALSE; | 122 bInteger = FALSE; |
| 123 *(FX_FLOAT*)pData = FX_atof(strc); | 123 *(FX_FLOAT*)pData = FX_atof(strc); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 |
| 126 FX_FLOAT FX_atof(const CFX_ByteStringC& strc) { | 127 FX_FLOAT FX_atof(const CFX_ByteStringC& strc) { |
| 127 if (strc.IsEmpty()) | 128 if (strc.IsEmpty()) |
| 128 return 0.0; | 129 return 0.0; |
| 129 | 130 |
| 130 int cc = 0; | 131 int cc = 0; |
| 131 bool bNegative = false; | 132 bool bNegative = false; |
| 132 int len = strc.GetLength(); | 133 int len = strc.GetLength(); |
| 133 if (strc[0] == '+') { | 134 if (strc[0] == '+') { |
| 134 cc++; | 135 cc++; |
| 135 } else if (strc[0] == '-') { | 136 } else if (strc[0] == '-') { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 d * m.b + e * m.e + f * m.h, d * m.c + e * m.f + f * m.i, | 357 d * m.b + e * m.e + f * m.h, d * m.c + e * m.f + f * m.i, |
| 357 g * m.a + h * m.d + i * m.g, g * m.b + h * m.e + i * m.h, | 358 g * m.a + h * m.d + i * m.g, g * m.b + h * m.e + i * m.h, |
| 358 g * m.c + h * m.f + i * m.i); | 359 g * m.c + h * m.f + i * m.i); |
| 359 } | 360 } |
| 360 | 361 |
| 361 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1& v) { | 362 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1& v) { |
| 362 return CFX_Vector_3by1(a * v.a + b * v.b + c * v.c, | 363 return CFX_Vector_3by1(a * v.a + b * v.b + c * v.c, |
| 363 d * v.a + e * v.b + f * v.c, | 364 d * v.a + e * v.b + f * v.c, |
| 364 g * v.a + h * v.b + i * v.c); | 365 g * v.a + h * v.b + i * v.c); |
| 365 } | 366 } |
| OLD | NEW |