From 63a0e7afff271ac1b1df3309bbf35f52e4771419 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 12 Apr 2019 18:14:20 -0500 Subject: Make help text spacing consistent. --- lib/help.c | 2 +- scripts/config2help.c | 21 ++++++++++++++------- toys/other/help.c | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/help.c b/lib/help.c index d0185678..7b97e8b9 100644 --- a/lib/help.c +++ b/lib/help.c @@ -30,6 +30,6 @@ void show_help(FILE *out) i = toy_find(++s)-toy_list; } - fprintf(out, "%s", s); + fprintf(out, "%s\n", s); } } diff --git a/scripts/config2help.c b/scripts/config2help.c index edb1caea..0eff7087 100644 --- a/scripts/config2help.c +++ b/scripts/config2help.c @@ -479,7 +479,7 @@ int main(int argc, char *argv[]) struct double_list *dd; if (sym->help) { - int i; + int i, blank; char *s; strcpy(s = xmalloc(strlen(sym->name)+1), sym->name); @@ -489,21 +489,28 @@ int main(int argc, char *argv[]) free(s); dd = sym->help; + blank = 0; for (;;) { - i = sym->help_indent; // Trim leading whitespace s = dd->data; - while (isspace(*s) && i) { - s++; - i--; + i = sym->help_indent; + while (isspace(*s) && i--) s++; + + // Only one blank line between nonblank lines, not at start or end. + if (!*s) blank = 2; + else { + while (blank--) { + putchar('\\'); + putchar('n'); + } + blank = 1; } + for (i=0; s[i]; i++) { if (s[i] == '"' || s[i] == '\\') putchar('\\'); putchar(s[i]); } - putchar('\\'); - putchar('n'); dd = dd->next; if (dd == sym->help) break; } diff --git a/toys/other/help.c b/toys/other/help.c index f7d84817..6ce1b02e 100644 --- a/toys/other/help.c +++ b/toys/other/help.c @@ -61,7 +61,7 @@ void help_main(void) if (toys.optflags & FLAG_h) { xprintf("\nToybox command list\n\n

\n"); for (i=0; i < toys.toycount; i++) - xprintf("%s\n", toy_list[i].name, + xprintf("%s\n\n", toy_list[i].name, toy_list[i].name); xprintf("

\n"); } @@ -71,7 +71,7 @@ void help_main(void) else { memset(toybuf, '-', 78); memcpy(toybuf+3, toy_list[i].name, strlen(toy_list[i].name)); - printf("%s\n\n", toybuf); + printf("\n%s\n\n", toybuf); } do_help(toy_list+i); if (toys.optflags & FLAG_h) xprintf("\n"); -- cgit v1.2.3