From 4bb26bb9518a0166e2102eef139b518fae8d20b6 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 25 Aug 2002 16:04:11 +0000 Subject: If script returns 0 while it's being loaded, it's terminated without any error message. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2885 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/perl/irssi-core.pl | 4 +++- src/perl/perl-core.c | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/perl/irssi-core.pl b/src/perl/irssi-core.pl index 9ab5953b..11aa0f6f 100644 --- a/src/perl/irssi-core.pl +++ b/src/perl/irssi-core.pl @@ -30,8 +30,10 @@ sub eval_data { } die $@ if $@; - eval {$package->handler;}; + my $ret; + eval { $ret = $package->handler; }; die $@ if $@; + return $ret; } sub eval_file { diff --git a/src/perl/perl-core.c b/src/perl/perl-core.c index accd5ef4..0c1e506b 100644 --- a/src/perl/perl-core.c +++ b/src/perl/perl-core.c @@ -216,6 +216,7 @@ static int perl_script_eval(PERL_SCRIPT_REC *script) dSP; char *error; int retcount; + SV *ret; ENTER; SAVETMPS; @@ -234,19 +235,19 @@ static int perl_script_eval(PERL_SCRIPT_REC *script) error = NULL; if (SvTRUE(ERRSV)) { - error = SvPV(ERRSV, PL_na); - } else if (retcount > 0) { - error = POPp; - } + error = SvPV(ERRSV, PL_na); - if (error != NULL) { - if (*error == '\0') - error = NULL; - else { - error = g_strdup(error); + if (error != NULL) { + error = g_strdup(error); signal_emit("script error", 2, script, error); - g_free(error); + g_free(error); } + } else if (retcount > 0) { + /* if script returns 0, it means the script wanted to die + immediately without any error message */ + ret = POPs; + if (ret != &PL_sv_undef && SvIOK(ret) && SvIV(ret) == 0) + error = ""; } PUTBACK; -- cgit v1.2.3