Hello,
I made a patch for VIM works with ruby 1.9 or ruby 1.8.
It affects file if_ruby.c and src/auto/configure.
The patch is for VIM 7.2.234.
I tested the patch with ruby 1.9.1 and ruby 1.8.7 on my
Linux box.
Any comments are welcome.

  Regards,
  Masaki Suketa

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

diff -U 2 -r vim7/src/auto/configure vim7-ruby/src/auto/configure
--- vim7/src/auto/configure	2009-07-21 19:32:05.000000000 +0900
+++ vim7-ruby/src/auto/configure	2009-07-21 19:31:49.000000000 +0900
@@ -5753,9 +5753,15 @@
       { $as_echo "$as_me:$LINENO: checking Ruby header files" >&5
 $as_echo_n "checking Ruby header files... " >&6; }
-      rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null`
+      rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG["rubyhdrdir"] || Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null`
       if test "X$rubyhdrdir" != "X"; then
 	{ $as_echo "$as_me:$LINENO: result: $rubyhdrdir" >&5
 $as_echo "$rubyhdrdir" >&6; }
 	RUBY_CFLAGS="-I$rubyhdrdir"
+        rubyarch=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["arch"]'`
+        if test -d "$rubyhdrdir/$rubyarch"; then
+          RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
+        fi
+        rubyversion=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["ruby_version"].gsub(/\./, "")[0,2]'`
+        RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
 	rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["LIBS"]'`
 	if test "X$rubylibs" != "X"; then
diff -U 2 -r vim7/src/if_ruby.c vim7-ruby/src/if_ruby.c
--- vim7/src/if_ruby.c	2009-07-21 19:32:08.000000000 +0900
+++ vim7-ruby/src/if_ruby.c	2009-07-21 19:31:21.000000000 +0900
@@ -61,4 +61,20 @@
 #endif
 
+#ifndef StringValuePtr
+#define StringValuePtr(s) STR2CSTR(s)
+#endif
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(s) RARRAY(s)->len
+#endif 
+#ifndef RARRAY_PTR
+#define RARRAY_PTR(s) RARRAY(s)->ptr
+#endif
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(s) RSTRING(s)->len
+#endif
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(s) RSTRING(s)->ptr
+#endif
+
 #include "vim.h"
 #include "version.h"
@@ -130,5 +146,9 @@
 #define rb_str_new			dll_rb_str_new
 #define rb_str_new2			dll_rb_str_new2
+#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
+#define rb_errinfo                      dll_rb_errinfo
+#else
 #define ruby_errinfo			(*dll_ruby_errinfo)
+#endif
 #define ruby_init			dll_ruby_init
 #define ruby_init_loadpath		dll_ruby_init_loadpath
@@ -184,5 +204,9 @@
 static VALUE (*dll_rb_str_new) (const char*, long);
 static VALUE (*dll_rb_str_new2) (const char*);
+#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
+static VALUE (*dll_rb_errinfo) (void);
+#else
 static VALUE *dll_ruby_errinfo;
+#endif
 static void (*dll_ruby_init) (void);
 static void (*dll_ruby_init_loadpath) (void);
@@ -246,5 +270,9 @@
     {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new},
     {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2},
+#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
+    {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo},
+#else
     {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
+#endif
     {"ruby_init", (RUBY_PROC*)&dll_ruby_init},
     {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath},
@@ -366,5 +394,5 @@
 		    return;
 		}
-		ml_replace(i, (char_u *) STR2CSTR(line), 1);
+		ml_replace(i, (char_u *) StringValuePtr(line), 1);
 		changed();
 #ifdef SYNTAX_HL
