Mercurial > vim
comparison src/main.c @ 445:c773cb978acf v7.0116
updated for version 7.0116
author | vimboss |
---|---|
date | Mon, 25 Jul 2005 20:46:57 +0000 |
parents | 43bf0bcf2110 |
children | 7472c565592a |
comparison
equal
deleted
inserted
replaced
444:d0d15b184c56 | 445:c773cb978acf |
---|---|
37 { | 37 { |
38 int argc; | 38 int argc; |
39 char **argv; | 39 char **argv; |
40 | 40 |
41 int evim_mode; /* started as "evim" */ | 41 int evim_mode; /* started as "evim" */ |
42 int bin_mode; /* -b argument used */ | |
43 char_u *use_vimrc; /* vimrc from -u argument */ | 42 char_u *use_vimrc; /* vimrc from -u argument */ |
44 | 43 |
45 int n_commands; /* no. of commands from + or -c */ | 44 int n_commands; /* no. of commands from + or -c */ |
46 char_u *commands[MAX_ARG_CMDS]; /* commands from + or -c arg. */ | 45 char_u *commands[MAX_ARG_CMDS]; /* commands from + or -c arg. */ |
47 char_u cmds_tofree[MAX_ARG_CMDS]; /* commands that need free() */ | 46 char_u cmds_tofree[MAX_ARG_CMDS]; /* commands that need free() */ |
365 mch_exit(1); | 364 mch_exit(1); |
366 } | 365 } |
367 # endif | 366 # endif |
368 #endif | 367 #endif |
369 | 368 |
370 /* "-b" argument used. Check before expanding file names, because for | |
371 * Win32 this makes us edit a shortcut file itself, instead of the file it | |
372 * links to. */ | |
373 if (params.bin_mode) | |
374 { | |
375 set_options_bin(curbuf->b_p_bin, 1, 0); | |
376 curbuf->b_p_bin = 1; /* binary file I/O */ | |
377 } | |
378 | |
379 if (GARGCOUNT > 0) | 369 if (GARGCOUNT > 0) |
380 { | 370 { |
381 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE) | 371 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE) |
382 /* | 372 /* |
383 * Expand wildcards in file names. | 373 * Expand wildcards in file names. |
418 } | 408 } |
419 #endif | 409 #endif |
420 TIME_MSG("expanding arguments"); | 410 TIME_MSG("expanding arguments"); |
421 | 411 |
422 #ifdef FEAT_DIFF | 412 #ifdef FEAT_DIFF |
423 if (params.diff_mode && params.window_count == -1) | 413 if (params.diff_mode) |
424 params.window_count = 0; /* open up to 3 files in a window */ | 414 { |
415 if (params.window_count == -1) | |
416 params.window_count = 0; /* open up to 3 windows */ | |
417 if (params.vert_windows == MAYBE) | |
418 params.vert_windows = TRUE; /* use vertical split */ | |
419 } | |
425 #endif | 420 #endif |
426 | 421 |
427 /* Don't redraw until much later. */ | 422 /* Don't redraw until much later. */ |
428 ++RedrawingDisabled; | 423 ++RedrawingDisabled; |
429 | 424 |
1451 char **argv = parmp->argv; | 1446 char **argv = parmp->argv; |
1452 int argv_idx; /* index in argv[n][] */ | 1447 int argv_idx; /* index in argv[n][] */ |
1453 int had_minmin = FALSE; /* found "--" argument */ | 1448 int had_minmin = FALSE; /* found "--" argument */ |
1454 int want_argument; /* option argument with argument */ | 1449 int want_argument; /* option argument with argument */ |
1455 int c; | 1450 int c; |
1456 char_u *p; | 1451 char_u *p = NULL; |
1457 long n; | 1452 long n; |
1458 | 1453 |
1459 --argc; | 1454 --argc; |
1460 ++argv; | 1455 ++argv; |
1461 argv_idx = 1; /* active option letter is argv[0][argv_idx] */ | 1456 argv_idx = 1; /* active option letter is argv[0][argv_idx] */ |
1595 mch_exit(2); | 1590 mch_exit(2); |
1596 #endif | 1591 #endif |
1597 break; | 1592 break; |
1598 | 1593 |
1599 case 'b': /* "-b" binary mode */ | 1594 case 'b': /* "-b" binary mode */ |
1600 parmp->bin_mode = TRUE; /* postpone to after reading .exrc files */ | 1595 /* Needs to be effective before expanding file names, because |
1596 * for Win32 this makes us edit a shortcut file itself, | |
1597 * instead of the file it links to. */ | |
1598 set_options_bin(curbuf->b_p_bin, 1, 0); | |
1599 curbuf->b_p_bin = 1; /* binary file I/O */ | |
1601 break; | 1600 break; |
1602 | 1601 |
1603 case 'C': /* "-C" Compatible */ | 1602 case 'C': /* "-C" Compatible */ |
1604 change_compatible(TRUE); | 1603 change_compatible(TRUE); |
1605 break; | 1604 break; |
1689 break; | 1688 break; |
1690 | 1689 |
1691 case 'o': /* "-o[N]" open N horizontal split windows */ | 1690 case 'o': /* "-o[N]" open N horizontal split windows */ |
1692 #ifdef FEAT_WINDOWS | 1691 #ifdef FEAT_WINDOWS |
1693 /* default is 0: open window for each file */ | 1692 /* default is 0: open window for each file */ |
1694 parmp->window_count = get_number_arg((char_u *)argv[0], &argv_idx, 0); | 1693 parmp->window_count = get_number_arg((char_u *)argv[0], |
1694 &argv_idx, 0); | |
1695 parmp->vert_windows = FALSE; | 1695 parmp->vert_windows = FALSE; |
1696 #endif | 1696 #endif |
1697 break; | 1697 break; |
1698 | 1698 |
1699 case 'O': /* "-O[N]" open N vertical split windows */ | 1699 case 'O': /* "-O[N]" open N vertical split windows */ |
1700 #if defined(FEAT_VERTSPLIT) && defined(FEAT_WINDOWS) | 1700 #if defined(FEAT_VERTSPLIT) && defined(FEAT_WINDOWS) |
1701 /* default is 0: open window for each file */ | 1701 /* default is 0: open window for each file */ |
1702 parmp->window_count = get_number_arg((char_u *)argv[0], &argv_idx, 0); | 1702 parmp->window_count = get_number_arg((char_u *)argv[0], |
1703 &argv_idx, 0); | |
1703 parmp->vert_windows = TRUE; | 1704 parmp->vert_windows = TRUE; |
1704 #endif | 1705 #endif |
1705 break; | 1706 break; |
1706 | 1707 |
1707 #ifdef FEAT_QUICKFIX | 1708 #ifdef FEAT_QUICKFIX |
1815 command */ | 1816 command */ |
1816 if (argv[0][argv_idx] != NUL) | 1817 if (argv[0][argv_idx] != NUL) |
1817 { | 1818 { |
1818 if (parmp->n_commands >= MAX_ARG_CMDS) | 1819 if (parmp->n_commands >= MAX_ARG_CMDS) |
1819 mainerr(ME_EXTRA_CMD, NULL); | 1820 mainerr(ME_EXTRA_CMD, NULL); |
1820 parmp->commands[parmp->n_commands++] = (char_u *)argv[0] + argv_idx; | 1821 parmp->commands[parmp->n_commands++] = (char_u *)argv[0] |
1822 + argv_idx; | |
1821 argv_idx = -1; | 1823 argv_idx = -1; |
1822 break; | 1824 break; |
1823 } | 1825 } |
1824 /*FALLTHROUGH*/ | 1826 /*FALLTHROUGH*/ |
1825 case 'S': /* "-S {file}" execute Vim script */ | 1827 case 'S': /* "-S {file}" execute Vim script */ |
1888 sprintf((char *)p, "so %s", a); | 1890 sprintf((char *)p, "so %s", a); |
1889 parmp->cmds_tofree[parmp->n_commands] = TRUE; | 1891 parmp->cmds_tofree[parmp->n_commands] = TRUE; |
1890 parmp->commands[parmp->n_commands++] = p; | 1892 parmp->commands[parmp->n_commands++] = p; |
1891 } | 1893 } |
1892 else | 1894 else |
1893 parmp->commands[parmp->n_commands++] = (char_u *)argv[0]; | 1895 parmp->commands[parmp->n_commands++] = |
1896 (char_u *)argv[0]; | |
1894 break; | 1897 break; |
1895 | 1898 |
1896 case '-': /* "--cmd {command}" execute command */ | 1899 case '-': /* "--cmd {command}" execute command */ |
1897 if (parmp->n_pre_commands >= MAX_ARG_CMDS) | 1900 if (parmp->n_pre_commands >= MAX_ARG_CMDS) |
1898 mainerr(ME_EXTRA_CMD, NULL); | 1901 mainerr(ME_EXTRA_CMD, NULL); |
1899 parmp->pre_commands[parmp->n_pre_commands++] = (char_u *)argv[0]; | 1902 parmp->pre_commands[parmp->n_pre_commands++] = |
1903 (char_u *)argv[0]; | |
1900 break; | 1904 break; |
1901 | 1905 |
1902 /* case 'd': -d {device} is handled in mch_check_win() for the | 1906 /* case 'd': -d {device} is handled in mch_check_win() for the |
1903 * Amiga */ | 1907 * Amiga */ |
1904 | 1908 |
2050 mch_exit(2); | 2054 mch_exit(2); |
2051 } | 2055 } |
2052 #endif | 2056 #endif |
2053 alist_add(&global_alist, p, | 2057 alist_add(&global_alist, p, |
2054 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE) | 2058 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE) |
2055 parmp->literal ? 2 : 0 /* add buffer number after expanding */ | 2059 parmp->literal ? 2 : 0 /* add buffer nr after exp. */ |
2056 #else | 2060 #else |
2057 2 /* add buffer number now and use curbuf */ | 2061 2 /* add buffer number now and use curbuf */ |
2058 #endif | 2062 #endif |
2059 ); | 2063 ); |
2060 | 2064 |
2423 * If -u argument given, use only the initializations from that file and | 2427 * If -u argument given, use only the initializations from that file and |
2424 * nothing else. | 2428 * nothing else. |
2425 */ | 2429 */ |
2426 if (parmp->use_vimrc != NULL) | 2430 if (parmp->use_vimrc != NULL) |
2427 { | 2431 { |
2428 if (STRCMP(parmp->use_vimrc, "NONE") == 0 || STRCMP(parmp->use_vimrc, "NORC") == 0) | 2432 if (STRCMP(parmp->use_vimrc, "NONE") == 0 |
2433 || STRCMP(parmp->use_vimrc, "NORC") == 0) | |
2429 { | 2434 { |
2430 #ifdef FEAT_GUI | 2435 #ifdef FEAT_GUI |
2431 if (use_gvimrc == NULL) /* don't load gvimrc either */ | 2436 if (use_gvimrc == NULL) /* don't load gvimrc either */ |
2432 use_gvimrc = parmp->use_vimrc; | 2437 use_gvimrc = parmp->use_vimrc; |
2433 #endif | 2438 #endif |