aboutsummaryrefslogtreecommitdiff
path: root/gdb/unittests
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-04-17 08:04:59 -0600
committerTom Tromey <tromey@adacore.com>2024-05-14 13:23:37 -0600
commitbe2a6a5803e575db62a1c27e022cb596d237181a (patch)
tree1543e663647730b84d86353eaf88b42874e20cec /gdb/unittests
parent0a6b9eefc211bc6af718d65adb260c056f3c6659 (diff)
downloadgdb-be2a6a5803e575db62a1c27e022cb596d237181a.zip
gdb-be2a6a5803e575db62a1c27e022cb596d237181a.tar.gz
gdb-be2a6a5803e575db62a1c27e022cb596d237181a.tar.bz2
Disallow trailing whitespace in docstrings
This patch changes the docstring self-test to verify that there is no trailing whitespace at the end of lines. A few existing docstrings had to be updated.
Diffstat (limited to 'gdb/unittests')
-rw-r--r--gdb/unittests/command-def-selftests.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c
index 6936af7..6a9b194 100644
--- a/gdb/unittests/command-def-selftests.c
+++ b/gdb/unittests/command-def-selftests.c
@@ -73,10 +73,25 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix)
"first line is not terminated with a '.' character");
/* Checks the doc is not terminated with a new line. */
- if (c->doc[strlen (c->doc) - 1] == '\n')
+ if (isspace (c->doc[strlen (c->doc) - 1]))
broken_doc_invariant
(prefix, c->name,
- "has a superfluous trailing end of line");
+ "has superfluous trailing whitespace");
+
+ for (const char *nl = strchr (c->doc, '\n');
+ nl != nullptr;
+ nl = strchr (nl + 1, '\n'))
+ {
+ if (nl == c->doc)
+ broken_doc_invariant (prefix, c->name, "has a leading newline");
+ else
+ {
+ /* \n\n is ok, so we check that explicitly here. */
+ if (isspace (nl[-1]) && nl[-1] != '\n')
+ broken_doc_invariant (prefix, c->name,
+ "has whitespace before a newline");
+ }
+ }
/* Check if this command has subcommands and is not an
abbreviation. We skip checking subcommands of abbreviations