Skip to content

Commit

Permalink
released 4.4.1
Browse files Browse the repository at this point in the history
fix installation of completions #335
  • Loading branch information
genivia-inc committed Dec 19, 2023
1 parent 7f82191 commit ecb8e97
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 26 deletions.
6 changes: 3 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -1024,19 +1024,19 @@ install-data-hook:
rm -f ug.1 && \
$(LN_S) ugrep.1 ug.1
@if [ "x$(bashcompletiondir)" != "x" ]; then \
cd $(bashcompletiondir) && \
cd $(DESTDIR)$(bashcompletiondir) && \
$(LN_S) -f ug ug+ && \
$(LN_S) -f ug ugrep && \
$(LN_S) -f ug ugrep+; \
fi
@if [ "x$(fishcompletiondir)" != "x" ]; then \
cd $(fishcompletiondir) && \
cd $(DESTDIR)$(fishcompletiondir) && \
sed -e 's/-c ug /-c ug+ /' ug.fish > ug+.fish && \
sed -e 's/-c ug /-c ugrep /' ug.fish > ugrep.fish && \
sed -e 's/-c ug /-c ugrep+ /' ug.fish > ugrep+.fish; \
fi
@if [ "x$(zshcompletiondir)" != "x" ]; then \
cd $(zshcompletiondir) && \
cd $(DESTDIR)$(zshcompletiondir) && \
sed -e 's/^#compdef ug/#compdef ug+/' _ug > _ug+ && \
sed -e 's/^#compdef ug/#compdef ugrep/' _ug > _ugrep && \
sed -e 's/^#compdef ug/#compdef ugrep+/' _ug > _ugrep+; \
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4636,9 +4636,10 @@ in markdown:
For capitalized file types, the search is expanded to include
files with matching file signature magic bytes, as if passed to
option -M. When a type is preceded by a `!' or a `^', excludes
files of the specified type. This option may be repeated. The
possible file types can be (where -tlist displays a detailed
list): `actionscript', `ada', `asm', `asp', `aspx', `autoconf',
files of the specified type. Specifying the initial part of a
type name suffices when the choice is unambiguous. This option
may be repeated. The possible file types can be (-tlist displays
a list): `actionscript', `ada', `asm', `asp', `aspx', `autoconf',
`automake', `awk', `Awk', `basic', `batch', `bison', `c', `c++',
`clojure', `cpp', `csharp', `css', `csv', `dart', `Dart',
`delphi', `elisp', `elixir', `erlang', `fortran', `gif', `Gif',
Expand Down Expand Up @@ -5347,7 +5348,7 @@ in markdown:



ugrep 4.4.0 December 18, 2023 UGREP(1)
ugrep 4.4.1 December 19, 2023 UGREP(1)

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

Expand Down
Binary file added bin/win32/ug.exe
Binary file not shown.
Binary file modified bin/win32/ugrep.exe
Binary file not shown.
Binary file added bin/win64/ug.exe
Binary file not shown.
Binary file modified bin/win64/ugrep.exe
Binary file not shown.
7 changes: 4 additions & 3 deletions man/ugrep.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH UGREP "1" "December 18, 2023" "ugrep 4.4.0" "User Commands"
.TH UGREP "1" "December 19, 2023" "ugrep 4.4.1" "User Commands"
.SH NAME
\fBugrep\fR, \fBug\fR -- file pattern searcher
.SH SYNOPSIS
Expand Down Expand Up @@ -776,8 +776,9 @@ extensions passed to option \fB\-O\fR and filenames passed to option \fB\-g\fR.
For capitalized file types, the search is expanded to include files
with matching file signature magic bytes, as if passed to option
\fB\-M\fR. When a type is preceded by a `!' or a `^', excludes files of
the specified type. This option may be repeated. The possible
file types can be (where \fB\-t\fRlist displays a detailed list):
the specified type. Specifying the initial part of a type name
suffices when the choice is unambiguous. This option may be
repeated. The possible file types can be (\fB\-t\fRlist displays a list):
`actionscript', `ada', `asm', `asp', `aspx', `autoconf', `automake',
`awk', `Awk', `basic', `batch', `bison', `c', `c++',
`clojure', `cpp', `csharp', `css', `csv', `dart', `Dart',
Expand Down
48 changes: 33 additions & 15 deletions src/ugrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6898,40 +6898,57 @@ void init(int argc, const char **argv)
std::string type(types.substr(from, size));

size_t i;
bool found = false;
bool valid = true;

// scan the type_table[] for a matching type
for (i = 0; type_table[i].type != NULL; ++i)
if (type == type_table[i].type)
break;
// scan the type_table[] for the specified type, allowing type to be a prefix when unambiguous
for (size_t j = 0; type_table[j].type != NULL; ++j)
{
if (type.compare(0, size, type_table[j].type, size) == 0)
{
// an ambiguous prefix is not a valid type
if (found)
valid = false;

found = true;
i = j;

// if full type match then we found a valid type match
if (strlen(type_table[j].type) == size)
{
valid = true;
break;
}
}
}

// if not found then find an unambiguous type with the specified filename suffix
if (type_table[i].type == NULL)
// if not found a valid type, then find an unambiguous type with the specified filename suffix
if (!found && valid)
{
size_t k = i;
for (size_t j = 0; type_table[j].type != NULL; ++j)
{
if (islower(type_table[j].type[0]))
{
const char *s = strstr(type_table[j].extensions, type.c_str());
if (s != NULL && (s == type_table[j].extensions || *--s == ','))
{
if (type_table[k].type != NULL)
if (found)
{
k = i;
valid = false;
break;
}
k = j;
found = true;
i = j;
}
}
}
i = k;
}

if (type_table[i].type == NULL)
if (!found || !valid)
{
std::string msg("invalid argument -t TYPES, valid arguments are");

for (int i = 0; type_table[i].type != NULL; ++i)
for (i = 0; type_table[i].type != NULL; ++i)
msg.append(" '").append(type_table[i].type).append("',");
msg.append(" and 'list' to show a detailed list of file types");

Expand Down Expand Up @@ -14080,8 +14097,9 @@ void help(std::ostream& out)
For capitalized file types, the search is expanded to include files\n\
with matching file signature magic bytes, as if passed to option\n\
-M. When a type is preceded by a `!' or a `^', excludes files of\n\
the specified type. This option may be repeated. The possible\n\
file types can be (where -tlist displays a detailed list):";
the specified type. Specifying the initial part of a type name\n\
suffices when the choice is unambiguous. This option may be\n\
repeated. The possible file types can be (-tlist displays a list):";
for (int i = 0; type_table[i].type != NULL; ++i)
out << (i == 0 ? "" : ",") << (i % 7 ? " " : "\n ") << "`" << type_table[i].type << "'";
out << ".\n\
Expand Down
2 changes: 1 addition & 1 deletion src/ugrep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define UGREP_HPP

// ugrep version
#define UGREP_VERSION "4.4.0"
#define UGREP_VERSION "4.4.1"

// disable mmap because mmap is almost always slower than the file reading speed improvements since 3.0.0
#define WITH_NO_MMAP
Expand Down

0 comments on commit ecb8e97

Please sign in to comment.