c.c (3220B)
1 /* vi:set ts=8 sts=4 sw=4 noet: 2 * VIM_TEST_SETUP let g:c_comment_strings = 1 3 * 4 * VIM - Vi IMproved by Bram Moolenaar 5 * 6 * Do ":help uganda" in Vim to read copying and usage conditions. 7 * Do ":help credits" in Vim to see a list of people who contributed. 8 * See README.txt for an overview of the Vim source code. 9 */ 10 11 #define EXTERN 12 #include "vim.h" 13 14 #ifdef __CYGWIN__ 15 # include <cygwin/version.h> 16 # include <sys/cygwin.h> // for cygwin_conv_to_posix_path() and/or 17 // cygwin_conv_path() 18 # include <limits.h> 19 #endif 20 21 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) 22 # include "iscygpty.h" 23 #endif 24 25 // Values for edit_type. 26 #define EDIT_NONE 0 // no edit type yet 27 #define EDIT_FILE 1 // file name argument[s] given, use argument list 28 #define EDIT_STDIN 2 // read file from stdin 29 #define EDIT_TAG 3 // tag name argument given, use tagname 30 #define EDIT_QF 4 // start in quickfix mode 31 32 #if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN) 33 static int file_owned(char *fname); 34 #endif 35 static void mainerr(int, char_u *); 36 static void early_arg_scan(mparm_T *parmp); 37 #ifndef NO_VIM_MAIN 38 static void usage(void); 39 static void parse_command_name(mparm_T *parmp); 40 static void command_line_scan(mparm_T *parmp); 41 static void check_tty(mparm_T *parmp); 42 static void read_stdin(void); 43 static void create_windows(mparm_T *parmp); 44 static void edit_buffers(mparm_T *parmp, char_u *cwd); 45 static void exe_pre_commands(mparm_T *parmp); 46 static void exe_commands(mparm_T *parmp); 47 static void source_startup_scripts(mparm_T *parmp); 48 static void main_start_gui(void); 49 static void check_swap_exists_action(void); 50 # ifdef FEAT_EVAL 51 static void set_progpath(char_u *argv0); 52 # endif 53 #endif 54 55 56 /* 57 * Different types of error messages. 58 */ 59 static char *(main_errors[]) = 60 { 61 N_("Unknown option argument"), 62 #define ME_UNKNOWN_OPTION 0 63 N_("Too many edit arguments"), 64 #define ME_TOO_MANY_ARGS 1 65 N_("Argument missing after"), 66 #define ME_ARG_MISSING 2 67 N_("Garbage after option argument"), 68 #define ME_GARBAGE 3 69 N_("Too many \"+command\", \"-c command\" or \"--cmd command\" arguments"), 70 #define ME_EXTRA_CMD 4 71 N_("Invalid argument for"), 72 #define ME_INVALID_ARG 5 73 }; 74 75 #ifndef PROTO // don't want a prototype for main() 76 77 // Various parameters passed between main() and other functions. 78 static mparm_T params; 79 80 #ifdef _IOLBF 81 static void *s_vbuf = NULL; // buffer for setvbuf() 82 #endif 83 84 #ifndef NO_VIM_MAIN // skip this for unittests 85 86 static char_u *start_dir = NULL; // current working dir on startup 87 88 static int has_dash_c_arg = FALSE; 89 90 # ifdef VIMDLL 91 __declspec(dllexport) 92 # endif 93 int 94 # ifdef MSWIN 95 VimMain 96 # else 97 main 98 # endif 99 (int argc, char **argv) 100 { 101 #if defined(STARTUPTIME) || defined(CLEAN_RUNTIMEPATH) 102 int i; 103 #endif 104 105 /* 106 * Do any system-specific initialisations. These can NOT use IObuff or 107 * NameBuff. Thus emsg2() cannot be called! 108 */ 109 mch_early_init(); 110 111 // Source startup scripts. 112 source_startup_scripts(¶ms); 113 114 #if 0 115 /* 116 * Newer version of MzScheme (Racket) require earlier (trampolined) 117 * initialisation via scheme_main_setup. 118 */ 119 return mzscheme_main(); 120 #else 121 return vim_main2(); 122 #endif 123 }