From fba3b6d16c206882c3ccb98da38271cf36100629 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 3 Jun 2024 09:40:47 -0600 Subject: [PATCH] Ensure that help text fits in 80 columns This patch adds a new unit test that ensures that all help text wraps at 80 columns. --- gdb/unittests/command-def-selftests.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c index 6a9b194e680..cf51f0d275a 100644 --- a/gdb/unittests/command-def-selftests.c +++ b/gdb/unittests/command-def-selftests.c @@ -78,9 +78,10 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix) (prefix, c->name, "has superfluous trailing whitespace"); + const char *prev_start = c->doc; for (const char *nl = strchr (c->doc, '\n'); nl != nullptr; - nl = strchr (nl + 1, '\n')) + nl = strchr (prev_start, '\n')) { if (nl == c->doc) broken_doc_invariant (prefix, c->name, "has a leading newline"); @@ -91,8 +92,15 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix) broken_doc_invariant (prefix, c->name, "has whitespace before a newline"); } + + if (nl - prev_start > cli_help_line_length) + broken_doc_invariant (prefix, c->name, "has over-long line"); + prev_start = nl + 1; } + if (strlen (prev_start) > cli_help_line_length) + broken_doc_invariant (prefix, c->name, "has over-long line"); + /* Check if this command has subcommands and is not an abbreviation. We skip checking subcommands of abbreviations in order to avoid duplicates in the output. */