summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/page/cpdf_contentmark.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_contentmark.h2
-rw-r--r--core/fpdfapi/parser/cpdf_simple_parser.cpp27
-rw-r--r--core/fpdfapi/parser/cpdf_simple_parser.h4
4 files changed, 20 insertions, 17 deletions
diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp
index 7d411b2084..cf8e37ec75 100644
--- a/core/fpdfapi/page/cpdf_contentmark.cpp
+++ b/core/fpdfapi/page/cpdf_contentmark.cpp
@@ -61,7 +61,7 @@ bool CPDF_ContentMark::HasMark(const ByteStringView& mark) const {
}
bool CPDF_ContentMark::LookupMark(const ByteStringView& mark,
- CPDF_Dictionary*& pDict) const {
+ CPDF_Dictionary** pDict) const {
const MarkData* pData = m_Ref.GetObject();
if (!pData)
return false;
@@ -69,7 +69,7 @@ bool CPDF_ContentMark::LookupMark(const ByteStringView& mark,
for (int i = 0; i < pData->CountItems(); i++) {
const CPDF_ContentMarkItem& item = pData->GetItem(i);
if (item.GetName() == mark) {
- pDict = item.GetParam();
+ *pDict = item.GetParam();
return true;
}
}
diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h
index f702859065..9619b12b6c 100644
--- a/core/fpdfapi/page/cpdf_contentmark.h
+++ b/core/fpdfapi/page/cpdf_contentmark.h
@@ -28,7 +28,7 @@ class CPDF_ContentMark {
const CPDF_ContentMarkItem& GetItem(int i) const;
bool HasMark(const ByteStringView& mark) const;
- bool LookupMark(const ByteStringView& mark, CPDF_Dictionary*& pDict) const;
+ bool LookupMark(const ByteStringView& mark, CPDF_Dictionary** pDict) const;
void AddMark(const ByteString& name, CPDF_Dictionary* pDict, bool bDirect);
void DeleteLastMark();
diff --git a/core/fpdfapi/parser/cpdf_simple_parser.cpp b/core/fpdfapi/parser/cpdf_simple_parser.cpp
index 5358b183d8..b49f8423c3 100644
--- a/core/fpdfapi/parser/cpdf_simple_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_simple_parser.cpp
@@ -14,17 +14,17 @@ CPDF_SimpleParser::CPDF_SimpleParser(const uint8_t* pData, uint32_t dwSize)
CPDF_SimpleParser::CPDF_SimpleParser(const ByteStringView& str)
: m_pData(str.raw_str()), m_dwSize(str.GetLength()), m_dwCurPos(0) {}
-void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, uint32_t& dwSize) {
- pStart = nullptr;
- dwSize = 0;
+std::pair<const uint8_t*, uint32_t> CPDF_SimpleParser::ParseWord() {
+ const uint8_t* pStart = nullptr;
+ uint8_t dwSize = 0;
uint8_t ch;
while (1) {
if (m_dwSize <= m_dwCurPos)
- return;
+ return std::make_pair(pStart, dwSize);
ch = m_pData[m_dwCurPos++];
while (PDFCharIsWhitespace(ch)) {
if (m_dwSize <= m_dwCurPos)
- return;
+ return std::make_pair(pStart, dwSize);
ch = m_pData[m_dwCurPos++];
}
@@ -33,7 +33,7 @@ void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, uint32_t& dwSize) {
while (1) {
if (m_dwSize <= m_dwCurPos)
- return;
+ return std::make_pair(pStart, dwSize);
ch = m_pData[m_dwCurPos++];
if (PDFCharIsLineEnding(ch))
break;
@@ -46,19 +46,19 @@ void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, uint32_t& dwSize) {
if (ch == '/') {
while (1) {
if (m_dwSize <= m_dwCurPos)
- return;
+ return std::make_pair(pStart, dwSize);
ch = m_pData[m_dwCurPos++];
if (!PDFCharIsOther(ch) && !PDFCharIsNumeric(ch)) {
m_dwCurPos--;
dwSize = m_dwCurPos - start_pos;
- return;
+ return std::make_pair(pStart, dwSize);
}
}
} else {
dwSize = 1;
if (ch == '<') {
if (m_dwSize <= m_dwCurPos)
- return;
+ return std::make_pair(pStart, dwSize);
ch = m_pData[m_dwCurPos++];
if (ch == '<')
dwSize = 2;
@@ -66,7 +66,7 @@ void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, uint32_t& dwSize) {
m_dwCurPos--;
} else if (ch == '>') {
if (m_dwSize <= m_dwCurPos)
- return;
+ return std::make_pair(pStart, dwSize);
ch = m_pData[m_dwCurPos++];
if (ch == '>')
dwSize = 2;
@@ -74,13 +74,13 @@ void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, uint32_t& dwSize) {
m_dwCurPos--;
}
}
- return;
+ return std::make_pair(pStart, dwSize);
}
dwSize = 1;
while (1) {
if (m_dwSize <= m_dwCurPos)
- return;
+ return std::make_pair(pStart, dwSize);
ch = m_pData[m_dwCurPos++];
if (PDFCharIsDelimiter(ch) || PDFCharIsWhitespace(ch)) {
@@ -89,12 +89,13 @@ void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, uint32_t& dwSize) {
}
dwSize++;
}
+ return std::make_pair(pStart, dwSize);
}
ByteStringView CPDF_SimpleParser::GetWord() {
const uint8_t* pStart;
uint32_t dwSize;
- ParseWord(pStart, dwSize);
+ std::tie(pStart, dwSize) = ParseWord();
if (dwSize == 1 && pStart[0] == '<') {
while (m_dwCurPos < m_dwSize && m_pData[m_dwCurPos] != '>') {
m_dwCurPos++;
diff --git a/core/fpdfapi/parser/cpdf_simple_parser.h b/core/fpdfapi/parser/cpdf_simple_parser.h
index 72cf700f60..659039e6fa 100644
--- a/core/fpdfapi/parser/cpdf_simple_parser.h
+++ b/core/fpdfapi/parser/cpdf_simple_parser.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_PARSER_CPDF_SIMPLE_PARSER_H_
#define CORE_FPDFAPI_PARSER_CPDF_SIMPLE_PARSER_H_
+#include <utility>
+
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
@@ -25,7 +27,7 @@ class CPDF_SimpleParser {
uint32_t GetCurPos() const { return m_dwCurPos; }
private:
- void ParseWord(const uint8_t*& pStart, uint32_t& dwSize);
+ std::pair<const uint8_t*, uint32_t> ParseWord();
const uint8_t* m_pData;
uint32_t m_dwSize;