lkundrak / rpms / vim

Forked from rpms/vim 4 years ago
Clone
487812e
To: vim-dev@vim.org
487812e
Subject: Patch 7.3.013
487812e
Fcc: outbox
487812e
From: Bram Moolenaar <Bram@moolenaar.net>
487812e
Mime-Version: 1.0
487812e
Content-Type: text/plain; charset=UTF-8
487812e
Content-Transfer-Encoding: 8bit
487812e
------------
487812e
487812e
Patch 7.3.013
487812e
Problem:    Dynamic loading with Ruby doesn't work for 1.9.2.
487812e
Solution:   Handle rb_str2cstr differently.  Also support dynamic loading on
487812e
	    Unix. (Jon Maken)
487812e
Files:	    src/if_ruby.c
487812e
487812e
487812e
*** ../vim-7.3.012/src/if_ruby.c	2010-08-15 21:57:25.000000000 +0200
487812e
--- src/if_ruby.c	2010-09-29 12:49:50.000000000 +0200
487812e
***************
487812e
*** 4,9 ****
487812e
--- 4,10 ----
487812e
   *
487812e
   * Ruby interface by Shugo Maeda
487812e
   *   with improvements by SegPhault (Ryan Paul)
487812e
+  *   with improvements by Jon Maken
487812e
   *
487812e
   * Do ":help uganda"  in Vim to read copying and usage conditions.
487812e
   * Do ":help credits" in Vim to see a list of people who contributed.
487812e
***************
487812e
*** 26,37 ****
487812e
  # define RUBYEXTERN extern
487812e
  #endif
487812e
  
487812e
  /*
487812e
   * This is tricky.  In ruby.h there is (inline) function rb_class_of()
487812e
   * definition.  This function use these variables.  But we want function to
487812e
   * use dll_* variables.
487812e
   */
487812e
- #ifdef DYNAMIC_RUBY
487812e
  # define rb_cFalseClass		(*dll_rb_cFalseClass)
487812e
  # define rb_cFixnum		(*dll_rb_cFixnum)
487812e
  # define rb_cNilClass		(*dll_rb_cNilClass)
487812e
--- 27,38 ----
487812e
  # define RUBYEXTERN extern
487812e
  #endif
487812e
  
487812e
+ #ifdef DYNAMIC_RUBY
487812e
  /*
487812e
   * This is tricky.  In ruby.h there is (inline) function rb_class_of()
487812e
   * definition.  This function use these variables.  But we want function to
487812e
   * use dll_* variables.
487812e
   */
487812e
  # define rb_cFalseClass		(*dll_rb_cFalseClass)
487812e
  # define rb_cFixnum		(*dll_rb_cFixnum)
487812e
  # define rb_cNilClass		(*dll_rb_cNilClass)
487812e
***************
487812e
*** 46,53 ****
487812e
--- 47,67 ----
487812e
   */
487812e
  #  define RUBY_EXPORT
487812e
  # endif
487812e
+ 
487812e
+ #if !(defined(WIN32) || defined(_WIN64))
487812e
+ # include <dlfcn.h>
487812e
+ # define HANDLE void*
487812e
+ # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
487812e
+ # define symbol_from_dll dlsym
487812e
+ # define close_dll dlclose
487812e
+ #else
487812e
+ # define load_dll LoadLibrary
487812e
+ # define symbol_from_dll GetProcAddress
487812e
+ # define close_dll FreeLibrary
487812e
  #endif
487812e
  
487812e
+ #endif  /* ifdef DYNAMIC_RUBY */
487812e
+ 
487812e
  /* suggested by Ariya Mizutani */
487812e
  #if (_MSC_VER == 1200)
487812e
  # undef _WIN32_WINNT
487812e
***************
487812e
*** 166,172 ****
487812e
  #define rb_obj_as_string		dll_rb_obj_as_string
487812e
  #define rb_obj_id			dll_rb_obj_id
487812e
  #define rb_raise			dll_rb_raise
487812e
- #define rb_str2cstr			dll_rb_str2cstr
487812e
  #define rb_str_cat			dll_rb_str_cat
487812e
  #define rb_str_concat			dll_rb_str_concat
487812e
  #define rb_str_new			dll_rb_str_new
487812e
--- 180,185 ----
487812e
***************
487812e
*** 178,187 ****
487812e
--- 191,203 ----
487812e
  # define rb_str_new2			dll_rb_str_new2
487812e
  #endif
487812e
  #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
487812e
+ # define rb_string_value		dll_rb_string_value
487812e
  # define rb_string_value_ptr		dll_rb_string_value_ptr
487812e
  # define rb_float_new			dll_rb_float_new
487812e
  # define rb_ary_new			dll_rb_ary_new
487812e
  # define rb_ary_push			dll_rb_ary_push
