From 8b3c897ae978c4460d8df779ebedc94b5e0d32b2 Mon Sep 17 00:00:00 2001 From: Stu Grossman Date: Mon, 28 Oct 1991 02:20:47 +0000 Subject: [PATCH] * main.c (initialize_history): Read history after reading all init files. --- gdb/ChangeLog | 5 +++++ gdb/main.c | 54 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cf279c0ade..93321877e2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +Sun Oct 27 18:18:39 1991 Stu Grossman (grossman at cygnus.com) + + * main.c (initialize_history): Read history after reading all + init files. + Sun Oct 27 14:09:25 1991 John Gilmore (gnu at cygnus.com) * buildsym.c: Break out initial malloc sizes. diff --git a/gdb/main.c b/gdb/main.c index 795e94a747..936879cf00 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -170,6 +170,7 @@ extern void init_malloc (); void free_command_lines (); char *gdb_readline (); char *command_line_input (); +static void initialize_history (); static void initialize_main (); static void initialize_cmd_lists (); static void init_signals (); @@ -211,7 +212,7 @@ char *baud_rate; #define HAVE_SIGSETMASK !defined (USG) #endif -#if !HAVE_SIGSETMASK +#if 0 == (HAVE_SIGSETMASK) #define sigsetmask(n) #endif @@ -677,6 +678,9 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); } free (cmdarg); + /* Read in the old history after all the command files have been read. */ + initialize_history(); + if (batch) { /* We have hit the end of the batch file. */ @@ -1993,13 +1997,40 @@ initialize_cmd_lists () unsethistlist = (struct cmd_list_element *) 0; } +/* Init the history buffer. Note that we are called after the init file(s) + * have been read so that the user can change the history file via his + * .gdbinit file (for instance). The GDBHISTFILE environment variable + * overrides all of this. + */ + +static void +initialize_history() +{ + char *tmpenv; + + if (tmpenv = getenv ("HISTSIZE")) + history_size = atoi (tmpenv); + else if (!history_size) + history_size = 256; + + stifle_history (history_size); + + if (tmpenv = getenv ("GDBHISTFILE")) + history_filename = savestring (tmpenv, strlen(tmpenv)); + else if (!history_filename) { + /* We include the current directory so that if the user changes + directories the file written will be the same as the one + that was read. */ + history_filename = concat (current_directory, "/.gdb_history", ""); + } + read_history (history_filename); +} + static void initialize_main () { struct cmd_list_element *c; - char *tmpenv; - #ifdef DEFAULT_PROMPT prompt = savestring (DEFAULT_PROMPT, strlen(DEFAULT_PROMPT)); #else @@ -2011,23 +2042,6 @@ initialize_main () history_expansion_p = 0; write_history_p = 0; - if (tmpenv = getenv ("HISTSIZE")) - history_size = atoi (tmpenv); - else - history_size = 256; - - stifle_history (history_size); - - if (tmpenv = getenv ("GDBHISTFILE")) - history_filename = savestring (tmpenv, strlen(tmpenv)); - else - /* We include the current directory so that if the user changes - directories the file written will be the same as the one - that was read. */ - history_filename = concat (current_directory, "/.gdb_history", ""); - - read_history (history_filename); - /* Setup important stuff for command line editing. */ rl_completion_entry_function = (int (*)()) symbol_completion_function; rl_completer_word_break_characters = gdb_completer_word_break_characters;