| 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/fxcodec/fx_codec.h" | 7 #include "../../../include/fxcodec/fx_codec.h" |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 extern "C" double FXstrtod(const char* nptr, char** endptr) { | 150 extern "C" double FXstrtod(const char* nptr, char** endptr) { |
| 151 double ret = 0.0; | 151 double ret = 0.0; |
| 152 const char* ptr = nptr; | 152 const char* ptr = nptr; |
| 153 const char* exp_ptr = NULL; | 153 const char* exp_ptr = NULL; |
| 154 int e_number = 0, e_signal = 0, e_point = 0, is_negative = 0; | 154 int e_number = 0, e_signal = 0, e_point = 0, is_negative = 0; |
| 155 int exp_ret = 0, exp_sig = 1, fra_ret = 0, fra_count = 0, fra_base = 1; | 155 int exp_ret = 0, exp_sig = 1, fra_ret = 0, fra_count = 0, fra_base = 1; |
| 156 if (nptr == NULL) { | 156 if (nptr == NULL) { |
| 157 return 0.0; | 157 return 0.0; |
| 158 } | 158 } |
| 159 for (;; ptr++) { | 159 for (;; ptr++) { |
| 160 if (!e_number && !e_point && (*ptr == '\t' || *ptr == ' ')) { | 160 if (!e_number && !e_point && (*ptr == '\t' || *ptr == ' ')) |
| 161 continue; | 161 continue; |
| 162 } | 162 |
| 163 if (*ptr >= '0' && *ptr <= '9') { | 163 if (std::isdigit(*ptr)) { |
| 164 if (!e_number) { | 164 if (!e_number) |
| 165 e_number = 1; | 165 e_number = 1; |
| 166 } | 166 |
| 167 if (!e_point) { | 167 if (!e_point) { |
| 168 ret *= 10; | 168 ret *= 10; |
| 169 ret += (*ptr - '0'); | 169 ret += (*ptr - '0'); |
| 170 } else { | 170 } else { |
| 171 fra_count++; | 171 fra_count++; |
| 172 fra_ret *= 10; | 172 fra_ret *= 10; |
| 173 fra_ret += (*ptr - '0'); | 173 fra_ret += (*ptr - '0'); |
| 174 } | 174 } |
| 175 continue; | 175 continue; |
| 176 } | 176 } |
| 177 if (!e_point && *ptr == '.') { | 177 if (!e_point && *ptr == '.') { |
| 178 e_point = 1; | 178 e_point = 1; |
| 179 continue; | 179 continue; |
| 180 } | 180 } |
| 181 if (!e_number && !e_point && !e_signal) { | 181 if (!e_number && !e_point && !e_signal) { |
| 182 switch (*ptr) { | 182 switch (*ptr) { |
| 183 case '-': | 183 case '-': |
| 184 is_negative = 1; | 184 is_negative = 1; |
| 185 case '+': | 185 case '+': |
| 186 e_signal = 1; | 186 e_signal = 1; |
| 187 continue; | 187 continue; |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 if (e_number && (*ptr == 'e' || *ptr == 'E')) { | 190 if (e_number && (*ptr == 'e' || *ptr == 'E')) { |
| 191 #define EXPONENT_DETECT(ptr) \ | 191 #define EXPONENT_DETECT(ptr) \ |
| 192 for (;; ptr++) { \ | 192 for (;; ptr++) { \ |
| 193 if (*ptr < '0' || *ptr > '9') { \ | 193 if (!std::isdigit(*ptr)) { \ |
| 194 if (endptr) \ | 194 if (endptr) \ |
| 195 *endptr = (char*)ptr; \ | 195 *endptr = (char*)ptr; \ |
| 196 break; \ | 196 break; \ |
| 197 } else { \ | 197 } else { \ |
| 198 exp_ret *= 10; \ | 198 exp_ret *= 10; \ |
| 199 exp_ret += (*ptr - '0'); \ | 199 exp_ret += (*ptr - '0'); \ |
| 200 continue; \ | 200 continue; \ |
| 201 } \ | 201 } \ |
| 202 } | 202 } |
| 203 exp_ptr = ptr++; | 203 exp_ptr = ptr++; |
| 204 if (*ptr == '+' || *ptr == '-') { | 204 if (*ptr == '+' || *ptr == '-') { |
| 205 exp_sig = (*ptr++ == '+') ? 1 : -1; | 205 exp_sig = (*ptr++ == '+') ? 1 : -1; |
| 206 if (*ptr < '0' || *ptr > '9') { | 206 if (!std::isdigit(*ptr)) { |
| 207 if (endptr) { | 207 if (endptr) { |
| 208 *endptr = (char*)exp_ptr; | 208 *endptr = (char*)exp_ptr; |
| 209 } | 209 } |
| 210 break; | 210 break; |
| 211 } | 211 } |
| 212 EXPONENT_DETECT(ptr); | 212 EXPONENT_DETECT(ptr); |
| 213 } else if (*ptr >= '0' && *ptr <= '9') { | 213 } else if (std::isdigit(*ptr)) { |
| 214 EXPONENT_DETECT(ptr); | 214 EXPONENT_DETECT(ptr); |
| 215 } else { | 215 } else { |
| 216 if (endptr) { | 216 if (endptr) { |
| 217 *endptr = (char*)exp_ptr; | 217 *endptr = (char*)exp_ptr; |
| 218 } | 218 } |
| 219 break; | 219 break; |
| 220 } | 220 } |
| 221 #undef EXPONENT_DETECT | 221 #undef EXPONENT_DETECT |
| 222 break; | 222 break; |
| 223 } | 223 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 int nComps, | 439 int nComps, |
| 440 int bpc) { | 440 int bpc) { |
| 441 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; | 441 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; |
| 442 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, | 442 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, |
| 443 bpc)) { | 443 bpc)) { |
| 444 delete pRLScanlineDecoder; | 444 delete pRLScanlineDecoder; |
| 445 return NULL; | 445 return NULL; |
| 446 } | 446 } |
| 447 return pRLScanlineDecoder; | 447 return pRLScanlineDecoder; |
| 448 } | 448 } |
| OLD | NEW |