From 727c244ab6658012a00646067fa6d327248e74c8 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Fri, 30 Jun 2006 04:46:24 +0000
Subject: [PATCH] in findnextfile(), simplify the uses of tail()

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3696 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog     |  2 ++
 src/browser.c | 14 ++++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index da0f6df2..43413023 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,8 @@ CVS code -
 	  truncated, and where file sizes could be too long. (DLR)
 	- For the ".." entry, display "(parent dir)" instead of "(dir)",
 	  as Pico does. (DLR)
+  findnextfile()
+	- Simplify the uses of tail(). (DLR)
 - doc/syntax/c.nanorc:
 	- Since .i and .ii are preprocessed C and C++ output, colorize
 	  them here. (Mike Frysinger)
diff --git a/src/browser.c b/src/browser.c
index df6a8c44..9fd52ced 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -742,17 +742,17 @@ bool findnextfile(bool no_sameline, size_t begin, const char *needle)
     size_t currselected = selected;
 	/* The location in the current file list of the match we
 	 * find. */
-    const char *rev_start = tail(filelist[currselected]), *found = NULL;
+    const char *filetail = tail(filelist[currselected]);
+    const char *rev_start = filetail, *found = NULL;
 
 #ifndef NANO_TINY
     if (ISSET(BACKWARDS_SEARCH))
-	rev_start += strlen(tail(filelist[currselected]));
+	rev_start += strlen(rev_start);
 #endif
 
     /* Look for needle in the current filename we're searching. */
     while (TRUE) {
-	found = strstrwrapper(tail(filelist[currselected]), needle,
-		rev_start);
+	found = strstrwrapper(filetail, needle, rev_start);
 
 	/* We've found a potential match.  If we're not allowed to find
 	 * a match on the same filename we started on and this potential
@@ -792,10 +792,12 @@ bool findnextfile(bool no_sameline, size_t begin, const char *needle)
 	if (currselected == begin)
 	    search_last_file = TRUE;
 
-	rev_start = tail(filelist[currselected]);
+	filetail = tail(filelist[currselected]);
+
+	rev_start = filetail;
 #ifndef NANO_TINY
 	if (ISSET(BACKWARDS_SEARCH))
-	    rev_start += strlen(tail(filelist[currselected]));
+	    rev_start += strlen(rev_start);
 #endif
     }
 
-- 
GitLab