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
This commit is contained in:
Tom Tromey
2019-10-22 13:32:39 -06:00
parent 8a46e447a8
commit 992a70401e
7 changed files with 20 additions and 9 deletions

View File

@ -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];