Karsten Hopp 4a8814
To: vim_dev@googlegroups.com
Karsten Hopp 4a8814
Subject: Patch 7.3.058
Karsten Hopp 4a8814
Fcc: outbox
Karsten Hopp 4a8814
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 4a8814
Mime-Version: 1.0
Karsten Hopp 4a8814
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 4a8814
Content-Transfer-Encoding: 8bit
Karsten Hopp 4a8814
------------
Karsten Hopp 4a8814
Karsten Hopp 4a8814
Patch 7.3.058
Karsten Hopp 4a8814
Problem:    Error "code converter not found" when loading Ruby script.
Karsten Hopp 4a8814
Solution:   Load Gem module. (Yasuhiro Matsumoto)
Karsten Hopp 4a8814
Files:	    src/if_ruby.c
Karsten Hopp 4a8814
Karsten Hopp 4a8814
Karsten Hopp 4a8814
*** ../vim-7.3.057/src/if_ruby.c	2010-10-27 17:40:53.000000000 +0200
Karsten Hopp 4a8814
--- src/if_ruby.c	2010-11-16 14:37:48.000000000 +0100
Karsten Hopp 4a8814
***************
Karsten Hopp 4a8814
*** 229,234 ****
Karsten Hopp 4a8814
--- 229,237 ----
Karsten Hopp 4a8814
  # define rb_enc_find_index		dll_rb_enc_find_index
Karsten Hopp 4a8814
  # define rb_enc_find			dll_rb_enc_find
Karsten Hopp 4a8814
  # define rb_enc_str_new			dll_rb_enc_str_new
Karsten Hopp 4a8814
+ # define rb_intern2			dll_rb_intern2
Karsten Hopp 4a8814
+ # define rb_const_remove		dll_rb_const_remove
Karsten Hopp 4a8814
+ # define Init_prelude			dll_Init_prelude
Karsten Hopp 4a8814
  # define rb_sprintf			dll_rb_sprintf
Karsten Hopp 4a8814
  # define ruby_init_stack		dll_ruby_init_stack
Karsten Hopp 4a8814
  #endif
Karsten Hopp 4a8814
***************
Karsten Hopp 4a8814
*** 317,322 ****
Karsten Hopp 4a8814
--- 320,328 ----
Karsten Hopp 4a8814
  static int (*dll_rb_enc_find_index) (const char*);
Karsten Hopp 4a8814
  static rb_encoding* (*dll_rb_enc_find) (const char*);
Karsten Hopp 4a8814
  static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
Karsten Hopp 4a8814
+ static ID (*dll_rb_intern2) (const char*, long);
Karsten Hopp 4a8814
+ static void (*dll_Init_prelude) (void);
Karsten Hopp 4a8814
+ static VALUE (*dll_rb_const_remove) (VALUE, ID);
Karsten Hopp 4a8814
  static VALUE (*dll_rb_sprintf) (const char*, ...);
Karsten Hopp 4a8814
  static void (*ruby_init_stack)(VALUE*);
Karsten Hopp 4a8814
  #endif
