From 14dbcd00bf3642a4228733e9c0896b33554d6afe Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 7 Jan 2001 08:23:06 +0000 Subject: [PATCH] "return 1" doesn't anymore stop signals in perl scripts. Fixed Irssi::signal_stop() to properly stop the signal from going to other perl scripts. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1086 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/signals.c | 11 +++++++++++ src/core/signals.h | 2 ++ src/perl/perl-signals.c | 23 ++++++----------------- src/perl/perl.c | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/core/signals.c b/src/core/signals.c index b15cce32..ad5f4cd8 100644 --- a/src/core/signals.c +++ b/src/core/signals.c @@ -318,6 +318,17 @@ int signal_get_emitted_id(void) return rec->id; } +/* return TRUE if specified signal was stopped */ +int signal_is_stopped(int signal_id) +{ + SIGNAL_REC *rec; + + rec = g_hash_table_lookup(signals, GINT_TO_POINTER(signal_id)); + g_return_val_if_fail(rec != NULL, FALSE); + + return rec->emitting <= rec->stop_emit; +} + static void signal_remove_module(void *signal, SIGNAL_REC *rec, const char *module) { diff --git a/src/core/signals.h b/src/core/signals.h index d3fc41bd..795f7327 100644 --- a/src/core/signals.h +++ b/src/core/signals.h @@ -42,6 +42,8 @@ void signal_stop_by_name(const char *signal); const char *signal_get_emitted(void); /* return the ID of the signal that is currently being emitted */ int signal_get_emitted_id(void); +/* return TRUE if specified signal was stopped */ +int signal_is_stopped(int signal_id); /* remove all signals that belong to `module' */ void signals_remove_module(const char *module); diff --git a/src/perl/perl-signals.c b/src/perl/perl-signals.c index ae857aea..73a4da40 100644 --- a/src/perl/perl-signals.c +++ b/src/perl/perl-signals.c @@ -49,8 +49,8 @@ static PERL_SIGNAL_ARGS_REC *perl_signal_args_find(int signal_id) return NULL; } -static int perl_call_signal(const char *func, int signal_id, - gconstpointer *args) +static void perl_call_signal(const char *func, int signal_id, + gconstpointer *args) { dSP; int retcount, ret; @@ -106,28 +106,18 @@ static int perl_call_signal(const char *func, int signal_id, } PUTBACK; - retcount = perl_call_pv((char *) func, G_EVAL|G_SCALAR); + retcount = perl_call_pv((char *) func, G_EVAL|G_DISCARD); SPAGAIN; - ret = 0; if (SvTRUE(ERRSV)) { STRLEN n_a; signal_emit("gui dialog", 2, "error", SvPV(ERRSV, n_a)); - (void)POPs; - } else if (retcount > 0) { - SV *sv = POPs; - - if (SvIOK(sv) && SvIV(sv) == 1) ret = 1; - while (--retcount > 0) - (void)POPi; } PUTBACK; FREETMPS; LEAVE; - - return ret; } static void sig_func(int priority, gconstpointer *args) @@ -141,10 +131,9 @@ static void sig_func(int priority, gconstpointer *args) for (tmp = list == NULL ? NULL : *list; tmp != NULL; tmp = tmp->next) { PERL_SIGNAL_REC *rec = tmp->data; - if (perl_call_signal(rec->func, signal_id, args)) { - signal_stop(); - break; - } + perl_call_signal(rec->func, signal_id, args); + if (signal_is_stopped(signal_id)) + break; } } diff --git a/src/perl/perl.c b/src/perl/perl.c index f233e295..aaf1ce99 100644 --- a/src/perl/perl.c +++ b/src/perl/perl.c @@ -317,7 +317,7 @@ static int perl_source_event(PERL_SOURCE_REC *rec) XPUSHs(sv_2mortal(new_pv(rec->data))); PUTBACK; - retcount = perl_call_pv(rec->func, G_EVAL|G_SCALAR); + retcount = perl_call_pv(rec->func, G_EVAL|G_DISCARD); SPAGAIN; if (SvTRUE(ERRSV)) {