]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Disallow trailing whitespace in docstrings
authorTom Tromey <tromey@adacore.com>
Wed, 17 Apr 2024 14:04:59 +0000 (08:04 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 14 May 2024 19:23:37 +0000 (13:23 -0600)
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.

gdb/breakpoint.c
gdb/cris-tdep.c
gdb/infcmd.c
gdb/macrocmd.c
gdb/reverse.c
gdb/skip.c
gdb/typeprint.c
gdb/unittests/command-def-selftests.c

index b321baeb3bebb872edf90ddc201f7a56ae38ffdf..5653842ce76bd36e453ad6502a13b7257f1736d7 100644 (file)
@@ -14598,7 +14598,7 @@ command" [PROBE_MODIFIER] [LOCATION] [thread THREADNUM]\n\
 \t[-force-condition] [if CONDITION]\n\
 PROBE_MODIFIER shall be present if the command is to be placed in a\n\
 probe point.  Accepted values are `-probe' (for a generic, automatically\n\
-guessed probe type), `-probe-stap' (for a SystemTap probe) or \n\
+guessed probe type), `-probe-stap' (for a SystemTap probe) or\n\
 `-probe-dtrace' (for a DTrace probe).\n\
 LOCATION may be a linespec, address, or explicit location as described\n\
 below.\n\
@@ -15029,7 +15029,7 @@ Do \"help tracepoints\" for info on other tracepoint commands."));
 Set a static tracepoint at location or marker.\n\
 \n\
 strace [LOCATION] [if CONDITION]\n\
-LOCATION may be a linespec, explicit, or address location (described below) \n\
+LOCATION may be a linespec, explicit, or address location (described below)\n\
 or -m MARKER_ID.\n\n\
 If a marker id is specified, probe the marker with that name.  With\n\
 no LOCATION, uses current execution address of the selected stack frame.\n\
index 4c8ae77cc86de9459ee7f17599d1a02b4f09b97c..692aa9ac5477b8d178b922f37af5b839f553e49f 100644 (file)
@@ -3829,7 +3829,7 @@ _initialize_cris_tdep ()
                             _("Show the current CRIS version."),
                             _("\
 Set to 10 for CRISv10 or 32 for CRISv32 if autodetection fails.\n\
-Defaults to 10. "),
+Defaults to 10."),
                             set_cris_version,
                             NULL, /* FIXME: i18n: Current CRIS version
                                      is %s.  */
index 0309658690c1c4c3670455d52edb8b19f29e56fc..09b8d3941156fcf768e52b599efbe119baeed621 100644 (file)
@@ -3077,7 +3077,7 @@ shell that will start the program (specified by the \"$SHELL\" environment\n\
 variable).  Input and output redirection with \">\", \"<\", or \">>\"\n\
 are also allowed.\n\
 \n\
-With no arguments, uses arguments last specified (with \"run\" or \n\
+With no arguments, uses arguments last specified (with \"run\" or\n\
 \"set args\").  To cancel previous arguments and run with no arguments,\n\
 use \"set args\" without arguments.\n\
 \n\
@@ -3303,7 +3303,7 @@ which means to set the ignore count of that breakpoint to N - 1 (so that\n\
 the breakpoint won't break until the Nth time it is reached).\n\
 \n\
 If non-stop mode is enabled, continue only the current thread,\n\
-otherwise all the threads in the program are continued.  To \n\
+otherwise all the threads in the program are continued.  To\n\
 continue all stopped threads in non-stop mode, use the -a option.\n\
 Specifying -a and an ignore count simultaneously is an error."));
   add_com_alias ("c", continue_cmd, class_run, 1);
@@ -3329,7 +3329,7 @@ RUN_ARGS_HELP));
   add_com ("interrupt", class_run, interrupt_command,
           _("Interrupt the execution of the debugged program.\n\
 If non-stop mode is enabled, interrupt only the current thread,\n\
-otherwise all the threads in the program are stopped.  To \n\
+otherwise all the threads in the program are stopped.  To\n\
 interrupt all running threads in non-stop mode, use the -a option."));
 
   cmd_list_element *info_registers_cmd
