Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp

Issue 1821043003: Remove FX_WORD in favor of uint16_t. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use stdint.h directly, bitfield minefield. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" 7 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 #include <vector> 10 #include <vector>
11 11
12 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" 12 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
14 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
15 #include "core/fpdfapi/include/cpdf_modulemgr.h" 15 #include "core/fpdfapi/include/cpdf_modulemgr.h"
16 #include "core/include/fxcodec/fx_codec.h" 16 #include "core/include/fxcodec/fx_codec.h"
17 #include "core/include/fxcrt/fx_ext.h" 17 #include "core/include/fxcrt/fx_ext.h"
18 #include "third_party/base/stl_util.h" 18 #include "third_party/base/stl_util.h"
19 19
20 #define _STREAM_MAX_SIZE_ 20 * 1024 * 1024 20 #define _STREAM_MAX_SIZE_ 20 * 1024 * 1024
21 21
22 const FX_WORD PDFDocEncoding[256] = { 22 const uint16_t PDFDocEncoding[256] = {
23 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 23 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
24 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 24 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0011,
25 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x02d8, 0x02c7, 0x02c6, 25 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x02d8, 0x02c7, 0x02c6,
26 0x02d9, 0x02dd, 0x02db, 0x02da, 0x02dc, 0x0020, 0x0021, 0x0022, 0x0023, 26 0x02d9, 0x02dd, 0x02db, 0x02da, 0x02dc, 0x0020, 0x0021, 0x0022, 0x0023,
27 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 27 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c,
28 0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 28 0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035,
29 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 29 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e,
30 0x003f, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 30 0x003f, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
31 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050, 31 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050,
32 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 32 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 if (!max_chars) { 440 if (!max_chars) {
441 return result; 441 return result;
442 } 442 }
443 if (src_data[0] == 0xff) { 443 if (src_data[0] == 0xff) {
444 bBE = !src_data[2]; 444 bBE = !src_data[2];
445 } 445 }
446 FX_WCHAR* dest_buf = result.GetBuffer(max_chars); 446 FX_WCHAR* dest_buf = result.GetBuffer(max_chars);
447 const uint8_t* uni_str = src_data + 2; 447 const uint8_t* uni_str = src_data + 2;
448 int dest_pos = 0; 448 int dest_pos = 0;
449 for (FX_DWORD i = 0; i < max_chars * 2; i += 2) { 449 for (FX_DWORD i = 0; i < max_chars * 2; i += 2) {
450 FX_WORD unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) 450 uint16_t unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1])
451 : (uni_str[i + 1] << 8 | uni_str[i]); 451 : (uni_str[i + 1] << 8 | uni_str[i]);
452 if (unicode == 0x1b) { 452 if (unicode == 0x1b) {
453 i += 2; 453 i += 2;
454 while (i < max_chars * 2) { 454 while (i < max_chars * 2) {
455 FX_WORD unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) 455 uint16_t unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1])
456 : (uni_str[i + 1] << 8 | uni_str[i]); 456 : (uni_str[i + 1] << 8 | uni_str[i]);
457 i += 2; 457 i += 2;
458 if (unicode == 0x1b) { 458 if (unicode == 0x1b) {
459 break; 459 break;
460 } 460 }
461 } 461 }
462 } else { 462 } else {
463 dest_buf[dest_pos++] = unicode; 463 dest_buf[dest_pos++] = unicode;
464 } 464 }
465 } 465 }
466 result.ReleaseBuffer(dest_pos); 466 result.ReleaseBuffer(dest_pos);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 FX_DWORD src_size, 583 FX_DWORD src_size,
584 uint8_t*& dest_buf, 584 uint8_t*& dest_buf,
585 FX_DWORD& dest_size) { 585 FX_DWORD& dest_size) {
586 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); 586 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule();
587 if (pEncoders) { 587 if (pEncoders) {
588 return pEncoders->GetFlateModule()->FlateOrLZWDecode( 588 return pEncoders->GetFlateModule()->FlateOrLZWDecode(
589 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); 589 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size);
590 } 590 }
591 return 0; 591 return 0;
592 } 592 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_parser_unittest.cpp ('k') | core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698