1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

readline only handles SIGWINCH

* acinclude.m4 (GUILE_READLINE): Check for rl_catch_signals and
  rl_catch_sigwinch.

* guile-readline/readline.c (scm_init_readline): If we can, turn off
  readline's signal handling, because we can do our own.
  (scm_readline): Use dynwinds to handle resetting readline's state on
  nonlocal exit, not catches.
  (unwind_readline): Rename from handle_error.
This commit is contained in:
Andy Wingo 2010-07-09 16:48:30 +02:00
parent adb825b678
commit ddfb5e2bb0
2 changed files with 23 additions and 9 deletions

View file

@ -395,6 +395,9 @@ AC_DEFUN([GUILE_READLINE], [
dnl Check for modern readline naming dnl Check for modern readline naming
AC_CHECK_FUNCS([rl_filename_completion_function]) AC_CHECK_FUNCS([rl_filename_completion_function])
AC_CHECK_DECLS([rl_catch_signals, rl_catch_sigwinch], [], [],
[[#include <stdio.h>]
[#include <readline/readline.h>]])
dnl Check for rl_get_keymap. We only use this for deciding whether to dnl Check for rl_get_keymap. We only use this for deciding whether to
dnl install paren matching on the Guile command line (when using dnl install paren matching on the Guile command line (when using

View file

@ -146,7 +146,7 @@ static int in_readline = 0;
static SCM reentry_barrier_mutex; static SCM reentry_barrier_mutex;
static SCM internal_readline (SCM text); static SCM internal_readline (SCM text);
static SCM handle_error (void *data, SCM tag, SCM args); static void unwind_readline (void *unused);
static void reentry_barrier (void); static void reentry_barrier (void);
@ -200,10 +200,12 @@ SCM_DEFINE (scm_readline, "%readline", 0, 4, 0,
scm_readline_init_ports (inp, outp); scm_readline_init_ports (inp, outp);
ans = scm_internal_catch (SCM_BOOL_T, scm_dynwind_begin (0);
(scm_t_catch_body) internal_readline, scm_dynwind_unwind_handler (unwind_readline, NULL, 0);
(void *) SCM_UNPACK (text),
handle_error, 0); ans = internal_readline (text);
scm_dynwind_end ();
#ifndef __MINGW32__ #ifndef __MINGW32__
fclose (rl_instream); fclose (rl_instream);
@ -231,8 +233,9 @@ reentry_barrier ()
scm_misc_error (s_scm_readline, "readline is not reentrant", SCM_EOL); scm_misc_error (s_scm_readline, "readline is not reentrant", SCM_EOL);
} }
static SCM /* This function is only called on nonlocal exit from readline(). */
handle_error (void *data, SCM tag, SCM args) static void
unwind_readline (void *unused)
{ {
rl_free_line_state (); rl_free_line_state ();
rl_cleanup_after_signal (); rl_cleanup_after_signal ();
@ -242,8 +245,6 @@ handle_error (void *data, SCM tag, SCM args)
fclose (rl_outstream); fclose (rl_outstream);
#endif #endif
--in_readline; --in_readline;
scm_handle_by_throw (data, tag, args);
return SCM_UNSPECIFIED; /* never reached */
} }
static SCM static SCM
@ -557,6 +558,16 @@ scm_init_readline ()
rl_basic_word_break_characters = " \t\n\"'`;()"; rl_basic_word_break_characters = " \t\n\"'`;()";
rl_readline_name = "Guile"; rl_readline_name = "Guile";
/* Let Guile handle signals. */
#if defined (HAVE_DECL_RL_CATCH_SIGNALS) && HAVE_DECL_RL_CATCH_SIGNALS
rl_catch_signals = 0;
#endif
/* But let readline handle SIGWINCH. */
#if defined (HAVE_DECL_RL_CATCH_SIGWINCH) && HAVE_DECL_RL_CATCH_SIGWINCH
rl_catch_sigwinch = 1;
#endif
reentry_barrier_mutex = scm_make_mutex (); reentry_barrier_mutex = scm_make_mutex ();
scm_init_opts (scm_readline_options, scm_init_opts (scm_readline_options,
scm_readline_opts); scm_readline_opts);