summaryrefslogtreecommitdiff
path: root/guile-readline
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-07-09 16:48:30 +0200
committerAndy Wingo <wingo@pobox.com>2010-07-09 17:05:25 +0200
commitddfb5e2bb02e167c734af5091d40d7db4ffeffa1 (patch)
tree33ed9c9d6bd735935cd50c62e8765adb1dba964e /guile-readline
parentadb825b6780b52a19291420c8699900d56de748d (diff)
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.
Diffstat (limited to 'guile-readline')
-rw-r--r--guile-readline/readline.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/guile-readline/readline.c b/guile-readline/readline.c
index 13e786324..0e4ad2902 100644
--- a/guile-readline/readline.c
+++ b/guile-readline/readline.c
@@ -146,7 +146,7 @@ static int in_readline = 0;
static SCM reentry_barrier_mutex;
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);
@@ -200,10 +200,12 @@ SCM_DEFINE (scm_readline, "%readline", 0, 4, 0,
scm_readline_init_ports (inp, outp);
- ans = scm_internal_catch (SCM_BOOL_T,
- (scm_t_catch_body) internal_readline,
- (void *) SCM_UNPACK (text),
- handle_error, 0);
+ scm_dynwind_begin (0);
+ scm_dynwind_unwind_handler (unwind_readline, NULL, 0);
+
+ ans = internal_readline (text);
+
+ scm_dynwind_end ();
#ifndef __MINGW32__
fclose (rl_instream);
@@ -231,8 +233,9 @@ reentry_barrier ()
scm_misc_error (s_scm_readline, "readline is not reentrant", SCM_EOL);
}
-static SCM
-handle_error (void *data, SCM tag, SCM args)
+/* This function is only called on nonlocal exit from readline(). */
+static void
+unwind_readline (void *unused)
{
rl_free_line_state ();
rl_cleanup_after_signal ();
@@ -242,8 +245,6 @@ handle_error (void *data, SCM tag, SCM args)
fclose (rl_outstream);
#endif
--in_readline;
- scm_handle_by_throw (data, tag, args);
- return SCM_UNSPECIFIED; /* never reached */
}
static SCM
@@ -557,6 +558,16 @@ scm_init_readline ()
rl_basic_word_break_characters = " \t\n\"'`;()";
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 ();
scm_init_opts (scm_readline_options,
scm_readline_opts);