Skip to content

Commit

Permalink
released 4.3.6
Browse files Browse the repository at this point in the history
fix an issue with -Zbest
  • Loading branch information
genivia-inc committed Dec 7, 2023
1 parent 6c9b5e6 commit 34910c2
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -5364,7 +5364,7 @@ in markdown:



ugrep 4.3.5 December 6, 2023 UGREP(1)
ugrep 4.3.6 December 7, 2023 UGREP(1)

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

Expand Down
Binary file modified bin/win32/ugrep.exe
Binary file not shown.
Binary file modified bin/win64/ugrep.exe
Binary file not shown.
12 changes: 6 additions & 6 deletions man.sh
Expand Up @@ -51,7 +51,7 @@ The default pattern syntax is an extended form of the POSIX ERE syntax, same as
option \fB-E\fR (\fB--extended-regexp\fR). Try \fBug --help regex\fR for help
with pattern syntax and how to use logical connectives to specify Boolean
search queries with option \fB-%\fR (\fB--bool\fR) to match lines and \fB-%%\fR
(-fB--files --bool\fR) to match files. Options \fB-F\fR
(\fB--files --bool\fR) to match files. Options \fB-F\fR
(\fB--fixed-strings\fR), \fB-G\fR (\fB--basic-regexp\fR) and \fB-P\fR
(\fB--perl-regexp\fR) specify other pattern syntaxes.
.PP
Expand Down Expand Up @@ -545,7 +545,7 @@ $ ugrep -cowi patricia myfile.txt
.PP
List lines with `amount' and a decimal, ignoring case (space is AND):
.IP
$ ugrep -i --bool 'amount \d+(\.\d+)?' myfile.txt
$ ugrep -i -% 'amount \d+(\.\d+)?' myfile.txt
.PP
Alternative query:
.IP
Expand Down Expand Up @@ -605,15 +605,15 @@ $ ugrep -n -e FIXME --and urgent myfile.cpp
.PP
The same, but with a Boolean query pattern (a space is AND):
.IP
$ ugrep -n --bool 'FIXME urgent' myfile.cpp
$ ugrep -n -% 'FIXME urgent' myfile.cpp
.PP
Find lines with `FIXME' that do not also contain `later':
.IP
$ ugrep -n -e FIXME --andnot later myfile.cpp
.PP
The same, but with a Boolean query pattern (a space is AND, - is NOT):
.IP
$ ugrep -n --bool 'FIXME -later' myfile.cpp
$ ugrep -n -% 'FIXME -later' myfile.cpp
.PP
Output a list of line numbers of lines with `FIXME' but not `later':
.IP
Expand All @@ -622,7 +622,7 @@ $ ugrep -e FIXME --andnot later --format='%,%n' myfile.cpp
Recursively list all files with both `FIXME' and `LICENSE' anywhere in the
file, not necessarily on the same line:
.IP
$ ugrep -l --files --bool 'FIXME LICENSE'
$ ugrep -l -%% 'FIXME LICENSE'
.PP
Find lines with `FIXME' in the C/C++ files stored in a tarball:
.IP
Expand Down Expand Up @@ -665,7 +665,7 @@ $ tail -f /var/log/system.log | ugrep -u -i -w bug
.PP
Interactive fuzzy search with Boolean search queries:
.IP
$ ugrep -Q -l --bool -Z3 --sort=best
$ ugrep -Q -l -% -Z3 --sort=best
.PP
Display all words in a MacRoman-encoded file that has CR newlines:
.IP
Expand Down
14 changes: 7 additions & 7 deletions man/ugrep.1
@@ -1,4 +1,4 @@
.TH UGREP "1" "December 06, 2023" "ugrep 4.3.5" "User Commands"
.TH UGREP "1" "December 07, 2023" "ugrep 4.3.6" "User Commands"
.SH NAME
\fBugrep\fR, \fBug\fR -- file pattern searcher
.SH SYNOPSIS
Expand Down Expand Up @@ -36,7 +36,7 @@ The default pattern syntax is an extended form of the POSIX ERE syntax, same as
option \fB-E\fR (\fB--extended-regexp\fR). Try \fBug --help regex\fR for help
with pattern syntax and how to use logical connectives to specify Boolean
search queries with option \fB-%\fR (\fB--bool\fR) to match lines and \fB-%%\fR
(-fB--files --bool\fR) to match files. Options \fB-F\fR
(\fB--files --bool\fR) to match files. Options \fB-F\fR
(\fB--fixed-strings\fR), \fB-G\fR (\fB--basic-regexp\fR) and \fB-P\fR
(\fB--perl-regexp\fR) specify other pattern syntaxes.
.PP
Expand Down Expand Up @@ -1306,7 +1306,7 @@ $ ugrep -cowi patricia myfile.txt
.PP
List lines with `amount' and a decimal, ignoring case (space is AND):
.IP
$ ugrep -i --bool 'amount \d+(\.\d+)?' myfile.txt
$ ugrep -i -% 'amount \d+(\.\d+)?' myfile.txt
.PP
Alternative query:
.IP
Expand Down Expand Up @@ -1366,15 +1366,15 @@ $ ugrep -n -e FIXME --and urgent myfile.cpp
.PP
The same, but with a Boolean query pattern (a space is AND):
.IP
$ ugrep -n --bool 'FIXME urgent' myfile.cpp
$ ugrep -n -% 'FIXME urgent' myfile.cpp
.PP
Find lines with `FIXME' that do not also contain `later':
.IP
$ ugrep -n -e FIXME --andnot later myfile.cpp
.PP
The same, but with a Boolean query pattern (a space is AND, - is NOT):
.IP
$ ugrep -n --bool 'FIXME -later' myfile.cpp
$ ugrep -n -% 'FIXME -later' myfile.cpp
.PP
Output a list of line numbers of lines with `FIXME' but not `later':
.IP
Expand All @@ -1383,7 +1383,7 @@ $ ugrep -e FIXME --andnot later --format='%,%n' myfile.cpp
Recursively list all files with both `FIXME' and `LICENSE' anywhere in the
file, not necessarily on the same line:
.IP
$ ugrep -l --files --bool 'FIXME LICENSE'
$ ugrep -l -%% 'FIXME LICENSE'
.PP
Find lines with `FIXME' in the C/C++ files stored in a tarball:
.IP
Expand Down Expand Up @@ -1426,7 +1426,7 @@ $ tail -f /var/log/system.log | ugrep -u -i -w bug
.PP
Interactive fuzzy search with Boolean search queries:
.IP
$ ugrep -Q -l --bool -Z3 --sort=best
$ ugrep -Q -l -% -Z3 --sort=best
.PP
Display all words in a MacRoman-encoded file that has CR newlines:
.IP
Expand Down
40 changes: 21 additions & 19 deletions src/ugrep.cpp
Expand Up @@ -5126,7 +5126,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
else if (strcmp(arg, "after-context") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--after-context, --and, --andnot, --any-line or --ascii");
usage("invalid option --", arg, "--after-context=, --and, --andnot, --any-line or --ascii");
break;

case 'b':
Expand All @@ -5149,7 +5149,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
else if (strcmp(arg, "before-context") == 0 || strcmp(arg, "binary-files") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--basic-regexp, --before-context, --binary, --binary-files, --bool, --break or --byte-offset");
usage("invalid option --", arg, "--basic-regexp, --before-context=, --binary, --binary-files=, --bool, --break or --byte-offset");
break;

case 'c':
Expand Down Expand Up @@ -5182,7 +5182,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
strcmp(arg, "context") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--color, --colors, --column-number, --config, --confirm, --context, --count, --cpp or --csv");
usage("invalid option --", arg, "--color, --colors=, --column-number, --config, --confirm, --context=, --count, --cpp or --csv");
break;

case 'd':
Expand All @@ -5209,7 +5209,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
strcmp(arg, "directories") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--decompress, --delay, --depth, --dereference, --dereference-files, --dereference-recursive, --devices, --directories or --dotall");
usage("invalid option --", arg, "--decompress, --delay=, --depth=, --dereference, --dereference-files, --dereference-recursive, --devices=, --directories= or --dotall");
break;

case 'e':
Expand All @@ -5234,7 +5234,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
strcmp(arg, "exclude-fs") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--empty, --encoding, --exclude, --exclude-dir, --exclude-from, --exclude-fs or --extended-regexp");
usage("invalid option --", arg, "--empty, --encoding=, --exclude=, --exclude-dir=, --exclude-from=, --exclude-fs= or --extended-regexp");
break;

case 'f':
Expand Down Expand Up @@ -5287,7 +5287,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
strcmp(arg, "format-open") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--file, --file-extension, --file-magic, --file-type, --files, --files-with-matches, --files-without-match, --fixed-strings, --filter, --filter-magic-label, --format, --format-begin, --format-close, --format-end, --format-open, --fuzzy or --free-space");
usage("invalid option --", arg, "--file=, --file-extension=, --file-magic=, --file-type=, --files, --files-with-matches, --files-without-match, --fixed-strings, --filter=, --filter-magic-label=, --format=, --format-begin=, --format-close, --format-end=, --format-open=, --fuzzy or --free-space");
break;

case 'g':
Expand All @@ -5302,7 +5302,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
else if (strcmp(arg, "glob") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--glob, --glob-ignore-case or --group-separator");
usage("invalid option --", arg, "--glob=, --glob-ignore-case or --group-separator");
break;

case 'h':
Expand Down Expand Up @@ -5359,7 +5359,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
strcmp(arg, "include-fs") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--ignore-case, --ignore-files, --include, --include-dir, --include-from, --include-fs, --initial-tab or --invert-match");
usage("invalid option --", arg, "--ignore-case, --ignore-files, --include=, --include-dir=, --include-from=, --include-fs=, --initial-tab or --invert-match");
break;

case 'j':
Expand All @@ -5370,7 +5370,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
else if (strcmp(arg, "jobs") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--jobs or --json");
usage("invalid option --", arg, "--jobs= or --json");
break;

case 'l':
Expand All @@ -5387,7 +5387,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
else if (strcmp(arg, "label") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--label, --line-buffered, --line-number, --line-regexp or --lines");
usage("invalid option --", arg, "--label=, --line-buffered, --line-number, --line-regexp or --lines");
break;

case 'm':
Expand Down Expand Up @@ -5426,7 +5426,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
strcmp(arg, "min-line") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--match, --max-count, --max-depth, --max-files, --max-line, --min-count, --min-depth, --min-line, --mmap or --messages");
usage("invalid option --", arg, "--match, --max-count=, --max-depth=, --max-files=, --max-line=, --min-count=, --min-depth=, --min-line=, --mmap or --messages");
break;

case 'n':
Expand Down Expand Up @@ -5523,7 +5523,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
else if (strcmp(arg, "neg-regexp") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--neg-regexp, --not, --no-any-line, --no-ascii, --no-binary, --no-bool, --no-break, --no-byte-offset, --no-color, --no-confirm, --no-decompress, --no-dereference, --no-dereference-files, --no-dotall, --no-empty, --no-filename, --no-filter, --glob-no-ignore-case, --no-group-separator, --no-heading, --no-hidden, --no-hyperlink, --no-ignore-binary, --no-ignore-case, --no-ignore-files --no-initial-tab, --no-invert-match, --no-line-number, --no-only-line-number, --no-only-matching, --no-messages, --no-mmap, --no-pager, --no-pretty, --no-smart-case, --no-sort, --no-split, --no-stats, --no-tree, --no-ungroup, --no-view or --null");
usage("invalid option --", arg, "--neg-regexp=, --not, --no-any-line, --no-ascii, --no-binary, --no-bool, --no-break, --no-byte-offset, --no-color, --no-confirm, --no-decompress, --no-dereference, --no-dereference-files, --no-dotall, --no-empty, --no-filename, --no-filter, --no-glob-ignore-case, --no-group-separator, --no-heading, --no-hidden, --no-hyperlink, --no-ignore-binary, --no-ignore-case, --no-ignore-files --no-initial-tab, --no-invert-match, --no-line-number, --no-only-line-number, --no-only-matching, --no-messages, --no-mmap, --no-pager, --no-pretty, --no-smart-case, --no-sort, --no-split, --no-stats, --no-tree, --no-ungroup, --no-view or --null");
break;

case 'o':
Expand All @@ -5549,7 +5549,7 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
else if (strncmp(arg, "pretty=", 7) == 0)
flag_pretty = strarg(arg + 7);
else
usage("invalid option --", arg, "--pager, --passthru, --perl-regexp or --pretty");
usage("invalid option --", arg, "--pager, --passthru, --perl-regexp= or --pretty");
break;

case 'q':
Expand All @@ -5572,10 +5572,12 @@ void options(std::list<std::pair<CNF::PATTERN,const char*>>& pattern_args, int a
option_regexp(pattern_args, arg + 7);
else if (strncmp(arg, "replace=", 8) == 0)
flag_replace = strarg(arg + 8);
else if (strcmp(arg, "range") == 0 || strcmp(arg, "regexp") == 0 || strcmp(arg, "replace") == 0)
else if (strcmp(arg, "range") == 0 ||
strcmp(arg, "regexp") == 0 ||
strcmp(arg, "replace") == 0)
usage("missing argument for --", arg);
else
usage("invalid option --", arg, "--range, --recursive, --regexp or --replace");
usage("invalid option --", arg, "--range=, --recursive, --regexp= or --replace=");
break;

case 's':
Expand Down Expand Up @@ -9714,8 +9716,8 @@ void Grep::recurse(size_t level, const char *pathname)

#endif

// -Z and --sort=best: presearch the selected files to determine edit distance cost
if (flag_fuzzy > 0 && flag_sort_key == Sort::BEST)
// -Z and --sort=best without --match: presearch the selected files to determine edit distance cost
if (flag_fuzzy > 0 && flag_sort_key == Sort::BEST && !flag_match)
{
auto entry = file_entries.begin();
while (entry != file_entries.end())
Expand Down Expand Up @@ -9902,8 +9904,8 @@ uint16_t Grep::compute_cost(const char *pathname)
// search input to output the pattern matches
void Grep::search(const char *pathname, uint16_t cost)
{
// -Zbest (or --best-match): compute cost if not yet computed by --sort=best
if (flag_best_match && flag_fuzzy > 0 && !flag_quiet && !flag_files_with_matches && matchers == NULL && pathname != Static::LABEL_STANDARD_INPUT)
// -Zbest (or --best-match) without --match: compute cost if not yet computed by --sort=best
if (flag_best_match && flag_fuzzy > 0 && !flag_match && !flag_quiet && !flag_files_with_matches && matchers == NULL && pathname != Static::LABEL_STANDARD_INPUT)
{
// -Z: matcher is a FuzzyMatcher for sure
reflex::FuzzyMatcher *fuzzy_matcher = dynamic_cast<reflex::FuzzyMatcher*>(matcher);
Expand Down
2 changes: 1 addition & 1 deletion src/ugrep.hpp
Expand Up @@ -38,7 +38,7 @@
#define UGREP_HPP

// ugrep version
#define UGREP_VERSION "4.3.5"
#define UGREP_VERSION "4.3.6"

// disable mmap because mmap is almost always slower than the file reading speed improvements since 3.0.0
#define WITH_NO_MMAP
Expand Down
2 changes: 1 addition & 1 deletion src/zstream.hpp
Expand Up @@ -39,8 +39,8 @@

#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cinttypes>
#include <streambuf>
#include <zlib.h>

Expand Down

0 comments on commit 34910c2

Please sign in to comment.