Mercurial > vim
comparison src/if_ruby.c @ 18798:f0f9692d4487 v8.1.2387
patch 8.1.2387: using old C style comments
Commit: https://github.com/vim/vim/commit/2ab2e8608f9b2c85432715bb9a7f226fdbf8cd35
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 4 21:24:53 2019 +0100
patch 8.1.2387: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 04 Dec 2019 21:30:04 +0100 |
parents | 366978ec2c03 |
children | 23df4b83fd31 |
comparison
equal
deleted
inserted
replaced
18797:76af6d0ea316 | 18798:f0f9692d4487 |
---|---|
22 #ifdef _WIN32 | 22 #ifdef _WIN32 |
23 # if !defined(DYNAMIC_RUBY_VER) || (DYNAMIC_RUBY_VER < 18) | 23 # if !defined(DYNAMIC_RUBY_VER) || (DYNAMIC_RUBY_VER < 18) |
24 # define NT | 24 # define NT |
25 # endif | 25 # endif |
26 # ifndef DYNAMIC_RUBY | 26 # ifndef DYNAMIC_RUBY |
27 # define IMPORT /* For static dll usage __declspec(dllimport) */ | 27 # define IMPORT // For static dll usage __declspec(dllimport) |
28 # define RUBYEXTERN __declspec(dllimport) | 28 # define RUBYEXTERN __declspec(dllimport) |
29 # endif | 29 # endif |
30 #endif | 30 #endif |
31 #ifndef RUBYEXTERN | 31 #ifndef RUBYEXTERN |
32 # define RUBYEXTERN extern | 32 # define RUBYEXTERN extern |
85 || (defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 21) | 85 || (defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 21) |
86 # define RUBY21_OR_LATER 1 | 86 # define RUBY21_OR_LATER 1 |
87 #endif | 87 #endif |
88 | 88 |
89 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 | 89 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 |
90 /* Ruby 1.9 defines a number of static functions which use rb_num2long and | 90 // Ruby 1.9 defines a number of static functions which use rb_num2long and |
91 * rb_int2big */ | 91 // rb_int2big |
92 # define rb_num2long rb_num2long_stub | 92 # define rb_num2long rb_num2long_stub |
93 # define rb_int2big rb_int2big_stub | 93 # define rb_int2big rb_int2big_stub |
94 #endif | 94 #endif |
95 | 95 |
96 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 \ | 96 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 \ |
97 && VIM_SIZEOF_INT < VIM_SIZEOF_LONG | 97 && VIM_SIZEOF_INT < VIM_SIZEOF_LONG |
98 /* Ruby 1.9 defines a number of static functions which use rb_fix2int and | 98 // Ruby 1.9 defines a number of static functions which use rb_fix2int and |
99 * rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit) */ | 99 // rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit) |
100 # define rb_fix2int rb_fix2int_stub | 100 # define rb_fix2int rb_fix2int_stub |
101 # define rb_num2int rb_num2int_stub | 101 # define rb_num2int rb_num2int_stub |
102 #endif | 102 #endif |
103 | 103 |
104 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21 | 104 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21 |
105 /* Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses | 105 // Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses |
106 * rb_gc_writebarrier_unprotect_promoted if USE_RGENGC */ | 106 // rb_gc_writebarrier_unprotect_promoted if USE_RGENGC |
107 # define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub | 107 # define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub |
108 #endif | 108 #endif |
109 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22 | 109 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22 |
110 # define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub | 110 # define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub |
111 #endif | 111 #endif |
124 | 124 |
125 #undef off_t // ruby defines off_t as _int64, Mingw uses long | 125 #undef off_t // ruby defines off_t as _int64, Mingw uses long |
126 #undef EXTERN | 126 #undef EXTERN |
127 #undef _ | 127 #undef _ |
128 | 128 |
129 /* T_DATA defined both by Ruby and Mac header files, hack around it... */ | 129 // T_DATA defined both by Ruby and Mac header files, hack around it... |
130 #if defined(MACOS_X) | 130 #if defined(MACOS_X) |
131 # define __OPENTRANSPORT__ | 131 # define __OPENTRANSPORT__ |
132 # define __OPENTRANSPORTPROTOCOL__ | 132 # define __OPENTRANSPORTPROTOCOL__ |
133 # define __OPENTRANSPORTPROVIDERS__ | 133 # define __OPENTRANSPORTPROVIDERS__ |
134 #endif | 134 #endif |
187 # define close_dll FreeLibrary | 187 # define close_dll FreeLibrary |
188 # endif | 188 # endif |
189 #endif | 189 #endif |
190 | 190 |
191 #if defined(PROTO) && !defined(FEAT_RUBY) | 191 #if defined(PROTO) && !defined(FEAT_RUBY) |
192 /* Define these to be able to generate the function prototypes. */ | 192 // Define these to be able to generate the function prototypes. |
193 # define VALUE int | 193 # define VALUE int |
194 # define RUBY_DATA_FUNC int | 194 # define RUBY_DATA_FUNC int |
195 #endif | 195 #endif |
196 | 196 |
197 static int ruby_initialized = 0; | 197 static int ruby_initialized = 0; |
216 # endif | 216 # endif |
217 #endif | 217 #endif |
218 | 218 |
219 #if defined(DYNAMIC_RUBY) || defined(PROTO) | 219 #if defined(DYNAMIC_RUBY) || defined(PROTO) |
220 # if defined(PROTO) && !defined(HINSTANCE) | 220 # if defined(PROTO) && !defined(HINSTANCE) |
221 # define HINSTANCE int /* for generating prototypes */ | 221 # define HINSTANCE int // for generating prototypes |
222 # endif | 222 # endif |
223 | 223 |
224 /* | 224 /* |
225 * Wrapper defines | 225 * Wrapper defines |
226 */ | 226 */ |
271 // ruby.h may redefine rb_intern to use RUBY_CONST_ID_CACHE(), but that won't | 271 // ruby.h may redefine rb_intern to use RUBY_CONST_ID_CACHE(), but that won't |
272 // work. Not using the cache appears to be the best solution. | 272 // work. Not using the cache appears to be the best solution. |
273 # undef rb_intern | 273 # undef rb_intern |
274 # define rb_intern dll_rb_intern | 274 # define rb_intern dll_rb_intern |
275 | 275 |
276 # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */ | 276 # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG // 64 bits only |
277 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 18 | 277 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 18 |
278 # define rb_fix2int dll_rb_fix2int | 278 # define rb_fix2int dll_rb_fix2int |
279 # define rb_num2int dll_rb_num2int | 279 # define rb_num2int dll_rb_num2int |
280 # endif | 280 # endif |
281 # define rb_num2uint dll_rb_num2uint | 281 # define rb_num2uint dll_rb_num2uint |
298 # define rb_str_cat dll_rb_str_cat | 298 # define rb_str_cat dll_rb_str_cat |
299 # define rb_str_concat dll_rb_str_concat | 299 # define rb_str_concat dll_rb_str_concat |
300 # undef rb_str_new | 300 # undef rb_str_new |
301 # define rb_str_new dll_rb_str_new | 301 # define rb_str_new dll_rb_str_new |
302 # ifdef rb_str_new2 | 302 # ifdef rb_str_new2 |
303 /* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */ | 303 // Ruby may #define rb_str_new2 to use rb_str_new_cstr. |
304 # define need_rb_str_new_cstr 1 | 304 # define need_rb_str_new_cstr 1 |
305 /* Ruby's headers #define rb_str_new_cstr to make use of GCC's | 305 // Ruby's headers #define rb_str_new_cstr to make use of GCC's |
306 * __builtin_constant_p extension. */ | 306 // __builtin_constant_p extension. |
307 # undef rb_str_new_cstr | 307 # undef rb_str_new_cstr |
308 # define rb_str_new_cstr dll_rb_str_new_cstr | 308 # define rb_str_new_cstr dll_rb_str_new_cstr |
309 # else | 309 # else |
310 # define rb_str_new2 dll_rb_str_new2 | 310 # define rb_str_new2 dll_rb_str_new2 |
311 # endif | 311 # endif |
418 static VALUE (*dll_rb_hash_foreach) (VALUE, int (*)(VALUE, VALUE, VALUE), VALUE); | 418 static VALUE (*dll_rb_hash_foreach) (VALUE, int (*)(VALUE, VALUE, VALUE), VALUE); |
419 static VALUE (*dll_rb_hash_new) (void); | 419 static VALUE (*dll_rb_hash_new) (void); |
420 static VALUE (*dll_rb_inspect) (VALUE); | 420 static VALUE (*dll_rb_inspect) (VALUE); |
421 static VALUE (*dll_rb_int2inum) (long); | 421 static VALUE (*dll_rb_int2inum) (long); |
422 static ID (*dll_rb_intern) (const char*); | 422 static ID (*dll_rb_intern) (const char*); |
423 # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */ | 423 # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG // 64 bits only |
424 static long (*dll_rb_fix2int) (VALUE); | 424 static long (*dll_rb_fix2int) (VALUE); |
425 static long (*dll_rb_num2int) (VALUE); | 425 static long (*dll_rb_num2int) (VALUE); |
426 static unsigned long (*dll_rb_num2uint) (VALUE); | 426 static unsigned long (*dll_rb_num2uint) (VALUE); |
427 # endif | 427 # endif |
428 static double (*dll_rb_num2dbl) (VALUE); | 428 static double (*dll_rb_num2dbl) (VALUE); |
443 # endif | 443 # endif |
444 static VALUE (*dll_rb_str_cat) (VALUE, const char*, long); | 444 static VALUE (*dll_rb_str_cat) (VALUE, const char*, long); |
445 static VALUE (*dll_rb_str_concat) (VALUE, VALUE); | 445 static VALUE (*dll_rb_str_concat) (VALUE, VALUE); |
446 static VALUE (*dll_rb_str_new) (const char*, long); | 446 static VALUE (*dll_rb_str_new) (const char*, long); |
447 # ifdef need_rb_str_new_cstr | 447 # ifdef need_rb_str_new_cstr |
448 /* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */ | 448 // Ruby may #define rb_str_new2 to use rb_str_new_cstr. |
449 static VALUE (*dll_rb_str_new_cstr) (const char*); | 449 static VALUE (*dll_rb_str_new_cstr) (const char*); |
450 # else | 450 # else |
451 static VALUE (*dll_rb_str_new2) (const char*); | 451 static VALUE (*dll_rb_str_new2) (const char*); |
452 # endif | 452 # endif |
453 # ifdef RUBY19_OR_LATER | 453 # ifdef RUBY19_OR_LATER |
558 return (long)RSHIFT((SIGNED_VALUE)(x),1); | 558 return (long)RSHIFT((SIGNED_VALUE)(x),1); |
559 } | 559 } |
560 # endif | 560 # endif |
561 # endif | 561 # endif |
562 | 562 |
563 /* Do not generate a prototype here, VALUE isn't always defined. */ | 563 // Do not generate a prototype here, VALUE isn't always defined. |
564 # if defined(USE_RGENGC) && USE_RGENGC && !defined(PROTO) | 564 # if defined(USE_RGENGC) && USE_RGENGC && !defined(PROTO) |
565 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21 | 565 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21 |
566 void | 566 void |
567 rb_gc_writebarrier_unprotect_promoted_stub(VALUE obj) | 567 rb_gc_writebarrier_unprotect_promoted_stub(VALUE obj) |
568 { | 568 { |
583 { | 583 { |
584 dll_rb_ary_detransient(x); | 584 dll_rb_ary_detransient(x); |
585 } | 585 } |
586 # endif | 586 # endif |
587 | 587 |
588 static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */ | 588 static HINSTANCE hinstRuby = NULL; // Instance of ruby.dll |
589 | 589 |
590 /* | 590 /* |
591 * Table of name to function pointer of ruby. | 591 * Table of name to function pointer of ruby. |
592 */ | 592 */ |
593 static struct | 593 static struct |
651 {"rb_hash_foreach", (RUBY_PROC*)&dll_rb_hash_foreach}, | 651 {"rb_hash_foreach", (RUBY_PROC*)&dll_rb_hash_foreach}, |
652 {"rb_hash_new", (RUBY_PROC*)&dll_rb_hash_new}, | 652 {"rb_hash_new", (RUBY_PROC*)&dll_rb_hash_new}, |
653 {"rb_inspect", (RUBY_PROC*)&dll_rb_inspect}, | 653 {"rb_inspect", (RUBY_PROC*)&dll_rb_inspect}, |
654 {"rb_int2inum", (RUBY_PROC*)&dll_rb_int2inum}, | 654 {"rb_int2inum", (RUBY_PROC*)&dll_rb_int2inum}, |
655 {"rb_intern", (RUBY_PROC*)&dll_rb_intern}, | 655 {"rb_intern", (RUBY_PROC*)&dll_rb_intern}, |
656 # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */ | 656 # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG // 64 bits only |
657 {"rb_fix2int", (RUBY_PROC*)&dll_rb_fix2int}, | 657 {"rb_fix2int", (RUBY_PROC*)&dll_rb_fix2int}, |
658 {"rb_num2int", (RUBY_PROC*)&dll_rb_num2int}, | 658 {"rb_num2int", (RUBY_PROC*)&dll_rb_num2int}, |
659 {"rb_num2uint", (RUBY_PROC*)&dll_rb_num2uint}, | 659 {"rb_num2uint", (RUBY_PROC*)&dll_rb_num2uint}, |
660 # endif | 660 # endif |
661 {"rb_num2dbl", (RUBY_PROC*)&dll_rb_num2dbl}, | 661 {"rb_num2dbl", (RUBY_PROC*)&dll_rb_num2dbl}, |
798 int | 798 int |
799 ruby_enabled(int verbose) | 799 ruby_enabled(int verbose) |
800 { | 800 { |
801 return ruby_runtime_link_init((char *)p_rubydll, verbose) == OK; | 801 return ruby_runtime_link_init((char *)p_rubydll, verbose) == OK; |
802 } | 802 } |
803 #endif /* defined(DYNAMIC_RUBY) || defined(PROTO) */ | 803 #endif // defined(DYNAMIC_RUBY) || defined(PROTO) |
804 | 804 |
805 void | 805 void |
806 ruby_end(void) | 806 ruby_end(void) |
807 { | 807 { |
808 #ifdef DYNAMIC_RUBY | 808 #ifdef DYNAMIC_RUBY |
916 return; | 916 return; |
917 } | 917 } |
918 ml_replace(i, (char_u *) StringValuePtr(line), 1); | 918 ml_replace(i, (char_u *) StringValuePtr(line), 1); |
919 changed(); | 919 changed(); |
920 #ifdef SYNTAX_HL | 920 #ifdef SYNTAX_HL |
921 syn_changed(i); /* recompute syntax hl. for this line */ | 921 syn_changed(i); // recompute syntax hl. for this line |
922 #endif | 922 #endif |
923 } | 923 } |
924 } | 924 } |
925 check_cursor(); | 925 check_cursor(); |
926 update_curbuf(NOT_VALID); | 926 update_curbuf(NOT_VALID); |
976 #ifdef DYNAMIC_RUBY | 976 #ifdef DYNAMIC_RUBY |
977 if (ruby_enabled(TRUE)) | 977 if (ruby_enabled(TRUE)) |
978 { | 978 { |
979 #endif | 979 #endif |
980 #ifdef MSWIN | 980 #ifdef MSWIN |
981 /* suggested by Ariya Mizutani */ | 981 // suggested by Ariya Mizutani |
982 int argc = 1; | 982 int argc = 1; |
983 char *argv[] = {"gvim.exe"}; | 983 char *argv[] = {"gvim.exe"}; |
984 char **argvp = argv; | 984 char **argvp = argv; |
985 # ifdef RUBY19_OR_LATER | 985 # ifdef RUBY19_OR_LATER |
986 ruby_sysinit(&argc, &argvp); | 986 ruby_sysinit(&argc, &argvp); |
1110 char *buff, *p; | 1110 char *buff, *p; |
1111 | 1111 |
1112 str = rb_obj_as_string(str); | 1112 str = rb_obj_as_string(str); |
1113 if (RSTRING_LEN(str) > 0) | 1113 if (RSTRING_LEN(str) > 0) |
1114 { | 1114 { |
1115 /* Only do this when the string isn't empty, alloc(0) causes trouble. */ | 1115 // Only do this when the string isn't empty, alloc(0) causes trouble. |
1116 buff = ALLOCA_N(char, RSTRING_LEN(str) + 1); | 1116 buff = ALLOCA_N(char, RSTRING_LEN(str) + 1); |
1117 strcpy(buff, RSTRING_PTR(str)); | 1117 strcpy(buff, RSTRING_PTR(str)); |
1118 p = strchr(buff, '\n'); | 1118 p = strchr(buff, '\n'); |
1119 if (p) *p = '\0'; | 1119 if (p) *p = '\0'; |
1120 msg(buff); | 1120 msg(buff); |
1209 else if (tv->v_type == VAR_BLOB) | 1209 else if (tv->v_type == VAR_BLOB) |
1210 { | 1210 { |
1211 result = rb_str_new(tv->vval.v_blob->bv_ga.ga_data, | 1211 result = rb_str_new(tv->vval.v_blob->bv_ga.ga_data, |
1212 tv->vval.v_blob->bv_ga.ga_len); | 1212 tv->vval.v_blob->bv_ga.ga_len); |
1213 } | 1213 } |
1214 /* else return Qnil; */ | 1214 // else return Qnil; |
1215 | 1215 |
1216 return result; | 1216 return result; |
1217 } | 1217 } |
1218 #endif | 1218 #endif |
1219 | 1219 |
1317 buf_T *b; | 1317 buf_T *b; |
1318 int n = 0; | 1318 int n = 0; |
1319 | 1319 |
1320 FOR_ALL_BUFFERS(b) | 1320 FOR_ALL_BUFFERS(b) |
1321 { | 1321 { |
1322 /* Deleted buffers should not be counted | 1322 // Deleted buffers should not be counted |
1323 * SegPhault - 01/07/05 */ | 1323 // SegPhault - 01/07/05 |
1324 if (b->b_p_bl) | 1324 if (b->b_p_bl) |
1325 n++; | 1325 n++; |
1326 } | 1326 } |
1327 | 1327 |
1328 return INT2NUM(n); | 1328 return INT2NUM(n); |
1334 buf_T *b; | 1334 buf_T *b; |
1335 int n = NUM2INT(num); | 1335 int n = NUM2INT(num); |
1336 | 1336 |
1337 FOR_ALL_BUFFERS(b) | 1337 FOR_ALL_BUFFERS(b) |
1338 { | 1338 { |
1339 /* Deleted buffers should not be counted | 1339 // Deleted buffers should not be counted |
1340 * SegPhault - 01/07/05 */ | 1340 // SegPhault - 01/07/05 |
1341 if (!b->b_p_bl) | 1341 if (!b->b_p_bl) |
1342 continue; | 1342 continue; |
1343 | 1343 |
1344 if (n == 0) | 1344 if (n == 0) |
1345 return buffer_new(b); | 1345 return buffer_new(b); |
1386 { | 1386 { |
1387 buf_T *buf = get_buf(self); | 1387 buf_T *buf = get_buf(self); |
1388 | 1388 |
1389 if (buf != NULL) | 1389 if (buf != NULL) |
1390 return get_buffer_line(buf, (linenr_T)NUM2LONG(num)); | 1390 return get_buffer_line(buf, (linenr_T)NUM2LONG(num)); |
1391 return Qnil; /* For stop warning */ | 1391 return Qnil; // For stop warning |
1392 } | 1392 } |
1393 | 1393 |
1394 static VALUE | 1394 static VALUE |
1395 set_buffer_line(buf_T *buf, linenr_T n, VALUE str) | 1395 set_buffer_line(buf_T *buf, linenr_T n, VALUE str) |
1396 { | 1396 { |
1397 char *line = StringValuePtr(str); | 1397 char *line = StringValuePtr(str); |
1398 aco_save_T aco; | 1398 aco_save_T aco; |
1399 | 1399 |
1400 if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL) | 1400 if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL) |
1401 { | 1401 { |
1402 /* set curwin/curbuf for "buf" and save some things */ | 1402 // set curwin/curbuf for "buf" and save some things |
1403 aucmd_prepbuf(&aco, buf); | 1403 aucmd_prepbuf(&aco, buf); |
1404 | 1404 |
1405 if (u_savesub(n) == OK) | 1405 if (u_savesub(n) == OK) |
1406 { | 1406 { |
1407 ml_replace(n, (char_u *)line, TRUE); | 1407 ml_replace(n, (char_u *)line, TRUE); |
1408 changed(); | 1408 changed(); |
1409 #ifdef SYNTAX_HL | 1409 #ifdef SYNTAX_HL |
1410 syn_changed(n); /* recompute syntax hl. for this line */ | 1410 syn_changed(n); // recompute syntax hl. for this line |
1411 #endif | 1411 #endif |
1412 } | 1412 } |
1413 | 1413 |
1414 /* restore curwin/curbuf and a few other things */ | 1414 // restore curwin/curbuf and a few other things |
1415 aucmd_restbuf(&aco); | 1415 aucmd_restbuf(&aco); |
1416 /* Careful: autocommands may have made "buf" invalid! */ | 1416 // Careful: autocommands may have made "buf" invalid! |
1417 | 1417 |
1418 update_curbuf(NOT_VALID); | 1418 update_curbuf(NOT_VALID); |
1419 } | 1419 } |
1420 else | 1420 else |
1421 { | 1421 { |
1441 long n = NUM2LONG(num); | 1441 long n = NUM2LONG(num); |
1442 aco_save_T aco; | 1442 aco_save_T aco; |
1443 | 1443 |
1444 if (n > 0 && n <= buf->b_ml.ml_line_count) | 1444 if (n > 0 && n <= buf->b_ml.ml_line_count) |
1445 { | 1445 { |
1446 /* set curwin/curbuf for "buf" and save some things */ | 1446 // set curwin/curbuf for "buf" and save some things |
1447 aucmd_prepbuf(&aco, buf); | 1447 aucmd_prepbuf(&aco, buf); |
1448 | 1448 |
1449 if (u_savedel(n, 1) == OK) | 1449 if (u_savedel(n, 1) == OK) |
1450 { | 1450 { |
1451 ml_delete(n, 0); | 1451 ml_delete(n, 0); |
1452 | 1452 |
1453 /* Changes to non-active buffers should properly refresh | 1453 // Changes to non-active buffers should properly refresh |
1454 * SegPhault - 01/09/05 */ | 1454 // SegPhault - 01/09/05 |
1455 deleted_lines_mark(n, 1L); | 1455 deleted_lines_mark(n, 1L); |
1456 | 1456 |
1457 changed(); | 1457 changed(); |
1458 } | 1458 } |
1459 | 1459 |
1460 /* restore curwin/curbuf and a few other things */ | 1460 // restore curwin/curbuf and a few other things |
1461 aucmd_restbuf(&aco); | 1461 aucmd_restbuf(&aco); |
1462 /* Careful: autocommands may have made "buf" invalid! */ | 1462 // Careful: autocommands may have made "buf" invalid! |
1463 | 1463 |
1464 update_curbuf(NOT_VALID); | 1464 update_curbuf(NOT_VALID); |
1465 } | 1465 } |
1466 else | 1466 else |
1467 { | 1467 { |
1482 { | 1482 { |
1483 rb_raise(rb_eIndexError, "NULL line"); | 1483 rb_raise(rb_eIndexError, "NULL line"); |
1484 } | 1484 } |
1485 else if (n >= 0 && n <= buf->b_ml.ml_line_count) | 1485 else if (n >= 0 && n <= buf->b_ml.ml_line_count) |
1486 { | 1486 { |
1487 /* set curwin/curbuf for "buf" and save some things */ | 1487 // set curwin/curbuf for "buf" and save some things |
1488 aucmd_prepbuf(&aco, buf); | 1488 aucmd_prepbuf(&aco, buf); |
1489 | 1489 |
1490 if (u_inssub(n + 1) == OK) | 1490 if (u_inssub(n + 1) == OK) |
1491 { | 1491 { |
1492 ml_append(n, (char_u *) line, (colnr_T) 0, FALSE); | 1492 ml_append(n, (char_u *) line, (colnr_T) 0, FALSE); |
1493 | 1493 |
1494 /* Changes to non-active buffers should properly refresh screen | 1494 // Changes to non-active buffers should properly refresh screen |
1495 * SegPhault - 12/20/04 */ | 1495 // SegPhault - 12/20/04 |
1496 appended_lines_mark(n, 1L); | 1496 appended_lines_mark(n, 1L); |
1497 | 1497 |
1498 changed(); | 1498 changed(); |
1499 } | 1499 } |
1500 | 1500 |
1501 /* restore curwin/curbuf and a few other things */ | 1501 // restore curwin/curbuf and a few other things |
1502 aucmd_restbuf(&aco); | 1502 aucmd_restbuf(&aco); |
1503 /* Careful: autocommands may have made "buf" invalid! */ | 1503 // Careful: autocommands may have made "buf" invalid! |
1504 | 1504 |
1505 update_curbuf(NOT_VALID); | 1505 update_curbuf(NOT_VALID); |
1506 } | 1506 } |
1507 else | 1507 else |
1508 { | 1508 { |
1682 lnum = RARRAY_PTR(pos)[0]; | 1682 lnum = RARRAY_PTR(pos)[0]; |
1683 col = RARRAY_PTR(pos)[1]; | 1683 col = RARRAY_PTR(pos)[1]; |
1684 win->w_cursor.lnum = NUM2LONG(lnum); | 1684 win->w_cursor.lnum = NUM2LONG(lnum); |
1685 win->w_cursor.col = NUM2UINT(col); | 1685 win->w_cursor.col = NUM2UINT(col); |
1686 win->w_set_curswant = TRUE; | 1686 win->w_set_curswant = TRUE; |
1687 check_cursor(); /* put cursor on an existing line */ | 1687 check_cursor(); // put cursor on an existing line |
1688 update_screen(NOT_VALID); | 1688 update_screen(NOT_VALID); |
1689 return Qnil; | 1689 return Qnil; |
1690 } | 1690 } |
1691 | 1691 |
1692 static VALUE | 1692 static VALUE |
1737 ruby_vim_init(void) | 1737 ruby_vim_init(void) |
1738 { | 1738 { |
1739 objtbl = rb_hash_new(); | 1739 objtbl = rb_hash_new(); |
1740 rb_global_variable(&objtbl); | 1740 rb_global_variable(&objtbl); |
1741 | 1741 |
1742 /* The Vim module used to be called "VIM", but "Vim" is better. Make an | 1742 // The Vim module used to be called "VIM", but "Vim" is better. Make an |
1743 * alias "VIM" for backwards compatibility. */ | 1743 // alias "VIM" for backwards compatibility. |
1744 mVIM = rb_define_module("Vim"); | 1744 mVIM = rb_define_module("Vim"); |
1745 rb_define_const(rb_cObject, "VIM", mVIM); | 1745 rb_define_const(rb_cObject, "VIM", mVIM); |
1746 rb_define_const(mVIM, "VERSION_MAJOR", INT2NUM(VIM_VERSION_MAJOR)); | 1746 rb_define_const(mVIM, "VERSION_MAJOR", INT2NUM(VIM_VERSION_MAJOR)); |
1747 rb_define_const(mVIM, "VERSION_MINOR", INT2NUM(VIM_VERSION_MINOR)); | 1747 rb_define_const(mVIM, "VERSION_MINOR", INT2NUM(VIM_VERSION_MINOR)); |
1748 rb_define_const(mVIM, "VERSION_BUILD", INT2NUM(VIM_VERSION_BUILD)); | 1748 rb_define_const(mVIM, "VERSION_BUILD", INT2NUM(VIM_VERSION_BUILD)); |
1773 rb_define_method(cBuffer, "[]", buffer_aref, 1); | 1773 rb_define_method(cBuffer, "[]", buffer_aref, 1); |
1774 rb_define_method(cBuffer, "[]=", buffer_aset, 2); | 1774 rb_define_method(cBuffer, "[]=", buffer_aset, 2); |
1775 rb_define_method(cBuffer, "delete", buffer_delete, 1); | 1775 rb_define_method(cBuffer, "delete", buffer_delete, 1); |
1776 rb_define_method(cBuffer, "append", buffer_append, 2); | 1776 rb_define_method(cBuffer, "append", buffer_append, 2); |
1777 | 1777 |
1778 /* Added line manipulation functions | 1778 // Added line manipulation functions |
1779 * SegPhault - 03/07/05 */ | 1779 // SegPhault - 03/07/05 |
1780 rb_define_method(cBuffer, "line_number", current_line_number, 0); | 1780 rb_define_method(cBuffer, "line_number", current_line_number, 0); |
1781 rb_define_method(cBuffer, "line", line_s_current, 0); | 1781 rb_define_method(cBuffer, "line", line_s_current, 0); |
1782 rb_define_method(cBuffer, "line=", set_current_line, 1); | 1782 rb_define_method(cBuffer, "line=", set_current_line, 1); |
1783 | 1783 |
1784 | 1784 |
1799 } | 1799 } |
1800 | 1800 |
1801 void | 1801 void |
1802 vim_ruby_init(void *stack_start) | 1802 vim_ruby_init(void *stack_start) |
1803 { | 1803 { |
1804 /* should get machine stack start address early in main function */ | 1804 // should get machine stack start address early in main function |
1805 ruby_stack_start = stack_start; | 1805 ruby_stack_start = stack_start; |
1806 } | 1806 } |
1807 | 1807 |
1808 static int | 1808 static int |
1809 convert_hash2dict(VALUE key, VALUE val, VALUE arg) | 1809 convert_hash2dict(VALUE key, VALUE val, VALUE arg) |