diff options
Diffstat (limited to 'src/plugins/perl')
-rw-r--r-- | src/plugins/perl/weechat-perl.c | 26 |
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 = $@;" |