From 71e2f0c9e337b320de02f043a6684f70fb6094c1 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 23 Apr 2012 23:43:48 +0000 Subject: [PATCH] [BUG_FIXED] (Author: Dave Brotherstone) Fix UTF-8 EOF detection for PCRE. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@900 f5eea248-9336-0410-98b8-ebc06183d4e3 --- scintilla/boostregex/BuildBoost.bat | 2 +- scintilla/boostregex/UTF8DocumentIterator.h | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scintilla/boostregex/BuildBoost.bat b/scintilla/boostregex/BuildBoost.bat index 5282ae1f..28dbf23d 100644 --- a/scintilla/boostregex/BuildBoost.bat +++ b/scintilla/boostregex/BuildBoost.bat @@ -173,7 +173,7 @@ IF [%BOOSTLIBPATH%] == [] ( GOTO USAGE ) -ECHO # Autogenerated file, run BuildBoost.bat [path_to_boost] to generate > %~dp0%\boostpath.mak +ECHO # Autogenerated file, run BuildBoost.bat [path_to_boost] to generate > %WORKPATH%\boostpath.mak ECHO BOOSTPATH=%BOOSTPATH% >> %WORKPATH%\boostpath.mak ECHO BOOSTLIBPATH=%BOOSTLIBPATH% >> %WORKPATH%\boostpath.mak POPD diff --git a/scintilla/boostregex/UTF8DocumentIterator.h b/scintilla/boostregex/UTF8DocumentIterator.h index 534eb7d6..3f36aad2 100644 --- a/scintilla/boostregex/UTF8DocumentIterator.h +++ b/scintilla/boostregex/UTF8DocumentIterator.h @@ -94,6 +94,11 @@ public: else { m_pos += m_utf8Length; + + if (m_pos > m_end) + { + m_pos = m_end; + } m_characterIndex = 0; readCharacter(); } @@ -110,7 +115,7 @@ public: { --m_pos; // Skip past the UTF-8 extension bytes - while (0x80 == (m_doc->CharAt(m_pos) & 0xC0)) + while (0x80 == (m_doc->CharAt(m_pos) & 0xC0) && m_pos > 0) --m_pos; readCharacter(); @@ -133,7 +138,7 @@ private: bool ended() const { - return m_pos == m_end; + return m_pos >= m_end; } int m_pos;