Fix broken statusbar when symlink name exceeds max cols

This commit is contained in:
Arun Prakash Jana 2021-08-15 19:11:04 +05:30
parent 7cbc79a5fc
commit 943a7c13ac
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -6037,7 +6037,7 @@ static bool set_time_type(int *presel)
static void statusbar(char *path) static void statusbar(char *path)
{ {
int i = 0, extnlen = 0; int i = 0, len = 0;
char *ptr; char *ptr;
pEntry pent = &pdents[cur]; pEntry pent = &pdents[cur];
@ -6051,8 +6051,8 @@ static void statusbar(char *path)
i = (int)(pent->nlen - 1); i = (int)(pent->nlen - 1);
ptr = xextension(pent->name, i); ptr = xextension(pent->name, i);
if (ptr) if (ptr)
extnlen = i - (ptr - pent->name); len = i - (ptr - pent->name);
if (!ptr || extnlen > 5 || extnlen < 2) if (!ptr || len > 5 || len < 2)
ptr = "\b"; ptr = "\b";
} else } else
ptr = "\b"; ptr = "\b";
@ -6106,16 +6106,14 @@ static void statusbar(char *path)
#endif #endif
if (S_ISLNK(pent->mode)) { if (S_ISLNK(pent->mode)) {
i = readlink(pent->name, g_buf, PATH_MAX); i = readlink(pent->name, g_buf, PATH_MAX);
addstr(coolsize(i >= 0 ? i : pent->size)); /* Show symlink size */ addstr(coolsize(i >= 0 ? i : pent->size)); /* Show symlink size */
if (i > 1) { /* Show symlink target */ if (i > 1) { /* Show symlink target */
g_buf[i] = '\0'; int y;
#ifdef ICONS_ENABLED
addstr(" "MD_ARROW_FORWARD);
#else
addstr(" ->"); addstr(" ->");
#endif getyx(stdscr, len, y);
i = MIN(i, xcols - y);
g_buf[i] = '\0';
addstr(g_buf); addstr(g_buf);
} }
} else { } else {