Karsten Hopp 4a8814
***************
Karsten Hopp 4a8814
*** 425,430 ****
Karsten Hopp 4a8814
--- 431,439 ----
Karsten Hopp 4a8814
      {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
Karsten Hopp 4a8814
      {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find},
Karsten Hopp 4a8814
      {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
Karsten Hopp 4a8814
+     {"rb_intern2", (RUBY_PROC*)&dll_rb_intern2},
Karsten Hopp 4a8814
+     {"rb_const_remove", (RUBY_PROC*)&dll_rb_const_remove},
Karsten Hopp 4a8814
+     {"Init_prelude", (RUBY_PROC*)&dll_Init_prelude},
Karsten Hopp 4a8814
      {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
Karsten Hopp 4a8814
      {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack},
Karsten Hopp 4a8814
  #endif
Karsten Hopp 4a8814
***************
Karsten Hopp 4a8814
*** 662,667 ****
Karsten Hopp 4a8814
--- 671,682 ----
Karsten Hopp 4a8814
  	    ruby_io_init();
Karsten Hopp 4a8814
  #ifdef RUBY19_OR_LATER
Karsten Hopp 4a8814
  	    rb_enc_find_index("encdb");
Karsten Hopp 4a8814
+ 
Karsten Hopp 4a8814
+ 	    /* This avoids the error "Encoding::ConverterNotFoundError: code
Karsten Hopp 4a8814
+ 	     * converter not found (UTF-16LE to ASCII-8BIT)". */
Karsten Hopp 4a8814
+ 	    rb_define_module("Gem");
Karsten Hopp 4a8814
+ 	    Init_prelude();
Karsten Hopp 4a8814
+ 	    rb_const_remove(rb_cObject, rb_intern2("TMP_RUBY_PREFIX", 15));
Karsten Hopp 4a8814
  #endif
Karsten Hopp 4a8814
  	    ruby_vim_init();
Karsten Hopp 4a8814
  	    ruby_initialized = 1;
Karsten Hopp 4a8814
***************
Karsten Hopp 4a8814
*** 946,958 ****
Karsten Hopp 4a8814
  
Karsten Hopp 4a8814
  static VALUE get_buffer_line(buf_T *buf, linenr_T n)
Karsten Hopp 4a8814
  {
Karsten Hopp 4a8814
!     if (n > 0 && n <= buf->b_ml.ml_line_count)
Karsten Hopp 4a8814
!     {
Karsten Hopp 4a8814
! 	char *line = (char *)ml_get_buf(buf, n, FALSE);
Karsten Hopp 4a8814
! 	return line ? vim_str2rb_enc_str(line) : Qnil;
Karsten Hopp 4a8814
!     }
Karsten Hopp 4a8814
!     rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
Karsten Hopp 4a8814
!     return Qnil; /* For stop warning */
Karsten Hopp 4a8814
  }
Karsten Hopp 4a8814
  
Karsten Hopp 4a8814
  static VALUE buffer_aref(VALUE self, VALUE num)
Karsten Hopp 4a8814
--- 961,969 ----
Karsten Hopp 4a8814
  
Karsten Hopp 4a8814
  static VALUE get_buffer_line(buf_T *buf, linenr_T n)
Karsten Hopp 4a8814
  {
Karsten Hopp 4a8814
!     if (n <= 0 || n > buf->b_ml.ml_line_count)
Karsten Hopp 4a8814
! 	rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
Karsten Hopp 4a8814
!     return vim_str2rb_enc_str((char *)ml_get_buf(buf, n, FALSE));
Karsten Hopp 4a8814
  }
Karsten Hopp 4a8814
  
Karsten Hopp 4a8814
  static VALUE buffer_aref(VALUE self, VALUE num)
Karsten Hopp 4a8814
***************
Karsten Hopp 4a8814
*** 991,999 ****
Karsten Hopp 4a8814
      else
Karsten Hopp 4a8814
      {
Karsten Hopp 4a8814
  	rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
Karsten Hopp 4a8814
- #ifndef __GNUC__
Karsten Hopp 4a8814
- 	return Qnil; /* For stop warning */
Karsten Hopp 4a8814
- #endif
Karsten Hopp 4a8814
      }
Karsten Hopp 4a8814
      return str;
Karsten Hopp 4a8814
  }
Karsten Hopp 4a8814
--- 1002,1007 ----
Karsten Hopp 4a8814
***************
Karsten Hopp 4a8814
*** 1048,1054 ****
Karsten Hopp 4a8814
      long	n = NUM2LONG(num);
Karsten Hopp 4a8814
      aco_save_T	aco;
Karsten Hopp 4a8814
  
Karsten Hopp 4a8814
!     if (line == NULL) {
Karsten Hopp 4a8814
  	rb_raise(rb_eIndexError, "NULL line");
Karsten Hopp 4a8814
      }
Karsten Hopp 4a8814
      else if (n >= 0 && n <= buf->b_ml.ml_line_count)
Karsten Hopp 4a8814
--- 1056,1063 ----
Karsten Hopp 4a8814
      long	n = NUM2LONG(num);
Karsten Hopp 4a8814
      aco_save_T	aco;
Karsten Hopp 4a8814
  
Karsten Hopp 4a8814
!     if (line == NULL)
Karsten Hopp 4a8814
!     {
Karsten Hopp 4a8814
  	rb_raise(rb_eIndexError, "NULL line");
Karsten Hopp 4a8814
      }
Karsten Hopp 4a8814
      else if (n >= 0 && n <= buf->b_ml.ml_line_count)
Karsten Hopp 4a8814
***************
Karsten Hopp 4a8814
*** 1072,1078 ****
Karsten Hopp 4a8814
  
Karsten Hopp 4a8814
  	update_curbuf(NOT_VALID);
Karsten Hopp 4a8814
      }
Karsten Hopp 4a8814
!     else {
Karsten Hopp 4a8814
  	rb_raise(rb_eIndexError, "line number %ld out of range", n);
Karsten Hopp 4a8814
      }
Karsten Hopp 4a8814
      return str;
Karsten Hopp 4a8814
--- 1081,1088 ----
Karsten Hopp 4a8814
  
Karsten Hopp 4a8814
  	update_curbuf(NOT_VALID);
Karsten Hopp 4a8814
      }
Karsten Hopp 4a8814
!     else
Karsten Hopp 4a8814
!     {
Karsten Hopp 4a8814
  	rb_raise(rb_eIndexError, "line number %ld out of range", n);
Karsten Hopp 4a8814
      }
Karsten Hopp 4a8814
      return str;
Karsten Hopp 4a8814
*** ../vim-7.3.057/src/version.c	2010-11-16 14:05:48.000000000 +0100
Karsten Hopp 4a8814
--- src/version.c	2010-11-16 14:44:42.000000000 +0100
Karsten Hopp 4a8814
***************
Karsten Hopp 4a8814
*** 716,717 ****
Karsten Hopp 4a8814
--- 716,719 ----
Karsten Hopp 4a8814
  {   /* Add new patch number below this line */
Karsten Hopp 4a8814
+ /**/
Karsten Hopp 4a8814
+     58,
Karsten Hopp 4a8814
  /**/
Karsten Hopp 4a8814
Karsten Hopp 4a8814
-- 
Karsten Hopp 4a8814
SIGIRO -- irony detected (iron core dumped)
Karsten Hopp 4a8814
Karsten Hopp 4a8814
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 4a8814
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 4a8814
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 4a8814
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///