public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Constify command_line_input
@ 2019-11-08 14:05 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2019-11-08 14:05 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=992a70401ec229425ee75b2ad9b731f30d2de391

commit 992a70401ec229425ee75b2ad9b731f30d2de391
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Oct 22 13:32:39 2019 -0600

    Constify command_line_input
    
    This changes command_line_input to return a "const char *", which is
    appropriate because the memory is owned by command_line_input.  Then
    it fixes up the users.
    
    I looked at making command_line_input transfer ownership to its caller
    instead, but this is complicated due to the way read_next_line is
    called, so I decided against it.
    
    Tested by rebuilding.
    
    gdb/ChangeLog
    2019-11-08  Tom Tromey  <tromey@adacore.com>
    
    	* top.c (read_command_file): Update.
    	(command_line_input): Make return type const.
    	* python/py-gdb-readline.c: Update.
    	* linespec.c (decode_line_2): Update.
    	* defs.h (command_line_input): Make return type const.
    	* cli/cli-script.c (read_next_line): Make return type const.
    	* ada-lang.c (get_selections): Update.
    
    Change-Id: I27e6c9477fd1005ab5b16e0d337e4c015b6e6248

Diff:
---
 gdb/ChangeLog                | 10 ++++++++++
 gdb/ada-lang.c               |  2 +-
 gdb/cli/cli-script.c         |  6 +++---
 gdb/defs.h                   |  2 +-
 gdb/linespec.c               |  2 +-
 gdb/python/py-gdb-readline.c |  3 ++-
 gdb/top.c                    |  4 ++--
 7 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f43d3a5..f5c8a76 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2019-11-08  Tom Tromey  <tromey@adacore.com>
+
+	* top.c (read_command_file): Update.
+	(command_line_input): Make return type const.
+	* python/py-gdb-readline.c: Update.
+	* linespec.c (decode_line_2): Update.
+	* defs.h (command_line_input): Make return type const.
+	* cli/cli-script.c (read_next_line): Make return type const.
+	* ada-lang.c (get_selections): Update.
+
 2019-11-06  Christian Biesinger  <cbiesinger@google.com>
 
 	* linux-tdep.c (linux_info_proc): Use strtok_r instead of strtok.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 0bddc9e..2935df5 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3273,7 +3273,7 @@ static int
 get_selections (int *choices, int n_choices, int max_results,
                 int is_all_choice, const char *annotation_suffix)
 {
-  char *args;
+  const char *args;
   const char *prompt;
   int n_chosen;
   int first_choice = is_all_choice ? 2 : 1;
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 8abd48c..316aca0 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -50,7 +50,7 @@ recurse_read_control_structure
 static void do_define_command (const char *comname, int from_tty,
 			       const counted_command_line *commands);
 
-static char *read_next_line (void);
+static const char *read_next_line ();
 
 /* Level of control structure when reading.  */
 static int control_level;
@@ -890,8 +890,8 @@ user_args::insert_args (const char *line) const
    recurse_read_control_structure whenever we need to read commands
    from stdin.  */
 
-static char *
-read_next_line (void)
+static const char *
+read_next_line ()
 {
   struct ui *ui = current_ui;
   char *prompt_ptr, control_prompt[256];
diff --git a/gdb/defs.h b/gdb/defs.h
index f12ba36..5d68be2 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -306,7 +306,7 @@ typedef void initialize_file_ftype (void);
 
 extern char *gdb_readline_wrapper (const char *);
 
-extern char *command_line_input (const char *, const char *);
+extern const char *command_line_input (const char *, const char *);
 
 extern void print_prompt (void);
 
diff --git a/gdb/linespec.c b/gdb/linespec.c
index fdbb670..9b7a8c9 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1489,7 +1489,7 @@ decode_line_2 (struct linespec_state *self,
 	       std::vector<symtab_and_line> *result,
 	       const char *select_mode)
 {
-  char *args;
+  const char *args;
   const char *prompt;
   int i;
   std::vector<const char *> filters;
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
index ec4ff9e..dcf3b83 100644
--- a/gdb/python/py-gdb-readline.c
+++ b/gdb/python/py-gdb-readline.c
@@ -37,7 +37,8 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
 #endif
 {
   int n;
-  char *p = NULL, *q;
+  const char *p = NULL;
+  char *q;
 
   try
     {
diff --git a/gdb/top.c b/gdb/top.c
index a443159..08c7425 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -420,7 +420,7 @@ read_command_file (FILE *stream)
 
   while (ui->instream != NULL && !feof (ui->instream))
     {
-      char *command;
+      const char *command;
 
       /* Get a command-line.  This calls the readline package.  */
       command = command_line_input (NULL, NULL);
@@ -1210,7 +1210,7 @@ gdb_safe_append_history (void)
    This routine either uses fancy command line editing or simple input
    as the user has requested.  */
 
-char *
+const char *
 command_line_input (const char *prompt_arg, const char *annotation_suffix)
 {
   static struct buffer cmd_line_buffer;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-08 14:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 14:05 [binutils-gdb] Constify command_line_input Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).