diff options
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua.c | 18 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl.c | 2 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 9 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby.c | 30 | ||||
-rw-r--r-- | weechat/src/plugins/scripts/lua/weechat-lua.c | 18 | ||||
-rw-r--r-- | weechat/src/plugins/scripts/perl/weechat-perl.c | 2 | ||||
-rw-r--r-- | weechat/src/plugins/scripts/python/weechat-python.c | 9 | ||||
-rw-r--r-- | weechat/src/plugins/scripts/ruby/weechat-ruby.c | 30 |
8 files changed, 54 insertions, 64 deletions
diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c index 384e930e6..6526507ec 100644 --- a/src/plugins/scripts/lua/weechat-lua.c +++ b/src/plugins/scripts/lua/weechat-lua.c @@ -2115,26 +2115,18 @@ weechat_lua_get_buffer_data (lua_State *L) channel = NULL; n = lua_gettop (lua_current_interpreter); - - switch (n) + if (n != 2) { - case 0: - break; - case 1: - server = lua_tostring (lua_current_interpreter, -1); - break; - case 2: - server = lua_tostring (lua_current_interpreter, -2); - channel = lua_tostring (lua_current_interpreter, -1); - break; - default: lua_plugin->print_server (lua_plugin, "Lua error: wrong parameters for " "\"get_buffer_data\" function"); lua_pushnumber (lua_current_interpreter, 0); return 1; } - + + server = lua_tostring (lua_current_interpreter, -2); + channel = lua_tostring (lua_current_interpreter, -1); + buffer_data = lua_plugin->get_buffer_data (lua_plugin, (char *) server, (char *) channel); if (!buffer_data) { diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index 4e4530e21..66418273f 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -1843,7 +1843,7 @@ static XS (XS_weechat_get_buffer_data) XSRETURN_EMPTY; } - if (items > 2) + if (items != 2) { perl_plugin->print_server (perl_plugin, "Perl error: wrong parameters for " diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 58ca1f154..ca73eafb4 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -522,7 +522,7 @@ weechat_python_remove_infobar (PyObject *self, PyObject *args) how_many = 0; - if (!PyArg_ParseTuple (args, "|is", &how_many)) + if (!PyArg_ParseTuple (args, "|i", &how_many)) { python_plugin->print_server (python_plugin, "Python error: wrong parameters for " @@ -2050,8 +2050,11 @@ weechat_python_get_buffer_data (PyObject *self, PyObject *args) Py_INCREF(Py_None); return Py_None; } - - if (!PyArg_ParseTuple (args, "|ss", &server, &channel)) + + server = NULL; + channel = NULL; + + if (!PyArg_ParseTuple (args, "ss|", &server, &channel)) { python_plugin->print_server (python_plugin, "Python error: wrong parameters for " diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index 40f0cde87..acd35fc3e 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -2023,11 +2023,10 @@ weechat_ruby_get_buffer_info (VALUE class) */ static VALUE -weechat_ruby_get_buffer_data (int argc, VALUE *argv, VALUE class) +weechat_ruby_get_buffer_data (VALUE class, VALUE server, VALUE channel) { t_plugin_buffer_line *buffer_data, *ptr_data; VALUE data_list, data_list_member; - VALUE server, channel; char *c_server, *c_channel; char timebuffer[64]; @@ -2042,24 +2041,25 @@ weechat_ruby_get_buffer_data (int argc, VALUE *argv, VALUE class) return INT2FIX (0); } - server = Qnil; - channel = Qnil; c_server = NULL; c_channel = NULL; - rb_scan_args (argc, argv, "02", &server, &channel); - - if (!NIL_P (server)) + if (NIL_P (server) || NIL_P (channel)) { - Check_Type (server, T_STRING); - c_server = STR2CSTR (server); + ruby_plugin->print_server (ruby_plugin, + "Ruby error: wrong parameters for " + "\"get_buffer_data\" function"); + return INT2FIX (0); } - if (!NIL_P (channel)) - { - Check_Type (channel, T_STRING); - c_channel = STR2CSTR (channel); - } + Check_Type (server, T_STRING); + Check_Type (channel, T_STRING); + + c_server = STR2CSTR (server); + c_channel = STR2CSTR (channel); + + if (!c_server || !c_channel) + return INT2FIX (0); data_list = rb_ary_new(); if (NIL_P (data_list)) @@ -2640,7 +2640,7 @@ weechat_plugin_init (t_weechat_plugin *plugin) rb_define_module_function (ruby_mWeechat, "get_irc_color", weechat_ruby_get_irc_color, 1); rb_define_module_function (ruby_mWeechat, "get_window_info", weechat_ruby_get_window_info, 0); rb_define_module_function (ruby_mWeechat, "get_buffer_info", weechat_ruby_get_buffer_info, 0); - rb_define_module_function (ruby_mWeechat, "get_buffer_data", weechat_ruby_get_buffer_data, -1); + rb_define_module_function (ruby_mWeechat, "get_buffer_data", weechat_ruby_get_buffer_data, 2); /* redirect stdin and stdout */ ruby_mWeechatOutputs = rb_define_module("WeechatOutputs"); diff --git a/weechat/src/plugins/scripts/lua/weechat-lua.c b/weechat/src/plugins/scripts/lua/weechat-lua.c index 384e930e6..6526507ec 100644 --- a/weechat/src/plugins/scripts/lua/weechat-lua.c +++ b/weechat/src/plugins/scripts/lua/weechat-lua.c @@ -2115,26 +2115,18 @@ weechat_lua_get_buffer_data (lua_State *L) channel = NULL; n = lua_gettop (lua_current_interpreter); - - switch (n) + if (n != 2) { - case 0: - break; - case 1: - server = lua_tostring (lua_current_interpreter, -1); - break; - case 2: - server = lua_tostring (lua_current_interpreter, -2); - channel = lua_tostring (lua_current_interpreter, -1); - break; - default: lua_plugin->print_server (lua_plugin, "Lua error: wrong parameters for " "\"get_buffer_data\" function"); lua_pushnumber (lua_current_interpreter, 0); return 1; } - + + server = lua_tostring (lua_current_interpreter, -2); + channel = lua_tostring (lua_current_interpreter, -1); + buffer_data = lua_plugin->get_buffer_data (lua_plugin, (char *) server, (char *) channel); if (!buffer_data) { diff --git a/weechat/src/plugins/scripts/perl/weechat-perl.c b/weechat/src/plugins/scripts/perl/weechat-perl.c index 4e4530e21..66418273f 100644 --- a/weechat/src/plugins/scripts/perl/weechat-perl.c +++ b/weechat/src/plugins/scripts/perl/weechat-perl.c @@ -1843,7 +1843,7 @@ static XS (XS_weechat_get_buffer_data) XSRETURN_EMPTY; } - if (items > 2) + if (items != 2) { perl_plugin->print_server (perl_plugin, "Perl error: wrong parameters for " diff --git a/weechat/src/plugins/scripts/python/weechat-python.c b/weechat/src/plugins/scripts/python/weechat-python.c index 58ca1f154..ca73eafb4 100644 --- a/weechat/src/plugins/scripts/python/weechat-python.c +++ b/weechat/src/plugins/scripts/python/weechat-python.c @@ -522,7 +522,7 @@ weechat_python_remove_infobar (PyObject *self, PyObject *args) how_many = 0; - if (!PyArg_ParseTuple (args, "|is", &how_many)) + if (!PyArg_ParseTuple (args, "|i", &how_many)) { python_plugin->print_server (python_plugin, "Python error: wrong parameters for " @@ -2050,8 +2050,11 @@ weechat_python_get_buffer_data (PyObject *self, PyObject *args) Py_INCREF(Py_None); return Py_None; } - - if (!PyArg_ParseTuple (args, "|ss", &server, &channel)) + + server = NULL; + channel = NULL; + + if (!PyArg_ParseTuple (args, "ss|", &server, &channel)) { python_plugin->print_server (python_plugin, "Python error: wrong parameters for " diff --git a/weechat/src/plugins/scripts/ruby/weechat-ruby.c b/weechat/src/plugins/scripts/ruby/weechat-ruby.c index 40f0cde87..acd35fc3e 100644 --- a/weechat/src/plugins/scripts/ruby/weechat-ruby.c +++ b/weechat/src/plugins/scripts/ruby/weechat-ruby.c @@ -2023,11 +2023,10 @@ weechat_ruby_get_buffer_info (VALUE class) */ static VALUE -weechat_ruby_get_buffer_data (int argc, VALUE *argv, VALUE class) +weechat_ruby_get_buffer_data (VALUE class, VALUE server, VALUE channel) { t_plugin_buffer_line *buffer_data, *ptr_data; VALUE data_list, data_list_member; - VALUE server, channel; char *c_server, *c_channel; char timebuffer[64]; @@ -2042,24 +2041,25 @@ weechat_ruby_get_buffer_data (int argc, VALUE *argv, VALUE class) return INT2FIX (0); } - server = Qnil; - channel = Qnil; c_server = NULL; c_channel = NULL; - rb_scan_args (argc, argv, "02", &server, &channel); - - if (!NIL_P (server)) + if (NIL_P (server) || NIL_P (channel)) { - Check_Type (server, T_STRING); - c_server = STR2CSTR (server); + ruby_plugin->print_server (ruby_plugin, + "Ruby error: wrong parameters for " + "\"get_buffer_data\" function"); + return INT2FIX (0); } - if (!NIL_P (channel)) - { - Check_Type (channel, T_STRING); - c_channel = STR2CSTR (channel); - } + Check_Type (server, T_STRING); + Check_Type (channel, T_STRING); + + c_server = STR2CSTR (server); + c_channel = STR2CSTR (channel); + + if (!c_server || !c_channel) + return INT2FIX (0); data_list = rb_ary_new(); if (NIL_P (data_list)) @@ -2640,7 +2640,7 @@ weechat_plugin_init (t_weechat_plugin *plugin) rb_define_module_function (ruby_mWeechat, "get_irc_color", weechat_ruby_get_irc_color, 1); rb_define_module_function (ruby_mWeechat, "get_window_info", weechat_ruby_get_window_info, 0); rb_define_module_function (ruby_mWeechat, "get_buffer_info", weechat_ruby_get_buffer_info, 0); - rb_define_module_function (ruby_mWeechat, "get_buffer_data", weechat_ruby_get_buffer_data, -1); + rb_define_module_function (ruby_mWeechat, "get_buffer_data", weechat_ruby_get_buffer_data, 2); /* redirect stdin and stdout */ ruby_mWeechatOutputs = rb_define_module("WeechatOutputs"); |