diff options
author | sin <sin@2f30.org> | 2016-01-06 15:21:41 +0000 |
---|---|---|
committer | sin <sin@2f30.org> | 2016-01-06 15:22:21 +0000 |
commit | a7152012558006b0f0ffca633c8c90ff4ce9726d (patch) | |
tree | 279b2c10605d921a338a18c1adbcf0293ab84341 /noice.c | |
parent | 2d87145fa23f582baf9d057a295a007e5c0a873b (diff) | |
download | noice-a7152012558006b0f0ffca633c8c90ff4ce9726d.tar.gz |
Print the resolved path for cwd
Avoids weird things like /etc/.. when displaying cwd.
Also no need for cwd to be on the heap.
Diffstat (limited to 'noice.c')
-rw-r--r-- | noice.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -595,8 +595,9 @@ populate(void) void redraw(void) { + char cwd[PATH_MAX], cwdresolved[PATH_MAX]; + size_t ncols; int nlines, odd; - char *cwd; int i; nlines = MIN(LINES - 4, n); @@ -615,11 +616,14 @@ redraw(void) DPRINTF_S(path); /* No text wrapping in cwd line */ - cwd = xmalloc(COLS * sizeof(char)); - strlcpy(cwd, path, COLS * sizeof(char)); - cwd[COLS - strlen(CWD) - 1] = '\0'; - - printw(CWD "%s\n\n", cwd); + ncols = COLS; + if (ncols > PATH_MAX) + ncols = PATH_MAX; + strlcpy(cwd, path, ncols); + cwd[ncols - strlen(CWD) - 1] = '\0'; + realpath(cwd, cwdresolved); + + printw(CWD "%s\n\n", cwdresolved); /* Print listing */ odd = ISODD(nlines); |