mirror of
https://github.com/vim/vim.git
synced 2025-10-17 07:44:28 -04:00
patch 9.0.1132: code is indented more than needed
Problem: Code is indented more than needed. Solution: Use an early return to reduce indentation. (Yegappan Lakshmanan, closes #11769)
This commit is contained in:
committed by
Bram Moolenaar
parent
a2942c7468
commit
dc4daa3a39
159
src/dosinst.c
159
src/dosinst.c
@@ -830,87 +830,88 @@ install_bat_choice(int idx)
|
||||
char *vimarg = targets[choices[idx].arg].exearg;
|
||||
FILE *fd;
|
||||
|
||||
if (*batpath != NUL)
|
||||
if (*batpath == NUL)
|
||||
return;
|
||||
|
||||
fd = fopen(batpath, "w");
|
||||
if (fd == NULL)
|
||||
{
|
||||
fd = fopen(batpath, "w");
|
||||
if (fd == NULL)
|
||||
printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath);
|
||||
else
|
||||
{
|
||||
need_uninstall_entry = 1;
|
||||
|
||||
fprintf(fd, "@echo off\n");
|
||||
fprintf(fd, "rem -- Run Vim --\n");
|
||||
fprintf(fd, VIMBAT_UNINSTKEY "\n");
|
||||
fprintf(fd, "\n");
|
||||
fprintf(fd, "setlocal\n");
|
||||
|
||||
/*
|
||||
* Don't use double quotes for the "set" argument, also when it
|
||||
* contains a space. The quotes would be included in the value.
|
||||
* The order of preference is:
|
||||
* 1. $VIMRUNTIME/vim.exe (user preference)
|
||||
* 2. $VIM/vim81/vim.exe (hard coded version)
|
||||
* 3. installdir/vim.exe (hard coded install directory)
|
||||
*/
|
||||
fprintf(fd, "set VIM_EXE_DIR=%s\n", installdir);
|
||||
fprintf(fd, "if exist \"%%VIM%%\\%s\\%s\" set VIM_EXE_DIR=%%VIM%%\\%s\n",
|
||||
VIM_VERSION_NODOT, exename, VIM_VERSION_NODOT);
|
||||
fprintf(fd, "if exist \"%%VIMRUNTIME%%\\%s\" set VIM_EXE_DIR=%%VIMRUNTIME%%\n", exename);
|
||||
fprintf(fd, "\n");
|
||||
|
||||
// Give an error message when the executable could not be found.
|
||||
fprintf(fd, "if not exist \"%%VIM_EXE_DIR%%\\%s\" (\n", exename);
|
||||
fprintf(fd, " echo \"%%VIM_EXE_DIR%%\\%s\" not found\n", exename);
|
||||
fprintf(fd, " goto :eof\n");
|
||||
fprintf(fd, ")\n");
|
||||
fprintf(fd, "\n");
|
||||
|
||||
if (*exename == 'g')
|
||||
{
|
||||
fprintf(fd, "rem check --nofork argument\n");
|
||||
fprintf(fd, "set VIMNOFORK=\n");
|
||||
fprintf(fd, ":loopstart\n");
|
||||
fprintf(fd, "if .%%1==. goto loopend\n");
|
||||
fprintf(fd, "if .%%1==.--nofork (\n");
|
||||
fprintf(fd, " set VIMNOFORK=1\n");
|
||||
fprintf(fd, ") else if .%%1==.-f (\n");
|
||||
fprintf(fd, " set VIMNOFORK=1\n");
|
||||
fprintf(fd, ")\n");
|
||||
fprintf(fd, "shift\n");
|
||||
fprintf(fd, "goto loopstart\n");
|
||||
fprintf(fd, ":loopend\n");
|
||||
fprintf(fd, "\n");
|
||||
}
|
||||
|
||||
if (*exename == 'g')
|
||||
{
|
||||
// For gvim.exe use "start /b" to avoid that the console window
|
||||
// stays open.
|
||||
fprintf(fd, "if .%%VIMNOFORK%%==.1 (\n");
|
||||
fprintf(fd, " start \"dummy\" /b /wait ");
|
||||
// Always use quotes, $VIM or $VIMRUNTIME might have a space.
|
||||
fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
|
||||
exename, vimarg);
|
||||
fprintf(fd, ") else (\n");
|
||||
fprintf(fd, " start \"dummy\" /b ");
|
||||
// Always use quotes, $VIM or $VIMRUNTIME might have a space.
|
||||
fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
|
||||
exename, vimarg);
|
||||
fprintf(fd, ")\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Always use quotes, $VIM or $VIMRUNTIME might have a space.
|
||||
fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
|
||||
exename, vimarg);
|
||||
}
|
||||
|
||||
fclose(fd);
|
||||
printf("%s has been %s\n", batpath,
|
||||
oldname == NULL ? "created" : "overwritten");
|
||||
}
|
||||
printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath);
|
||||
return;
|
||||
}
|
||||
|
||||
need_uninstall_entry = 1;
|
||||
|
||||
fprintf(fd, "@echo off\n");
|
||||
fprintf(fd, "rem -- Run Vim --\n");
|
||||
fprintf(fd, VIMBAT_UNINSTKEY "\n");
|
||||
fprintf(fd, "\n");
|
||||
fprintf(fd, "setlocal\n");
|
||||
|
||||
/*
|
||||
* Don't use double quotes for the "set" argument, also when it
|
||||
* contains a space. The quotes would be included in the value.
|
||||
* The order of preference is:
|
||||
* 1. $VIMRUNTIME/vim.exe (user preference)
|
||||
* 2. $VIM/vim81/vim.exe (hard coded version)
|
||||
* 3. installdir/vim.exe (hard coded install directory)
|
||||
*/
|
||||
fprintf(fd, "set VIM_EXE_DIR=%s\n", installdir);
|
||||
fprintf(fd, "if exist \"%%VIM%%\\%s\\%s\" set VIM_EXE_DIR=%%VIM%%\\%s\n",
|
||||
VIM_VERSION_NODOT, exename, VIM_VERSION_NODOT);
|
||||
fprintf(fd, "if exist \"%%VIMRUNTIME%%\\%s\" set VIM_EXE_DIR=%%VIMRUNTIME%%\n", exename);
|
||||
fprintf(fd, "\n");
|
||||
|
||||
// Give an error message when the executable could not be found.
|
||||
fprintf(fd, "if not exist \"%%VIM_EXE_DIR%%\\%s\" (\n", exename);
|
||||
fprintf(fd, " echo \"%%VIM_EXE_DIR%%\\%s\" not found\n", exename);
|
||||
fprintf(fd, " goto :eof\n");
|
||||
fprintf(fd, ")\n");
|
||||
fprintf(fd, "\n");
|
||||
|
||||
if (*exename == 'g')
|
||||
{
|
||||
fprintf(fd, "rem check --nofork argument\n");
|
||||
fprintf(fd, "set VIMNOFORK=\n");
|
||||
fprintf(fd, ":loopstart\n");
|
||||
fprintf(fd, "if .%%1==. goto loopend\n");
|
||||
fprintf(fd, "if .%%1==.--nofork (\n");
|
||||
fprintf(fd, " set VIMNOFORK=1\n");
|
||||
fprintf(fd, ") else if .%%1==.-f (\n");
|
||||
fprintf(fd, " set VIMNOFORK=1\n");
|
||||
fprintf(fd, ")\n");
|
||||
fprintf(fd, "shift\n");
|
||||
fprintf(fd, "goto loopstart\n");
|
||||
fprintf(fd, ":loopend\n");
|
||||
fprintf(fd, "\n");
|
||||
}
|
||||
|
||||
if (*exename == 'g')
|
||||
{
|
||||
// For gvim.exe use "start /b" to avoid that the console window
|
||||
// stays open.
|
||||
fprintf(fd, "if .%%VIMNOFORK%%==.1 (\n");
|
||||
fprintf(fd, " start \"dummy\" /b /wait ");
|
||||
// Always use quotes, $VIM or $VIMRUNTIME might have a space.
|
||||
fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
|
||||
exename, vimarg);
|
||||
fprintf(fd, ") else (\n");
|
||||
fprintf(fd, " start \"dummy\" /b ");
|
||||
// Always use quotes, $VIM or $VIMRUNTIME might have a space.
|
||||
fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
|
||||
exename, vimarg);
|
||||
fprintf(fd, ")\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Always use quotes, $VIM or $VIMRUNTIME might have a space.
|
||||
fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
|
||||
exename, vimarg);
|
||||
}
|
||||
|
||||
fclose(fd);
|
||||
printf("%s has been %s\n", batpath,
|
||||
oldname == NULL ? "created" : "overwritten");
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user