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

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

Issue 1885973002: Remove implicit cast from CFX_ByteString to (const char*). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Typo Created 4 years, 8 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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/cpdf_parser.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 FX_BOOL bXRefRebuilt = FALSE; 195 FX_BOOL bXRefRebuilt = FALSE;
196 if (m_pSyntax->SearchWord("startxref", TRUE, FALSE, 4096)) { 196 if (m_pSyntax->SearchWord("startxref", TRUE, FALSE, 4096)) {
197 m_SortedOffset.insert(m_pSyntax->SavePos()); 197 m_SortedOffset.insert(m_pSyntax->SavePos());
198 m_pSyntax->GetKeyword(); 198 m_pSyntax->GetKeyword();
199 199
200 bool bNumber; 200 bool bNumber;
201 CFX_ByteString xrefpos_str = m_pSyntax->GetNextWord(&bNumber); 201 CFX_ByteString xrefpos_str = m_pSyntax->GetNextWord(&bNumber);
202 if (!bNumber) 202 if (!bNumber)
203 return FORMAT_ERROR; 203 return FORMAT_ERROR;
204 204
205 m_LastXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); 205 m_LastXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str.c_str());
206 if (!LoadAllCrossRefV4(m_LastXRefOffset) && 206 if (!LoadAllCrossRefV4(m_LastXRefOffset) &&
207 !LoadAllCrossRefV5(m_LastXRefOffset)) { 207 !LoadAllCrossRefV5(m_LastXRefOffset)) {
208 if (!RebuildCrossRef()) 208 if (!RebuildCrossRef())
209 return FORMAT_ERROR; 209 return FORMAT_ERROR;
210 210
211 bXRefRebuilt = TRUE; 211 bXRefRebuilt = TRUE;
212 m_LastXRefOffset = 0; 212 m_LastXRefOffset = 0;
213 } 213 }
214 } else { 214 } else {
215 if (!RebuildCrossRef()) 215 if (!RebuildCrossRef())
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 bool bIsNumber; 498 bool bIsNumber;
499 CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber); 499 CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
500 if (word.IsEmpty()) 500 if (word.IsEmpty())
501 return false; 501 return false;
502 502
503 if (!bIsNumber) { 503 if (!bIsNumber) {
504 m_pSyntax->RestorePos(SavedPos); 504 m_pSyntax->RestorePos(SavedPos);
505 break; 505 break;
506 } 506 }
507 507
508 uint32_t start_objnum = FXSYS_atoui(word); 508 uint32_t start_objnum = FXSYS_atoui(word.c_str());
509 if (start_objnum >= kMaxObjectNumber) 509 if (start_objnum >= kMaxObjectNumber)
510 return false; 510 return false;
511 511
512 uint32_t count = m_pSyntax->GetDirectNum(); 512 uint32_t count = m_pSyntax->GetDirectNum();
513 m_pSyntax->ToNextWord(); 513 m_pSyntax->ToNextWord();
514 SavedPos = m_pSyntax->SavePos(); 514 SavedPos = m_pSyntax->SavePos();
515 const int32_t recordsize = 20; 515 const int32_t recordsize = 20;
516 516
517 m_dwXrefStartObjNum = start_objnum; 517 m_dwXrefStartObjNum = start_objnum;
518 if (!bSkip) { 518 if (!bSkip) {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 m_pTrailer = pTrailer; 839 m_pTrailer = pTrailer;
840 } 840 }
841 841
842 FX_FILESIZE dwSavePos = m_pSyntax->SavePos(); 842 FX_FILESIZE dwSavePos = m_pSyntax->SavePos();
843 CFX_ByteString strWord = m_pSyntax->GetKeyword(); 843 CFX_ByteString strWord = m_pSyntax->GetKeyword();
844 if (!strWord.Compare("startxref")) { 844 if (!strWord.Compare("startxref")) {
845 bool bNumber; 845 bool bNumber;
846 CFX_ByteString bsOffset = 846 CFX_ByteString bsOffset =
847 m_pSyntax->GetNextWord(&bNumber); 847 m_pSyntax->GetNextWord(&bNumber);
848 if (bNumber) 848 if (bNumber)
849 m_LastXRefOffset = FXSYS_atoi(bsOffset); 849 m_LastXRefOffset = FXSYS_atoi(bsOffset.c_str());
850 } 850 }
851 m_pSyntax->RestorePos(dwSavePos); 851 m_pSyntax->RestorePos(dwSavePos);
852 } 852 }
853 } else { 853 } else {
854 pObj->Release(); 854 pObj->Release();
855 } 855 }
856 } 856 }
857 } 857 }
858 } 858 }
859 --i; 859 --i;
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 FX_FILESIZE SavedPos = m_pSyntax->SavePos(); 1286 FX_FILESIZE SavedPos = m_pSyntax->SavePos();
1287 m_pSyntax->RestorePos(pos); 1287 m_pSyntax->RestorePos(pos);
1288 1288
1289 bool bIsNumber; 1289 bool bIsNumber;
1290 CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber); 1290 CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
1291 if (!bIsNumber) { 1291 if (!bIsNumber) {
1292 m_pSyntax->RestorePos(SavedPos); 1292 m_pSyntax->RestorePos(SavedPos);
1293 return; 1293 return;
1294 } 1294 }
1295 1295
1296 uint32_t parser_objnum = FXSYS_atoui(word); 1296 uint32_t parser_objnum = FXSYS_atoui(word.c_str());
1297 if (parser_objnum && parser_objnum != objnum) { 1297 if (parser_objnum && parser_objnum != objnum) {
1298 m_pSyntax->RestorePos(SavedPos); 1298 m_pSyntax->RestorePos(SavedPos);
1299 return; 1299 return;
1300 } 1300 }
1301 1301
1302 word = m_pSyntax->GetNextWord(&bIsNumber); 1302 word = m_pSyntax->GetNextWord(&bIsNumber);
1303 if (!bIsNumber) { 1303 if (!bIsNumber) {
1304 m_pSyntax->RestorePos(SavedPos); 1304 m_pSyntax->RestorePos(SavedPos);
1305 return; 1305 return;
1306 } 1306 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 m_pSyntax->RestorePos(pos); 1358 m_pSyntax->RestorePos(pos);
1359 bool bIsNumber; 1359 bool bIsNumber;
1360 CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber); 1360 CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
1361 if (!bIsNumber) { 1361 if (!bIsNumber) {
1362 m_pSyntax->RestorePos(SavedPos); 1362 m_pSyntax->RestorePos(SavedPos);
1363 return nullptr; 1363 return nullptr;
1364 } 1364 }
1365 1365
1366 FX_FILESIZE objOffset = m_pSyntax->SavePos(); 1366 FX_FILESIZE objOffset = m_pSyntax->SavePos();
1367 objOffset -= word.GetLength(); 1367 objOffset -= word.GetLength();
1368 uint32_t parser_objnum = FXSYS_atoui(word); 1368 uint32_t parser_objnum = FXSYS_atoui(word.c_str());
1369 if (objnum && parser_objnum != objnum) { 1369 if (objnum && parser_objnum != objnum) {
1370 m_pSyntax->RestorePos(SavedPos); 1370 m_pSyntax->RestorePos(SavedPos);
1371 return nullptr; 1371 return nullptr;
1372 } 1372 }
1373 1373
1374 word = m_pSyntax->GetNextWord(&bIsNumber); 1374 word = m_pSyntax->GetNextWord(&bIsNumber);
1375 if (!bIsNumber) { 1375 if (!bIsNumber) {
1376 m_pSyntax->RestorePos(SavedPos); 1376 m_pSyntax->RestorePos(SavedPos);
1377 return nullptr; 1377 return nullptr;
1378 } 1378 }
1379 1379
1380 uint32_t parser_gennum = FXSYS_atoui(word); 1380 uint32_t parser_gennum = FXSYS_atoui(word.c_str());
1381 if (m_pSyntax->GetKeyword() != "obj") { 1381 if (m_pSyntax->GetKeyword() != "obj") {
1382 m_pSyntax->RestorePos(SavedPos); 1382 m_pSyntax->RestorePos(SavedPos);
1383 return nullptr; 1383 return nullptr;
1384 } 1384 }
1385 1385
1386 CPDF_Object* pObj = 1386 CPDF_Object* pObj =
1387 m_pSyntax->GetObject(pObjList, objnum, parser_gennum, true); 1387 m_pSyntax->GetObject(pObjList, objnum, parser_gennum, true);
1388 m_pSyntax->SavePos(); 1388 m_pSyntax->SavePos();
1389 1389
1390 CFX_ByteString bsWord = m_pSyntax->GetKeyword(); 1390 CFX_ByteString bsWord = m_pSyntax->GetKeyword();
(...skipping 17 matching lines...) Expand all
1408 FX_FILESIZE SavedPos = m_pSyntax->SavePos(); 1408 FX_FILESIZE SavedPos = m_pSyntax->SavePos();
1409 m_pSyntax->RestorePos(pos); 1409 m_pSyntax->RestorePos(pos);
1410 1410
1411 bool bIsNumber; 1411 bool bIsNumber;
1412 CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber); 1412 CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
1413 if (!bIsNumber) { 1413 if (!bIsNumber) {
1414 m_pSyntax->RestorePos(SavedPos); 1414 m_pSyntax->RestorePos(SavedPos);
1415 return nullptr; 1415 return nullptr;
1416 } 1416 }
1417 1417
1418 uint32_t parser_objnum = FXSYS_atoui(word); 1418 uint32_t parser_objnum = FXSYS_atoui(word.c_str());
1419 if (objnum && parser_objnum != objnum) { 1419 if (objnum && parser_objnum != objnum) {
1420 m_pSyntax->RestorePos(SavedPos); 1420 m_pSyntax->RestorePos(SavedPos);
1421 return nullptr; 1421 return nullptr;
1422 } 1422 }
1423 1423
1424 word = m_pSyntax->GetNextWord(&bIsNumber); 1424 word = m_pSyntax->GetNextWord(&bIsNumber);
1425 if (!bIsNumber) { 1425 if (!bIsNumber) {
1426 m_pSyntax->RestorePos(SavedPos); 1426 m_pSyntax->RestorePos(SavedPos);
1427 return nullptr; 1427 return nullptr;
1428 } 1428 }
1429 1429
1430 uint32_t gennum = FXSYS_atoui(word); 1430 uint32_t gennum = FXSYS_atoui(word.c_str());
1431 if (m_pSyntax->GetKeyword() != "obj") { 1431 if (m_pSyntax->GetKeyword() != "obj") {
1432 m_pSyntax->RestorePos(SavedPos); 1432 m_pSyntax->RestorePos(SavedPos);
1433 return nullptr; 1433 return nullptr;
1434 } 1434 }
1435 1435
1436 CPDF_Object* pObj = m_pSyntax->GetObjectByStrict(pObjList, objnum, gennum); 1436 CPDF_Object* pObj = m_pSyntax->GetObjectByStrict(pObjList, objnum, gennum);
1437 if (pResultPos) 1437 if (pResultPos)
1438 *pResultPos = m_pSyntax->m_Pos; 1438 *pResultPos = m_pSyntax->m_Pos;
1439 1439
1440 m_pSyntax->RestorePos(SavedPos); 1440 m_pSyntax->RestorePos(SavedPos);
(...skipping 29 matching lines...) Expand all
1470 uint32_t offset) { 1470 uint32_t offset) {
1471 m_pSyntax->InitParser(pFileAccess, offset); 1471 m_pSyntax->InitParser(pFileAccess, offset);
1472 m_pSyntax->RestorePos(m_pSyntax->m_HeaderOffset + 9); 1472 m_pSyntax->RestorePos(m_pSyntax->m_HeaderOffset + 9);
1473 1473
1474 FX_FILESIZE SavedPos = m_pSyntax->SavePos(); 1474 FX_FILESIZE SavedPos = m_pSyntax->SavePos();
1475 bool bIsNumber; 1475 bool bIsNumber;
1476 CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber); 1476 CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
1477 if (!bIsNumber) 1477 if (!bIsNumber)
1478 return FALSE; 1478 return FALSE;
1479 1479
1480 uint32_t objnum = FXSYS_atoui(word); 1480 uint32_t objnum = FXSYS_atoui(word.c_str());
1481 word = m_pSyntax->GetNextWord(&bIsNumber); 1481 word = m_pSyntax->GetNextWord(&bIsNumber);
1482 if (!bIsNumber) 1482 if (!bIsNumber)
1483 return FALSE; 1483 return FALSE;
1484 1484
1485 uint32_t gennum = FXSYS_atoui(word); 1485 uint32_t gennum = FXSYS_atoui(word.c_str());
1486 if (m_pSyntax->GetKeyword() != "obj") { 1486 if (m_pSyntax->GetKeyword() != "obj") {
1487 m_pSyntax->RestorePos(SavedPos); 1487 m_pSyntax->RestorePos(SavedPos);
1488 return FALSE; 1488 return FALSE;
1489 } 1489 }
1490 1490
1491 m_pLinearized = m_pSyntax->GetObject(nullptr, objnum, gennum, true); 1491 m_pLinearized = m_pSyntax->GetObject(nullptr, objnum, gennum, true);
1492 if (!m_pLinearized) 1492 if (!m_pLinearized)
1493 return FALSE; 1493 return FALSE;
1494 1494
1495 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); 1495 CPDF_Dictionary* pDict = m_pLinearized->GetDict();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && 1643 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) &&
1644 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { 1644 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) {
1645 m_LastXRefOffset = 0; 1645 m_LastXRefOffset = 0;
1646 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1646 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1647 return FORMAT_ERROR; 1647 return FORMAT_ERROR;
1648 } 1648 }
1649 1649
1650 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1650 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1651 return SUCCESS; 1651 return SUCCESS;
1652 } 1652 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698