summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0232
blob: b7ae0f03608c53e93d77b4019b6810b5f40832fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0232
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0232
Problem:    Ruby error does not include backtrace.
Solution:   Add an error backtrace. (Masataka Pocke Kuwabara, closes #3267)
Files:	    src/if_ruby.c


*** ../vim-8.1.0231/src/if_ruby.c	2018-07-28 17:18:05.164865356 +0200
--- src/if_ruby.c	2018-08-01 18:41:37.613550764 +0200
***************
*** 93,98 ****
--- 93,103 ----
  # define RUBY20_OR_LATER 1
  #endif
  
+ #if (defined(RUBY_VERSION) && RUBY_VERSION >= 21) \
+     || (defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 21)
+ # define RUBY21_OR_LATER 1
+ #endif
+ 
  #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
  /* Ruby 1.9 defines a number of static functions which use rb_num2long and
   * rb_int2big */
***************
*** 238,248 ****
--- 243,263 ----
  # define rb_eRuntimeError		(*dll_rb_eRuntimeError)
  # define rb_eStandardError		(*dll_rb_eStandardError)
  # define rb_eval_string_protect		dll_rb_eval_string_protect
+ # ifdef RUBY21_OR_LATER
+ #  define rb_funcallv			dll_rb_funcallv
+ # else
+ #  define rb_funcall2			dll_rb_funcall2
+ # endif
  # define rb_global_variable		dll_rb_global_variable
  # define rb_hash_aset			dll_rb_hash_aset
  # define rb_hash_new			dll_rb_hash_new
  # define rb_inspect			dll_rb_inspect
  # define rb_int2inum			dll_rb_int2inum
+ # ifdef RUBY19_OR_LATER
+ #  define rb_intern2			dll_rb_intern2
+ # else
+ #  define rb_intern			dll_rb_intern
+ # endif
  # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */
  #  if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 18
  #   define rb_fix2int			dll_rb_fix2int
***************
*** 367,377 ****
--- 382,402 ----
  static VALUE *dll_rb_eRuntimeError;
  static VALUE *dll_rb_eStandardError;
  static VALUE (*dll_rb_eval_string_protect) (const char*, int*);
+ # ifdef RUBY21_OR_LATER
+ static VALUE (*dll_rb_funcallv) (VALUE, ID, int, const VALUE*);
+ # else
+ static VALUE (*dll_rb_funcall2) (VALUE, ID, int, const VALUE*);
+ # endif
  static void (*dll_rb_global_variable) (VALUE*);
  static VALUE (*dll_rb_hash_aset) (VALUE, VALUE, VALUE);
  static VALUE (*dll_rb_hash_new) (void);
  static VALUE (*dll_rb_inspect) (VALUE);
  static VALUE (*dll_rb_int2inum) (long);
+ # ifdef RUBY19_OR_LATER
+ static ID (*dll_rb_intern2) (const char*, long);
+ # else
+ static ID (*dll_rb_intern) (const char*);
+ # endif
  # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */
  static long (*dll_rb_fix2int) (VALUE);
  static long (*dll_rb_num2int) (VALUE);
***************
*** 561,571 ****
--- 586,606 ----
      {"rb_eRuntimeError", (RUBY_PROC*)&dll_rb_eRuntimeError},
      {"rb_eStandardError", (RUBY_PROC*)&dll_rb_eStandardError},
      {"rb_eval_string_protect", (RUBY_PROC*)&dll_rb_eval_string_protect},
+ # ifdef RUBY21_OR_LATER
+     {"rb_funcallv", (RUBY_PROC*)&dll_rb_funcallv},
+ # else
+     {"rb_funcall2", (RUBY_PROC*)&dll_rb_funcall2},
+ # endif
      {"rb_global_variable", (RUBY_PROC*)&dll_rb_global_variable},
      {"rb_hash_aset", (RUBY_PROC*)&dll_rb_hash_aset},
      {"rb_hash_new", (RUBY_PROC*)&dll_rb_hash_new},
      {"rb_inspect", (RUBY_PROC*)&dll_rb_inspect},
      {"rb_int2inum", (RUBY_PROC*)&dll_rb_int2inum},
+ # ifdef RUBY19_OR_LATER
+     {"rb_intern2", (RUBY_PROC*)&dll_rb_intern2},
+ # else
+     {"rb_intern", (RUBY_PROC*)&dll_rb_intern},
+ # endif
  # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */
      {"rb_fix2int", (RUBY_PROC*)&dll_rb_fix2int},
      {"rb_num2int", (RUBY_PROC*)&dll_rb_num2int},
***************
*** 926,934 ****
--- 961,973 ----
      RUBYEXTERN VALUE ruby_errinfo;
  #endif
  #endif
+     VALUE error;
      VALUE eclass;
      VALUE einfo;
+     VALUE bt;
+     int attr;
      char buff[BUFSIZ];
+     long i;
  
  #define TAG_RETURN	0x1
  #define TAG_BREAK	0x2
***************
*** 960,971 ****
      case TAG_RAISE:
      case TAG_FATAL:
  #ifdef RUBY19_OR_LATER
! 	eclass = CLASS_OF(rb_errinfo());
! 	einfo = rb_obj_as_string(rb_errinfo());
  #else
! 	eclass = CLASS_OF(ruby_errinfo);
! 	einfo = rb_obj_as_string(ruby_errinfo);
  #endif
  	if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0)
  	{
  	    EMSG(_("E272: unhandled exception"));
--- 999,1010 ----
      case TAG_RAISE:
      case TAG_FATAL:
  #ifdef RUBY19_OR_LATER
! 	error = rb_errinfo();
  #else
! 	error = ruby_errinfo;
  #endif
+ 	eclass = CLASS_OF(error);
+ 	einfo = rb_obj_as_string(error);
  	if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0)
  	{
  	    EMSG(_("E272: unhandled exception"));
***************
*** 982,987 ****
--- 1021,1037 ----
  	    if (p) *p = '\0';
  	    EMSG(buff);
  	}
+ 
+ 	attr = syn_name2attr((char_u *)"Error");
+ # ifdef RUBY21_OR_LATER
+ 	bt = rb_funcallv(error, rb_intern("backtrace"), 0, 0);
+ 	for (i = 0; i < RARRAY_LEN(bt); i++)
+ 	    msg_attr((char_u *)RSTRING_PTR(RARRAY_AREF(bt, i)), attr);
+ # else
+ 	bt = rb_funcall2(error, rb_intern("backtrace"), 0, 0);
+ 	for (i = 0; i < RARRAY_LEN(bt); i++)
+ 	    msg_attr((char_u *)RSTRING_PTR(RARRAY_PTR(bt)[i]), attr);
+ # endif
  	break;
      default:
  	vim_snprintf(buff, BUFSIZ, _("E273: unknown longjmp status %d"), state);
*** ../vim-8.1.0231/src/version.c	2018-08-01 18:02:57.493860532 +0200
--- src/version.c	2018-08-01 18:39:43.442285284 +0200
***************
*** 796,797 ****
--- 796,799 ----
  {   /* Add new patch number below this line */
+ /**/
+     232,
  /**/

-- 
ARTHUR:  Be quiet!
DENNIS:  --but by a two-thirds majority in the case of more--
ARTHUR:  Be quiet!  I order you to be quiet!
WOMAN:   Order, eh -- who does he think he is?
ARTHUR:  I am your king!
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- Bram@Moolenaar.net -- 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    ///