]> git.pld-linux.org Git - packages/the_silver_searcher.git/commitdiff
fix highlighting of multiple matches in same line with --nomultiline; rel 2 auto/th/the_silver_searcher-2.2.0-2
authorJan Palus <atler@pld-linux.org>
Wed, 25 Nov 2020 12:30:13 +0000 (13:30 +0100)
committerJan Palus <atler@pld-linux.org>
Wed, 25 Nov 2020 12:31:54 +0000 (13:31 +0100)
hl_multi_matches_nomultiline.patch [new file with mode: 0644]
the_silver_searcher.spec

diff --git a/hl_multi_matches_nomultiline.patch b/hl_multi_matches_nomultiline.patch
new file mode 100644 (file)
index 0000000..a940bb1
--- /dev/null
@@ -0,0 +1,37 @@
+From b1e0ba5b8325860ac5fc6866f1982d62bedb9437 Mon Sep 17 00:00:00 2001
+From: Jan Palus <atler@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) {
index 95599192a1455bcee01d4963a11e2bbf865ca1fa..eff9448a50e4282a7c816d17e8d64047bd1dcdcb 100644 (file)
@@ -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
This page took 0.055224 seconds and 4 git commands to generate.