200103.1 · 09290681250220b28ea145516048898008ee81a4
released 1.6.12 - option -I behavior compatible with GNU/BSD grep option -I behavior
reading declarations
@@ -407,20 +407,34 @@ Notes on using `ugrep.exe` from the Windows command line: ### Using ugrep within Vim -Add to `.vimrc`:+First, let's define the `:grep` command in Vim to search files recursively. To+do so, add the following lines to your `.vimrc` located in the root directory: if executable('ugrep')- set grepprg=ugrep\ -Rnk\ -u\ --tabs=1+ set grepprg=ugrep\ -RInk\ -j\ -u\ --tabs=1\ --no-hidden\ --ignore-files set grepformat=%f:%l:%c:%m,%f+%l+%c+%m,%-G%f\\\|%l\\\|%c\\\|%m endif -Within Vim you can now use **ugrep** with the Vim `:grep` command to search one-or more files on a specified `PATH` (optional, search working directory-recursively by default) for `PATTERN` matches:+This specifies case insensitive searches with the Vim `:grep` command. For+case sensitive searches, remove `\ -j` from `grepprg`. Multiple matches on the+same line are listed in the quickfix window separately. If this is not+desired, remove `\ -u` from `grepprg`. With this change, only the first match+on a line is shown. Option `--no-hidden` skips hidden files (dotfiles) and+option `--ignore-files` skips files specified in `.gitignore` files, when+present. To limit the depth of recursive searches to the current directory+only, append `\ --max-depth=1` to `grepprg`.++You can now invoke the Vim `:grep` command in Vim to search files on a+specified `PATH` for `PATTERN` matches: :grep PATTERN [PATH] -This query shows the results in a+If you omit `PATH`, then the working directory is searched. Use `%` as `PATH`+to search only the currently opened file in Vim:++ :grep PATTERN %++The `:grep` command shows the results in a [quickfix](http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:grep) window that allows you to quickly jump to the matches found. @@ -436,26 +450,45 @@ recursively search C++ source code marked `FIXME` in the working directory: :grep -tc++ FIXME -Use `%` as `PATH` to search the current file in Vim:-- :grep FIXME %- To close the quickfix window: :cclose -Note that multiple matches on the same line are listed in the quickfix window-separately. If this is not desired then remove `\ -u` from `grepprg` in-`.vimrc`. With this change, only the first match on a line is shown.--You can use **ugrep** options with the Vim `:grep` command, for example to+You can use **ugrep** options with the `:grep` command, for example to select single- and multi-line comments in the current file: :grep -f c++/comments % Only the first line of a multi-line comment is shown in quickfix, to save-space. To show all lines of a multi-line match, remove `%-G` from `grepformat`-in `.vimrc`.+space. To show all lines of a multi-line match, remove `%-G` from+`grepformat`.++A popular Vim tool is [ctrlp.vim](http://kien.github.io/ctrlp.vim), which is+installed with:++ $ cd ~/.vim+ $ git clone https://github.com/kien/ctrlp.vim.git bundle/ctrlp.vim++CtrlP uses **ugrep** by adding the following lines to your `.vimrc`:++ if executable('ugrep')+ set runtimepath^=~/.vim/bundle/ctrlp.vim+ let g:ctrlp_match_window='bottom,order:ttb'+ let g:ctrlp_user_command='ugrep %s -RIl --no-hidden --ignore-files --max-depth=3'+ endif++Option `--no-hidden` skips hidden files (dotfiles), option `--ignore-files`+skips files specified in `.gitignore` files, when present, and option+`--max-depth=3` restricts searching directories to three levels deep.+NOte that binary files are ignored with option `-I`.++Start Vim then enter the command:++ :helptags ~/.vim/bundle/ctrlp.vim/doc++To view the CtrlP documentation in Vim, enter the command:++ :help ctrlp.txt <a name="comparison"/> @@ -2887,7 +2920,7 @@ in markdown: - ugrep 1.6.11 December 31, 2019 UGREP(1)+ ugrep 1.6.12 January 03, 2020 UGREP(1) <a name="patterns"/>
bin/linux/ugrep
bin/macosx/ugrep
@@ -1,4 +1,4 @@-.TH UGREP "1" "December 31, 2019" "ugrep 1.6.11" "User Commands"+.TH UGREP "1" "January 03, 2020" "ugrep 1.6.12" "User Commands" .SH NAME \fBugrep\fR -- universal file pattern searcher .SH SYNOPSIS
@@ -17,9 +17,8 @@ skipping all matches of identifiers in comments and strings: ugrep -r -n -f java/names -f java/zap_comments -f java/zap_strings Pattern files contain one or more regex patters, one pattern per line. Empty-lines and lines starting with a `#` are ignored in pattern files. A starting-line with `###-o` auto-enables option `-o` for all patterns matched. Use `\#`-to define a pattern that starts with a `#` on a line.+lines and lines starting with `###` are ignored in pattern files. A starting+line with `###-o` auto-enables option `-o` for all patterns matched. Patterns that requiring Unicode matching should be placed in Unicode mode with `(?u:X)`, just in case to prevent ugrep option `-U` from disabling them.
@@ -1,2 +1,2 @@-\#.*+#.* ^=[[:word:]](.|\n[^=]|\n=c[^u]|\n=cu[^t])*\n=cut
@@ -1 +1 @@-\#.*+#.*
@@ -1,2 +1,2 @@-\#.*+#.* ^=begin(.|\n[^=]|\n=e[^n]|\n=en[^d])*\n=end
@@ -30,15 +30,9 @@ @file ugrep.cpp @brief Universal grep - a pattern search utility written in C++11 @author Robert van Engelen - engelen@genivia.com-@copyright (c) 2019-2019, Robert van Engelen, Genivia Inc. All rights reserved.+@copyright (c) 2019-2020, Robert van Engelen, Genivia Inc. All rights reserved. @copyright (c) BSD-3 License - see LICENSE.txt -Universal grep: high-performance file search utility. Supersedes GNU and BSD-grep with full Unicode support. Offers easy options and predefined regex-patterns to quickly search source code, text, and binary files in large-directory trees. Compatible with GNU/BSD grep, offering a faster drop-in-replacement.- For download and installation instructions: https://github.com/Genivia/ugrep@@ -51,6 +45,8 @@ Optional libraries to support options -P and -z: Boost.Regex zlib+ libbz2+ liblzma Build ugrep as follows: @@ -74,7 +70,7 @@ Prebuilt executables are located in ugrep/bin. */ // ugrep version-#define UGREP_VERSION "1.6.11"+#define UGREP_VERSION "1.6.12" #include <reflex/input.h> #include <reflex/matcher.h>@@ -4150,10 +4146,10 @@ int main(int argc, char **argv) // add line to the regex if not empty if (!line.empty()) {- // enable -o when the first line is ###-o+ // enable -o when the first line is ###-o, skip ###-comments if (lineno == 1 && line == "###-o") flag_only_matching = true;- else+ else if (line.substr(0, 3) != "###") regex.append(Q).append(line).append(E); } }@@ -5437,10 +5433,19 @@ void Grep::search(const char *pathname) read_file(); + // -I: do not match binary+ if (flag_binary_without_matches)+ {+ const char *eol = matcher->eol(); // warning: call eol() before bol()+ const char *bol = matcher->bol();+ if (is_binary(bol, eol - bol))+ goto exit_search;+ }+ matches = matcher->find() != 0; // -K: max line exceeded?- if (flag_max_line > 0 && matcher->lineno() > flag_max_line)+ if (matches > 0 && flag_max_line > 0 && matcher->lineno() > flag_max_line) matches = 0; if (flag_invert_match)@@ -5492,7 +5497,16 @@ void Grep::search(const char *pathname) read_file(); - while (matcher->find() != 0)+ // -I: do not match binary+ if (flag_binary_without_matches)+ {+ const char *eol = matcher->eol(); // warning: call eol() before bol()+ const char *bol = matcher->bol();+ if (is_binary(bol, eol - bol))+ goto exit_search;+ }++ while (matcher->find()) { // -K: max line exceeded? if (flag_max_line > 0 && matcher->lineno() > flag_max_line)@@ -5513,6 +5527,15 @@ void Grep::search(const char *pathname) read_file(); + // -I: do not match binary+ if (flag_binary_without_matches)+ {+ const char *eol = matcher->eol(); // warning: call eol() before bol()+ const char *bol = matcher->bol();+ if (is_binary(bol, eol - bol))+ goto exit_search;+ }+ while (matcher->find()) { size_t current_lineno = matcher->lineno();@@ -5634,6 +5657,15 @@ void Grep::search(const char *pathname) read_file(); + // -I: do not match binary+ if (flag_binary_without_matches)+ {+ const char *eol = matcher->eol(); // warning: call eol() before bol()+ const char *bol = matcher->bol();+ if (is_binary(bol, eol - bol))+ goto exit_search;+ }+ while (matcher->find()) { size_t current_lineno = matcher->lineno();@@ -5675,6 +5707,15 @@ void Grep::search(const char *pathname) read_file(); + // -I: do not match binary+ if (flag_binary_without_matches)+ {+ const char *eol = matcher->eol(); // warning: call eol() before bol()+ const char *bol = matcher->bol();+ if (is_binary(bol, eol - bol))+ goto exit_search;+ }+ while (matcher->find()) { const char *begin = matcher->begin();@@ -5815,6 +5856,15 @@ void Grep::search(const char *pathname) read_file(); + // -I: do not match binary+ if (flag_binary_without_matches)+ {+ const char *eol = matcher->eol(); // warning: call eol() before bol()+ const char *bol = matcher->bol();+ if (is_binary(bol, eol - bol))+ goto exit_search;+ }+ while (matcher->find()) { size_t current_lineno = matcher->lineno();