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

Unified Diff: core/fpdfdoc/doc_basic.cpp

Issue 1977093002: Make CFX_ByteString(const CFX_ByteStringC&) explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, nit Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/doc_action.cpp ('k') | core/fpdfdoc/doc_bookmark.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/doc_basic.cpp
diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp
index 76639efac66743f6a9fbe0942543f32f1cd2941f..ab99cff77246e1bd82c5dd9d3027a1ebf88e9619 100644
--- a/core/fpdfdoc/doc_basic.cpp
+++ b/core/fpdfdoc/doc_basic.cpp
@@ -500,30 +500,25 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const {
wsLabel.Format(L"%d", nPage + 1);
return wsLabel;
}
+
int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const {
- if (!m_pDocument) {
+ if (!m_pDocument)
return -1;
- }
+
CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
- if (!pPDFRoot) {
+ if (!pPDFRoot)
return -1;
- }
+
int nPages = m_pDocument->GetPageCount();
- CFX_ByteString bsLbl;
- CFX_ByteString bsOrig = bsLabel;
for (int i = 0; i < nPages; i++) {
- bsLbl = PDF_EncodeText(GetLabel(i));
- if (!bsLbl.Compare(bsOrig.AsStringC())) {
+ if (PDF_EncodeText(GetLabel(i)).Compare(bsLabel))
return i;
- }
- }
- bsLbl = bsOrig;
- int nPage = FXSYS_atoi(bsLbl.c_str());
- if (nPage > 0 && nPage <= nPages) {
- return nPage;
}
- return -1;
+
+ int nPage = FXSYS_atoi(CFX_ByteString(bsLabel).c_str()); // NUL terminate.
+ return nPage > 0 && nPage <= nPages ? nPage : -1;
}
+
int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const {
return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsStringC());
}
« no previous file with comments | « core/fpdfdoc/doc_action.cpp ('k') | core/fpdfdoc/doc_bookmark.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698