summaryrefslogtreecommitdiff
path: root/src/plugins/perl
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 /src/plugins/perl
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.
Diffstat (limited to 'src/plugins/perl')
-rw-r--r--src/plugins/perl/weechat-perl.c26
1 files changed, 21 insertions, 5 deletions
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 = $@;"