From d6e05d83764ea447dcb92f19c2ade38a4cf26a2e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 17 Sep 2019 13:31:09 +0200 Subject: [PATCH] tweaks: simplify the determination of a canonical path Suggested-by: Brand Huntsman --- src/color.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/color.c b/src/color.c index da2b429f..188ded08 100644 --- a/src/color.c +++ b/src/color.c @@ -26,7 +26,6 @@ #include #endif #include -#include #ifdef ENABLE_COLOR @@ -192,17 +191,7 @@ void color_update(void) /* If no syntax-override string was specified, or it didn't match, * try finding a syntax based on the filename (extension). */ if (sint == NULL && !inhelp) { - char *reservation = charalloc(PATH_MAX + 1); - char *currentdir = getcwd(reservation, PATH_MAX + 1); - char *joinednames = charalloc(PATH_MAX + 1); - char *fullname = NULL; - - /* When the specified filename is not absolute, concatenate it - * with the working directory and canonicalize the result. */ - if (currentdir != NULL && openfile->filename[0] != '/') { - sprintf(joinednames, "%s/%s", currentdir, openfile->filename); - fullname = get_full_path(joinednames); - } + char *fullname = get_full_path(openfile->filename); if (fullname == NULL) fullname = mallocstrcpy(fullname, openfile->filename); @@ -213,8 +202,6 @@ void color_update(void) } free(fullname); - free(joinednames); - free(reservation); } /* If the filename didn't match anything, try the first line. */