Skip to content

Commit

Permalink
released 6.4.1
Browse files Browse the repository at this point in the history
fix #417
  • Loading branch information
genivia-inc committed Aug 9, 2024
1 parent 78af03d commit 62a9310
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 116 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5441,7 +5441,7 @@ in markdown:



ugrep 6.4.0 August 7, 2024 UGREP(1)
ugrep 6.4.1 August 8, 2024 UGREP(1)

🔝 [Back to table of contents](#toc)

Expand Down
Binary file modified bin/win32/ug.exe
Binary file not shown.
Binary file modified bin/win32/ugrep-indexer.exe
Binary file not shown.
Binary file modified bin/win32/ugrep.exe
Binary file not shown.
Binary file modified bin/win64/ug.exe
Binary file not shown.
Binary file modified bin/win64/ugrep-indexer.exe
Binary file not shown.
Binary file modified bin/win64/ugrep.exe
Binary file not shown.
20 changes: 10 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.72 for ugrep 6.4.0.
# Generated by GNU Autoconf 2.72 for ugrep 6.4.1.
#
# Report bugs to <https://github.com/Genivia/ugrep/issues>.
#
Expand Down Expand Up @@ -606,8 +606,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='ugrep'
PACKAGE_TARNAME='ugrep'
PACKAGE_VERSION='6.4.0'
PACKAGE_STRING='ugrep 6.4.0'
PACKAGE_VERSION='6.4.1'
PACKAGE_STRING='ugrep 6.4.1'
PACKAGE_BUGREPORT='https://github.com/Genivia/ugrep/issues'
PACKAGE_URL='https://ugrep.com'

Expand Down Expand Up @@ -1382,7 +1382,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
'configure' configures ugrep 6.4.0 to adapt to many kinds of systems.
'configure' configures ugrep 6.4.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1453,7 +1453,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of ugrep 6.4.0:";;
short | recursive ) echo "Configuration of ugrep 6.4.1:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1630,7 +1630,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
ugrep configure 6.4.0
ugrep configure 6.4.1
generated by GNU Autoconf 2.72
Copyright (C) 2023 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2184,7 +2184,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by ugrep $as_me 6.4.0, which was
It was created by ugrep $as_me 6.4.1, which was
generated by GNU Autoconf 2.72. Invocation command line was
$ $0$ac_configure_args_raw
Expand Down Expand Up @@ -3694,7 +3694,7 @@ fi

# Define the identity of the package.
PACKAGE='ugrep'
VERSION='6.4.0'
VERSION='6.4.1'


printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
Expand Down Expand Up @@ -11790,7 +11790,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by ugrep $as_me 6.4.0, which was
This file was extended by ugrep $as_me 6.4.1, which was
generated by GNU Autoconf 2.72. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -11863,7 +11863,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
ugrep config.status 6.4.0
ugrep config.status 6.4.1
configured by $0, generated by GNU Autoconf 2.72,
with options \\"\$ac_cs_config\\"
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([ugrep],[6.4.0],[https://github.com/Genivia/ugrep/issues],[ugrep],[https://ugrep.com])
AC_INIT([ugrep],[6.4.1],[https://github.com/Genivia/ugrep/issues],[ugrep],[https://ugrep.com])
AM_INIT_AUTOMAKE([foreign subdir-objects dist-xz no-dist-gzip])
AC_CONFIG_HEADERS([config.h])
AC_COPYRIGHT([Copyright (C) 2019-2024 Robert van Engelen, Genivia Inc.])
Expand Down
9 changes: 5 additions & 4 deletions include/reflex/pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,16 +676,17 @@ class Pattern {
Tree::Node *tnode; ///< the corresponding tree DFA node, when applicable
#endif
Edges edges; ///< state transitions
Lookaheads heads; ///< lookahead head set
Lookaheads tails; ///< lookahead tail set
Index first; ///< index of this state in the opcode table in the first assembly pass, also used in breadth-first search to cut DFA for predict match
Index index; ///< index of this state in the opcode table, also used in HFA construction
Accept accept; ///< nonzero if final state, the index of an accepted/captured subpattern
Lookaheads heads; ///< lookahead head set
Lookaheads tails; ///< lookahead tail set
bool redo; ///< true if this is a final state of a negative pattern
};
typedef std::list<State*> List;
static const uint16_t ALLOC = 1024; ///< allocate 1024 DFA states at a time, to improve performance
static const uint16_t MAX_DEPTH = 256; ///< analyze DFA up to states this deep to improve predict match
static const Index MAX_STATES = Const::GMAX; ///< maximum number of states
static const Index DEAD_PATH = 1; ///< state marker "path always and only reaches backedges" (a dead end)
static const Index KEEP_PATH = MAX_DEPTH; ///< state marker "required path" (from a newline edge)
static const Index LOOP_PATH = MAX_DEPTH + 1; ///< state marker "path reaches a backedge" (collect lookback chars)
Expand Down Expand Up @@ -1161,8 +1162,8 @@ class Pattern {
std::string rex_; ///< regular expression string
std::vector<Location> end_; ///< entries point to the subpattern's ending '|' or '\0'
std::vector<bool> acc_; ///< true if subpattern n is accepting (state is reachable)
size_t vno_; ///< number of finite state machine vertices |V|
size_t eno_; ///< number of finite state machine edges |E|
size_t vno_; ///< number of finite state machine vertices |V| (nodes)
size_t eno_; ///< number of finite state machine edges |E| (arrows)
size_t hno_; ///< number of indexing hash tables (HFA edges)
const Opcode *opc_; ///< points to the table with compiled finite state machine opcodes
FSM fsm_; ///< function pointer to FSM code
Expand Down
16 changes: 10 additions & 6 deletions lib/pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ void Pattern::parse(
{
DBGLOG("BEGIN parse()");
if (rex_.size() > Position::MAXLOC)
throw regex_error(regex_error::exceeds_length, rex_, Position::MAXLOC);
error(regex_error::exceeds_length, Position::MAXLOC);
Location len = static_cast<Location>(rex_.size());
Location loc = 0;
Accept choice = 1;
Expand Down Expand Up @@ -773,6 +773,8 @@ void Pattern::parse(
t = target_state;
++eno_;
++vno_;
if (vno_ > DFA::MAX_STATES)
error(regex_error::exceeds_limits, loc);
}
else
{
Expand Down Expand Up @@ -2118,6 +2120,8 @@ void Pattern::compile(
if (state->accept > 0 && state->accept <= end_.size())
acc_[state->accept - 1] = true;
++vno_;
if (vno_ > DFA::MAX_STATES)
error(regex_error::exceeds_limits, rex_.size());
}
delete[] table;
vms_ = timer_elapsed(vt) - ems_;
Expand Down Expand Up @@ -2791,7 +2795,7 @@ void Pattern::encode_dfa(DFA::State *start)
#endif
nop_ += static_cast<Index>(state->heads.size() + state->tails.size() + (state->accept > 0 || state->redo));
if (!valid_goto_index(nop_))
throw regex_error(regex_error::exceeds_limits, rex_, rex_.size());
error(regex_error::exceeds_limits, rex_.size());
}
if (nop_ > Const::LONG)
{
Expand Down Expand Up @@ -2853,7 +2857,7 @@ void Pattern::encode_dfa(DFA::State *start)
#endif
nop_ += static_cast<Index>(state->heads.size() + state->tails.size() + (state->accept > 0 || state->redo));
if (!valid_goto_index(nop_))
throw regex_error(regex_error::exceeds_limits, rex_, rex_.size());
error(regex_error::exceeds_limits, rex_.size());
}
}
Opcode *opcode = new Opcode[nop_];
Expand All @@ -2872,13 +2876,13 @@ void Pattern::encode_dfa(DFA::State *start)
for (Lookaheads::const_iterator i = state->tails.begin(); i != state->tails.end(); ++i)
{
if (!valid_lookahead_index(static_cast<Index>(*i)))
throw regex_error(regex_error::exceeds_limits, rex_, rex_.size());
error(regex_error::exceeds_limits, rex_.size());
opcode[pc++] = opcode_tail(static_cast<Index>(*i));
}
for (Lookaheads::const_iterator i = state->heads.begin(); i != state->heads.end(); ++i)
{
if (!valid_lookahead_index(static_cast<Index>(*i)))
throw regex_error(regex_error::exceeds_limits, rex_, rex_.size());
error(regex_error::exceeds_limits, rex_.size());
opcode[pc++] = opcode_head(static_cast<Index>(*i));
}
#if WITH_COMPACT_DFA == -1
Expand Down Expand Up @@ -3906,7 +3910,7 @@ void Pattern::analyze_dfa(DFA::State *start)
count = static_cast<uint16_t>(next_chars.count()); // never more than 256
}
// save the previous metrics
cut_states = states;
cut_states.swap(states);
cut_fin_states = fin_states;
cut_count = count + fin_count;
cut_chars += chars;
Expand Down
2 changes: 1 addition & 1 deletion man/ug.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH UGREP "1" "August 07, 2024" "ugrep 6.4.0" "User Commands"
.TH UGREP "1" "August 08, 2024" "ugrep 6.4.1" "User Commands"
.SH NAME
\fBugrep\fR, \fBug\fR -- file pattern searcher
.SH SYNOPSIS
Expand Down
2 changes: 1 addition & 1 deletion man/ugrep-indexer.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH UGREP-INDEXER "1" "August 07, 2024" "ugrep-indexer 6.4.0" "User Commands"
.TH UGREP-INDEXER "1" "August 08, 2024" "ugrep-indexer 6.4.1" "User Commands"
.SH NAME
\fBugrep-indexer\fR -- file indexer to accelerate recursive searching
.SH SYNOPSIS
Expand Down
2 changes: 1 addition & 1 deletion man/ugrep.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH UGREP "1" "August 07, 2024" "ugrep 6.4.0" "User Commands"
.TH UGREP "1" "August 08, 2024" "ugrep 6.4.1" "User Commands"
.SH NAME
\fBugrep\fR, \fBug\fR -- file pattern searcher
.SH SYNOPSIS
Expand Down
120 changes: 63 additions & 57 deletions src/cnf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,69 @@ class CNF {
// return the first ALT-terms of the CNF
std::string first() const;

// quote a pattern with \Q and \E
static void quote(std::string& pattern)
{
// when empty then nothing to quote
if (pattern.empty())
return;

size_t from = 0;
size_t to;

// replace each \E in the pattern with \E\\E\Q
while ((to = pattern.find("\\E", from)) != std::string::npos)
{
pattern.insert(to + 2, "\\\\E\\Q");
from = to + 7;
}

// enclose in \Q and \E
pattern.insert(0, "\\Q").append("\\E");
}

// anchor a pattern, when specified with -w or -x
static void anchor(std::string& pattern)
{
// patterns that start with ^ or end with $ are already anchored
if (pattern.empty())
{
// -x: empty regex matches empty lines with ^$
if (flag_line_regexp)
pattern.assign("^$");
}
else if (flag_line_regexp)
{
// -x: make the regex line-anchored
// -G requires \( \) instead of ( )
const char *xleft = flag_basic_regexp ? "^\\(" : "^(?:";
const char *xright = flag_basic_regexp ? "\\)$" : ")$";
pattern.insert(0, xleft).append(xright);
}
else if (flag_word_regexp)
{
// -w: make the regex word-anchored (or implicitly done with matcher option W instead of \< and \>)
if (flag_perl_regexp)
{
// -P requires (?<!\w) (?!\w) instead of \< and \>
#if defined(HAVE_PCRE2)
// PCRE2_EXTRA_MATCH_WORD does not work and \b(?:regex)\b is not correct anyway, so we roll out our own
const char *wleft = pattern.front() != '^' ? "(?<!\\w)(?:" : "(?:";
const char *wright = pattern.back() != '$' ? ")(?!\\w)" : ")";
#else // Boost.Regex
const char *wleft = pattern.front() != '^' ? "(?<![[:word:]])(?:" : "(?:";
const char *wright = pattern.back() != '$' ? ")(?![[:word:]])" : ")";
#endif
pattern.insert(0, wleft).append(wright);
}
}
else if (pattern.front() == '^' || pattern.back() == '$')
{
// enable -Y to match empty
flag_empty = true;
}
}

protected:

struct OpTree {
Expand Down Expand Up @@ -247,63 +310,6 @@ class CNF {

};

// quote a pattern with \Q and \E
static void quote(std::string& pattern)
{
// when empty then nothing to quote
if (pattern.empty())
return;

size_t from = 0;
size_t to;

// replace each \E in the pattern with \E\\E\Q
while ((to = pattern.find("\\E", from)) != std::string::npos)
{
pattern.insert(to + 2, "\\\\E\\Q");
from = to + 7;
}

// enclose in \Q and \E
pattern.insert(0, "\\Q").append("\\E");
}

// anchor a pattern, when specified with -w or -x
static void anchor(std::string& pattern)
{
// -G requires \( \) instead of ( ) and -P requires (?<!\w) (?!\w) instead of \< and \>
const char *xleft = flag_basic_regexp ? "^\\(" : "^(?:";
const char *xright = flag_basic_regexp ? "\\)$" : ")$";
#if defined(HAVE_PCRE2)
// PCRE2_EXTRA_MATCH_WORD does not work and \b(?:regex)\b is not correct anyway, so we roll out our own
const char *wleft = flag_perl_regexp ? "(?<!\\w)(?:" : NULL;
const char *wright = flag_perl_regexp ? ")(?!\\w)" : NULL;
#else // Boost.Regex
const char *wleft = flag_perl_regexp ? "(?<![[:word:]])(?:" : NULL;
const char *wright = flag_perl_regexp ? ")(?![[:word:]])" : NULL;
#endif

// patterns that start with ^ or end with $ are already anchored
if (!pattern.empty() && (pattern.front() == '^' || pattern.back() == '$'))
{
// enable -Y to match empty
flag_empty = true;
}
else if (flag_line_regexp)
{
// make the regex line-anchored
if (!pattern.empty())
pattern.insert(0, xleft).append(xright);
else
pattern.assign("^$");
}
else if (!pattern.empty() && flag_word_regexp && wleft != NULL && wright != NULL)
{
// make the regex word-anchored (or done with matcher option W instead of \< and \>)
pattern.insert(0, wleft).append(wright);
}
}

// CNF terms, an AND-list of ALT-term lists of string/NULL patterns
Terms terms;

Expand Down
2 changes: 1 addition & 1 deletion src/ugrep-indexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/

// DO NOT ALTER THIS LINE: updated by makemake.sh and we need it physically here for MSVC++ build from source
#define UGREP_VERSION "6.4.0"
#define UGREP_VERSION "6.4.1"

// use a task-parallel thread to decompress the stream into a pipe to search, also handles nested archives
#define WITH_DECOMPRESSION_THREAD
Expand Down
Loading

0 comments on commit 62a9310

Please sign in to comment.