diff options
Diffstat (limited to 'gdb/unittests')
-rw-r--r-- | gdb/unittests/command-def-selftests.c | 19 |
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 |