@@ -415,5 +443,9 @@
 	{
 #endif
+#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
+            RUBY_INIT_STACK;
+#endif
 	    ruby_init();
+            ruby_script("vim-ruby");
 	    ruby_init_loadpath();
 	    ruby_io_init();
@@ -435,6 +467,8 @@
 {
 #ifndef DYNAMIC_RUBY
+#if !(defined(RUBY_VERSION) &&  RUBY_VERSION >= 19)
     RUBYEXTERN VALUE ruby_errinfo;
 #endif
+#endif
     VALUE eclass;
     VALUE einfo;
@@ -469,7 +503,12 @@
     case TAG_RAISE:
     case TAG_FATAL:
+# if defined(RUBY_VERSION) && RUBY_VERSION >= 19
+	eclass = CLASS_OF(rb_errinfo());
+	einfo = rb_obj_as_string(rb_errinfo());
+#else
 	eclass = CLASS_OF(ruby_errinfo);
 	einfo = rb_obj_as_string(ruby_errinfo);
-	if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
+#endif
+	if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
 	    EMSG(_("E272: unhandled exception"));
 	}
@@ -480,5 +519,5 @@
 	    epath = rb_class_path(eclass);
 	    vim_snprintf(buff, BUFSIZ, "%s: %s",
-		     RSTRING(epath)->ptr, RSTRING(einfo)->ptr);
+		     RSTRING_PTR(epath), RSTRING_PTR(einfo));
 	    p = strchr(buff, '\n');
 	    if (p) *p = '\0';
@@ -498,6 +537,6 @@
 
     str = rb_obj_as_string(str);
-    buff = ALLOCA_N(char, RSTRING(str)->len);
-    strcpy(buff, RSTRING(str)->ptr);
+    buff = ALLOCA_N(char, RSTRING_LEN(str));
+    strcpy(buff, RSTRING_PTR(str));
     p = strchr(buff, '\n');
     if (p) *p = '\0';
@@ -508,5 +547,5 @@
 static VALUE vim_set_option(VALUE self UNUSED, VALUE str)
 {
-    do_set((char_u *)STR2CSTR(str), 0);
+    do_set((char_u *)StringValuePtr(str), 0);
     update_screen(NOT_VALID);
     return Qnil;
@@ -515,5 +554,5 @@
 static VALUE vim_command(VALUE self UNUSED, VALUE str)
 {
-    do_cmdline_cmd((char_u *)STR2CSTR(str));
+    do_cmdline_cmd((char_u *)StringValuePtr(str));
     return Qnil;
 }
@@ -522,5 +561,5 @@
 {
 #ifdef FEAT_EVAL
-    char_u *value = eval_to_string((char_u *)STR2CSTR(str), NULL, TRUE);
+    char_u *value = eval_to_string((char_u *)StringValuePtr(str), NULL, TRUE);
 
     if (value != NULL)
@@ -646,5 +685,5 @@
 static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
 {
-    char	*line = STR2CSTR(str);
+    char	*line = StringValuePtr(str);
     aco_save_T	aco;
 
@@ -724,5 +763,5 @@
 {
     buf_T	*buf = get_buf(self);
-    char	*line = STR2CSTR(str);
+    char	*line = StringValuePtr(str);
     long	n = NUM2LONG(num);
     aco_save_T	aco;
@@ -891,8 +930,8 @@
 
     Check_Type(pos, T_ARRAY);
-    if (RARRAY(pos)->len != 2)
+    if (RARRAY_LEN(pos) != 2)
 	rb_raise(rb_eArgError, "array length must be 2");
-    lnum = RARRAY(pos)->ptr[0];
-    col = RARRAY(pos)->ptr[1];
+    lnum = RARRAY_PTR(pos)[0];
+    col = RARRAY_PTR(pos)[1];
     win->w_cursor.lnum = NUM2LONG(lnum);
     win->w_cursor.col = NUM2UINT(col);
@@ -911,5 +950,5 @@
 	rb_str_concat(str, rb_inspect(argv[i]));
     }
-    MSG(RSTRING(str)->ptr);
+    MSG(RSTRING_PTR(str));
     return Qnil;
 }

Raspunde prin e-mail lui