@ 260915.5

201221.1 · 214138a44870c64c2926b059b7323f648bbe1e53

released 3.1.1

reading declarations

README.md

@@ -4601,7 +4601,7 @@ in markdown:   -    ugrep 3.1.0                    December 14, 2020                      UGREP(1)+    ugrep 3.1.1                    December 21, 2020                      UGREP(1)  🔝 [Back to table of contents](#toc) 

bin/win32/ugrep.exe

Binary file changed

bin/win64/ugrep.exe

Binary file changed

man/ugrep.1

@@ -1,4 +1,4 @@-.TH UGREP "1" "December 14, 2020" "ugrep 3.1.0" "User Commands"+.TH UGREP "1" "December 21, 2020" "ugrep 3.1.1" "User Commands" .SH NAME \fBugrep\fR, \fBug\fR -- file pattern searcher .SH SYNOPSIS

src/cnf.hpp

@@ -252,14 +252,21 @@ class CNF {   // anchor a pattern, when specified with -w or -x   static void anchor(std::string& pattern)   {+    // -G requires \( \) instead of ( )+    const char *xleft = flag_basic_regexp ? "^\\(" : "^(";+    const char *xright = flag_basic_regexp ? "\\)$" : ")$";+    const char *wleft = flag_basic_regexp ? "\\<\\(" : "\\<(";+    const char *wright = flag_basic_regexp ? "\\)\\>" : ")\\>";++    // patterns that start with ^ or end with $ are already anchored     if (!pattern.empty() && (pattern.front() == '^' || pattern.back() == '$'))     {       if (!flag_line_regexp && flag_word_regexp)       {         if (pattern.front() != '^')-          pattern.insert(0, "\\<(");+          pattern.insert(0, wleft);         else if (pattern.back() != '$')-          pattern.append(")\\>");+          pattern.append(wright);       }        // enable -Y to match empty@@ -268,14 +275,14 @@ class CNF {     else if (flag_line_regexp)     {       if (!pattern.empty())-        pattern.insert(0, "^(").append(")$");+        pattern.insert(0, xleft).append(xright);       else         pattern.assign("^$");     }     else if (flag_word_regexp)     {       if (!pattern.empty())-        pattern.insert(0, "\\<(").append(")\\>");+        pattern.insert(0, wleft).append(wright);     }   } 

src/output.cpp

@@ -814,7 +814,7 @@ void Output::format(const char *format, const char *pathname, const std::string&   } } -// output formatted match with options --format, --format-open, --format-close+// output formatted match with options -v --format void Output::format_invert(const char *format, const char *pathname, const std::string& partname, size_t matches, size_t lineno, size_t offset, const char *ptr, size_t size, bool next) {   size_t len = 0;

src/query.cpp

@@ -400,6 +400,7 @@ void Query::draw()   } } +// view one row of text by drawing it on screen void Query::view(int row) {   Screen::normal();

src/screen.cpp

@@ -46,6 +46,9 @@ // max collective length of ANSI CSI escape sequences collected when skipping lead text with skip>0 #define SCREEN_MAX_CODELEN 256 +// enable to interpret backspace (CTRL-H), not recommended because search results may not match what is shown+// #define WITH_BACKSPACE+ // emit ANSI SGR CSI sequence with one numeric parameter void Screen::CSI(int code, int num) {@@ -513,6 +516,13 @@ void Screen::put(int row, int col, const char *text, size_t size, int skip, int             ++text;             break; +#ifdef WITH_BACKSPACE+          case '\b':+            ++num;+            ++text;+            break;+#endif+           case '\t':             num -= 1 + (~(cols - num) & 7);             ++text;@@ -554,7 +564,7 @@ void Screen::put(int row, int col, const char *text, size_t size, int skip, int               num -= width;               if (num < 0)               {-                // cut a double wide character in half?+                // cut a double wide character that does not fit in half                 if (width == 2 && num == -1)                 {                   put(' ');@@ -587,6 +597,20 @@ void Screen::put(int row, int col, const char *text, size_t size, int skip, int       {         int tab; +#ifdef WITH_BACKSPACE+        case '\b':+          if (ptr > text)+          {+            const char *p = ptr;+            while (p > text && (*--p & 0xc0) == 0x80)+              continue;+            put(text, p - text);+            ++len;+          }+          text = ++ptr;+          break;+#endif+         case '\t':           put(text, ptr - text);           tab = 1 + (~(cols - len) & 7);@@ -693,6 +717,7 @@ void Screen::put(int row, int col, const char *text, size_t size, int skip, int             }             else if (wc <= 0x1f)             {+              // display CTRL character               put(text, ptr - text);               if (*ptr == '\0' && nulls > 0)               {@@ -710,6 +735,7 @@ void Screen::put(int row, int col, const char *text, size_t size, int skip, int             }             else if (wc == 0x7f)             {+              // display control character 0x7f               put(text, ptr - text);               invert();               put("^?", 2);

src/ugrep.cpp

@@ -67,7 +67,7 @@ After this, you may want to test ugrep and install it (optional): */  // ugrep version-#define UGREP_VERSION "3.1.0"+#define UGREP_VERSION "3.1.1"  // disable mmap because mmap is almost always slower than the file reading speed improvements since 3.0.0 #define WITH_NO_MMAP@@ -6033,11 +6033,17 @@ void ugrep()     // remove the ending '|' from the |-concatenated regexes in the regex string     regex.pop_back(); +    // -G requires \( \) instead of ( )+    const char *xleft = flag_basic_regexp ? "^\\(" : "^(";+    const char *xright = flag_basic_regexp ? "\\)$" : ")$";+    const char *wleft = flag_basic_regexp ? "\\<\\(" : "\\<(";+    const char *wright = flag_basic_regexp ? "\\)\\>" : ")\\>";+     // -x or -w: if no PATTERN is specified, then apply -x or -w to -f FILE patterns     if (line_regexp)-      regex.insert(0, "^(").append(")$"); // make the regex line-anchored+      regex.insert(0, xleft).append(xright); // make the regex line-anchored     else if (word_regexp)-      regex.insert(0, "\\<(").append(")\\>"); // make the regex word-anchored+      regex.insert(0, wleft).append(wright); // make the regex word-anchored   }    // --match: adjust color highlighting to show matches as selected lines without color

