vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit cbaa24a340a7a62995feff4c46be668db6c66ac9 parent 497097aa669697886ccdce65d41a89bdb21ff64d Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 7 Jun 2017 09:45:28 +0200 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. Diffstat:
| M | vis.c | | | 4 | +++- |
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git 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);