From 42e2790cb7c9f531be1cfc78b1241f592776db07 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 3 Jul 2018 13:41:14 +0000 Subject: Fix indentation in CPDF_SyntaxParser. Change-Id: I293730ea5981ba8e2dca7a522b9036fa62d7cd35 Reviewed-on: https://pdfium-review.googlesource.com/36890 Commit-Queue: dsinclair Reviewed-by: Art Snake Reviewed-by: dsinclair --- core/fpdfapi/parser/cpdf_syntax_parser.cpp | 144 ++++++++++++++--------------- 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index 0910a39e2a..09ed011cda 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -530,92 +530,92 @@ std::unique_ptr CPDF_SyntaxParser::ReadStream( const ByteStringView kEndStreamStr("endstream"); const ByteStringView kEndObjStr("endobj"); - bool bSearchForKeyword = true; - if (len >= 0) { - pdfium::base::CheckedNumeric pos = m_Pos; - pos += len; - if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) - m_Pos = pos.ValueOrDie(); - - m_Pos += ReadEOLMarkers(m_Pos); - memset(m_WordBuffer, 0, kEndStreamStr.GetLength() + 1); - GetNextWordInternal(nullptr); - // Earlier version of PDF specification doesn't require EOL marker before - // 'endstream' keyword. If keyword 'endstream' follows the bytes in - // specified length, it signals the end of stream. - if (memcmp(m_WordBuffer, kEndStreamStr.raw_str(), - kEndStreamStr.GetLength()) == 0) { - bSearchForKeyword = false; - } + bool bSearchForKeyword = true; + if (len >= 0) { + pdfium::base::CheckedNumeric pos = m_Pos; + pos += len; + if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) + m_Pos = pos.ValueOrDie(); + + m_Pos += ReadEOLMarkers(m_Pos); + memset(m_WordBuffer, 0, kEndStreamStr.GetLength() + 1); + GetNextWordInternal(nullptr); + // Earlier version of PDF specification doesn't require EOL marker before + // 'endstream' keyword. If keyword 'endstream' follows the bytes in + // specified length, it signals the end of stream. + if (memcmp(m_WordBuffer, kEndStreamStr.raw_str(), + kEndStreamStr.GetLength()) == 0) { + bSearchForKeyword = false; } + } - if (bSearchForKeyword) { - // If len is not available, len needs to be calculated - // by searching the keywords "endstream" or "endobj". - m_Pos = streamStartPos; - FX_FILESIZE endStreamOffset = 0; - while (endStreamOffset >= 0) { - endStreamOffset = FindTag(kEndStreamStr, 0); + if (bSearchForKeyword) { + // If len is not available, len needs to be calculated + // by searching the keywords "endstream" or "endobj". + m_Pos = streamStartPos; + FX_FILESIZE endStreamOffset = 0; + while (endStreamOffset >= 0) { + endStreamOffset = FindTag(kEndStreamStr, 0); - // Can't find "endstream". - if (endStreamOffset < 0) - break; + // Can't find "endstream". + if (endStreamOffset < 0) + break; - // Stop searching when "endstream" is found. - if (IsWholeWord(m_Pos - kEndStreamStr.GetLength(), m_FileLen, - kEndStreamStr, true)) { - endStreamOffset = m_Pos - streamStartPos - kEndStreamStr.GetLength(); - break; - } + // Stop searching when "endstream" is found. + if (IsWholeWord(m_Pos - kEndStreamStr.GetLength(), m_FileLen, + kEndStreamStr, true)) { + endStreamOffset = m_Pos - streamStartPos - kEndStreamStr.GetLength(); + break; } + } - m_Pos = streamStartPos; - FX_FILESIZE endObjOffset = 0; - while (endObjOffset >= 0) { - endObjOffset = FindTag(kEndObjStr, 0); + m_Pos = streamStartPos; + FX_FILESIZE endObjOffset = 0; + while (endObjOffset >= 0) { + endObjOffset = FindTag(kEndObjStr, 0); - // Can't find "endobj". - if (endObjOffset < 0) - break; + // Can't find "endobj". + if (endObjOffset < 0) + break; - // Stop searching when "endobj" is found. - if (IsWholeWord(m_Pos - kEndObjStr.GetLength(), m_FileLen, kEndObjStr, - true)) { - endObjOffset = m_Pos - streamStartPos - kEndObjStr.GetLength(); - break; - } + // Stop searching when "endobj" is found. + if (IsWholeWord(m_Pos - kEndObjStr.GetLength(), m_FileLen, kEndObjStr, + true)) { + endObjOffset = m_Pos - streamStartPos - kEndObjStr.GetLength(); + break; } + } - // Can't find "endstream" or "endobj". - if (endStreamOffset < 0 && endObjOffset < 0) - return nullptr; + // Can't find "endstream" or "endobj". + if (endStreamOffset < 0 && endObjOffset < 0) + return nullptr; - if (endStreamOffset < 0 && endObjOffset >= 0) { - // Correct the position of end stream. - endStreamOffset = endObjOffset; - } else if (endStreamOffset >= 0 && endObjOffset < 0) { - // Correct the position of end obj. - endObjOffset = endStreamOffset; - } else if (endStreamOffset > endObjOffset) { - endStreamOffset = endObjOffset; - } - len = endStreamOffset; + if (endStreamOffset < 0 && endObjOffset >= 0) { + // Correct the position of end stream. + endStreamOffset = endObjOffset; + } else if (endStreamOffset >= 0 && endObjOffset < 0) { + // Correct the position of end obj. + endObjOffset = endStreamOffset; + } else if (endStreamOffset > endObjOffset) { + endStreamOffset = endObjOffset; + } + len = endStreamOffset; - int numMarkers = ReadEOLMarkers(streamStartPos + endStreamOffset - 2); - if (numMarkers == 2) { - len -= 2; - } else { - numMarkers = ReadEOLMarkers(streamStartPos + endStreamOffset - 1); - if (numMarkers == 1) { - len -= 1; - } + int numMarkers = ReadEOLMarkers(streamStartPos + endStreamOffset - 2); + if (numMarkers == 2) { + len -= 2; + } else { + numMarkers = ReadEOLMarkers(streamStartPos + endStreamOffset - 1); + if (numMarkers == 1) { + len -= 1; } - if (len < 0) - return nullptr; - - pDict->SetNewFor("Length", static_cast(len)); } - m_Pos = streamStartPos; + if (len < 0) + return nullptr; + + pDict->SetNewFor("Length", static_cast(len)); + } + m_Pos = streamStartPos; // Read up to the end of the buffer. Note, we allow zero length streams as // we need to pass them through when we are importing pages into a new -- cgit v1.2.3