From 0df87384ac791bbf85cf4b3d386fb851e5b87de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 7 Jun 2017 09:45:28 +0200 Subject: vis: strip double leading slashes of paths This fixes the internal representation as well as the path displayed in the status bar. Previously opening a file in the root directory e.g. /foo would be display as //foo. --- vis.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vis.c b/vis.c index dc2c984..b689e6f 100644 --- a/vis.c +++ b/vis.c @@ -160,8 +160,10 @@ static char *absolute_path(const char *name) { char *base = basename(copy2); if (!(path_absolute = realpath(dir, NULL))) goto err; + if (strcmp(path_absolute, "/") == 0) + path_absolute[0] = '\0'; - snprintf(path_normalized, sizeof(path_normalized)-1, "%s/%s", + snprintf(path_normalized, sizeof(path_normalized), "%s/%s", path_absolute, base); err: free(copy1); -- cgit v1.2.3