Karsten Hopp 7c82aa
To: vim-dev@vim.org
Karsten Hopp 7c82aa
Subject: Patch 7.2.400
Karsten Hopp 7c82aa
Fcc: outbox
Karsten Hopp 7c82aa
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 7c82aa
Mime-Version: 1.0
Karsten Hopp 7c82aa
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 7c82aa
Content-Transfer-Encoding: 8bit
Karsten Hopp 7c82aa
------------
Karsten Hopp 7c82aa
Karsten Hopp 7c82aa
Patch 7.2.400 (after 7.2.387)
Karsten Hopp 7c82aa
Problem:    Dynamic Ruby is not initialised properly for version 1.9.1.
Karsten Hopp 7c82aa
	    Ruby cannot create strings from NULL.
Karsten Hopp 7c82aa
Solution:   Cleanup #ifdefs.  Handle NULL like an empty string.  Add
Karsten Hopp 7c82aa
	    ruby_init_stack. (Sergey Khorev)
Karsten Hopp 7c82aa
Files:	    src/if_ruby.c
Karsten Hopp 7c82aa
Karsten Hopp 7c82aa
Karsten Hopp 7c82aa
*** ../vim-7.2.399/src/if_ruby.c	2010-03-10 12:46:38.000000000 +0100
Karsten Hopp 7c82aa
--- src/if_ruby.c	2010-03-17 17:37:53.000000000 +0100
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 53,58 ****
Karsten Hopp 7c82aa
--- 53,63 ----
Karsten Hopp 7c82aa
  # undef _WIN32_WINNT
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
+ #if (defined(RUBY_VERSION) && RUBY_VERSION >= 19) \
Karsten Hopp 7c82aa
+     || (defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19)
Karsten Hopp 7c82aa
+ # define RUBY19_OR_LATER 1
Karsten Hopp 7c82aa
+ #endif
Karsten Hopp 7c82aa
+ 
Karsten Hopp 7c82aa
  #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
Karsten Hopp 7c82aa
  /* Ruby 1.9 defines a number of static functions which use rb_num2long and
Karsten Hopp 7c82aa
   * rb_int2big */
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 61,67 ****
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
  #include <ruby.h>
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
Karsten Hopp 7c82aa
  # include <ruby/encoding.h>
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
--- 66,72 ----
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
  #include <ruby.h>
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  # include <ruby/encoding.h>
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 172,179 ****
Karsten Hopp 7c82aa
  # define rb_ary_new			dll_rb_ary_new
Karsten Hopp 7c82aa
  # define rb_ary_push			dll_rb_ary_push
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 \
Karsten Hopp 7c82aa
!     || defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
Karsten Hopp 7c82aa
  # define rb_errinfo			dll_rb_errinfo
Karsten Hopp 7c82aa
  #else
Karsten Hopp 7c82aa
  # define ruby_errinfo			(*dll_ruby_errinfo)
Karsten Hopp 7c82aa
--- 177,183 ----
Karsten Hopp 7c82aa
  # define rb_ary_new			dll_rb_ary_new
Karsten Hopp 7c82aa
  # define rb_ary_push			dll_rb_ary_push
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  # define rb_errinfo			dll_rb_errinfo
Karsten Hopp 7c82aa
  #else
Karsten Hopp 7c82aa
  # define ruby_errinfo			(*dll_ruby_errinfo)
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 185,196 ****
Karsten Hopp 7c82aa
  # define rb_w32_snprintf		dll_rb_w32_snprintf
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
Karsten Hopp 7c82aa
  # define ruby_script			dll_ruby_script
Karsten Hopp 7c82aa
  # define rb_enc_find_index		dll_rb_enc_find_index
Karsten Hopp 7c82aa
  # define rb_enc_find			dll_rb_enc_find
Karsten Hopp 7c82aa
  # define rb_enc_str_new			dll_rb_enc_str_new
Karsten Hopp 7c82aa
  # define rb_sprintf			dll_rb_sprintf
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
  /*
Karsten Hopp 7c82aa
--- 189,201 ----
Karsten Hopp 7c82aa
  # define rb_w32_snprintf		dll_rb_w32_snprintf
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  # define ruby_script			dll_ruby_script
Karsten Hopp 7c82aa
  # define rb_enc_find_index		dll_rb_enc_find_index
Karsten Hopp 7c82aa
  # define rb_enc_find			dll_rb_enc_find
Karsten Hopp 7c82aa
  # define rb_enc_str_new			dll_rb_enc_str_new
Karsten Hopp 7c82aa
  # define rb_sprintf			dll_rb_sprintf
Karsten Hopp 7c82aa
+ # define ruby_init_stack		dll_ruby_init_stack
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
  /*
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 240,247 ****
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_str_concat) (VALUE, VALUE);
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_str_new) (const char*, long);
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_str_new2) (const char*);
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 \
Karsten Hopp 7c82aa
!     || defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_errinfo) (void);
Karsten Hopp 7c82aa
  #else
Karsten Hopp 7c82aa
  static VALUE *dll_ruby_errinfo;
Karsten Hopp 7c82aa
--- 245,251 ----
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_str_concat) (VALUE, VALUE);
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_str_new) (const char*, long);
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_str_new2) (const char*);
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_errinfo) (void);
Karsten Hopp 7c82aa
  #else
Karsten Hopp 7c82aa
  static VALUE *dll_ruby_errinfo;
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 255,276 ****
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_ary_new) (void);
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_ary_push) (VALUE, VALUE);
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
! #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_int2big)(SIGNED_VALUE);
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
Karsten Hopp 7c82aa
  static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...);
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
Karsten Hopp 7c82aa
  static void (*dll_ruby_script) (const char*);
Karsten Hopp 7c82aa
  static int (*dll_rb_enc_find_index) (const char*);
Karsten Hopp 7c82aa
  static rb_encoding* (*dll_rb_enc_find) (const char*);
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_sprintf) (const char*, ...);
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
! #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
Karsten Hopp 7c82aa
  static SIGNED_VALUE rb_num2long_stub(VALUE x)
Karsten Hopp 7c82aa
  {
Karsten Hopp 7c82aa
      return dll_rb_num2long(x);
Karsten Hopp 7c82aa
--- 259,281 ----
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_ary_new) (void);
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_ary_push) (VALUE, VALUE);
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_int2big)(SIGNED_VALUE);
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
Karsten Hopp 7c82aa
  static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...);
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  static void (*dll_ruby_script) (const char*);
Karsten Hopp 7c82aa
  static int (*dll_rb_enc_find_index) (const char*);
Karsten Hopp 7c82aa
  static rb_encoding* (*dll_rb_enc_find) (const char*);
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
Karsten Hopp 7c82aa
  static VALUE (*dll_rb_sprintf) (const char*, ...);
Karsten Hopp 7c82aa
+ static void (*ruby_init_stack)(VALUE*);
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  static SIGNED_VALUE rb_num2long_stub(VALUE x)
Karsten Hopp 7c82aa
  {
Karsten Hopp 7c82aa
      return dll_rb_num2long(x);
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 336,343 ****
Karsten Hopp 7c82aa
      {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat},
Karsten Hopp 7c82aa
      {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new},
Karsten Hopp 7c82aa
      {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2},
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 \
Karsten Hopp 7c82aa
!     || defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
Karsten Hopp 7c82aa
      {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo},
Karsten Hopp 7c82aa
  #else
Karsten Hopp 7c82aa
      {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
Karsten Hopp 7c82aa
--- 341,347 ----
Karsten Hopp 7c82aa
      {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat},
Karsten Hopp 7c82aa
      {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new},
Karsten Hopp 7c82aa
      {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2},
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
      {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo},
Karsten Hopp 7c82aa
  #else
Karsten Hopp 7c82aa
      {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 360,374 ****
Karsten Hopp 7c82aa
      {"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new},
Karsten Hopp 7c82aa
      {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push},
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
! #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
Karsten Hopp 7c82aa
      {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big},
Karsten Hopp 7c82aa
- #endif
Karsten Hopp 7c82aa
- #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
Karsten Hopp 7c82aa
      {"ruby_script", (RUBY_PROC*)&dll_ruby_script},
Karsten Hopp 7c82aa
      {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
Karsten Hopp 7c82aa
      {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find},
Karsten Hopp 7c82aa
      {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
Karsten Hopp 7c82aa
      {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
      {"", NULL},
Karsten Hopp 7c82aa
  };
Karsten Hopp 7c82aa
--- 364,377 ----
Karsten Hopp 7c82aa
      {"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new},
Karsten Hopp 7c82aa
      {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push},
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
      {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big},
Karsten Hopp 7c82aa
      {"ruby_script", (RUBY_PROC*)&dll_ruby_script},
Karsten Hopp 7c82aa
      {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
Karsten Hopp 7c82aa
      {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find},
Karsten Hopp 7c82aa
      {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
Karsten Hopp 7c82aa
      {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
Karsten Hopp 7c82aa
+     {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack},
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
      {"", NULL},
Karsten Hopp 7c82aa
  };
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 467,473 ****
Karsten Hopp 7c82aa
      static VALUE
Karsten Hopp 7c82aa
  vim_str2rb_enc_str(const char *s)
Karsten Hopp 7c82aa
  {
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
Karsten Hopp 7c82aa
      int isnum;
Karsten Hopp 7c82aa
      long lval;
Karsten Hopp 7c82aa
      char_u *sval;
Karsten Hopp 7c82aa
--- 470,476 ----
Karsten Hopp 7c82aa
      static VALUE
Karsten Hopp 7c82aa
  vim_str2rb_enc_str(const char *s)
Karsten Hopp 7c82aa
  {
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
      int isnum;
Karsten Hopp 7c82aa
      long lval;
Karsten Hopp 7c82aa
      char_u *sval;
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 489,495 ****
Karsten Hopp 7c82aa
      static VALUE
Karsten Hopp 7c82aa
  eval_enc_string_protect(const char *str, int *state)
Karsten Hopp 7c82aa
  {
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
Karsten Hopp 7c82aa
      int isnum;
Karsten Hopp 7c82aa
      long lval;
Karsten Hopp 7c82aa
      char_u *sval;
Karsten Hopp 7c82aa
--- 492,498 ----
Karsten Hopp 7c82aa
      static VALUE
Karsten Hopp 7c82aa
  eval_enc_string_protect(const char *str, int *state)
Karsten Hopp 7c82aa
  {
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
      int isnum;
Karsten Hopp 7c82aa
      long lval;
Karsten Hopp 7c82aa
      char_u *sval;
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 591,606 ****
Karsten Hopp 7c82aa
  	    char *argv[] = {"gvim.exe"};
Karsten Hopp 7c82aa
  	    NtInitialize(&argc, &argv);
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
Karsten Hopp 7c82aa
  	    RUBY_INIT_STACK;
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  	    ruby_init();
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
Karsten Hopp 7c82aa
  	    ruby_script("vim-ruby");
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  	    ruby_init_loadpath();
Karsten Hopp 7c82aa
  	    ruby_io_init();
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
Karsten Hopp 7c82aa
  	    rb_enc_find_index("encdb");
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  	    ruby_vim_init();
Karsten Hopp 7c82aa
--- 594,609 ----
Karsten Hopp 7c82aa
  	    char *argv[] = {"gvim.exe"};
Karsten Hopp 7c82aa
  	    NtInitialize(&argc, &argv);
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  	    RUBY_INIT_STACK;
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  	    ruby_init();
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  	    ruby_script("vim-ruby");
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  	    ruby_init_loadpath();
Karsten Hopp 7c82aa
  	    ruby_io_init();
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  	    rb_enc_find_index("encdb");
Karsten Hopp 7c82aa
  #endif
Karsten Hopp 7c82aa
  	    ruby_vim_init();
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 657,664 ****
Karsten Hopp 7c82aa
  	break;
Karsten Hopp 7c82aa
      case TAG_RAISE:
Karsten Hopp 7c82aa
      case TAG_FATAL:
Karsten Hopp 7c82aa
! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 \
Karsten Hopp 7c82aa
!     || defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
Karsten Hopp 7c82aa
  	eclass = CLASS_OF(rb_errinfo());
Karsten Hopp 7c82aa
  	einfo = rb_obj_as_string(rb_errinfo());
Karsten Hopp 7c82aa
  #else
Karsten Hopp 7c82aa
--- 660,666 ----
Karsten Hopp 7c82aa
  	break;
Karsten Hopp 7c82aa
      case TAG_RAISE:
Karsten Hopp 7c82aa
      case TAG_FATAL:
Karsten Hopp 7c82aa
! #ifdef RUBY19_OR_LATER
Karsten Hopp 7c82aa
  	eclass = CLASS_OF(rb_errinfo());
Karsten Hopp 7c82aa
  	einfo = rb_obj_as_string(rb_errinfo());
Karsten Hopp 7c82aa
  #else
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 720,775 ****
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
      if (tv->v_type == VAR_STRING)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
!         result = rb_str_new2((char *)tv->vval.v_string);
Karsten Hopp 7c82aa
      }
Karsten Hopp 7c82aa
      else if (tv->v_type == VAR_NUMBER)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
!         result = INT2NUM(tv->vval.v_number);
Karsten Hopp 7c82aa
      }
Karsten Hopp 7c82aa
  # ifdef FEAT_FLOAT
Karsten Hopp 7c82aa
      else if (tv->v_type == VAR_FLOAT)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
!         result = rb_float_new(tv->vval.v_float);
Karsten Hopp 7c82aa
      }
Karsten Hopp 7c82aa
  # endif
Karsten Hopp 7c82aa
      else if (tv->v_type == VAR_LIST)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
!         list_T      *list = tv->vval.v_list;
Karsten Hopp 7c82aa
!         listitem_T  *curr;
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
!         result = rb_ary_new();
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
!         if (list != NULL)
Karsten Hopp 7c82aa
!         {
Karsten Hopp 7c82aa
!             for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
Karsten Hopp 7c82aa
!             {
Karsten Hopp 7c82aa
!                 rb_ary_push(result, vim_to_ruby(&curr->li_tv));
Karsten Hopp 7c82aa
!             }
Karsten Hopp 7c82aa
!         }
Karsten Hopp 7c82aa
      }
Karsten Hopp 7c82aa
      else if (tv->v_type == VAR_DICT)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
!         result = rb_hash_new();
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
!         if (tv->vval.v_dict != NULL)
Karsten Hopp 7c82aa
!         {
Karsten Hopp 7c82aa
!             hashtab_T   *ht = &tv->vval.v_dict->dv_hashtab;
Karsten Hopp 7c82aa
!             long_u      todo = ht->ht_used;
Karsten Hopp 7c82aa
!             hashitem_T  *hi;
Karsten Hopp 7c82aa
!             dictitem_T  *di;
Karsten Hopp 7c82aa
! 
Karsten Hopp 7c82aa
!             for (hi = ht->ht_array; todo > 0; ++hi)
Karsten Hopp 7c82aa
!             {
Karsten Hopp 7c82aa
!                 if (!HASHITEM_EMPTY(hi))
Karsten Hopp 7c82aa
!                 {
Karsten Hopp 7c82aa
!                     --todo;
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
!                     di = dict_lookup(hi);
Karsten Hopp 7c82aa
!                     rb_hash_aset(result, rb_str_new2((char *)hi->hi_key),
Karsten Hopp 7c82aa
  						     vim_to_ruby(&di->di_tv));
Karsten Hopp 7c82aa
!                 }
Karsten Hopp 7c82aa
!             }
Karsten Hopp 7c82aa
!         }
Karsten Hopp 7c82aa
      } /* else return Qnil; */
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
      return result;
Karsten Hopp 7c82aa
--- 722,778 ----
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
      if (tv->v_type == VAR_STRING)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
! 	result = rb_str_new2((char *)(tv->vval.v_string == NULL
Karsten Hopp 7c82aa
! 						   ? "" : tv->vval.v_string));
Karsten Hopp 7c82aa
      }
Karsten Hopp 7c82aa
      else if (tv->v_type == VAR_NUMBER)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
! 	result = INT2NUM(tv->vval.v_number);
Karsten Hopp 7c82aa
      }
Karsten Hopp 7c82aa
  # ifdef FEAT_FLOAT
Karsten Hopp 7c82aa
      else if (tv->v_type == VAR_FLOAT)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
! 	result = rb_float_new(tv->vval.v_float);
Karsten Hopp 7c82aa
      }
Karsten Hopp 7c82aa
  # endif
Karsten Hopp 7c82aa
      else if (tv->v_type == VAR_LIST)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
! 	list_T      *list = tv->vval.v_list;
Karsten Hopp 7c82aa
! 	listitem_T  *curr;
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
! 	result = rb_ary_new();
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
! 	if (list != NULL)
Karsten Hopp 7c82aa
! 	{
Karsten Hopp 7c82aa
! 	    for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
Karsten Hopp 7c82aa
! 	    {
Karsten Hopp 7c82aa
! 		rb_ary_push(result, vim_to_ruby(&curr->li_tv));
Karsten Hopp 7c82aa
! 	    }
Karsten Hopp 7c82aa
! 	}
Karsten Hopp 7c82aa
      }
Karsten Hopp 7c82aa
      else if (tv->v_type == VAR_DICT)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
! 	result = rb_hash_new();
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
! 	if (tv->vval.v_dict != NULL)
Karsten Hopp 7c82aa
! 	{
Karsten Hopp 7c82aa
! 	    hashtab_T   *ht = &tv->vval.v_dict->dv_hashtab;
Karsten Hopp 7c82aa
! 	    long_u      todo = ht->ht_used;
Karsten Hopp 7c82aa
! 	    hashitem_T  *hi;
Karsten Hopp 7c82aa
! 	    dictitem_T  *di;
Karsten Hopp 7c82aa
! 
Karsten Hopp 7c82aa
! 	    for (hi = ht->ht_array; todo > 0; ++hi)
Karsten Hopp 7c82aa
! 	    {
Karsten Hopp 7c82aa
! 		if (!HASHITEM_EMPTY(hi))
Karsten Hopp 7c82aa
! 		{
Karsten Hopp 7c82aa
! 		    --todo;
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
! 		    di = dict_lookup(hi);
Karsten Hopp 7c82aa
! 		    rb_hash_aset(result, rb_str_new2((char *)hi->hi_key),
Karsten Hopp 7c82aa
  						     vim_to_ruby(&di->di_tv));
Karsten Hopp 7c82aa
! 		}
Karsten Hopp 7c82aa
! 	    }
Karsten Hopp 7c82aa
! 	}
Karsten Hopp 7c82aa
      } /* else return Qnil; */
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
      return result;
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 785,791 ****
Karsten Hopp 7c82aa
      tv = eval_expr((char_u *)StringValuePtr(str), NULL);
