Skip to content

Commit 1fa8d2c

Browse files
committed
patch 8.2.0273: MS-Windows uninstall may delete wrong batch file
Problem: MS-Windows uninstall may delete wrong batch file. Solution: Add specific marker in the generated batch file. (Ken Takata, closes #5654)
1 parent 414b796 commit 1fa8d2c

5 files changed

Lines changed: 12 additions & 13 deletions

File tree

src/Make_mvc.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ $(VIM): $(VIM).exe
13591359
$(OUTDIR):
13601360
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
13611361

1362-
CFLAGS_INST = /nologo -DNDEBUG -DWIN32 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) $(CFLAGS_DEPR)
1362+
CFLAGS_INST = /nologo /O2 -DNDEBUG -DWIN32 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) $(CFLAGS_DEPR)
13631363

13641364
install.exe: dosinst.c dosinst.h version.h
13651365
$(CC) $(CFLAGS_INST) dosinst.c kernel32.lib shell32.lib \

src/dosinst.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ install_bat_choice(int idx)
841841

842842
fprintf(fd, "@echo off\n");
843843
fprintf(fd, "rem -- Run Vim --\n");
844+
fprintf(fd, VIMBAT_UNINSTKEY "\n");
844845
fprintf(fd, "\n");
845846
fprintf(fd, "setlocal\n");
846847

src/dosinst.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ struct
354354
"vimtutor.bat", "vimtutor.bat", ""},
355355
};
356356

357+
/* Uninstall key for vim.bat, etc. */
358+
#define VIMBAT_UNINSTKEY "rem # uninstall key: " VIM_VERSION_NODOT " #"
359+
357360
#define ICON_COUNT 3
358361
char *(icon_names[ICON_COUNT]) =
359362
{"gVim " VIM_VERSION_SHORT,

src/uninstall.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,26 +200,19 @@ batfile_thisversion(char *path)
200200
{
201201
FILE *fd;
202202
char line[BUFSIZE];
203-
char *p;
204-
int ver_len = strlen(VIM_VERSION_NODOT);
203+
int key_len = strlen(VIMBAT_UNINSTKEY);
205204
int found = FALSE;
206205

207206
fd = fopen(path, "r");
208207
if (fd != NULL)
209208
{
210209
while (fgets(line, sizeof(line), fd) != NULL)
211210
{
212-
for (p = line; *p != 0; ++p)
213-
// don't accept "vim60an" when looking for "vim60".
214-
if (strnicmp(p, VIM_VERSION_NODOT, ver_len) == 0
215-
&& !isdigit(p[ver_len])
216-
&& !isalpha(p[ver_len]))
217-
{
218-
found = TRUE;
219-
break;
220-
}
221-
if (found)
211+
if (strncmp(line, VIMBAT_UNINSTKEY, key_len) == 0)
212+
{
213+
found = TRUE;
222214
break;
215+
}
223216
}
224217
fclose(fd);
225218
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
273,
741743
/**/
742744
272,
743745
/**/

0 commit comments

Comments
 (0)