mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 22:36:38 +02:00
perl: simplify code to load scripts
This commit is contained in:
@@ -102,6 +102,7 @@ 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)
|
||||
|
||||
@@ -83,34 +83,18 @@ 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"
|
||||
"{"
|
||||
#ifdef MULTIPLICITY
|
||||
" my $filename = shift;"
|
||||
#else
|
||||
" my ($filename, $package) = @_;"
|
||||
#endif
|
||||
" my $content = weechat_perl_load_file ($filename);"
|
||||
" if ($content eq \"__WEECHAT_PERL_ERROR__\")"
|
||||
" {"
|
||||
" return 1;"
|
||||
" }"
|
||||
#ifdef MULTIPLICITY
|
||||
" my $eval = $content;"
|
||||
" do $filename;"
|
||||
#else
|
||||
" my $eval = qq{package $package; $content;};"
|
||||
" eval \"package $package; \".'do $filename;';"
|
||||
#endif
|
||||
" if ($!)"
|
||||
" {"
|
||||
" eval $eval;"
|
||||
" $weechat_perl_load_eval_file_error = $!;"
|
||||
" return 1;"
|
||||
" }"
|
||||
" if ($@)"
|
||||
" {"
|
||||
|
||||
Reference in New Issue
Block a user