1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 13:56:37 +02:00

make arguments for function get_buffer_data() mandatory in plugins/scripts

This commit is contained in:
Emmanuel Bouthenot
2007-03-09 15:46:08 +00:00
parent cfd2f57dd1
commit 063744ef7d
8 changed files with 54 additions and 64 deletions
+5 -13
View File
@@ -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)
{
+1 -1
View File
@@ -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 "
+6 -3
View File
@@ -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 "
+15 -15
View File
@@ -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");