diff options
Diffstat (limited to 'callback.c')
-rw-r--r-- | callback.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -1,6 +1,6 @@ /* callback.c -- functions to use readline as an X `callback' mechanism. */ -/* Copyright (C) 1987-2017 Free Software Foundation, Inc. +/* Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. @@ -136,6 +136,8 @@ rl_callback_read_char (void) abort (); } + eof = 0; + memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t)); #if defined (HAVE_POSIX_SIGSETJMP) jcode = sigsetjmp (_rl_top_level, 0); @@ -147,6 +149,14 @@ rl_callback_read_char (void) (*rl_redisplay_function) (); _rl_want_redisplay = 0; memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t)); + + /* If we longjmped because of a timeout, handle it here. */ + if (RL_ISSTATE (RL_STATE_TIMEOUT)) + { + RL_SETSTATE (RL_STATE_DONE); + rl_done = 1; + } + CALLBACK_READ_RETURN (); } @@ -268,6 +278,13 @@ rl_callback_read_char (void) _rl_want_redisplay = 0; } + /* Make sure application hooks can see whether we saw EOF. */ + if (eof > 0) + { + rl_eof_found = eof; + RL_SETSTATE(RL_STATE_EOF); + } + if (rl_done) { line = readline_internal_teardown (eof); @@ -278,7 +295,8 @@ rl_callback_read_char (void) rl_clear_signals (); #endif in_handler = 0; - (*rl_linefunc) (line); + if (rl_linefunc) /* just in case */ + (*rl_linefunc) (line); /* If the user did not clear out the line, do it for him. */ if (rl_line_buffer[0]) |