summaryrefslogtreecommitdiff
path: root/src/plugins/ruby/weechat-ruby.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2014-01-06 07:54:29 +0100
committerSebastien Helleu <flashcode@flashtux.org>2014-01-06 07:54:29 +0100
commit0ac504a18ba2afe5410494d249d001de724c4125 (patch)
tree0a77a652719e7e9a8340604eecb00fe11082c644 /src/plugins/ruby/weechat-ruby.c
parentcc40a0ee55555d1e26573cadea4e3c8135560cdd (diff)
downloadweechat-0ac504a18ba2afe5410494d249d001de724c4125.zip
ruby: fix ruby init with ruby >= 2.0 (bug #41115)
Diffstat (limited to 'src/plugins/ruby/weechat-ruby.c')
-rw-r--r--src/plugins/ruby/weechat-ruby.c113
1 files changed, 56 insertions, 57 deletions
diff --git a/src/plugins/ruby/weechat-ruby.c b/src/plugins/ruby/weechat-ruby.c
index b71cc39fa..dd50356c4 100644
--- a/src/plugins/ruby/weechat-ruby.c
+++ b/src/plugins/ruby/weechat-ruby.c
@@ -23,7 +23,7 @@
#undef _
#include <ruby.h>
-#if defined(RUBY_VERSION) && RUBY_VERSION >=19
+#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
#include <ruby/encoding.h>
#endif
#ifdef HAVE_RUBY_VERSION_H
@@ -1084,62 +1084,61 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
struct t_plugin_script_init init;
int ruby_error;
- char *weechat_ruby_code =
- {
- "$stdout = WeechatOutputs\n"
- "$stderr = WeechatOutputs\n"
- "begin"
- " if RUBY_VERSION.split('.')[1] == '9'\n"
- " require 'enc/encdb.so'\n"
- " require 'enc/trans/transdb.so'\n"
- "\n"
- " require 'thread'\n"
- " class ::Mutex\n"
- " def synchronize(*args)\n"
- " yield\n"
- " end\n"
- " end\n"
- " require 'rubygems'\n"
- " else\n"
- " require 'rubygems'\n"
- " end\n"
- "rescue LoadError\n"
- "end\n"
- "\n"
- "class Module\n"
- "\n"
- " def load_eval_file (file)\n"
- " lines = ''\n"
- " begin\n"
- " lines = File.read(file)\n"
- " rescue => e\n"
- " return 1\n"
- " end\n"
- "\n"
- " begin\n"
- " module_eval(lines)\n"
- " rescue Exception => e\n"
- " @load_eval_file_error = e\n"
- " return 2\n"
- " end\n"
- "\n"
- " has_init = false\n"
- "\n"
- " instance_methods.each do |meth|\n"
- " if meth.to_s == 'weechat_init'\n"
- " has_init = true\n"
- " end\n"
- " module_eval('module_function :' + meth.to_s)\n"
- " end\n"
- "\n"
- " unless has_init\n"
- " return 3\n"
- " end\n"
- "\n"
- " return 0\n"
- " end\n"
- "end\n"
- };
+ char *weechat_ruby_code = {
+ "$stdout = WeechatOutputs\n"
+ "$stderr = WeechatOutputs\n"
+ "begin"
+ " if RUBY_VERSION.split('.')[0] == '1' and RUBY_VERSION.split('.')[1] <= '8'\n"
+ " require 'rubygems'\n"
+ " else\n"
+ " require 'enc/encdb.so'\n"
+ " require 'enc/trans/transdb.so'\n"
+ "\n"
+ " require 'thread'\n"
+ " class ::Mutex\n"
+ " def synchronize(*args)\n"
+ " yield\n"
+ " end\n"
+ " end\n"
+ " require 'rubygems'\n"
+ " end\n"
+ "rescue LoadError\n"
+ "end\n"
+ "\n"
+ "class Module\n"
+ "\n"
+ " def load_eval_file (file)\n"
+ " lines = ''\n"
+ " begin\n"
+ " lines = File.read(file)\n"
+ " rescue => e\n"
+ " return 1\n"
+ " end\n"
+ "\n"
+ " begin\n"
+ " module_eval(lines)\n"
+ " rescue Exception => e\n"
+ " @load_eval_file_error = e\n"
+ " return 2\n"
+ " end\n"
+ "\n"
+ " has_init = false\n"
+ "\n"
+ " instance_methods.each do |meth|\n"
+ " if meth.to_s == 'weechat_init'\n"
+ " has_init = true\n"
+ " end\n"
+ " module_eval('module_function :' + meth.to_s)\n"
+ " end\n"
+ "\n"
+ " unless has_init\n"
+ " return 3\n"
+ " end\n"
+ "\n"
+ " return 0\n"
+ " end\n"
+ "end\n"
+ };
weechat_ruby_plugin = plugin;