487812e
+ #else
487812e
+ # define rb_str2cstr			dll_rb_str2cstr
487812e
  #endif
487812e
  #ifdef RUBY19_OR_LATER
487812e
  # define rb_errinfo			dll_rb_errinfo
487812e
***************
487812e
*** 246,252 ****
487812e
--- 262,272 ----
487812e
  static VALUE (*dll_rb_obj_as_string) (VALUE);
487812e
  static VALUE (*dll_rb_obj_id) (VALUE);
487812e
  static void (*dll_rb_raise) (VALUE, const char*, ...);
487812e
+ #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
487812e
+ static VALUE (*dll_rb_string_value) (volatile VALUE*);
487812e
+ #else
487812e
  static char *(*dll_rb_str2cstr) (VALUE,int*);
487812e
+ #endif
487812e
  static VALUE (*dll_rb_str_cat) (VALUE, const char*, long);
487812e
  static VALUE (*dll_rb_str_concat) (VALUE, VALUE);
487812e
  static VALUE (*dll_rb_str_new) (const char*, long);
487812e
***************
487812e
*** 347,353 ****
487812e
--- 367,377 ----
487812e
      {"rb_obj_as_string", (RUBY_PROC*)&dll_rb_obj_as_string},
487812e
      {"rb_obj_id", (RUBY_PROC*)&dll_rb_obj_id},
487812e
      {"rb_raise", (RUBY_PROC*)&dll_rb_raise},
487812e
+ #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
487812e
+     {"rb_string_value", (RUBY_PROC*)&dll_rb_string_value},
487812e
+ #else
487812e
      {"rb_str2cstr", (RUBY_PROC*)&dll_rb_str2cstr},
487812e
+ #endif
487812e
      {"rb_str_cat", (RUBY_PROC*)&dll_rb_str_cat},
487812e
      {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat},
487812e
      {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new},
487812e
***************
487812e
*** 399,405 ****
487812e
  {
487812e
      if (hinstRuby)
487812e
      {
487812e
! 	FreeLibrary(hinstRuby);
487812e
  	hinstRuby = 0;
487812e
      }
487812e
  }
487812e
--- 423,429 ----
487812e
  {
487812e
      if (hinstRuby)
487812e
      {
487812e
! 	close_dll(hinstRuby);
487812e
  	hinstRuby = 0;
487812e
      }
487812e
  }
487812e
***************
487812e
*** 416,422 ****
487812e
  
487812e
      if (hinstRuby)
487812e
  	return OK;
487812e
!     hinstRuby = LoadLibrary(libname);
487812e
      if (!hinstRuby)
487812e
      {
487812e
  	if (verbose)
487812e
--- 440,446 ----
487812e
  
487812e
      if (hinstRuby)
487812e
  	return OK;
487812e
!     hinstRuby = load_dll(libname);
487812e
      if (!hinstRuby)
487812e
      {
487812e
  	if (verbose)
487812e
***************
487812e
*** 426,435 ****
487812e
  
487812e
      for (i = 0; ruby_funcname_table[i].ptr; ++i)
487812e
      {
487812e
! 	if (!(*ruby_funcname_table[i].ptr = GetProcAddress(hinstRuby,
487812e
  			ruby_funcname_table[i].name)))
487812e
  	{
487812e
! 	    FreeLibrary(hinstRuby);
487812e
  	    hinstRuby = 0;
487812e
  	    if (verbose)
487812e
  		EMSG2(_(e_loadfunc), ruby_funcname_table[i].name);
487812e
--- 450,459 ----
487812e
  
487812e
      for (i = 0; ruby_funcname_table[i].ptr; ++i)
487812e
      {
487812e
! 	if (!(*ruby_funcname_table[i].ptr = symbol_from_dll(hinstRuby,
487812e
  			ruby_funcname_table[i].name)))
487812e
  	{
487812e
! 	    close_dll(hinstRuby);
487812e
  	    hinstRuby = 0;
487812e
  	    if (verbose)
487812e
  		EMSG2(_(e_loadfunc), ruby_funcname_table[i].name);
487812e
*** ../vim-7.3.012/src/version.c	2010-09-29 12:37:53.000000000 +0200
487812e
--- src/version.c	2010-09-29 13:00:42.000000000 +0200
487812e
***************
487812e
*** 716,717 ****
487812e
--- 716,719 ----
487812e
  {   /* Add new patch number below this line */
487812e
+ /**/
487812e
+     13,
487812e
  /**/
487812e
487812e
-- 
487812e
hundred-and-one symptoms of being an internet addict:
487812e
223. You set up a web-cam as your home's security system.
487812e
487812e
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
487812e
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
487812e
\\\        download, build and distribute -- http://www.A-A-P.org        ///
487812e
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///