From 4da8ba603b588bef38f772c18d883fbf5ddc9e65 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 16 Mar 2017 23:30:21 -0400 Subject: Color link targets for -ls Fixes #18. --- bftw.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'bftw.c') diff --git a/bftw.c b/bftw.c index a3f3345..6d0c849 100644 --- a/bftw.c +++ b/bftw.c @@ -760,24 +760,6 @@ static void bftw_set_error(struct bftw_state *state, int error) { } } -/** - * Figure out the name offset in a path. - */ -static size_t basename_offset(const char *path) { - size_t i; - - // Strip trailing slashes - for (i = strlen(path); i > 0 && path[i - 1] == '/'; --i); - - // Find the beginning of the name - for (; i > 0 && path[i - 1] != '/'; --i); - - // Strip leading slashes - for (; path[i] == '/' && path[i + 1]; ++i); - - return i; -} - /** * Initialize the buffers with data about the current path. */ @@ -811,7 +793,7 @@ static void bftw_init_buffers(struct bftw_state *state, const struct dirent *de) if (ftwbuf->depth == 0) { // Compute the name offset for root paths like "foo/bar" - ftwbuf->nameoff = basename_offset(ftwbuf->path); + ftwbuf->nameoff = xbasename(ftwbuf->path) - ftwbuf->path; } ftwbuf->typeflag = BFTW_UNKNOWN; -- cgit v1.2.3