From 55137600e0b88dc36644ef8fee43482c80ca9f63 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Mon, 6 May 2024 19:05:46 +0530 Subject: [PATCH] Fix #1877: use dprintf() instead of write() --- src/nnn.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/nnn.c b/src/nnn.c index 41303ce0..0334b5b7 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -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");