]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove init_cli_cmds
authorTom Tromey <tromey@adacore.com>
Thu, 11 Jul 2019 14:54:17 +0000 (08:54 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 11 Jul 2019 16:28:27 +0000 (10:28 -0600)
I noticed that init_cli_cmds only installs a command, and so doesn't
need to be handled specially.  This patch merges it into
_initialize_cli_cmds.

The help text is constructed dynamically, which is sometimes an
indication that special treatment is needed; but in this case it is
just to insert the value of "gdbinit", which is created at
compile-time and not modified; so this doesn't affect the result.

This version also removes the "gdbinit" global.  There's no need for
it, as GDBINIT can be used instead.  Note, though, that the help text
in question must still be dynamically constructed, in order to be
i18n-friendly.

gdb/ChangeLog
2019-07-11  Tom Tromey  <tromey@adacore.com>

* main.c (get_init_files): Use GDBINIT, not gdbinit.
* auto-load.c (file_is_auto_load_safe): Use GDBINIT, not gdbinit.
* top.h (gdbinit): Don't declare.
* cli/cli-cmds.c (init_cli_cmds): Remove, merging contents
into...
(_initialize_cli_cmds): ...here.  Use GDBINIT, not gdbinit.
* top.c (gdb_init): Don't call init_cli_cmds.
(gdbinit): Remove.
* cli/cli-cmds.h (init_cli_cmds): Don't declare.

gdb/ChangeLog
gdb/auto-load.c
gdb/cli/cli-cmds.c
gdb/cli/cli-cmds.h
gdb/main.c
gdb/top.c
gdb/top.h

index b5585b4085a284b73a3b9640012579cd1c1f1e34..90da3d42c1d4c0f5fa427ee913d60e34598d2ba8 100644 (file)
@@ -1,3 +1,15 @@
+2019-07-11  Tom Tromey  <tromey@adacore.com>
+
+       * main.c (get_init_files): Use GDBINIT, not gdbinit.
+       * auto-load.c (file_is_auto_load_safe): Use GDBINIT, not gdbinit.
+       * top.h (gdbinit): Don't declare.
+       * cli/cli-cmds.c (init_cli_cmds): Remove, merging contents
+       into...
+       (_initialize_cli_cmds): ...here.  Use GDBINIT, not gdbinit.
+       * top.c (gdb_init): Don't call init_cli_cmds.
+       (gdbinit): Remove.
+       * cli/cli-cmds.h (init_cli_cmds): Don't declare.
+
 2019-07-11  Tom Tromey  <tromey@adacore.com>
 
        * python/py-inferior.c (add_thread_object): Don't use thread_obj
index 7e417994e8f17a9a67cec5312c9149f513916c0f..616aeb6fc96a5988e26d05a20a74d844010fe248 100644 (file)
@@ -500,7 +500,7 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
 
       if (homedir == NULL)
        homedir = "$HOME";
-      std::string homeinit = string_printf ("%s/%s", homedir, gdbinit);
+      std::string homeinit = string_printf ("%s/%s", homedir, GDBINIT);
 
       printf_filtered (_("\
 To enable execution of this file add\n\
index e689c0ff64edaa8a2ee0456609b204478dedfcd8..0b62622e888b4471463a332a1116a653ec9017e0 100644 (file)
@@ -2215,15 +2215,8 @@ Make \"spe\" an alias of \"set print elements\":\n\
   alias spe = set print elements\n\
 Make \"elms\" an alias of \"elements\" in the \"set print\" command:\n\
   alias -a set print elms = set print elements"));
-}
-
-void
-init_cli_cmds (void)
-{
-  struct cmd_list_element *c;
-  char *source_help_text;
 
-  source_help_text = xstrprintf (_("\
+  const char *source_help_text = xstrprintf (_("\
 Read commands from a file named FILE.\n\
 \n\
 Usage: source [-s] [-v] FILE\n\
@@ -2232,7 +2225,7 @@ Usage: source [-s] [-v] FILE\n\
 -v: each command in FILE is echoed as it is executed.\n\
 \n\
 Note that the file \"%s\" is read automatically in this way\n\
-when GDB is started."), gdbinit);
+when GDB is started."), GDBINIT);
   c = add_cmd ("source", class_support, source_command,
               source_help_text, &cmdlist);
   set_cmd_completer (c, filename_completer);
index ac0591e2e894e94113a759bf0594c93cdda1f6bc..5bfffde04a105e911e245e4d1eab45b29c7a0c08 100644 (file)
@@ -105,8 +105,6 @@ extern struct cmd_list_element *showchecklist;
 
 void init_cmd_lists (void);
 
-void init_cli_cmds (void);
-
 int is_complete_command (struct cmd_list_element *cmd);
 
 /* Exported to gdb/main.c */
index 540738e543d5e0b77126a7d2bd04ce2b72ae0254..678c413021c7db30149f28c028c289ced2c1861d 100644 (file)
@@ -260,7 +260,7 @@ get_init_files (const char **system_gdbinit,
 
       if (homedir)
        {
-         homeinit = xstrprintf ("%s/%s", homedir, gdbinit);
+         homeinit = xstrprintf ("%s/%s", homedir, GDBINIT);
          if (stat (homeinit, &homebuf) != 0)
            {
              xfree (homeinit);
@@ -268,12 +268,12 @@ get_init_files (const char **system_gdbinit,
            }
        }
 
-      if (stat (gdbinit, &cwdbuf) == 0)
+      if (stat (GDBINIT, &cwdbuf) == 0)
        {
          if (!homeinit
              || memcmp ((char *) &homebuf, (char *) &cwdbuf,
                         sizeof (struct stat)))
-           localinit = gdbinit;
+           localinit = GDBINIT;
        }
       
       initialized = 1;
index 68cf405f6e063e95430b92033b7df325379c2a1b..83a3604688b1c952d4d412ed454401b6485825bf 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -108,10 +108,6 @@ gen_ret_current_ui_field_ptr (struct ui_file *, gdb_stderr)
 gen_ret_current_ui_field_ptr (struct ui_file *, gdb_stdlog)
 gen_ret_current_ui_field_ptr (struct ui_out *, current_uiout)
 
-/* Initialization file name for gdb.  This is host-dependent.  */
-
-const char gdbinit[] = GDBINIT;
-
 int inhibit_gdbinit = 0;
 
 extern char lang_frame_mismatch_warn[];                /* language.c */
@@ -2265,7 +2261,6 @@ gdb_init (char *argv0)
   initialize_progspace ();
   initialize_inferiors ();
   initialize_current_architecture ();
-  init_cli_cmds();
   init_main ();                        /* But that omits this file!  Do it now.  */
 
   initialize_stdin_serial ();
index e7659b65ffe4c619291d5fb5456546708ff85ae8..32a898b82f5b485d00dec93d72629378a541132d 100644 (file)
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -219,7 +219,6 @@ extern void ui_unregister_input_event_handler (struct ui *ui);
 /* From top.c.  */
 extern int confirm;
 extern int inhibit_gdbinit;
-extern const char gdbinit[];
 
 /* Print the GDB version banner to STREAM.  If INTERACTIVE is false,
    then information referring to commands (e.g., "show configuration")