From ffd990fcd9e1280bb747c19545ca36a0313d2f16 Mon Sep 17 00:00:00 2001 From: Robert van Engelen Date: Thu, 14 Nov 2024 13:47:42 -0500 Subject: [PATCH] released 7.0.4 fix ugrep.exe TUI issue #438 after #437 which caused some users to struggle with TUI issues due to Windows API peculiarities with different Windows OS --- README.md | 2 +- bin/win32/ug.exe | Bin 1831936 -> 1831936 bytes bin/win32/ugrep-indexer.exe | Bin 600064 -> 600064 bytes bin/win32/ugrep.exe | Bin 1831936 -> 1831936 bytes bin/win64/ug.exe | Bin 2045440 -> 2045440 bytes bin/win64/ugrep-indexer.exe | Bin 688128 -> 688128 bytes bin/win64/ugrep.exe | Bin 2045440 -> 2045440 bytes configure | 20 ++++++++++---------- configure.ac | 2 +- include/reflex/matcher.h | 2 +- man/ug.1 | 2 +- man/ugrep-indexer.1 | 2 +- man/ugrep.1 | 2 +- src/query.cpp | 11 ++++++++--- src/ugrep-indexer.cpp | 2 +- src/ugrep.hpp | 18 +++++++++++++----- src/vkey.cpp | 10 ++++++++-- src/vkey.hpp | 1 + 18 files changed, 47 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 5c6ff172..dd95bd89 100644 --- a/README.md +++ b/README.md @@ -5459,7 +5459,7 @@ in markdown: - ugrep 7.0.3 November 10, 2024 UGREP(1) + ugrep 7.0.4 November 12, 2024 UGREP(1) 🔝 [Back to table of contents](#toc) diff --git a/bin/win32/ug.exe b/bin/win32/ug.exe index 1d319b2b3c02a7e2b8d319c3b0f92837e0f39b76..94cc20762d7caefce0bf445dcfc0d1294a037301 100755 GIT binary patch delta 206 zcmXxexedZV6old31;Iw!J3KnWCp3n1H!l^jD0#132m3H%QH zq)&R9NhU3lv`8LXZSv?6>T9Sg1`RaPf`>Lb=%R-{d<-ze2xCkz#S8)FSYU}2);82~ vz8~^ve^Q*m5#>u%`IIVBb?5U3h~J`OS9iBhCc<9(&BPN%XeU;?&2RSy(G)MJ diff --git a/bin/win32/ugrep-indexer.exe b/bin/win32/ugrep-indexer.exe index 6b190286cd1902bdd4f7e9de963a8d2df2f656c3..3696c84b8d1ad9bc8813a56de08194c19c3b38bb 100755 GIT binary patch delta 141 zcmZp;pwe(bWrGGIbIUB_W^KlHZAK7g0%B$$W&vVWAZ7z%_U+n?9R3ZACflnUIc92F z12v>G009#amjdyIlN<~ic5;A(7+`WdK(+`FYn(AWi+o9@4wLlR`;_UzRhk$jBO L+mG(#u+9SjZDJwc delta 141 zcmZp;pwe(bWrGGIbL$3!W^KlHZAK7g0%B$$W&vVWAZ7z%_U+n?9R3ZA#@nkKIc92F z12v>G009#amjdyIlN<~ic5;A(7+`WdK(+`FYn(AWi+o9@4wLlR`;_UzRhk$j9& L+mG(#u+9Sjgy|wd diff --git a/bin/win32/ugrep.exe b/bin/win32/ugrep.exe index 1d319b2b3c02a7e2b8d319c3b0f92837e0f39b76..94cc20762d7caefce0bf445dcfc0d1294a037301 100755 GIT binary patch delta 206 zcmXxexedZV6old31;Iw!J3KnWCp3n1H!l^jD0#132m3H%QH zq)&R9NhU3lv`8LXZSv?6>T9Sg1`RaPf`>Lb=%R-{d<-ze2xCkz#S8)FSYU}2);82~ vz8~^ve^Q*m5#>u%`IIVBb?5U3h~J`OS9iBhCc<9(&BPN%XeU;?&2RSy(G)MJ diff --git a/bin/win64/ug.exe b/bin/win64/ug.exe index cbbf5e6e4d1666d72b64d860618a575f6d319c02..caffe637e33606733bad92ab8056da87b61d99d6 100755 GIT binary patch delta 218 zcmXxeI}UVnzx>VZlal2gXuENkL-465Ioo9W9%nbp)v{)wg*H0qqK7^P7-9qyV_2AAiW%luz{V0Qtg*os4tCh* zTB__4M8WkgI0Fw9PbG>_)s<*AlWfC#DdF9k?PK}M;rCqoDmzLyEkl);;oPj@5O?F{kN|;--eVjmf{GRJTr3dLJWvKEp^iRJ(JjyO! diff --git a/bin/win64/ugrep-indexer.exe b/bin/win64/ugrep-indexer.exe index a1181da56e49fae7d286fb470bc396dc464bde20..8e206a272d1ec36ca041ec94ba4dac8b2a2fc977 100755 GIT binary patch delta 145 zcmZo@&}wMV+MvP6+%?O%S(~w4n-PSWfS4JGS%8=oh}nRc9f&!$Ycq0+hccRMcMjt; z)V2m{N@oB9CLpc^;vcIy8GcOX1PL*~jxeIutN$ky$r8#x`t N80EL~&fxs~8~|7LB4q#o delta 145 zcmZo@&}wMV+MvP6T(iNTS(~w4n-PSWfS4JGS%8=oh}nRc9f&!$Ycq0+hcX&(cMjt; z)V2m{N@oB9CLpc^;vcIy8GcOX1PL*~jxeIutN$ky$r8#x`t N80EI}&fxs~8~|NsB76V< diff --git a/bin/win64/ugrep.exe b/bin/win64/ugrep.exe index cbbf5e6e4d1666d72b64d860618a575f6d319c02..caffe637e33606733bad92ab8056da87b61d99d6 100755 GIT binary patch delta 218 zcmXxeI}UVnzx>VZlal2gXuENkL-465Ioo9W9%nbp)v{)wg*H0qqK7^P7-9qyV_2AAiW%luz{V0Qtg*os4tCh* zTB__4M8WkgI0Fw9PbG>_)s<*AlWfC#DdF9k?PK}M;rCqoDmzLyEkl);;oPj@5O?F{kN|;--eVjmf{GRJTr3dLJWvKEp^iRJ(JjyO! diff --git a/configure b/configure index e6489c2d..9854cbb0 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.72 for ugrep 7.0.3. +# Generated by GNU Autoconf 2.72 for ugrep 7.0.4. # # Report bugs to . # @@ -606,8 +606,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ugrep' PACKAGE_TARNAME='ugrep' -PACKAGE_VERSION='7.0.3' -PACKAGE_STRING='ugrep 7.0.3' +PACKAGE_VERSION='7.0.4' +PACKAGE_STRING='ugrep 7.0.4' PACKAGE_BUGREPORT='https://github.com/Genivia/ugrep/issues' PACKAGE_URL='https://ugrep.com' @@ -1382,7 +1382,7 @@ if test "$ac_init_help" = "long"; then # 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 7.0.3 to adapt to many kinds of systems. +'configure' configures ugrep 7.0.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1453,7 +1453,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ugrep 7.0.3:";; + short | recursive ) echo "Configuration of ugrep 7.0.4:";; esac cat <<\_ACEOF @@ -1630,7 +1630,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ugrep configure 7.0.3 +ugrep configure 7.0.4 generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -2184,7 +2184,7 @@ cat >config.log <<_ACEOF 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 7.0.3, which was +It was created by ugrep $as_me 7.0.4, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -3694,7 +3694,7 @@ fi # Define the identity of the package. PACKAGE='ugrep' - VERSION='7.0.3' + VERSION='7.0.4' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -11790,7 +11790,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # 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 7.0.3, which was +This file was extended by ugrep $as_me 7.0.4, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -11863,7 +11863,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -ugrep config.status 7.0.3 +ugrep config.status 7.0.4 configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 419477ac..2d0f86e2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([ugrep],[7.0.3],[https://github.com/Genivia/ugrep/issues],[ugrep],[https://ugrep.com]) +AC_INIT([ugrep],[7.0.4],[https://github.com/Genivia/ugrep/issues],[ugrep],[https://ugrep.com]) AM_INIT_AUTOMAKE([foreign subdir-objects dist-xz no-dist-gzip]) AC_CONFIG_HEADERS([config.h]) AC_COPYRIGHT([Copyright (C) 2019-2024 Robert van Engelen, Genivia Inc.]) diff --git a/include/reflex/matcher.h b/include/reflex/matcher.h index e5df388f..15485a69 100644 --- a/include/reflex/matcher.h +++ b/include/reflex/matcher.h @@ -50,7 +50,7 @@ class Matcher : public PatternMatcher { template static std::string convert(T regex, convert_flag_type flags = convert_flag::none, bool *multiline = NULL) { - return reflex::convert(regex, "imsx#=^:abcdefhijklnrstuvwxzABDHLNQSUW<>?", flags, multiline); + return reflex::convert(regex, "imsx#=^:abcdefhijklnrstuvwxzABDHLNQSUW0<>?", flags, multiline); } /// Default constructor. Matcher() : PatternMatcher() diff --git a/man/ug.1 b/man/ug.1 index 5eeb4705..904bcaeb 100644 --- a/man/ug.1 +++ b/man/ug.1 @@ -1,4 +1,4 @@ -.TH UGREP "1" "November 10, 2024" "ugrep 7.0.3" "User Commands" +.TH UGREP "1" "November 12, 2024" "ugrep 7.0.4" "User Commands" .SH NAME \fBugrep\fR, \fBug\fR -- file pattern searcher .SH SYNOPSIS diff --git a/man/ugrep-indexer.1 b/man/ugrep-indexer.1 index 692a0eb2..62504652 100644 --- a/man/ugrep-indexer.1 +++ b/man/ugrep-indexer.1 @@ -1,4 +1,4 @@ -.TH UGREP-INDEXER "1" "November 10, 2024" "ugrep-indexer 7.0.3" "User Commands" +.TH UGREP-INDEXER "1" "November 12, 2024" "ugrep-indexer 7.0.4" "User Commands" .SH NAME \fBugrep-indexer\fR -- file indexer to accelerate recursive searching .SH SYNOPSIS diff --git a/man/ugrep.1 b/man/ugrep.1 index 5eeb4705..904bcaeb 100644 --- a/man/ugrep.1 +++ b/man/ugrep.1 @@ -1,4 +1,4 @@ -.TH UGREP "1" "November 10, 2024" "ugrep 7.0.3" "User Commands" +.TH UGREP "1" "November 12, 2024" "ugrep 7.0.4" "User Commands" .SH NAME \fBugrep\fR, \fBug\fR -- file pattern searcher .SH SYNOPSIS diff --git a/src/query.cpp b/src/query.cpp index 77f36956..9b503600 100644 --- a/src/query.cpp +++ b/src/query.cpp @@ -2421,12 +2421,17 @@ void Query::view() if (found) { + + Screen::clear(); + Screen::put("Waiting on "); + Screen::put(command.c_str()); + Screen::put(" to finish"); + Screen::home(); + // -n: add +line_number if (line_number > 0) command.append(" +").append(std::to_string(line_number)); - Screen::clear(); - FILE *pager = NULL; #ifdef OS_WIN @@ -2475,7 +2480,7 @@ void Query::view() wcommand = utf8_decode(command); // flush before calling _wsystem(), according to the Window's system API documentation - _flushall(); + // _flushall(); removed because this may cause the TUI to freeze #endif } diff --git a/src/ugrep-indexer.cpp b/src/ugrep-indexer.cpp index 0c44c9b4..b3583755 100644 --- a/src/ugrep-indexer.cpp +++ b/src/ugrep-indexer.cpp @@ -35,7 +35,7 @@ */ // DO NOT ALTER THIS LINE: updated by makemake.sh and we need it physically here for MSVC++ build from source -#define UGREP_VERSION "7.0.3" +#define UGREP_VERSION "7.0.4" // use a task-parallel thread to decompress the stream into a pipe to search, also handles nested archives #define WITH_DECOMPRESSION_THREAD diff --git a/src/ugrep.hpp b/src/ugrep.hpp index bb8b7e8c..8515ecbb 100644 --- a/src/ugrep.hpp +++ b/src/ugrep.hpp @@ -38,7 +38,7 @@ #define UGREP_HPP // DO NOT ALTER THIS LINE: updated by makemake.sh and we need it physically here for MSVC++ build from source -#define UGREP_VERSION "7.0.3" +#define UGREP_VERSION "7.0.4" // disable mmap because mmap is almost always slower than the file reading speed improvements since 3.0.0 #define WITH_NO_MMAP @@ -132,8 +132,12 @@ inline std::string utf8_encode(const std::wstring &wstr) if (wstr.empty()) return std::string(); int size = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast(wstr.size()), NULL, 0, NULL, NULL); - std::string str(size, 0); - WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast(wstr.size()), &str[0], size, NULL, NULL); + std::string str; + if (size >= 0) + { + str.resize(size); + WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast(wstr.size()), &str[0], size, NULL, NULL); + } return str; } @@ -143,8 +147,12 @@ inline std::wstring utf8_decode(const std::string &str) if (str.empty()) return std::wstring(); int size = MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast(str.size()), NULL, 0); - std::wstring wstr(size, 0); - MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast(str.size()), &wstr[0], size); + std::wstring wstr; + if (size >= 0) + { + wstr.resize(size); + MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast(str.size()), &wstr[0], size); + } return wstr; } diff --git a/src/vkey.cpp b/src/vkey.cpp index 85db575f..54bdff19 100644 --- a/src/vkey.cpp +++ b/src/vkey.cpp @@ -780,14 +780,15 @@ bool VKey::setup(int mode) inMode |= ENABLE_WINDOW_INPUT; #ifdef VKEY_WIN - inMode |= ENABLE_VIRTUAL_TERMINAL_INPUT; + inMode |= ENABLE_VIRTUAL_TERMINAL_INPUT | ENABLE_EXTENDED_FLAGS; #endif if (!SetConsoleMode(hConIn, inMode)) return false; #ifdef CP_UTF8 - SetConsoleCP(CP_UTF8); + oldOutputCP = GetConsoleOutputCP(); + SetConsoleOutputCP(CP_UTF8); #endif #else @@ -844,6 +845,10 @@ void VKey::cleanup() CloseHandle(hConIn); } +#ifdef CP_UTF8 + SetConsoleOutputCP(oldOutputCP); +#endif + #else tcsetattr(tty, TCSAFLUSH, &oldterm); @@ -898,6 +903,7 @@ void VKey::map_fn_key(unsigned num, const char *keys) // Windows console state HANDLE VKey::hConIn; DWORD VKey::oldInMode; +UINT VKey::oldOutputCP; #else diff --git a/src/vkey.hpp b/src/vkey.hpp index 21ddc74c..f72458d7 100644 --- a/src/vkey.hpp +++ b/src/vkey.hpp @@ -317,6 +317,7 @@ class VKey { // Windows console state static HANDLE hConIn; static DWORD oldInMode; + static UINT oldOutputCP; #else