Skip to content

Commit

Permalink
minor bugfixes, ^C in edit line handling, protect against repeated re…
Browse files Browse the repository at this point in the history
…ading of history file
  • Loading branch information
okbob committed Jul 22, 2021
1 parent 7606e73 commit 92b92f5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ static char *readline_prompt;
static int tabcomplete_mode;
static const char **possible_tokens = NULL;

static bool readline_initized = false;

#ifdef HAVE_READLINE_HISTORY

static char last_history[256];
Expand Down Expand Up @@ -533,6 +535,7 @@ get_string(char *prompt,
*/
if (!history_loaded)
{
log_row("history loaded");
read_history(tilde(NULL, saved_histfile));
history_loaded = true;

Expand Down Expand Up @@ -633,11 +636,11 @@ get_string(char *prompt,
wrefresh(prompt_window);
}

else if (handle_sigint)
goto finish_read;

continue;
}

if (handle_sigint)
goto finish_read;
}
while (c == ERR || c == 0);

Expand Down Expand Up @@ -752,6 +755,14 @@ get_string(char *prompt,
void
pspg_init_readline(const char *histfile)
{
/*
* Don't repeat readline initialization
*/
if (readline_initized)
return;

readline_initized = true;

rl_catch_signals = 0;
rl_catch_sigwinch = 0;
rl_deprep_term_function = NULL;
Expand Down

0 comments on commit 92b92f5

Please sign in to comment.