]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Ensure that help text fits in 80 columns
authorTom Tromey <tromey@adacore.com>
Mon, 3 Jun 2024 15:40:47 +0000 (09:40 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 11 Nov 2024 14:45:02 +0000 (07:45 -0700)
This patch adds a new unit test that ensures that all help text wraps
at 80 columns.

gdb/unittests/command-def-selftests.c

index 6a9b194e6804320153859df66be284c0f73e54ae..cf51f0d275ab799d2f205d46e1c9e6555bd04108 100644 (file)
@@ -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.  */