static void
xstrlcpy(char *dest, const char *src, size_t n)
{
- while (--n && (*dest++ = *src++))
- ;
+ while (--n && (*dest = *src))
+ ++dest, ++src;
+
if (!n)
*dest = '\0';
}
p = (unsigned char *)s + n - 1;
- while (n--)
- if ((*p--) == ch)
- return ++p;
+ while (n) {
+ if (*p == ch)
+ return p;
+
+ --p;
+ --n;
+ }
return NULL;
}
int count = 0;
- while (*ptr == '.') {
- count++;
- ptr++;
- }
+ while (*ptr == '.')
+ ++count, ++ptr;
if (*ptr)
return 0;
c1 = s1;
while (isspace(*c1))
- c1++;
+ ++c1;
if (*c1 == '-' || *c1 == '+')
- c1++;
+ ++c1;
while (*c1 >= '0' && *c1 <= '9')
- c1++;
+ ++c1;
c2 = s2;
while (isspace(*c2))
- c2++;
+ ++c2;
if (*c2 == '-' || *c2 == '+')
- c2++;
+ ++c2;
while (*c2 >= '0' && *c2 <= '9')
- c2++;
+ ++c2;
if (*c1 == '\0' && *c2 == '\0') {
static long long num1, num2;
return 1;
while (*s2 && *s1 && TOUPPER(*s1) == TOUPPER(*s2))
- s1++, s2++;
+ ++s1, ++s2;
/* In case of alphabetically same names, make sure
* lower case one comes before upper case one
size_t len = strlen(s) - 1;
while (len != 0 && (isspace(s[len]) || s[len] == '/'))
- len--;
+ --len;
s[len + 1] = '\0';
while (*s && isspace(*s))
- s++;
+ ++s;
return s;
}
unsigned int i;
static unsigned int len = LEN(assocs);
- for (i = 0; i < len; i++) {
+ for (i = 0; i < len; ++i) {
if (regcomp(®ex, assocs[i].regex,
REG_NOSUB | REG_EXTENDED | REG_ICASE) != 0)
continue;
*presel = 0;
if (c == -1)
- idle++;
+ ++idle;
else
idle = 0;
- for (i = 0; i < len; i++)
+ for (i = 0; i < len; ++i)
if (c == bindings[i].sym) {
*run = bindings[i].run;
*env = bindings[i].env;
{
static int count;
- for (count = 0; count < ndents; count++) {
+ for (count = 0; count < ndents; ++count) {
if (filter(re, (*dents)[count].name) == 0) {
if (count != --ndents) {
static struct entry _dent;
(*dents)[ndents].size = _dent.size;
(*dents)[ndents].bsize = _dent.bsize;
- count--;
+ --count;
}
continue;
case CONTROL('Q'):
goto end;
default:
- wln[len++] = (wchar_t)*ch;
+ wln[len] = (wchar_t)*ch;
+ ++len;
wln[len] = '\0';
wcstombs(ln, wln, LINE_MAX << 2);
ndents = total;
while (*bms && i < MAX_BM) {
bookmark[i].key = bms;
- bms++;
+ ++bms;
while (*bms && *bms != ':')
- bms++;
+ ++bms;
if (!*bms) {
bookmark[i].key = NULL;
}
while (*bms && *bms != ';')
- bms++;
+ ++bms;
if (*bms)
*bms = '\0';
else
break;
- bms++;
- i++;
+ ++bms;
+ ++i;
}
}
if (*buf <= '\x1f' || *buf == '\x7f')
*buf = '\?';
- buf++;
+ ++buf;
}
/* Convert wide char to multi-byte */
tmp = size;
size >>= 10;
rem = tmp - (size << 10);
- i++;
+ ++i;
}
snprintf(size_buf, 12, "%.*Lf%s", i, size + rem * div_2_pow_10, U[i]);
begin = p + 1;
}
- p++;
+ ++p;
}
dprintf(fd, " %s", begin);
}
if (getenv("NNN_BMS")) {
dprintf(fd, "BOOKMARKS\n");
- for (; i < MAX_BM; i++)
+ for (; i < MAX_BM; ++i)
if (bookmark[i].key)
dprintf(fd, " %s: %s\n",
bookmark[i].key, bookmark[i].loc);
(*dents)[n].bsize = sb.st_blocks;
}
- n++;
+ ++n;
}
if (bsizeorder) {
p = basename(path);
DPRINTF_S(p);
- for (i = 0; i < n; i++)
+ for (i = 0; i < n; ++i)
if (strcmp(p, dents[i].name) == 0)
return i;
erase();
/* Strip trailing slashes */
- for (i = strlen(path) - 1; i > 0; i--)
+ for (i = strlen(path) - 1; i > 0; --i)
if (path[i] == '/')
path[i] = '\0';
else
/* Print listing */
if (cur < (nlines >> 1)) {
- for (i = 0; i < nlines; i++)
+ for (i = 0; i < nlines; ++i)
printptr(&dents[i], i == cur);
} else if (cur >= ndents - (nlines >> 1)) {
- for (i = ndents - nlines; i < ndents; i++)
+ for (i = ndents - nlines; i < ndents; ++i)
printptr(&dents[i], i == cur);
} else {
static int odd;
odd = ISODD(nlines);
nlines >>= 1;
- for (i = cur - nlines; i < cur + nlines + odd; i++)
+ for (i = cur - nlines; i < cur + nlines + odd; ++i)
printptr(&dents[i], i == cur);
}
break;
case SEL_NEXT:
if (cur < ndents - 1)
- cur++;
+ ++cur;
else if (ndents)
/* Roll over, set cursor to first entry */
cur = 0;
break;
case SEL_PREV:
if (cur > 0)
- cur--;
+ --cur;
else if (ndents)
/* Roll over, set cursor to last entry */
cur = ndents - 1;
break;
}
- r--;
+ --r;
dir = path;
- for (fd = 0; fd < r; fd++) {
+ for (fd = 0; fd < r; ++fd) {
/* Reached / ? */
if (path[0] == '/' && path[1] == '\0') {
/* If it's a cd .. at / */
clearprompt();
- for (r = 0; bookmark[r].key && r < MAX_BM; r++) {
+ for (r = 0; bookmark[r].key && r < MAX_BM; ++r) {
if (strcmp(bookmark[r].key, tmp) == 0) {
if (bookmark[r].loc[0] == '~') {
/* Expand ~ to HOME */