--- vim72-orig/src/configure.in 2009-08-03 19:54:22.596785133 +0300 +++ vim72-orig/src/configure.in 2009-08-03 19:56:46.276932871 +0300 @@ -956,10 +956,16 @@ if $vi_cv_path_ruby -e '(VERSION rescue RUBY_VERSION) >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then AC_MSG_RESULT(OK) AC_MSG_CHECKING(Ruby header files) - 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 AC_MSG_RESULT($rubyhdrdir) 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 RUBY_LIBS="$rubylibs" --- vim72-orig/src/if_ruby.c 2009-08-03 19:54:22.606036990 +0300 +++ vim72-orig/src/if_ruby.c 2009-08-03 19:48:53.964013676 +0300 @@ -60,6 +60,22 @@ # define __OPENTRANSPORTPROVIDERS__ #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" @@ -129,7 +145,11 @@ #define rb_str_concat dll_rb_str_concat #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 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 @@ -183,7 +203,11 @@ static VALUE (*dll_rb_str_concat) (VALUE, VALUE); 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); #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 @@ -245,7 +269,11 @@ {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat}, {"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}, #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 @@ -365,7 +393,7 @@ EMSG(_("E265: $_ must be an instance of String")); return; } - ml_replace(i, (char_u *) STR2CSTR(line), 1); + ml_replace(i, (char_u *) StringValuePtr(line), 1); changed(); #ifdef SYNTAX_HL syn_changed(i); /* recompute syntax hl. for this line */ @@ -414,7 +442,11 @@ if (ruby_enabled(TRUE)) { #endif +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 + RUBY_INIT_STACK; +#endif ruby_init(); + ruby_script("vim-ruby"); ruby_init_loadpath(); ruby_io_init(); ruby_vim_init(); @@ -434,8 +466,10 @@ static void error_print(int state) { #ifndef DYNAMIC_RUBY +#if !(defined(RUBY_VERSION) && RUBY_VERSION >= 19) RUBYEXTERN VALUE ruby_errinfo; #endif +#endif VALUE eclass; VALUE einfo; char buff[BUFSIZ]; @@ -468,9 +502,14 @@ break; 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")); } else { @@ -479,7 +518,7 @@ 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'; EMSG(buff); @@ -497,8 +536,8 @@ char *buff, *p; 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'; MSG(buff); @@ -507,21 +546,21 @@ 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; } 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; } static VALUE vim_evaluate(VALUE self UNUSED, VALUE str) { #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) { @@ -645,7 +684,7 @@ 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; if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL) @@ -723,7 +762,7 @@ static VALUE buffer_append(VALUE self, VALUE num, VALUE str) { buf_T *buf = get_buf(self); - char *line = STR2CSTR(str); + char *line = StringValuePtr(str); long n = NUM2LONG(num); aco_save_T aco; @@ -890,10 +929,10 @@ win_T *win = get_win(self); 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); check_cursor(); /* put cursor on an existing line */ @@ -910,7 +949,7 @@ if (i > 0) rb_str_cat(str, ", ", 2); rb_str_concat(str, rb_inspect(argv[i])); } - MSG(RSTRING(str)->ptr); + MSG(RSTRING_PTR(str)); return Qnil; }