mirror of
https://github.com/vim/vim.git
synced 2025-09-02 21:13:50 -04:00
patch 7.4.2176
Problem: #ifdefs in main() are complicated. Solution: Always define vim_main2(). Move params to the file level. (suggested by Ken Takata)
This commit is contained in:
parent
812ad4f3a2
commit
a8e691d449
@ -1009,8 +1009,11 @@ static intptr_t _tls_index = 0;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
mzscheme_main(int argc, char** argv)
|
mzscheme_main()
|
||||||
{
|
{
|
||||||
|
int argc = 0;
|
||||||
|
char *argv = NULL;
|
||||||
|
|
||||||
#ifdef DYNAMIC_MZSCHEME
|
#ifdef DYNAMIC_MZSCHEME
|
||||||
/*
|
/*
|
||||||
* Racket requires trampolined startup. We can not load it later.
|
* Racket requires trampolined startup. We can not load it later.
|
||||||
@ -1019,16 +1022,16 @@ mzscheme_main(int argc, char** argv)
|
|||||||
if (!mzscheme_enabled(FALSE))
|
if (!mzscheme_enabled(FALSE))
|
||||||
{
|
{
|
||||||
disabled = TRUE;
|
disabled = TRUE;
|
||||||
return vim_main2(argc, argv);
|
return vim_main2();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_TLS_SPACE
|
#ifdef HAVE_TLS_SPACE
|
||||||
scheme_register_tls_space(&tls_space, _tls_index);
|
scheme_register_tls_space(&tls_space, _tls_index);
|
||||||
#endif
|
#endif
|
||||||
#ifdef TRAMPOLINED_MZVIM_STARTUP
|
#ifdef TRAMPOLINED_MZVIM_STARTUP
|
||||||
return scheme_main_setup(TRUE, mzscheme_env_main, argc, argv);
|
return scheme_main_setup(TRUE, mzscheme_env_main, argc, &argv);
|
||||||
#else
|
#else
|
||||||
return mzscheme_env_main(NULL, argc, argv);
|
return mzscheme_env_main(NULL, argc, &argv);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1056,7 +1059,7 @@ mzscheme_env_main(Scheme_Env *env, int argc, char **argv)
|
|||||||
* We trampoline into vim_main2
|
* We trampoline into vim_main2
|
||||||
* Passing argc, argv through from mzscheme_main
|
* Passing argc, argv through from mzscheme_main
|
||||||
*/
|
*/
|
||||||
vim_main_result = vim_main2(argc, argv);
|
vim_main_result = vim_main2();
|
||||||
#if !defined(TRAMPOLINED_MZVIM_STARTUP) && defined(MZ_PRECISE_GC)
|
#if !defined(TRAMPOLINED_MZVIM_STARTUP) && defined(MZ_PRECISE_GC)
|
||||||
/* releasing dummy */
|
/* releasing dummy */
|
||||||
MZ_GC_REG();
|
MZ_GC_REG();
|
||||||
|
70
src/main.c
70
src/main.c
@ -92,6 +92,9 @@ static char_u *start_dir = NULL; /* current working dir on startup */
|
|||||||
|
|
||||||
static int has_dash_c_arg = FALSE;
|
static int has_dash_c_arg = FALSE;
|
||||||
|
|
||||||
|
/* Various parameters passed between main() and other functions. */
|
||||||
|
static mparm_T params;
|
||||||
|
|
||||||
int
|
int
|
||||||
# ifdef VIMDLL
|
# ifdef VIMDLL
|
||||||
_export
|
_export
|
||||||
@ -106,9 +109,6 @@ main
|
|||||||
# endif
|
# endif
|
||||||
(int argc, char **argv)
|
(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char_u *fname = NULL; /* file name from command line */
|
|
||||||
mparm_T params; /* various parameters passed between
|
|
||||||
* main() and other functions. */
|
|
||||||
#ifdef STARTUPTIME
|
#ifdef STARTUPTIME
|
||||||
int i;
|
int i;
|
||||||
#endif
|
#endif
|
||||||
@ -157,6 +157,7 @@ main
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STARTUPTIME
|
#ifdef STARTUPTIME
|
||||||
|
/* Need to find "--startuptime" before actually parsing arguments. */
|
||||||
for (i = 1; i < argc; ++i)
|
for (i = 1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
if (STRICMP(argv[i], "--startuptime") == 0 && i + 1 < argc)
|
if (STRICMP(argv[i], "--startuptime") == 0 && i + 1 < argc)
|
||||||
@ -241,7 +242,7 @@ main
|
|||||||
mch_chdir((char *)start_dir);
|
mch_chdir((char *)start_dir);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fname = alist_name(&GARGLIST[0]);
|
params.fname = alist_name(&GARGLIST[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WIN32) && defined(FEAT_MBYTE)
|
#if defined(WIN32) && defined(FEAT_MBYTE)
|
||||||
@ -263,7 +264,7 @@ main
|
|||||||
* Hint: to avoid this when typing a command use a forward slash.
|
* Hint: to avoid this when typing a command use a forward slash.
|
||||||
* If the cd fails, it doesn't matter.
|
* If the cd fails, it doesn't matter.
|
||||||
*/
|
*/
|
||||||
(void)vim_chdirfile(fname);
|
(void)vim_chdirfile(params.fname);
|
||||||
if (start_dir != NULL)
|
if (start_dir != NULL)
|
||||||
mch_dirname(start_dir, MAXPATHL);
|
mch_dirname(start_dir, MAXPATHL);
|
||||||
}
|
}
|
||||||
@ -281,7 +282,7 @@ main
|
|||||||
/*
|
/*
|
||||||
* When listing swap file names, don't do cursor positioning et. al.
|
* When listing swap file names, don't do cursor positioning et. al.
|
||||||
*/
|
*/
|
||||||
if (recoverymode && fname == NULL)
|
if (recoverymode && params.fname == NULL)
|
||||||
params.want_full_screen = FALSE;
|
params.want_full_screen = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -312,8 +313,8 @@ main
|
|||||||
if (getcwd((char *)NameBuff, MAXPATHL) != NULL
|
if (getcwd((char *)NameBuff, MAXPATHL) != NULL
|
||||||
&& STRCMP(NameBuff, "/") == 0)
|
&& STRCMP(NameBuff, "/") == 0)
|
||||||
{
|
{
|
||||||
if (fname != NULL)
|
if (params.fname != NULL)
|
||||||
(void)vim_chdirfile(fname);
|
(void)vim_chdirfile(params.fname);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
|
expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
|
||||||
@ -407,37 +408,23 @@ main
|
|||||||
* Newer version of MzScheme (Racket) require earlier (trampolined)
|
* Newer version of MzScheme (Racket) require earlier (trampolined)
|
||||||
* initialisation via scheme_main_setup.
|
* initialisation via scheme_main_setup.
|
||||||
* Implement this by initialising it as early as possible
|
* Implement this by initialising it as early as possible
|
||||||
* and splitting off remaining Vim main into vim_main2
|
* and splitting off remaining Vim main into vim_main2().
|
||||||
*/
|
*/
|
||||||
{
|
return mzscheme_main();
|
||||||
/* Pack up preprocessed command line arguments.
|
#else
|
||||||
* It is safe because Scheme does not access argc/argv. */
|
return vim_main2();
|
||||||
char *args[2];
|
|
||||||
args[0] = (char *)fname;
|
|
||||||
args[1] = (char *)¶ms;
|
|
||||||
return mzscheme_main(2, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
#endif /* NO_VIM_MAIN */
|
#endif /* NO_VIM_MAIN */
|
||||||
|
|
||||||
/* vim_main2() needs to be produced when FEAT_MZSCHEME is defined even when
|
/*
|
||||||
* NO_VIM_MAIN is defined. */
|
* vim_main2() is needed for FEAT_MZSCHEME, but we define it always to keep
|
||||||
#ifdef FEAT_MZSCHEME
|
* things simple.
|
||||||
|
* It is also defined when NO_VIM_MAIN is defined, but then it's empty.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
vim_main2(int argc UNUSED, char **argv UNUSED)
|
vim_main2(void)
|
||||||
{
|
{
|
||||||
# ifndef NO_VIM_MAIN
|
|
||||||
char_u *fname = (char_u *)argv[0];
|
|
||||||
mparm_T params;
|
|
||||||
|
|
||||||
memcpy(¶ms, argv[1], sizeof(params));
|
|
||||||
# else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NO_VIM_MAIN
|
#ifndef NO_VIM_MAIN
|
||||||
/* Reset 'loadplugins' for "-u NONE" before "--cmd" arguments.
|
/* Reset 'loadplugins' for "-u NONE" before "--cmd" arguments.
|
||||||
* Allows for setting 'loadplugins' there. */
|
* Allows for setting 'loadplugins' there. */
|
||||||
@ -493,7 +480,7 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
|
|||||||
* This uses the 'dir' option, therefore it must be after the
|
* This uses the 'dir' option, therefore it must be after the
|
||||||
* initializations.
|
* initializations.
|
||||||
*/
|
*/
|
||||||
if (recoverymode && fname == NULL)
|
if (recoverymode && params.fname == NULL)
|
||||||
{
|
{
|
||||||
recover_names(NULL, TRUE, 0, NULL);
|
recover_names(NULL, TRUE, 0, NULL);
|
||||||
mch_exit(0);
|
mch_exit(0);
|
||||||
@ -888,16 +875,17 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
|
|||||||
*/
|
*/
|
||||||
main_loop(FALSE, FALSE);
|
main_loop(FALSE, FALSE);
|
||||||
|
|
||||||
|
#endif /* NO_VIM_MAIN */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* NO_VIM_MAIN */
|
|
||||||
#endif /* PROTO */
|
#endif /* PROTO */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialisation shared by main() and some tests.
|
* Initialisation shared by main() and some tests.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
common_init(mparm_T *params)
|
common_init(mparm_T *paramp)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
@ -914,7 +902,7 @@ common_init(mparm_T *params)
|
|||||||
#ifdef MAC_OS_CLASSIC
|
#ifdef MAC_OS_CLASSIC
|
||||||
/* Prepare for possibly starting GUI sometime */
|
/* Prepare for possibly starting GUI sometime */
|
||||||
/* Macintosh needs this before any memory is allocated. */
|
/* Macintosh needs this before any memory is allocated. */
|
||||||
gui_prepare(¶ms->argc, params->argv);
|
gui_prepare(¶mp->argc, paramp->argv);
|
||||||
TIME_MSG("GUI prepared");
|
TIME_MSG("GUI prepared");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -963,14 +951,14 @@ common_init(mparm_T *params)
|
|||||||
* --socketid
|
* --socketid
|
||||||
* --windowid
|
* --windowid
|
||||||
*/
|
*/
|
||||||
early_arg_scan(params);
|
early_arg_scan(paramp);
|
||||||
|
|
||||||
#ifdef FEAT_SUN_WORKSHOP
|
#ifdef FEAT_SUN_WORKSHOP
|
||||||
findYourself(params->argv[0]);
|
findYourself(paramp->argv[0]);
|
||||||
#endif
|
#endif
|
||||||
#if defined(FEAT_GUI) && !defined(MAC_OS_CLASSIC)
|
#if defined(FEAT_GUI) && !defined(MAC_OS_CLASSIC)
|
||||||
/* Prepare for possibly starting GUI sometime */
|
/* Prepare for possibly starting GUI sometime */
|
||||||
gui_prepare(¶ms->argc, params->argv);
|
gui_prepare(¶mp->argc, paramp->argv);
|
||||||
TIME_MSG("GUI prepared");
|
TIME_MSG("GUI prepared");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -985,7 +973,7 @@ common_init(mparm_T *params)
|
|||||||
* (needed for :! to * work). mch_check_win() will also handle the -d or
|
* (needed for :! to * work). mch_check_win() will also handle the -d or
|
||||||
* -dev argument.
|
* -dev argument.
|
||||||
*/
|
*/
|
||||||
params->stdout_isatty = (mch_check_win(params->argc, params->argv) != FAIL);
|
paramp->stdout_isatty = (mch_check_win(paramp->argc, paramp->argv) != FAIL);
|
||||||
TIME_MSG("window checked");
|
TIME_MSG("window checked");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3,7 +3,7 @@ int mzscheme_enabled(int verbose);
|
|||||||
void mzvim_check_threads(void);
|
void mzvim_check_threads(void);
|
||||||
void mzvim_reset_timer(void);
|
void mzvim_reset_timer(void);
|
||||||
void mzscheme_end(void);
|
void mzscheme_end(void);
|
||||||
int mzscheme_main(int argc, char **argv);
|
int mzscheme_main(void);
|
||||||
void mzscheme_buffer_free(buf_T *buf);
|
void mzscheme_buffer_free(buf_T *buf);
|
||||||
void mzscheme_window_free(win_T *win);
|
void mzscheme_window_free(win_T *win);
|
||||||
void ex_mzscheme(exarg_T *eap);
|
void ex_mzscheme(exarg_T *eap);
|
||||||
|
@ -3160,7 +3160,7 @@ struct timer_S
|
|||||||
timer_T *tr_prev;
|
timer_T *tr_prev;
|
||||||
proftime_T tr_due; /* when the callback is to be invoked */
|
proftime_T tr_due; /* when the callback is to be invoked */
|
||||||
int tr_repeat; /* number of times to repeat, -1 forever */
|
int tr_repeat; /* number of times to repeat, -1 forever */
|
||||||
long tr_interval; /* only set when it repeats */
|
long tr_interval; /* msec */
|
||||||
char_u *tr_callback; /* allocated */
|
char_u *tr_callback; /* allocated */
|
||||||
partial_T *tr_partial;
|
partial_T *tr_partial;
|
||||||
#endif
|
#endif
|
||||||
@ -3180,6 +3180,8 @@ typedef struct
|
|||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
|
|
||||||
|
char_u *fname; /* first file to edit */
|
||||||
|
|
||||||
int evim_mode; /* started as "evim" */
|
int evim_mode; /* started as "evim" */
|
||||||
char_u *use_vimrc; /* vimrc from -u argument */
|
char_u *use_vimrc; /* vimrc from -u argument */
|
||||||
|
|
||||||
|
@ -763,6 +763,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2176,
|
||||||
/**/
|
/**/
|
||||||
2175,
|
2175,
|
||||||
/**/
|
/**/
|
||||||
|
@ -2439,10 +2439,8 @@ typedef enum
|
|||||||
#define JSON_JS 1 /* use JS instead of JSON */
|
#define JSON_JS 1 /* use JS instead of JSON */
|
||||||
#define JSON_NO_NONE 2 /* v:none item not allowed */
|
#define JSON_NO_NONE 2 /* v:none item not allowed */
|
||||||
|
|
||||||
#ifdef FEAT_MZSCHEME
|
/* This is in main.c, cproto can't handle it. */
|
||||||
/* this is in main.c, cproto can't handle it. */
|
int vim_main2(void);
|
||||||
int vim_main2(int argc, char **argv);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Used for flags of do_in_path() */
|
/* Used for flags of do_in_path() */
|
||||||
#define DIP_ALL 0x01 /* all matches, not just the first one */
|
#define DIP_ALL 0x01 /* all matches, not just the first one */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user