[PATCH v2] search: skip a match on the magic line, as it is a just convenience line

Benno Schulenberg <[email protected]>
Newsgroups gmane.editors.nano.devel
Message-ID <[email protected]>
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 any regex, like ^ or $, to match it.

This fixes https://savannah.gnu.org/bugs/?63034.
Indirectly-reported-by: Mike Scalora <[email protected]>

Bug existed since before version 2.0.0.
---
 src/search.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/search.c b/src/search.c
index d759668b..57236667 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 || line->data[0])
+				break;
 		}
 
 #ifndef NANO_TINY
-- 
2.37.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.