Patch 8.2.2235
Problem:    Build failure with some Ruby versions.
Solution:   Adjust the code for Ruby 3.0. (Ozaki Kiichi, closes #7564)
Files:      ci/config.mk.clang.sed, src/if_ruby.c


*** ../vim-8.2.2234/ci/config.mk.clang.sed      2020-05-26 20:09:06.910102525 
+0200
--- ci/config.mk.clang.sed      2020-12-28 15:02:12.762545837 +0100
***************
*** 1,2 ****
  /^CFLAGS[[:blank:]]*=/s/$/ -Wno-error=missing-field-initializers/
! /^RUBY_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=unknown-attributes 
-Wno-error=ignored-attributes/
--- 1,2 ----
  /^CFLAGS[[:blank:]]*=/s/$/ -Wno-error=missing-field-initializers/
! /^RUBY_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=unknown-attributes 
-Wno-error=ignored-attributes -fms-extensions/
*** ../vim-8.2.2234/src/if_ruby.c       2020-12-10 20:50:31.046939538 +0100
--- src/if_ruby.c       2020-12-28 15:02:12.762545837 +0100
***************
*** 32,39 ****
  # define RUBYEXTERN extern
  #endif
  
! #if defined(DYNAMIC_RUBY) && RUBY_VERSION >= 24
! # define USE_RUBY_INTEGER
  #endif
  
  #ifdef DYNAMIC_RUBY
--- 32,40 ----
  # define RUBYEXTERN extern
  #endif
  
! // suggested by Ariya Mizutani
! #if (_MSC_VER == 1200)
! # undef _WIN32_WINNT
  #endif
  
  #ifdef DYNAMIC_RUBY
***************
*** 42,47 ****
--- 43,52 ----
   * definition.  This function use these variables.  But we want function to
   * use dll_* variables.
   */
+ # if RUBY_VERSION >= 24
+ #  define USE_RUBY_INTEGER
+ # endif
+ 
  # define rb_cFalseClass               (*dll_rb_cFalseClass)
  # define rb_cFixnum           (*dll_rb_cFixnum)
  # if defined(USE_RUBY_INTEGER)
***************
*** 54,59 ****
--- 59,65 ----
  # define rb_cString           (*dll_rb_cString)
  # define rb_cSymbol           (*dll_rb_cSymbol)
  # define rb_cTrueClass                (*dll_rb_cTrueClass)
+ 
  # if RUBY_VERSION >= 18
  /*
   * On ver 1.8, all Ruby functions are exported with "__declspec(dllimport)"
***************
*** 64,103 ****
  #  define RUBY_EXPORT
  # endif
  
! #endif  // ifdef DYNAMIC_RUBY
! 
! // suggested by Ariya Mizutani
! #if (_MSC_VER == 1200)
! # undef _WIN32_WINNT
! #endif
! 
! #if defined(DYNAMIC_RUBY) && RUBY_VERSION >= 19
  // Ruby 1.9 defines a number of static functions which use rb_num2long and
  // rb_int2big
! # define rb_num2long rb_num2long_stub
! # define rb_int2big rb_int2big_stub
! #endif
  
! #if defined(DYNAMIC_RUBY) && RUBY_VERSION >= 19 \
!       && VIM_SIZEOF_INT < VIM_SIZEOF_LONG
  // Ruby 1.9 defines a number of static functions which use rb_fix2int and
  // rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit)
! # define rb_fix2int rb_fix2int_stub
! # define rb_num2int rb_num2int_stub
! #endif
  
! #if defined(DYNAMIC_RUBY) && RUBY_VERSION == 21
  // Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses
  // rb_gc_writebarrier_unprotect_promoted if USE_RGENGC
! # define rb_gc_writebarrier_unprotect_promoted 
rb_gc_writebarrier_unprotect_promoted_stub
! #endif
! #if defined(DYNAMIC_RUBY) && RUBY_VERSION >= 22
! # define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub
! #endif
  
! #if defined(DYNAMIC_RUBY) && RUBY_VERSION >= 26
! # define rb_ary_detransient rb_ary_detransient_stub
! #endif
  
  // On macOS pre-installed Ruby defines "SIZEOF_TIME_T" as "SIZEOF_LONG" so it
  // conflicts with the definition in config.h then causes a macro-redefined
--- 70,110 ----
  #  define RUBY_EXPORT
  # endif
  
! # if RUBY_VERSION >= 19
  // Ruby 1.9 defines a number of static functions which use rb_num2long and
  // rb_int2big
! #  define rb_num2long rb_num2long_stub
! #  define rb_int2big rb_int2big_stub
  
! #  if RUBY_VERSION >= 30 || VIM_SIZEOF_INT < VIM_SIZEOF_LONG
  // Ruby 1.9 defines a number of static functions which use rb_fix2int and
  // rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit)
! #   define rb_fix2int rb_fix2int_stub
! #   define rb_num2int rb_num2int_stub
! #  endif
! # endif
  
! # if RUBY_VERSION == 21
  // Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses
  // rb_gc_writebarrier_unprotect_promoted if USE_RGENGC
! #  define rb_gc_writebarrier_unprotect_promoted 
rb_gc_writebarrier_unprotect_promoted_stub
! # endif
  
! # if RUBY_VERSION >= 22
! #  define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub
! # endif
! 
! # if RUBY_VERSION >= 26
! #  define rb_ary_detransient rb_ary_detransient_stub
! # endif
! 
! # if RUBY_VERSION >= 30
! #  define rb_check_type rb_check_type_stub
! #  define rb_num2uint rb_num2uint_stub
! #  define ruby_malloc_size_overflow ruby_malloc_size_overflow_stub
! # endif
! 
! #endif  // ifdef DYNAMIC_RUBY
  
  // On macOS pre-installed Ruby defines "SIZEOF_TIME_T" as "SIZEOF_LONG" so it
  // conflicts with the definition in config.h then causes a macro-redefined
***************
*** 232,238 ****
  # define rb_assoc_new                 dll_rb_assoc_new
  # define rb_cObject                   (*dll_rb_cObject)
  # define rb_class_new_instance                dll_rb_class_new_instance
! # define rb_check_type                        dll_rb_check_type
  # ifdef USE_TYPEDDATA
  #  define rb_check_typeddata          dll_rb_check_typeddata
  # endif
--- 239,247 ----
  # define rb_assoc_new                 dll_rb_assoc_new
  # define rb_cObject                   (*dll_rb_cObject)
  # define rb_class_new_instance                dll_rb_class_new_instance
! # if RUBY_VERSION < 30
! #  define rb_check_type                       dll_rb_check_type
! # endif
  # ifdef USE_TYPEDDATA
  #  define rb_check_typeddata          dll_rb_check_typeddata
  # endif
***************
*** 283,289 ****
  #   define rb_fix2int                 dll_rb_fix2int
  #   define rb_num2int                 dll_rb_num2int
  #  endif
! #  define rb_num2uint                 dll_rb_num2uint
  # endif
  # define rb_num2dbl                   dll_rb_num2dbl
  # define rb_lastline_get                      dll_rb_lastline_get
--- 292,300 ----
  #   define rb_fix2int                 dll_rb_fix2int
  #   define rb_num2int                 dll_rb_num2int
  #  endif
! #  if RUBY_VERSION < 30
! #   define rb_num2uint                        dll_rb_num2uint
! #  endif
  # endif
  # define rb_num2dbl                   dll_rb_num2dbl
  # define rb_lastline_get                      dll_rb_lastline_get
***************
*** 501,507 ****
  static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
  static VALUE (*dll_rb_sprintf) (const char*, ...);
  static VALUE (*dll_rb_require) (const char*);
! static void* (*ruby_options)(int, char**);
  # endif
  
  # if defined(USE_RGENGC) && USE_RGENGC
--- 512,518 ----
  static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
  static VALUE (*dll_rb_sprintf) (const char*, ...);
  static VALUE (*dll_rb_require) (const char*);
! static void* (*dll_ruby_options)(int, char**);
  # endif
  
  # if defined(USE_RGENGC) && USE_RGENGC
***************
*** 512,543 ****
  #  endif
  # endif
  
  # if RUBY_VERSION >= 26
  void rb_ary_detransient_stub(VALUE x);
  # endif
  
! # if (RUBY_VERSION >= 19) && !defined(PROTO)
! #  if RUBY_VERSION >= 22
      long
  rb_num2long_stub(VALUE x)
! #  else
      SIGNED_VALUE
  rb_num2long_stub(VALUE x)
! #  endif
  {
      return dll_rb_num2long(x);
  }
! #  if RUBY_VERSION >= 26
      VALUE
  rb_int2big_stub(intptr_t x)
! #  else
      VALUE
  rb_int2big_stub(SIGNED_VALUE x)
! #  endif
  {
      return dll_rb_int2big(x);
  }
! #  if (RUBY_VERSION >= 19) && (VIM_SIZEOF_INT < VIM_SIZEOF_LONG)
      long
  rb_fix2int_stub(VALUE x)
  {
--- 523,560 ----
  #  endif
  # endif
  
+ # if RUBY_VERSION >= 30
+ NORETURN(static void (*dll_ruby_malloc_size_overflow)(size_t, size_t));
+ # endif
+ 
  # if RUBY_VERSION >= 26
  void rb_ary_detransient_stub(VALUE x);
  # endif
  
! // Do not generate a prototype here, VALUE isn't always defined.
! # ifndef PROTO
! #  if RUBY_VERSION >= 19
! #   if RUBY_VERSION >= 22
      long
  rb_num2long_stub(VALUE x)
! #   else
      SIGNED_VALUE
  rb_num2long_stub(VALUE x)
! #   endif
  {
      return dll_rb_num2long(x);
  }
! #   if RUBY_VERSION >= 26
      VALUE
  rb_int2big_stub(intptr_t x)
! #   else
      VALUE
  rb_int2big_stub(SIGNED_VALUE x)
! #   endif
  {
      return dll_rb_int2big(x);
  }
! #   if VIM_SIZEOF_INT < VIM_SIZEOF_LONG
      long
  rb_fix2int_stub(VALUE x)
  {
***************
*** 548,597 ****
  {
      return dll_rb_num2int(x);
  }
! #  endif
! #  if RUBY_VERSION >= 20
      VALUE
  rb_float_new_in_heap(double d)
  {
      return dll_rb_float_new(d);
  }
! #   if RUBY_VERSION >= 22
      unsigned long
  rb_num2ulong(VALUE x)
! #   else
      VALUE
  rb_num2ulong(VALUE x)
! #   endif
  {
      return (long)RSHIFT((SIGNED_VALUE)(x),1);
  }
  #  endif
! # endif
! 
!    // Do not generate a prototype here, VALUE isn't always defined.
! # if defined(USE_RGENGC) && USE_RGENGC && !defined(PROTO)
! #  if RUBY_VERSION == 21
      void
  rb_gc_writebarrier_unprotect_promoted_stub(VALUE obj)
  {
      dll_rb_gc_writebarrier_unprotect_promoted(obj);
  }
! #  else
      void
  rb_gc_writebarrier_unprotect_stub(VALUE obj)
  {
      dll_rb_gc_writebarrier_unprotect(obj);
  }
  #  endif
! # endif
! 
! # if RUBY_VERSION >= 26
      void
  rb_ary_detransient_stub(VALUE x)
  {
      dll_rb_ary_detransient(x);
  }
! # endif
  
  static HINSTANCE hinstRuby = NULL; // Instance of ruby.dll
  
--- 565,629 ----
  {
      return dll_rb_num2int(x);
  }
! #   endif
! #   if RUBY_VERSION >= 20
      VALUE
  rb_float_new_in_heap(double d)
  {
      return dll_rb_float_new(d);
  }
! #    if RUBY_VERSION >= 22
      unsigned long
  rb_num2ulong(VALUE x)
! #    else
      VALUE
  rb_num2ulong(VALUE x)
! #    endif
  {
      return (long)RSHIFT((SIGNED_VALUE)(x),1);
  }
+ #   endif
  #  endif
! #  if defined(USE_RGENGC) && USE_RGENGC
! #   if RUBY_VERSION == 21
      void
  rb_gc_writebarrier_unprotect_promoted_stub(VALUE obj)
  {
      dll_rb_gc_writebarrier_unprotect_promoted(obj);
  }
! #   else
      void
  rb_gc_writebarrier_unprotect_stub(VALUE obj)
  {
      dll_rb_gc_writebarrier_unprotect(obj);
  }
+ #   endif
  #  endif
! #  if RUBY_VERSION >= 26
      void
  rb_ary_detransient_stub(VALUE x)
  {
      dll_rb_ary_detransient(x);
  }
! #  endif
! #  if RUBY_VERSION >= 30
!     void
! rb_check_type_stub(VALUE obj, int t)
! {
!     dll_rb_check_type(obj, t);
! }
!     unsigned long
! rb_num2uint_stub(VALUE x)
! {
!     return dll_rb_num2uint(x);
! }
!     void
! ruby_malloc_size_overflow_stub(size_t x, size_t y)
! {
!     dll_ruby_malloc_size_overflow(x, y);
! }
! #  endif
! # endif // ifndef PROTO
  
  static HINSTANCE hinstRuby = NULL; // Instance of ruby.dll
  
***************
*** 748,753 ****
--- 780,788 ----
      {"rb_gc_writebarrier_unprotect", 
(RUBY_PROC*)&dll_rb_gc_writebarrier_unprotect},
  #  endif
  # endif
+ # if RUBY_VERSION >= 30
+     {"ruby_malloc_size_overflow", (RUBY_PROC*)&dll_ruby_malloc_size_overflow},
+ # endif
      {"", NULL},
  };
  
***************
*** 1827,1833 ****
      dict_T *d = (dict_T *)arg;
      dictitem_T *di;
  
!     di = dictitem_alloc((char_u 
*)RSTRING_PTR(RSTRING(rb_obj_as_string(key))));
      if (di == NULL || ruby_convert_to_vim_value(val, &di->di_tv) != OK
                                                     || dict_add(d, di) != OK)
      {
--- 1862,1868 ----
      dict_T *d = (dict_T *)arg;
      dictitem_T *di;
  
!     di = dictitem_alloc((char_u *)RSTRING_PTR(rb_obj_as_string(key)));
      if (di == NULL || ruby_convert_to_vim_value(val, &di->di_tv) != OK
                                                     || dict_add(d, di) != OK)
      {
*** ../vim-8.2.2234/src/version.c       2020-12-28 13:41:49.642920468 +0100
--- src/version.c       2020-12-28 15:04:09.326140866 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2235,
  /**/

-- 
Know this story about a nerd who fell into a river and drowned,
despite his cries of "F1! F1!"?

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202012281408.0BSE8BG7305224%40masaka.moolenaar.net.

Raspunde prin e-mail lui