| 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/fxcodec/include/fx_codec.h" | 7 #include "core/fxcodec/include/fx_codec.h" |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return v_GetNextLine(); | 77 return v_GetNextLine(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 FX_BOOL CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf, | 80 FX_BOOL CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf, |
| 81 uint32_t src_size, | 81 uint32_t src_size, |
| 82 uint8_t*& dest_buf, | 82 uint8_t*& dest_buf, |
| 83 uint32_t& dest_size) { | 83 uint32_t& dest_size) { |
| 84 return FALSE; | 84 return FALSE; |
| 85 } | 85 } |
| 86 | 86 |
| 87 #define EXPONENT_DETECT(ptr) \ | |
| 88 for (;; ptr++) { \ | |
| 89 if (!std::isdigit(*ptr)) { \ | |
| 90 if (endptr) \ | |
| 91 *endptr = (char*)ptr; \ | |
| 92 break; \ | |
| 93 } else { \ | |
| 94 exp_ret *= 10; \ | |
| 95 exp_ret += FXSYS_toDecimalDigit(*ptr); \ | |
| 96 continue; \ | |
| 97 } \ | |
| 98 } | |
| 99 | |
| 100 extern "C" double FXstrtod(const char* nptr, char** endptr) { | |
| 101 double ret = 0.0; | |
| 102 const char* ptr = nptr; | |
| 103 const char* exp_ptr = NULL; | |
| 104 int e_number = 0, e_signal = 0, e_point = 0, is_negative = 0; | |
| 105 int exp_ret = 0, exp_sig = 1, fra_ret = 0, fra_count = 0, fra_base = 1; | |
| 106 if (!nptr) { | |
| 107 return 0.0; | |
| 108 } | |
| 109 for (;; ptr++) { | |
| 110 if (!e_number && !e_point && (*ptr == '\t' || *ptr == ' ')) | |
| 111 continue; | |
| 112 | |
| 113 if (std::isdigit(*ptr)) { | |
| 114 if (!e_number) | |
| 115 e_number = 1; | |
| 116 | |
| 117 if (!e_point) { | |
| 118 ret *= 10; | |
| 119 ret += FXSYS_toDecimalDigit(*ptr); | |
| 120 } else { | |
| 121 fra_count++; | |
| 122 fra_ret *= 10; | |
| 123 fra_ret += FXSYS_toDecimalDigit(*ptr); | |
| 124 } | |
| 125 continue; | |
| 126 } | |
| 127 if (!e_point && *ptr == '.') { | |
| 128 e_point = 1; | |
| 129 continue; | |
| 130 } | |
| 131 if (!e_number && !e_point && !e_signal) { | |
| 132 switch (*ptr) { | |
| 133 case '-': | |
| 134 is_negative = 1; | |
| 135 case '+': | |
| 136 e_signal = 1; | |
| 137 continue; | |
| 138 } | |
| 139 } | |
| 140 if (e_number && (*ptr == 'e' || *ptr == 'E')) { | |
| 141 exp_ptr = ptr++; | |
| 142 if (*ptr == '+' || *ptr == '-') { | |
| 143 exp_sig = (*ptr++ == '+') ? 1 : -1; | |
| 144 if (!std::isdigit(*ptr)) { | |
| 145 if (endptr) { | |
| 146 *endptr = (char*)exp_ptr; | |
| 147 } | |
| 148 break; | |
| 149 } | |
| 150 EXPONENT_DETECT(ptr); | |
| 151 } else if (std::isdigit(*ptr)) { | |
| 152 EXPONENT_DETECT(ptr); | |
| 153 } else { | |
| 154 if (endptr) { | |
| 155 *endptr = (char*)exp_ptr; | |
| 156 } | |
| 157 break; | |
| 158 } | |
| 159 break; | |
| 160 } | |
| 161 if (ptr != nptr && !e_number) { | |
| 162 if (endptr) { | |
| 163 *endptr = (char*)nptr; | |
| 164 } | |
| 165 break; | |
| 166 } | |
| 167 if (endptr) { | |
| 168 *endptr = (char*)ptr; | |
| 169 } | |
| 170 break; | |
| 171 } | |
| 172 while (fra_count--) { | |
| 173 fra_base *= 10; | |
| 174 } | |
| 175 ret += (double)fra_ret / (double)fra_base; | |
| 176 if (exp_sig == 1) { | |
| 177 while (exp_ret--) { | |
| 178 ret *= 10.0; | |
| 179 } | |
| 180 } else { | |
| 181 while (exp_ret--) { | |
| 182 ret /= 10.0; | |
| 183 } | |
| 184 } | |
| 185 return is_negative ? -ret : ret; | |
| 186 } | |
| 187 #undef EXPONENT_DETECT | |
| 188 | |
| 189 FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, | 87 FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, |
| 190 uint32_t src_size, | 88 uint32_t src_size, |
| 191 uint8_t*& dest_buf, | 89 uint8_t*& dest_buf, |
| 192 uint32_t& dest_size) { | 90 uint32_t& dest_size) { |
| 193 return FALSE; | 91 return FALSE; |
| 194 } | 92 } |
| 195 | 93 |
| 196 #ifdef PDF_ENABLE_XFA | 94 #ifdef PDF_ENABLE_XFA |
| 197 CFX_DIBAttribute::CFX_DIBAttribute() | 95 CFX_DIBAttribute::CFX_DIBAttribute() |
| 198 : m_nXDPI(-1), | 96 : m_nXDPI(-1), |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 int bpc) { | 306 int bpc) { |
| 409 std::unique_ptr<CCodec_RLScanlineDecoder> pRLScanlineDecoder( | 307 std::unique_ptr<CCodec_RLScanlineDecoder> pRLScanlineDecoder( |
| 410 new CCodec_RLScanlineDecoder); | 308 new CCodec_RLScanlineDecoder); |
| 411 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, | 309 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, |
| 412 bpc)) { | 310 bpc)) { |
| 413 return nullptr; | 311 return nullptr; |
| 414 } | 312 } |
| 415 | 313 |
| 416 return pRLScanlineDecoder.release(); | 314 return pRLScanlineDecoder.release(); |
| 417 } | 315 } |
| OLD | NEW |