Rename global `n` to `ndents`

This is more descriptive for a global variable which
can easily be shadowed.
This commit is contained in:
sin 2016-02-10 15:16:19 +00:00
parent 414ea845bb
commit 872a0f4620
1 changed files with 16 additions and 16 deletions

32
noice.c
View File

@ -80,7 +80,7 @@ struct entry {
/* Global context */ /* Global context */
struct entry *dents; struct entry *dents;
int n, cur; int ndents, cur;
char path[PATH_MAX], oldpath[PATH_MAX]; char path[PATH_MAX], oldpath[PATH_MAX];
char fltr[LINE_MAX]; char fltr[LINE_MAX];
int idle; int idle;
@ -506,15 +506,15 @@ populate(void)
dentfree(dents); dentfree(dents);
n = 0; ndents = 0;
dents = NULL; dents = NULL;
n = dentfill(path, &dents, visible, &re); ndents = dentfill(path, &dents, visible, &re);
qsort(dents, n, sizeof(*dents), entrycmp); qsort(dents, ndents, sizeof(*dents), entrycmp);
/* Find cur from history */ /* Find cur from history */
cur = dentfind(dents, n, path, oldpath); cur = dentfind(dents, ndents, path, oldpath);
return 0; return 0;
} }
@ -526,7 +526,7 @@ redraw(void)
int nlines, odd; int nlines, odd;
int i; int i;
nlines = MIN(LINES - 4, n); nlines = MIN(LINES - 4, ndents);
/* Clean screen */ /* Clean screen */
erase(); erase();
@ -556,8 +556,8 @@ redraw(void)
if (cur < nlines / 2) { if (cur < nlines / 2) {
for (i = 0; i < nlines; i++) for (i = 0; i < nlines; i++)
printent(&dents[i], i == cur); printent(&dents[i], i == cur);
} else if (cur >= n - nlines / 2) { } else if (cur >= ndents - nlines / 2) {
for (i = n - nlines; i < n; i++) for (i = ndents - nlines; i < ndents; i++)
printent(&dents[i], i == cur); printent(&dents[i], i == cur);
} else { } else {
for (i = cur - nlines / 2; for (i = cur - nlines / 2;
@ -610,7 +610,7 @@ nochange:
goto begin; goto begin;
case SEL_GOIN: case SEL_GOIN:
/* Cannot descend in empty directories */ /* Cannot descend in empty directories */
if (n == 0) if (ndents == 0)
goto nochange; goto nochange;
mkpath(path, dents[cur].name, newpath, sizeof(newpath)); mkpath(path, dents[cur].name, newpath, sizeof(newpath));
@ -668,11 +668,11 @@ nochange:
strlcpy(fltr, tmp, sizeof(fltr)); strlcpy(fltr, tmp, sizeof(fltr));
DPRINTF_S(fltr); DPRINTF_S(fltr);
/* Save current */ /* Save current */
if (n > 0) if (ndents > 0)
mkpath(path, dents[cur].name, oldpath, sizeof(oldpath)); mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
goto begin; goto begin;
case SEL_NEXT: case SEL_NEXT:
if (cur < n - 1) if (cur < ndents - 1)
cur++; cur++;
break; break;
case SEL_PREV: case SEL_PREV:
@ -680,8 +680,8 @@ nochange:
cur--; cur--;
break; break;
case SEL_PGDN: case SEL_PGDN:
if (cur < n - 1) if (cur < ndents - 1)
cur += MIN((LINES - 4) / 2, n - 1 - cur); cur += MIN((LINES - 4) / 2, ndents - 1 - cur);
break; break;
case SEL_PGUP: case SEL_PGUP:
if (cur > 0) if (cur > 0)
@ -691,7 +691,7 @@ nochange:
cur = 0; cur = 0;
break; break;
case SEL_END: case SEL_END:
cur = n - 1; cur = ndents - 1;
break; break;
case SEL_CD: case SEL_CD:
/* Read target dir */ /* Read target dir */
@ -714,12 +714,12 @@ nochange:
case SEL_MTIME: case SEL_MTIME:
mtimeorder = !mtimeorder; mtimeorder = !mtimeorder;
/* Save current */ /* Save current */
if (n > 0) if (ndents > 0)
mkpath(path, dents[cur].name, oldpath, sizeof(oldpath)); mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
goto begin; goto begin;
case SEL_REDRAW: case SEL_REDRAW:
/* Save current */ /* Save current */
if (n > 0) if (ndents > 0)
mkpath(path, dents[cur].name, oldpath, sizeof(oldpath)); mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
goto begin; goto begin;
case SEL_RUN: case SEL_RUN: