Skip to content

Commit

Permalink
Fix #1877: use dprintf() instead of write()
Browse files Browse the repository at this point in the history
  • Loading branch information
jarun committed May 6, 2024
1 parent be6988d commit 5513760
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -5197,25 +5197,21 @@ static void show_help(const char *path)
get_output(prog, NULL, NULL, fd, FALSE);

bool hex = true;
const char space = ' ';
const char *end = helpstr + (sizeof helpstr - 1);
const char *end = helpstr + sizeof(helpstr) - 1;

for (const char *s = helpstr; s < end; ++s) {
if (hex) {
for (int k = 0, n = xchartohex(*s); k < n; ++k)
if (write(fd, &space, 1) != 1)
break;
dprintf(fd, " ");
} else if (*s == '%') {
int n = ((s[1] - '0') * 10) + (s[2] - '0');
for (int k = 0; k < n; ++k)
if (write(fd, &space, 1) != 1)
break;
dprintf(fd, " ");
s += 2;
} else {
if (write(fd, s, 1) != 1)
break;
dprintf(fd, "%c", *s);
}
hex = *s == '\n';
hex = (*s == '\n');
}

dprintf(fd, "\nLOCATIONS\n");
Expand Down

0 comments on commit 5513760

Please sign in to comment.