index bf7e43a8530f1df3edc81edb618b23b798bb1017..19295faf21ecf61e18fb553179c90829d90e13a8 100644 (file)
@@ -480,7 +480,7 @@ expression work together to yield a pre-processed expression."),
   add_info ("macro", info_macro_command,
            _("Show the definition of MACRO, and it's source location.\n\
 Usage: info macro [-a|-all] [--] MACRO\n\
-Options: \n\
+Options:\n\
   -a, --all    Output all definitions of MACRO in the current compilation\
  unit.\n\
   --           Specify the end of arguments and the beginning of the MACRO."));
index 11c76b4b33550b5dbc2f2ee8ae666b700d5306e8..ca11f83119bb41c2fa00dc7304f8777e242e90e0 100644 (file)
@@ -320,12 +320,12 @@ Execute backward until just before selected stack frame is called."));
 
   add_com ("bookmark", class_bookmark, save_bookmark_command, _("\
 Set a bookmark in the program's execution history.\n\
-A bookmark represents a point in the execution history \n\
+A bookmark represents a point in the execution history\n\
 that can be returned to at a later point in the debug session."));
   add_info ("bookmarks", info_bookmarks_command, _("\
 Status of user-settable bookmarks.\n\
-Bookmarks are user-settable markers representing a point in the \n\
-execution history that can be returned to later in the same debug \n\
+Bookmarks are user-settable markers representing a point in the\n\
+execution history that can be returned to later in the same debug\n\
 session."));
   add_cmd ("bookmark", class_bookmark, delete_bookmark_command, _("\
 Delete a bookmark from the bookmark list.\n\
@@ -334,7 +334,7 @@ Argument is a bookmark number or numbers,\n\
           &deletelist);
   add_com ("goto-bookmark", class_bookmark, goto_bookmark_command, _("\
 Go to an earlier-bookmarked point in the program's execution history.\n\
-Argument is the bookmark number of a bookmark saved earlier by using \n\
+Argument is the bookmark number of a bookmark saved earlier by using\n\
 the 'bookmark' command, or the special arguments:\n\
   start (beginning of recording)\n\
   end   (end of recording)"));
index 4dff5c5a9e5fa9de0468d35473c5040eb1443e20..72f4efd0e2988edb4d83ec9c762dcd2e040c52ea 100644 (file)
@@ -723,7 +723,7 @@ If you don't specify any numbers or ranges, we'll delete all skip entries."),
   add_info ("skip", info_skip_command, _("\
 Display the status of skips.\n\
 Usage: info skip [NUMBER | RANGES]...\n\
-You can specify numbers (e.g. \"info skip 1 3\"), \n\
+You can specify numbers (e.g. \"info skip 1 3\"),\n\
 ranges (e.g. \"info skip 4-8\"), or both (e.g. \"info skip 1 3 4-8\").\n\n\
 If you don't specify any numbers or ranges, we'll show all skips."));
   set_cmd_completer (c, complete_skip_number);
index ccc621ffd54470ca51f93067f3acd007bc7faa70..2e1c5ea81e73d0173238aef15107475fc1fc103c 100644 (file)
@@ -843,7 +843,7 @@ Available FLAGS are:\n\
   /x    use hexadecimal notation when displaying sizes and offsets\n\
        of struct members\n\
   /d    use decimal notation when displaying sizes and offsets\n\
-       of struct members "));
+       of struct members"));
   set_cmd_completer (c, expression_completer);
 
   c = add_com ("whatis", class_vars, whatis_command,
index 6936af740fc40e62f92bf1e1a4140ee65bf79c9b..6a9b194e6804320153859df66be284c0f73e54ae 100644 (file)
@@ -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