summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-07-03 20:28:47 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-03 20:28:47 +0000
commita0aef45d9181aee30198fdb87557d61f62ad2a7c (patch)
tree37db07c7b3ad5833ace2c5e2caec3e12232130d7 /core
parent77f15f7883638a4ced131d74c053af10a5970ce9 (diff)
downloadpdfium-a0aef45d9181aee30198fdb87557d61f62ad2a7c.tar.xz
Remove a parameter from CPDF_SyntaxParser::FindTag().
The limit parameter is always set to 0. Change-Id: Idf7f44e1c5a895e05ad474932d3e9df85f435e3f Reviewed-on: https://pdfium-review.googlesource.com/36990 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.cpp20
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.h2
2 files changed, 9 insertions, 13 deletions
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index 6edfb24ba2..f8f36aee11 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -551,13 +551,13 @@ unsigned int CPDF_SyntaxParser::ReadEOLMarkers(FX_FILESIZE pos) {
FX_FILESIZE CPDF_SyntaxParser::FindWordPos(const ByteStringView& word) {
AutoRestorer<FX_FILESIZE> pos_restorer(&m_Pos);
- FX_FILESIZE end_offset = FindTag(word, 0);
+ FX_FILESIZE end_offset = FindTag(word);
while (end_offset >= 0) {
// Stop searching when word is found.
if (IsWholeWord(GetPos() - word.GetLength(), m_FileLen, word, true))
return GetPos() - word.GetLength();
- end_offset = FindTag(word, 0);
+ end_offset = FindTag(word);
}
return -1;
}
@@ -791,13 +791,12 @@ bool CPDF_SyntaxParser::BackwardsSearchToWord(const ByteStringView& tag,
}
}
-FX_FILESIZE CPDF_SyntaxParser::FindTag(const ByteStringView& tag,
- FX_FILESIZE limit) {
- int32_t taglen = tag.GetLength();
- int32_t match = 0;
- limit += m_Pos;
- FX_FILESIZE startpos = m_Pos;
+FX_FILESIZE CPDF_SyntaxParser::FindTag(const ByteStringView& tag) {
+ const FX_FILESIZE startpos = GetPos();
+ const int32_t taglen = tag.GetLength();
+ ASSERT(taglen > 0);
+ int32_t match = 0;
while (1) {
uint8_t ch;
if (!GetNextChar(ch))
@@ -806,13 +805,10 @@ FX_FILESIZE CPDF_SyntaxParser::FindTag(const ByteStringView& tag,
if (ch == tag[match]) {
match++;
if (match == taglen)
- return m_Pos - startpos - taglen;
+ return GetPos() - startpos - taglen;
} else {
match = ch == tag[0] ? 1 : 0;
}
-
- if (limit && m_Pos == limit)
- return -1;
}
return -1;
}
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h
index a29d631c95..962c32753d 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.h
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.h
@@ -54,7 +54,7 @@ class CPDF_SyntaxParser {
void ToNextLine();
void ToNextWord();
bool BackwardsSearchToWord(const ByteStringView& word, FX_FILESIZE limit);
- FX_FILESIZE FindTag(const ByteStringView& tag, FX_FILESIZE limit);
+ FX_FILESIZE FindTag(const ByteStringView& tag);
bool ReadBlock(uint8_t* pBuf, uint32_t size);
bool GetCharAt(FX_FILESIZE pos, uint8_t& ch);
ByteString GetNextWord(bool* bIsNumber);