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

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

Issue 2027273002: Fix all the code which has duplicate variable declarations (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 6 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 <utility> 10 #include <utility>
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 440 }
441 FX_WCHAR* dest_buf = result.GetBuffer(max_chars); 441 FX_WCHAR* dest_buf = result.GetBuffer(max_chars);
442 const uint8_t* uni_str = src_data + 2; 442 const uint8_t* uni_str = src_data + 2;
443 int dest_pos = 0; 443 int dest_pos = 0;
444 for (uint32_t i = 0; i < max_chars * 2; i += 2) { 444 for (uint32_t i = 0; i < max_chars * 2; i += 2) {
445 uint16_t unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) 445 uint16_t unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1])
446 : (uni_str[i + 1] << 8 | uni_str[i]); 446 : (uni_str[i + 1] << 8 | uni_str[i]);
447 if (unicode == 0x1b) { 447 if (unicode == 0x1b) {
448 i += 2; 448 i += 2;
449 while (i < max_chars * 2) { 449 while (i < max_chars * 2) {
450 uint16_t unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) 450 uint16_t unicode2 = 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 i += 2; 452 i += 2;
453 if (unicode == 0x1b) { 453 if (unicode2 == 0x1b)
454 break; 454 break;
455 }
456 } 455 }
457 } else { 456 } else {
458 dest_buf[dest_pos++] = unicode; 457 dest_buf[dest_pos++] = unicode;
459 } 458 }
460 } 459 }
461 result.ReleaseBuffer(dest_pos); 460 result.ReleaseBuffer(dest_pos);
462 } else { 461 } else {
463 FX_WCHAR* dest_buf = result.GetBuffer(src_len); 462 FX_WCHAR* dest_buf = result.GetBuffer(src_len);
464 for (uint32_t i = 0; i < src_len; i++) 463 for (uint32_t i = 0; i < src_len; i++)
465 dest_buf[i] = PDFDocEncoding[src_data[i]]; 464 dest_buf[i] = PDFDocEncoding[src_data[i]];
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 result.ReleaseBuffer(0); 498 result.ReleaseBuffer(0);
500 return result; 499 return result;
501 } 500 }
502 501
503 int encLen = len * 2 + 2; 502 int encLen = len * 2 + 2;
504 503
505 uint8_t* dest_buf2 = (uint8_t*)result.GetBuffer(encLen); 504 uint8_t* dest_buf2 = (uint8_t*)result.GetBuffer(encLen);
506 dest_buf2[0] = 0xfe; 505 dest_buf2[0] = 0xfe;
507 dest_buf2[1] = 0xff; 506 dest_buf2[1] = 0xff;
508 dest_buf2 += 2; 507 dest_buf2 += 2;
509 for (int i = 0; i < len; i++) { 508 for (int j = 0; j < len; j++) {
510 *dest_buf2++ = pString[i] >> 8; 509 *dest_buf2++ = pString[i] >> 8;
511 *dest_buf2++ = (uint8_t)pString[i]; 510 *dest_buf2++ = (uint8_t)pString[j];
512 } 511 }
513 result.ReleaseBuffer(encLen); 512 result.ReleaseBuffer(encLen);
514 return result; 513 return result;
515 } 514 }
516 515
517 CFX_ByteString PDF_EncodeText(const CFX_WideString& str) { 516 CFX_ByteString PDF_EncodeText(const CFX_WideString& str) {
518 return PDF_EncodeText(str.c_str(), str.GetLength()); 517 return PDF_EncodeText(str.c_str(), str.GetLength());
519 } 518 }
520 519
521 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) { 520 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 uint32_t src_size, 577 uint32_t src_size,
579 uint8_t*& dest_buf, 578 uint8_t*& dest_buf,
580 uint32_t& dest_size) { 579 uint32_t& dest_size) {
581 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); 580 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule();
582 if (pEncoders) { 581 if (pEncoders) {
583 return pEncoders->GetFlateModule()->FlateOrLZWDecode( 582 return pEncoders->GetFlateModule()->FlateOrLZWDecode(
584 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); 583 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size);
585 } 584 }
586 return 0; 585 return 0;
587 } 586 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp ('k') | core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698