tests/archive.gz

Binary file changed

tests/archive.tar.zip

Binary file changed

tests/archive.tgz

Binary file changed

tests/archive.zip

Binary file changed

tests/gen.sh

@@ -102,8 +102,12 @@ for PAT in '' 'Hello' '\w+\s+\S+' '\S\n\S' 'nomatch' ; do   $UG -U -Fx "$PAT" Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt > "out/$FN-Fx.out"   if [ "$PAT" == '\w+\s+\S+' ]; then     $UG -U -G  '\w\+\s\+\S\+' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt > "out/$FN-G.out"+    $UG -U -Gw '\w\+\s\+\S\+' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt > "out/$FN-Gw.out"+    $UG -U -Gx '\w\+\s\+\S\+' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt > "out/$FN-Gx.out"   else     $UG -U -G  "$PAT" Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt > "out/$FN-G.out"+    $UG -U -Gw "$PAT" Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt > "out/$FN-Gw.out"+    $UG -U -Gx "$PAT" Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt > "out/$FN-Gx.out"   fi   $UG -U -IP  "$PAT" Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt > "out/$FN-IP.out"   $UG -U -IPw "$PAT" Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt > "out/$FN-IPw.out"

tests/out/Hello_-Gw.out

new file mode 100644@@ -0,0 +1,15 @@+Hello.bat:#!/bin/sh+Hello.bat:echo "Hello World!"+Binary file Hello.class matches+Hello.java:import java.lang.*;+Hello.java:+Hello.java:public class Hello // prints a Hello World! greeting+Hello.java:{ public static void main(String[] arg)+Hello.java:  { System.out.println("Hello World!");+Hello.java:  }+Hello.java:}+Hello.pdf:%PDF-1.3+Binary file Hello.pdf matches+Hello.sh:#!/bin/sh+Hello.sh:echo "Hello World!"+Hello.txt:Hello

tests/out/Hello_-Gx.out

new file mode 100644@@ -0,0 +1 @@+Hello.java:

tests/out/Hello_Hello-Gw.out

new file mode 100644@@ -0,0 +1,7 @@+Hello.bat:echo "Hello World!"+Binary file Hello.class matches+Hello.java:public class Hello // prints a Hello World! greeting+Hello.java:  { System.out.println("Hello World!");+Hello.pdf:(Hello)+Hello.sh:echo "Hello World!"+Hello.txt:Hello

tests/out/Hello_Hello-Gx.out

new file mode 100644@@ -0,0 +1 @@+Hello.txt:Hello

tests/out/Hello_SnS-Gw.out

new file mode 100644@@ -0,0 +1 @@+Binary file Hello.pdf matches

tests/out/Hello_SnS-Gx.out

new file mode 100644

tests/out/Hello_nomatch-Gw.out

new file mode 100644

tests/out/Hello_nomatch-Gx.out

new file mode 100644

tests/out/Hello_wsS-Gw.out

new file mode 100644@@ -0,0 +1,12 @@+Hello.bat:#!/bin/sh+Hello.bat|echo "Hello World!"+Binary file Hello.class matches+Hello.java:import java.lang.*;+Hello.java:public class Hello // prints a Hello World! greeting+Hello.java:{ public static void main(String[] arg)+Hello.java:  { System.out.println("Hello World!");+Hello.pdf:4 0 obj+Hello.pdf:<< /Length 5 0 R /Filter /FlateDecode >>+Binary file Hello.pdf matches+Hello.sh:#!/bin/sh+Hello.sh|echo "Hello World!"

tests/out/Hello_wsS-Gx.out

new file mode 100644@@ -0,0 +1,2 @@+Hello.java:import java.lang.*;+Binary file Hello.pdf matches

tests/verify.sh

@@ -217,10 +217,22 @@ for PAT in '' 'Hello' '\w+\s+\S+' '\S\n\S' 'nomatch' ; do     $UG -U -G  '\w\+\s\+\S\+' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt \       | $DIFF "out/$FN-G.out" \       || ERR "-G '$PAT' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt"+    $UG -U -Gw '\w\+\s\+\S\+' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt \+      | $DIFF "out/$FN-Gw.out" \+      || ERR "-Gw '$PAT' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt"+    $UG -U -Gx '\w\+\s\+\S\+' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt \+      | $DIFF "out/$FN-Gx.out" \+      || ERR "-Gx '$PAT' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt"   else     $UG -U -G  "$PAT" Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt \       | $DIFF "out/$FN-G.out" \       || ERR "-G '$PAT' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt"+    $UG -U -Gw "$PAT" Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt \+      | $DIFF "out/$FN-Gw.out" \+      || ERR "-Gw '$PAT' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt"+    $UG -U -Gx "$PAT" Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt \+      | $DIFF "out/$FN-Gx.out" \+      || ERR "-Gx '$PAT' Hello.bat Hello.class Hello.java Hello.pdf Hello.sh Hello.txt"   fi   if [ "$have_pcre2" == yes ] || [ "$have_boost_regex" == yes ]; then     printf .