summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-01-10 09:32:19 +0100
committerSebastien Helleu <flashcode@flashtux.org>2013-01-10 09:32:19 +0100
commit6d636b61184d2c7827b106f2405fa6f423b6f102 (patch)
treeaf48174308fe450015ae8cc6a81e9c6eb4944f4d
parent793a3cb1bad053ac3366cc34775dbc9b1e9ffb8a (diff)
downloadweechat-6d636b61184d2c7827b106f2405fa6f423b6f102.zip
Revert "perl: simplify code to load scripts"
This reverts commit 793a3cb1bad053ac3366cc34775dbc9b1e9ffb8a. This commit was causing crash on Linux when loading scripts like buffers.pl.
-rw-r--r--ChangeLog1
-rw-r--r--src/plugins/perl/weechat-perl.c26
2 files changed, 21 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 38d6bd2b6..52a4663bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -102,7 +102,6 @@ Version 0.4.0 (under dev!)
* irc: fix crash when message 352 has too few arguments (bug #37513)
* irc: remove unneeded server disconnect when server buffer is closed and server
is already disconnected
-* perl: simplify code to load scripts
* perl: display script filename in error messages
* perl: fix calls to callbacks during load of script when multiplicity is
disabled (bug #38044)
diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c
index 457655641..2de10d24a 100644
--- a/src/plugins/perl/weechat-perl.c
+++ b/src/plugins/perl/weechat-perl.c
@@ -83,19 +83,35 @@ char *perl_weechat_code =
"package WeechatPerlScriptLoader;"
#endif
"$weechat_perl_load_eval_file_error = \"\";"
+ "sub weechat_perl_load_file"
+ "{"
+ " my $filename = shift;"
+ " local $/ = undef;"
+ " open FILE, $filename or return \"__WEECHAT_PERL_ERROR__\";"
+ " $_ = <FILE>;"
+ " close FILE;"
+ " return qq{\n#line 1 \"$filename\"\n$_};"
+ "}"
"sub weechat_perl_load_eval_file"
"{"
- " my ($filename, $package) = @_;"
#ifdef MULTIPLICITY
- " do $filename;"
+ " my $filename = shift;"
#else
- " eval \"package $package; \".'do $filename;';"
+ " my ($filename, $package) = @_;"
#endif
- " if ($!)"
+ " my $content = weechat_perl_load_file ($filename);"
+ " if ($content eq \"__WEECHAT_PERL_ERROR__\")"
" {"
- " $weechat_perl_load_eval_file_error = $!;"
" return 1;"
" }"
+#ifdef MULTIPLICITY
+ " my $eval = $content;"
+#else
+ " my $eval = qq{package $package; $content;};"
+#endif
+ " {"
+ " eval $eval;"
+ " }"
" if ($@)"
" {"
" $weechat_perl_load_eval_file_error = $@;"