From 063744ef7db5c0fd721b5530dfc1bee8de1b42c8 Mon Sep 17 00:00:00 2001 From: Emmanuel Bouthenot Date: Fri, 9 Mar 2007 15:46:08 +0000 Subject: make arguments for function get_buffer_data() mandatory in plugins/scripts --- src/plugins/scripts/ruby/weechat-ruby.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/plugins/scripts/ruby/weechat-ruby.c') 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"); -- cgit v1.2.3