Mercurial > vim
comparison src/main.c @ 18800:f41b55f9357c v8.1.2388
patch 8.1.2388: using old C style comments
Commit: https://github.com/vim/vim/commit/4ba37b5833de99db9e9afe8928b31c864182405c
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 4 21:57:43 2019 +0100
patch 8.1.2388: 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 22:00:04 +0100 |
parents | 49b78d6465e5 |
children | 410155e75efa |
comparison
equal
deleted
inserted
replaced
18799:d7d0942e231b | 18800:f41b55f9357c |
---|---|
11 #include "vim.h" | 11 #include "vim.h" |
12 | 12 |
13 #ifdef __CYGWIN__ | 13 #ifdef __CYGWIN__ |
14 # ifndef MSWIN | 14 # ifndef MSWIN |
15 # include <cygwin/version.h> | 15 # include <cygwin/version.h> |
16 # include <sys/cygwin.h> /* for cygwin_conv_to_posix_path() and/or | 16 # include <sys/cygwin.h> // for cygwin_conv_to_posix_path() and/or |
17 * cygwin_conv_path() */ | 17 // cygwin_conv_path() |
18 # endif | 18 # endif |
19 # include <limits.h> | 19 # include <limits.h> |
20 #endif | 20 #endif |
21 | 21 |
22 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) | 22 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) |
23 # include "iscygpty.h" | 23 # include "iscygpty.h" |
24 #endif | 24 #endif |
25 | 25 |
26 /* Values for edit_type. */ | 26 // Values for edit_type. |
27 #define EDIT_NONE 0 /* no edit type yet */ | 27 #define EDIT_NONE 0 // no edit type yet |
28 #define EDIT_FILE 1 /* file name argument[s] given, use argument list */ | 28 #define EDIT_FILE 1 // file name argument[s] given, use argument list |
29 #define EDIT_STDIN 2 /* read file from stdin */ | 29 #define EDIT_STDIN 2 // read file from stdin |
30 #define EDIT_TAG 3 /* tag name argument given, use tagname */ | 30 #define EDIT_TAG 3 // tag name argument given, use tagname |
31 #define EDIT_QF 4 /* start in quickfix mode */ | 31 #define EDIT_QF 4 // start in quickfix mode |
32 | 32 |
33 #if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN) | 33 #if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN) |
34 static int file_owned(char *fname); | 34 static int file_owned(char *fname); |
35 #endif | 35 #endif |
36 static void mainerr(int, char_u *); | 36 static void mainerr(int, char_u *); |
80 #define ME_EXTRA_CMD 4 | 80 #define ME_EXTRA_CMD 4 |
81 N_("Invalid argument for"), | 81 N_("Invalid argument for"), |
82 #define ME_INVALID_ARG 5 | 82 #define ME_INVALID_ARG 5 |
83 }; | 83 }; |
84 | 84 |
85 #ifndef PROTO /* don't want a prototype for main() */ | 85 #ifndef PROTO // don't want a prototype for main() |
86 | 86 |
87 /* Various parameters passed between main() and other functions. */ | 87 // Various parameters passed between main() and other functions. |
88 static mparm_T params; | 88 static mparm_T params; |
89 | 89 |
90 #ifndef NO_VIM_MAIN /* skip this for unittests */ | 90 #ifndef NO_VIM_MAIN // skip this for unittests |
91 | 91 |
92 static char_u *start_dir = NULL; /* current working dir on startup */ | 92 static char_u *start_dir = NULL; // current working dir on startup |
93 | 93 |
94 static int has_dash_c_arg = FALSE; | 94 static int has_dash_c_arg = FALSE; |
95 | 95 |
96 # ifdef VIMDLL | 96 # ifdef VIMDLL |
97 __declspec(dllexport) | 97 __declspec(dllexport) |
120 * convert when 'encoding' changes. Get the unexpanded arguments. | 120 * convert when 'encoding' changes. Get the unexpanded arguments. |
121 */ | 121 */ |
122 argc = get_cmd_argsW(&argv); | 122 argc = get_cmd_argsW(&argv); |
123 #endif | 123 #endif |
124 | 124 |
125 /* Many variables are in "params" so that we can pass them to invoked | 125 // Many variables are in "params" so that we can pass them to invoked |
126 * functions without a lot of arguments. "argc" and "argv" are also | 126 // functions without a lot of arguments. "argc" and "argv" are also |
127 * copied, so that they can be changed. */ | 127 // copied, so that they can be changed. |
128 vim_memset(¶ms, 0, sizeof(params)); | 128 vim_memset(¶ms, 0, sizeof(params)); |
129 params.argc = argc; | 129 params.argc = argc; |
130 params.argv = argv; | 130 params.argv = argv; |
131 params.want_full_screen = TRUE; | 131 params.want_full_screen = TRUE; |
132 #ifdef FEAT_EVAL | 132 #ifdef FEAT_EVAL |
148 #ifdef MEM_PROFILE | 148 #ifdef MEM_PROFILE |
149 atexit(vim_mem_profile_dump); | 149 atexit(vim_mem_profile_dump); |
150 #endif | 150 #endif |
151 | 151 |
152 #ifdef STARTUPTIME | 152 #ifdef STARTUPTIME |
153 /* Need to find "--startuptime" before actually parsing arguments. */ | 153 // Need to find "--startuptime" before actually parsing arguments. |
154 for (i = 1; i < argc - 1; ++i) | 154 for (i = 1; i < argc - 1; ++i) |
155 if (STRICMP(argv[i], "--startuptime") == 0) | 155 if (STRICMP(argv[i], "--startuptime") == 0) |
156 { | 156 { |
157 time_fd = mch_fopen(argv[i + 1], "a"); | 157 time_fd = mch_fopen(argv[i + 1], "a"); |
158 TIME_MSG("--- VIM STARTING ---"); | 158 TIME_MSG("--- VIM STARTING ---"); |
160 } | 160 } |
161 #endif | 161 #endif |
162 starttime = time(NULL); | 162 starttime = time(NULL); |
163 | 163 |
164 #ifdef CLEAN_RUNTIMEPATH | 164 #ifdef CLEAN_RUNTIMEPATH |
165 /* Need to find "--clean" before actually parsing arguments. */ | 165 // Need to find "--clean" before actually parsing arguments. |
166 for (i = 1; i < argc; ++i) | 166 for (i = 1; i < argc; ++i) |
167 if (STRICMP(argv[i], "--clean") == 0) | 167 if (STRICMP(argv[i], "--clean") == 0) |
168 { | 168 { |
169 params.clean = TRUE; | 169 params.clean = TRUE; |
170 break; | 170 break; |
217 { | 217 { |
218 if (gui_init_check() == FAIL) | 218 if (gui_init_check() == FAIL) |
219 { | 219 { |
220 gui.starting = FALSE; | 220 gui.starting = FALSE; |
221 | 221 |
222 /* When running "evim" or "gvim -y" we need the menus, exit if we | 222 // When running "evim" or "gvim -y" we need the menus, exit if we |
223 * don't have them. */ | 223 // don't have them. |
224 if (params.evim_mode) | 224 if (params.evim_mode) |
225 mch_exit(1); | 225 mch_exit(1); |
226 } | 226 } |
227 } | 227 } |
228 # endif | 228 # endif |
237 if (!params.literal) | 237 if (!params.literal) |
238 { | 238 { |
239 start_dir = alloc(MAXPATHL); | 239 start_dir = alloc(MAXPATHL); |
240 if (start_dir != NULL) | 240 if (start_dir != NULL) |
241 mch_dirname(start_dir, MAXPATHL); | 241 mch_dirname(start_dir, MAXPATHL); |
242 /* Temporarily add '(' and ')' to 'isfname'. These are valid | 242 // Temporarily add '(' and ')' to 'isfname'. These are valid |
243 * filename characters but are excluded from 'isfname' to make | 243 // filename characters but are excluded from 'isfname' to make |
244 * "gf" work on a file name in parenthesis (e.g.: see vim.h). */ | 244 // "gf" work on a file name in parenthesis (e.g.: see vim.h). |
245 do_cmdline_cmd((char_u *)":set isf+=(,)"); | 245 do_cmdline_cmd((char_u *)":set isf+=(,)"); |
246 alist_expand(NULL, 0); | 246 alist_expand(NULL, 0); |
247 do_cmdline_cmd((char_u *)":set isf&"); | 247 do_cmdline_cmd((char_u *)":set isf&"); |
248 if (start_dir != NULL) | 248 if (start_dir != NULL) |
249 mch_chdir((char *)start_dir); | 249 mch_chdir((char *)start_dir); |
254 | 254 |
255 #ifdef MSWIN | 255 #ifdef MSWIN |
256 { | 256 { |
257 extern void set_alist_count(void); | 257 extern void set_alist_count(void); |
258 | 258 |
259 /* Remember the number of entries in the argument list. If it changes | 259 // Remember the number of entries in the argument list. If it changes |
260 * we don't react on setting 'encoding'. */ | 260 // we don't react on setting 'encoding'. |
261 set_alist_count(); | 261 set_alist_count(); |
262 } | 262 } |
263 #endif | 263 #endif |
264 | 264 |
265 #ifdef MSWIN | 265 #ifdef MSWIN |
278 #endif | 278 #endif |
279 TIME_MSG("expanding arguments"); | 279 TIME_MSG("expanding arguments"); |
280 | 280 |
281 #ifdef FEAT_DIFF | 281 #ifdef FEAT_DIFF |
282 if (params.diff_mode && params.window_count == -1) | 282 if (params.diff_mode && params.window_count == -1) |
283 params.window_count = 0; /* open up to 3 windows */ | 283 params.window_count = 0; // open up to 3 windows |
284 #endif | 284 #endif |
285 | 285 |
286 /* Don't redraw until much later. */ | 286 // Don't redraw until much later. |
287 ++RedrawingDisabled; | 287 ++RedrawingDisabled; |
288 | 288 |
289 /* | 289 /* |
290 * When listing swap file names, don't do cursor positioning et. al. | 290 * When listing swap file names, don't do cursor positioning et. al. |
291 */ | 291 */ |
306 ) | 306 ) |
307 params.want_full_screen = FALSE; | 307 params.want_full_screen = FALSE; |
308 #endif | 308 #endif |
309 | 309 |
310 #if defined(FEAT_GUI_MAC) && defined(MACOS_X_DARWIN) | 310 #if defined(FEAT_GUI_MAC) && defined(MACOS_X_DARWIN) |
311 /* When the GUI is started from Finder, need to display messages in a | 311 // When the GUI is started from Finder, need to display messages in a |
312 * message box. isatty(2) returns TRUE anyway, thus we need to check the | 312 // message box. isatty(2) returns TRUE anyway, thus we need to check the |
313 * name to know we're not started from a terminal. */ | 313 // name to know we're not started from a terminal. |
314 if (gui.starting && (!isatty(2) || strcmp("/dev/console", ttyname(2)) == 0)) | 314 if (gui.starting && (!isatty(2) || strcmp("/dev/console", ttyname(2)) == 0)) |
315 { | 315 { |
316 params.want_full_screen = FALSE; | 316 params.want_full_screen = FALSE; |
317 | 317 |
318 /* Avoid always using "/" as the current directory. Note that when | 318 // Avoid always using "/" as the current directory. Note that when |
319 * started from Finder the arglist will be filled later in | 319 // started from Finder the arglist will be filled later in |
320 * HandleODocAE() and "fname" will be NULL. */ | 320 // HandleODocAE() and "fname" will be NULL. |
321 if (getcwd((char *)NameBuff, MAXPATHL) != NULL | 321 if (getcwd((char *)NameBuff, MAXPATHL) != NULL |
322 && STRCMP(NameBuff, "/") == 0) | 322 && STRCMP(NameBuff, "/") == 0) |
323 { | 323 { |
324 if (params.fname != NULL) | 324 if (params.fname != NULL) |
325 (void)vim_chdirfile(params.fname, "drop"); | 325 (void)vim_chdirfile(params.fname, "drop"); |
366 * Print a warning if stdout is not a terminal. | 366 * Print a warning if stdout is not a terminal. |
367 */ | 367 */ |
368 check_tty(¶ms); | 368 check_tty(¶ms); |
369 | 369 |
370 #ifdef _IOLBF | 370 #ifdef _IOLBF |
371 /* Ensure output works usefully without a tty: buffer lines instead of | 371 // Ensure output works usefully without a tty: buffer lines instead of |
372 * fully buffered. */ | 372 // fully buffered. |
373 if (silent_mode) | 373 if (silent_mode) |
374 setvbuf(stdout, NULL, _IOLBF, 0); | 374 setvbuf(stdout, NULL, _IOLBF, 0); |
375 #endif | 375 #endif |
376 | 376 |
377 // This message comes before term inits, but after setting "silent_mode" | 377 // This message comes before term inits, but after setting "silent_mode" |
379 if (GARGCOUNT > 1 && !silent_mode && !is_not_a_term()) | 379 if (GARGCOUNT > 1 && !silent_mode && !is_not_a_term()) |
380 printf(_("%d files to edit\n"), GARGCOUNT); | 380 printf(_("%d files to edit\n"), GARGCOUNT); |
381 | 381 |
382 if (params.want_full_screen && !silent_mode) | 382 if (params.want_full_screen && !silent_mode) |
383 { | 383 { |
384 termcapinit(params.term); /* set terminal name and get terminal | 384 termcapinit(params.term); // set terminal name and get terminal |
385 capabilities (will set full_screen) */ | 385 // capabilities (will set full_screen) |
386 screen_start(); /* don't know where cursor is now */ | 386 screen_start(); // don't know where cursor is now |
387 TIME_MSG("Termcap init"); | 387 TIME_MSG("Termcap init"); |
388 } | 388 } |
389 | 389 |
390 /* | 390 /* |
391 * Set the default values for the options that use Rows and Columns. | 391 * Set the default values for the options that use Rows and Columns. |
392 */ | 392 */ |
393 ui_get_shellsize(); /* inits Rows and Columns */ | 393 ui_get_shellsize(); // inits Rows and Columns |
394 win_init_size(); | 394 win_init_size(); |
395 #ifdef FEAT_DIFF | 395 #ifdef FEAT_DIFF |
396 /* Set the 'diff' option now, so that it can be checked for in a .vimrc | 396 // Set the 'diff' option now, so that it can be checked for in a .vimrc |
397 * file. There is no buffer yet though. */ | 397 // file. There is no buffer yet though. |
398 if (params.diff_mode) | 398 if (params.diff_mode) |
399 diff_win_options(firstwin, FALSE); | 399 diff_win_options(firstwin, FALSE); |
400 #endif | 400 #endif |
401 | 401 |
402 cmdline_row = Rows - p_ch; | 402 cmdline_row = Rows - p_ch; |
403 msg_row = cmdline_row; | 403 msg_row = cmdline_row; |
404 screenalloc(FALSE); /* allocate screen buffers */ | 404 screenalloc(FALSE); // allocate screen buffers |
405 set_init_2(); | 405 set_init_2(); |
406 TIME_MSG("inits 2"); | 406 TIME_MSG("inits 2"); |
407 | 407 |
408 msg_scroll = TRUE; | 408 msg_scroll = TRUE; |
409 no_wait_return = TRUE; | 409 no_wait_return = TRUE; |
410 | 410 |
411 init_mappings(); /* set up initial mappings */ | 411 init_mappings(); // set up initial mappings |
412 | 412 |
413 init_highlight(TRUE, FALSE); /* set the default highlight groups */ | 413 init_highlight(TRUE, FALSE); // set the default highlight groups |
414 TIME_MSG("init highlight"); | 414 TIME_MSG("init highlight"); |
415 | 415 |
416 #ifdef FEAT_EVAL | 416 #ifdef FEAT_EVAL |
417 /* Set the break level after the terminal is initialized. */ | 417 // Set the break level after the terminal is initialized. |
418 debug_break_level = params.use_debug_break_level; | 418 debug_break_level = params.use_debug_break_level; |
419 #endif | 419 #endif |
420 | 420 |
421 /* Reset 'loadplugins' for "-u NONE" before "--cmd" arguments. | 421 // Reset 'loadplugins' for "-u NONE" before "--cmd" arguments. |
422 * Allows for setting 'loadplugins' there. */ | 422 // Allows for setting 'loadplugins' there. |
423 if (params.use_vimrc != NULL | 423 if (params.use_vimrc != NULL |
424 && (STRCMP(params.use_vimrc, "NONE") == 0 | 424 && (STRCMP(params.use_vimrc, "NONE") == 0 |
425 || STRCMP(params.use_vimrc, "DEFAULTS") == 0)) | 425 || STRCMP(params.use_vimrc, "DEFAULTS") == 0)) |
426 p_lpl = FALSE; | 426 p_lpl = FALSE; |
427 | 427 |
428 /* Execute --cmd arguments. */ | 428 // Execute --cmd arguments. |
429 exe_pre_commands(¶ms); | 429 exe_pre_commands(¶ms); |
430 | 430 |
431 /* Source startup scripts. */ | 431 // Source startup scripts. |
432 source_startup_scripts(¶ms); | 432 source_startup_scripts(¶ms); |
433 | 433 |
434 #ifdef FEAT_MZSCHEME | 434 #ifdef FEAT_MZSCHEME |
435 /* | 435 /* |
436 * Newer version of MzScheme (Racket) require earlier (trampolined) | 436 * Newer version of MzScheme (Racket) require earlier (trampolined) |
442 return mzscheme_main(); | 442 return mzscheme_main(); |
443 #else | 443 #else |
444 return vim_main2(); | 444 return vim_main2(); |
445 #endif | 445 #endif |
446 } | 446 } |
447 #endif /* NO_VIM_MAIN */ | 447 #endif // NO_VIM_MAIN |
448 #endif /* PROTO */ | 448 #endif // PROTO |
449 | 449 |
450 /* | 450 /* |
451 * vim_main2() is needed for FEAT_MZSCHEME, but we define it always to keep | 451 * vim_main2() is needed for FEAT_MZSCHEME, but we define it always to keep |
452 * things simple. | 452 * things simple. |
453 * It is also defined when NO_VIM_MAIN is defined, but then it's empty. | 453 * It is also defined when NO_VIM_MAIN is defined, but then it's empty. |
463 */ | 463 */ |
464 if (p_lpl) | 464 if (p_lpl) |
465 { | 465 { |
466 char_u *rtp_copy = NULL; | 466 char_u *rtp_copy = NULL; |
467 | 467 |
468 /* First add all package directories to 'runtimepath', so that their | 468 // First add all package directories to 'runtimepath', so that their |
469 * autoload directories can be found. Only if not done already with a | 469 // autoload directories can be found. Only if not done already with a |
470 * :packloadall command. | 470 // :packloadall command. |
471 * Make a copy of 'runtimepath', so that source_runtime does not use | 471 // Make a copy of 'runtimepath', so that source_runtime does not use |
472 * the pack directories. */ | 472 // the pack directories. |
473 if (!did_source_packages) | 473 if (!did_source_packages) |
474 { | 474 { |
475 rtp_copy = vim_strsave(p_rtp); | 475 rtp_copy = vim_strsave(p_rtp); |
476 add_pack_start_dirs(); | 476 add_pack_start_dirs(); |
477 } | 477 } |
478 | 478 |
479 source_in_path(rtp_copy == NULL ? p_rtp : rtp_copy, | 479 source_in_path(rtp_copy == NULL ? p_rtp : rtp_copy, |
480 # ifdef VMS /* Somehow VMS doesn't handle the "**". */ | 480 # ifdef VMS // Somehow VMS doesn't handle the "**". |
481 (char_u *)"plugin/*.vim", | 481 (char_u *)"plugin/*.vim", |
482 # else | 482 # else |
483 (char_u *)"plugin/**/*.vim", | 483 (char_u *)"plugin/**/*.vim", |
484 # endif | 484 # endif |
485 DIP_ALL | DIP_NOAFTER); | 485 DIP_ALL | DIP_NOAFTER); |
486 TIME_MSG("loading plugins"); | 486 TIME_MSG("loading plugins"); |
487 vim_free(rtp_copy); | 487 vim_free(rtp_copy); |
488 | 488 |
489 /* Only source "start" packages if not done already with a :packloadall | 489 // Only source "start" packages if not done already with a :packloadall |
490 * command. */ | 490 // command. |
491 if (!did_source_packages) | 491 if (!did_source_packages) |
492 load_start_packages(); | 492 load_start_packages(); |
493 TIME_MSG("loading packages"); | 493 TIME_MSG("loading packages"); |
494 | 494 |
495 # ifdef VMS /* Somehow VMS doesn't handle the "**". */ | 495 # ifdef VMS // Somehow VMS doesn't handle the "**". |
496 source_runtime((char_u *)"plugin/*.vim", DIP_ALL | DIP_AFTER); | 496 source_runtime((char_u *)"plugin/*.vim", DIP_ALL | DIP_AFTER); |
497 # else | 497 # else |
498 source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_AFTER); | 498 source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_AFTER); |
499 # endif | 499 # endif |
500 TIME_MSG("loading after plugins"); | 500 TIME_MSG("loading after plugins"); |
501 | 501 |
502 } | 502 } |
503 #endif | 503 #endif |
504 | 504 |
505 #ifdef FEAT_DIFF | 505 #ifdef FEAT_DIFF |
506 /* Decide about window layout for diff mode after reading vimrc. */ | 506 // Decide about window layout for diff mode after reading vimrc. |
507 if (params.diff_mode && params.window_layout == 0) | 507 if (params.diff_mode && params.window_layout == 0) |
508 { | 508 { |
509 if (diffopt_horizontal()) | 509 if (diffopt_horizontal()) |
510 params.window_layout = WIN_HOR; /* use horizontal split */ | 510 params.window_layout = WIN_HOR; // use horizontal split |
511 else | 511 else |
512 params.window_layout = WIN_VER; /* use vertical split */ | 512 params.window_layout = WIN_VER; // use vertical split |
513 } | 513 } |
514 #endif | 514 #endif |
515 | 515 |
516 /* | 516 /* |
517 * Recovery mode without a file name: List swap files. | 517 * Recovery mode without a file name: List swap files. |
540 | 540 |
541 #ifdef FEAT_GUI | 541 #ifdef FEAT_GUI |
542 if (gui.starting) | 542 if (gui.starting) |
543 { | 543 { |
544 # if defined(UNIX) || defined(VMS) | 544 # if defined(UNIX) || defined(VMS) |
545 /* When something caused a message from a vimrc script, need to output | 545 // When something caused a message from a vimrc script, need to output |
546 * an extra newline before the shell prompt. */ | 546 // an extra newline before the shell prompt. |
547 if (did_emsg || msg_didout) | 547 if (did_emsg || msg_didout) |
548 putchar('\n'); | 548 putchar('\n'); |
549 # endif | 549 # endif |
550 | 550 |
551 gui_start(NULL); /* will set full_screen to TRUE */ | 551 gui_start(NULL); // will set full_screen to TRUE |
552 TIME_MSG("starting GUI"); | 552 TIME_MSG("starting GUI"); |
553 | 553 |
554 /* When running "evim" or "gvim -y" we need the menus, exit if we | 554 // When running "evim" or "gvim -y" we need the menus, exit if we |
555 * don't have them. */ | 555 // don't have them. |
556 if (!gui.in_use && params.evim_mode) | 556 if (!gui.in_use && params.evim_mode) |
557 mch_exit(1); | 557 mch_exit(1); |
558 } | 558 } |
559 #endif | 559 #endif |
560 | 560 |
568 read_viminfo(NULL, VIF_WANT_INFO | VIF_GET_OLDFILES); | 568 read_viminfo(NULL, VIF_WANT_INFO | VIF_GET_OLDFILES); |
569 TIME_MSG("reading viminfo"); | 569 TIME_MSG("reading viminfo"); |
570 } | 570 } |
571 #endif | 571 #endif |
572 #ifdef FEAT_EVAL | 572 #ifdef FEAT_EVAL |
573 /* It's better to make v:oldfiles an empty list than NULL. */ | 573 // It's better to make v:oldfiles an empty list than NULL. |
574 if (get_vim_var_list(VV_OLDFILES) == NULL) | 574 if (get_vim_var_list(VV_OLDFILES) == NULL) |
575 set_vim_var_list(VV_OLDFILES, list_alloc()); | 575 set_vim_var_list(VV_OLDFILES, list_alloc()); |
576 #endif | 576 #endif |
577 | 577 |
578 #ifdef FEAT_QUICKFIX | 578 #ifdef FEAT_QUICKFIX |
630 #if defined(MACOS_X) && defined(FEAT_CLIPBOARD) | 630 #if defined(MACOS_X) && defined(FEAT_CLIPBOARD) |
631 clip_init(TRUE); | 631 clip_init(TRUE); |
632 #endif | 632 #endif |
633 | 633 |
634 #ifdef FEAT_XCLIPBOARD | 634 #ifdef FEAT_XCLIPBOARD |
635 /* Start using the X clipboard, unless the GUI was started. */ | 635 // Start using the X clipboard, unless the GUI was started. |
636 # ifdef FEAT_GUI | 636 # ifdef FEAT_GUI |
637 if (!gui.in_use) | 637 if (!gui.in_use) |
638 # endif | 638 # endif |
639 { | 639 { |
640 setup_term_clip(); | 640 setup_term_clip(); |
641 TIME_MSG("setup clipboard"); | 641 TIME_MSG("setup clipboard"); |
642 } | 642 } |
643 #endif | 643 #endif |
644 | 644 |
645 #ifdef FEAT_CLIENTSERVER | 645 #ifdef FEAT_CLIENTSERVER |
646 /* Prepare for being a Vim server. */ | 646 // Prepare for being a Vim server. |
647 prepare_server(¶ms); | 647 prepare_server(¶ms); |
648 #endif | 648 #endif |
649 | 649 |
650 /* | 650 /* |
651 * If "-" argument given: Read file from stdin. | 651 * If "-" argument given: Read file from stdin. |
656 */ | 656 */ |
657 if (params.edit_type == EDIT_STDIN && !recoverymode) | 657 if (params.edit_type == EDIT_STDIN && !recoverymode) |
658 read_stdin(); | 658 read_stdin(); |
659 | 659 |
660 #if defined(UNIX) || defined(VMS) | 660 #if defined(UNIX) || defined(VMS) |
661 /* When switching screens and something caused a message from a vimrc | 661 // When switching screens and something caused a message from a vimrc |
662 * script, need to output an extra newline on exit. */ | 662 // script, need to output an extra newline on exit. |
663 if ((did_emsg || msg_didout) && *T_TI != NUL) | 663 if ((did_emsg || msg_didout) && *T_TI != NUL) |
664 newline_on_exit = TRUE; | 664 newline_on_exit = TRUE; |
665 #endif | 665 #endif |
666 | 666 |
667 /* | 667 /* |
679 { | 679 { |
680 wait_return(TRUE); | 680 wait_return(TRUE); |
681 TIME_MSG("waiting for return"); | 681 TIME_MSG("waiting for return"); |
682 } | 682 } |
683 | 683 |
684 starttermcap(); /* start termcap if not done by wait_return() */ | 684 starttermcap(); // start termcap if not done by wait_return() |
685 TIME_MSG("start termcap"); | 685 TIME_MSG("start termcap"); |
686 | 686 |
687 setmouse(); // may start using the mouse | 687 setmouse(); // may start using the mouse |
688 if (scroll_region) | 688 if (scroll_region) |
689 scroll_region_reset(); /* In case Rows changed */ | 689 scroll_region_reset(); // In case Rows changed |
690 scroll_start(); /* may scroll the screen to the right position */ | 690 scroll_start(); // may scroll the screen to the right position |
691 | 691 |
692 #if defined(FEAT_TITLE) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) | 692 #if defined(FEAT_TITLE) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
693 term_push_title(SAVE_RESTORE_BOTH); | 693 term_push_title(SAVE_RESTORE_BOTH); |
694 #endif | 694 #endif |
695 | 695 |
702 #endif | 702 #endif |
703 ) | 703 ) |
704 must_redraw = CLEAR; | 704 must_redraw = CLEAR; |
705 else | 705 else |
706 { | 706 { |
707 screenclear(); /* clear screen */ | 707 screenclear(); // clear screen |
708 TIME_MSG("clearing screen"); | 708 TIME_MSG("clearing screen"); |
709 } | 709 } |
710 | 710 |
711 #ifdef FEAT_CRYPT | 711 #ifdef FEAT_CRYPT |
712 if (params.ask_for_key) | 712 if (params.ask_for_key) |
725 */ | 725 */ |
726 create_windows(¶ms); | 726 create_windows(¶ms); |
727 TIME_MSG("opening buffers"); | 727 TIME_MSG("opening buffers"); |
728 | 728 |
729 #ifdef FEAT_EVAL | 729 #ifdef FEAT_EVAL |
730 /* clear v:swapcommand */ | 730 // clear v:swapcommand |
731 set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); | 731 set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); |
732 #endif | 732 #endif |
733 | 733 |
734 /* Ex starts at last line of the file */ | 734 // Ex starts at last line of the file |
735 if (exmode_active) | 735 if (exmode_active) |
736 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | 736 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; |
737 | 737 |
738 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | 738 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); |
739 TIME_MSG("BufEnter autocommands"); | 739 TIME_MSG("BufEnter autocommands"); |
760 #ifdef FEAT_DIFF | 760 #ifdef FEAT_DIFF |
761 if (params.diff_mode) | 761 if (params.diff_mode) |
762 { | 762 { |
763 win_T *wp; | 763 win_T *wp; |
764 | 764 |
765 /* set options in each window for "vimdiff". */ | 765 // set options in each window for "vimdiff". |
766 FOR_ALL_WINDOWS(wp) | 766 FOR_ALL_WINDOWS(wp) |
767 diff_win_options(wp, TRUE); | 767 diff_win_options(wp, TRUE); |
768 } | 768 } |
769 #endif | 769 #endif |
770 | 770 |
783 | 783 |
784 vim_snprintf((char *)IObuff, IOSIZE, "ta %s", params.tagname); | 784 vim_snprintf((char *)IObuff, IOSIZE, "ta %s", params.tagname); |
785 do_cmdline_cmd(IObuff); | 785 do_cmdline_cmd(IObuff); |
786 TIME_MSG("jumping to tag"); | 786 TIME_MSG("jumping to tag"); |
787 | 787 |
788 /* If the user doesn't want to edit the file then we quit here. */ | 788 // If the user doesn't want to edit the file then we quit here. |
789 if (swap_exists_did_quit) | 789 if (swap_exists_did_quit) |
790 getout(1); | 790 getout(1); |
791 } | 791 } |
792 | 792 |
793 /* Execute any "+", "-c" and "-S" arguments. */ | 793 // Execute any "+", "-c" and "-S" arguments. |
794 if (params.n_commands > 0) | 794 if (params.n_commands > 0) |
795 exe_commands(¶ms); | 795 exe_commands(¶ms); |
796 | 796 |
797 /* Must come before the may_req_ calls. */ | 797 // Must come before the may_req_ calls. |
798 starting = 0; | 798 starting = 0; |
799 | 799 |
800 #if defined(FEAT_TERMRESPONSE) | 800 #if defined(FEAT_TERMRESPONSE) |
801 /* Must be done before redrawing, puts a few characters on the screen. */ | 801 // Must be done before redrawing, puts a few characters on the screen. |
802 may_req_ambiguous_char_width(); | 802 may_req_ambiguous_char_width(); |
803 #endif | 803 #endif |
804 | 804 |
805 RedrawingDisabled = 0; | 805 RedrawingDisabled = 0; |
806 redraw_all_later(NOT_VALID); | 806 redraw_all_later(NOT_VALID); |
807 no_wait_return = FALSE; | 807 no_wait_return = FALSE; |
808 | 808 |
809 /* 'autochdir' has been postponed */ | 809 // 'autochdir' has been postponed |
810 DO_AUTOCHDIR; | 810 DO_AUTOCHDIR; |
811 | 811 |
812 #ifdef FEAT_TERMRESPONSE | 812 #ifdef FEAT_TERMRESPONSE |
813 /* Requesting the termresponse is postponed until here, so that a "-c q" | 813 // Requesting the termresponse is postponed until here, so that a "-c q" |
814 * argument doesn't make it appear in the shell Vim was started from. */ | 814 // argument doesn't make it appear in the shell Vim was started from. |
815 may_req_termresponse(); | 815 may_req_termresponse(); |
816 | 816 |
817 may_req_bg_color(); | 817 may_req_bg_color(); |
818 #endif | 818 #endif |
819 | 819 |
820 /* start in insert mode */ | 820 // start in insert mode |
821 if (p_im) | 821 if (p_im) |
822 need_start_insertmode = TRUE; | 822 need_start_insertmode = TRUE; |
823 | 823 |
824 #ifdef FEAT_EVAL | 824 #ifdef FEAT_EVAL |
825 set_vim_var_nr(VV_VIM_DID_ENTER, 1L); | 825 set_vim_var_nr(VV_VIM_DID_ENTER, 1L); |
826 #endif | 826 #endif |
827 apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf); | 827 apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf); |
828 TIME_MSG("VimEnter autocommands"); | 828 TIME_MSG("VimEnter autocommands"); |
829 | 829 |
830 #if defined(FEAT_EVAL) && defined(FEAT_CLIPBOARD) | 830 #if defined(FEAT_EVAL) && defined(FEAT_CLIPBOARD) |
831 /* Adjust default register name for "unnamed" in 'clipboard'. Can only be | 831 // Adjust default register name for "unnamed" in 'clipboard'. Can only be |
832 * done after the clipboard is available and all initial commands that may | 832 // done after the clipboard is available and all initial commands that may |
833 * modify the 'clipboard' setting have run; i.e. just before entering the | 833 // modify the 'clipboard' setting have run; i.e. just before entering the |
834 * main loop. */ | 834 // main loop. |
835 { | 835 { |
836 int default_regname = 0; | 836 int default_regname = 0; |
837 | 837 |
838 adjust_clip_reg(&default_regname); | 838 adjust_clip_reg(&default_regname); |
839 set_reg_var(default_regname); | 839 set_reg_var(default_regname); |
840 } | 840 } |
841 #endif | 841 #endif |
842 | 842 |
843 #if defined(FEAT_DIFF) | 843 #if defined(FEAT_DIFF) |
844 /* When a startup script or session file setup for diff'ing and | 844 // When a startup script or session file setup for diff'ing and |
845 * scrollbind, sync the scrollbind now. */ | 845 // scrollbind, sync the scrollbind now. |
846 if (curwin->w_p_diff && curwin->w_p_scb) | 846 if (curwin->w_p_diff && curwin->w_p_scb) |
847 { | 847 { |
848 update_topline(); | 848 update_topline(); |
849 check_scrollbind((linenr_T)0, 0L); | 849 check_scrollbind((linenr_T)0, 0L); |
850 TIME_MSG("diff scrollbinding"); | 850 TIME_MSG("diff scrollbinding"); |
853 | 853 |
854 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) | 854 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) |
855 # ifdef VIMDLL | 855 # ifdef VIMDLL |
856 if (!gui.in_use) | 856 if (!gui.in_use) |
857 # endif | 857 # endif |
858 mch_set_winsize_now(); /* Allow winsize changes from now on */ | 858 mch_set_winsize_now(); // Allow winsize changes from now on |
859 #endif | 859 #endif |
860 | 860 |
861 #if defined(FEAT_GUI) | 861 #if defined(FEAT_GUI) |
862 /* When tab pages were created, may need to update the tab pages line and | 862 // When tab pages were created, may need to update the tab pages line and |
863 * scrollbars. This is skipped while creating them. */ | 863 // scrollbars. This is skipped while creating them. |
864 if (first_tabpage->tp_next != NULL) | 864 if (first_tabpage->tp_next != NULL) |
865 { | 865 { |
866 out_flush(); | 866 out_flush(); |
867 gui_init_which_components(NULL); | 867 gui_init_which_components(NULL); |
868 gui_update_scrollbars(TRUE); | 868 gui_update_scrollbars(TRUE); |
869 } | 869 } |
870 need_mouse_correct = TRUE; | 870 need_mouse_correct = TRUE; |
871 #endif | 871 #endif |
872 | 872 |
873 /* If ":startinsert" command used, stuff a dummy command to be able to | 873 // If ":startinsert" command used, stuff a dummy command to be able to |
874 * call normal_cmd(), which will then start Insert mode. */ | 874 // call normal_cmd(), which will then start Insert mode. |
875 if (restart_edit != 0) | 875 if (restart_edit != 0) |
876 stuffcharReadbuff(K_NOP); | 876 stuffcharReadbuff(K_NOP); |
877 | 877 |
878 #ifdef FEAT_NETBEANS_INTG | 878 #ifdef FEAT_NETBEANS_INTG |
879 if (netbeansArg != NULL && strncmp("-nb", netbeansArg, 3) == 0) | 879 if (netbeansArg != NULL && strncmp("-nb", netbeansArg, 3) == 0) |
886 mch_errmsg(_("netbeans is not supported with this GUI\n")); | 886 mch_errmsg(_("netbeans is not supported with this GUI\n")); |
887 mch_exit(2); | 887 mch_exit(2); |
888 } | 888 } |
889 # endif | 889 # endif |
890 # endif | 890 # endif |
891 /* Tell the client that it can start sending commands. */ | 891 // Tell the client that it can start sending commands. |
892 netbeans_open(netbeansArg + 3, TRUE); | 892 netbeans_open(netbeansArg + 3, TRUE); |
893 } | 893 } |
894 #endif | 894 #endif |
895 | 895 |
896 TIME_MSG("before starting main loop"); | 896 TIME_MSG("before starting main loop"); |
898 /* | 898 /* |
899 * Call the main command loop. This never returns. | 899 * Call the main command loop. This never returns. |
900 */ | 900 */ |
901 main_loop(FALSE, FALSE); | 901 main_loop(FALSE, FALSE); |
902 | 902 |
903 #endif /* NO_VIM_MAIN */ | 903 #endif // NO_VIM_MAIN |
904 | 904 |
905 return 0; | 905 return 0; |
906 } | 906 } |
907 | 907 |
908 /* | 908 /* |
911 void | 911 void |
912 common_init(mparm_T *paramp) | 912 common_init(mparm_T *paramp) |
913 { | 913 { |
914 cmdline_init(); | 914 cmdline_init(); |
915 | 915 |
916 (void)mb_init(); /* init mb_bytelen_tab[] to ones */ | 916 (void)mb_init(); // init mb_bytelen_tab[] to ones |
917 #ifdef FEAT_EVAL | 917 #ifdef FEAT_EVAL |
918 eval_init(); /* init global variables */ | 918 eval_init(); // init global variables |
919 #endif | 919 #endif |
920 | 920 |
921 #ifdef __QNXNTO__ | 921 #ifdef __QNXNTO__ |
922 qnx_init(); /* PhAttach() for clipboard, (and gui) */ | 922 qnx_init(); // PhAttach() for clipboard, (and gui) |
923 #endif | 923 #endif |
924 | 924 |
925 /* Init the table of Normal mode commands. */ | 925 // Init the table of Normal mode commands. |
926 init_normal_cmds(); | 926 init_normal_cmds(); |
927 | 927 |
928 /* | 928 /* |
929 * Allocate space for the generic buffers (needed for set_init_1() and | 929 * Allocate space for the generic buffers (needed for set_init_1() and |
930 * emsg()). | 930 * emsg()). |
933 || (NameBuff = alloc(MAXPATHL)) == NULL) | 933 || (NameBuff = alloc(MAXPATHL)) == NULL) |
934 mch_exit(0); | 934 mch_exit(0); |
935 TIME_MSG("Allocated generic buffers"); | 935 TIME_MSG("Allocated generic buffers"); |
936 | 936 |
937 #ifdef NBDEBUG | 937 #ifdef NBDEBUG |
938 /* Wait a moment for debugging NetBeans. Must be after allocating | 938 // Wait a moment for debugging NetBeans. Must be after allocating |
939 * NameBuff. */ | 939 // NameBuff. |
940 nbdebug_log_init("SPRO_GVIM_DEBUG", "SPRO_GVIM_DLEVEL"); | 940 nbdebug_log_init("SPRO_GVIM_DEBUG", "SPRO_GVIM_DLEVEL"); |
941 nbdebug_wait(WT_ENV | WT_WAIT | WT_STOP, "SPRO_GVIM_WAIT", 20); | 941 nbdebug_wait(WT_ENV | WT_WAIT | WT_STOP, "SPRO_GVIM_WAIT", 20); |
942 TIME_MSG("NetBeans debug wait"); | 942 TIME_MSG("NetBeans debug wait"); |
943 #endif | 943 #endif |
944 | 944 |
951 init_locale(); | 951 init_locale(); |
952 TIME_MSG("locale set"); | 952 TIME_MSG("locale set"); |
953 #endif | 953 #endif |
954 | 954 |
955 #ifdef FEAT_GUI | 955 #ifdef FEAT_GUI |
956 gui.dofork = TRUE; /* default is to use fork() */ | 956 gui.dofork = TRUE; // default is to use fork() |
957 #endif | 957 #endif |
958 | 958 |
959 /* | 959 /* |
960 * Do a first scan of the arguments in "argv[]": | 960 * Do a first scan of the arguments in "argv[]": |
961 * -display or --display | 961 * -display or --display |
964 * --windowid | 964 * --windowid |
965 */ | 965 */ |
966 early_arg_scan(paramp); | 966 early_arg_scan(paramp); |
967 | 967 |
968 #if defined(FEAT_GUI) | 968 #if defined(FEAT_GUI) |
969 /* Prepare for possibly starting GUI sometime */ | 969 // Prepare for possibly starting GUI sometime |
970 gui_prepare(¶mp->argc, paramp->argv); | 970 gui_prepare(¶mp->argc, paramp->argv); |
971 TIME_MSG("GUI prepared"); | 971 TIME_MSG("GUI prepared"); |
972 #endif | 972 #endif |
973 | 973 |
974 #ifdef FEAT_CLIPBOARD | 974 #ifdef FEAT_CLIPBOARD |
975 clip_init(FALSE); /* Initialise clipboard stuff */ | 975 clip_init(FALSE); // Initialise clipboard stuff |
976 TIME_MSG("clipboard setup"); | 976 TIME_MSG("clipboard setup"); |
977 #endif | 977 #endif |
978 | 978 |
979 /* | 979 /* |
980 * Check if we have an interactive window. | 980 * Check if we have an interactive window. |
990 * Can't do anything without it, exit when it fails. | 990 * Can't do anything without it, exit when it fails. |
991 */ | 991 */ |
992 if (win_alloc_first() == FAIL) | 992 if (win_alloc_first() == FAIL) |
993 mch_exit(0); | 993 mch_exit(0); |
994 | 994 |
995 init_yank(); /* init yank buffers */ | 995 init_yank(); // init yank buffers |
996 | 996 |
997 alist_init(&global_alist); /* Init the argument list to empty. */ | 997 alist_init(&global_alist); // Init the argument list to empty. |
998 global_alist.id = 0; | 998 global_alist.id = 0; |
999 | 999 |
1000 /* | 1000 /* |
1001 * Set the default values for the options. | 1001 * Set the default values for the options. |
1002 * NOTE: Non-latin1 translated messages are working only after this, | 1002 * NOTE: Non-latin1 translated messages are working only after this, |
1003 * because this is where "has_mbyte" will be set, which is used by | 1003 * because this is where "has_mbyte" will be set, which is used by |
1004 * msg_outtrans_len_attr(). | 1004 * msg_outtrans_len_attr(). |
1005 * First find out the home directory, needed to expand "~" in options. | 1005 * First find out the home directory, needed to expand "~" in options. |
1006 */ | 1006 */ |
1007 init_homedir(); /* find real value of $HOME */ | 1007 init_homedir(); // find real value of $HOME |
1008 set_init_1(paramp->clean); | 1008 set_init_1(paramp->clean); |
1009 TIME_MSG("inits 1"); | 1009 TIME_MSG("inits 1"); |
1010 | 1010 |
1011 #ifdef FEAT_EVAL | 1011 #ifdef FEAT_EVAL |
1012 // set v:lang and v:ctype | 1012 // set v:lang and v:ctype |
1154 * Also used to handle ":visual" command after ":global": execute Normal mode | 1154 * Also used to handle ":visual" command after ":global": execute Normal mode |
1155 * commands, return when entering Ex mode. "noexmode" is TRUE then. | 1155 * commands, return when entering Ex mode. "noexmode" is TRUE then. |
1156 */ | 1156 */ |
1157 void | 1157 void |
1158 main_loop( | 1158 main_loop( |
1159 int cmdwin, /* TRUE when working in the command-line window */ | 1159 int cmdwin, // TRUE when working in the command-line window |
1160 int noexmode) /* TRUE when return on entering Ex mode */ | 1160 int noexmode) // TRUE when return on entering Ex mode |
1161 { | 1161 { |
1162 oparg_T oa; // operator arguments | 1162 oparg_T oa; // operator arguments |
1163 oparg_T *prev_oap; // operator arguments | 1163 oparg_T *prev_oap; // operator arguments |
1164 volatile int previous_got_int = FALSE; // "got_int" was TRUE | 1164 volatile int previous_got_int = FALSE; // "got_int" was TRUE |
1165 #ifdef FEAT_CONCEAL | 1165 #ifdef FEAT_CONCEAL |
1171 | 1171 |
1172 prev_oap = current_oap; | 1172 prev_oap = current_oap; |
1173 current_oap = &oa; | 1173 current_oap = &oa; |
1174 | 1174 |
1175 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) | 1175 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) |
1176 /* Setup to catch a terminating error from the X server. Just ignore | 1176 // Setup to catch a terminating error from the X server. Just ignore |
1177 * it, restore the state and continue. This might not always work | 1177 // it, restore the state and continue. This might not always work |
1178 * properly, but at least we don't exit unexpectedly when the X server | 1178 // properly, but at least we don't exit unexpectedly when the X server |
1179 * exits while Vim is running in a console. */ | 1179 // exits while Vim is running in a console. |
1180 if (!cmdwin && !noexmode && SETJMP(x_jump_env)) | 1180 if (!cmdwin && !noexmode && SETJMP(x_jump_env)) |
1181 { | 1181 { |
1182 State = NORMAL; | 1182 State = NORMAL; |
1183 VIsual_active = FALSE; | 1183 VIsual_active = FALSE; |
1184 got_int = TRUE; | 1184 got_int = TRUE; |
1211 if (stuff_empty()) | 1211 if (stuff_empty()) |
1212 { | 1212 { |
1213 did_check_timestamps = FALSE; | 1213 did_check_timestamps = FALSE; |
1214 if (need_check_timestamps) | 1214 if (need_check_timestamps) |
1215 check_timestamps(FALSE); | 1215 check_timestamps(FALSE); |
1216 if (need_wait_return) /* if wait_return still needed ... */ | 1216 if (need_wait_return) // if wait_return still needed ... |
1217 wait_return(FALSE); /* ... call it now */ | 1217 wait_return(FALSE); // ... call it now |
1218 if (need_start_insertmode && goto_im() && !VIsual_active) | 1218 if (need_start_insertmode && goto_im() && !VIsual_active) |
1219 { | 1219 { |
1220 need_start_insertmode = FALSE; | 1220 need_start_insertmode = FALSE; |
1221 stuffReadbuff((char_u *)"i"); /* start insert mode next */ | 1221 stuffReadbuff((char_u *)"i"); // start insert mode next |
1222 /* skip the fileinfo message now, because it would be shown | 1222 // skip the fileinfo message now, because it would be shown |
1223 * after insert mode finishes! */ | 1223 // after insert mode finishes! |
1224 need_fileinfo = FALSE; | 1224 need_fileinfo = FALSE; |
1225 } | 1225 } |
1226 } | 1226 } |
1227 | 1227 |
1228 /* Reset "got_int" now that we got back to the main loop. Except when | 1228 // Reset "got_int" now that we got back to the main loop. Except when |
1229 * inside a ":g/pat/cmd" command, then the "got_int" needs to abort | 1229 // inside a ":g/pat/cmd" command, then the "got_int" needs to abort |
1230 * the ":g" command. | 1230 // the ":g" command. |
1231 * For ":g/pat/vi" we reset "got_int" when used once. When used | 1231 // For ":g/pat/vi" we reset "got_int" when used once. When used |
1232 * a second time we go back to Ex mode and abort the ":g" command. */ | 1232 // a second time we go back to Ex mode and abort the ":g" command. |
1233 if (got_int) | 1233 if (got_int) |
1234 { | 1234 { |
1235 if (noexmode && global_busy && !exmode_active && previous_got_int) | 1235 if (noexmode && global_busy && !exmode_active && previous_got_int) |
1236 { | 1236 { |
1237 /* Typed two CTRL-C in a row: go back to ex mode as if "Q" was | 1237 // Typed two CTRL-C in a row: go back to ex mode as if "Q" was |
1238 * used and keep "got_int" set, so that it aborts ":g". */ | 1238 // used and keep "got_int" set, so that it aborts ":g". |
1239 exmode_active = EXMODE_NORMAL; | 1239 exmode_active = EXMODE_NORMAL; |
1240 State = NORMAL; | 1240 State = NORMAL; |
1241 } | 1241 } |
1242 else if (!global_busy || !exmode_active) | 1242 else if (!global_busy || !exmode_active) |
1243 { | 1243 { |
1244 if (!quit_more) | 1244 if (!quit_more) |
1245 (void)vgetc(); /* flush all buffers */ | 1245 (void)vgetc(); // flush all buffers |
1246 got_int = FALSE; | 1246 got_int = FALSE; |
1247 } | 1247 } |
1248 previous_got_int = TRUE; | 1248 previous_got_int = TRUE; |
1249 } | 1249 } |
1250 else | 1250 else |
1278 #ifdef FEAT_CONCEAL | 1278 #ifdef FEAT_CONCEAL |
1279 if (curwin->w_p_cole == 0) | 1279 if (curwin->w_p_cole == 0) |
1280 conceal_update_lines = FALSE; | 1280 conceal_update_lines = FALSE; |
1281 #endif | 1281 #endif |
1282 | 1282 |
1283 /* Trigger CursorMoved if the cursor moved. */ | 1283 // Trigger CursorMoved if the cursor moved. |
1284 if (!finish_op && ( | 1284 if (!finish_op && ( |
1285 has_cursormoved() | 1285 has_cursormoved() |
1286 #ifdef FEAT_PROP_POPUP | 1286 #ifdef FEAT_PROP_POPUP |
1287 || popup_visible | 1287 || popup_visible |
1288 #endif | 1288 #endif |
1325 curwin->w_valid &= ~VALID_CROW; | 1325 curwin->w_valid &= ~VALID_CROW; |
1326 need_cursor_line_redraw = FALSE; | 1326 need_cursor_line_redraw = FALSE; |
1327 } | 1327 } |
1328 #endif | 1328 #endif |
1329 | 1329 |
1330 /* Trigger TextChanged if b:changedtick differs. */ | 1330 // Trigger TextChanged if b:changedtick differs. |
1331 if (!finish_op && has_textchanged() | 1331 if (!finish_op && has_textchanged() |
1332 && curbuf->b_last_changedtick != CHANGEDTICK(curbuf)) | 1332 && curbuf->b_last_changedtick != CHANGEDTICK(curbuf)) |
1333 { | 1333 { |
1334 apply_autocmds(EVENT_TEXTCHANGED, NULL, NULL, FALSE, curbuf); | 1334 apply_autocmds(EVENT_TEXTCHANGED, NULL, NULL, FALSE, curbuf); |
1335 curbuf->b_last_changedtick = CHANGEDTICK(curbuf); | 1335 curbuf->b_last_changedtick = CHANGEDTICK(curbuf); |
1347 { | 1347 { |
1348 ex_diffupdate(NULL); | 1348 ex_diffupdate(NULL); |
1349 curtab->tp_diff_update = FALSE; | 1349 curtab->tp_diff_update = FALSE; |
1350 } | 1350 } |
1351 | 1351 |
1352 /* Scroll-binding for diff mode may have been postponed until | 1352 // Scroll-binding for diff mode may have been postponed until |
1353 * here. Avoids doing it for every change. */ | 1353 // here. Avoids doing it for every change. |
1354 if (diff_need_scrollbind) | 1354 if (diff_need_scrollbind) |
1355 { | 1355 { |
1356 check_scrollbind((linenr_T)0, 0L); | 1356 check_scrollbind((linenr_T)0, 0L); |
1357 diff_need_scrollbind = FALSE; | 1357 diff_need_scrollbind = FALSE; |
1358 } | 1358 } |
1359 #endif | 1359 #endif |
1360 #if defined(FEAT_FOLDING) | 1360 #if defined(FEAT_FOLDING) |
1361 /* Include a closed fold completely in the Visual area. */ | 1361 // Include a closed fold completely in the Visual area. |
1362 foldAdjustVisual(); | 1362 foldAdjustVisual(); |
1363 #endif | 1363 #endif |
1364 #ifdef FEAT_FOLDING | 1364 #ifdef FEAT_FOLDING |
1365 /* | 1365 /* |
1366 * When 'foldclose' is set, apply 'foldlevel' to folds that don't | 1366 * When 'foldclose' is set, apply 'foldlevel' to folds that don't |
1408 maketitle(); | 1408 maketitle(); |
1409 #endif | 1409 #endif |
1410 #ifdef FEAT_VIMINFO | 1410 #ifdef FEAT_VIMINFO |
1411 curbuf->b_last_used = vim_time(); | 1411 curbuf->b_last_used = vim_time(); |
1412 #endif | 1412 #endif |
1413 /* display message after redraw */ | 1413 // display message after redraw |
1414 if (keep_msg != NULL) | 1414 if (keep_msg != NULL) |
1415 { | 1415 { |
1416 char_u *p = vim_strsave(keep_msg); | 1416 char_u *p = vim_strsave(keep_msg); |
1417 | 1417 |
1418 if (p != NULL) | 1418 if (p != NULL) |
1425 msg_attr((char *)p, keep_msg_attr); | 1425 msg_attr((char *)p, keep_msg_attr); |
1426 msg_hist_off = FALSE; | 1426 msg_hist_off = FALSE; |
1427 vim_free(p); | 1427 vim_free(p); |
1428 } | 1428 } |
1429 } | 1429 } |
1430 if (need_fileinfo) /* show file info after redraw */ | 1430 if (need_fileinfo) // show file info after redraw |
1431 { | 1431 { |
1432 fileinfo(FALSE, TRUE, FALSE); | 1432 fileinfo(FALSE, TRUE, FALSE); |
1433 need_fileinfo = FALSE; | 1433 need_fileinfo = FALSE; |
1434 } | 1434 } |
1435 | 1435 |
1436 emsg_on_display = FALSE; /* can delete error message now */ | 1436 emsg_on_display = FALSE; // can delete error message now |
1437 did_emsg = FALSE; | 1437 did_emsg = FALSE; |
1438 msg_didany = FALSE; /* reset lines_left in msg_start() */ | 1438 msg_didany = FALSE; // reset lines_left in msg_start() |
1439 may_clear_sb_text(); /* clear scroll-back text on next msg */ | 1439 may_clear_sb_text(); // clear scroll-back text on next msg |
1440 showruler(FALSE); | 1440 showruler(FALSE); |
1441 | 1441 |
1442 setcursor(); | 1442 setcursor(); |
1443 cursor_on(); | 1443 cursor_on(); |
1444 | 1444 |
1445 do_redraw = FALSE; | 1445 do_redraw = FALSE; |
1446 | 1446 |
1447 #ifdef STARTUPTIME | 1447 #ifdef STARTUPTIME |
1448 /* Now that we have drawn the first screen all the startup stuff | 1448 // Now that we have drawn the first screen all the startup stuff |
1449 * has been done, close any file for startup messages. */ | 1449 // has been done, close any file for startup messages. |
1450 if (time_fd != NULL) | 1450 if (time_fd != NULL) |
1451 { | 1451 { |
1452 TIME_MSG("first screen update"); | 1452 TIME_MSG("first screen update"); |
1453 TIME_MSG("--- VIM STARTED ---"); | 1453 TIME_MSG("--- VIM STARTED ---"); |
1454 fclose(time_fd); | 1454 fclose(time_fd); |
1481 * If we're invoked as ex, do a round of ex commands. | 1481 * If we're invoked as ex, do a round of ex commands. |
1482 * Otherwise, get and execute a normal mode command. | 1482 * Otherwise, get and execute a normal mode command. |
1483 */ | 1483 */ |
1484 if (exmode_active) | 1484 if (exmode_active) |
1485 { | 1485 { |
1486 if (noexmode) /* End of ":global/path/visual" commands */ | 1486 if (noexmode) // End of ":global/path/visual" commands |
1487 goto theend; | 1487 goto theend; |
1488 do_exmode(exmode_active == EXMODE_VIM); | 1488 do_exmode(exmode_active == EXMODE_VIM); |
1489 } | 1489 } |
1490 else | 1490 else |
1491 { | 1491 { |
1493 if (term_use_loop() | 1493 if (term_use_loop() |
1494 && oa.op_type == OP_NOP && oa.regname == NUL | 1494 && oa.op_type == OP_NOP && oa.regname == NUL |
1495 && !VIsual_active | 1495 && !VIsual_active |
1496 && !skip_term_loop) | 1496 && !skip_term_loop) |
1497 { | 1497 { |
1498 /* If terminal_loop() returns OK we got a key that is handled | 1498 // If terminal_loop() returns OK we got a key that is handled |
1499 * in Normal model. With FAIL we first need to position the | 1499 // in Normal model. With FAIL we first need to position the |
1500 * cursor and the screen needs to be redrawn. */ | 1500 // cursor and the screen needs to be redrawn. |
1501 if (terminal_loop(TRUE) == OK) | 1501 if (terminal_loop(TRUE) == OK) |
1502 normal_cmd(&oa, TRUE); | 1502 normal_cmd(&oa, TRUE); |
1503 } | 1503 } |
1504 else | 1504 else |
1505 #endif | 1505 #endif |
1523 */ | 1523 */ |
1524 void | 1524 void |
1525 getout_preserve_modified(int exitval) | 1525 getout_preserve_modified(int exitval) |
1526 { | 1526 { |
1527 # if defined(SIGHUP) && defined(SIG_IGN) | 1527 # if defined(SIGHUP) && defined(SIG_IGN) |
1528 /* Ignore SIGHUP, because a dropped connection causes a read error, which | 1528 // Ignore SIGHUP, because a dropped connection causes a read error, which |
1529 * makes Vim exit and then handling SIGHUP causes various reentrance | 1529 // makes Vim exit and then handling SIGHUP causes various reentrance |
1530 * problems. */ | 1530 // problems. |
1531 signal(SIGHUP, SIG_IGN); | 1531 signal(SIGHUP, SIG_IGN); |
1532 # endif | 1532 # endif |
1533 | 1533 |
1534 ml_close_notmod(); /* close all not-modified buffers */ | 1534 ml_close_notmod(); // close all not-modified buffers |
1535 ml_sync_all(FALSE, FALSE); /* preserve all swap files */ | 1535 ml_sync_all(FALSE, FALSE); // preserve all swap files |
1536 ml_close_all(FALSE); /* close all memfiles, without deleting */ | 1536 ml_close_all(FALSE); // close all memfiles, without deleting |
1537 getout(exitval); /* exit Vim properly */ | 1537 getout(exitval); // exit Vim properly |
1538 } | 1538 } |
1539 #endif | 1539 #endif |
1540 | 1540 |
1541 | 1541 |
1542 /* | 1542 /* |
1548 exiting = TRUE; | 1548 exiting = TRUE; |
1549 #if defined(FEAT_JOB_CHANNEL) | 1549 #if defined(FEAT_JOB_CHANNEL) |
1550 ch_log(NULL, "Exiting..."); | 1550 ch_log(NULL, "Exiting..."); |
1551 #endif | 1551 #endif |
1552 | 1552 |
1553 /* When running in Ex mode an error causes us to exit with a non-zero exit | 1553 // When running in Ex mode an error causes us to exit with a non-zero exit |
1554 * code. POSIX requires this, although it's not 100% clear from the | 1554 // code. POSIX requires this, although it's not 100% clear from the |
1555 * standard. */ | 1555 // standard. |
1556 if (exmode_active) | 1556 if (exmode_active) |
1557 exitval += ex_exitval; | 1557 exitval += ex_exitval; |
1558 | 1558 |
1559 /* Position the cursor on the last screen line, below all the text */ | 1559 // Position the cursor on the last screen line, below all the text |
1560 #ifdef FEAT_GUI | 1560 #ifdef FEAT_GUI |
1561 if (!gui.in_use) | 1561 if (!gui.in_use) |
1562 #endif | 1562 #endif |
1563 windgoto((int)Rows - 1, 0); | 1563 windgoto((int)Rows - 1, 0); |
1564 | 1564 |
1565 #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL) | 1565 #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL) |
1566 /* Optionally print hashtable efficiency. */ | 1566 // Optionally print hashtable efficiency. |
1567 hash_debug_results(); | 1567 hash_debug_results(); |
1568 #endif | 1568 #endif |
1569 | 1569 |
1570 #ifdef FEAT_GUI | 1570 #ifdef FEAT_GUI |
1571 msg_didany = FALSE; | 1571 msg_didany = FALSE; |
1576 tabpage_T *tp; | 1576 tabpage_T *tp; |
1577 tabpage_T *next_tp; | 1577 tabpage_T *next_tp; |
1578 buf_T *buf; | 1578 buf_T *buf; |
1579 win_T *wp; | 1579 win_T *wp; |
1580 | 1580 |
1581 /* Trigger BufWinLeave for all windows, but only once per buffer. */ | 1581 // Trigger BufWinLeave for all windows, but only once per buffer. |
1582 for (tp = first_tabpage; tp != NULL; tp = next_tp) | 1582 for (tp = first_tabpage; tp != NULL; tp = next_tp) |
1583 { | 1583 { |
1584 next_tp = tp->tp_next; | 1584 next_tp = tp->tp_next; |
1585 FOR_ALL_WINDOWS_IN_TAB(tp, wp) | 1585 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
1586 { | 1586 { |
1587 if (wp->w_buffer == NULL) | 1587 if (wp->w_buffer == NULL) |
1588 /* Autocmd must have close the buffer already, skip. */ | 1588 // Autocmd must have close the buffer already, skip. |
1589 continue; | 1589 continue; |
1590 buf = wp->w_buffer; | 1590 buf = wp->w_buffer; |
1591 if (CHANGEDTICK(buf) != -1) | 1591 if (CHANGEDTICK(buf) != -1) |
1592 { | 1592 { |
1593 bufref_T bufref; | 1593 bufref_T bufref; |
1594 | 1594 |
1595 set_bufref(&bufref, buf); | 1595 set_bufref(&bufref, buf); |
1596 apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, | 1596 apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, |
1597 buf->b_fname, FALSE, buf); | 1597 buf->b_fname, FALSE, buf); |
1598 if (bufref_valid(&bufref)) | 1598 if (bufref_valid(&bufref)) |
1599 CHANGEDTICK(buf) = -1; /* note we did it already */ | 1599 CHANGEDTICK(buf) = -1; // note we did it already |
1600 | 1600 |
1601 /* start all over, autocommands may mess up the lists */ | 1601 // start all over, autocommands may mess up the lists |
1602 next_tp = first_tabpage; | 1602 next_tp = first_tabpage; |
1603 break; | 1603 break; |
1604 } | 1604 } |
1605 } | 1605 } |
1606 } | 1606 } |
1607 | 1607 |
1608 /* Trigger BufUnload for buffers that are loaded */ | 1608 // Trigger BufUnload for buffers that are loaded |
1609 FOR_ALL_BUFFERS(buf) | 1609 FOR_ALL_BUFFERS(buf) |
1610 if (buf->b_ml.ml_mfp != NULL) | 1610 if (buf->b_ml.ml_mfp != NULL) |
1611 { | 1611 { |
1612 bufref_T bufref; | 1612 bufref_T bufref; |
1613 | 1613 |
1614 set_bufref(&bufref, buf); | 1614 set_bufref(&bufref, buf); |
1615 apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, | 1615 apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, |
1616 FALSE, buf); | 1616 FALSE, buf); |
1617 if (!bufref_valid(&bufref)) | 1617 if (!bufref_valid(&bufref)) |
1618 /* autocmd deleted the buffer */ | 1618 // autocmd deleted the buffer |
1619 break; | 1619 break; |
1620 } | 1620 } |
1621 apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf); | 1621 apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf); |
1622 } | 1622 } |
1623 | 1623 |
1624 #ifdef FEAT_VIMINFO | 1624 #ifdef FEAT_VIMINFO |
1625 if (*p_viminfo != NUL) | 1625 if (*p_viminfo != NUL) |
1626 /* Write out the registers, history, marks etc, to the viminfo file */ | 1626 // Write out the registers, history, marks etc, to the viminfo file |
1627 write_viminfo(NULL, FALSE); | 1627 write_viminfo(NULL, FALSE); |
1628 #endif | 1628 #endif |
1629 | 1629 |
1630 if (v_dying <= 1) | 1630 if (v_dying <= 1) |
1631 { | 1631 { |
1650 #ifdef FEAT_GUI | 1650 #ifdef FEAT_GUI |
1651 || (gui.in_use && msg_didany && p_verbose > 0) | 1651 || (gui.in_use && msg_didany && p_verbose > 0) |
1652 #endif | 1652 #endif |
1653 ) | 1653 ) |
1654 { | 1654 { |
1655 /* give the user a chance to read the (error) message */ | 1655 // give the user a chance to read the (error) message |
1656 no_wait_return = FALSE; | 1656 no_wait_return = FALSE; |
1657 wait_return(FALSE); | 1657 wait_return(FALSE); |
1658 } | 1658 } |
1659 | 1659 |
1660 /* Position the cursor again, the autocommands may have moved it */ | 1660 // Position the cursor again, the autocommands may have moved it |
1661 #ifdef FEAT_GUI | 1661 #ifdef FEAT_GUI |
1662 if (!gui.in_use) | 1662 if (!gui.in_use) |
1663 #endif | 1663 #endif |
1664 windgoto((int)Rows - 1, 0); | 1664 windgoto((int)Rows - 1, 0); |
1665 | 1665 |
1715 init_locale(void) | 1715 init_locale(void) |
1716 { | 1716 { |
1717 setlocale(LC_ALL, ""); | 1717 setlocale(LC_ALL, ""); |
1718 | 1718 |
1719 # ifdef FEAT_GUI_GTK | 1719 # ifdef FEAT_GUI_GTK |
1720 /* Tell Gtk not to change our locale settings. */ | 1720 // Tell Gtk not to change our locale settings. |
1721 gtk_disable_setlocale(); | 1721 gtk_disable_setlocale(); |
1722 # endif | 1722 # endif |
1723 # if defined(FEAT_FLOAT) && defined(LC_NUMERIC) | 1723 # if defined(FEAT_FLOAT) && defined(LC_NUMERIC) |
1724 /* Make sure strtod() uses a decimal point, not a comma. */ | 1724 // Make sure strtod() uses a decimal point, not a comma. |
1725 setlocale(LC_NUMERIC, "C"); | 1725 setlocale(LC_NUMERIC, "C"); |
1726 # endif | 1726 # endif |
1727 | 1727 |
1728 # ifdef MSWIN | 1728 # ifdef MSWIN |
1729 /* Apparently MS-Windows printf() may cause a crash when we give it 8-bit | 1729 // Apparently MS-Windows printf() may cause a crash when we give it 8-bit |
1730 * text while it's expecting text in the current locale. This call avoids | 1730 // text while it's expecting text in the current locale. This call avoids |
1731 * that. */ | 1731 // that. |
1732 setlocale(LC_CTYPE, "C"); | 1732 setlocale(LC_CTYPE, "C"); |
1733 # endif | 1733 # endif |
1734 | 1734 |
1735 # ifdef FEAT_GETTEXT | 1735 # ifdef FEAT_GETTEXT |
1736 { | 1736 { |
1737 int mustfree = FALSE; | 1737 int mustfree = FALSE; |
1738 char_u *p; | 1738 char_u *p; |
1739 | 1739 |
1740 # ifdef DYNAMIC_GETTEXT | 1740 # ifdef DYNAMIC_GETTEXT |
1741 /* Initialize the gettext library */ | 1741 // Initialize the gettext library |
1742 dyn_libintl_init(); | 1742 dyn_libintl_init(); |
1743 # endif | 1743 # endif |
1744 /* expand_env() doesn't work yet, because g_chartab[] is not | 1744 // expand_env() doesn't work yet, because g_chartab[] is not |
1745 * initialized yet, call vim_getenv() directly */ | 1745 // initialized yet, call vim_getenv() directly |
1746 p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree); | 1746 p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree); |
1747 if (p != NULL && *p != NUL) | 1747 if (p != NULL && *p != NUL) |
1748 { | 1748 { |
1749 vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p); | 1749 vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p); |
1750 bindtextdomain(VIMPACKAGE, (char *)NameBuff); | 1750 bindtextdomain(VIMPACKAGE, (char *)NameBuff); |
1800 else if (STRNICMP(argv[i], "--remote", 8) == 0) | 1800 else if (STRNICMP(argv[i], "--remote", 8) == 0) |
1801 { | 1801 { |
1802 parmp->serverArg = TRUE; | 1802 parmp->serverArg = TRUE; |
1803 # ifdef FEAT_GUI | 1803 # ifdef FEAT_GUI |
1804 if (strstr(argv[i], "-wait") != 0) | 1804 if (strstr(argv[i], "-wait") != 0) |
1805 /* don't fork() when starting the GUI to edit files ourself */ | 1805 // don't fork() when starting the GUI to edit files ourself |
1806 gui.dofork = FALSE; | 1806 gui.dofork = FALSE; |
1807 # endif | 1807 # endif |
1808 } | 1808 } |
1809 # endif | 1809 # endif |
1810 | 1810 |
1855 /* | 1855 /* |
1856 * Get a (optional) count for a Vim argument. | 1856 * Get a (optional) count for a Vim argument. |
1857 */ | 1857 */ |
1858 static int | 1858 static int |
1859 get_number_arg( | 1859 get_number_arg( |
1860 char_u *p, /* pointer to argument */ | 1860 char_u *p, // pointer to argument |
1861 int *idx, /* index in argument, is incremented */ | 1861 int *idx, // index in argument, is incremented |
1862 int def) /* default value */ | 1862 int def) // default value |
1863 { | 1863 { |
1864 if (vim_isdigit(p[*idx])) | 1864 if (vim_isdigit(p[*idx])) |
1865 { | 1865 { |
1866 def = atoi((char *)&(p[*idx])); | 1866 def = atoi((char *)&(p[*idx])); |
1867 while (vim_isdigit(p[*idx])) | 1867 while (vim_isdigit(p[*idx])) |
1886 char_u *initstr; | 1886 char_u *initstr; |
1887 | 1887 |
1888 initstr = gettail((char_u *)parmp->argv[0]); | 1888 initstr = gettail((char_u *)parmp->argv[0]); |
1889 | 1889 |
1890 #ifdef FEAT_GUI_MAC | 1890 #ifdef FEAT_GUI_MAC |
1891 /* An issue has been seen when launching Vim in such a way that | 1891 // An issue has been seen when launching Vim in such a way that |
1892 * $PWD/$ARGV[0] or $ARGV[0] is not the absolute path to the | 1892 // $PWD/$ARGV[0] or $ARGV[0] is not the absolute path to the |
1893 * executable or a symbolic link of it. Until this issue is resolved | 1893 // executable or a symbolic link of it. Until this issue is resolved |
1894 * we prohibit the GUI from being used. | 1894 // we prohibit the GUI from being used. |
1895 */ | |
1896 if (STRCMP(initstr, parmp->argv[0]) == 0) | 1895 if (STRCMP(initstr, parmp->argv[0]) == 0) |
1897 disallow_gui = TRUE; | 1896 disallow_gui = TRUE; |
1898 | 1897 |
1899 /* TODO: On MacOS X default to gui if argv[0] ends in: | 1898 // TODO: On MacOS X default to gui if argv[0] ends in: |
1900 * /Vim.app/Contents/MacOS/Vim */ | 1899 // /Vim.app/Contents/MacOS/Vim |
1901 #endif | 1900 #endif |
1902 | 1901 |
1903 #ifdef FEAT_EVAL | 1902 #ifdef FEAT_EVAL |
1904 set_vim_var_string(VV_PROGNAME, initstr, -1); | 1903 set_vim_var_string(VV_PROGNAME, initstr, -1); |
1905 set_progpath((char_u *)parmp->argv[0]); | 1904 set_progpath((char_u *)parmp->argv[0]); |
1909 { | 1908 { |
1910 restricted = TRUE; | 1909 restricted = TRUE; |
1911 ++initstr; | 1910 ++initstr; |
1912 } | 1911 } |
1913 | 1912 |
1914 /* Use evim mode for "evim" and "egvim", not for "editor". */ | 1913 // Use evim mode for "evim" and "egvim", not for "editor". |
1915 if (TOLOWER_ASC(initstr[0]) == 'e' | 1914 if (TOLOWER_ASC(initstr[0]) == 'e' |
1916 && (TOLOWER_ASC(initstr[1]) == 'v' | 1915 && (TOLOWER_ASC(initstr[1]) == 'v' |
1917 || TOLOWER_ASC(initstr[1]) == 'g')) | 1916 || TOLOWER_ASC(initstr[1]) == 'g')) |
1918 { | 1917 { |
1919 #ifdef FEAT_GUI | 1918 #ifdef FEAT_GUI |
1921 #endif | 1920 #endif |
1922 parmp->evim_mode = TRUE; | 1921 parmp->evim_mode = TRUE; |
1923 ++initstr; | 1922 ++initstr; |
1924 } | 1923 } |
1925 | 1924 |
1926 /* "gvim" starts the GUI. Also accept "Gvim" for MS-Windows. */ | 1925 // "gvim" starts the GUI. Also accept "Gvim" for MS-Windows. |
1927 if (TOLOWER_ASC(initstr[0]) == 'g') | 1926 if (TOLOWER_ASC(initstr[0]) == 'g') |
1928 { | 1927 { |
1929 main_start_gui(); | 1928 main_start_gui(); |
1930 #ifdef FEAT_GUI | 1929 #ifdef FEAT_GUI |
1931 ++initstr; | 1930 ++initstr; |
1942 | 1941 |
1943 if (STRNICMP(initstr, "view", 4) == 0) | 1942 if (STRNICMP(initstr, "view", 4) == 0) |
1944 { | 1943 { |
1945 readonlymode = TRUE; | 1944 readonlymode = TRUE; |
1946 curbuf->b_p_ro = TRUE; | 1945 curbuf->b_p_ro = TRUE; |
1947 p_uc = 10000; /* don't update very often */ | 1946 p_uc = 10000; // don't update very often |
1948 initstr += 4; | 1947 initstr += 4; |
1949 } | 1948 } |
1950 else if (STRNICMP(initstr, "vim", 3) == 0) | 1949 else if (STRNICMP(initstr, "vim", 3) == 0) |
1951 initstr += 3; | 1950 initstr += 3; |
1952 | 1951 |
1980 static void | 1979 static void |
1981 command_line_scan(mparm_T *parmp) | 1980 command_line_scan(mparm_T *parmp) |
1982 { | 1981 { |
1983 int argc = parmp->argc; | 1982 int argc = parmp->argc; |
1984 char **argv = parmp->argv; | 1983 char **argv = parmp->argv; |
1985 int argv_idx; /* index in argv[n][] */ | 1984 int argv_idx; // index in argv[n][] |
1986 int had_minmin = FALSE; /* found "--" argument */ | 1985 int had_minmin = FALSE; // found "--" argument |
1987 int want_argument; /* option argument with argument */ | 1986 int want_argument; // option argument with argument |
1988 int c; | 1987 int c; |
1989 char_u *p = NULL; | 1988 char_u *p = NULL; |
1990 long n; | 1989 long n; |
1991 | 1990 |
1992 --argc; | 1991 --argc; |
1993 ++argv; | 1992 ++argv; |
1994 argv_idx = 1; /* active option letter is argv[0][argv_idx] */ | 1993 argv_idx = 1; // active option letter is argv[0][argv_idx] |
1995 while (argc > 0) | 1994 while (argc > 0) |
1996 { | 1995 { |
1997 /* | 1996 /* |
1998 * "+" or "+{number}" or "+/{pat}" or "+{command}" argument. | 1997 * "+" or "+{number}" or "+/{pat}" or "+{command}" argument. |
1999 */ | 1998 */ |
2000 if (argv[0][0] == '+' && !had_minmin) | 1999 if (argv[0][0] == '+' && !had_minmin) |
2001 { | 2000 { |
2002 if (parmp->n_commands >= MAX_ARG_CMDS) | 2001 if (parmp->n_commands >= MAX_ARG_CMDS) |
2003 mainerr(ME_EXTRA_CMD, NULL); | 2002 mainerr(ME_EXTRA_CMD, NULL); |
2004 argv_idx = -1; /* skip to next argument */ | 2003 argv_idx = -1; // skip to next argument |
2005 if (argv[0][1] == NUL) | 2004 if (argv[0][1] == NUL) |
2006 parmp->commands[parmp->n_commands++] = (char_u *)"$"; | 2005 parmp->commands[parmp->n_commands++] = (char_u *)"$"; |
2007 else | 2006 else |
2008 parmp->commands[parmp->n_commands++] = (char_u *)&(argv[0][1]); | 2007 parmp->commands[parmp->n_commands++] = (char_u *)&(argv[0][1]); |
2009 } | 2008 } |
2028 else | 2027 else |
2029 c = TOLOWER_ASC(c); | 2028 c = TOLOWER_ASC(c); |
2030 #endif | 2029 #endif |
2031 switch (c) | 2030 switch (c) |
2032 { | 2031 { |
2033 case NUL: /* "vim -" read from stdin */ | 2032 case NUL: // "vim -" read from stdin |
2034 /* "ex -" silent mode */ | 2033 // "ex -" silent mode |
2035 if (exmode_active) | 2034 if (exmode_active) |
2036 silent_mode = TRUE; | 2035 silent_mode = TRUE; |
2037 else | 2036 else |
2038 { | 2037 { |
2039 if (parmp->edit_type != EDIT_NONE) | 2038 if (parmp->edit_type != EDIT_NONE) |
2040 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | 2039 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); |
2041 parmp->edit_type = EDIT_STDIN; | 2040 parmp->edit_type = EDIT_STDIN; |
2042 read_cmd_fd = 2; /* read from stderr instead of stdin */ | 2041 read_cmd_fd = 2; // read from stderr instead of stdin |
2043 } | 2042 } |
2044 argv_idx = -1; /* skip to next argument */ | 2043 argv_idx = -1; // skip to next argument |
2045 break; | 2044 break; |
2046 | 2045 |
2047 case '-': /* "--" don't take any more option arguments */ | 2046 case '-': // "--" don't take any more option arguments |
2048 /* "--help" give help message */ | 2047 // "--help" give help message |
2049 /* "--version" give version message */ | 2048 // "--version" give version message |
2050 /* "--clean" clean context */ | 2049 // "--clean" clean context |
2051 /* "--literal" take files literally */ | 2050 // "--literal" take files literally |
2052 /* "--nofork" don't fork */ | 2051 // "--nofork" don't fork |
2053 /* "--not-a-term" don't warn for not a term */ | 2052 // "--not-a-term" don't warn for not a term |
2054 /* "--ttyfail" exit if not a term */ | 2053 // "--ttyfail" exit if not a term |
2055 /* "--noplugin[s]" skip plugins */ | 2054 // "--noplugin[s]" skip plugins |
2056 /* "--cmd <cmd>" execute cmd before vimrc */ | 2055 // "--cmd <cmd>" execute cmd before vimrc |
2057 if (STRICMP(argv[0] + argv_idx, "help") == 0) | 2056 if (STRICMP(argv[0] + argv_idx, "help") == 0) |
2058 usage(); | 2057 usage(); |
2059 else if (STRICMP(argv[0] + argv_idx, "version") == 0) | 2058 else if (STRICMP(argv[0] + argv_idx, "version") == 0) |
2060 { | 2059 { |
2061 Columns = 80; /* need to init Columns */ | 2060 Columns = 80; // need to init Columns |
2062 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ | 2061 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
2063 list_version(); | 2062 list_version(); |
2064 msg_putchar('\n'); | 2063 msg_putchar('\n'); |
2065 msg_didout = FALSE; | 2064 msg_didout = FALSE; |
2066 mch_exit(0); | 2065 mch_exit(0); |
2067 } | 2066 } |
2081 #endif | 2080 #endif |
2082 } | 2081 } |
2083 else if (STRNICMP(argv[0] + argv_idx, "nofork", 6) == 0) | 2082 else if (STRNICMP(argv[0] + argv_idx, "nofork", 6) == 0) |
2084 { | 2083 { |
2085 #ifdef FEAT_GUI | 2084 #ifdef FEAT_GUI |
2086 gui.dofork = FALSE; /* don't fork() when starting GUI */ | 2085 gui.dofork = FALSE; // don't fork() when starting GUI |
2087 #endif | 2086 #endif |
2088 } | 2087 } |
2089 else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0) | 2088 else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0) |
2090 p_lpl = FALSE; | 2089 p_lpl = FALSE; |
2091 else if (STRNICMP(argv[0] + argv_idx, "not-a-term", 10) == 0) | 2090 else if (STRNICMP(argv[0] + argv_idx, "not-a-term", 10) == 0) |
2102 want_argument = TRUE; | 2101 want_argument = TRUE; |
2103 argv_idx += 11; | 2102 argv_idx += 11; |
2104 } | 2103 } |
2105 #ifdef FEAT_CLIENTSERVER | 2104 #ifdef FEAT_CLIENTSERVER |
2106 else if (STRNICMP(argv[0] + argv_idx, "serverlist", 10) == 0) | 2105 else if (STRNICMP(argv[0] + argv_idx, "serverlist", 10) == 0) |
2107 ; /* already processed -- no arg */ | 2106 ; // already processed -- no arg |
2108 else if (STRNICMP(argv[0] + argv_idx, "servername", 10) == 0 | 2107 else if (STRNICMP(argv[0] + argv_idx, "servername", 10) == 0 |
2109 || STRNICMP(argv[0] + argv_idx, "serversend", 10) == 0) | 2108 || STRNICMP(argv[0] + argv_idx, "serversend", 10) == 0) |
2110 { | 2109 { |
2111 /* already processed -- snatch the following arg */ | 2110 // already processed -- snatch the following arg |
2112 if (argc > 1) | 2111 if (argc > 1) |
2113 { | 2112 { |
2114 --argc; | 2113 --argc; |
2115 ++argv; | 2114 ++argv; |
2116 } | 2115 } |
2121 else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0) | 2120 else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0) |
2122 # else | 2121 # else |
2123 else if (STRNICMP(argv[0] + argv_idx, "windowid", 8) == 0) | 2122 else if (STRNICMP(argv[0] + argv_idx, "windowid", 8) == 0) |
2124 # endif | 2123 # endif |
2125 { | 2124 { |
2126 /* already processed -- snatch the following arg */ | 2125 // already processed -- snatch the following arg |
2127 if (argc > 1) | 2126 if (argc > 1) |
2128 { | 2127 { |
2129 --argc; | 2128 --argc; |
2130 ++argv; | 2129 ++argv; |
2131 } | 2130 } |
2132 } | 2131 } |
2133 #endif | 2132 #endif |
2134 #ifdef FEAT_GUI_GTK | 2133 #ifdef FEAT_GUI_GTK |
2135 else if (STRNICMP(argv[0] + argv_idx, "echo-wid", 8) == 0) | 2134 else if (STRNICMP(argv[0] + argv_idx, "echo-wid", 8) == 0) |
2136 { | 2135 { |
2137 /* already processed, skip */ | 2136 // already processed, skip |
2138 } | 2137 } |
2139 #endif | 2138 #endif |
2140 else | 2139 else |
2141 { | 2140 { |
2142 if (argv[0][argv_idx]) | 2141 if (argv[0][argv_idx]) |
2143 mainerr(ME_UNKNOWN_OPTION, (char_u *)argv[0]); | 2142 mainerr(ME_UNKNOWN_OPTION, (char_u *)argv[0]); |
2144 had_minmin = TRUE; | 2143 had_minmin = TRUE; |
2145 } | 2144 } |
2146 if (!want_argument) | 2145 if (!want_argument) |
2147 argv_idx = -1; /* skip to next argument */ | 2146 argv_idx = -1; // skip to next argument |
2148 break; | 2147 break; |
2149 | 2148 |
2150 case 'A': /* "-A" start in Arabic mode */ | 2149 case 'A': // "-A" start in Arabic mode |
2151 #ifdef FEAT_ARABIC | 2150 #ifdef FEAT_ARABIC |
2152 set_option_value((char_u *)"arabic", 1L, NULL, 0); | 2151 set_option_value((char_u *)"arabic", 1L, NULL, 0); |
2153 #else | 2152 #else |
2154 mch_errmsg(_(e_noarabic)); | 2153 mch_errmsg(_(e_noarabic)); |
2155 mch_exit(2); | 2154 mch_exit(2); |
2156 #endif | 2155 #endif |
2157 break; | 2156 break; |
2158 | 2157 |
2159 case 'b': /* "-b" binary mode */ | 2158 case 'b': // "-b" binary mode |
2160 /* Needs to be effective before expanding file names, because | 2159 // Needs to be effective before expanding file names, because |
2161 * for Win32 this makes us edit a shortcut file itself, | 2160 // for Win32 this makes us edit a shortcut file itself, |
2162 * instead of the file it links to. */ | 2161 // instead of the file it links to. |
2163 set_options_bin(curbuf->b_p_bin, 1, 0); | 2162 set_options_bin(curbuf->b_p_bin, 1, 0); |
2164 curbuf->b_p_bin = 1; /* binary file I/O */ | 2163 curbuf->b_p_bin = 1; // binary file I/O |
2165 break; | 2164 break; |
2166 | 2165 |
2167 case 'C': /* "-C" Compatible */ | 2166 case 'C': // "-C" Compatible |
2168 change_compatible(TRUE); | 2167 change_compatible(TRUE); |
2169 has_dash_c_arg = TRUE; | 2168 has_dash_c_arg = TRUE; |
2170 break; | 2169 break; |
2171 | 2170 |
2172 case 'e': /* "-e" Ex mode */ | 2171 case 'e': // "-e" Ex mode |
2173 exmode_active = EXMODE_NORMAL; | 2172 exmode_active = EXMODE_NORMAL; |
2174 break; | 2173 break; |
2175 | 2174 |
2176 case 'E': /* "-E" Improved Ex mode */ | 2175 case 'E': // "-E" Improved Ex mode |
2177 exmode_active = EXMODE_VIM; | 2176 exmode_active = EXMODE_VIM; |
2178 break; | 2177 break; |
2179 | 2178 |
2180 case 'f': /* "-f" GUI: run in foreground. Amiga: open | 2179 case 'f': // "-f" GUI: run in foreground. Amiga: open |
2181 window directly, not with newcli */ | 2180 // window directly, not with newcli |
2182 #ifdef FEAT_GUI | 2181 #ifdef FEAT_GUI |
2183 gui.dofork = FALSE; /* don't fork() when starting GUI */ | 2182 gui.dofork = FALSE; // don't fork() when starting GUI |
2184 #endif | 2183 #endif |
2185 break; | 2184 break; |
2186 | 2185 |
2187 case 'g': /* "-g" start GUI */ | 2186 case 'g': // "-g" start GUI |
2188 main_start_gui(); | 2187 main_start_gui(); |
2189 break; | 2188 break; |
2190 | 2189 |
2191 case 'F': /* "-F" was for Farsi mode */ | 2190 case 'F': // "-F" was for Farsi mode |
2192 mch_errmsg(_(e_nofarsi)); | 2191 mch_errmsg(_(e_nofarsi)); |
2193 mch_exit(2); | 2192 mch_exit(2); |
2194 break; | 2193 break; |
2195 | 2194 |
2196 case '?': /* "-?" give help message (for MS-Windows) */ | 2195 case '?': // "-?" give help message (for MS-Windows) |
2197 case 'h': /* "-h" give help message */ | 2196 case 'h': // "-h" give help message |
2198 #ifdef FEAT_GUI_GNOME | 2197 #ifdef FEAT_GUI_GNOME |
2199 /* Tell usage() to exit for "gvim". */ | 2198 // Tell usage() to exit for "gvim". |
2200 gui.starting = FALSE; | 2199 gui.starting = FALSE; |
2201 #endif | 2200 #endif |
2202 usage(); | 2201 usage(); |
2203 break; | 2202 break; |
2204 | 2203 |
2205 case 'H': /* "-H" start in Hebrew mode: rl + hkmap set */ | 2204 case 'H': // "-H" start in Hebrew mode: rl + hkmap set |
2206 #ifdef FEAT_RIGHTLEFT | 2205 #ifdef FEAT_RIGHTLEFT |
2207 p_hkmap = TRUE; | 2206 p_hkmap = TRUE; |
2208 set_option_value((char_u *)"rl", 1L, NULL, 0); | 2207 set_option_value((char_u *)"rl", 1L, NULL, 0); |
2209 #else | 2208 #else |
2210 mch_errmsg(_(e_nohebrew)); | 2209 mch_errmsg(_(e_nohebrew)); |
2211 mch_exit(2); | 2210 mch_exit(2); |
2212 #endif | 2211 #endif |
2213 break; | 2212 break; |
2214 | 2213 |
2215 case 'l': /* "-l" lisp mode, 'lisp' and 'showmatch' on */ | 2214 case 'l': // "-l" lisp mode, 'lisp' and 'showmatch' on |
2216 #ifdef FEAT_LISP | 2215 #ifdef FEAT_LISP |
2217 set_option_value((char_u *)"lisp", 1L, NULL, 0); | 2216 set_option_value((char_u *)"lisp", 1L, NULL, 0); |
2218 p_sm = TRUE; | 2217 p_sm = TRUE; |
2219 #endif | 2218 #endif |
2220 break; | 2219 break; |
2221 | 2220 |
2222 case 'M': /* "-M" no changes or writing of files */ | 2221 case 'M': // "-M" no changes or writing of files |
2223 reset_modifiable(); | 2222 reset_modifiable(); |
2224 /* FALLTHROUGH */ | 2223 // FALLTHROUGH |
2225 | 2224 |
2226 case 'm': /* "-m" no writing of files */ | 2225 case 'm': // "-m" no writing of files |
2227 p_write = FALSE; | 2226 p_write = FALSE; |
2228 break; | 2227 break; |
2229 | 2228 |
2230 case 'y': /* "-y" easy mode */ | 2229 case 'y': // "-y" easy mode |
2231 #ifdef FEAT_GUI | 2230 #ifdef FEAT_GUI |
2232 gui.starting = TRUE; /* start GUI a bit later */ | 2231 gui.starting = TRUE; // start GUI a bit later |
2233 #endif | 2232 #endif |
2234 parmp->evim_mode = TRUE; | 2233 parmp->evim_mode = TRUE; |
2235 break; | 2234 break; |
2236 | 2235 |
2237 case 'N': /* "-N" Nocompatible */ | 2236 case 'N': // "-N" Nocompatible |
2238 change_compatible(FALSE); | 2237 change_compatible(FALSE); |
2239 break; | 2238 break; |
2240 | 2239 |
2241 case 'n': /* "-n" no swap file */ | 2240 case 'n': // "-n" no swap file |
2242 #ifdef FEAT_NETBEANS_INTG | 2241 #ifdef FEAT_NETBEANS_INTG |
2243 /* checking for "-nb", netbeans parameters */ | 2242 // checking for "-nb", netbeans parameters |
2244 if (argv[0][argv_idx] == 'b') | 2243 if (argv[0][argv_idx] == 'b') |
2245 { | 2244 { |
2246 netbeansArg = argv[0]; | 2245 netbeansArg = argv[0]; |
2247 argv_idx = -1; /* skip to next argument */ | 2246 argv_idx = -1; // skip to next argument |
2248 } | 2247 } |
2249 else | 2248 else |
2250 #endif | 2249 #endif |
2251 parmp->no_swap_file = TRUE; | 2250 parmp->no_swap_file = TRUE; |
2252 break; | 2251 break; |
2253 | 2252 |
2254 case 'p': /* "-p[N]" open N tab pages */ | 2253 case 'p': // "-p[N]" open N tab pages |
2255 #ifdef TARGET_API_MAC_OSX | 2254 #ifdef TARGET_API_MAC_OSX |
2256 /* For some reason on MacOS X, an argument like: | 2255 // For some reason on MacOS X, an argument like: |
2257 -psn_0_10223617 is passed in when invoke from Finder | 2256 // -psn_0_10223617 is passed in when invoke from Finder |
2258 or with the 'open' command */ | 2257 // or with the 'open' command |
2259 if (argv[0][argv_idx] == 's') | 2258 if (argv[0][argv_idx] == 's') |
2260 { | 2259 { |
2261 argv_idx = -1; /* bypass full -psn */ | 2260 argv_idx = -1; // bypass full -psn |
2262 main_start_gui(); | 2261 main_start_gui(); |
2263 break; | 2262 break; |
2264 } | 2263 } |
2265 #endif | 2264 #endif |
2266 /* default is 0: open window for each file */ | 2265 // default is 0: open window for each file |
2267 parmp->window_count = get_number_arg((char_u *)argv[0], | 2266 parmp->window_count = get_number_arg((char_u *)argv[0], |
2268 &argv_idx, 0); | 2267 &argv_idx, 0); |
2269 parmp->window_layout = WIN_TABS; | 2268 parmp->window_layout = WIN_TABS; |
2270 break; | 2269 break; |
2271 | 2270 |
2272 case 'o': /* "-o[N]" open N horizontal split windows */ | 2271 case 'o': // "-o[N]" open N horizontal split windows |
2273 /* default is 0: open window for each file */ | 2272 // default is 0: open window for each file |
2274 parmp->window_count = get_number_arg((char_u *)argv[0], | 2273 parmp->window_count = get_number_arg((char_u *)argv[0], |
2275 &argv_idx, 0); | 2274 &argv_idx, 0); |
2276 parmp->window_layout = WIN_HOR; | 2275 parmp->window_layout = WIN_HOR; |
2277 break; | 2276 break; |
2278 | 2277 |
2279 case 'O': /* "-O[N]" open N vertical split windows */ | 2278 case 'O': // "-O[N]" open N vertical split windows |
2280 /* default is 0: open window for each file */ | 2279 // default is 0: open window for each file |
2281 parmp->window_count = get_number_arg((char_u *)argv[0], | 2280 parmp->window_count = get_number_arg((char_u *)argv[0], |
2282 &argv_idx, 0); | 2281 &argv_idx, 0); |
2283 parmp->window_layout = WIN_VER; | 2282 parmp->window_layout = WIN_VER; |
2284 break; | 2283 break; |
2285 | 2284 |
2286 #ifdef FEAT_QUICKFIX | 2285 #ifdef FEAT_QUICKFIX |
2287 case 'q': /* "-q" QuickFix mode */ | 2286 case 'q': // "-q" QuickFix mode |
2288 if (parmp->edit_type != EDIT_NONE) | 2287 if (parmp->edit_type != EDIT_NONE) |
2289 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | 2288 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); |
2290 parmp->edit_type = EDIT_QF; | 2289 parmp->edit_type = EDIT_QF; |
2291 if (argv[0][argv_idx]) /* "-q{errorfile}" */ | 2290 if (argv[0][argv_idx]) // "-q{errorfile}" |
2292 { | 2291 { |
2293 parmp->use_ef = (char_u *)argv[0] + argv_idx; | 2292 parmp->use_ef = (char_u *)argv[0] + argv_idx; |
2294 argv_idx = -1; | 2293 argv_idx = -1; |
2295 } | 2294 } |
2296 else if (argc > 1) /* "-q {errorfile}" */ | 2295 else if (argc > 1) // "-q {errorfile}" |
2297 want_argument = TRUE; | 2296 want_argument = TRUE; |
2298 break; | 2297 break; |
2299 #endif | 2298 #endif |
2300 | 2299 |
2301 case 'R': /* "-R" readonly mode */ | 2300 case 'R': // "-R" readonly mode |
2302 readonlymode = TRUE; | 2301 readonlymode = TRUE; |
2303 curbuf->b_p_ro = TRUE; | 2302 curbuf->b_p_ro = TRUE; |
2304 p_uc = 10000; /* don't update very often */ | 2303 p_uc = 10000; // don't update very often |
2305 break; | 2304 break; |
2306 | 2305 |
2307 case 'r': /* "-r" recovery mode */ | 2306 case 'r': // "-r" recovery mode |
2308 case 'L': /* "-L" recovery mode */ | 2307 case 'L': // "-L" recovery mode |
2309 recoverymode = 1; | 2308 recoverymode = 1; |
2310 break; | 2309 break; |
2311 | 2310 |
2312 case 's': | 2311 case 's': |
2313 if (exmode_active) /* "-s" silent (batch) mode */ | 2312 if (exmode_active) // "-s" silent (batch) mode |
2314 silent_mode = TRUE; | 2313 silent_mode = TRUE; |
2315 else /* "-s {scriptin}" read from script file */ | 2314 else // "-s {scriptin}" read from script file |
2316 want_argument = TRUE; | 2315 want_argument = TRUE; |
2317 break; | 2316 break; |
2318 | 2317 |
2319 case 't': /* "-t {tag}" or "-t{tag}" jump to tag */ | 2318 case 't': // "-t {tag}" or "-t{tag}" jump to tag |
2320 if (parmp->edit_type != EDIT_NONE) | 2319 if (parmp->edit_type != EDIT_NONE) |
2321 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | 2320 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); |
2322 parmp->edit_type = EDIT_TAG; | 2321 parmp->edit_type = EDIT_TAG; |
2323 if (argv[0][argv_idx]) /* "-t{tag}" */ | 2322 if (argv[0][argv_idx]) // "-t{tag}" |
2324 { | 2323 { |
2325 parmp->tagname = (char_u *)argv[0] + argv_idx; | 2324 parmp->tagname = (char_u *)argv[0] + argv_idx; |
2326 argv_idx = -1; | 2325 argv_idx = -1; |
2327 } | 2326 } |
2328 else /* "-t {tag}" */ | 2327 else // "-t {tag}" |
2329 want_argument = TRUE; | 2328 want_argument = TRUE; |
2330 break; | 2329 break; |
2331 | 2330 |
2332 #ifdef FEAT_EVAL | 2331 #ifdef FEAT_EVAL |
2333 case 'D': /* "-D" Debugging */ | 2332 case 'D': // "-D" Debugging |
2334 parmp->use_debug_break_level = 9999; | 2333 parmp->use_debug_break_level = 9999; |
2335 break; | 2334 break; |
2336 #endif | 2335 #endif |
2337 #ifdef FEAT_DIFF | 2336 #ifdef FEAT_DIFF |
2338 case 'd': /* "-d" 'diff' */ | 2337 case 'd': // "-d" 'diff' |
2339 # ifdef AMIGA | 2338 # ifdef AMIGA |
2340 /* check for "-dev {device}" */ | 2339 // check for "-dev {device}" |
2341 if (argv[0][argv_idx] == 'e' && argv[0][argv_idx + 1] == 'v') | 2340 if (argv[0][argv_idx] == 'e' && argv[0][argv_idx + 1] == 'v') |
2342 want_argument = TRUE; | 2341 want_argument = TRUE; |
2343 else | 2342 else |
2344 # endif | 2343 # endif |
2345 parmp->diff_mode = TRUE; | 2344 parmp->diff_mode = TRUE; |
2346 break; | 2345 break; |
2347 #endif | 2346 #endif |
2348 case 'V': /* "-V{N}" Verbose level */ | 2347 case 'V': // "-V{N}" Verbose level |
2349 /* default is 10: a little bit verbose */ | 2348 // default is 10: a little bit verbose |
2350 p_verbose = get_number_arg((char_u *)argv[0], &argv_idx, 10); | 2349 p_verbose = get_number_arg((char_u *)argv[0], &argv_idx, 10); |
2351 if (argv[0][argv_idx] != NUL) | 2350 if (argv[0][argv_idx] != NUL) |
2352 { | 2351 { |
2353 set_option_value((char_u *)"verbosefile", 0L, | 2352 set_option_value((char_u *)"verbosefile", 0L, |
2354 (char_u *)argv[0] + argv_idx, 0); | 2353 (char_u *)argv[0] + argv_idx, 0); |
2355 argv_idx = (int)STRLEN(argv[0]); | 2354 argv_idx = (int)STRLEN(argv[0]); |
2356 } | 2355 } |
2357 break; | 2356 break; |
2358 | 2357 |
2359 case 'v': /* "-v" Vi-mode (as if called "vi") */ | 2358 case 'v': // "-v" Vi-mode (as if called "vi") |
2360 exmode_active = 0; | 2359 exmode_active = 0; |
2361 #if defined(FEAT_GUI) && !defined(VIMDLL) | 2360 #if defined(FEAT_GUI) && !defined(VIMDLL) |
2362 gui.starting = FALSE; /* don't start GUI */ | 2361 gui.starting = FALSE; // don't start GUI |
2363 #endif | 2362 #endif |
2364 break; | 2363 break; |
2365 | 2364 |
2366 case 'w': /* "-w{number}" set window height */ | 2365 case 'w': // "-w{number}" set window height |
2367 /* "-w {scriptout}" write to script */ | 2366 // "-w {scriptout}" write to script |
2368 if (vim_isdigit(((char_u *)argv[0])[argv_idx])) | 2367 if (vim_isdigit(((char_u *)argv[0])[argv_idx])) |
2369 { | 2368 { |
2370 n = get_number_arg((char_u *)argv[0], &argv_idx, 10); | 2369 n = get_number_arg((char_u *)argv[0], &argv_idx, 10); |
2371 set_option_value((char_u *)"window", n, NULL, 0); | 2370 set_option_value((char_u *)"window", n, NULL, 0); |
2372 break; | 2371 break; |
2373 } | 2372 } |
2374 want_argument = TRUE; | 2373 want_argument = TRUE; |
2375 break; | 2374 break; |
2376 | 2375 |
2377 #ifdef FEAT_CRYPT | 2376 #ifdef FEAT_CRYPT |
2378 case 'x': /* "-x" encrypted reading/writing of files */ | 2377 case 'x': // "-x" encrypted reading/writing of files |
2379 parmp->ask_for_key = TRUE; | 2378 parmp->ask_for_key = TRUE; |
2380 break; | 2379 break; |
2381 #endif | 2380 #endif |
2382 | 2381 |
2383 case 'X': /* "-X" don't connect to X server */ | 2382 case 'X': // "-X" don't connect to X server |
2384 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11) | 2383 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11) |
2385 x_no_connect = TRUE; | 2384 x_no_connect = TRUE; |
2386 #endif | 2385 #endif |
2387 break; | 2386 break; |
2388 | 2387 |
2389 case 'Z': /* "-Z" restricted mode */ | 2388 case 'Z': // "-Z" restricted mode |
2390 restricted = TRUE; | 2389 restricted = TRUE; |
2391 break; | 2390 break; |
2392 | 2391 |
2393 case 'c': /* "-c{command}" or "-c {command}" execute | 2392 case 'c': // "-c{command}" or "-c {command}" execute |
2394 command */ | 2393 // command |
2395 if (argv[0][argv_idx] != NUL) | 2394 if (argv[0][argv_idx] != NUL) |
2396 { | 2395 { |
2397 if (parmp->n_commands >= MAX_ARG_CMDS) | 2396 if (parmp->n_commands >= MAX_ARG_CMDS) |
2398 mainerr(ME_EXTRA_CMD, NULL); | 2397 mainerr(ME_EXTRA_CMD, NULL); |
2399 parmp->commands[parmp->n_commands++] = (char_u *)argv[0] | 2398 parmp->commands[parmp->n_commands++] = (char_u *)argv[0] |
2400 + argv_idx; | 2399 + argv_idx; |
2401 argv_idx = -1; | 2400 argv_idx = -1; |
2402 break; | 2401 break; |
2403 } | 2402 } |
2404 /* FALLTHROUGH */ | 2403 // FALLTHROUGH |
2405 case 'S': /* "-S {file}" execute Vim script */ | 2404 case 'S': // "-S {file}" execute Vim script |
2406 case 'i': /* "-i {viminfo}" use for viminfo */ | 2405 case 'i': // "-i {viminfo}" use for viminfo |
2407 #ifndef FEAT_DIFF | 2406 #ifndef FEAT_DIFF |
2408 case 'd': /* "-d {device}" device (for Amiga) */ | 2407 case 'd': // "-d {device}" device (for Amiga) |
2409 #endif | 2408 #endif |
2410 case 'T': /* "-T {terminal}" terminal name */ | 2409 case 'T': // "-T {terminal}" terminal name |
2411 case 'u': /* "-u {vimrc}" vim inits file */ | 2410 case 'u': // "-u {vimrc}" vim inits file |
2412 case 'U': /* "-U {gvimrc}" gvim inits file */ | 2411 case 'U': // "-U {gvimrc}" gvim inits file |
2413 case 'W': /* "-W {scriptout}" overwrite */ | 2412 case 'W': // "-W {scriptout}" overwrite |
2414 #ifdef FEAT_GUI_MSWIN | 2413 #ifdef FEAT_GUI_MSWIN |
2415 case 'P': /* "-P {parent title}" MDI parent */ | 2414 case 'P': // "-P {parent title}" MDI parent |
2416 #endif | 2415 #endif |
2417 want_argument = TRUE; | 2416 want_argument = TRUE; |
2418 break; | 2417 break; |
2419 | 2418 |
2420 default: | 2419 default: |
2431 */ | 2430 */ |
2432 if (argv[0][argv_idx] != NUL) | 2431 if (argv[0][argv_idx] != NUL) |
2433 mainerr(ME_GARBAGE, (char_u *)argv[0]); | 2432 mainerr(ME_GARBAGE, (char_u *)argv[0]); |
2434 | 2433 |
2435 --argc; | 2434 --argc; |
2436 if (argc < 1 && c != 'S') /* -S has an optional argument */ | 2435 if (argc < 1 && c != 'S') // -S has an optional argument |
2437 mainerr_arg_missing((char_u *)argv[0]); | 2436 mainerr_arg_missing((char_u *)argv[0]); |
2438 ++argv; | 2437 ++argv; |
2439 argv_idx = -1; | 2438 argv_idx = -1; |
2440 | 2439 |
2441 switch (c) | 2440 switch (c) |
2442 { | 2441 { |
2443 case 'c': /* "-c {command}" execute command */ | 2442 case 'c': // "-c {command}" execute command |
2444 case 'S': /* "-S {file}" execute Vim script */ | 2443 case 'S': // "-S {file}" execute Vim script |
2445 if (parmp->n_commands >= MAX_ARG_CMDS) | 2444 if (parmp->n_commands >= MAX_ARG_CMDS) |
2446 mainerr(ME_EXTRA_CMD, NULL); | 2445 mainerr(ME_EXTRA_CMD, NULL); |
2447 if (c == 'S') | 2446 if (c == 'S') |
2448 { | 2447 { |
2449 char *a; | 2448 char *a; |
2450 | 2449 |
2451 if (argc < 1) | 2450 if (argc < 1) |
2452 /* "-S" without argument: use default session file | 2451 // "-S" without argument: use default session file |
2453 * name. */ | 2452 // name. |
2454 a = SESSION_FILE; | 2453 a = SESSION_FILE; |
2455 else if (argv[0][0] == '-') | 2454 else if (argv[0][0] == '-') |
2456 { | 2455 { |
2457 /* "-S" followed by another option: use default | 2456 // "-S" followed by another option: use default |
2458 * session file name. */ | 2457 // session file name. |
2459 a = SESSION_FILE; | 2458 a = SESSION_FILE; |
2460 ++argc; | 2459 ++argc; |
2461 --argv; | 2460 --argv; |
2462 } | 2461 } |
2463 else | 2462 else |
2475 break; | 2474 break; |
2476 | 2475 |
2477 case '-': | 2476 case '-': |
2478 if (argv[-1][2] == 'c') | 2477 if (argv[-1][2] == 'c') |
2479 { | 2478 { |
2480 /* "--cmd {command}" execute command */ | 2479 // "--cmd {command}" execute command |
2481 if (parmp->n_pre_commands >= MAX_ARG_CMDS) | 2480 if (parmp->n_pre_commands >= MAX_ARG_CMDS) |
2482 mainerr(ME_EXTRA_CMD, NULL); | 2481 mainerr(ME_EXTRA_CMD, NULL); |
2483 parmp->pre_commands[parmp->n_pre_commands++] = | 2482 parmp->pre_commands[parmp->n_pre_commands++] = |
2484 (char_u *)argv[0]; | 2483 (char_u *)argv[0]; |
2485 } | 2484 } |
2486 /* "--startuptime <file>" already handled */ | 2485 // "--startuptime <file>" already handled |
2487 break; | 2486 break; |
2488 | 2487 |
2489 /* case 'd': -d {device} is handled in mch_check_win() for the | 2488 // case 'd': -d {device} is handled in mch_check_win() for the |
2490 * Amiga */ | 2489 // Amiga |
2491 | 2490 |
2492 #ifdef FEAT_QUICKFIX | 2491 #ifdef FEAT_QUICKFIX |
2493 case 'q': /* "-q {errorfile}" QuickFix mode */ | 2492 case 'q': // "-q {errorfile}" QuickFix mode |
2494 parmp->use_ef = (char_u *)argv[0]; | 2493 parmp->use_ef = (char_u *)argv[0]; |
2495 break; | 2494 break; |
2496 #endif | 2495 #endif |
2497 | 2496 |
2498 case 'i': /* "-i {viminfo}" use for viminfo */ | 2497 case 'i': // "-i {viminfo}" use for viminfo |
2499 set_option_value((char_u *)"vif", 0L, (char_u *)argv[0], 0); | 2498 set_option_value((char_u *)"vif", 0L, (char_u *)argv[0], 0); |
2500 break; | 2499 break; |
2501 | 2500 |
2502 case 's': /* "-s {scriptin}" read from script file */ | 2501 case 's': // "-s {scriptin}" read from script file |
2503 if (scriptin[0] != NULL) | 2502 if (scriptin[0] != NULL) |
2504 { | 2503 { |
2505 scripterror: | 2504 scripterror: |
2506 mch_errmsg(_("Attempt to open script file again: \"")); | 2505 mch_errmsg(_("Attempt to open script file again: \"")); |
2507 mch_errmsg(argv[-1]); | 2506 mch_errmsg(argv[-1]); |
2516 mch_errmsg(argv[0]); | 2515 mch_errmsg(argv[0]); |
2517 mch_errmsg("\"\n"); | 2516 mch_errmsg("\"\n"); |
2518 mch_exit(2); | 2517 mch_exit(2); |
2519 } | 2518 } |
2520 if (save_typebuf() == FAIL) | 2519 if (save_typebuf() == FAIL) |
2521 mch_exit(2); /* out of memory */ | 2520 mch_exit(2); // out of memory |
2522 break; | 2521 break; |
2523 | 2522 |
2524 case 't': /* "-t {tag}" */ | 2523 case 't': // "-t {tag}" |
2525 parmp->tagname = (char_u *)argv[0]; | 2524 parmp->tagname = (char_u *)argv[0]; |
2526 break; | 2525 break; |
2527 | 2526 |
2528 case 'T': /* "-T {terminal}" terminal name */ | 2527 case 'T': // "-T {terminal}" terminal name |
2529 /* | 2528 /* |
2530 * The -T term argument is always available and when | 2529 * The -T term argument is always available and when |
2531 * HAVE_TERMLIB is supported it overrides the environment | 2530 * HAVE_TERMLIB is supported it overrides the environment |
2532 * variable TERM. | 2531 * variable TERM. |
2533 */ | 2532 */ |
2534 #ifdef FEAT_GUI | 2533 #ifdef FEAT_GUI |
2535 if (term_is_gui((char_u *)argv[0])) | 2534 if (term_is_gui((char_u *)argv[0])) |
2536 gui.starting = TRUE; /* start GUI a bit later */ | 2535 gui.starting = TRUE; // start GUI a bit later |
2537 else | 2536 else |
2538 #endif | 2537 #endif |
2539 parmp->term = (char_u *)argv[0]; | 2538 parmp->term = (char_u *)argv[0]; |
2540 break; | 2539 break; |
2541 | 2540 |
2542 case 'u': /* "-u {vimrc}" vim inits file */ | 2541 case 'u': // "-u {vimrc}" vim inits file |
2543 parmp->use_vimrc = (char_u *)argv[0]; | 2542 parmp->use_vimrc = (char_u *)argv[0]; |
2544 break; | 2543 break; |
2545 | 2544 |
2546 case 'U': /* "-U {gvimrc}" gvim inits file */ | 2545 case 'U': // "-U {gvimrc}" gvim inits file |
2547 #ifdef FEAT_GUI | 2546 #ifdef FEAT_GUI |
2548 use_gvimrc = (char_u *)argv[0]; | 2547 use_gvimrc = (char_u *)argv[0]; |
2549 #endif | 2548 #endif |
2550 break; | 2549 break; |
2551 | 2550 |
2552 case 'w': /* "-w {nr}" 'window' value */ | 2551 case 'w': // "-w {nr}" 'window' value |
2553 /* "-w {scriptout}" append to script file */ | 2552 // "-w {scriptout}" append to script file |
2554 if (vim_isdigit(*((char_u *)argv[0]))) | 2553 if (vim_isdigit(*((char_u *)argv[0]))) |
2555 { | 2554 { |
2556 argv_idx = 0; | 2555 argv_idx = 0; |
2557 n = get_number_arg((char_u *)argv[0], &argv_idx, 10); | 2556 n = get_number_arg((char_u *)argv[0], &argv_idx, 10); |
2558 set_option_value((char_u *)"window", n, NULL, 0); | 2557 set_option_value((char_u *)"window", n, NULL, 0); |
2559 argv_idx = -1; | 2558 argv_idx = -1; |
2560 break; | 2559 break; |
2561 } | 2560 } |
2562 /* FALLTHROUGH */ | 2561 // FALLTHROUGH |
2563 case 'W': /* "-W {scriptout}" overwrite script file */ | 2562 case 'W': // "-W {scriptout}" overwrite script file |
2564 if (scriptout != NULL) | 2563 if (scriptout != NULL) |
2565 goto scripterror; | 2564 goto scripterror; |
2566 if ((scriptout = mch_fopen(argv[0], | 2565 if ((scriptout = mch_fopen(argv[0], |
2567 c == 'w' ? APPENDBIN : WRITEBIN)) == NULL) | 2566 c == 'w' ? APPENDBIN : WRITEBIN)) == NULL) |
2568 { | 2567 { |
2572 mch_exit(2); | 2571 mch_exit(2); |
2573 } | 2572 } |
2574 break; | 2573 break; |
2575 | 2574 |
2576 #ifdef FEAT_GUI_MSWIN | 2575 #ifdef FEAT_GUI_MSWIN |
2577 case 'P': /* "-P {parent title}" MDI parent */ | 2576 case 'P': // "-P {parent title}" MDI parent |
2578 gui_mch_set_parent(argv[0]); | 2577 gui_mch_set_parent(argv[0]); |
2579 break; | 2578 break; |
2580 #endif | 2579 #endif |
2581 } | 2580 } |
2582 } | 2581 } |
2585 /* | 2584 /* |
2586 * File name argument. | 2585 * File name argument. |
2587 */ | 2586 */ |
2588 else | 2587 else |
2589 { | 2588 { |
2590 argv_idx = -1; /* skip to next argument */ | 2589 argv_idx = -1; // skip to next argument |
2591 | 2590 |
2592 /* Check for only one type of editing. */ | 2591 // Check for only one type of editing. |
2593 if (parmp->edit_type != EDIT_NONE && parmp->edit_type != EDIT_FILE) | 2592 if (parmp->edit_type != EDIT_NONE && parmp->edit_type != EDIT_FILE) |
2594 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); | 2593 mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]); |
2595 parmp->edit_type = EDIT_FILE; | 2594 parmp->edit_type = EDIT_FILE; |
2596 | 2595 |
2597 #ifdef MSWIN | 2596 #ifdef MSWIN |
2598 /* Remember if the argument was a full path before changing | 2597 // Remember if the argument was a full path before changing |
2599 * slashes to backslashes. */ | 2598 // slashes to backslashes. |
2600 if (argv[0][0] != NUL && argv[0][1] == ':' && argv[0][2] == '\\') | 2599 if (argv[0][0] != NUL && argv[0][1] == ':' && argv[0][2] == '\\') |
2601 parmp->full_path = TRUE; | 2600 parmp->full_path = TRUE; |
2602 #endif | 2601 #endif |
2603 | 2602 |
2604 /* Add the file to the global argument list. */ | 2603 // Add the file to the global argument list. |
2605 if (ga_grow(&global_alist.al_ga, 1) == FAIL | 2604 if (ga_grow(&global_alist.al_ga, 1) == FAIL |
2606 || (p = vim_strsave((char_u *)argv[0])) == NULL) | 2605 || (p = vim_strsave((char_u *)argv[0])) == NULL) |
2607 mch_exit(2); | 2606 mch_exit(2); |
2608 #ifdef FEAT_DIFF | 2607 #ifdef FEAT_DIFF |
2609 if (parmp->diff_mode && mch_isdir(p) && GARGCOUNT > 0 | 2608 if (parmp->diff_mode && mch_isdir(p) && GARGCOUNT > 0 |
2641 mch_exit(2); | 2640 mch_exit(2); |
2642 } | 2641 } |
2643 #endif | 2642 #endif |
2644 | 2643 |
2645 #ifdef USE_FNAME_CASE | 2644 #ifdef USE_FNAME_CASE |
2646 /* Make the case of the file name match the actual file. */ | 2645 // Make the case of the file name match the actual file. |
2647 fname_case(p, 0); | 2646 fname_case(p, 0); |
2648 #endif | 2647 #endif |
2649 | 2648 |
2650 alist_add(&global_alist, p, | 2649 alist_add(&global_alist, p, |
2651 #ifdef EXPAND_FILENAMES | 2650 #ifdef EXPAND_FILENAMES |
2652 parmp->literal ? 2 : 0 /* add buffer nr after exp. */ | 2651 parmp->literal ? 2 : 0 // add buffer nr after exp. |
2653 #else | 2652 #else |
2654 2 /* add buffer number now and use curbuf */ | 2653 2 // add buffer number now and use curbuf |
2655 #endif | 2654 #endif |
2656 ); | 2655 ); |
2657 | 2656 |
2658 #ifdef MSWIN | 2657 #ifdef MSWIN |
2659 { | 2658 { |
2660 /* Remember this argument has been added to the argument list. | 2659 // Remember this argument has been added to the argument list. |
2661 * Needed when 'encoding' is changed. */ | 2660 // Needed when 'encoding' is changed. |
2662 used_file_arg(argv[0], parmp->literal, parmp->full_path, | 2661 used_file_arg(argv[0], parmp->literal, parmp->full_path, |
2663 # ifdef FEAT_DIFF | 2662 # ifdef FEAT_DIFF |
2664 parmp->diff_mode | 2663 parmp->diff_mode |
2665 # else | 2664 # else |
2666 FALSE | 2665 FALSE |
2682 argv_idx = 1; | 2681 argv_idx = 1; |
2683 } | 2682 } |
2684 } | 2683 } |
2685 | 2684 |
2686 #ifdef FEAT_EVAL | 2685 #ifdef FEAT_EVAL |
2687 /* If there is a "+123" or "-c" command, set v:swapcommand to the first | 2686 // If there is a "+123" or "-c" command, set v:swapcommand to the first |
2688 * one. */ | 2687 // one. |
2689 if (parmp->n_commands > 0) | 2688 if (parmp->n_commands > 0) |
2690 { | 2689 { |
2691 p = alloc(STRLEN(parmp->commands[0]) + 3); | 2690 p = alloc(STRLEN(parmp->commands[0]) + 3); |
2692 if (p != NULL) | 2691 if (p != NULL) |
2693 { | 2692 { |
2704 * When starting in Ex mode and commands come from a file, set silent_mode. | 2703 * When starting in Ex mode and commands come from a file, set silent_mode. |
2705 */ | 2704 */ |
2706 static void | 2705 static void |
2707 check_tty(mparm_T *parmp) | 2706 check_tty(mparm_T *parmp) |
2708 { | 2707 { |
2709 int input_isatty; /* is active input a terminal? */ | 2708 int input_isatty; // is active input a terminal? |
2710 | 2709 |
2711 input_isatty = mch_input_isatty(); | 2710 input_isatty = mch_input_isatty(); |
2712 if (exmode_active) | 2711 if (exmode_active) |
2713 { | 2712 { |
2714 if (!input_isatty) | 2713 if (!input_isatty) |
2715 silent_mode = TRUE; | 2714 silent_mode = TRUE; |
2716 } | 2715 } |
2717 else if (parmp->want_full_screen && (!stdout_isatty || !input_isatty) | 2716 else if (parmp->want_full_screen && (!stdout_isatty || !input_isatty) |
2718 #ifdef FEAT_GUI | 2717 #ifdef FEAT_GUI |
2719 /* don't want the delay when started from the desktop */ | 2718 // don't want the delay when started from the desktop |
2720 && !gui.starting | 2719 && !gui.starting |
2721 #endif | 2720 #endif |
2722 && !parmp->not_a_term) | 2721 && !parmp->not_a_term) |
2723 { | 2722 { |
2724 #ifdef NBDEBUG | 2723 #ifdef NBDEBUG |
2744 { | 2743 { |
2745 # if defined(HAVE_BIND_TEXTDOMAIN_CODESET) \ | 2744 # if defined(HAVE_BIND_TEXTDOMAIN_CODESET) \ |
2746 && defined(FEAT_GETTEXT) | 2745 && defined(FEAT_GETTEXT) |
2747 char *s, *tofree = NULL; | 2746 char *s, *tofree = NULL; |
2748 | 2747 |
2749 /* Set the encoding of the error message based on $LC_ALL or | 2748 // Set the encoding of the error message based on $LC_ALL or |
2750 * other environment variables instead of 'encoding'. | 2749 // other environment variables instead of 'encoding'. |
2751 * Note that the message is shown on a Cygwin terminal (e.g. | 2750 // Note that the message is shown on a Cygwin terminal (e.g. |
2752 * mintty) which encoding is based on $LC_ALL or etc., not the | 2751 // mintty) which encoding is based on $LC_ALL or etc., not the |
2753 * current codepage used by normal Win32 console programs. */ | 2752 // current codepage used by normal Win32 console programs. |
2754 tofree = s = (char *)enc_locale_env(NULL); | 2753 tofree = s = (char *)enc_locale_env(NULL); |
2755 if (s == NULL) | 2754 if (s == NULL) |
2756 s = "utf-8"; /* Use "utf-8" by default. */ | 2755 s = "utf-8"; // Use "utf-8" by default. |
2757 (void)bind_textdomain_codeset(VIMPACKAGE, s); | 2756 (void)bind_textdomain_codeset(VIMPACKAGE, s); |
2758 vim_free(tofree); | 2757 vim_free(tofree); |
2759 # endif | 2758 # endif |
2760 mch_errmsg(_("Vim: Error: This version of Vim does not run in a Cygwin terminal\n")); | 2759 mch_errmsg(_("Vim: Error: This version of Vim does not run in a Cygwin terminal\n")); |
2761 exit(1); | 2760 exit(1); |
2816 int done = 0; | 2815 int done = 0; |
2817 | 2816 |
2818 /* | 2817 /* |
2819 * Create the number of windows that was requested. | 2818 * Create the number of windows that was requested. |
2820 */ | 2819 */ |
2821 if (parmp->window_count == -1) /* was not set */ | 2820 if (parmp->window_count == -1) // was not set |
2822 parmp->window_count = 1; | 2821 parmp->window_count = 1; |
2823 if (parmp->window_count == 0) | 2822 if (parmp->window_count == 0) |
2824 parmp->window_count = GARGCOUNT; | 2823 parmp->window_count = GARGCOUNT; |
2825 if (parmp->window_count > 1) | 2824 if (parmp->window_count > 1) |
2826 { | 2825 { |
2827 /* Don't change the windows if there was a command in .vimrc that | 2826 // Don't change the windows if there was a command in .vimrc that |
2828 * already split some windows */ | 2827 // already split some windows |
2829 if (parmp->window_layout == 0) | 2828 if (parmp->window_layout == 0) |
2830 parmp->window_layout = WIN_HOR; | 2829 parmp->window_layout = WIN_HOR; |
2831 if (parmp->window_layout == WIN_TABS) | 2830 if (parmp->window_layout == WIN_TABS) |
2832 { | 2831 { |
2833 parmp->window_count = make_tabpages(parmp->window_count); | 2832 parmp->window_count = make_tabpages(parmp->window_count); |
2843 parmp->window_count = win_count(); | 2842 parmp->window_count = win_count(); |
2844 } | 2843 } |
2845 else | 2844 else |
2846 parmp->window_count = 1; | 2845 parmp->window_count = 1; |
2847 | 2846 |
2848 if (recoverymode) /* do recover */ | 2847 if (recoverymode) // do recover |
2849 { | 2848 { |
2850 msg_scroll = TRUE; /* scroll message up */ | 2849 msg_scroll = TRUE; // scroll message up |
2851 ml_recover(TRUE); | 2850 ml_recover(TRUE); |
2852 if (curbuf->b_ml.ml_mfp == NULL) /* failed */ | 2851 if (curbuf->b_ml.ml_mfp == NULL) // failed |
2853 getout(1); | 2852 getout(1); |
2854 do_modelines(0); /* do modelines */ | 2853 do_modelines(0); // do modelines |
2855 } | 2854 } |
2856 else | 2855 else |
2857 { | 2856 { |
2858 /* | 2857 /* |
2859 * Open a buffer for windows that don't have one yet. | 2858 * Open a buffer for windows that don't have one yet. |
2890 dorewind = FALSE; | 2889 dorewind = FALSE; |
2891 curbuf = curwin->w_buffer; | 2890 curbuf = curwin->w_buffer; |
2892 if (curbuf->b_ml.ml_mfp == NULL) | 2891 if (curbuf->b_ml.ml_mfp == NULL) |
2893 { | 2892 { |
2894 #ifdef FEAT_FOLDING | 2893 #ifdef FEAT_FOLDING |
2895 /* Set 'foldlevel' to 'foldlevelstart' if it's not negative. */ | 2894 // Set 'foldlevel' to 'foldlevelstart' if it's not negative. |
2896 if (p_fdls >= 0) | 2895 if (p_fdls >= 0) |
2897 curwin->w_p_fdl = p_fdls; | 2896 curwin->w_p_fdl = p_fdls; |
2898 #endif | 2897 #endif |
2899 // When getting the ATTENTION prompt here, use a dialog | 2898 // When getting the ATTENTION prompt here, use a dialog |
2900 swap_exists_action = SEA_DIALOG; | 2899 swap_exists_action = SEA_DIALOG; |
2901 | 2900 |
2902 set_buflisted(TRUE); | 2901 set_buflisted(TRUE); |
2903 | 2902 |
2904 /* create memfile, read file */ | 2903 // create memfile, read file |
2905 (void)open_buffer(FALSE, NULL, 0); | 2904 (void)open_buffer(FALSE, NULL, 0); |
2906 | 2905 |
2907 if (swap_exists_action == SEA_QUIT) | 2906 if (swap_exists_action == SEA_QUIT) |
2908 { | 2907 { |
2909 if (got_int || only_one_window()) | 2908 if (got_int || only_one_window()) |
2910 { | 2909 { |
2911 /* abort selected or quit and only one window */ | 2910 // abort selected or quit and only one window |
2912 did_emsg = FALSE; /* avoid hit-enter prompt */ | 2911 did_emsg = FALSE; // avoid hit-enter prompt |
2913 getout(1); | 2912 getout(1); |
2914 } | 2913 } |
2915 /* We can't close the window, it would disturb what | 2914 // We can't close the window, it would disturb what |
2916 * happens next. Clear the file name and set the arg | 2915 // happens next. Clear the file name and set the arg |
2917 * index to -1 to delete it later. */ | 2916 // index to -1 to delete it later. |
2918 setfname(curbuf, NULL, NULL, FALSE); | 2917 setfname(curbuf, NULL, NULL, FALSE); |
2919 curwin->w_arg_idx = -1; | 2918 curwin->w_arg_idx = -1; |
2920 swap_exists_action = SEA_NONE; | 2919 swap_exists_action = SEA_NONE; |
2921 } | 2920 } |
2922 else | 2921 else |
2923 handle_swap_exists(NULL); | 2922 handle_swap_exists(NULL); |
2924 dorewind = TRUE; /* start again */ | 2923 dorewind = TRUE; // start again |
2925 } | 2924 } |
2926 ui_breakcheck(); | 2925 ui_breakcheck(); |
2927 if (got_int) | 2926 if (got_int) |
2928 { | 2927 { |
2929 (void)vgetc(); /* only break the file loading, not the rest */ | 2928 (void)vgetc(); // only break the file loading, not the rest |
2930 break; | 2929 break; |
2931 } | 2930 } |
2932 } | 2931 } |
2933 if (parmp->window_layout == WIN_TABS) | 2932 if (parmp->window_layout == WIN_TABS) |
2934 goto_tabpage(1); | 2933 goto_tabpage(1); |
2945 * windows. make_windows() has already opened the windows. | 2944 * windows. make_windows() has already opened the windows. |
2946 */ | 2945 */ |
2947 static void | 2946 static void |
2948 edit_buffers( | 2947 edit_buffers( |
2949 mparm_T *parmp, | 2948 mparm_T *parmp, |
2950 char_u *cwd) /* current working dir */ | 2949 char_u *cwd) // current working dir |
2951 { | 2950 { |
2952 int arg_idx; /* index in argument list */ | 2951 int arg_idx; // index in argument list |
2953 int i; | 2952 int i; |
2954 int advance = TRUE; | 2953 int advance = TRUE; |
2955 win_T *win; | 2954 win_T *win; |
2956 char_u *p_shm_save = NULL; | 2955 char_u *p_shm_save = NULL; |
2957 | 2956 |
2959 * Don't execute Win/Buf Enter/Leave autocommands here | 2958 * Don't execute Win/Buf Enter/Leave autocommands here |
2960 */ | 2959 */ |
2961 ++autocmd_no_enter; | 2960 ++autocmd_no_enter; |
2962 ++autocmd_no_leave; | 2961 ++autocmd_no_leave; |
2963 | 2962 |
2964 /* When w_arg_idx is -1 remove the window (see create_windows()). */ | 2963 // When w_arg_idx is -1 remove the window (see create_windows()). |
2965 if (curwin->w_arg_idx == -1) | 2964 if (curwin->w_arg_idx == -1) |
2966 { | 2965 { |
2967 win_close(curwin, TRUE); | 2966 win_close(curwin, TRUE); |
2968 advance = FALSE; | 2967 advance = FALSE; |
2969 } | 2968 } |
2971 arg_idx = 1; | 2970 arg_idx = 1; |
2972 for (i = 1; i < parmp->window_count; ++i) | 2971 for (i = 1; i < parmp->window_count; ++i) |
2973 { | 2972 { |
2974 if (cwd != NULL) | 2973 if (cwd != NULL) |
2975 mch_chdir((char *)cwd); | 2974 mch_chdir((char *)cwd); |
2976 /* When w_arg_idx is -1 remove the window (see create_windows()). */ | 2975 // When w_arg_idx is -1 remove the window (see create_windows()). |
2977 if (curwin->w_arg_idx == -1) | 2976 if (curwin->w_arg_idx == -1) |
2978 { | 2977 { |
2979 ++arg_idx; | 2978 ++arg_idx; |
2980 win_close(curwin, TRUE); | 2979 win_close(curwin, TRUE); |
2981 advance = FALSE; | 2980 advance = FALSE; |
2984 | 2983 |
2985 if (advance) | 2984 if (advance) |
2986 { | 2985 { |
2987 if (parmp->window_layout == WIN_TABS) | 2986 if (parmp->window_layout == WIN_TABS) |
2988 { | 2987 { |
2989 if (curtab->tp_next == NULL) /* just checking */ | 2988 if (curtab->tp_next == NULL) // just checking |
2990 break; | 2989 break; |
2991 goto_tabpage(0); | 2990 goto_tabpage(0); |
2992 // Temporarily reset 'shm' option to not print fileinfo when | 2991 // Temporarily reset 'shm' option to not print fileinfo when |
2993 // loading the other buffers. This would overwrite the already | 2992 // loading the other buffers. This would overwrite the already |
2994 // existing fileinfo for the first tab. | 2993 // existing fileinfo for the first tab. |
3001 set_option_value((char_u *)"shm", 0L, (char_u *)buf, 0); | 3000 set_option_value((char_u *)"shm", 0L, (char_u *)buf, 0); |
3002 } | 3001 } |
3003 } | 3002 } |
3004 else | 3003 else |
3005 { | 3004 { |
3006 if (curwin->w_next == NULL) /* just checking */ | 3005 if (curwin->w_next == NULL) // just checking |
3007 break; | 3006 break; |
3008 win_enter(curwin->w_next, FALSE); | 3007 win_enter(curwin->w_next, FALSE); |
3009 } | 3008 } |
3010 } | 3009 } |
3011 advance = TRUE; | 3010 advance = TRUE; |
3012 | 3011 |
3013 /* Only open the file if there is no file in this window yet (that can | 3012 // Only open the file if there is no file in this window yet (that can |
3014 * happen when .vimrc contains ":sall"). */ | 3013 // happen when .vimrc contains ":sall"). |
3015 if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL) | 3014 if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL) |
3016 { | 3015 { |
3017 curwin->w_arg_idx = arg_idx; | 3016 curwin->w_arg_idx = arg_idx; |
3018 /* Edit file from arg list, if there is one. When "Quit" selected | 3017 // Edit file from arg list, if there is one. When "Quit" selected |
3019 * at the ATTENTION prompt close the window. */ | 3018 // at the ATTENTION prompt close the window. |
3020 swap_exists_did_quit = FALSE; | 3019 swap_exists_did_quit = FALSE; |
3021 (void)do_ecmd(0, arg_idx < GARGCOUNT | 3020 (void)do_ecmd(0, arg_idx < GARGCOUNT |
3022 ? alist_name(&GARGLIST[arg_idx]) : NULL, | 3021 ? alist_name(&GARGLIST[arg_idx]) : NULL, |
3023 NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin); | 3022 NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin); |
3024 if (swap_exists_did_quit) | 3023 if (swap_exists_did_quit) |
3025 { | 3024 { |
3026 /* abort or quit selected */ | 3025 // abort or quit selected |
3027 if (got_int || only_one_window()) | 3026 if (got_int || only_one_window()) |
3028 { | 3027 { |
3029 /* abort selected and only one window */ | 3028 // abort selected and only one window |
3030 did_emsg = FALSE; /* avoid hit-enter prompt */ | 3029 did_emsg = FALSE; // avoid hit-enter prompt |
3031 getout(1); | 3030 getout(1); |
3032 } | 3031 } |
3033 win_close(curwin, TRUE); | 3032 win_close(curwin, TRUE); |
3034 advance = FALSE; | 3033 advance = FALSE; |
3035 } | 3034 } |
3038 ++arg_idx; | 3037 ++arg_idx; |
3039 } | 3038 } |
3040 ui_breakcheck(); | 3039 ui_breakcheck(); |
3041 if (got_int) | 3040 if (got_int) |
3042 { | 3041 { |
3043 (void)vgetc(); /* only break the file loading, not the rest */ | 3042 (void)vgetc(); // only break the file loading, not the rest |
3044 break; | 3043 break; |
3045 } | 3044 } |
3046 } | 3045 } |
3047 | 3046 |
3048 if (p_shm_save != NULL) | 3047 if (p_shm_save != NULL) |
3053 | 3052 |
3054 if (parmp->window_layout == WIN_TABS) | 3053 if (parmp->window_layout == WIN_TABS) |
3055 goto_tabpage(1); | 3054 goto_tabpage(1); |
3056 --autocmd_no_enter; | 3055 --autocmd_no_enter; |
3057 | 3056 |
3058 /* make the first window the current window */ | 3057 // make the first window the current window |
3059 win = firstwin; | 3058 win = firstwin; |
3060 #if defined(FEAT_QUICKFIX) | 3059 #if defined(FEAT_QUICKFIX) |
3061 /* Avoid making a preview window the current window. */ | 3060 // Avoid making a preview window the current window. |
3062 while (win->w_p_pvw) | 3061 while (win->w_p_pvw) |
3063 { | 3062 { |
3064 win = win->w_next; | 3063 win = win->w_next; |
3065 if (win == NULL) | 3064 if (win == NULL) |
3066 { | 3065 { |
3072 win_enter(win, FALSE); | 3071 win_enter(win, FALSE); |
3073 | 3072 |
3074 --autocmd_no_leave; | 3073 --autocmd_no_leave; |
3075 TIME_MSG("editing files in windows"); | 3074 TIME_MSG("editing files in windows"); |
3076 if (parmp->window_count > 1 && parmp->window_layout != WIN_TABS) | 3075 if (parmp->window_count > 1 && parmp->window_layout != WIN_TABS) |
3077 win_equal(curwin, FALSE, 'b'); /* adjust heights */ | 3076 win_equal(curwin, FALSE, 'b'); // adjust heights |
3078 } | 3077 } |
3079 | 3078 |
3080 /* | 3079 /* |
3081 * Execute the commands from --cmd arguments "cmds[cnt]". | 3080 * Execute the commands from --cmd arguments "cmds[cnt]". |
3082 */ | 3081 */ |
3087 int cnt = parmp->n_pre_commands; | 3086 int cnt = parmp->n_pre_commands; |
3088 int i; | 3087 int i; |
3089 | 3088 |
3090 if (cnt > 0) | 3089 if (cnt > 0) |
3091 { | 3090 { |
3092 curwin->w_cursor.lnum = 0; /* just in case.. */ | 3091 curwin->w_cursor.lnum = 0; // just in case.. |
3093 sourcing_name = (char_u *)_("pre-vimrc command line"); | 3092 sourcing_name = (char_u *)_("pre-vimrc command line"); |
3094 # ifdef FEAT_EVAL | 3093 # ifdef FEAT_EVAL |
3095 current_sctx.sc_sid = SID_CMDARG; | 3094 current_sctx.sc_sid = SID_CMDARG; |
3096 # endif | 3095 # endif |
3097 for (i = 0; i < cnt; ++i) | 3096 for (i = 0; i < cnt; ++i) |
3140 | 3139 |
3141 if (!exmode_active) | 3140 if (!exmode_active) |
3142 msg_scroll = FALSE; | 3141 msg_scroll = FALSE; |
3143 | 3142 |
3144 #ifdef FEAT_QUICKFIX | 3143 #ifdef FEAT_QUICKFIX |
3145 /* When started with "-q errorfile" jump to first error again. */ | 3144 // When started with "-q errorfile" jump to first error again. |
3146 if (parmp->edit_type == EDIT_QF) | 3145 if (parmp->edit_type == EDIT_QF) |
3147 qf_jump(NULL, 0, 0, FALSE); | 3146 qf_jump(NULL, 0, 0, FALSE); |
3148 #endif | 3147 #endif |
3149 TIME_MSG("executing command arguments"); | 3148 TIME_MSG("executing command arguments"); |
3150 } | 3149 } |
3177 do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE); | 3176 do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE); |
3178 else if (STRCMP(parmp->use_vimrc, "NONE") == 0 | 3177 else if (STRCMP(parmp->use_vimrc, "NONE") == 0 |
3179 || STRCMP(parmp->use_vimrc, "NORC") == 0) | 3178 || STRCMP(parmp->use_vimrc, "NORC") == 0) |
3180 { | 3179 { |
3181 #ifdef FEAT_GUI | 3180 #ifdef FEAT_GUI |
3182 if (use_gvimrc == NULL) /* don't load gvimrc either */ | 3181 if (use_gvimrc == NULL) // don't load gvimrc either |
3183 use_gvimrc = parmp->use_vimrc; | 3182 use_gvimrc = parmp->use_vimrc; |
3184 #endif | 3183 #endif |
3185 } | 3184 } |
3186 else | 3185 else |
3187 { | 3186 { |
3193 { | 3192 { |
3194 #ifdef AMIGA | 3193 #ifdef AMIGA |
3195 struct Process *proc = (struct Process *)FindTask(0L); | 3194 struct Process *proc = (struct Process *)FindTask(0L); |
3196 APTR save_winptr = proc->pr_WindowPtr; | 3195 APTR save_winptr = proc->pr_WindowPtr; |
3197 | 3196 |
3198 /* Avoid a requester here for a volume that doesn't exist. */ | 3197 // Avoid a requester here for a volume that doesn't exist. |
3199 proc->pr_WindowPtr = (APTR)-1L; | 3198 proc->pr_WindowPtr = (APTR)-1L; |
3200 #endif | 3199 #endif |
3201 | 3200 |
3202 /* | 3201 /* |
3203 * Get system wide defaults, if the file name is defined. | 3202 * Get system wide defaults, if the file name is defined. |
3239 #ifdef USR_EXRC_FILE2 | 3238 #ifdef USR_EXRC_FILE2 |
3240 && do_source((char_u *)USR_EXRC_FILE2, FALSE, DOSO_NONE) == FAIL | 3239 && do_source((char_u *)USR_EXRC_FILE2, FALSE, DOSO_NONE) == FAIL |
3241 #endif | 3240 #endif |
3242 && !has_dash_c_arg) | 3241 && !has_dash_c_arg) |
3243 { | 3242 { |
3244 /* When no .vimrc file was found: source defaults.vim. */ | 3243 // When no .vimrc file was found: source defaults.vim. |
3245 do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE); | 3244 do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE); |
3246 } | 3245 } |
3247 } | 3246 } |
3248 | 3247 |
3249 /* | 3248 /* |
3256 * SYS_VIMRC_FILE. | 3255 * SYS_VIMRC_FILE. |
3257 */ | 3256 */ |
3258 if (p_exrc) | 3257 if (p_exrc) |
3259 { | 3258 { |
3260 #if defined(UNIX) || defined(VMS) | 3259 #if defined(UNIX) || defined(VMS) |
3261 /* If ".vimrc" file is not owned by user, set 'secure' mode. */ | 3260 // If ".vimrc" file is not owned by user, set 'secure' mode. |
3262 if (!file_owned(VIMRC_FILE)) | 3261 if (!file_owned(VIMRC_FILE)) |
3263 #endif | 3262 #endif |
3264 secure = p_secure; | 3263 secure = p_secure; |
3265 | 3264 |
3266 i = FAIL; | 3265 i = FAIL; |
3282 i = do_source((char_u *)VIMRC_FILE, TRUE, DOSO_VIMRC); | 3281 i = do_source((char_u *)VIMRC_FILE, TRUE, DOSO_VIMRC); |
3283 | 3282 |
3284 if (i == FAIL) | 3283 if (i == FAIL) |
3285 { | 3284 { |
3286 #if defined(UNIX) || defined(VMS) | 3285 #if defined(UNIX) || defined(VMS) |
3287 /* if ".exrc" is not owned by user set 'secure' mode */ | 3286 // if ".exrc" is not owned by user set 'secure' mode |
3288 if (!file_owned(EXRC_FILE)) | 3287 if (!file_owned(EXRC_FILE)) |
3289 secure = p_secure; | 3288 secure = p_secure; |
3290 else | 3289 else |
3291 secure = 0; | 3290 secure = 0; |
3292 #endif | 3291 #endif |
3315 */ | 3314 */ |
3316 static void | 3315 static void |
3317 main_start_gui(void) | 3316 main_start_gui(void) |
3318 { | 3317 { |
3319 #ifdef FEAT_GUI | 3318 #ifdef FEAT_GUI |
3320 gui.starting = TRUE; /* start GUI a bit later */ | 3319 gui.starting = TRUE; // start GUI a bit later |
3321 #else | 3320 #else |
3322 mch_errmsg(_(e_nogvim)); | 3321 mch_errmsg(_(e_nogvim)); |
3323 mch_errmsg("\n"); | 3322 mch_errmsg("\n"); |
3324 mch_exit(2); | 3323 mch_exit(2); |
3325 #endif | 3324 #endif |
3326 } | 3325 } |
3327 | 3326 |
3328 #endif /* NO_VIM_MAIN */ | 3327 #endif // NO_VIM_MAIN |
3329 | 3328 |
3330 /* | 3329 /* |
3331 * Get an environment variable, and execute it as Ex commands. | 3330 * Get an environment variable, and execute it as Ex commands. |
3332 * Returns FAIL if the environment variable was not executed, OK otherwise. | 3331 * Returns FAIL if the environment variable was not executed, OK otherwise. |
3333 */ | 3332 */ |
3334 int | 3333 int |
3335 process_env( | 3334 process_env( |
3336 char_u *env, | 3335 char_u *env, |
3337 int is_viminit) /* when TRUE, called for VIMINIT */ | 3336 int is_viminit) // when TRUE, called for VIMINIT |
3338 { | 3337 { |
3339 char_u *initstr; | 3338 char_u *initstr; |
3340 char_u *save_sourcing_name; | 3339 char_u *save_sourcing_name; |
3341 linenr_T save_sourcing_lnum; | 3340 linenr_T save_sourcing_lnum; |
3342 #ifdef FEAT_EVAL | 3341 #ifdef FEAT_EVAL |
3379 file_owned(char *fname) | 3378 file_owned(char *fname) |
3380 { | 3379 { |
3381 stat_T s; | 3380 stat_T s; |
3382 # ifdef UNIX | 3381 # ifdef UNIX |
3383 uid_t uid = getuid(); | 3382 uid_t uid = getuid(); |
3384 # else /* VMS */ | 3383 # else // VMS |
3385 uid_t uid = ((getgid() << 16) | getuid()); | 3384 uid_t uid = ((getgid() << 16) | getuid()); |
3386 # endif | 3385 # endif |
3387 | 3386 |
3388 return !(mch_stat(fname, &s) != 0 || s.st_uid != uid | 3387 return !(mch_stat(fname, &s) != 0 || s.st_uid != uid |
3389 # ifdef HAVE_LSTAT | 3388 # ifdef HAVE_LSTAT |
3396 /* | 3395 /* |
3397 * Give an error message main_errors["n"] and exit. | 3396 * Give an error message main_errors["n"] and exit. |
3398 */ | 3397 */ |
3399 static void | 3398 static void |
3400 mainerr( | 3399 mainerr( |
3401 int n, /* one of the ME_ defines */ | 3400 int n, // one of the ME_ defines |
3402 char_u *str) /* extra argument or NULL */ | 3401 char_u *str) // extra argument or NULL |
3403 { | 3402 { |
3404 #if defined(UNIX) || defined(VMS) | 3403 #if defined(UNIX) || defined(VMS) |
3405 reset_signals(); /* kill us with CTRL-C here, if you like */ | 3404 reset_signals(); // kill us with CTRL-C here, if you like |
3406 #endif | 3405 #endif |
3407 | 3406 |
3408 // If this is a Windows GUI executable, show an error dialog box. | 3407 // If this is a Windows GUI executable, show an error dialog box. |
3409 #ifdef VIMDLL | 3408 #ifdef VIMDLL |
3410 gui.in_use = mch_is_gui_executable(); | 3409 gui.in_use = mch_is_gui_executable(); |
3462 N_("-q [errorfile] edit file with first error") | 3461 N_("-q [errorfile] edit file with first error") |
3463 #endif | 3462 #endif |
3464 }; | 3463 }; |
3465 | 3464 |
3466 #if defined(UNIX) || defined(VMS) | 3465 #if defined(UNIX) || defined(VMS) |
3467 reset_signals(); /* kill us with CTRL-C here, if you like */ | 3466 reset_signals(); // kill us with CTRL-C here, if you like |
3468 #endif | 3467 #endif |
3469 | 3468 |
3470 init_longVersion(); | 3469 init_longVersion(); |
3471 mch_msg(longVersion); | 3470 mch_msg(longVersion); |
3472 mch_msg(_("\n\nUsage:")); | 3471 mch_msg(_("\n\nUsage:")); |
3606 main_msg(_("-menuheight <height>\tUse a menu bar height of <height> (also: -mh)")); | 3605 main_msg(_("-menuheight <height>\tUse a menu bar height of <height> (also: -mh)")); |
3607 # endif | 3606 # endif |
3608 main_msg(_("-reverse\t\tUse reverse video (also: -rv)")); | 3607 main_msg(_("-reverse\t\tUse reverse video (also: -rv)")); |
3609 main_msg(_("+reverse\t\tDon't use reverse video (also: +rv)")); | 3608 main_msg(_("+reverse\t\tDon't use reverse video (also: +rv)")); |
3610 main_msg(_("-xrm <resource>\tSet the specified resource")); | 3609 main_msg(_("-xrm <resource>\tSet the specified resource")); |
3611 #endif /* FEAT_GUI_X11 */ | 3610 #endif // FEAT_GUI_X11 |
3612 #ifdef FEAT_GUI_GTK | 3611 #ifdef FEAT_GUI_GTK |
3613 mch_msg(_("\nArguments recognised by gvim (GTK+ version):\n")); | 3612 mch_msg(_("\nArguments recognised by gvim (GTK+ version):\n")); |
3614 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)")); | 3613 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)")); |
3615 main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)")); | 3614 main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)")); |
3616 main_msg(_("-reverse\t\tUse reverse video (also: -rv)")); | 3615 main_msg(_("-reverse\t\tUse reverse video (also: -rv)")); |
3628 main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget")); | 3627 main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget")); |
3629 } | 3628 } |
3630 #endif | 3629 #endif |
3631 | 3630 |
3632 #ifdef FEAT_GUI_GNOME | 3631 #ifdef FEAT_GUI_GNOME |
3633 /* Gnome gives extra messages for --help if we continue, but not for -h. */ | 3632 // Gnome gives extra messages for --help if we continue, but not for -h. |
3634 if (gui.starting) | 3633 if (gui.starting) |
3635 { | 3634 { |
3636 mch_msg("\n"); | 3635 mch_msg("\n"); |
3637 gui.dofork = FALSE; | 3636 gui.dofork = FALSE; |
3638 } | 3637 } |
3652 if (swap_exists_action == SEA_QUIT) | 3651 if (swap_exists_action == SEA_QUIT) |
3653 getout(1); | 3652 getout(1); |
3654 handle_swap_exists(NULL); | 3653 handle_swap_exists(NULL); |
3655 } | 3654 } |
3656 | 3655 |
3657 #endif /* NO_VIM_MAIN */ | 3656 #endif // NO_VIM_MAIN |
3658 | 3657 |
3659 #if defined(STARTUPTIME) || defined(PROTO) | 3658 #if defined(STARTUPTIME) || defined(PROTO) |
3660 static struct timeval prev_timeval; | 3659 static struct timeval prev_timeval; |
3661 | 3660 |
3662 # ifdef MSWIN | 3661 # ifdef MSWIN |
3700 * Note: The arguments are (void *) to avoid trouble with systems that don't | 3699 * Note: The arguments are (void *) to avoid trouble with systems that don't |
3701 * have struct timeval. | 3700 * have struct timeval. |
3702 */ | 3701 */ |
3703 void | 3702 void |
3704 time_pop( | 3703 time_pop( |
3705 void *tp) /* actually (struct timeval *) */ | 3704 void *tp) // actually (struct timeval *) |
3706 { | 3705 { |
3707 prev_timeval.tv_usec -= ((struct timeval *)tp)->tv_usec; | 3706 prev_timeval.tv_usec -= ((struct timeval *)tp)->tv_usec; |
3708 prev_timeval.tv_sec -= ((struct timeval *)tp)->tv_sec; | 3707 prev_timeval.tv_sec -= ((struct timeval *)tp)->tv_sec; |
3709 if (prev_timeval.tv_usec < 0) | 3708 if (prev_timeval.tv_usec < 0) |
3710 { | 3709 { |
3726 } | 3725 } |
3727 | 3726 |
3728 void | 3727 void |
3729 time_msg( | 3728 time_msg( |
3730 char *mesg, | 3729 char *mesg, |
3731 void *tv_start) /* only for do_source: start time; actually | 3730 void *tv_start) // only for do_source: start time; actually |
3732 (struct timeval *) */ | 3731 // (struct timeval *) |
3733 { | 3732 { |
3734 static struct timeval start; | 3733 static struct timeval start; |
3735 struct timeval now; | 3734 struct timeval now; |
3736 | 3735 |
3737 if (time_fd != NULL) | 3736 if (time_fd != NULL) |
3765 set_progpath(char_u *argv0) | 3764 set_progpath(char_u *argv0) |
3766 { | 3765 { |
3767 char_u *val = argv0; | 3766 char_u *val = argv0; |
3768 | 3767 |
3769 # ifdef MSWIN | 3768 # ifdef MSWIN |
3770 /* A relative path containing a "/" will become invalid when using ":cd", | 3769 // A relative path containing a "/" will become invalid when using ":cd", |
3771 * turn it into a full path. | 3770 // turn it into a full path. |
3772 * On MS-Windows "vim" should be expanded to "vim.exe", thus always do | 3771 // On MS-Windows "vim" should be expanded to "vim.exe", thus always do |
3773 * this. */ | 3772 // this. |
3774 char_u *path = NULL; | 3773 char_u *path = NULL; |
3775 | 3774 |
3776 if (mch_can_exe(argv0, &path, FALSE) && path != NULL) | 3775 if (mch_can_exe(argv0, &path, FALSE) && path != NULL) |
3777 val = path; | 3776 val = path; |
3778 # else | 3777 # else |
3802 # ifdef MSWIN | 3801 # ifdef MSWIN |
3803 vim_free(path); | 3802 vim_free(path); |
3804 # endif | 3803 # endif |
3805 } | 3804 } |
3806 | 3805 |
3807 #endif /* NO_VIM_MAIN */ | 3806 #endif // NO_VIM_MAIN |
3808 | 3807 |
3809 #if (defined(FEAT_CLIENTSERVER) && !defined(NO_VIM_MAIN)) || defined(PROTO) | 3808 #if (defined(FEAT_CLIENTSERVER) && !defined(NO_VIM_MAIN)) || defined(PROTO) |
3810 | 3809 |
3811 /* | 3810 /* |
3812 * Common code for the X command server and the Win32 command server. | 3811 * Common code for the X command server and the Win32 command server. |
3821 exec_on_server(mparm_T *parmp) | 3820 exec_on_server(mparm_T *parmp) |
3822 { | 3821 { |
3823 if (parmp->serverName_arg == NULL || *parmp->serverName_arg != NUL) | 3822 if (parmp->serverName_arg == NULL || *parmp->serverName_arg != NUL) |
3824 { | 3823 { |
3825 # ifdef MSWIN | 3824 # ifdef MSWIN |
3826 /* Initialise the client/server messaging infrastructure. */ | 3825 // Initialise the client/server messaging infrastructure. |
3827 serverInitMessaging(); | 3826 serverInitMessaging(); |
3828 # endif | 3827 # endif |
3829 | 3828 |
3830 /* | 3829 /* |
3831 * When a command server argument was found, execute it. This may | 3830 * When a command server argument was found, execute it. This may |
3837 cmdsrv_main(&parmp->argc, parmp->argv, | 3836 cmdsrv_main(&parmp->argc, parmp->argv, |
3838 parmp->serverName_arg, &parmp->serverStr); | 3837 parmp->serverName_arg, &parmp->serverStr); |
3839 parmp->serverStrEnc = vim_strsave(p_enc); | 3838 parmp->serverStrEnc = vim_strsave(p_enc); |
3840 } | 3839 } |
3841 | 3840 |
3842 /* If we're still running, get the name to register ourselves. | 3841 // If we're still running, get the name to register ourselves. |
3843 * On Win32 can register right now, for X11 need to setup the | 3842 // On Win32 can register right now, for X11 need to setup the |
3844 * clipboard first, it's further down. */ | 3843 // clipboard first, it's further down. |
3845 parmp->servername = serverMakeName(parmp->serverName_arg, | 3844 parmp->servername = serverMakeName(parmp->serverName_arg, |
3846 parmp->argv[0]); | 3845 parmp->argv[0]); |
3847 # ifdef MSWIN | 3846 # ifdef MSWIN |
3848 if (parmp->servername != NULL) | 3847 if (parmp->servername != NULL) |
3849 { | 3848 { |
3945 * from the argc/argv array; We may have to return into main() | 3944 * from the argc/argv array; We may have to return into main() |
3946 */ | 3945 */ |
3947 for (i = 1; i < Argc; i++) | 3946 for (i = 1; i < Argc; i++) |
3948 { | 3947 { |
3949 res = NULL; | 3948 res = NULL; |
3950 if (STRCMP(argv[i], "--") == 0) /* end of option arguments */ | 3949 if (STRCMP(argv[i], "--") == 0) // end of option arguments |
3951 { | 3950 { |
3952 for (; i < *argc; i++) | 3951 for (; i < *argc; i++) |
3953 { | 3952 { |
3954 *newArgV++ = argv[i]; | 3953 *newArgV++ = argv[i]; |
3955 newArgC++; | 3954 newArgC++; |
4004 { | 4003 { |
4005 *serverStr = build_drop_cmd(*argc - i - 1, argv + i + 1, | 4004 *serverStr = build_drop_cmd(*argc - i - 1, argv + i + 1, |
4006 tabs, argtype == ARGTYPE_EDIT_WAIT); | 4005 tabs, argtype == ARGTYPE_EDIT_WAIT); |
4007 if (*serverStr == NULL) | 4006 if (*serverStr == NULL) |
4008 { | 4007 { |
4009 /* Probably out of memory, exit. */ | 4008 // Probably out of memory, exit. |
4010 didone = TRUE; | 4009 didone = TRUE; |
4011 exiterr = 1; | 4010 exiterr = 1; |
4012 break; | 4011 break; |
4013 } | 4012 } |
4014 Argc = i; | 4013 Argc = i; |
4021 } | 4020 } |
4022 else | 4021 else |
4023 ret = serverSendToVim(xterm_dpy, sname, *serverStr, | 4022 ret = serverSendToVim(xterm_dpy, sname, *serverStr, |
4024 NULL, &srv, 0, 0, 0, silent); | 4023 NULL, &srv, 0, 0, 0, silent); |
4025 # else | 4024 # else |
4026 /* Win32 always works? */ | 4025 // Win32 always works? |
4027 ret = serverSendToVim(sname, *serverStr, NULL, &srv, 0, 0, silent); | 4026 ret = serverSendToVim(sname, *serverStr, NULL, &srv, 0, 0, silent); |
4028 # endif | 4027 # endif |
4029 if (ret < 0) | 4028 if (ret < 0) |
4030 { | 4029 { |
4031 if (argtype == ARGTYPE_SEND) | 4030 if (argtype == ARGTYPE_SEND) |
4032 { | 4031 { |
4033 /* Failed to send, abort. */ | 4032 // Failed to send, abort. |
4034 mch_errmsg(_(": Send failed.\n")); | 4033 mch_errmsg(_(": Send failed.\n")); |
4035 didone = TRUE; | 4034 didone = TRUE; |
4036 exiterr = 1; | 4035 exiterr = 1; |
4037 } | 4036 } |
4038 else if (!silent) | 4037 else if (!silent) |
4039 /* Let vim start normally. */ | 4038 // Let vim start normally. |
4040 mch_errmsg(_(": Send failed. Trying to execute locally\n")); | 4039 mch_errmsg(_(": Send failed. Trying to execute locally\n")); |
4041 break; | 4040 break; |
4042 } | 4041 } |
4043 | 4042 |
4044 # ifdef FEAT_GUI_MSWIN | 4043 # ifdef FEAT_GUI_MSWIN |
4045 /* Guess that when the server name starts with "g" it's a GUI | 4044 // Guess that when the server name starts with "g" it's a GUI |
4046 * server, which we can bring to the foreground here. | 4045 // server, which we can bring to the foreground here. |
4047 * Foreground() in the server doesn't work very well. */ | 4046 // Foreground() in the server doesn't work very well. |
4048 if (argtype != ARGTYPE_SEND && TOUPPER_ASC(*sname) == 'G') | 4047 if (argtype != ARGTYPE_SEND && TOUPPER_ASC(*sname) == 'G') |
4049 SetForegroundWindow(srv); | 4048 SetForegroundWindow(srv); |
4050 # endif | 4049 # endif |
4051 | 4050 |
4052 /* | 4051 /* |
4064 int count = 0; | 4063 int count = 0; |
4065 extern HWND message_window; | 4064 extern HWND message_window; |
4066 # endif | 4065 # endif |
4067 | 4066 |
4068 if (numFiles > 0 && argv[i + 1][0] == '+') | 4067 if (numFiles > 0 && argv[i + 1][0] == '+') |
4069 /* Skip "+cmd" argument, don't wait for it to be edited. */ | 4068 // Skip "+cmd" argument, don't wait for it to be edited. |
4070 --numFiles; | 4069 --numFiles; |
4071 | 4070 |
4072 # ifdef FEAT_GUI_MSWIN | 4071 # ifdef FEAT_GUI_MSWIN |
4073 ni.cbSize = sizeof(ni); | 4072 ni.cbSize = sizeof(ni); |
4074 ni.hWnd = message_window; | 4073 ni.hWnd = message_window; |
4077 ni.hIcon = LoadIcon((HINSTANCE)GetModuleHandle(0), "IDR_VIM"); | 4076 ni.hIcon = LoadIcon((HINSTANCE)GetModuleHandle(0), "IDR_VIM"); |
4078 sprintf(ni.szTip, _("%d of %d edited"), count, numFiles); | 4077 sprintf(ni.szTip, _("%d of %d edited"), count, numFiles); |
4079 Shell_NotifyIcon(NIM_ADD, &ni); | 4078 Shell_NotifyIcon(NIM_ADD, &ni); |
4080 # endif | 4079 # endif |
4081 | 4080 |
4082 /* Wait for all files to unload in remote */ | 4081 // Wait for all files to unload in remote |
4083 vim_memset(done, 0, numFiles); | 4082 vim_memset(done, 0, numFiles); |
4084 while (memchr(done, 0, numFiles) != NULL) | 4083 while (memchr(done, 0, numFiles) != NULL) |
4085 { | 4084 { |
4086 # ifdef MSWIN | 4085 # ifdef MSWIN |
4087 p = serverGetReply(srv, NULL, TRUE, TRUE, 0); | 4086 p = serverGetReply(srv, NULL, TRUE, TRUE, 0); |
4111 else if (STRICMP(argv[i], "--remote-expr") == 0) | 4110 else if (STRICMP(argv[i], "--remote-expr") == 0) |
4112 { | 4111 { |
4113 if (i == *argc - 1) | 4112 if (i == *argc - 1) |
4114 mainerr_arg_missing((char_u *)argv[i]); | 4113 mainerr_arg_missing((char_u *)argv[i]); |
4115 # ifdef MSWIN | 4114 # ifdef MSWIN |
4116 /* Win32 always works? */ | 4115 // Win32 always works? |
4117 if (serverSendToVim(sname, (char_u *)argv[i + 1], | 4116 if (serverSendToVim(sname, (char_u *)argv[i + 1], |
4118 &res, NULL, 1, 0, FALSE) < 0) | 4117 &res, NULL, 1, 0, FALSE) < 0) |
4119 # else | 4118 # else |
4120 if (xterm_dpy == NULL) | 4119 if (xterm_dpy == NULL) |
4121 mch_errmsg(_("No display: Send expression failed.\n")); | 4120 mch_errmsg(_("No display: Send expression failed.\n")); |
4123 &res, NULL, 1, 0, 1, FALSE) < 0) | 4122 &res, NULL, 1, 0, 1, FALSE) < 0) |
4124 # endif | 4123 # endif |
4125 { | 4124 { |
4126 if (res != NULL && *res != NUL) | 4125 if (res != NULL && *res != NUL) |
4127 { | 4126 { |
4128 /* Output error from remote */ | 4127 // Output error from remote |
4129 mch_errmsg((char *)res); | 4128 mch_errmsg((char *)res); |
4130 VIM_CLEAR(res); | 4129 VIM_CLEAR(res); |
4131 } | 4130 } |
4132 mch_errmsg(_(": Send expression failed.\n")); | 4131 mch_errmsg(_(": Send expression failed.\n")); |
4133 } | 4132 } |
4134 } | 4133 } |
4135 else if (STRICMP(argv[i], "--serverlist") == 0) | 4134 else if (STRICMP(argv[i], "--serverlist") == 0) |
4136 { | 4135 { |
4137 # ifdef MSWIN | 4136 # ifdef MSWIN |
4138 /* Win32 always works? */ | 4137 // Win32 always works? |
4139 res = serverGetVimNames(); | 4138 res = serverGetVimNames(); |
4140 # else | 4139 # else |
4141 if (xterm_dpy != NULL) | 4140 if (xterm_dpy != NULL) |
4142 res = serverGetVimNames(xterm_dpy); | 4141 res = serverGetVimNames(xterm_dpy); |
4143 # endif | 4142 # endif |
4144 if (called_emsg) | 4143 if (called_emsg) |
4145 mch_errmsg("\n"); | 4144 mch_errmsg("\n"); |
4146 } | 4145 } |
4147 else if (STRICMP(argv[i], "--servername") == 0) | 4146 else if (STRICMP(argv[i], "--servername") == 0) |
4148 { | 4147 { |
4149 /* Already processed. Take it out of the command line */ | 4148 // Already processed. Take it out of the command line |
4150 i++; | 4149 i++; |
4151 continue; | 4150 continue; |
4152 } | 4151 } |
4153 else | 4152 else |
4154 { | 4153 { |
4166 vim_free(res); | 4165 vim_free(res); |
4167 } | 4166 } |
4168 | 4167 |
4169 if (didone) | 4168 if (didone) |
4170 { | 4169 { |
4171 display_errors(); /* display any collected messages */ | 4170 display_errors(); // display any collected messages |
4172 exit(exiterr); /* Mission accomplished - get out */ | 4171 exit(exiterr); // Mission accomplished - get out |
4173 } | 4172 } |
4174 | 4173 |
4175 /* Return back into main() */ | 4174 // Return back into main() |
4176 *argc = newArgC; | 4175 *argc = newArgC; |
4177 vim_free(sname); | 4176 vim_free(sname); |
4178 } | 4177 } |
4179 | 4178 |
4180 /* | 4179 /* |
4182 */ | 4181 */ |
4183 static char_u * | 4182 static char_u * |
4184 build_drop_cmd( | 4183 build_drop_cmd( |
4185 int filec, | 4184 int filec, |
4186 char **filev, | 4185 char **filev, |
4187 int tabs, /* Use ":tab drop" instead of ":drop". */ | 4186 int tabs, // Use ":tab drop" instead of ":drop". |
4188 int sendReply) | 4187 int sendReply) |
4189 { | 4188 { |
4190 garray_T ga; | 4189 garray_T ga; |
4191 int i; | 4190 int i; |
4192 char_u *inicmd = NULL; | 4191 char_u *inicmd = NULL; |
4198 { | 4197 { |
4199 inicmd = (char_u *)filev[0] + 1; | 4198 inicmd = (char_u *)filev[0] + 1; |
4200 filev++; | 4199 filev++; |
4201 filec--; | 4200 filec--; |
4202 } | 4201 } |
4203 /* Check if we have at least one argument. */ | 4202 // Check if we have at least one argument. |
4204 if (filec <= 0) | 4203 if (filec <= 0) |
4205 mainerr_arg_missing((char_u *)filev[-1]); | 4204 mainerr_arg_missing((char_u *)filev[-1]); |
4206 | 4205 |
4207 /* Temporarily cd to the current directory to handle relative file names. */ | 4206 // Temporarily cd to the current directory to handle relative file names. |
4208 cwd = alloc(MAXPATHL); | 4207 cwd = alloc(MAXPATHL); |
4209 if (cwd == NULL) | 4208 if (cwd == NULL) |
4210 return NULL; | 4209 return NULL; |
4211 if (mch_dirname(cwd, MAXPATHL) != OK) | 4210 if (mch_dirname(cwd, MAXPATHL) != OK) |
4212 { | 4211 { |
4213 vim_free(cwd); | 4212 vim_free(cwd); |
4214 return NULL; | 4213 return NULL; |
4215 } | 4214 } |
4216 cdp = vim_strsave_escaped_ext(cwd, | 4215 cdp = vim_strsave_escaped_ext(cwd, |
4217 #ifdef BACKSLASH_IN_FILENAME | 4216 #ifdef BACKSLASH_IN_FILENAME |
4218 (char_u *)"", /* rem_backslash() will tell what chars to escape */ | 4217 (char_u *)"", // rem_backslash() will tell what chars to escape |
4219 #else | 4218 #else |
4220 PATH_ESC_CHARS, | 4219 PATH_ESC_CHARS, |
4221 #endif | 4220 #endif |
4222 '\\', TRUE); | 4221 '\\', TRUE); |
4223 vim_free(cwd); | 4222 vim_free(cwd); |
4224 if (cdp == NULL) | 4223 if (cdp == NULL) |
4225 return NULL; | 4224 return NULL; |
4226 ga_init2(&ga, 1, 100); | 4225 ga_init2(&ga, 1, 100); |
4227 ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd "); | 4226 ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd "); |
4228 ga_concat(&ga, cdp); | 4227 ga_concat(&ga, cdp); |
4229 | 4228 |
4230 /* Call inputsave() so that a prompt for an encryption key works. */ | 4229 // Call inputsave() so that a prompt for an encryption key works. |
4231 ga_concat(&ga, (char_u *)"<CR>:if exists('*inputsave')|call inputsave()|endif|"); | 4230 ga_concat(&ga, (char_u *)"<CR>:if exists('*inputsave')|call inputsave()|endif|"); |
4232 if (tabs) | 4231 if (tabs) |
4233 ga_concat(&ga, (char_u *)"tab "); | 4232 ga_concat(&ga, (char_u *)"tab "); |
4234 ga_concat(&ga, (char_u *)"drop"); | 4233 ga_concat(&ga, (char_u *)"drop"); |
4235 for (i = 0; i < filec; i++) | 4234 for (i = 0; i < filec; i++) |
4236 { | 4235 { |
4237 /* On Unix the shell has already expanded the wildcards, don't want to | 4236 // On Unix the shell has already expanded the wildcards, don't want to |
4238 * do it again in the Vim server. On MS-Windows only escape | 4237 // do it again in the Vim server. On MS-Windows only escape |
4239 * non-wildcard characters. */ | 4238 // non-wildcard characters. |
4240 p = vim_strsave_escaped((char_u *)filev[i], | 4239 p = vim_strsave_escaped((char_u *)filev[i], |
4241 #ifdef UNIX | 4240 #ifdef UNIX |
4242 PATH_ESC_CHARS | 4241 PATH_ESC_CHARS |
4243 #else | 4242 #else |
4244 (char_u *)" \t%#" | 4243 (char_u *)" \t%#" |
4253 ga_concat(&ga, p); | 4252 ga_concat(&ga, p); |
4254 vim_free(p); | 4253 vim_free(p); |
4255 } | 4254 } |
4256 ga_concat(&ga, (char_u *)"|if exists('*inputrestore')|call inputrestore()|endif<CR>"); | 4255 ga_concat(&ga, (char_u *)"|if exists('*inputrestore')|call inputrestore()|endif<CR>"); |
4257 | 4256 |
4258 /* The :drop commands goes to Insert mode when 'insertmode' is set, use | 4257 // The :drop commands goes to Insert mode when 'insertmode' is set, use |
4259 * CTRL-\ CTRL-N again. */ | 4258 // CTRL-\ CTRL-N again. |
4260 ga_concat(&ga, (char_u *)"<C-\\><C-N>"); | 4259 ga_concat(&ga, (char_u *)"<C-\\><C-N>"); |
4261 | 4260 |
4262 /* Switch back to the correct current directory (prior to temporary path | 4261 // Switch back to the correct current directory (prior to temporary path |
4263 * switch) unless 'autochdir' is set, in which case it will already be | 4262 // switch) unless 'autochdir' is set, in which case it will already be |
4264 * correct after the :drop command. With line breaks and spaces: | 4263 // correct after the :drop command. With line breaks and spaces: |
4265 * if !exists('+acd') || !&acd | 4264 // if !exists('+acd') || !&acd |
4266 * if haslocaldir() | 4265 // if haslocaldir() |
4267 * cd - | 4266 // cd - |
4268 * lcd - | 4267 // lcd - |
4269 * elseif getcwd() ==# 'current path' | 4268 // elseif getcwd() ==# 'current path' |
4270 * cd - | 4269 // cd - |
4271 * endif | 4270 // endif |
4272 * endif | 4271 // endif |
4273 */ | |
4274 ga_concat(&ga, (char_u *)":if !exists('+acd')||!&acd|if haslocaldir()|"); | 4272 ga_concat(&ga, (char_u *)":if !exists('+acd')||!&acd|if haslocaldir()|"); |
4275 ga_concat(&ga, (char_u *)"cd -|lcd -|elseif getcwd() ==# '"); | 4273 ga_concat(&ga, (char_u *)"cd -|lcd -|elseif getcwd() ==# '"); |
4276 ga_concat(&ga, cdp); | 4274 ga_concat(&ga, cdp); |
4277 ga_concat(&ga, (char_u *)"'|cd -|endif|endif<CR>"); | 4275 ga_concat(&ga, (char_u *)"'|cd -|endif|endif<CR>"); |
4278 vim_free(cdp); | 4276 vim_free(cdp); |
4280 if (sendReply) | 4278 if (sendReply) |
4281 ga_concat(&ga, (char_u *)":call SetupRemoteReplies()<CR>"); | 4279 ga_concat(&ga, (char_u *)":call SetupRemoteReplies()<CR>"); |
4282 ga_concat(&ga, (char_u *)":"); | 4280 ga_concat(&ga, (char_u *)":"); |
4283 if (inicmd != NULL) | 4281 if (inicmd != NULL) |
4284 { | 4282 { |
4285 /* Can't use <CR> after "inicmd", because an "startinsert" would cause | 4283 // Can't use <CR> after "inicmd", because an "startinsert" would cause |
4286 * the following commands to be inserted as text. Use a "|", | 4284 // the following commands to be inserted as text. Use a "|", |
4287 * hopefully "inicmd" does allow this... */ | 4285 // hopefully "inicmd" does allow this... |
4288 ga_concat(&ga, inicmd); | 4286 ga_concat(&ga, inicmd); |
4289 ga_concat(&ga, (char_u *)"|"); | 4287 ga_concat(&ga, (char_u *)"|"); |
4290 } | 4288 } |
4291 /* Bring the window to the foreground, goto Insert mode when 'im' set and | 4289 // Bring the window to the foreground, goto Insert mode when 'im' set and |
4292 * clear command line. */ | 4290 // clear command line. |
4293 ga_concat(&ga, (char_u *)"cal foreground()|if &im|star|en|redr|f<CR>"); | 4291 ga_concat(&ga, (char_u *)"cal foreground()|if &im|star|en|redr|f<CR>"); |
4294 ga_append(&ga, NUL); | 4292 ga_append(&ga, NUL); |
4295 return ga.ga_data; | 4293 return ga.ga_data; |
4296 } | 4294 } |
4297 | 4295 |
4308 if (arg != NULL && *arg != NUL) | 4306 if (arg != NULL && *arg != NUL) |
4309 p = vim_strsave_up(arg); | 4307 p = vim_strsave_up(arg); |
4310 else | 4308 else |
4311 { | 4309 { |
4312 p = vim_strsave_up(gettail((char_u *)cmd)); | 4310 p = vim_strsave_up(gettail((char_u *)cmd)); |
4313 /* Remove .exe or .bat from the name. */ | 4311 // Remove .exe or .bat from the name. |
4314 if (p != NULL && vim_strchr(p, '.') != NULL) | 4312 if (p != NULL && vim_strchr(p, '.') != NULL) |
4315 *vim_strchr(p, '.') = NUL; | 4313 *vim_strchr(p, '.') = NUL; |
4316 } | 4314 } |
4317 return p; | 4315 return p; |
4318 } | 4316 } |
4319 #endif /* FEAT_CLIENTSERVER */ | 4317 #endif // FEAT_CLIENTSERVER |
4320 | 4318 |
4321 #if defined(FEAT_CLIENTSERVER) || defined(PROTO) | 4319 #if defined(FEAT_CLIENTSERVER) || defined(PROTO) |
4322 /* | 4320 /* |
4323 * Replace termcodes such as <CR> and insert as key presses if there is room. | 4321 * Replace termcodes such as <CR> and insert as key presses if there is room. |
4324 */ | 4322 */ |
4326 server_to_input_buf(char_u *str) | 4324 server_to_input_buf(char_u *str) |
4327 { | 4325 { |
4328 char_u *ptr = NULL; | 4326 char_u *ptr = NULL; |
4329 char_u *cpo_save = p_cpo; | 4327 char_u *cpo_save = p_cpo; |
4330 | 4328 |
4331 /* Set 'cpoptions' the way we want it. | 4329 // Set 'cpoptions' the way we want it. |
4332 * B set - backslashes are *not* treated specially | 4330 // B set - backslashes are *not* treated specially |
4333 * k set - keycodes are *not* reverse-engineered | 4331 // k set - keycodes are *not* reverse-engineered |
4334 * < unset - <Key> sequences *are* interpreted | 4332 // < unset - <Key> sequences *are* interpreted |
4335 * The last but one parameter of replace_termcodes() is TRUE so that the | 4333 // The last but one parameter of replace_termcodes() is TRUE so that the |
4336 * <lt> sequence is recognised - needed for a real backslash. | 4334 // <lt> sequence is recognised - needed for a real backslash. |
4337 */ | |
4338 p_cpo = (char_u *)"Bk"; | 4335 p_cpo = (char_u *)"Bk"; |
4339 str = replace_termcodes((char_u *)str, &ptr, REPTERM_DO_LT, NULL); | 4336 str = replace_termcodes((char_u *)str, &ptr, REPTERM_DO_LT, NULL); |
4340 p_cpo = cpo_save; | 4337 p_cpo = cpo_save; |
4341 | 4338 |
4342 if (*ptr != NUL) /* trailing CTRL-V results in nothing */ | 4339 if (*ptr != NUL) // trailing CTRL-V results in nothing |
4343 { | 4340 { |
4344 /* | 4341 /* |
4345 * Add the string to the input stream. | 4342 * Add the string to the input stream. |
4346 * Can't use add_to_input_buf() here, we now have K_SPECIAL bytes. | 4343 * Can't use add_to_input_buf() here, we now have K_SPECIAL bytes. |
4347 * | 4344 * |
4351 */ | 4348 */ |
4352 if (typebuf.tb_maplen < typebuf.tb_len) | 4349 if (typebuf.tb_maplen < typebuf.tb_len) |
4353 del_typebuf(typebuf.tb_len - typebuf.tb_maplen, typebuf.tb_maplen); | 4350 del_typebuf(typebuf.tb_len - typebuf.tb_maplen, typebuf.tb_maplen); |
4354 (void)ins_typebuf(str, REMAP_NONE, typebuf.tb_len, TRUE, FALSE); | 4351 (void)ins_typebuf(str, REMAP_NONE, typebuf.tb_len, TRUE, FALSE); |
4355 | 4352 |
4356 /* Let input_available() know we inserted text in the typeahead | 4353 // Let input_available() know we inserted text in the typeahead |
4357 * buffer. */ | 4354 // buffer. |
4358 typebuf_was_filled = TRUE; | 4355 typebuf_was_filled = TRUE; |
4359 } | 4356 } |
4360 vim_free((char_u *)ptr); | 4357 vim_free((char_u *)ptr); |
4361 } | 4358 } |
4362 | 4359 |
4370 int save_dbl = debug_break_level; | 4367 int save_dbl = debug_break_level; |
4371 int save_ro = redir_off; | 4368 int save_ro = redir_off; |
4372 funccal_entry_T funccal_entry; | 4369 funccal_entry_T funccal_entry; |
4373 int did_save_funccal = FALSE; | 4370 int did_save_funccal = FALSE; |
4374 | 4371 |
4375 /* Evaluate the expression at the toplevel, don't use variables local to | 4372 // Evaluate the expression at the toplevel, don't use variables local to |
4376 * the calling function. Except when in debug mode. */ | 4373 // the calling function. Except when in debug mode. |
4377 if (!debug_mode) | 4374 if (!debug_mode) |
4378 { | 4375 { |
4379 save_funccal(&funccal_entry); | 4376 save_funccal(&funccal_entry); |
4380 did_save_funccal = TRUE; | 4377 did_save_funccal = TRUE; |
4381 } | 4378 } |
4382 | 4379 |
4383 /* Disable debugging, otherwise Vim hangs, waiting for "cont" to be | 4380 // Disable debugging, otherwise Vim hangs, waiting for "cont" to be |
4384 * typed. */ | 4381 // typed. |
4385 debug_break_level = -1; | 4382 debug_break_level = -1; |
4386 redir_off = 0; | 4383 redir_off = 0; |
4387 /* Do not display error message, otherwise Vim hangs, waiting for "cont" | 4384 // Do not display error message, otherwise Vim hangs, waiting for "cont" |
4388 * to be typed. Do generate errors so that try/catch works. */ | 4385 // to be typed. Do generate errors so that try/catch works. |
4389 ++emsg_silent; | 4386 ++emsg_silent; |
4390 | 4387 |
4391 res = eval_to_string(expr, NULL, TRUE); | 4388 res = eval_to_string(expr, NULL, TRUE); |
4392 | 4389 |
4393 debug_break_level = save_dbl; | 4390 debug_break_level = save_dbl; |
4396 if (emsg_silent < 0) | 4393 if (emsg_silent < 0) |
4397 emsg_silent = 0; | 4394 emsg_silent = 0; |
4398 if (did_save_funccal) | 4395 if (did_save_funccal) |
4399 restore_funccal(); | 4396 restore_funccal(); |
4400 | 4397 |
4401 /* A client can tell us to redraw, but not to display the cursor, so do | 4398 // A client can tell us to redraw, but not to display the cursor, so do |
4402 * that here. */ | 4399 // that here. |
4403 setcursor(); | 4400 setcursor(); |
4404 out_flush_cursor(FALSE, FALSE); | 4401 out_flush_cursor(FALSE, FALSE); |
4405 | 4402 |
4406 return res; | 4403 return res; |
4407 } | 4404 } |