Karsten Hopp 7c82aa
      if (tv == NULL)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
!         return Qnil;
Karsten Hopp 7c82aa
      }
Karsten Hopp 7c82aa
      result = vim_to_ruby(tv);
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
--- 788,794 ----
Karsten Hopp 7c82aa
      tv = eval_expr((char_u *)StringValuePtr(str), NULL);
Karsten Hopp 7c82aa
      if (tv == NULL)
Karsten Hopp 7c82aa
      {
Karsten Hopp 7c82aa
! 	return Qnil;
Karsten Hopp 7c82aa
      }
Karsten Hopp 7c82aa
      result = vim_to_ruby(tv);
Karsten Hopp 7c82aa
  
Karsten Hopp 7c82aa
*** ../vim-7.2.399/src/version.c	2010-03-17 17:24:58.000000000 +0100
Karsten Hopp 7c82aa
--- src/version.c	2010-03-17 18:14:31.000000000 +0100
Karsten Hopp 7c82aa
***************
Karsten Hopp 7c82aa
*** 683,684 ****
Karsten Hopp 7c82aa
--- 683,686 ----
Karsten Hopp 7c82aa
  {   /* Add new patch number below this line */
Karsten Hopp 7c82aa
+ /**/
Karsten Hopp 7c82aa
+     400,
Karsten Hopp 7c82aa
  /**/
Karsten Hopp 7c82aa
Karsten Hopp 7c82aa
-- 
Karsten Hopp 7c82aa
Q: What do you call a fish without an eye?
Karsten Hopp 7c82aa
A: fsh!
Karsten Hopp 7c82aa
Q: What do you call a deer with no eyes?
Karsten Hopp 7c82aa
A: no eye deer.
Karsten Hopp 7c82aa
Q: What do you call a deer with no eyes and no legs?
Karsten Hopp 7c82aa
A: still no eye deer.
Karsten Hopp 7c82aa
Karsten Hopp 7c82aa
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 7c82aa
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 7c82aa
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 7c82aa
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///