diff options
Diffstat (limited to 'src/dosinst.c')
-rw-r--r-- | src/dosinst.c | 155 |
1 files changed, 78 insertions, 77 deletions
diff --git a/src/dosinst.c b/src/dosinst.c index 60e3c649ac..4eae5aadc4 100644 --- a/src/dosinst.c +++ b/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"); - } + printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath); + return; + } - 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); - } + need_uninstall_entry = 1; - fclose(fd); - printf("%s has been %s\n", batpath, - oldname == NULL ? "created" : "overwritten"); - } + 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"); } /* |