Skip to content

Commit

Permalink
released 4.1.1
Browse files Browse the repository at this point in the history
minor update to correct a DFA construction problem for POSIX regex lazy quantifiers matching too much in some cases
  • Loading branch information
genivia-inc committed Mar 11, 2024
1 parent 187103a commit 660d4af
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ Changelog
- Feb 17, 2024: 4.0.0 faster `Matcher::find()` with a new DFA cut algorithm to optimize match prediction speed and accuracy, see also ugrep 5.0; apply Unicode pattern canonicalization with `reflex::convert(..., reflex::convert_flag::unicode)`.
- Feb 23, 2024: 4.0.1 new `rawk` example to demonstrate awk-like fast search in C++; enable `<<EOF>>` rules for option `find` to generate a fast search engine.
- Mar 5, 2024: 4.1.0 improved lazy quantifiers for POSIX regex lazy matching in linear time using an advanced DFA transformation algorithm introduced in RE/flex in 2016.
- Mar 11, 2024: 4.1.1 minor update to correct a DFA construction problem for POSIX regex lazy quantifiers matching too much in some cases.

[logo-url]: https://www.genivia.com/images/reflex-logo.png
[reflex-url]: https://www.genivia.com/reflex.html
Expand Down
Binary file modified bin/win32/reflex.exe
Binary file not shown.
Binary file modified bin/win64/reflex.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion doc/man/reflex.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH REFLEX "1" "March 05, 2024" "reflex 4.1.0" "User Commands"
.TH REFLEX "1" "March 11, 2024" "reflex 4.1.1" "User Commands"
.SH NAME
\fBreflex\fR -- regex\-centric, fast and flexible lexical analyzer generator
.SH SYNOPSIS
Expand Down
23 changes: 17 additions & 6 deletions lib/pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,13 +944,23 @@ void Pattern::parse2(
iter = iter1;
}
}
for (Positions::const_iterator p = a_pos.begin(); p != a_pos.end(); ++p)
for (Positions::iterator p = a_pos.begin(); p != a_pos.end(); ++p)
{
for (Positions::const_iterator k = lastpos.begin(); k != lastpos.end(); ++k)
if (at(k->loc()) == ')' && lookahead.find(k->loc()) != lookahead.end())
pos_add(followpos[p->pos()], *k);
for (Positions::const_iterator k = lastpos.begin(); k != lastpos.end(); ++k)
pos_add(followpos[k->pos()], p->anchor(!nullable || k->pos() != p->pos()));
if (lazypos.empty())
{
for (Positions::const_iterator k = lastpos.begin(); k != lastpos.end(); ++k)
pos_add(followpos[k->pos()], p->anchor(!nullable || k->pos() != p->pos()));
}
else
{
// make the starting anchors at positions a_pos lazy
for (Lazypos::const_iterator l = lazypos.begin(); l != lazypos.end(); ++l)
for (Positions::const_iterator k = lastpos.begin(); k != lastpos.end(); ++k)
pos_add(followpos[k->pos()], p->lazy(l->lazy()).anchor(!nullable || k->pos() != p->pos()));
}
lastpos.clear();
pos_add(lastpos, *p);
if (nullable || firstpos.empty())
Expand Down Expand Up @@ -2179,9 +2189,10 @@ void Pattern::trim_lazy(Positions *pos, const Lazypos& lazypos) const
if (p->lazy() == l->lazy())
if (max < l->loc())
max = l->loc();
for (Positions::iterator p = pos->begin(); p != pos->end(); ++p)
if (p->loc() > max)
*p = p->lazy(0);
if (max > 0)
for (Positions::iterator p = pos->begin(); p != pos->end(); ++p)
if (p->loc() > max)
*p = p->lazy(0);
}
#ifdef DEBUG
DBGLOG("END trim_lazy({");
Expand Down
2 changes: 1 addition & 1 deletion src/reflex.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#endif

// DO NOT ALTER THIS LINE: the makemake.sh script updates the version
#define REFLEX_VERSION "4.1.0"
#define REFLEX_VERSION "4.1.1"

/// RE/flex scanner generator class, a variation of the classic "lex" tool to generate scanners.
/**
Expand Down

0 comments on commit 660d4af

Please sign in to comment.