nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] searching: skip a regex match on the magic line


From: Benno Schulenberg
Subject: [PATCH] searching: skip a regex match on the magic line
Date: Thu, 8 Sep 2022 12:56:25 +0200

As the magic line isn't really a line (it is not counted in the number
of lines read and written), and nothing is on it (not even a newline),
it doesn't make sense to allow the regexes ^ or $ or ^$ to match it.

Requested-by: Mike Scalora <mike@scalora.org>
---
 src/search.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/search.c b/src/search.c
index d759668b..c4ff5dce 100644
--- a/src/search.c
+++ b/src/search.c
@@ -222,8 +222,9 @@ int findnextstr(const char *needle, bool whole_word_only, 
int modus,
                                continue;
                        }
 #endif
-                       /* The match is valid. */
-                       break;
+                       /* When not on the magic line, the match is valid. */
+                       if (line->next || *found || ISSET(NO_NEWLINES))
+                               break;
                }
 
 #ifndef NANO_TINY
-- 
2.37.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]