diff --git a/README.md b/README.md index d904f26e..83673e65 100644 --- a/README.md +++ b/README.md @@ -3059,9 +3059,9 @@ field | output `%a` | the file basename without directory path `%p` | the directory path to the file `%z` | the pathname in a (compressed) archive, without `{` and `}` -`%H ` | if option `-H` is used: the quoted pathname and separator -`%[ARG]H` | if option `-H` is used: `ARG`, the quoted pathname and separator -`%h` | the quoted file pathname +`%H` | if option `-H` is used: the quoted pathname and separator, `\"` and `\\` replace `"` and `\` +`%[ARG]H` | if option `-H` is used: `ARG`, the quoted pathname and separator, `\"` and `\\` replace `"` and `\` +`%h` | the quoted file pathname, `\"` and `\\` replace `"` and `\` `%N` | if option `-n` is used: the line number and separator `%[ARG]N` | if option `-n` is used: `ARG`, the line number and separator `%n` | the line number of the match @@ -4455,9 +4455,10 @@ in markdown: %z the file pathname in a (compressed) archive. %[ARG]H - if option -H is used: ARG, the quoted pathname and separator. + if option -H is used: ARG, the quoted pathname and separator, \" + and \\ replace " and \. - %h the quoted file pathname. + %h the quoted file pathname, \" and \\ replace " and \. %[ARG]N if option -n is used: ARG, the line number and separator. @@ -4539,7 +4540,7 @@ in markdown: %u select unique lines only, unless option -u is used. - %1 the first regex group capture of the match, and so on up to + %1 the first regex group capture of the match, and so on up to group %9, same as %[1]#; requires option -P. %[NUM]# @@ -4549,24 +4550,24 @@ in markdown: the first group capture NUM that matched; requires option -P. %[NAME]# - the NAMEd group capture; requires option -P and capturing pat- + the NAMEd group capture; requires option -P and capturing pat- tern `(?PATTERN)', see also %G. %[NAME1|NAME2|...]# - the first NAMEd group capture that matched; requires option -P + the first NAMEd group capture that matched; requires option -P and capturing pattern `(?PATTERN)', see also %G. - %G list of group capture indices/names that matched; requires + %G list of group capture indices/names that matched; requires option -P. %[TEXT1|TEXT2|...]G - list of TEXT indexed by group capture indices that matched; + list of TEXT indexed by group capture indices that matched; requires option -P. %g the group capture index/name matched or 1; requires option -P. %[TEXT1|TEXT2|...]g - the first TEXT indexed by the first group capture index that + the first TEXT indexed by the first group capture index that matched; requires option -P. %% the percentage sign. @@ -4574,22 +4575,22 @@ in markdown: Formatted output is written without a terminating newline, unless %~ or `\n' is explicitly specified in the format string. - The [ARG] part of a field is optional and may be omitted. When - present, the argument must be placed in [] brackets, for example %[,]F + The [ARG] part of a field is optional and may be omitted. When + present, the argument must be placed in [] brackets, for example %[,]F to output a comma, the pathname, and a separator. %[SEP]$ and %u are switches and do not send anything to the output. - The separator used by the %F, %H, %N, %K, %B, %S and %G fields may be + The separator used by the %F, %H, %N, %K, %B, %S and %G fields may be changed by preceding the field by %[SEP]$. When [SEP] is not provided, - this reverts the separator to the default separator or the separator + this reverts the separator to the default separator or the separator specified with --separator. Formatted output is written for each matching pattern, which means that - a line may be output multiple times when patterns match more than once - on the same line. If field %u is specified anywhere in a format + a line may be output multiple times when patterns match more than once + on the same line. If field %u is specified anywhere in a format string, matching lines are output only once, unless option -u, - --ungroup is specified or when more than one line of input matched the + --ungroup is specified or when more than one line of input matched the search pattern. Additional formatting options: @@ -4606,8 +4607,8 @@ in markdown: --format-end=FORMAT the FORMAT when ending the search. - The context options -A, -B, -C, -y, and display options --break, - --heading, --color, -T, and --null have no effect on formatted output. + The context options -A, -B, -C, -y, and display options --break, + --heading, --color, -T, and --null have no effect on formatted output. EXAMPLES Display lines containing the word `patricia' in `myfile.txt': @@ -4668,7 +4669,7 @@ in markdown: $ ugrep -n -f c++/comments myfile.cpp - List the lines that need fixing in a C/C++ source file by looking for + List the lines that need fixing in a C/C++ source file by looking for the word `FIXME' while skipping any `FIXME' in quoted strings: $ ugrep -e FIXME -N '"(\\.|\\\r?\n|[^\\\n"])*"' myfile.cpp @@ -4698,7 +4699,7 @@ in markdown: $ ugrep -z -tc++ -n FIXME project.tgz - Recursively find lines with `FIXME' in C/C++ files, but do not search + Recursively find lines with `FIXME' in C/C++ files, but do not search any `bak' and `old' directories: $ ugrep -n FIXME -tc++ -g^bak/,^old/ @@ -4708,9 +4709,9 @@ in markdown: $ ugrep -z -w --filter='pdf:pdftotext % -' copyright - Match the binary pattern `A3hhhhA3hh' (hex) in a binary file without - Unicode pattern matching -U (which would otherwise match `\xaf' as a - Unicode character U+00A3 with UTF-8 byte sequence C2 A3) and display + Match the binary pattern `A3hhhhA3hh' (hex) in a binary file without + Unicode pattern matching -U (which would otherwise match `\xaf' as a + Unicode character U+00A3 with UTF-8 byte sequence C2 A3) and display the results in hex with -X using `less -R' as a pager: $ ugrep --pager -UXo '\xa3[\x00-\xff]{2}\xa3[\x00-\xff]' a.out @@ -4723,12 +4724,12 @@ in markdown: $ ugrep -l '' --ignore-files - List all files containing a RPM signature, located in the `rpm' direc- + List all files containing a RPM signature, located in the `rpm' direc- tory and recursively below up to two levels deeper (3 levels total): $ ugrep -3 -l -tRpm '' rpm/ - Monitor the system log for bug reports and ungroup multiple matches on + Monitor the system log for bug reports and ungroup multiple matches on a line: $ tail -f /var/log/system.log | ugrep -u -i -w bug @@ -4752,8 +4753,8 @@ in markdown: LICENSE - ugrep is released under the BSD-3 license. All parts of the software - have reasonable copyright terms permitting free redistribution. This + ugrep is released under the BSD-3 license. All parts of the software + have reasonable copyright terms permitting free redistribution. This includes the ability to reuse all or parts of the ugrep source tree. SEE ALSO @@ -4761,7 +4762,7 @@ in markdown: - ugrep 3.3.6 July 26, 2021 UGREP(1) + ugrep 3.3.7 August 06, 2021 UGREP(1) 🔝 [Back to table of contents](#toc) diff --git a/bin/win32/ugrep.exe b/bin/win32/ugrep.exe index 06e2fced..c9a91031 100755 Binary files a/bin/win32/ugrep.exe and b/bin/win32/ugrep.exe differ diff --git a/bin/win64/ugrep.exe b/bin/win64/ugrep.exe index c95db554..6f986f40 100755 Binary files a/bin/win64/ugrep.exe and b/bin/win64/ugrep.exe differ diff --git a/man.sh b/man.sh index 7572420a..646b7512 100755 --- a/man.sh +++ b/man.sh @@ -287,9 +287,10 @@ the directory path to the file. .IP \fB%z\fR the file pathname in a (compressed) archive. .IP \fB%[\fR\fIARG\fR\fB]H\fR -if option \fB-H\fR is used: \fIARG\fR, the quoted pathname and separator. +if option \fB-H\fR is used: \fIARG\fR, the quoted pathname and separator, \\" +and \\\\ replace " and \\. .IP \fB%h\fR -the quoted file pathname. +the quoted file pathname, \\" and \\\\ replace " and \\. .IP \fB%[\fR\fIARG\fR\fB]N\fR if option \fB-n\fR is used: \fIARG\fR, the line number and separator. .IP \fB%n\fR diff --git a/man/ugrep.1 b/man/ugrep.1 index e76c45cf..6ca4a4db 100644 --- a/man/ugrep.1 +++ b/man/ugrep.1 @@ -1,4 +1,4 @@ -.TH UGREP "1" "July 26, 2021" "ugrep 3.3.6" "User Commands" +.TH UGREP "1" "August 06, 2021" "ugrep 3.3.7" "User Commands" .SH NAME \fBugrep\fR, \fBug\fR -- file pattern searcher .SH SYNOPSIS @@ -937,9 +937,10 @@ the directory path to the file. .IP \fB%z\fR the file pathname in a (compressed) archive. .IP \fB%[\fR\fIARG\fR\fB]H\fR -if option \fB-H\fR is used: \fIARG\fR, the quoted pathname and separator. +if option \fB-H\fR is used: \fIARG\fR, the quoted pathname and separator, \\" +and \\\\ replace " and \\. .IP \fB%h\fR -the quoted file pathname. +the quoted file pathname, \\" and \\\\ replace " and \\. .IP \fB%[\fR\fIARG\fR\fB]N\fR if option \fB-n\fR is used: \fIARG\fR, the line number and separator. .IP \fB%n\fR diff --git a/src/ugrep.cpp b/src/ugrep.cpp index e2497a15..3fbde405 100644 --- a/src/ugrep.cpp +++ b/src/ugrep.cpp @@ -5694,8 +5694,8 @@ void terminal() dupenv_s(&env_grep_colors, "GREP_COLORS"); const char *grep_colors = env_grep_colors; - // if GREP_COLOR is defined, use it to set mt= default value (overridden by GREP_COLORS mt=, ms=, mc=) - if (env_grep_color != NULL) + // if GREP_COLOR is defined but not GREP_COLORS, use it to set mt= default value (overridden by GREP_COLORS mt=, ms=, mc=) + if (env_grep_colors == NULL && env_grep_color != NULL) set_color(std::string("mt=").append(env_grep_color).c_str(), "mt=", color_mt); else if (grep_colors == NULL) grep_colors = DEFAULT_GREP_COLORS; @@ -5744,7 +5744,7 @@ void terminal() copy_color(color_mc, color_mt); // if OSC hyperlinks are OK (note that "hl" does not match color letters so strstr can be used) - if (strstr(grep_colors, "hl") != NULL || (flag_colors != NULL && strstr(flag_colors, "hl") != NULL)) + if ((grep_colors != NULL && strstr(grep_colors, "hl") != NULL) || (flag_colors != NULL && strstr(flag_colors, "hl") != NULL)) { char *cwd = getcwd0(); if (cwd != NULL) @@ -5760,7 +5760,7 @@ void terminal() } // if CSI erase line is OK (note that ne does not match color letters so strstr can be used) - if (strstr(grep_colors, "ne") == NULL && (flag_colors == NULL || strstr(flag_colors, "ne") == NULL)) + if ((grep_colors == NULL || strstr(grep_colors, "ne") == NULL) && (flag_colors == NULL || strstr(flag_colors, "ne") == NULL)) color_del = "\033[K"; color_off = "\033[m"; diff --git a/src/ugrep.hpp b/src/ugrep.hpp index dabc4a8f..5aa5f238 100644 --- a/src/ugrep.hpp +++ b/src/ugrep.hpp @@ -38,7 +38,7 @@ #define UGREP_HPP // ugrep version -#define UGREP_VERSION "3.3.6" +#define UGREP_VERSION "3.3.7" // disable mmap because mmap is almost always slower than the file reading speed improvements since 3.0.0 #define WITH_NO_MMAP diff --git a/vs/ugrep/README.txt b/vs/ugrep/README.txt index 110f8fba..cee75092 100755 --- a/vs/ugrep/README.txt +++ b/vs/ugrep/README.txt @@ -121,25 +121,26 @@ Copy directory zstd-dev with its contents here. Follow the instructions to build the Release Win32 and x64 versions of the libzstd static ZSTD library compiled with Visual Studio C++ to libzstd_static.lib: - https://github.com/facebook/zstd/tree/dev/build + https://github.com/facebook/zstd/tree/dev/build After completing the steps above, this directory should contain the following directories and files (versions may differ): - api - bzip2-1.0.5 - lz4-dev - pcre2-10.37 - Release - ugrep - x64 - zlib-1.2.11 - zstd-dev - liblzma-x32.lib - liblzma-x64.lib - pcre2-x32.lib - pcre2-x64.lib - README.txt - ugrep.sln + api + bzip2-1.0.5 + lz4-dev + pcre2-10.37 + Release + ugrep + x64 + zlib-1.2.11 + zstd-dev + liblzma-x32.lib + liblzma-x64.lib + pcre2-x32.lib + pcre2-x64.lib + README.txt + ugrep.sln + manifest.xml Open vs\ugrep\ugrep.sln in Visual Studio. Upgrade the version if prompted. @@ -163,6 +164,9 @@ Configuration Properties Additional Library Directories: $(ProjectDir)\..;$(ProjectDir)\..\zstd-dev\build\VS2010\bin\Win32_Release Input: Additional Dependencies: pcre2-x32.lib;liblzma-x32.lib;libzstd_static.lib + Manifest Tool: + Input and Output: + Additional Manifest Files: $(ProjectDir)\..\manifest.xml Then build ugrep in Visual Studio. @@ -225,25 +229,26 @@ Copy directory zstd-dev with its contents here. Follow the instructions to build the Release Win32 and x64 versions of the libzstd static ZSTD library compiled with Visual Studio C++ to libzstd_static.lib: - https://github.com/facebook/zstd/tree/dev/build + https://github.com/facebook/zstd/tree/dev/build After completing the steps above, this directory should contain the following directories and files (versions may differ): - api - boost_1_72_0 - bzip2-1.0.5 - lz4-dev - Release - ugrep - x64 - zlib-1.2.11 - zstd-dev - libboost_regex-vc141-mt-s-x32-1_72.lib - libboost_regex-vc141-mt-s-x64-1_72.lib - liblzma-x32.lib - liblzma-x64.lib - README.txt - ugrep.sln + api + boost_1_72_0 + bzip2-1.0.5 + lz4-dev + Release + ugrep + x64 + zlib-1.2.11 + zstd-dev + libboost_regex-vc141-mt-s-x32-1_72.lib + libboost_regex-vc141-mt-s-x64-1_72.lib + liblzma-x32.lib + liblzma-x64.lib + README.txt + ugrep.sln + manifest.xml Open vs\ugrep\ugrep.sln in Visual Studio. Upgrade the version if prompted. @@ -267,5 +272,8 @@ Configuration Properties Additional Library Directories: $(ProjectDir)\..;$(ProjectDir)\..\zstd-dev\build\VS2010\bin\Win32_Release Input: Additional Dependencies: liblzma-x32.lib;libzstd_static.lib + Manifest Tool: + Input and Output: + Additional Manifest Files: $(ProjectDir)\..\manifest.xml Then build ugrep in Visual Studio. diff --git a/vs/ugrep/manifest.xml b/vs/ugrep/manifest.xml new file mode 100755 index 00000000..d63f6dac --- /dev/null +++ b/vs/ugrep/manifest.xml @@ -0,0 +1,7 @@ + + + + true + + + \ No newline at end of file