aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaHistory.html12
-rw-r--r--src/RESearch.cxx23
-rw-r--r--src/RESearch.h3
-rw-r--r--test/unit/testRESearch.cxx11
4 files changed, 38 insertions, 11 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 823c8dc7b..94b020036 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -584,6 +584,18 @@
</table>
<h2>Releases</h2>
<h3>
+ <a href="https://www.scintilla.org/scintilla541.zip">Release 5.4.1</a>
+ </h3>
+ <ul>
+ <li>
+ Released 18 November 2023.
+ </li>
+ <li>
+ Fix regular expression search failure when search for "\&lt;" followed by search for "\&gt;".
+ <a href="https://sourceforge.net/p/scintilla/bugs/2413/">Bug #2413</a>.
+ </li>
+ </ul>
+ <h3>
<a href="https://www.scintilla.org/scintilla540.zip">Release 5.4.0</a>
</h3>
<ul>
diff --git a/src/RESearch.cxx b/src/RESearch.cxx
index ca0f1b552..ac41138c8 100644
--- a/src/RESearch.cxx
+++ b/src/RESearch.cxx
@@ -256,8 +256,7 @@ RESearch::RESearch(CharClassify *charClassTable) {
bol = 0;
constexpr unsigned char nul = 0;
std::fill(bittab, std::end(bittab), nul);
- std::fill(tagstk, std::end(tagstk), 0);
- std::fill(nfa, std::end(nfa), '\0');
+ nfa[0] = END;
Clear();
}
@@ -419,12 +418,24 @@ int RESearch::GetBackslashExpression(
return result;
}
-const char *RESearch::Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix) noexcept {
+const char *RESearch::Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix) {
+ if (!pattern || !length) {
+ if (sta)
+ return nullptr;
+ else
+ return badpat("No previous regular expression");
+ }
+
+ constexpr unsigned char nul = 0;
+ std::fill(bittab, std::end(bittab), nul);
+ nfa[0] = END;
+
char *mp=nfa; /* nfa pointer */
char *lp=nullptr; /* saved pointer */
char *sp=nfa; /* another one */
const char * mpMax = mp + MAXNFA - BITBLK - 10;
+ int tagstk[MAXTAG]{}; /* subpat tag stack */
int tagi = 0; /* tag stack index */
int tagc = 1; /* actual tag count */
@@ -434,12 +445,6 @@ const char *RESearch::Compile(const char *pattern, Sci::Position length, bool ca
int c2 = 0;
int prevChar = 0;
- if (!pattern || !length) {
- if (sta)
- return nullptr;
- else
- return badpat("No previous regular expression");
- }
sta = NOP;
const char *p=pattern; /* pattern pointer */
diff --git a/src/RESearch.h b/src/RESearch.h
index 05bc0e093..5ac3f00dc 100644
--- a/src/RESearch.h
+++ b/src/RESearch.h
@@ -22,7 +22,7 @@ public:
explicit RESearch(CharClassify *charClassTable);
// No dynamic allocation so default copy constructor and assignment operator are OK.
void Clear();
- const char *Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix) noexcept;
+ const char *Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix);
int Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp);
static constexpr int MAXTAG = 10;
@@ -48,7 +48,6 @@ private:
Sci::Position PMatch(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, const char *ap);
Sci::Position bol;
- Sci::Position tagstk[MAXTAG]; /* subpat tag stack */
char nfa[MAXNFA]; /* automaton */
int sta;
unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */
diff --git a/test/unit/testRESearch.cxx b/test/unit/testRESearch.cxx
index 781d776a4..9bc1b43bb 100644
--- a/test/unit/testRESearch.cxx
+++ b/test/unit/testRESearch.cxx
@@ -60,6 +60,17 @@ TEST_CASE("RESearch") {
REQUIRE(nullptr == msg);
}
+ SECTION("Bug2413") {
+ // Check for https://sourceforge.net/p/scintilla/bugs/2413/
+ std::unique_ptr<RESearch> re = std::make_unique<RESearch>(&cc);
+ constexpr std::string_view BOW = "\\<";
+ constexpr std::string_view EOW = "\\>";
+ const char *msg = re->Compile(BOW.data(), BOW.length(), true, false);
+ REQUIRE(nullptr == msg);
+ msg = re->Compile(EOW.data(), EOW.length(), true, false);
+ REQUIRE(nullptr == msg);
+ }
+
SECTION("Execute") {
std::unique_ptr<RESearch> re = std::make_unique<RESearch>(&cc);
re->Compile(pattern.data(), pattern.length(), true, false);