|
1 To: [email protected] |
|
2 Subject: Patch 7.2.400 |
|
3 Fcc: outbox |
|
4 From: Bram Moolenaar <[email protected]> |
|
5 Mime-Version: 1.0 |
|
6 Content-Type: text/plain; charset=UTF-8 |
|
7 Content-Transfer-Encoding: 8bit |
|
8 ------------ |
|
9 |
|
10 Patch 7.2.400 (after 7.2.387) |
|
11 Problem: Dynamic Ruby is not initialised properly for version 1.9.1. |
|
12 Ruby cannot create strings from NULL. |
|
13 Solution: Cleanup #ifdefs. Handle NULL like an empty string. Add |
|
14 ruby_init_stack. (Sergey Khorev) |
|
15 Files: src/if_ruby.c |
|
16 |
|
17 |
|
18 *** ../vim-7.2.399/src/if_ruby.c 2010-03-10 12:46:38.000000000 +0100 |
|
19 --- src/if_ruby.c 2010-03-17 17:37:53.000000000 +0100 |
|
20 *************** |
|
21 *** 53,58 **** |
|
22 --- 53,63 ---- |
|
23 # undef _WIN32_WINNT |
|
24 #endif |
|
25 |
|
26 + #if (defined(RUBY_VERSION) && RUBY_VERSION >= 19) \ |
|
27 + || (defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19) |
|
28 + # define RUBY19_OR_LATER 1 |
|
29 + #endif |
|
30 + |
|
31 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 |
|
32 /* Ruby 1.9 defines a number of static functions which use rb_num2long and |
|
33 * rb_int2big */ |
|
34 *************** |
|
35 *** 61,67 **** |
|
36 #endif |
|
37 |
|
38 #include <ruby.h> |
|
39 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
|
40 # include <ruby/encoding.h> |
|
41 #endif |
|
42 |
|
43 --- 66,72 ---- |
|
44 #endif |
|
45 |
|
46 #include <ruby.h> |
|
47 ! #ifdef RUBY19_OR_LATER |
|
48 # include <ruby/encoding.h> |
|
49 #endif |
|
50 |
|
51 *************** |
|
52 *** 172,179 **** |
|
53 # define rb_ary_new dll_rb_ary_new |
|
54 # define rb_ary_push dll_rb_ary_push |
|
55 #endif |
|
56 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 \ |
|
57 ! || defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 |
|
58 # define rb_errinfo dll_rb_errinfo |
|
59 #else |
|
60 # define ruby_errinfo (*dll_ruby_errinfo) |
|
61 --- 177,183 ---- |
|
62 # define rb_ary_new dll_rb_ary_new |
|
63 # define rb_ary_push dll_rb_ary_push |
|
64 #endif |
|
65 ! #ifdef RUBY19_OR_LATER |
|
66 # define rb_errinfo dll_rb_errinfo |
|
67 #else |
|
68 # define ruby_errinfo (*dll_ruby_errinfo) |
|
69 *************** |
|
70 *** 185,196 **** |
|
71 # define rb_w32_snprintf dll_rb_w32_snprintf |
|
72 #endif |
|
73 |
|
74 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
|
75 # define ruby_script dll_ruby_script |
|
76 # define rb_enc_find_index dll_rb_enc_find_index |
|
77 # define rb_enc_find dll_rb_enc_find |
|
78 # define rb_enc_str_new dll_rb_enc_str_new |
|
79 # define rb_sprintf dll_rb_sprintf |
|
80 #endif |
|
81 |
|
82 /* |
|
83 --- 189,201 ---- |
|
84 # define rb_w32_snprintf dll_rb_w32_snprintf |
|
85 #endif |
|
86 |
|
87 ! #ifdef RUBY19_OR_LATER |
|
88 # define ruby_script dll_ruby_script |
|
89 # define rb_enc_find_index dll_rb_enc_find_index |
|
90 # define rb_enc_find dll_rb_enc_find |
|
91 # define rb_enc_str_new dll_rb_enc_str_new |
|
92 # define rb_sprintf dll_rb_sprintf |
|
93 + # define ruby_init_stack dll_ruby_init_stack |
|
94 #endif |
|
95 |
|
96 /* |
|
97 *************** |
|
98 *** 240,247 **** |
|
99 static VALUE (*dll_rb_str_concat) (VALUE, VALUE); |
|
100 static VALUE (*dll_rb_str_new) (const char*, long); |
|
101 static VALUE (*dll_rb_str_new2) (const char*); |
|
102 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 \ |
|
103 ! || defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 |
|
104 static VALUE (*dll_rb_errinfo) (void); |
|
105 #else |
|
106 static VALUE *dll_ruby_errinfo; |
|
107 --- 245,251 ---- |
|
108 static VALUE (*dll_rb_str_concat) (VALUE, VALUE); |
|
109 static VALUE (*dll_rb_str_new) (const char*, long); |
|
110 static VALUE (*dll_rb_str_new2) (const char*); |
|
111 ! #ifdef RUBY19_OR_LATER |
|
112 static VALUE (*dll_rb_errinfo) (void); |
|
113 #else |
|
114 static VALUE *dll_ruby_errinfo; |
|
115 *************** |
|
116 *** 255,276 **** |
|
117 static VALUE (*dll_rb_ary_new) (void); |
|
118 static VALUE (*dll_rb_ary_push) (VALUE, VALUE); |
|
119 #endif |
|
120 ! #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 |
|
121 static VALUE (*dll_rb_int2big)(SIGNED_VALUE); |
|
122 #endif |
|
123 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 |
|
124 static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...); |
|
125 #endif |
|
126 |
|
127 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
|
128 static void (*dll_ruby_script) (const char*); |
|
129 static int (*dll_rb_enc_find_index) (const char*); |
|
130 static rb_encoding* (*dll_rb_enc_find) (const char*); |
|
131 static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*); |
|
132 static VALUE (*dll_rb_sprintf) (const char*, ...); |
|
133 #endif |
|
134 |
|
135 ! #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 |
|
136 static SIGNED_VALUE rb_num2long_stub(VALUE x) |
|
137 { |
|
138 return dll_rb_num2long(x); |
|
139 --- 259,281 ---- |
|
140 static VALUE (*dll_rb_ary_new) (void); |
|
141 static VALUE (*dll_rb_ary_push) (VALUE, VALUE); |
|
142 #endif |
|
143 ! #ifdef RUBY19_OR_LATER |
|
144 static VALUE (*dll_rb_int2big)(SIGNED_VALUE); |
|
145 #endif |
|
146 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 |
|
147 static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...); |
|
148 #endif |
|
149 |
|
150 ! #ifdef RUBY19_OR_LATER |
|
151 static void (*dll_ruby_script) (const char*); |
|
152 static int (*dll_rb_enc_find_index) (const char*); |
|
153 static rb_encoding* (*dll_rb_enc_find) (const char*); |
|
154 static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*); |
|
155 static VALUE (*dll_rb_sprintf) (const char*, ...); |
|
156 + static void (*ruby_init_stack)(VALUE*); |
|
157 #endif |
|
158 |
|
159 ! #ifdef RUBY19_OR_LATER |
|
160 static SIGNED_VALUE rb_num2long_stub(VALUE x) |
|
161 { |
|
162 return dll_rb_num2long(x); |
|
163 *************** |
|
164 *** 336,343 **** |
|
165 {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat}, |
|
166 {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new}, |
|
167 {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2}, |
|
168 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 \ |
|
169 ! || defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 |
|
170 {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo}, |
|
171 #else |
|
172 {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo}, |
|
173 --- 341,347 ---- |
|
174 {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat}, |
|
175 {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new}, |
|
176 {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2}, |
|
177 ! #ifdef RUBY19_OR_LATER |
|
178 {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo}, |
|
179 #else |
|
180 {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo}, |
|
181 *************** |
|
182 *** 360,374 **** |
|
183 {"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new}, |
|
184 {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push}, |
|
185 #endif |
|
186 ! #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 |
|
187 {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big}, |
|
188 - #endif |
|
189 - #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
|
190 {"ruby_script", (RUBY_PROC*)&dll_ruby_script}, |
|
191 {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index}, |
|
192 {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find}, |
|
193 {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new}, |
|
194 {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf}, |
|
195 #endif |
|
196 {"", NULL}, |
|
197 }; |
|
198 --- 364,377 ---- |
|
199 {"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new}, |
|
200 {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push}, |
|
201 #endif |
|
202 ! #ifdef RUBY19_OR_LATER |
|
203 {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big}, |
|
204 {"ruby_script", (RUBY_PROC*)&dll_ruby_script}, |
|
205 {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index}, |
|
206 {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find}, |
|
207 {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new}, |
|
208 {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf}, |
|
209 + {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack}, |
|
210 #endif |
|
211 {"", NULL}, |
|
212 }; |
|
213 *************** |
|
214 *** 467,473 **** |
|
215 static VALUE |
|
216 vim_str2rb_enc_str(const char *s) |
|
217 { |
|
218 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
|
219 int isnum; |
|
220 long lval; |
|
221 char_u *sval; |
|
222 --- 470,476 ---- |
|
223 static VALUE |
|
224 vim_str2rb_enc_str(const char *s) |
|
225 { |
|
226 ! #ifdef RUBY19_OR_LATER |
|
227 int isnum; |
|
228 long lval; |
|
229 char_u *sval; |
|
230 *************** |
|
231 *** 489,495 **** |
|
232 static VALUE |
|
233 eval_enc_string_protect(const char *str, int *state) |
|
234 { |
|
235 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
|
236 int isnum; |
|
237 long lval; |
|
238 char_u *sval; |
|
239 --- 492,498 ---- |
|
240 static VALUE |
|
241 eval_enc_string_protect(const char *str, int *state) |
|
242 { |
|
243 ! #ifdef RUBY19_OR_LATER |
|
244 int isnum; |
|
245 long lval; |
|
246 char_u *sval; |
|
247 *************** |
|
248 *** 591,606 **** |
|
249 char *argv[] = {"gvim.exe"}; |
|
250 NtInitialize(&argc, &argv); |
|
251 #endif |
|
252 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
|
253 RUBY_INIT_STACK; |
|
254 #endif |
|
255 ruby_init(); |
|
256 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
|
257 ruby_script("vim-ruby"); |
|
258 #endif |
|
259 ruby_init_loadpath(); |
|
260 ruby_io_init(); |
|
261 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 |
|
262 rb_enc_find_index("encdb"); |
|
263 #endif |
|
264 ruby_vim_init(); |
|
265 --- 594,609 ---- |
|
266 char *argv[] = {"gvim.exe"}; |
|
267 NtInitialize(&argc, &argv); |
|
268 #endif |
|
269 ! #ifdef RUBY19_OR_LATER |
|
270 RUBY_INIT_STACK; |
|
271 #endif |
|
272 ruby_init(); |
|
273 ! #ifdef RUBY19_OR_LATER |
|
274 ruby_script("vim-ruby"); |
|
275 #endif |
|
276 ruby_init_loadpath(); |
|
277 ruby_io_init(); |
|
278 ! #ifdef RUBY19_OR_LATER |
|
279 rb_enc_find_index("encdb"); |
|
280 #endif |
|
281 ruby_vim_init(); |
|
282 *************** |
|
283 *** 657,664 **** |
|
284 break; |
|
285 case TAG_RAISE: |
|
286 case TAG_FATAL: |
|
287 ! #if defined(RUBY_VERSION) && RUBY_VERSION >= 19 \ |
|
288 ! || defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 |
|
289 eclass = CLASS_OF(rb_errinfo()); |
|
290 einfo = rb_obj_as_string(rb_errinfo()); |
|
291 #else |
|
292 --- 660,666 ---- |
|
293 break; |
|
294 case TAG_RAISE: |
|
295 case TAG_FATAL: |
|
296 ! #ifdef RUBY19_OR_LATER |
|
297 eclass = CLASS_OF(rb_errinfo()); |
|
298 einfo = rb_obj_as_string(rb_errinfo()); |
|
299 #else |
|
300 *************** |
|
301 *** 720,775 **** |
|
302 |
|
303 if (tv->v_type == VAR_STRING) |
|
304 { |
|
305 ! result = rb_str_new2((char *)tv->vval.v_string); |
|
306 } |
|
307 else if (tv->v_type == VAR_NUMBER) |
|
308 { |
|
309 ! result = INT2NUM(tv->vval.v_number); |
|
310 } |
|
311 # ifdef FEAT_FLOAT |
|
312 else if (tv->v_type == VAR_FLOAT) |
|
313 { |
|
314 ! result = rb_float_new(tv->vval.v_float); |
|
315 } |
|
316 # endif |
|
317 else if (tv->v_type == VAR_LIST) |
|
318 { |
|
319 ! list_T *list = tv->vval.v_list; |
|
320 ! listitem_T *curr; |
|
321 |
|
322 ! result = rb_ary_new(); |
|
323 |
|
324 ! if (list != NULL) |
|
325 ! { |
|
326 ! for (curr = list->lv_first; curr != NULL; curr = curr->li_next) |
|
327 ! { |
|
328 ! rb_ary_push(result, vim_to_ruby(&curr->li_tv)); |
|
329 ! } |
|
330 ! } |
|
331 } |
|
332 else if (tv->v_type == VAR_DICT) |
|
333 { |
|
334 ! result = rb_hash_new(); |
|
335 |
|
336 ! if (tv->vval.v_dict != NULL) |
|
337 ! { |
|
338 ! hashtab_T *ht = &tv->vval.v_dict->dv_hashtab; |
|
339 ! long_u todo = ht->ht_used; |
|
340 ! hashitem_T *hi; |
|
341 ! dictitem_T *di; |
|
342 ! |
|
343 ! for (hi = ht->ht_array; todo > 0; ++hi) |
|
344 ! { |
|
345 ! if (!HASHITEM_EMPTY(hi)) |
|
346 ! { |
|
347 ! --todo; |
|
348 |
|
349 ! di = dict_lookup(hi); |
|
350 ! rb_hash_aset(result, rb_str_new2((char *)hi->hi_key), |
|
351 vim_to_ruby(&di->di_tv)); |
|
352 ! } |
|
353 ! } |
|
354 ! } |
|
355 } /* else return Qnil; */ |
|
356 |
|
357 return result; |
|
358 --- 722,778 ---- |
|
359 |
|
360 if (tv->v_type == VAR_STRING) |
|
361 { |
|
362 ! result = rb_str_new2((char *)(tv->vval.v_string == NULL |
|
363 ! ? "" : tv->vval.v_string)); |
|
364 } |
|
365 else if (tv->v_type == VAR_NUMBER) |
|
366 { |
|
367 ! result = INT2NUM(tv->vval.v_number); |
|
368 } |
|
369 # ifdef FEAT_FLOAT |
|
370 else if (tv->v_type == VAR_FLOAT) |
|
371 { |
|
372 ! result = rb_float_new(tv->vval.v_float); |
|
373 } |
|
374 # endif |
|
375 else if (tv->v_type == VAR_LIST) |
|
376 { |
|
377 ! list_T *list = tv->vval.v_list; |
|
378 ! listitem_T *curr; |
|
379 |
|
380 ! result = rb_ary_new(); |
|
381 |
|
382 ! if (list != NULL) |
|
383 ! { |
|
384 ! for (curr = list->lv_first; curr != NULL; curr = curr->li_next) |
|
385 ! { |
|
386 ! rb_ary_push(result, vim_to_ruby(&curr->li_tv)); |
|
387 ! } |
|
388 ! } |
|
389 } |
|
390 else if (tv->v_type == VAR_DICT) |
|
391 { |
|
392 ! result = rb_hash_new(); |
|
393 |
|
394 ! if (tv->vval.v_dict != NULL) |
|
395 ! { |
|
396 ! hashtab_T *ht = &tv->vval.v_dict->dv_hashtab; |
|
397 ! long_u todo = ht->ht_used; |
|
398 ! hashitem_T *hi; |
|
399 ! dictitem_T *di; |
|
400 ! |
|
401 ! for (hi = ht->ht_array; todo > 0; ++hi) |
|
402 ! { |
|
403 ! if (!HASHITEM_EMPTY(hi)) |
|
404 ! { |
|
405 ! --todo; |
|
406 |
|
407 ! di = dict_lookup(hi); |
|
408 ! rb_hash_aset(result, rb_str_new2((char *)hi->hi_key), |
|
409 vim_to_ruby(&di->di_tv)); |
|
410 ! } |
|
411 ! } |
|
412 ! } |
|
413 } /* else return Qnil; */ |
|
414 |
|
415 return result; |
|
416 *************** |
|
417 *** 785,791 **** |
|
418 tv = eval_expr((char_u *)StringValuePtr(str), NULL); |
|
419 if (tv == NULL) |
|
420 { |
|
421 ! return Qnil; |
|
422 } |
|
423 result = vim_to_ruby(tv); |
|
424 |
|
425 --- 788,794 ---- |
|
426 tv = eval_expr((char_u *)StringValuePtr(str), NULL); |
|
427 if (tv == NULL) |
|
428 { |
|
429 ! return Qnil; |
|
430 } |
|
431 result = vim_to_ruby(tv); |
|
432 |
|
433 *** ../vim-7.2.399/src/version.c 2010-03-17 17:24:58.000000000 +0100 |
|
434 --- src/version.c 2010-03-17 18:14:31.000000000 +0100 |
|
435 *************** |
|
436 *** 683,684 **** |
|
437 --- 683,686 ---- |
|
438 { /* Add new patch number below this line */ |
|
439 + /**/ |
|
440 + 400, |
|
441 /**/ |
|
442 |
|
443 -- |
|
444 Q: What do you call a fish without an eye? |
|
445 A: fsh! |
|
446 Q: What do you call a deer with no eyes? |
|
447 A: no eye deer. |
|
448 Q: What do you call a deer with no eyes and no legs? |
|
449 A: still no eye deer. |
|
450 |
|
451 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ |
|
452 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ |
|
453 \\\ download, build and distribute -- http://www.A-A-P.org /// |
|
454 \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |