summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-29 17:51:49 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-29 17:51:49 -0500
commita0b84cc8f40e19a506332be3a05222b87e6ed617 (patch)
tree68607facee3bb655cfe2166d4a578db9e91bdf1f /util.c
parent565b5e619ed64f459f1b38b5b94bb72b5b9a714f (diff)
better tab bar, default to "save as" on Ctrl+S with starting buffer
Diffstat (limited to 'util.c')
-rw-r--r--util.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/util.c b/util.c
index 4a5340b..59ece04 100644
--- a/util.c
+++ b/util.c
@@ -204,3 +204,13 @@ static void qsort_with_context(void *base, size_t nmemb, size_t size, int (*comp
qsort_ctx_cmp = compar;
qsort(base, nmemb, size, qsort_with_context_cmp);
}
+
+// the actual file name part of the path; get rid of the containing directory.
+// NOTE: the returned string is part of path, so you don't need to free it or anything.
+static char const *path_filename(char const *path) {
+ char const *last_path_sep = strrchr(path, PATH_SEPARATOR);
+ if (last_path_sep)
+ return last_path_sep + 1;
+ // (a relative path with no path separators)
+ return path;
+}