[packages/the_silver_searcher] fix highlighting of multiple matches in same line with --nomultiline; rel 2

atler atler at pld-linux.org
Wed Nov 25 13:32:22 CET 2020


commit ffd243a92d5bfddf61f949d2545233aea8d21187
Author: Jan Palus <atler at pld-linux.org>
Date:   Wed Nov 25 13:30:13 2020 +0100

    fix highlighting of multiple matches in same line with --nomultiline; rel 2

 hl_multi_matches_nomultiline.patch | 37 +++++++++++++++++++++++++++++++++++++
 the_silver_searcher.spec           |  6 ++++--
 2 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/the_silver_searcher.spec b/the_silver_searcher.spec
index 9559919..eff9448 100644
--- a/the_silver_searcher.spec
+++ b/the_silver_searcher.spec
@@ -1,13 +1,14 @@
 Summary:	A code-searching tool similar to ack, but faster
 Name:		the_silver_searcher
 Version:	2.2.0
-Release:	1
+Release:	2
 License:	Appache v2.0
 Group:		Applications
 Source0:	https://geoff.greer.fm/ag/releases/%{name}-%{version}.tar.gz
 # Source0-md5:	958a614cbebf47b2f27a7d00a5bb1bcb
-URL:		https://geoff.greer.fm/ag/
 Patch0:		gcc10.patch
+Patch1:		hl_multi_matches_nomultiline.patch
+URL:		https://geoff.greer.fm/ag/
 BuildRequires:	autoconf >= 2.59
 BuildRequires:	automake
 BuildRequires:	pcre-devel
@@ -66,6 +67,7 @@ This package provides zsh-completion for the_silver_searcher.
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
 
 %build
 %{__aclocal} -I m4
diff --git a/hl_multi_matches_nomultiline.patch b/hl_multi_matches_nomultiline.patch
new file mode 100644
index 0000000..a940bb1
--- /dev/null
+++ b/hl_multi_matches_nomultiline.patch
@@ -0,0 +1,37 @@
+From b1e0ba5b8325860ac5fc6866f1982d62bedb9437 Mon Sep 17 00:00:00 2001
+From: Jan Palus <atler at pld-linux.org>
+Date: Tue, 24 Nov 2020 12:36:18 +0100
+Subject: [PATCH] Fix highlighting of multiple matches in same line with
+ --nomultiline
+
+offset_vector values are absolute within line so no need to recalculate
+them relative to previous match, just add buf_offset (beginning of line)
+
+Fixes #1080
+---
+ src/search.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/src/search.c b/src/search.c
+index 0dad3c07..ad48b9bb 100644
+--- a/src/search.c
++++ b/src/search.c
+@@ -147,7 +147,6 @@ ssize_t search_buf(const char *buf, const size_t buf_len,
+                     if (rv < 0) {
+                         break;
+                     }
+-                    size_t line_to_buf = buf_offset + line_offset;
+                     log_debug("Regex match found. File %s, offset %i bytes.", dir_full_path, offset_vector[0]);
+                     line_offset = offset_vector[1];
+                     if (offset_vector[0] == offset_vector[1]) {
+@@ -157,8 +156,8 @@ ssize_t search_buf(const char *buf, const size_t buf_len,
+ 
+                     realloc_matches(&matches, &matches_size, matches_len + matches_spare);
+ 
+-                    matches[matches_len].start = offset_vector[0] + line_to_buf;
+-                    matches[matches_len].end = offset_vector[1] + line_to_buf;
++                    matches[matches_len].start = offset_vector[0] + buf_offset;
++                    matches[matches_len].end = offset_vector[1] + buf_offset;
+                     matches_len++;
+ 
+                     if (opts.max_matches_per_file > 0 && matches_len >= opts.max_matches_per_file) {
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/the_silver_searcher.git/commitdiff/ffd243a92d5bfddf61f949d2545233aea8d21187



More information about the pld-cvs-commit mailing list