From 5c5fefc8cf91380a0c6576898b4dc8485fcae725 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 23 Apr 2016 13:23:49 +0200
Subject: [PATCH] files: tweak the function tail() and rename two variables

---
 src/files.c | 15 ++++++---------
 src/proto.h |  2 +-
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/files.c b/src/files.c
index d3945f84..33faabc2 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2927,18 +2927,15 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
 }
 #endif /* !DISABLE_TABCOMP */
 
-/* Only print the last part of a path.  Isn't there a shell command for
- * this? */
-const char *tail(const char *foo)
+/* Return the filename part of the given path. */
+const char *tail(const char *path)
 {
-    const char *tmp = strrchr(foo, '/');
+    const char *slash = strrchr(path, '/');
 
-    if (tmp == NULL)
-	tmp = foo;
+    if (slash == NULL)
+	return path;
     else
-	tmp++;
-
-    return tmp;
+	return ++slash;
 }
 
 #ifndef DISABLE_HISTORIES
diff --git a/src/proto.h b/src/proto.h
index 44621a40..7985c76d 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -342,7 +342,7 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
 char *input_tab(char *buf, bool allow_files, size_t *place,
 	bool *lastwastab, bool *listed);
 #endif
-const char *tail(const char *foo);
+const char *tail(const char *path);
 #ifndef DISABLE_HISTORIES
 char *histfilename(void);
 void load_history(void);
-- 
GitLab