Mercurial > vim
comparison src/if_ruby.c @ 14511:e6ad77cf13e0 v8.1.0269
patch 8.1.0269: Ruby Kernel.#p method always returns nil
commit https://github.com/vim/vim/commit/51e9fbf1c7ab4ec61ac959d72d5d5cb0a0b356bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 11 14:24:11 2018 +0200
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Problem: Ruby Kernel.#p method always returns nil.
Solution: Copy p method implementation from Ruby code. (Masataka Pocke
Kuwabara, closes #3315)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 11 Aug 2018 14:30:05 +0200 |
parents | 9992af1ec9d3 |
children | 3e9b24eac417 |
comparison
equal
deleted
inserted
replaced
14510:309ab903a25e | 14511:e6ad77cf13e0 |
---|---|
297 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 | 297 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 |
298 # define rb_string_value dll_rb_string_value | 298 # define rb_string_value dll_rb_string_value |
299 # define rb_string_value_ptr dll_rb_string_value_ptr | 299 # define rb_string_value_ptr dll_rb_string_value_ptr |
300 # define rb_float_new dll_rb_float_new | 300 # define rb_float_new dll_rb_float_new |
301 # define rb_ary_new dll_rb_ary_new | 301 # define rb_ary_new dll_rb_ary_new |
302 # ifdef rb_ary_new4 | |
303 # define RB_ARY_NEW4_MACRO 1 | |
304 # undef rb_ary_new4 | |
305 # endif | |
306 # define rb_ary_new4 dll_rb_ary_new4 | |
302 # define rb_ary_push dll_rb_ary_push | 307 # define rb_ary_push dll_rb_ary_push |
303 # if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK) | 308 # if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK) |
304 # ifdef __ia64 | 309 # ifdef __ia64 |
305 # define rb_ia64_bsp dll_rb_ia64_bsp | 310 # define rb_ia64_bsp dll_rb_ia64_bsp |
306 # undef ruby_init_stack | 311 # undef ruby_init_stack |
439 # endif | 444 # endif |
440 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 | 445 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 |
441 static char * (*dll_rb_string_value_ptr) (volatile VALUE*); | 446 static char * (*dll_rb_string_value_ptr) (volatile VALUE*); |
442 static VALUE (*dll_rb_float_new) (double); | 447 static VALUE (*dll_rb_float_new) (double); |
443 static VALUE (*dll_rb_ary_new) (void); | 448 static VALUE (*dll_rb_ary_new) (void); |
449 static VALUE (*dll_rb_ary_new4) (long n, const VALUE *elts); | |
444 static VALUE (*dll_rb_ary_push) (VALUE, VALUE); | 450 static VALUE (*dll_rb_ary_push) (VALUE, VALUE); |
445 # if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK) | 451 # if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK) |
446 # ifdef __ia64 | 452 # ifdef __ia64 |
447 static void * (*dll_rb_ia64_bsp) (void); | 453 static void * (*dll_rb_ia64_bsp) (void); |
448 static void (*dll_ruby_init_stack)(VALUE*, void*); | 454 static void (*dll_ruby_init_stack)(VALUE*, void*); |
645 {"rb_float_new", (RUBY_PROC*)&dll_rb_float_new}, | 651 {"rb_float_new", (RUBY_PROC*)&dll_rb_float_new}, |
646 # else | 652 # else |
647 {"rb_float_new_in_heap", (RUBY_PROC*)&dll_rb_float_new}, | 653 {"rb_float_new_in_heap", (RUBY_PROC*)&dll_rb_float_new}, |
648 # endif | 654 # endif |
649 {"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new}, | 655 {"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new}, |
656 # ifdef RB_ARY_NEW4_MACRO | |
657 {"rb_ary_new_from_values", (RUBY_PROC*)&dll_rb_ary_new4}, | |
658 # else | |
659 {"rb_ary_new4", (RUBY_PROC*)&dll_rb_ary_new4}, | |
660 # endif | |
650 {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push}, | 661 {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push}, |
651 # endif | 662 # endif |
652 # ifdef RUBY19_OR_LATER | 663 # ifdef RUBY19_OR_LATER |
653 {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big}, | 664 {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big}, |
654 {"ruby_script", (RUBY_PROC*)&dll_ruby_script}, | 665 {"ruby_script", (RUBY_PROC*)&dll_ruby_script}, |
1575 | 1586 |
1576 static VALUE f_p(int argc, VALUE *argv, VALUE self UNUSED) | 1587 static VALUE f_p(int argc, VALUE *argv, VALUE self UNUSED) |
1577 { | 1588 { |
1578 int i; | 1589 int i; |
1579 VALUE str = rb_str_new("", 0); | 1590 VALUE str = rb_str_new("", 0); |
1591 VALUE ret = Qnil; | |
1580 | 1592 |
1581 for (i = 0; i < argc; i++) | 1593 for (i = 0; i < argc; i++) |
1582 { | 1594 { |
1583 if (i > 0) rb_str_cat(str, ", ", 2); | 1595 if (i > 0) rb_str_cat(str, ", ", 2); |
1584 rb_str_concat(str, rb_inspect(argv[i])); | 1596 rb_str_concat(str, rb_inspect(argv[i])); |
1585 } | 1597 } |
1586 MSG(RSTRING_PTR(str)); | 1598 MSG(RSTRING_PTR(str)); |
1587 return Qnil; | 1599 |
1600 if (argc == 1) | |
1601 ret = argv[0]; | |
1602 else if (argc > 1) | |
1603 ret = rb_ary_new4(argc, argv); | |
1604 return ret; | |
1588 } | 1605 } |
1589 | 1606 |
1590 static void ruby_io_init(void) | 1607 static void ruby_io_init(void) |
1591 { | 1608 { |
1592 #ifndef DYNAMIC_RUBY | 1609 #ifndef DYNAMIC_RUBY |