Patch 8.1.0269
Problem: Ruby Kernel.#p method always returns nil.
Solution: Copy p method implementation from Ruby code. (Masataka Pocke
Kuwabara, closes #3315)
Files: src/if_ruby.c, src/testdir/test_ruby.vim
*** ../vim-8.1.0268/src/if_ruby.c 2018-08-04 17:24:39.062825210 +0200
--- src/if_ruby.c 2018-08-11 14:23:48.613860602 +0200
***************
*** 299,304 ****
--- 299,309 ----
# define rb_string_value_ptr dll_rb_string_value_ptr
# define rb_float_new dll_rb_float_new
# define rb_ary_new dll_rb_ary_new
+ # ifdef rb_ary_new4
+ # define RB_ARY_NEW4_MACRO 1
+ # undef rb_ary_new4
+ # endif
+ # define rb_ary_new4 dll_rb_ary_new4
# define rb_ary_push dll_rb_ary_push
# if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK)
# ifdef __ia64
***************
*** 441,446 ****
--- 446,452 ----
static char * (*dll_rb_string_value_ptr) (volatile VALUE*);
static VALUE (*dll_rb_float_new) (double);
static VALUE (*dll_rb_ary_new) (void);
+ static VALUE (*dll_rb_ary_new4) (long n, const VALUE *elts);
static VALUE (*dll_rb_ary_push) (VALUE, VALUE);
# if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK)
# ifdef __ia64
***************
*** 647,652 ****
--- 653,663 ----
{"rb_float_new_in_heap", (RUBY_PROC*)&dll_rb_float_new},
# endif
{"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new},
+ # ifdef RB_ARY_NEW4_MACRO
+ {"rb_ary_new_from_values", (RUBY_PROC*)&dll_rb_ary_new4},
+ # else
+ {"rb_ary_new4", (RUBY_PROC*)&dll_rb_ary_new4},
+ # endif
{"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push},
# endif
# ifdef RUBY19_OR_LATER
***************
*** 1577,1582 ****
--- 1588,1594 ----
{
int i;
VALUE str = rb_str_new("", 0);
+ VALUE ret = Qnil;
for (i = 0; i < argc; i++)
{
***************
*** 1584,1590 ****
rb_str_concat(str, rb_inspect(argv[i]));
}
MSG(RSTRING_PTR(str));
! return Qnil;
}
static void ruby_io_init(void)
--- 1596,1607 ----
rb_str_concat(str, rb_inspect(argv[i]));
}
MSG(RSTRING_PTR(str));
!
! if (argc == 1)
! ret = argv[0];
! else if (argc > 1)
! ret = rb_ary_new4(argc, argv);
! return ret;
}
static void ruby_io_init(void)
*** ../vim-8.1.0268/src/testdir/test_ruby.vim 2018-07-28 17:29:15.757096343
+0200
--- src/testdir/test_ruby.vim 2018-08-11 14:17:07.396211894 +0200
***************
*** 363,366 ****
--- 363,379 ----
ruby p 'Just a test'
let messages = split(execute('message'), "\n")
call assert_equal('"Just a test"', messages[-1])
+
+ " Check return values of p method
+
+ call assert_equal('123', RubyEval('p(123)'))
+ call assert_equal('[1, 2, 3]', RubyEval('p(1, 2, 3)'))
+
+ " Avoid the "message maintainer" line.
+ let $LANG = ''
+ messages clear
+ call assert_equal('true', RubyEval('p() == nil'))
+
+ let messages = split(execute('message'), "\n")
+ call assert_equal(0, len(messages))
endfunc
*** ../vim-8.1.0268/src/version.c 2018-08-11 13:57:16.215969777 +0200
--- src/version.c 2018-08-11 14:22:56.922175770 +0200
***************
*** 796,797 ****
--- 796,799 ----
{ /* Add new patch number below this line */
+ /**/
+ 269,
/**/
--
SIGFUN -- signature too funny (core dumped)
/// 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].
For more options, visit https://groups.google.com/d/optout.