]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
more: move runtime usage output to a function
authorSami Kerola <kerolasa@iki.fi>
Wed, 18 Mar 2020 20:13:02 +0000 (20:13 +0000)
committerSami Kerola <kerolasa@iki.fi>
Sat, 28 Mar 2020 07:55:58 +0000 (07:55 +0000)
This change also removes a ghost prompt that was left in place when printing
help.  When looking old commits the output fluke has been around at least
since util-linux v2.2.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
text-utils/more.c

index f426b662692042cc84bcded991c9496b855ccefd..823aa8d946c18b5b1e393bce2ca6b30470428a8b 100644 (file)
@@ -1402,6 +1402,37 @@ static char *find_editor(void)
        return editor;
 }
 
+static void runtime_usage(void)
+{
+       fputs(_("Most commands optionally preceded by integer argument k.  "
+               "Defaults in brackets.\n"
+               "Star (*) indicates argument becomes new default.\n"), stdout);
+       puts("-------------------------------------------------------------------------------");
+       fprintf(stdout,
+               _
+               ("<space>                 Display next k lines of text [current screen size]\n"
+                "z                       Display next k lines of text [current screen size]*\n"
+                "<return>                Display next k lines of text [1]*\n"
+                "d or ctrl-D             Scroll k lines [current scroll size, initially 11]*\n"
+                "q or Q or <interrupt>   Exit from more\n"
+                "s                       Skip forward k lines of text [1]\n"
+                "f                       Skip forward k screenfuls of text [1]\n"
+                "b or ctrl-B             Skip backwards k screenfuls of text [1]\n"
+                "'                       Go to place where previous search started\n"
+                "=                       Display current line number\n"
+                "/<regular expression>   Search for kth occurrence of regular expression [1]\n"
+                "n                       Search for kth occurrence of last r.e [1]\n"
+                "!<cmd> or :!<cmd>       Execute <cmd> in a subshell\n"
+                "v                       Start up '%s' at current line\n"
+                "ctrl-L                  Redraw screen\n"
+                ":n                      Go to kth next file [1]\n"
+                ":p                      Go to kth previous file [1]\n"
+                ":f                      Display current file name and line number\n"
+                ".                       Repeat previous command\n"),
+               find_editor());
+       puts("-------------------------------------------------------------------------------");
+}
+
 /* Read a command and do it.  A command consists of an optional integer
  * argument followed by the command character.  Return the number of
  * lines to display in the next screenful.  If there is nothing more to
@@ -1610,34 +1641,8 @@ static int more_key_command(struct more_control *ctl, char *filename, FILE *f)
                case 'h':
                        if (ctl->no_scroll)
                                more_clear_screen(ctl);
-                       fputs(_("\n"
-                                 "Most commands optionally preceded by integer argument k.  "
-                                 "Defaults in brackets.\n"
-                                 "Star (*) indicates argument becomes new default.\n"), stdout);
-                       puts("---------------------------------------"
-                            "----------------------------------------");
-                       fprintf(stdout,
-                              _("<space>                 Display next k lines of text [current screen size]\n"
-                                "z                       Display next k lines of text [current screen size]*\n"
-                                "<return>                Display next k lines of text [1]*\n"
-                                "d or ctrl-D             Scroll k lines [current scroll size, initially 11]*\n"
-                                "q or Q or <interrupt>   Exit from more\n"
-                                "s                       Skip forward k lines of text [1]\n"
-                                "f                       Skip forward k screenfuls of text [1]\n"
-                                "b or ctrl-B             Skip backwards k screenfuls of text [1]\n"
-                                "'                       Go to place where previous search started\n"
-                                "=                       Display current line number\n"
-                                "/<regular expression>   Search for kth occurrence of regular expression [1]\n"
-                                "n                       Search for kth occurrence of last r.e [1]\n"
-                                "!<cmd> or :!<cmd>       Execute <cmd> in a subshell\n"
-                                "v                       Start up '%s' at current line\n"
-                                "ctrl-L                  Redraw screen\n"
-                                ":n                      Go to kth next file [1]\n"
-                                ":p                      Go to kth previous file [1]\n"
-                                ":f                      Display current file name and line number\n"
-                                ".                       Repeat previous command\n"), find_editor());
-                       puts("---------------------------------------"
-                            "----------------------------------------");
+                       kill_line(ctl);
+                       runtime_usage();
                        output_prompt(ctl, filename);
                        break;
                case 'v':       /* This case should go right before default */