aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-06-07 09:45:28 +0200
committerMarc André Tanner <mat@brain-dump.org>2017-06-15 15:50:33 +0200
commit0df87384ac791bbf85cf4b3d386fb851e5b87de4 (patch)
tree569580f3876aa7c5933ea0b382106360a051639d
parentf0c5bfe978c1ffe1024f0cf594c971f5bcc30630 (diff)
downloadvis-0df87384ac791bbf85cf4b3d386fb851e5b87de4.tar.gz
vis-0df87384ac791bbf85cf4b3d386fb851e5b87de4.tar.xz
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.
-rw-r--r--vis.c4
1 files changed, 3 insertions, 1 deletions
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);