Hello community, here is the log from the commit of package ugrep for openSUSE:Factory checked in at 2020-09-23 18:42:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ugrep (Old) and /work/SRC/openSUSE:Factory/.ugrep.new.4249 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ugrep" Wed Sep 23 18:42:43 2020 rev:9 rq:836117 version:2.5.6 Changes: -------- --- /work/SRC/openSUSE:Factory/ugrep/ugrep.changes 2020-09-04 11:13:02.755058895 +0200 +++ /work/SRC/openSUSE:Factory/.ugrep.new.4249/ugrep.changes 2020-09-23 18:43:47.169508180 +0200 @@ -1,0 +2,11 @@ +Tue Sep 22 14:33:50 UTC 2020 - Andreas Stieger <andreas.stie...@gmx.de> + +- ugrep 2.5.6: + * Interactive query UI usability improvements + * new query UI commands: + Alt-[ (decrease fuzziness by one), + Alt-] (increase fuzziness by one), + Alt-{ (decrease context size by one line), + Alt-} (increase context size by one line) + +------------------------------------------------------------------- Old: ---- ugrep-2.5.5.tar.gz New: ---- ugrep-2.5.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ugrep.spec ++++++ --- /var/tmp/diff_new_pack.sOrKmn/_old 2020-09-23 18:43:48.165509097 +0200 +++ /var/tmp/diff_new_pack.sOrKmn/_new 2020-09-23 18:43:48.165509097 +0200 @@ -17,7 +17,7 @@ Name: ugrep -Version: 2.5.5 +Version: 2.5.6 Release: 0 Summary: Universal grep: a feature-rich grep implementation with focus on speed License: BSD-3-Clause ++++++ ugrep-2.5.5.tar.gz -> ugrep-2.5.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/README.md new/ugrep-2.5.6/README.md --- old/ugrep-2.5.5/README.md 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/README.md 2020-09-21 21:47:09.000000000 +0200 @@ -4371,7 +4371,7 @@ - ugrep 2.5.5 September 02, 2020 UGREP(1) + ugrep 2.5.6 September 21, 2020 UGREP(1) 🔝 [Back to table of contents](#toc) Binary files old/ugrep-2.5.5/bin/win32/ugrep.exe and new/ugrep-2.5.6/bin/win32/ugrep.exe differ Binary files old/ugrep-2.5.5/bin/win64/ugrep.exe and new/ugrep-2.5.6/bin/win64/ugrep.exe differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/configure new/ugrep-2.5.6/configure --- old/ugrep-2.5.5/configure 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/configure 2020-09-21 21:47:09.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for ugrep 2.4. +# Generated by GNU Autoconf 2.69 for ugrep 2.5. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -579,8 +579,8 @@ # Identity of this package. PACKAGE_NAME='ugrep' PACKAGE_TARNAME='ugrep' -PACKAGE_VERSION='2.4' -PACKAGE_STRING='ugrep 2.4' +PACKAGE_VERSION='2.5' +PACKAGE_STRING='ugrep 2.5' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1311,7 +1311,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ugrep 2.4 to adapt to many kinds of systems. +\`configure' configures ugrep 2.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1381,7 +1381,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ugrep 2.4:";; + short | recursive ) echo "Configuration of ugrep 2.5:";; esac cat <<\_ACEOF @@ -1518,7 +1518,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ugrep configure 2.4 +ugrep configure 2.5 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2235,7 +2235,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ugrep $as_me 2.4, which was +It was created by ugrep $as_me 2.5, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3101,7 +3101,7 @@ # Define the identity of the package. PACKAGE='ugrep' - VERSION='2.4' + VERSION='2.5' cat >>confdefs.h <<_ACEOF @@ -7902,8 +7902,6 @@ $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports ARM NEON/AArch64 intrinsics" >&5 $as_echo_n "checking whether ${CXX} supports ARM NEON/AArch64 intrinsics... " >&6; } - save_CXXFLAGS=$CXXFLAGS - CXXFLAGS="-march=native" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <arm_neon.h> @@ -7915,13 +7913,17 @@ return 0; } _ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : mneon_ok=yes else mneon_ok=no fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "x$mneon_ok" = "xyes"; then + SIMD_FLAGS="-DHAVE_NEON" + else + save_CXXFLAGS=$CXXFLAGS + CXXFLAGS="-march=native" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <arm_neon.h> @@ -7933,16 +7935,13 @@ return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_cxx_try_cpp "$LINENO"; then : mneon_ok=yes else mneon_ok=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext if test "x$mneon_ok" = "xyes"; then - SIMD_FLAGS="-march=native -DHAVE_NEON" - else - CXXFLAGS="-march=native -mfpu=neon" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <arm_neon.h> @@ -7961,11 +7960,33 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "x$mneon_ok" = "xyes"; then - SIMD_FLAGS="-march=native -mfpu=neon -DHAVE_NEON" + SIMD_FLAGS="-march=native -DHAVE_NEON" + else + CXXFLAGS="-march=native -mfpu=neon" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <arm_neon.h> +int +main () +{ +uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + mneon_ok=yes +else + mneon_ok=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test "x$mneon_ok" = "xyes"; then + SIMD_FLAGS="-march=native -mfpu=neon -DHAVE_NEON" + fi fi fi + CXXFLAGS=$save_CXXFLAGS fi - CXXFLAGS=$save_CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: result: $mneon_ok" >&5 $as_echo "$mneon_ok" >&6; } else @@ -8522,7 +8543,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ugrep $as_me 2.4, which was +This file was extended by ugrep $as_me 2.5, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -8588,7 +8609,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ugrep config.status 2.4 +ugrep config.status 2.5 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/configure.ac new/ugrep-2.5.6/configure.ac --- old/ugrep-2.5.5/configure.ac 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/configure.ac 2020-09-21 21:47:09.000000000 +0200 @@ -1,4 +1,4 @@ -AC_INIT(ugrep,2.4) +AC_INIT(ugrep,2.5) AM_INIT_AUTOMAKE([foreign]) AM_CONFIG_HEADER(config.h) AC_COPYRIGHT([Copyright (C) 2019-2020 Robert van Engelen, Genivia Inc.]) @@ -218,28 +218,35 @@ if test "x$with_no_neon" = "xno"; then AC_MSG_RESULT(no) AC_MSG_CHECKING([whether ${CXX} supports ARM NEON/AArch64 intrinsics]) - save_CXXFLAGS=$CXXFLAGS - CXXFLAGS="-march=native" - AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])], - [mneon_ok=yes], - [mneon_ok=no]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])], + [mneon_ok=yes], + [mneon_ok=no]) if test "x$mneon_ok" = "xyes"; then - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])], + SIMD_FLAGS="-DHAVE_NEON" + else + save_CXXFLAGS=$CXXFLAGS + CXXFLAGS="-march=native" + AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])], [mneon_ok=yes], [mneon_ok=no]) if test "x$mneon_ok" = "xyes"; then - SIMD_FLAGS="-march=native -DHAVE_NEON" - else - CXXFLAGS="-march=native -mfpu=neon" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])], [mneon_ok=yes], [mneon_ok=no]) if test "x$mneon_ok" = "xyes"; then - SIMD_FLAGS="-march=native -mfpu=neon -DHAVE_NEON" + SIMD_FLAGS="-march=native -DHAVE_NEON" + else + CXXFLAGS="-march=native -mfpu=neon" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])], + [mneon_ok=yes], + [mneon_ok=no]) + if test "x$mneon_ok" = "xyes"; then + SIMD_FLAGS="-march=native -mfpu=neon -DHAVE_NEON" + fi fi fi + CXXFLAGS=$save_CXXFLAGS fi - CXXFLAGS=$save_CXXFLAGS AC_MSG_RESULT($mneon_ok) else AC_MSG_RESULT(yes) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/include/reflex/abslexer.h new/ugrep-2.5.6/include/reflex/abslexer.h --- old/ugrep-2.5.5/include/reflex/abslexer.h 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/include/reflex/abslexer.h 2020-09-21 21:47:09.000000000 +0200 @@ -323,6 +323,11 @@ { return matcher().lineno(); } + /// Set or change the starting line number of the last match. + inline void lineno(size_t n) + { + matcher().lineno(n); + } /// Returns the number of lines that the match spans. inline size_t lines() const /// @returns number of lines diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/include/reflex/absmatcher.h new/ugrep-2.5.6/include/reflex/absmatcher.h --- old/ugrep-2.5.5/include/reflex/absmatcher.h 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/include/reflex/absmatcher.h 2020-09-21 21:47:09.000000000 +0200 @@ -577,6 +577,13 @@ { return utf8(txt_); } + /// Set or change the starting line number of the last match. + void lineno(size_t n) ///< new line number + { + if (lpb_ < txt_) + (void)lineno(); // update lno_ and bol_ (or cno_) before overriding lno_ + lno_ = n; + } /// Updates and returns the starting line number of the match in the input character sequence. size_t lineno() /// @returns line number diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/include/reflex/error.h new/ugrep-2.5.6/include/reflex/error.h --- old/ugrep-2.5.5/include/reflex/error.h 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/include/reflex/error.h 2020-09-21 21:47:09.000000000 +0200 @@ -140,6 +140,8 @@ const char *message, const char *pattern, size_t pos); + static size_t displen(const char *s, size_t k); + static const char *disppos(const char *s, size_t k); regex_error_type code_; size_t pos_; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/include/reflex/flexlexer.h new/ugrep-2.5.6/include/reflex/flexlexer.h --- old/ugrep-2.5.5/include/reflex/flexlexer.h 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/include/reflex/flexlexer.h 2020-09-21 21:47:09.000000000 +0200 @@ -364,6 +364,9 @@ /// Flex-compatible macro: the lineno accessor of a reentrant scanner. #define yyget_lineno(s) static_cast<int>(static_cast<FlexLexer*>(s)->lineno()) +/// Flex-compatible macro: set the lineno accessor of a reentrant scanner. +#define yyset_lineno(n,s) static_cast<FlexLexer*>(s)->lineno(n) + /// Flex-compatible macro: the reflex::Input in accessor of a reentrant scanner. #define yyget_in(s) static_cast<FlexLexer*>(s)->in() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/lib/error.cpp new/ugrep-2.5.6/lib/error.cpp --- old/ugrep-2.5.5/lib/error.cpp 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/lib/error.cpp 2020-09-21 21:47:09.000000000 +0200 @@ -68,18 +68,17 @@ std::string regex_error::regex_error_message(const char *message, const char *pattern, size_t pos) { - size_t l = std::strlen(message); - size_t n = pos / 80; - const char *p = pattern + 80 * n; - while (p > pattern && (p[0] & 0xc0) == 0x80) + size_t l = strlen(message); + size_t n = pos / 40; + size_t k = pos % 40 + (n == 0 ? 0 : 20); + const char *p = n == 0 ? pattern : pattern + 40 * n - 20; + while (p > pattern && (*p & 0xc0) == 0x80) + { --p; - size_t m = std::strlen(p); - if (m >= 80) - m = 79; - size_t r = pos % 80; - for (size_t i = r; i > 0; --i) - if ((p[i] & 0xc0) == 0x80) - --r; + ++k; + } + size_t m = disppos(p, 79) - p; + size_t r = displen(p, k); std::string what("error in regex at position "); what.append(ztoa(pos)).append("\n").append(p, m).append("\n"); if (r >= l + 4) @@ -89,4 +88,77 @@ return what; } +size_t regex_error::displen(const char *s, size_t k) +{ + size_t n = 0; + while (k > 0 && *s != '\0') + { + unsigned char c = *s++; + if (c >= 0x80) + { + if (c >= 0xf0 && + (c > 0xf0 || + (static_cast<unsigned char>(s[0]) >= 0x9f && + (static_cast<unsigned char>(s[0]) > 0x9f || + (static_cast<unsigned char>(s[1]) >= 0x86 && + (static_cast<unsigned char>(s[1]) > 0x86 || + static_cast<unsigned char>(s[2]) >= 0x8e)))))) + { + // U+1F18E (UTF-8 F0 9F 86 8E) and higher is usually double width + ++n; + if (k < 4) + break; + s += 3; + k -= 3; + } + else + { + while (k > 1 && (*s & 0xc0) == 0x80) + { + ++s; + --k; + } + } + } + ++n; + --k; + } + return n; +} + +const char *regex_error::disppos(const char *s, size_t k) +{ + while (k > 0 && *s != '\0') + { + unsigned char c = *s++; + if (c >= 0x80) + { + if (c >= 0xf0 && + (c > 0xf0 || + (static_cast<unsigned char>(s[0]) >= 0x9f && + (static_cast<unsigned char>(s[0]) > 0x9f || + (static_cast<unsigned char>(s[1]) >= 0x86 && + (static_cast<unsigned char>(s[1]) > 0x86 || + static_cast<unsigned char>(s[2]) >= 0x8e)))))) + { + // U+1F18E (UTF-8 F0 9F 86 8E) and higher is usually double width + if (k < 4) + break; + s += 3; + k -= 3; + } + else + { + while (k > 1 && (*s & 0xc0) == 0x80) + { + ++s; + --k; + } + } + } + --k; + } + return s; +} + } // namespace reflex diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/man/ugrep.1 new/ugrep-2.5.6/man/ugrep.1 --- old/ugrep-2.5.5/man/ugrep.1 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/man/ugrep.1 2020-09-21 21:47:09.000000000 +0200 @@ -1,4 +1,4 @@ -.TH UGREP "1" "September 02, 2020" "ugrep 2.5.5" "User Commands" +.TH UGREP "1" "September 21, 2020" "ugrep 2.5.6" "User Commands" .SH NAME \fBugrep\fR, \fBug\fR -- file pattern searcher .SH SYNOPSIS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/src/query.cpp new/ugrep-2.5.6/src/query.cpp --- old/ugrep-2.5.5/src/query.cpp 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/src/query.cpp 2020-09-21 21:47:09.000000000 +0200 @@ -170,7 +170,7 @@ { char *ptr = line_ptr(col); char *end = line_ptr(col + len); - char *err = error_ >= 0 && !Screen::mono ? line_ptr(0, error_) : NULL; + char *err = error_ >= 0 && !Screen::mono ? line_ + error_ : NULL; char *next; bool alert = false; for (next = ptr; next < end; ++next) @@ -463,10 +463,14 @@ for (Flags *fp = flags_; fp->text != NULL; ++fp) { - buf.assign("\033[7mM- \033[m [\033[32;1m \033[m] "); + buf.assign("\033[7mM- \033[m "); buf[6] = fp->key; - if (fp->flag) - buf[19] = 'X'; + if (strncmp(fp->text, "decrease", 8) == 0 || strncmp(fp->text, "increase", 8) == 0) + buf.append(" "); + else if (fp->flag) + buf.append("[\033[32;1mX\033[m] "); + else + buf.append("[ ] "); buf.append(fp->text); if (row >= Screen::rows) { @@ -772,6 +776,8 @@ bool ctrl_o = false; bool ctrl_v = false; + bool err = false; + while (true) { size_t delay = message_ ? QUERY_MESSAGE_DELAY : flag_query; @@ -797,6 +803,14 @@ Screen::setpos(select_ - row_ + 1, col_ - offset_); } + if (error_ >= 0 && !err) + { + // show error position in the query line, but only once + draw(); + + err = true; + } + key = VKey::in(100); if (key > 0) @@ -809,6 +823,8 @@ if (mode_ == Mode::QUERY && updated_) { search(); + + err = false; } #ifdef OS_WIN else @@ -919,7 +935,7 @@ switch (key) { case VKey::TAB: // Shift-TAB: chdir .. or deselect file (or pan screen in selection mode) - if (mode_ == Mode::QUERY) + if (mode_ == Mode::QUERY && error_ == -1) { if (select_ == -1) { @@ -982,7 +998,7 @@ break; case VKey::TAB: // TAB: chdir or select file (or pan screen in selection mode) - if (mode_ == Mode::QUERY) + if (mode_ == Mode::QUERY && error_ == -1) { if (select_ == -1) { @@ -1202,7 +1218,7 @@ break; case VKey::CTRL_CA: // CTRL-^: chdir back to working directory - if (mode_ == Mode::QUERY && select_ == -1) + if (mode_ == Mode::QUERY && error_ == -1 && select_ == -1) unselect(); break; @@ -2383,6 +2399,8 @@ { int key; + Screen::put(0, Screen::cols - 1, "?"); + #ifdef OS_WIN while (true) @@ -2411,7 +2429,6 @@ if (ctrl_o) { meta(key); - redraw(); ctrl_o = false; } else if (key == VKey::CTRL_Q) @@ -2456,26 +2473,32 @@ case VKey::META: meta(VKey::get()); - redraw(); break; default: - Screen::alert(); -#ifdef WITH_MACOS_META_KEY - if (key >= 0x80) + if (key < 0x80) + { + meta(key); + } + else { + Screen::alert(); + +#ifdef WITH_MACOS_META_KEY if (!Screen::mono) Screen::put(CERROR); Screen::put(1, 0, "MacOS Terminal Preferences/Profiles/Keyboard: enable \"Use Option as Meta key\""); Screen::setpos(0, start_ + col_ - offset_); - } #endif + } } } } mode_ = oldMode; + message_ = false; + Screen::clear(); redraw(); @@ -2489,17 +2512,21 @@ { if (flags_[5].flag || flags_[6].flag || flags_[17].flag || flags_[30].flag) { - // reset -F, -G, -P, -Z to switch back to -E (the Q> prompt) + // option -E: reset -F, -G, -P, -Z to switch back to normal mode (the Q> prompt) flags_[5].flag = false; flags_[6].flag = false; flags_[17].flag = false; flags_[30].flag = false; - set_prompt(); + search(); - draw(); + std::string msg; - search(); + msg.assign("\033[7mM-E\033[m extended regex \033[32;1mon\033[m"); + + message(msg); + + set_prompt(); } return; @@ -2699,35 +2726,35 @@ if (key == 'g') { - if (!globbing_) + if (mode_ == Mode::QUERY) { - globbing_ = true; + if (!globbing_) + { + globbing_ = true; - memcpy(temp_, line_, QUERY_MAX_LEN); - size_t num = globs_.size(); - if (num >= QUERY_MAX_LEN) - num = QUERY_MAX_LEN - 1; - memcpy(line_, globs_.c_str(), num); - line_[num] = '\0'; + memcpy(temp_, line_, QUERY_MAX_LEN); + size_t num = globs_.size(); + if (num >= QUERY_MAX_LEN) + num = QUERY_MAX_LEN - 1; + memcpy(line_, globs_.c_str(), num); + line_[num] = '\0'; - len_ = line_len(); - move(len_); + len_ = line_len(); + move(len_); - set_prompt(); - } - else - { - globbing_ = false; + set_prompt(); + } + else + { + globbing_ = false; - memcpy(line_, temp_, QUERY_MAX_LEN); - len_ = line_len(); - move(len_); + memcpy(line_, temp_, QUERY_MAX_LEN); + len_ = line_len(); + move(len_); - set_prompt(); - } + set_prompt(); + } - if (mode_ == Mode::QUERY) - { draw(); } else @@ -2750,11 +2777,52 @@ else { std::string msg; + msg.assign("\033[7mM- \033[m ").append(fp->text); + msg[6] = fp->key; + + if (key == '[') + { + flags_[30].flag = true; - fp->flag = !fp->flag; + if (fuzzy_ > 1) + --fuzzy_; - msg.assign("\033[7mM- \033[m ").append(fp->text).append(fp->flag ? " \033[32;1mon\033[m" : " \033[31;1moff\033[m"); - msg[6] = fp->key; + msg.append(" to ").append(std::to_string(fuzzy_)); + } + else if (key == ']') + { + if (flags_[30].flag) + ++fuzzy_; + else + flags_[30].flag = true; + + msg.append(" to ").append(std::to_string(fuzzy_)); + } + else if (key == '{') + { + if (!flags_[0].flag && !flags_[1].flag) + flags_[3].flag = true; + + if (context_ > 1) + --context_; + + msg.append(" to ").append(std::to_string(context_)); + } + else if (key == '}') + { + if (flags_[0].flag || flags_[1].flag || flags_[3].flag) + ++context_; + else if (!flags_[0].flag && !flags_[1].flag) + flags_[3].flag = true; + + msg.append(" to ").append(std::to_string(context_)); + } + else + { + fp->flag = !fp->flag; + + msg.append(fp->flag ? " \033[32;1mon\033[m" : " \033[31;1moff\033[m"); + } search(); @@ -3380,5 +3448,9 @@ { false, '$', "sort by changed" }, { false, '@', "sort by created" }, { false, '^', "reverse sort" }, + { false, '[', "decrease fuzziness" }, + { false, ']', "increase fuzziness" }, + { false, '{', "decrease context" }, + { false, '}', "increase context" }, { false, 0, NULL, } }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/src/screen.cpp new/ugrep-2.5.6/src/screen.cpp --- old/ugrep-2.5.5/src/screen.cpp 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/src/screen.cpp 2020-09-21 21:47:09.000000000 +0200 @@ -259,8 +259,8 @@ #endif - // enable alternative screen buffer, alternate scroll, enable cursor w/o blinking, soft reset, clear screen, reset colors - put("\033[?1049h\033[?1007h\033[?25h\033[?12l\033[!p\033[2J\033[m"); + // enable alternative screen buffer, alternate scroll, enable cursor w/o blinking, cursor keys normal mode, clear screen, reset colors + put("\033[?1049h\033[?1007h\033[?25h\033[?12l\033[?1l\033[2J\033[m"); // set title, when provided as argument if (title != NULL) @@ -392,7 +392,7 @@ (wc >= 0xff00 && wc <= 0xff60) || // Fullwidth Forms (wc >= 0xffe0 && wc <= 0xffe6) || (double_width_Emoji && - (wc >= 0x1f18e && wc <= 0x1f7ff)) || // Emoticons etc + (wc >= 0x1f18e && wc <= 0x1f9ff)) || // Emoticons etc (updated) (double_width_CJK && ((wc >= 0x20000 && wc <= 0x2fffd) || // CJK (wc >= 0x30000 && wc <= 0x3fffd))))); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/src/ugrep.cpp new/ugrep-2.5.6/src/ugrep.cpp --- old/ugrep-2.5.5/src/ugrep.cpp 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/src/ugrep.cpp 2020-09-21 21:47:09.000000000 +0200 @@ -67,7 +67,7 @@ */ // ugrep version -#define UGREP_VERSION "2.5.5" +#define UGREP_VERSION "2.5.6" #include "ugrep.hpp" #include "glob.hpp" @@ -1628,7 +1628,9 @@ waiting(false) #endif #endif - { } + { + restline.reserve(256); + } virtual ~Grep() { @@ -2828,13 +2830,14 @@ const char *filename; // the name of the file being searched std::string partname; // the name of an extracted file from an archive + std::string restline; // a buffer to store the rest of a line to search Output out; // asynchronous output reflex::AbstractMatcher *matcher; // the pattern matcher we're using MMap mmap; // mmap state reflex::Input input; // input to the matcher FILE *file; // the current input file #ifndef OS_WIN - StdInHandler stdin_handler; // a handler to handler non-blocking stdin from a TTY or a slow pipe + StdInHandler stdin_handler; // a handler to handle non-blocking stdin from a TTY or a slow pipe #endif #ifdef HAVE_LIBZ zstreambuf *zstream; // the decompressed stream from the current input file @@ -7516,10 +7519,9 @@ size_t lineno = 0; bool hex = false; bool binary = false; - std::string rest_line; - const char *rest_line_data = NULL; - size_t rest_line_size = 0; - size_t rest_line_last = 0; + const char *restline_data = NULL; + size_t restline_size = 0; + size_t restline_last = 0; while (matcher->find()) { @@ -7527,28 +7529,28 @@ if (lineno != current_lineno || flag_ungroup) { - if (rest_line_data != NULL) + if (restline_data != NULL) { if (binary) { - out.dump.hex(Output::Dump::HEX_LINE, rest_line_last, rest_line_data, rest_line_size); + out.dump.hex(Output::Dump::HEX_LINE, restline_last, restline_data, restline_size); } else { - if (rest_line_size > 0) + if (restline_size > 0) { - rest_line_size -= rest_line_data[rest_line_size - 1] == '\n'; - if (rest_line_size > 0) + restline_size -= restline_data[restline_size - 1] == '\n'; + if (restline_size > 0) { out.str(color_sl); - out.str(rest_line_data, rest_line_size); + out.str(restline_data, restline_size); out.str(color_off); } } out.nl(); } - rest_line_data = NULL; + restline_data = NULL; } // --range: max line exceeded? @@ -7619,10 +7621,10 @@ } else { - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = matcher->last(); + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = matcher->last(); } lineno += matcher->lines() - 1; @@ -7681,10 +7683,10 @@ } else { - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = matcher->last(); + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = matcher->last(); } } } @@ -7704,13 +7706,13 @@ if (binary) { - out.dump.hex(Output::Dump::HEX_LINE, rest_line_last, rest_line_data, first - rest_line_last); + out.dump.hex(Output::Dump::HEX_LINE, restline_last, restline_data, first - restline_last); out.dump.hex(Output::Dump::HEX_MATCH, first, begin, size); } else { out.str(color_sl); - out.str(rest_line_data, first - rest_line_last); + out.str(restline_data, first - restline_last); out.str(color_off); if (lines > 1) @@ -7745,9 +7747,9 @@ if (lines == 1) { - rest_line_data += last - rest_line_last; - rest_line_size -= last - rest_line_last; - rest_line_last = last; + restline_data += last - restline_last; + restline_size -= last - restline_last; + restline_last = last; } else { @@ -7798,10 +7800,10 @@ } else { - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = last; + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = last; } lineno += lines - 1; @@ -7811,28 +7813,28 @@ } } - if (rest_line_data != NULL) + if (restline_data != NULL) { if (binary) { - out.dump.hex(Output::Dump::HEX_LINE, rest_line_last, rest_line_data, rest_line_size); + out.dump.hex(Output::Dump::HEX_LINE, restline_last, restline_data, restline_size); } else { - if (rest_line_size > 0) + if (restline_size > 0) { - rest_line_size -= rest_line_data[rest_line_size - 1] == '\n'; - if (rest_line_size > 0) + restline_size -= restline_data[restline_size - 1] == '\n'; + if (restline_size > 0) { out.str(color_sl); - out.str(rest_line_data, rest_line_size); + out.str(restline_data, restline_size); out.str(color_off); } } out.nl(); } - rest_line_data = NULL; + restline_data = NULL; } if (binary) @@ -7934,13 +7936,12 @@ bool stop = false; // to display the rest of the matching line - std::string rest_line; - const char *rest_line_data = NULL; - size_t rest_line_size = 0; - size_t rest_line_last = 0; + const char *restline_data = NULL; + size_t restline_size = 0; + size_t restline_last = 0; // construct event handler functor with captured *this and some of the locals - AnyLineGrepHandler any_line_handler(*this, pathname, lineno, hex, binary, matches, stop, rest_line_data, rest_line_size, rest_line_last); + AnyLineGrepHandler any_line_handler(*this, pathname, lineno, hex, binary, matches, stop, restline_data, restline_size, restline_last); // register an event handler functor to display non-matching lines matcher->set_handler(&any_line_handler); @@ -7960,28 +7961,28 @@ if (lineno != current_lineno || flag_ungroup) { - if (rest_line_data != NULL) + if (restline_data != NULL) { if (binary) { - out.dump.hex(v_hex_line, rest_line_last, rest_line_data, rest_line_size); + out.dump.hex(v_hex_line, restline_last, restline_data, restline_size); } else { - if (rest_line_size > 0) + if (restline_size > 0) { - rest_line_size -= rest_line_data[rest_line_size - 1] == '\n'; - if (rest_line_size > 0) + restline_size -= restline_data[restline_size - 1] == '\n'; + if (restline_size > 0) { out.str(v_color_sl); - out.str(rest_line_data, rest_line_size); + out.str(restline_data, restline_size); out.str(color_off); } } out.nl(); } - rest_line_data = NULL; + restline_data = NULL; } // get the lines before the matched line @@ -8078,10 +8079,10 @@ } else { - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = matcher->last(); + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = matcher->last(); } lineno += matcher->lines() - 1; @@ -8140,10 +8141,10 @@ } else { - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = matcher->last(); + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = matcher->last(); } } } @@ -8163,13 +8164,13 @@ if (binary) { - out.dump.hex(v_hex_line, rest_line_last, rest_line_data, first - rest_line_last); + out.dump.hex(v_hex_line, restline_last, restline_data, first - restline_last); out.dump.hex(v_hex_match, first, begin, size); } else { out.str(v_color_sl); - out.str(rest_line_data, first - rest_line_last); + out.str(restline_data, first - restline_last); out.str(color_off); if (lines > 1) @@ -8204,9 +8205,9 @@ if (lines == 1) { - rest_line_data += last - rest_line_last; - rest_line_size -= last - rest_line_last; - rest_line_last = last; + restline_data += last - restline_last; + restline_size -= last - restline_last; + restline_last = last; } else { @@ -8257,10 +8258,10 @@ } else { - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = last; + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = last; } lineno += lines - 1; @@ -8270,28 +8271,28 @@ } } - if (rest_line_data != NULL) + if (restline_data != NULL) { if (binary) { - out.dump.hex(v_hex_line, rest_line_last, rest_line_data, rest_line_size); + out.dump.hex(v_hex_line, restline_last, restline_data, restline_size); } else { - if (rest_line_size > 0) + if (restline_size > 0) { - rest_line_size -= rest_line_data[rest_line_size - 1] == '\n'; - if (rest_line_size > 0) + restline_size -= restline_data[restline_size - 1] == '\n'; + if (restline_size > 0) { out.str(v_color_sl); - out.str(rest_line_data, rest_line_size); + out.str(restline_data, restline_size); out.str(color_off); } } out.nl(); } - rest_line_data = NULL; + restline_data = NULL; } // get the remaining context @@ -8330,13 +8331,12 @@ bool stop = false; // to display the rest of the matching line - std::string rest_line; - const char *rest_line_data = NULL; - size_t rest_line_size = 0; - size_t rest_line_last = 0; + const char *restline_data = NULL; + size_t restline_size = 0; + size_t restline_last = 0; // construct event handler functor with captured *this and some of the locals - ContextGrepHandler context_handler(*this, pathname, lineno, hex, binary, matches, stop, rest_line_data, rest_line_size, rest_line_last); + ContextGrepHandler context_handler(*this, pathname, lineno, hex, binary, matches, stop, restline_data, restline_size, restline_last); // register an event handler functor to display non-matching lines matcher->set_handler(&context_handler); @@ -8350,28 +8350,28 @@ if (lineno != current_lineno || flag_ungroup) { - if (rest_line_data != NULL) + if (restline_data != NULL) { if (binary) { - out.dump.hex(Output::Dump::HEX_LINE, rest_line_last, rest_line_data, rest_line_size); + out.dump.hex(Output::Dump::HEX_LINE, restline_last, restline_data, restline_size); } else { - if (rest_line_size > 0) + if (restline_size > 0) { - rest_line_size -= rest_line_data[rest_line_size - 1] == '\n'; - if (rest_line_size > 0) + restline_size -= restline_data[restline_size - 1] == '\n'; + if (restline_size > 0) { out.str(color_sl); - out.str(rest_line_data, rest_line_size); + out.str(restline_data, restline_size); out.str(color_off); } } out.nl(); } - rest_line_data = NULL; + restline_data = NULL; } // get the lines before the matched line @@ -8470,10 +8470,10 @@ } else { - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = matcher->last(); + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = matcher->last(); } lineno += matcher->lines() - 1; @@ -8532,10 +8532,10 @@ } else { - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = matcher->last(); + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = matcher->last(); } } } @@ -8555,13 +8555,13 @@ if (binary) { - out.dump.hex(Output::Dump::HEX_LINE, rest_line_last, rest_line_data, first - rest_line_last); + out.dump.hex(Output::Dump::HEX_LINE, restline_last, restline_data, first - restline_last); out.dump.hex(Output::Dump::HEX_MATCH, first, begin, size); } else { out.str(color_sl); - out.str(rest_line_data, first - rest_line_last); + out.str(restline_data, first - restline_last); out.str(color_off); if (lines > 1) @@ -8596,9 +8596,9 @@ if (lines == 1) { - rest_line_data += last - rest_line_last; - rest_line_size -= last - rest_line_last; - rest_line_last = last; + restline_data += last - restline_last; + restline_size -= last - restline_last; + restline_last = last; } else { @@ -8649,10 +8649,10 @@ } else { - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = last; + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = last; } lineno += lines - 1; @@ -8664,28 +8664,28 @@ context_handler.set_after_lineno(lineno + 1); } - if (rest_line_data != NULL) + if (restline_data != NULL) { if (binary) { - out.dump.hex(Output::Dump::HEX_LINE, rest_line_last, rest_line_data, rest_line_size); + out.dump.hex(Output::Dump::HEX_LINE, restline_last, restline_data, restline_size); } else { - if (rest_line_size > 0) + if (restline_size > 0) { - rest_line_size -= rest_line_data[rest_line_size - 1] == '\n'; - if (rest_line_size > 0) + restline_size -= restline_data[restline_size - 1] == '\n'; + if (restline_size > 0) { out.str(color_sl); - out.str(rest_line_data, rest_line_size); + out.str(restline_data, restline_size); out.str(color_off); } } out.nl(); } - rest_line_data = NULL; + restline_data = NULL; } // get the remaining context @@ -8726,13 +8726,12 @@ bool stop = false; // to display the rest of the matching line - std::string rest_line; - const char *rest_line_data = NULL; - size_t rest_line_size = 0; - size_t rest_line_last = 0; + const char *restline_data = NULL; + size_t restline_size = 0; + size_t restline_last = 0; // construct event handler functor with captured *this and some of the locals - InvertContextGrepHandler invert_context_handler(*this, pathname, lineno, hex, binary, matches, stop, rest_line_data, rest_line_size, rest_line_last); + InvertContextGrepHandler invert_context_handler(*this, pathname, lineno, hex, binary, matches, stop, restline_data, restline_size, restline_last); // register an event handler functor to display non-matching lines matcher->set_handler(&invert_context_handler); @@ -8752,28 +8751,28 @@ if (last_lineno != current_lineno) { - if (rest_line_data != NULL) + if (restline_data != NULL) { if (binary) { - out.dump.hex(Output::Dump::HEX_CONTEXT_LINE, rest_line_last, rest_line_data, rest_line_size); + out.dump.hex(Output::Dump::HEX_CONTEXT_LINE, restline_last, restline_data, restline_size); } else { - if (rest_line_size > 0) + if (restline_size > 0) { - rest_line_size -= rest_line_data[rest_line_size - 1] == '\n'; - if (rest_line_size > 0) + restline_size -= restline_data[restline_size - 1] == '\n'; + if (restline_size > 0) { out.str(color_cx); - out.str(rest_line_data, rest_line_size); + out.str(restline_data, restline_size); out.str(color_off); } } out.nl(); } - rest_line_data = NULL; + restline_data = NULL; } // get the lines before the matched line @@ -8861,10 +8860,10 @@ out.dump.hex(Output::Dump::HEX_CONTEXT_LINE, first - border, bol, border); out.dump.hex(Output::Dump::HEX_CONTEXT_MATCH, first, begin, size); - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = matcher->last(); + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = matcher->last(); } } else @@ -8902,10 +8901,10 @@ out.str(begin, size); out.str(match_off); - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = matcher->last(); + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = matcher->last(); } } else if (flag_before_context > 0) @@ -8984,13 +8983,13 @@ if (binary) { - out.dump.hex(Output::Dump::HEX_CONTEXT_LINE, rest_line_last, rest_line_data, first - rest_line_last); + out.dump.hex(Output::Dump::HEX_CONTEXT_LINE, restline_last, restline_data, first - restline_last); out.dump.hex(Output::Dump::HEX_CONTEXT_MATCH, first, begin, size); } else { out.str(color_cx); - out.str(rest_line_data, first - rest_line_last); + out.str(restline_data, first - restline_last); out.str(color_off); if (lines > 1) @@ -9025,9 +9024,9 @@ if (lines == 1) { - rest_line_data += last - rest_line_last; - rest_line_size -= last - rest_line_last; - rest_line_last = last; + restline_data += last - restline_last; + restline_size -= last - restline_last; + restline_last = last; } else { @@ -9046,38 +9045,38 @@ hex = binary; - rest_line.assign(end, eol - end); - rest_line_data = rest_line.c_str(); - rest_line_size = rest_line.size(); - rest_line_last = last; + restline.assign(end, eol - end); + restline_data = restline.c_str(); + restline_size = restline.size(); + restline_last = last; } } } } else { - if (rest_line_data != NULL) + if (restline_data != NULL) { if (binary) { - out.dump.hex(Output::Dump::HEX_CONTEXT_LINE, rest_line_last, rest_line_data, rest_line_size); + out.dump.hex(Output::Dump::HEX_CONTEXT_LINE, restline_last, restline_data, restline_size); } else { - if (rest_line_size > 0) + if (restline_size > 0) { - rest_line_size -= rest_line_data[rest_line_size - 1] == '\n'; - if (rest_line_size > 0) + restline_size -= restline_data[restline_size - 1] == '\n'; + if (restline_size > 0) { out.str(color_cx); - out.str(rest_line_data, rest_line_size); + out.str(restline_data, restline_size); out.str(color_off); } } out.nl(); } - rest_line_data = NULL; + restline_data = NULL; } if (flag_before_context > 0) @@ -9146,28 +9145,28 @@ last_lineno = lineno; } - if (rest_line_data != NULL) + if (restline_data != NULL) { if (binary) { - out.dump.hex(Output::Dump::HEX_CONTEXT_LINE, rest_line_last, rest_line_data, rest_line_size); + out.dump.hex(Output::Dump::HEX_CONTEXT_LINE, restline_last, restline_data, restline_size); } else { - if (rest_line_size > 0) + if (restline_size > 0) { - rest_line_size -= rest_line_data[rest_line_size - 1] == '\n'; - if (rest_line_size > 0) + restline_size -= restline_data[restline_size - 1] == '\n'; + if (restline_size > 0) { out.str(color_cx); - out.str(rest_line_data, rest_line_size); + out.str(restline_data, restline_size); out.str(color_off); } } out.nl(); } - rest_line_data = NULL; + restline_data = NULL; } // get the remaining context diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ugrep-2.5.5/src/ugrep.hpp new/ugrep-2.5.6/src/ugrep.hpp --- old/ugrep-2.5.5/src/ugrep.hpp 2020-09-02 16:35:50.000000000 +0200 +++ new/ugrep-2.5.6/src/ugrep.hpp 2020-09-21 21:47:09.000000000 +0200 @@ -176,7 +176,7 @@ Flag() : value(UNDEFINED) { } Flag(bool flag) : value(flag ? T : F) { } - Flag operator=(bool flag) { value = flag ? T : F; return *this; } + Flag& operator=(bool flag) { value = flag ? T : F; return *this; } operator bool() const { return is_true(); } bool is_undefined() const { return value == UNDEFINED; } bool is_defined() const { return value != UNDEFINED; }