diff --git a/ChangeLog b/ChangeLog index f64607a04..ca982bff1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,12 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2006-10-14 +ChangeLog - 2006-10-20 Version 0.2.2 (under dev!): + * fixed crash when loading ruby script if file does not exist, with + Ruby >= 1.9 only (bug #18064) * added date in plugin function get_buffer_data() * fixed some portability bugs (patch #5271) * fixed iconv detection for BSD (patch #5456) diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c index 2008f649c..950baf90e 100644 --- a/src/plugins/scripts/lua/weechat-lua.c +++ b/src/plugins/scripts/lua/weechat-lua.c @@ -1936,12 +1936,11 @@ weechat_lua_load (t_weechat_plugin *plugin, char *filename) if ((fp = fopen (filename, "r")) == NULL) { - plugin->print_server (plugin, - "Lua error: unable to open file \"%s\"", + plugin->print_server (plugin, "Lua error: script \"%s\" not found", filename); return 0; } - + lua_current_script = NULL; lua_current_interpreter = lua_open (); diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index 21ffaeb07..c89b8c5a7 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include "../../weechat-plugin.h" #include "../weechat-script.h" @@ -1631,7 +1633,8 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) STRLEN len; t_plugin_script tempscript; int eval; - + struct stat buf; + #ifndef MULTIPLICITY char pkgname[64]; #else @@ -1640,8 +1643,16 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) #endif plugin->print_server (plugin, "Loading Perl script \"%s\"", filename); - perl_current_script = NULL; + + if (stat (filename, &buf) != 0) + { + plugin->print_server (plugin, "Perl error: script \"%s\" not found", + filename); + return 0; + } + perl_current_script = NULL; + #ifndef MULTIPLICITY snprintf(pkgname, sizeof(pkgname), "%s%d", PKG_NAME_PREFIX, perl_num); perl_num++; diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index c8091260d..a894f82b0 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -1592,14 +1592,13 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename) if ((fp = fopen (filename, "r")) == NULL) { - plugin->print_server (plugin, - "Python error: unable to open file \"%s\"", + plugin->print_server (plugin, "Python error: script \"%s\" not found", filename); return 0; } - + python_current_script = NULL; - + /* PyEval_AcquireLock (); */ python_current_interpreter = Py_NewInterpreter (); PySys_SetArgv(1, argv); diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index 5001c10d3..4e2cebf90 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include "../../weechat-plugin.h" #include "../weechat-script.h" @@ -1796,10 +1798,19 @@ weechat_ruby_load (t_weechat_plugin *plugin, char *filename) char modname[64]; VALUE curModule, ruby_retcode, err; int ruby_error; + struct stat buf; plugin->print_server (plugin, "Loading Ruby script \"%s\"", filename); + + if (stat (filename, &buf) != 0) + { + plugin->print_server (plugin, "Ruby error: script \"%s\" not found", + filename); + return 0; + } + ruby_current_script = NULL; - + snprintf(modname, sizeof(modname), "%s%d", MOD_NAME_PREFIX, ruby_num); ruby_num++; diff --git a/weechat/ChangeLog b/weechat/ChangeLog index f64607a04..ca982bff1 100644 --- a/weechat/ChangeLog +++ b/weechat/ChangeLog @@ -1,10 +1,12 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2006-10-14 +ChangeLog - 2006-10-20 Version 0.2.2 (under dev!): + * fixed crash when loading ruby script if file does not exist, with + Ruby >= 1.9 only (bug #18064) * added date in plugin function get_buffer_data() * fixed some portability bugs (patch #5271) * fixed iconv detection for BSD (patch #5456) diff --git a/weechat/src/plugins/scripts/lua/weechat-lua.c b/weechat/src/plugins/scripts/lua/weechat-lua.c index 2008f649c..950baf90e 100644 --- a/weechat/src/plugins/scripts/lua/weechat-lua.c +++ b/weechat/src/plugins/scripts/lua/weechat-lua.c @@ -1936,12 +1936,11 @@ weechat_lua_load (t_weechat_plugin *plugin, char *filename) if ((fp = fopen (filename, "r")) == NULL) { - plugin->print_server (plugin, - "Lua error: unable to open file \"%s\"", + plugin->print_server (plugin, "Lua error: script \"%s\" not found", filename); return 0; } - + lua_current_script = NULL; lua_current_interpreter = lua_open (); diff --git a/weechat/src/plugins/scripts/perl/weechat-perl.c b/weechat/src/plugins/scripts/perl/weechat-perl.c index 21ffaeb07..c89b8c5a7 100644 --- a/weechat/src/plugins/scripts/perl/weechat-perl.c +++ b/weechat/src/plugins/scripts/perl/weechat-perl.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include "../../weechat-plugin.h" #include "../weechat-script.h" @@ -1631,7 +1633,8 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) STRLEN len; t_plugin_script tempscript; int eval; - + struct stat buf; + #ifndef MULTIPLICITY char pkgname[64]; #else @@ -1640,8 +1643,16 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename) #endif plugin->print_server (plugin, "Loading Perl script \"%s\"", filename); - perl_current_script = NULL; + + if (stat (filename, &buf) != 0) + { + plugin->print_server (plugin, "Perl error: script \"%s\" not found", + filename); + return 0; + } + perl_current_script = NULL; + #ifndef MULTIPLICITY snprintf(pkgname, sizeof(pkgname), "%s%d", PKG_NAME_PREFIX, perl_num); perl_num++; diff --git a/weechat/src/plugins/scripts/python/weechat-python.c b/weechat/src/plugins/scripts/python/weechat-python.c index c8091260d..a894f82b0 100644 --- a/weechat/src/plugins/scripts/python/weechat-python.c +++ b/weechat/src/plugins/scripts/python/weechat-python.c @@ -1592,14 +1592,13 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename) if ((fp = fopen (filename, "r")) == NULL) { - plugin->print_server (plugin, - "Python error: unable to open file \"%s\"", + plugin->print_server (plugin, "Python error: script \"%s\" not found", filename); return 0; } - + python_current_script = NULL; - + /* PyEval_AcquireLock (); */ python_current_interpreter = Py_NewInterpreter (); PySys_SetArgv(1, argv); diff --git a/weechat/src/plugins/scripts/ruby/weechat-ruby.c b/weechat/src/plugins/scripts/ruby/weechat-ruby.c index 5001c10d3..4e2cebf90 100644 --- a/weechat/src/plugins/scripts/ruby/weechat-ruby.c +++ b/weechat/src/plugins/scripts/ruby/weechat-ruby.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include "../../weechat-plugin.h" #include "../weechat-script.h" @@ -1796,10 +1798,19 @@ weechat_ruby_load (t_weechat_plugin *plugin, char *filename) char modname[64]; VALUE curModule, ruby_retcode, err; int ruby_error; + struct stat buf; plugin->print_server (plugin, "Loading Ruby script \"%s\"", filename); + + if (stat (filename, &buf) != 0) + { + plugin->print_server (plugin, "Ruby error: script \"%s\" not found", + filename); + return 0; + } + ruby_current_script = NULL; - + snprintf(modname, sizeof(modname), "%s%d", MOD_NAME_PREFIX, ruby_num); ruby_num++;