annotate src/dosinst.c @ 25206:dc66d0284518 v8.2.3139

patch 8.2.3139: functions for string manipulation are spread out Commit: https://github.com/vim/vim/commit/a2438132a675be4dde3acbdf03ba1fdb2f09427c Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Jul 10 21:29:18 2021 +0200 patch 8.2.3139: functions for string manipulation are spread out Problem: Functions for string manipulation are spread out. Solution: Move string related functions to a new source file. (Yegappan Lakshmanan, closes #8470)
author Bram Moolenaar <Bram@vim.org>
date Sat, 10 Jul 2021 21:30:04 +0200
parents 7334bf933510
children 5f6167685bbb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9680
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * dosinst.c: Install program for Vim on MS-DOS and MS-Windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 *
16606
7e733046db1d patch 8.1.1306: Borland support is outdated and doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 16229
diff changeset
13 * Compile with Make_mvc.mak, Make_cyg.mak or Make_ming.mak.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 /*
18174
1ec6539cef68 patch 8.1.2082: some files have a weird name to fit in 8.3 characters
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
17 * Include common code for dosinst.c and uninstall.c.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 #define DOSINST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 #include "dosinst.h"
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
21 #include <io.h>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
23 #define GVIMEXT64_PATH "GvimExt64\\gvimext.dll"
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
24 #define GVIMEXT32_PATH "GvimExt32\\gvimext.dll"
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
25
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
26 // Macro to do an error check I was typing over and over
13632
cec5137d5332 patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents: 13353
diff changeset
27 #define CHECK_REG_ERROR(code) \
cec5137d5332 patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents: 13353
diff changeset
28 do { \
cec5137d5332 patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents: 13353
diff changeset
29 if (code != ERROR_SUCCESS) \
cec5137d5332 patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents: 13353
diff changeset
30 { \
cec5137d5332 patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents: 13353
diff changeset
31 printf("%ld error number: %ld\n", (long)__LINE__, (long)code); \
cec5137d5332 patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents: 13353
diff changeset
32 return 1; \
cec5137d5332 patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents: 13353
diff changeset
33 } \
cec5137d5332 patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents: 13353
diff changeset
34 } while (0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
36 int has_vim = 0; // installable vim.exe exists
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
37 int has_gvim = 0; // installable gvim.exe exists
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
39 char oldvimrc[BUFSIZE]; // name of existing vimrc file
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
40 char vimrc[BUFSIZE]; // name of vimrc file to create
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
42 char *default_bat_dir = NULL; // when not NULL, use this as the default
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
43 // directory to write .bat files in
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
44 char *default_vim_dir = NULL; // when not NULL, use this as the default
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
45 // install dir for NSIS
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 * Structure used for each choice the user can make.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 struct choice
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
52 int active; // non-zero when choice is active
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
53 char *text; // text displayed for this choice
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
54 void (*changefunc)(int idx); // function to change this choice
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
55 int arg; // argument for function
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
56 void (*installfunc)(int idx); // function to install this choice
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
59 struct choice choices[30]; // choices the user can make
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
60 int choice_count = 0; // number of choices available
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 19762
diff changeset
62 #define TABLE_SIZE(s) (int)ARRAYSIZE(s)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 enum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 compat_vi = 1,
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
67 compat_vim,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 compat_some_enhancements,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 compat_all_enhancements
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 char *(compat_choices[]) =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 "\nChoose the default way to run Vim:",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 "Vi compatible",
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
75 "Vim default",
2154
7c8c7c95a865 First step in the Vim 7.3 branch. Changed version numbers.
Bram Moolenaar <bram@zimbu.org>
parents: 1569
diff changeset
76 "with some Vim enhancements",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 "with syntax highlighting and other features switched on",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 int compat_choice = (int)compat_all_enhancements;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 char *compat_text = "- run Vim %s";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 enum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 remap_no = 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 remap_win
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 char *(remap_choices[]) =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 "\nChoose:",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 "Do not remap keys for Windows behavior",
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
91 "Remap a few keys for Windows behavior (CTRL-V, CTRL-C, CTRL-F, etc)",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 };
12708
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
93 int remap_choice = (int)remap_no;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 char *remap_text = "- %s";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 enum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 mouse_xterm = 1,
12710
18020ddc2730 patch 8.0.1233: typo in dos installer
Christian Brabandt <cb@256bit.org>
parents: 12708
diff changeset
99 mouse_mswin,
12708
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
100 mouse_default
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 char *(mouse_choices[]) =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 "\nChoose the way how Vim uses the mouse:",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 "right button extends selection (the Unix way)",
12708
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
106 "right button has a popup menu, left button starts select mode (the Windows way)",
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
107 "right button has a popup menu, left button starts visual mode",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 };
12708
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
109 int mouse_choice = (int)mouse_default;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 char *mouse_text = "- The mouse %s";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 enum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 vimfiles_dir_none = 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 vimfiles_dir_vim,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 vimfiles_dir_home
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 };
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
118 static char *(vimfiles_dir_choices[]) =
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 "\nCreate plugin directories:",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 "No",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 "In the VIM directory",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 "In your HOME directory",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
126 // non-zero when selected to install the popup menu entry.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 static int install_popup = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
129 // non-zero when selected to install the "Open with" entry.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 static int install_openwith = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
132 // non-zero when need to add an uninstall entry in the registry
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 static int need_uninstall_entry = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 * Definitions of the directory name (under $VIM) of the vimfiles directory
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 * and its subdirectories:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 static char *(vimfiles_subdirs[]) =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 "colors",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 "compiler",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 "doc",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 "ftdetect",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 "ftplugin",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 "indent",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 "keymap",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 "plugin",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 "syntax",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 * Obtain a choice from a table.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 * First entry is a question, others are choices.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 get_choice(char **table, int entries)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 int answer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 char dummy[100];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 for (idx = 0; idx < entries; ++idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 if (idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 printf("%2d ", idx);
12708
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
169 puts(table[idx]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 printf("Choice: ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 if (scanf("%d", &answer) != 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 scanf("%99s", dummy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 answer = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 while (answer < 1 || answer >= entries);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 return answer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 * Check if the user unpacked the archives properly.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 * Sets "runtimeidx".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 check_unpack(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 char buf[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 struct stat st;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
194 // check for presence of the correct version number in installdir[]
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 runtimeidx = strlen(installdir) - strlen(VIM_VERSION_NODOT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 if (runtimeidx <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 || stricmp(installdir + runtimeidx, VIM_VERSION_NODOT) != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 || (installdir[runtimeidx - 1] != '/'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 && installdir[runtimeidx - 1] != '\\'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 printf("ERROR: Install program not in directory \"%s\"\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 VIM_VERSION_NODOT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 printf("This program can only work when it is located in its original directory\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 myexit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
207 // check if filetype.vim is present, which means the runtime archive has
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
208 // been unpacked
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 sprintf(buf, "%s\\filetype.vim", installdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 if (stat(buf, &st) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 printf("ERROR: Cannot find filetype.vim in \"%s\"\n", installdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 printf("It looks like you did not unpack the runtime archive.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 printf("You must unpack the runtime archive \"vim%srt.zip\" before installing.\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 VIM_VERSION_NODOT + 3);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 myexit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
219 // Check if vim.exe or gvim.exe is in the current directory.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 if ((fd = fopen("gvim.exe", "r")) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 has_gvim = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 if ((fd = fopen("vim.exe", "r")) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 has_vim = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 if (!has_gvim && !has_vim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 printf("ERROR: Cannot find any Vim executables in \"%s\"\n\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 installdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 myexit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 * Compare paths "p[plen]" to "q[qlen]". Return 0 if they match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 * Ignores case and differences between '/' and '\'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 * "plen" and "qlen" can be negative, strlen() is used then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 pathcmp(char *p, int plen, char *q, int qlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 if (plen < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 plen = strlen(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 if (qlen < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 qlen = strlen(q);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 for (i = 0; ; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
254 // End of "p": check if "q" also ends or just has a slash.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 if (i == plen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
257 if (i == qlen) // match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 if (i == qlen - 1 && (q[i] == '\\' || q[i] == '/'))
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
260 return 0; // match with trailing slash
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
261 return 1; // no match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
264 // End of "q": check if "p" also ends or just has a slash.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 if (i == qlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
267 if (i == plen) // match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 if (i == plen - 1 && (p[i] == '\\' || p[i] == '/'))
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
270 return 0; // match with trailing slash
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
271 return 1; // no match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 if (!(mytoupper(p[i]) == mytoupper(q[i])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 || ((p[i] == '/' || p[i] == '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 && (q[i] == '/' || q[i] == '\\'))))
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
277 return 1; // no match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 }
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
279 //NOTREACHED
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 * If the executable "**destination" is in the install directory, find another
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 * one in $PATH.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 * On input "**destination" is the path of an executable in allocated memory
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 * (or NULL).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 * "*destination" is set to NULL or the location of the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 findoldfile(char **destination)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 char *bp = *destination;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 size_t indir_l = strlen(installdir);
15758
675dd5d7afb3 patch 8.1.0886: compiler warning for NULL pointer and condition always true
Bram Moolenaar <Bram@vim.org>
parents: 15438
diff changeset
294 char *cp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 char *tmpname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 char *farname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 * No action needed if exe not found or not in this directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 */
15758
675dd5d7afb3 patch 8.1.0886: compiler warning for NULL pointer and condition always true
Bram Moolenaar <Bram@vim.org>
parents: 15438
diff changeset
301 if (bp == NULL || strnicmp(bp, installdir, indir_l) != 0)
675dd5d7afb3 patch 8.1.0886: compiler warning for NULL pointer and condition always true
Bram Moolenaar <Bram@vim.org>
parents: 15438
diff changeset
302 return;
675dd5d7afb3 patch 8.1.0886: compiler warning for NULL pointer and condition always true
Bram Moolenaar <Bram@vim.org>
parents: 15438
diff changeset
303 cp = bp + indir_l;
675dd5d7afb3 patch 8.1.0886: compiler warning for NULL pointer and condition always true
Bram Moolenaar <Bram@vim.org>
parents: 15438
diff changeset
304 if (strchr("/\\", *cp++) == NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 || strchr(cp, '\\') != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 || strchr(cp, '/') != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308
16782
fc58fee685e2 patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents: 16606
diff changeset
309 tmpname = alloc(strlen(cp) + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 strcpy(tmpname, cp);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
311 tmpname[strlen(tmpname) - 1] = 'x'; // .exe -> .exx
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 if (access(tmpname, 0) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 printf("\nERROR: %s and %s clash. Remove or rename %s.\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 tmpname, cp, tmpname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 myexit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 if (rename(cp, tmpname) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 printf("\nERROR: failed to rename %s to %s: %s\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 cp, tmpname, strerror(0));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 myexit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 farname = searchpath_save(cp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 if (rename(tmpname, cp) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 printf("\nERROR: failed to rename %s back to %s: %s\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 tmpname, cp, strerror(0));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 myexit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 free(*destination);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 free(tmpname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 *destination = farname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 * Check if there is a vim.[exe|bat|, gvim.[exe|bat|, etc. in the path.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 * When "check_bat_only" is TRUE, only find "default_bat_dir".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 find_bat_exe(int check_bat_only)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
350 // avoid looking in the "installdir" by chdir to system root
806
de6d169fe745 updated for version 7.0b01
vimboss
parents: 800
diff changeset
351 mch_chdir(sysdrive);
de6d169fe745 updated for version 7.0b01
vimboss
parents: 800
diff changeset
352 mch_chdir("\\");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 for (i = 1; i < TARGET_COUNT; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 targets[i].oldbat = searchpath_save(targets[i].batname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 if (!check_bat_only)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 targets[i].oldexe = searchpath_save(targets[i].exename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 if (default_bat_dir == NULL && targets[i].oldbat != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 default_bat_dir = alloc(strlen(targets[i].oldbat) + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 strcpy(default_bat_dir, targets[i].oldbat);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 remove_tail(default_bat_dir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 if (check_bat_only && targets[i].oldbat != NULL)
806
de6d169fe745 updated for version 7.0b01
vimboss
parents: 800
diff changeset
367 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 free(targets[i].oldbat);
806
de6d169fe745 updated for version 7.0b01
vimboss
parents: 800
diff changeset
369 targets[i].oldbat = NULL;
de6d169fe745 updated for version 7.0b01
vimboss
parents: 800
diff changeset
370 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 mch_chdir(installdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 * Get the value of $VIMRUNTIME or $VIM and write it in $TEMP/vimini.ini, so
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 * that NSIS can read it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 * When not set, use the directory of a previously installed Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 get_vim_env(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 char *vim;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 char buf[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 char fname[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
389 // First get $VIMRUNTIME. If it's set, remove the tail.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 vim = getenv("VIMRUNTIME");
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
391 if (vim != NULL && *vim != 0 && strlen(vim) < sizeof(buf))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 strcpy(buf, vim);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 remove_tail(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 vim = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 vim = getenv("VIM");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 if (vim == NULL || *vim == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
402 // Use the directory from an old uninstall entry.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 if (default_vim_dir != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 vim = default_vim_dir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 else
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
406 // Let NSIS know there is no default, it should use
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
407 // $PROGRAMFILES.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 vim = "";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
412 // NSIS also uses GetTempPath(), thus we should get the same directory
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
413 // name as where NSIS will look for vimini.ini.
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
414 GetTempPath(sizeof(fname) - 12, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 add_pathsep(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 strcat(fname, "vimini.ini");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 fd = fopen(fname, "w");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 if (fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
421 // Make it look like an .ini file, so that NSIS can read it with a
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
422 // ReadINIStr command.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 fprintf(fd, "[vimini]\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 fprintf(fd, "dir=\"%s\"\n", vim);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 printf("Failed to open %s\n", fname);
2287
573da4dac306 Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents: 2286
diff changeset
430 sleep(2);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433
2220
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
434 static int num_windows;
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
435
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
436 /*
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
437 * Callback used for EnumWindows():
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
438 * Count the window if the title looks like it is for the uninstaller.
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
439 */
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
440 //ARGSUSED
2220
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
441 static BOOL CALLBACK
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
442 window_cb(HWND hwnd, LPARAM lparam)
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
443 {
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
444 char title[256];
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
445
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
446 title[0] = 0;
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
447 GetWindowText(hwnd, title, 256);
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
448 if (strstr(title, "Vim ") != NULL && strstr(title, " Uninstall") != NULL)
2220
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
449 ++num_windows;
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
450 return TRUE;
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
451 }
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
452
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 /*
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
454 * Run the uninstaller silently.
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
455 */
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
456 static int
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
457 run_silent_uninstall(char *uninst_exe)
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
458 {
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
459 char vimrt_dir[BUFSIZE];
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
460 char temp_uninst[BUFSIZE];
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
461 char temp_dir[MAX_PATH];
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
462 char buf[BUFSIZE * 2 + 10];
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
463 int i;
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
464 DWORD tick;
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
465
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
466 strcpy(vimrt_dir, uninst_exe);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
467 remove_tail(vimrt_dir);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
468
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
469 if (!GetTempPath(sizeof(temp_dir), temp_dir))
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
470 return FAIL;
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
471
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
472 // Copy the uninstaller to a temporary exe.
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
473 tick = GetTickCount();
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
474 for (i = 0; ; i++)
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
475 {
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
476 sprintf(temp_uninst, "%s\\vimun%04X.exe", temp_dir,
15438
79b56abd37c6 patch 8.1.0727: compiler warning for sprintf() argument
Bram Moolenaar <Bram@vim.org>
parents: 15213
diff changeset
477 (unsigned int)((i + tick) & 0xFFFF));
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
478 if (CopyFile(uninst_exe, temp_uninst, TRUE))
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
479 break;
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
480 if (GetLastError() != ERROR_FILE_EXISTS)
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
481 return FAIL;
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
482 if (i == 65535)
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
483 return FAIL;
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
484 }
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
485
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
486 // Run the copied uninstaller silently.
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
487 if (strchr(temp_uninst, ' ') != NULL)
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
488 sprintf(buf, "\"%s\" /S _?=%s", temp_uninst, vimrt_dir);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
489 else
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
490 sprintf(buf, "%s /S _?=%s", temp_uninst, vimrt_dir);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
491 run_command(buf);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
492
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
493 DeleteFile(temp_uninst);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
494 return OK;
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
495 }
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
496
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
497 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 * Check for already installed Vims.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 * Return non-zero when found one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 static int
2217
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
502 uninstall_check(int skip_question)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 HKEY key_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 HKEY uninstall_key_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 char *uninstall_key = "software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 char subkey_name_buff[BUFSIZE];
15892
e43b5e6d9190 patch 8.1.0952: compilation warnings when building the MS-Windows installer
Bram Moolenaar <Bram@vim.org>
parents: 15758
diff changeset
508 char temp_string_buffer[BUFSIZE-2];
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
509 DWORD local_bufsize;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 FILETIME temp_pfiletime;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 DWORD key_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 char input;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 long code;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 DWORD value_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 DWORD orig_num_keys;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 DWORD new_num_keys;
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
517 DWORD allow_silent;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 int foundone = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519
2449
943280505f72 Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents: 2448
diff changeset
520 code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, uninstall_key, 0,
943280505f72 Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents: 2448
diff changeset
521 KEY_WOW64_64KEY | KEY_READ, &key_handle);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 CHECK_REG_ERROR(code);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
524 key_index = 0;
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
525 while (TRUE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 {
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
527 local_bufsize = sizeof(subkey_name_buff);
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
528 if (RegEnumKeyEx(key_handle, key_index, subkey_name_buff, &local_bufsize,
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
529 NULL, NULL, NULL, &temp_pfiletime) == ERROR_NO_MORE_ITEMS)
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
530 break;
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
531
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 if (strncmp("Vim", subkey_name_buff, 3) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
534 // Open the key named Vim*
2449
943280505f72 Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents: 2448
diff changeset
535 code = RegOpenKeyEx(key_handle, subkey_name_buff, 0,
943280505f72 Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents: 2448
diff changeset
536 KEY_WOW64_64KEY | KEY_READ, &uninstall_key_handle);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 CHECK_REG_ERROR(code);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
539 // get the DisplayName out of it to show the user
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
540 local_bufsize = sizeof(temp_string_buffer);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 code = RegQueryValueEx(uninstall_key_handle, "displayname", 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 &value_type, (LPBYTE)temp_string_buffer,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 &local_bufsize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 CHECK_REG_ERROR(code);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
546 allow_silent = 0;
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
547 if (skip_question)
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
548 {
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
549 DWORD varsize = sizeof(DWORD);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
550
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
551 RegQueryValueEx(uninstall_key_handle, "AllowSilent", 0,
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
552 &value_type, (LPBYTE)&allow_silent,
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
553 &varsize);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
554 }
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
555
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 foundone = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 printf("\n*********************************************************\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 printf("Vim Install found what looks like an existing Vim version.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 printf("The name of the entry is:\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 printf("\n \"%s\"\n\n", temp_string_buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 printf("Installing the new version will disable part of the existing version.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 printf("(The batch files used in a console and the \"Edit with Vim\" entry in\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 printf("the popup menu will use the new version)\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565
2217
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
566 if (skip_question)
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
567 printf("\nRunning uninstall program for \"%s\"\n", temp_string_buffer);
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
568 else
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
569 printf("\nDo you want to uninstall \"%s\" now?\n(y)es/(n)o) ", temp_string_buffer);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 fflush(stdout);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
572 // get the UninstallString
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
573 local_bufsize = sizeof(temp_string_buffer);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 code = RegQueryValueEx(uninstall_key_handle, "uninstallstring", 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 &value_type, (LPBYTE)temp_string_buffer, &local_bufsize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 CHECK_REG_ERROR(code);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
578 // Remember the directory, it is used as the default for NSIS.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 default_vim_dir = alloc(strlen(temp_string_buffer) + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 strcpy(default_vim_dir, temp_string_buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 remove_tail(default_vim_dir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 remove_tail(default_vim_dir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 input = 'n';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 if (input != 'n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 printf("%c is an invalid reply. Please enter either 'y' or 'n'\n", input);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589
2217
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
590 if (skip_question)
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
591 input = 'y';
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
592 else
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
593 {
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
594 rewind(stdin);
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
595 scanf("%c", &input);
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
596 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 switch (input)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 case 'y':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 case 'Y':
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
601 // save the number of uninstall keys so we can know if
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
602 // it changed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 RegQueryInfoKey(key_handle, NULL, NULL, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 &orig_num_keys, NULL, NULL, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 NULL, NULL, NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
607 // Find existing .bat files before deleting them.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 find_bat_exe(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
610 if (allow_silent)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 {
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
612 if (run_silent_uninstall(temp_string_buffer)
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
613 == FAIL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
614 allow_silent = 0; // Retry with non silent.
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
615 }
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
616 if (!allow_silent)
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
617 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
618 // Execute the uninstall program. Put it in double
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
619 // quotes if there is an embedded space.
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
620 {
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
621 char buf[BUFSIZE];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
623 if (strchr(temp_string_buffer, ' ') != NULL)
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
624 sprintf(buf, "\"%s\"", temp_string_buffer);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
625 else
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
626 strcpy(buf, temp_string_buffer);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
627 run_command(buf);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
628 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
630 // Count the number of windows with a title that
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
631 // match the installer, so that we can check when
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
632 // it's done. The uninstaller copies itself,
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
633 // executes the copy and exits, thus we can't wait
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
634 // for the process to finish.
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
635 sleep(1); // wait for uninstaller to start up
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
636 num_windows = 0;
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
637 EnumWindows(window_cb, 0);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
638 if (num_windows == 0)
2220
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
639 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
640 // Did not find the uninstaller, ask user to
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
641 // press Enter when done. Just in case.
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
642 printf("Press Enter when the uninstaller is finished\n");
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
643 rewind(stdin);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
644 (void)getchar();
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
645 }
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
646 else
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
647 {
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
648 printf("Waiting for the uninstaller to finish (press CTRL-C to abort).");
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
649 do
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
650 {
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
651 printf(".");
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
652 fflush(stdout);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
653 sleep(1); // wait for the uninstaller to
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
654 // finish
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
655 num_windows = 0;
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
656 EnumWindows(window_cb, 0);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
657 } while (num_windows > 0);
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
658 }
2220
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
659 }
b1c70c500de4 Found a way to make the MS-Windows installer wait for the uninstaller to
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
660 printf("\nDone!\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
662 // Check if an uninstall reg key was deleted.
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
663 // if it was, we want to decrement key_index.
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
664 // if we don't do this, we will skip the key
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
665 // immediately after any key that we delete.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 RegQueryInfoKey(key_handle, NULL, NULL, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 &new_num_keys, NULL, NULL, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 NULL, NULL, NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 if (new_num_keys < orig_num_keys)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 key_index--;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 input = 'y';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 case 'n':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 case 'N':
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
677 // Do not uninstall
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 input = 'n';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
681 default: // just drop through and redo the loop
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 } while (input != 'n' && input != 'y');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 RegCloseKey(uninstall_key_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 }
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
689
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
690 key_index++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 RegCloseKey(key_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 return foundone;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 * Find out information about the system.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 inspect_system(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 char buf[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 int foundone;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
709 // This may take a little while, let the user know what we're doing.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 printf("Inspecting system...\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 * If $VIM is set, check that it's pointing to our directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 p = getenv("VIM");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 if (p != NULL && pathcmp(p, -1, installdir, runtimeidx - 1) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 printf("------------------------------------------------------\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 printf("$VIM is set to \"%s\".\n", p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 printf("This is different from where this version of Vim is:\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 strcpy(buf, installdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 *(buf + runtimeidx - 1) = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 printf("\"%s\"\n", buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 printf("You must adjust or remove the setting of $VIM,\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 if (interactive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 printf("to be able to use this install program.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 myexit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 printf("otherwise Vim WILL NOT WORK properly!\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 printf("------------------------------------------------------\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 * If $VIMRUNTIME is set, check that it's pointing to our runtime directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 p = getenv("VIMRUNTIME");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 if (p != NULL && pathcmp(p, -1, installdir, -1) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 printf("------------------------------------------------------\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 printf("$VIMRUNTIME is set to \"%s\".\n", p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 printf("This is different from where this version of Vim is:\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 printf("\"%s\"\n", installdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 printf("You must adjust or remove the setting of $VIMRUNTIME,\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 if (interactive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 printf("to be able to use this install program.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 myexit(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 printf("otherwise Vim WILL NOT WORK properly!\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 printf("------------------------------------------------------\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 * Check if there is a vim.[exe|bat|, gvim.[exe|bat|, etc. in the path.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 find_bat_exe(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 * A .exe in the install directory may be found anyway on Windows 2000.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 * Check for this situation and find another executable if necessary.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 * w.briscoe@ponl.com 2001-01-20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 foundone = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 for (i = 1; i < TARGET_COUNT; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 findoldfile(&(targets[i].oldexe));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 if (targets[i].oldexe != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 foundone = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 if (foundone)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 printf("Warning: Found Vim executable(s) in your $PATH:\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 for (i = 1; i < TARGET_COUNT; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 if (targets[i].oldexe != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 printf("%s\n", targets[i].oldexe);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 printf("It will be used instead of the version you are installing.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 printf("Please delete or rename it, or adjust your $PATH setting.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 * Check if there is an existing ../_vimrc or ../.vimrc file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 strcpy(oldvimrc, installdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 strcpy(oldvimrc + runtimeidx, "_vimrc");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 if ((fd = fopen(oldvimrc, "r")) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
789 strcpy(oldvimrc + runtimeidx, "vimrc~1"); // short version of .vimrc
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 if ((fd = fopen(oldvimrc, "r")) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 strcpy(oldvimrc + runtimeidx, ".vimrc");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 fd = fopen(oldvimrc, "r");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 if (fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 *oldvimrc = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 * Add a dummy choice to avoid that the numbering changes depending on items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 * in the environment. The user may type a number he remembered without
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 * looking.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 add_dummy_choice(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 choices[choice_count].installfunc = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 choices[choice_count].active = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 choices[choice_count].changefunc = NULL;
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
813 choices[choice_count].text = NULL;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
814 choices[choice_count].arg = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
818 ////////////////////////////////////////////////
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
819 // stuff for creating the batch files.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 * Install the vim.bat, gvim.bat, etc. files.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 install_bat_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 char *batpath = targets[choices[idx].arg].batpath;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 char *oldname = targets[choices[idx].arg].oldbat;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 char *exename = targets[choices[idx].arg].exenamearg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 char *vimarg = targets[choices[idx].arg].exearg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 if (*batpath != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 fd = fopen(batpath, "w");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 if (fd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 need_uninstall_entry = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 fprintf(fd, "@echo off\n");
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
843 fprintf(fd, "rem -- Run Vim --\n");
19431
9800e126eaa2 patch 8.2.0273: MS-Windows uninstall may delete wrong batch file
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
844 fprintf(fd, VIMBAT_UNINSTKEY "\n");
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
845 fprintf(fd, "\n");
8789
667da8443275 commit https://github.com/vim/vim/commit/e609ad557c15e3e5d1e9ace2c578f48c5589c488
Christian Brabandt <cb@256bit.org>
parents: 5508
diff changeset
846 fprintf(fd, "setlocal\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
848 /*
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
849 * Don't use double quotes for the "set" argument, also when it
19762
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
850 * contains a space. The quotes would be included in the value.
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
851 * The order of preference is:
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
852 * 1. $VIMRUNTIME/vim.exe (user preference)
16162
cd5c83115ec6 patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents: 15941
diff changeset
853 * 2. $VIM/vim81/vim.exe (hard coded version)
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
854 * 3. installdir/vim.exe (hard coded install directory)
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
855 */
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
856 fprintf(fd, "set VIM_EXE_DIR=%s\n", installdir);
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
857 fprintf(fd, "if exist \"%%VIM%%\\%s\\%s\" set VIM_EXE_DIR=%%VIM%%\\%s\n",
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
858 VIM_VERSION_NODOT, exename, VIM_VERSION_NODOT);
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
859 fprintf(fd, "if exist \"%%VIMRUNTIME%%\\%s\" set VIM_EXE_DIR=%%VIMRUNTIME%%\n", exename);
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
860 fprintf(fd, "\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
862 // Give an error message when the executable could not be found.
19762
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
863 fprintf(fd, "if not exist \"%%VIM_EXE_DIR%%\\%s\" (\n", exename);
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
864 fprintf(fd, " echo \"%%VIM_EXE_DIR%%\\%s\" not found\n", exename);
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
865 fprintf(fd, " goto :eof\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
866 fprintf(fd, ")\n");
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
867 fprintf(fd, "\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 if (*exename == 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 {
19762
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
871 fprintf(fd, "rem check --nofork argument\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
872 fprintf(fd, "set VIMNOFORK=\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
873 fprintf(fd, ":loopstart\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
874 fprintf(fd, "if .%%1==. goto loopend\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
875 fprintf(fd, "if .%%1==.--nofork (\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
876 fprintf(fd, " set VIMNOFORK=1\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
877 fprintf(fd, ") else if .%%1==.-f (\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
878 fprintf(fd, " set VIMNOFORK=1\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
879 fprintf(fd, ")\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
880 fprintf(fd, "shift\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
881 fprintf(fd, "goto loopstart\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
882 fprintf(fd, ":loopend\n");
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
883 fprintf(fd, "\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 if (*exename == 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 {
19762
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
888 // For gvim.exe use "start /b" to avoid that the console window
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
889 // stays open.
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
890 fprintf(fd, "if .%%VIMNOFORK%%==.1 (\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
891 fprintf(fd, " start \"dummy\" /b /wait ");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
892 // Always use quotes, $VIM or $VIMRUNTIME might have a space.
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
893 fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
894 exename, vimarg);
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
895 fprintf(fd, ") else (\n");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
896 fprintf(fd, " start \"dummy\" /b ");
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
897 // Always use quotes, $VIM or $VIMRUNTIME might have a space.
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
898 fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
899 exename, vimarg);
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
900 fprintf(fd, ")\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 }
19762
b97112a4e3e4 patch 8.2.0437: MS-Windows installer contains old stuff
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
902 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
904 // Always use quotes, $VIM or $VIMRUNTIME might have a space.
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
905 fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
d20041a02ee5 updated for version 7.0228
vimboss
parents: 640
diff changeset
906 exename, vimarg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 printf("%s has been %s\n", batpath,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 oldname == NULL ? "created" : "overwritten");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 * Make the text string for choice "idx".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 * The format "fmt" is must have one %s item, which "arg" is used for.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 alloc_text(int idx, char *fmt, char *arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 if (choices[idx].text != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 free(choices[idx].text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925
16782
fc58fee685e2 patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents: 16606
diff changeset
926 choices[idx].text = alloc(strlen(fmt) + strlen(arg) - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 sprintf(choices[idx].text, fmt, arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 * Toggle the "Overwrite .../vim.bat" to "Don't overwrite".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 toggle_bat_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 char *batname = targets[choices[idx].arg].batpath;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 char *oldname = targets[choices[idx].arg].oldbat;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 if (*batname == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 alloc_text(idx, " Overwrite %s", oldname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 strcpy(batname, oldname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 alloc_text(idx, " Do NOT overwrite %s", oldname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 *batname = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 * Do some work for a batch file entry: Append the batch file name to the path
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 * and set the text for the choice.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 set_bat_text(int idx, char *batpath, char *name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 strcat(batpath, name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 alloc_text(idx, " Create %s", batpath);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 * Select a directory to write the batch file line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 change_bat_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 char *path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 char *batpath;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 char *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 char *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 char **names = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 int target = choices[idx].arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 name = targets[target].batname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 batpath = targets[target].batpath;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 path = getenv("PATH");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 if (path == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 printf("\nERROR: The variable $PATH is not set\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 * first round: count number of names in path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 * second round: save names to names[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 for (p = path; *p; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 s = strchr(p, ';');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 if (s == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 s = p + strlen(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 if (names != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 {
16782
fc58fee685e2 patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents: 16606
diff changeset
1004 names[count] = alloc(s - p + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 strncpy(names[count], p, s - p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 names[count][s - p] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 ++count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 p = s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 if (*p != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 if (names != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 break;
16782
fc58fee685e2 patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents: 16606
diff changeset
1015 names = alloc((count + 1) * sizeof(char *));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 names[0] = alloc(50);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 sprintf(names[0], "Select directory to create %s in:", name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 names[count] = alloc(50);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 if (choices[idx].arg == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 sprintf(names[count], "Do not create any .bat file.");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 sprintf(names[count], "Do not create a %s file.", name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 n = get_choice(names, count + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 if (n == count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1028 // Selected last item, don't create bat file.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 *batpath = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 if (choices[idx].arg != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 alloc_text(idx, " Do NOT create %s", name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1035 // Selected one of the paths. For the first item only keep the path,
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1036 // for the others append the batch file name.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 strcpy(batpath, names[n]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 add_pathsep(batpath);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 if (choices[idx].arg != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 set_bat_text(idx, batpath, name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 for (i = 0; i <= count; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 free(names[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 free(names);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 char *bat_text_yes = "Install .bat files to use Vim at the command line:";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 char *bat_text_no = "do NOT install .bat files to use Vim at the command line";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 change_main_bat_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1056 // let the user select a default directory or NONE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 change_bat_choice(idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 if (targets[0].batpath[0] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 choices[idx].text = bat_text_yes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 choices[idx].text = bat_text_no;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1064 // update the individual batch file selections
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 for (i = 1; i < TARGET_COUNT; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1067 // Only make it active when the first item has a path and the vim.exe
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1068 // or gvim.exe exists (there is a changefunc then).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 if (targets[0].batpath[0] != NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 && choices[idx + i].changefunc != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 choices[idx + i].active = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 if (choices[idx + i].changefunc == change_bat_choice
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 && targets[i].batpath[0] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 strcpy(targets[i].batpath, targets[0].batpath);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 set_bat_text(idx + i, targets[i].batpath, targets[i].batname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 choices[idx + i].active = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 * Initialize a choice for creating a batch file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 init_bat_choice(int target)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 char *batpath = targets[target].batpath;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 char *oldbat = targets[target].oldbat;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 choices[choice_count].arg = target;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 choices[choice_count].installfunc = install_bat_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 choices[choice_count].active = 1;
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1099 choices[choice_count].text = NULL; // will be set below
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 if (oldbat != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1102 // A [g]vim.bat exists: Only choice is to overwrite it or not.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 choices[choice_count].changefunc = toggle_bat_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 *batpath = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 toggle_bat_choice(choice_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 if (default_bat_dir != NULL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1110 // Prefer using the same path as an existing .bat file.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 strcpy(batpath, default_bat_dir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1114 // No [g]vim.bat exists: Write it to a directory in $PATH. Use
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1115 // $WINDIR by default, if it's empty the first item in $PATH.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 p = getenv("WINDIR");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 if (p != NULL && *p != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 strcpy(batpath, p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 p = getenv("PATH");
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1122 if (p == NULL || *p == NUL) // "cannot happen"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 strcpy(batpath, "C:/Windows");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 while (*p != NUL && *p != ';')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 batpath[i++] = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 batpath[i] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 add_pathsep(batpath);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 set_bat_text(choice_count, batpath, targets[target].batname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 choices[choice_count].changefunc = change_bat_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 * Set up the choices for installing .bat files.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 * For these items "arg" is the index in targets[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 init_bat_choices(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1150 // The first item is used to switch installing batch files on/off and
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1151 // setting the default path.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 choices[choice_count].text = bat_text_yes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 choices[choice_count].changefunc = change_main_bat_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 choices[choice_count].installfunc = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 choices[choice_count].active = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 choices[choice_count].arg = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1159 // Add items for each batch file target. Only used when not disabled by
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1160 // the first item. When a .exe exists, don't offer to create a .bat.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 for (i = 1; i < TARGET_COUNT; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 if (targets[i].oldexe == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 && (targets[i].exenamearg[0] == 'g' ? has_gvim : has_vim))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 init_bat_choice(i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 add_dummy_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 * Install the vimrc file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 install_vimrc(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 FILE *fd, *tfd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 char *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1178 // If an old vimrc file exists, overwrite it.
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1179 // Otherwise create a new one.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 if (*oldvimrc != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 fname = oldvimrc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 fname = vimrc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 fd = fopen(fname, "w");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 if (fd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 printf("\nERROR: Cannot open \"%s\" for writing.\n", fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 switch (compat_choice)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 case compat_vi:
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1194 fprintf(fd, "\" Vi compatible\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 fprintf(fd, "set compatible\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 break;
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1197 case compat_vim:
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1198 fprintf(fd, "\" Vim's default behavior\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1199 fprintf(fd, "if &compatible\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1200 fprintf(fd, " set nocompatible\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1201 fprintf(fd, "endif\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1202 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 case compat_some_enhancements:
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1204 fprintf(fd, "\" Vim with some enhancements\n");
9680
1b8932823a02 commit https://github.com/vim/vim/commit/c73e4474b1f1b5b18a8d504eec5305e0c77981f7
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
1205 fprintf(fd, "source $VIMRUNTIME/defaults.vim\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 case compat_all_enhancements:
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1208 fprintf(fd, "\" Vim with all enhancements\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 fprintf(fd, "source $VIMRUNTIME/vimrc_example.vim\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 switch (remap_choice)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 case remap_no:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 case remap_win:
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1217 fprintf(fd, "\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1218 fprintf(fd, "\" Remap a few keys for Windows behavior\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 fprintf(fd, "source $VIMRUNTIME/mswin.vim\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 switch (mouse_choice)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 case mouse_xterm:
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1225 fprintf(fd, "\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1226 fprintf(fd, "\" Mouse behavior (the Unix way)\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 fprintf(fd, "behave xterm\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 case mouse_mswin:
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1230 fprintf(fd, "\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1231 fprintf(fd, "\" Mouse behavior (the Windows way)\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 fprintf(fd, "behave mswin\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 break;
12708
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
1234 case mouse_default:
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
1235 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 if ((tfd = fopen("diff.exe", "r")) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1239 // Use the diff.exe that comes with the self-extracting gvim.exe.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 fclose(tfd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 fprintf(fd, "\n");
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1242 fprintf(fd, "\" Use the internal diff if available.\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1243 fprintf(fd, "\" Otherwise use the special 'diffexpr' for Windows.\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1244 fprintf(fd, "if &diffopt !~# 'internal'\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1245 fprintf(fd, " set diffexpr=MyDiff()\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1246 fprintf(fd, "endif\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 fprintf(fd, "function MyDiff()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 fprintf(fd, " let opt = '-a --binary '\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 fprintf(fd, " if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 fprintf(fd, " if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif\n");
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1251 // Use quotes only when needed, they may cause trouble.
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1252 // Always escape "!".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 fprintf(fd, " let arg1 = v:fname_in\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 fprintf(fd, " if arg1 =~ ' ' | let arg1 = '\"' . arg1 . '\"' | endif\n");
13917
f6dcc1a8d584 patch 8.0.1829: MS-Windows: script for vimdiff can't handle ! chars
Christian Brabandt <cb@256bit.org>
parents: 13632
diff changeset
1255 fprintf(fd, " let arg1 = substitute(arg1, '!', '\\!', 'g')\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 fprintf(fd, " let arg2 = v:fname_new\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 fprintf(fd, " if arg2 =~ ' ' | let arg2 = '\"' . arg2 . '\"' | endif\n");
13917
f6dcc1a8d584 patch 8.0.1829: MS-Windows: script for vimdiff can't handle ! chars
Christian Brabandt <cb@256bit.org>
parents: 13632
diff changeset
1258 fprintf(fd, " let arg2 = substitute(arg2, '!', '\\!', 'g')\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 fprintf(fd, " let arg3 = v:fname_out\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 fprintf(fd, " if arg3 =~ ' ' | let arg3 = '\"' . arg3 . '\"' | endif\n");
13917
f6dcc1a8d584 patch 8.0.1829: MS-Windows: script for vimdiff can't handle ! chars
Christian Brabandt <cb@256bit.org>
parents: 13632
diff changeset
1261 fprintf(fd, " let arg3 = substitute(arg3, '!', '\\!', 'g')\n");
640
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 419
diff changeset
1262
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1263 // If the path has a space: When using cmd.exe (Win NT/2000/XP) put
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1264 // quotes around the diff command and rely on the default value of
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1265 // shellxquote to solve the quoting problem for the whole command.
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1266 //
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1267 // Otherwise put a double quote just before the space and at the
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1268 // end of the command. Putting quotes around the whole thing
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1269 // doesn't work on Win 95/98/ME. This is mostly guessed!
640
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 419
diff changeset
1270 fprintf(fd, " if $VIMRUNTIME =~ ' '\n");
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 419
diff changeset
1271 fprintf(fd, " if &sh =~ '\\<cmd'\n");
5508
4db151014f93 updated for version 7.4.103
Bram Moolenaar <bram@vim.org>
parents: 5454
diff changeset
1272 fprintf(fd, " if empty(&shellxquote)\n");
4db151014f93 updated for version 7.4.103
Bram Moolenaar <bram@vim.org>
parents: 5454
diff changeset
1273 fprintf(fd, " let l:shxq_sav = ''\n");
4db151014f93 updated for version 7.4.103
Bram Moolenaar <bram@vim.org>
parents: 5454
diff changeset
1274 fprintf(fd, " set shellxquote&\n");
4db151014f93 updated for version 7.4.103
Bram Moolenaar <bram@vim.org>
parents: 5454
diff changeset
1275 fprintf(fd, " endif\n");
4db151014f93 updated for version 7.4.103
Bram Moolenaar <bram@vim.org>
parents: 5454
diff changeset
1276 fprintf(fd, " let cmd = '\"' . $VIMRUNTIME . '\\diff\"'\n");
640
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 419
diff changeset
1277 fprintf(fd, " else\n");
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 419
diff changeset
1278 fprintf(fd, " let cmd = substitute($VIMRUNTIME, ' ', '\" ', '') . '\\diff\"'\n");
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 419
diff changeset
1279 fprintf(fd, " endif\n");
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 419
diff changeset
1280 fprintf(fd, " else\n");
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 419
diff changeset
1281 fprintf(fd, " let cmd = $VIMRUNTIME . '\\diff'\n");
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 419
diff changeset
1282 fprintf(fd, " endif\n");
13917
f6dcc1a8d584 patch 8.0.1829: MS-Windows: script for vimdiff can't handle ! chars
Christian Brabandt <cb@256bit.org>
parents: 13632
diff changeset
1283 fprintf(fd, " let cmd = substitute(cmd, '!', '\\!', 'g')\n");
5508
4db151014f93 updated for version 7.4.103
Bram Moolenaar <bram@vim.org>
parents: 5454
diff changeset
1284 fprintf(fd, " silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3\n");
4db151014f93 updated for version 7.4.103
Bram Moolenaar <bram@vim.org>
parents: 5454
diff changeset
1285 fprintf(fd, " if exists('l:shxq_sav')\n");
4db151014f93 updated for version 7.4.103
Bram Moolenaar <bram@vim.org>
parents: 5454
diff changeset
1286 fprintf(fd, " let &shellxquote=l:shxq_sav\n");
4db151014f93 updated for version 7.4.103
Bram Moolenaar <bram@vim.org>
parents: 5454
diff changeset
1287 fprintf(fd, " endif\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 fprintf(fd, "endfunction\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 fprintf(fd, "\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 printf("%s has been written\n", fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 change_vimrc_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 if (choices[idx].installfunc != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1300 // Switch to NOT change or create a vimrc file.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 if (*oldvimrc != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 alloc_text(idx, "Do NOT change startup file %s", oldvimrc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 alloc_text(idx, "Do NOT create startup file %s", vimrc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 choices[idx].installfunc = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 choices[idx + 1].active = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 choices[idx + 2].active = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 choices[idx + 3].active = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1312 // Switch to change or create a vimrc file.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 if (*oldvimrc != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 alloc_text(idx, "Overwrite startup file %s with:", oldvimrc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 alloc_text(idx, "Create startup file %s with:", vimrc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 choices[idx].installfunc = install_vimrc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 choices[idx + 1].active = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 choices[idx + 2].active = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 choices[idx + 3].active = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 * Change the choice how to run Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 change_run_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 compat_choice = get_choice(compat_choices, TABLE_SIZE(compat_choices));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 alloc_text(idx, compat_text, compat_choices[compat_choice]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 * Change the choice if keys are to be remapped.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 change_remap_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 remap_choice = get_choice(remap_choices, TABLE_SIZE(remap_choices));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 alloc_text(idx, remap_text, remap_choices[remap_choice]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 * Change the choice how to select text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 change_mouse_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 mouse_choice = get_choice(mouse_choices, TABLE_SIZE(mouse_choices));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 alloc_text(idx, mouse_text, mouse_choices[mouse_choice]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 init_vimrc_choices(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1357 // set path for a new _vimrc file (also when not used)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 strcpy(vimrc, installdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 strcpy(vimrc + runtimeidx, "_vimrc");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1361 // Set opposite value and then toggle it by calling change_vimrc_choice()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 if (*oldvimrc == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 choices[choice_count].installfunc = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 choices[choice_count].installfunc = install_vimrc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 choices[choice_count].text = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 change_vimrc_choice(choice_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 choices[choice_count].changefunc = change_vimrc_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 choices[choice_count].active = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1372 // default way to run Vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 alloc_text(choice_count, compat_text, compat_choices[compat_choice]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 choices[choice_count].changefunc = change_run_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 choices[choice_count].installfunc = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 choices[choice_count].active = (*oldvimrc == NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1379 // Whether to remap keys
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 alloc_text(choice_count, remap_text , remap_choices[remap_choice]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 choices[choice_count].changefunc = change_remap_choice;
9252
c25898cc99c1 commit https://github.com/vim/vim/commit/945ec093cd4ddefab930239990564b12eb232153
Christian Brabandt <cb@256bit.org>
parents: 8789
diff changeset
1382 choices[choice_count].installfunc = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 choices[choice_count].active = (*oldvimrc == NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1386 // default way to use the mouse
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 alloc_text(choice_count, mouse_text, mouse_choices[mouse_choice]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 choices[choice_count].changefunc = change_mouse_choice;
9252
c25898cc99c1 commit https://github.com/vim/vim/commit/945ec093cd4ddefab930239990564b12eb232153
Christian Brabandt <cb@256bit.org>
parents: 8789
diff changeset
1389 choices[choice_count].installfunc = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 choices[choice_count].active = (*oldvimrc == NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1394 static LONG
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1395 reg_create_key(
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1396 HKEY root,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1397 const char *subkey,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1398 PHKEY phKey,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1399 DWORD flag)
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1400 {
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1401 DWORD disp;
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1402
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1403 *phKey = NULL;
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1404 return RegCreateKeyEx(
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1405 root, subkey,
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1406 0, NULL, REG_OPTION_NON_VOLATILE,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1407 flag | KEY_WRITE,
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1408 NULL, phKey, &disp);
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1409 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1410
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1411 static LONG
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1412 reg_set_string_value(
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1413 HKEY hKey,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1414 const char *value_name,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1415 const char *data)
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1416 {
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1417 return RegSetValueEx(hKey, value_name, 0, REG_SZ,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1418 (LPBYTE)data, (DWORD)(1 + strlen(data)));
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1419 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1420
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1421 static LONG
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1422 reg_create_key_and_value(
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1423 HKEY hRootKey,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1424 const char *subkey,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1425 const char *value_name,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1426 const char *data,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1427 DWORD flag)
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1428 {
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1429 HKEY hKey;
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1430 LONG lRet = reg_create_key(hRootKey, subkey, &hKey, flag);
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1431
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1432 if (ERROR_SUCCESS == lRet)
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1433 {
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1434 lRet = reg_set_string_value(hKey, value_name, data);
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1435 RegCloseKey(hKey);
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1436 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1437 return lRet;
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1438 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1439
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1440 static LONG
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1441 register_inproc_server(
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1442 HKEY hRootKey,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1443 const char *clsid,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1444 const char *extname,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1445 const char *module,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1446 const char *threading_model,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1447 DWORD flag)
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1448 {
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1449 CHAR subkey[BUFSIZE];
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1450 LONG lRet;
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1451
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1452 sprintf(subkey, "CLSID\\%s", clsid);
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1453 lRet = reg_create_key_and_value(hRootKey, subkey, NULL, extname, flag);
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1454 if (ERROR_SUCCESS == lRet)
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1455 {
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1456 sprintf(subkey, "CLSID\\%s\\InProcServer32", clsid);
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1457 lRet = reg_create_key_and_value(hRootKey, subkey, NULL, module, flag);
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1458 if (ERROR_SUCCESS == lRet)
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1459 {
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1460 lRet = reg_create_key_and_value(hRootKey, subkey,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1461 "ThreadingModel", threading_model, flag);
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1462 }
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1463 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1464 return lRet;
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1465 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1466
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1467 static LONG
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1468 register_shellex(
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1469 HKEY hRootKey,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1470 const char *clsid,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1471 const char *name,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1472 const char *exe_path,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1473 DWORD flag)
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1474 {
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1475 LONG lRet = reg_create_key_and_value(
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1476 hRootKey,
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1477 "*\\shellex\\ContextMenuHandlers\\gvim",
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1478 NULL,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1479 clsid,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1480 flag);
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1481
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1482 if (ERROR_SUCCESS == lRet)
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1483 {
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1484 lRet = reg_create_key_and_value(
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1485 HKEY_LOCAL_MACHINE,
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1486 "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1487 clsid,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1488 name,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1489 flag);
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1490
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1491 if (ERROR_SUCCESS == lRet)
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1492 {
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1493 lRet = reg_create_key_and_value(
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1494 HKEY_LOCAL_MACHINE,
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1495 "Software\\Vim\\Gvim",
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1496 "path",
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1497 exe_path,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1498 flag);
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1499 }
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1500 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1501 return lRet;
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1502 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1503
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1504 static LONG
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1505 register_openwith(
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1506 HKEY hRootKey,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1507 const char *exe_path,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1508 DWORD flag)
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1509 {
2448
628147a4b3b2 Fix: on MS-Windows the "open with..." menu starts Vim without a file.
Bram Moolenaar <bram@vim.org>
parents: 2344
diff changeset
1510 char exe_cmd[BUFSIZE];
628147a4b3b2 Fix: on MS-Windows the "open with..." menu starts Vim without a file.
Bram Moolenaar <bram@vim.org>
parents: 2344
diff changeset
1511 LONG lRet;
628147a4b3b2 Fix: on MS-Windows the "open with..." menu starts Vim without a file.
Bram Moolenaar <bram@vim.org>
parents: 2344
diff changeset
1512
2470
481f808ab5e1 Put quotes around the gvim.exe path for the "Open with" menu entry.
Bram Moolenaar <bram@vim.org>
parents: 2449
diff changeset
1513 sprintf(exe_cmd, "\"%s\" \"%%1\"", exe_path);
2448
628147a4b3b2 Fix: on MS-Windows the "open with..." menu starts Vim without a file.
Bram Moolenaar <bram@vim.org>
parents: 2344
diff changeset
1514 lRet = reg_create_key_and_value(
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1515 hRootKey,
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1516 "Applications\\gvim.exe\\shell\\edit\\command",
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1517 NULL,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1518 exe_cmd,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1519 flag);
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1520
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1521 if (ERROR_SUCCESS == lRet)
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1522 {
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1523 int i;
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1524 static const char *openwith[] = {
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1525 ".htm\\OpenWithList\\gvim.exe",
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1526 ".vim\\OpenWithList\\gvim.exe",
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1527 "*\\OpenWithList\\gvim.exe",
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1528 };
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1529
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 19762
diff changeset
1530 for (i = 0; ERROR_SUCCESS == lRet && i < ARRAYSIZE(openwith); i++)
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1531 lRet = reg_create_key_and_value(hRootKey, openwith[i], NULL, "", flag);
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1532 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1533
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1534 return lRet;
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1535 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1536
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1537 static LONG
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1538 register_uninstall(
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1539 HKEY hRootKey,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1540 const char *appname,
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1541 const char *display_name,
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1542 const char *uninstall_string,
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1543 const char *display_icon,
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1544 const char *display_version,
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1545 const char *publisher)
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1546 {
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1547 LONG lRet = reg_create_key_and_value(hRootKey, appname,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1548 "DisplayName", display_name, KEY_WOW64_64KEY);
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1549
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1550 if (ERROR_SUCCESS == lRet)
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1551 lRet = reg_create_key_and_value(hRootKey, appname,
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1552 "UninstallString", uninstall_string, KEY_WOW64_64KEY);
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1553 if (ERROR_SUCCESS == lRet)
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1554 lRet = reg_create_key_and_value(hRootKey, appname,
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1555 "DisplayIcon", display_icon, KEY_WOW64_64KEY);
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1556 if (ERROR_SUCCESS == lRet)
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1557 lRet = reg_create_key_and_value(hRootKey, appname,
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1558 "DisplayVersion", display_version, KEY_WOW64_64KEY);
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1559 if (ERROR_SUCCESS == lRet)
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1560 lRet = reg_create_key_and_value(hRootKey, appname,
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1561 "Publisher", publisher, KEY_WOW64_64KEY);
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1562 return lRet;
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1563 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1564
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 * Add some entries to the registry:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 * - to add "Edit with Vim" to the context * menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 * - to add Vim to the "Open with..." list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 * - to uninstall Vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 */
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1571 //ARGSUSED
2287
573da4dac306 Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents: 2286
diff changeset
1572 static int
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 install_registry(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574 {
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1575 LONG lRet = ERROR_SUCCESS;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 const char *vim_ext_ThreadingModel = "Apartment";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 const char *vim_ext_name = "Vim Shell Extension";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 const char *vim_ext_clsid = "{51EEE242-AD87-11d3-9C1E-0090278BBD99}";
15892
e43b5e6d9190 patch 8.1.0952: compilation warnings when building the MS-Windows installer
Bram Moolenaar <Bram@vim.org>
parents: 15758
diff changeset
1579 char vim_exe_path[MAX_PATH];
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1580 char display_name[BUFSIZE];
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1581 char uninstall_string[BUFSIZE];
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1582 char icon_string[BUFSIZE];
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1583 int i;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1584 int loop_count = is_64bit_os() ? 2 : 1;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1585 DWORD flag;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1587 sprintf(vim_exe_path, "%s\\gvim.exe", installdir);
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1588
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1589 if (install_popup)
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1590 {
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1591 char bufg[BUFSIZE];
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1592
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1593 printf("Creating \"Edit with Vim\" popup menu entry\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1595 for (i = 0; i < loop_count; i++)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1596 {
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1597 if (i == 0)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1598 {
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1599 sprintf(bufg, "%s\\" GVIMEXT32_PATH, installdir);
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1600 flag = KEY_WOW64_32KEY;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1601 }
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1602 else
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1603 {
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1604 sprintf(bufg, "%s\\" GVIMEXT64_PATH, installdir);
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1605 flag = KEY_WOW64_64KEY;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1606 }
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1607
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1608 lRet = register_inproc_server(
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1609 HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1610 bufg, vim_ext_ThreadingModel, flag);
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1611 if (ERROR_SUCCESS != lRet)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1612 return FAIL;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1613 lRet = register_shellex(
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1614 HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1615 vim_exe_path, flag);
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1616 if (ERROR_SUCCESS != lRet)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1617 return FAIL;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1618 }
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1619 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1620
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1621 if (install_openwith)
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1622 {
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1623 printf("Creating \"Open with ...\" list entry\n");
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1624
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1625 for (i = 0; i < loop_count; i++)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1626 {
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1627 if (i == 0)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1628 flag = KEY_WOW64_32KEY;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1629 else
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1630 flag = KEY_WOW64_64KEY;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1631
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1632 lRet = register_openwith(HKEY_CLASSES_ROOT, vim_exe_path, flag);
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1633 if (ERROR_SUCCESS != lRet)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1634 return FAIL;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1635 }
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1636 }
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1637
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1638 printf("Creating an uninstall entry\n");
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
1639 sprintf(display_name, "Vim " VIM_VERSION_SHORT
16229
081522b02c2d patch 8.1.1119: no support for Windows on ARM64.
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1640 #ifdef _M_ARM64
081522b02c2d patch 8.1.1119: no support for Windows on ARM64.
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1641 " (arm64)"
081522b02c2d patch 8.1.1119: no support for Windows on ARM64.
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1642 #elif _M_X64
15213
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
1643 " (x64)"
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
1644 #endif
c0eb9a74f73d patch 8.1.0616: NSIS installer is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15158
diff changeset
1645 );
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1646
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1647 // For the NSIS installer use the generated uninstaller.
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1648 if (interactive)
18174
1ec6539cef68 patch 8.1.2082: some files have a weird name to fit in 8.3 characters
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
1649 sprintf(uninstall_string, "%s\\uninstall.exe", installdir);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650 else
2344
a2b15b1e626d Fix: MS-Windows installer used wrong path for uninstaller key.
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
1651 sprintf(uninstall_string, "%s\\uninstall-gui.exe", installdir);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1652
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1653 sprintf(icon_string, "%s\\gvim.exe,0", installdir);
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1654
2286
144aa6167799 Adjust MS-Windows installer so that it also works for 64 bit systems. (George
Bram Moolenaar <bram@vim.org>
parents: 2220
diff changeset
1655 lRet = register_uninstall(
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1656 HKEY_LOCAL_MACHINE,
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1657 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT,
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
1658 display_name,
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1659 uninstall_string,
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1660 icon_string,
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1661 VIM_VERSION_SHORT,
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
1662 "Bram Moolenaar et al.");
2287
573da4dac306 Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents: 2286
diff changeset
1663 if (ERROR_SUCCESS != lRet)
573da4dac306 Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents: 2286
diff changeset
1664 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1665
2287
573da4dac306 Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents: 2286
diff changeset
1666 return OK;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 change_popup_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 if (install_popup == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 choices[idx].text = "Install an entry for Vim in the popup menu for the right\n mouse button so that you can edit any file with Vim";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 install_popup = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 choices[idx].text = "Do NOT install an entry for Vim in the popup menu for the\n right mouse button to edit any file with Vim";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 install_popup = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 * Only add the choice for the popup menu entry when gvim.exe was found and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686 * both gvimext.dll and regedit.exe exist.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1687 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1688 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689 init_popup_choice(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 struct stat st;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1692
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1693 if (has_gvim
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1694 && (stat(GVIMEXT32_PATH, &st) >= 0
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1695 || stat(GVIMEXT64_PATH, &st) >= 0))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 choices[choice_count].changefunc = change_popup_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 choices[choice_count].installfunc = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699 choices[choice_count].active = 1;
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1700 change_popup_choice(choice_count); // set the text
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 add_dummy_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1707 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 change_openwith_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1709 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1710 if (install_openwith == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1711 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1712 choices[idx].text = "Add Vim to the \"Open With...\" list in the popup menu for the right\n mouse button so that you can edit any file with Vim";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1713 install_openwith = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 choices[idx].text = "Do NOT add Vim to the \"Open With...\" list in the popup menu for the\n right mouse button to edit any file with Vim";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 install_openwith = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723 * Only add the choice for the open-with menu entry when gvim.exe was found
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4111
diff changeset
1724 * and regedit.exe exist.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727 init_openwith_choice(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728 {
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1729 if (has_gvim)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1730 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1731 choices[choice_count].changefunc = change_openwith_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1732 choices[choice_count].installfunc = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733 choices[choice_count].active = 1;
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1734 change_openwith_choice(choice_count); // set the text
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1735 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1736 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1738 add_dummy_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1741 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 * Create a shell link.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 * returns 0 on failure, non-zero on successful completion.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 * NOTE: Currently untested with mingw.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 create_shortcut(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 const char *shortcut_name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 const char *iconfile_path,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 int iconindex,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753 const char *shortcut_target,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 const char *shortcut_args,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755 const char *workingdir
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 IShellLink *shelllink_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 HRESULT hres;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 IPersistFile *persistfile_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1762 // Initialize COM library
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 hres = CoInitialize(NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 if (!SUCCEEDED(hres))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 printf("Error: Could not open the COM library. Not creating shortcut.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1770 // Instantiate a COM object for the ShellLink, store a pointer to it
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1771 // in shelllink_ptr.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 hres = CoCreateInstance(&CLSID_ShellLink,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 CLSCTX_INPROC_SERVER,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 &IID_IShellLink,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 (void **) &shelllink_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1778 if (SUCCEEDED(hres)) // If the instantiation was successful...
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1780 // ...Then build a PersistFile interface for the ShellLink so we can
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1781 // save it as a file after we build it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 hres = shelllink_ptr->lpVtbl->QueryInterface(shelllink_ptr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 &IID_IPersistFile, (void **) &persistfile_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 if (SUCCEEDED(hres))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 wchar_t wsz[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1789 // translate the (possibly) multibyte shortcut filename to windows
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1790 // Unicode so it can be used as a file name.
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
1791 MultiByteToWideChar(CP_ACP, 0, shortcut_name, -1, wsz, sizeof(wsz)/sizeof(wsz[0]));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1793 // set the attributes
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 shelllink_ptr->lpVtbl->SetPath(shelllink_ptr, shortcut_target);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 shelllink_ptr->lpVtbl->SetWorkingDirectory(shelllink_ptr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 workingdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 shelllink_ptr->lpVtbl->SetIconLocation(shelllink_ptr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 iconfile_path, iconindex);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 shelllink_ptr->lpVtbl->SetArguments(shelllink_ptr, shortcut_args);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1801 // save the shortcut to a file and return the PersistFile object
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 persistfile_ptr->lpVtbl->Save(persistfile_ptr, wsz, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 persistfile_ptr->lpVtbl->Release(persistfile_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 printf("QueryInterface Error\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1811 // Return the ShellLink object
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 shelllink_ptr->lpVtbl->Release(shelllink_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 printf("CoCreateInstance Error - hres = %08x\n", (int)hres);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824 * Build a path to where we will put a specified link.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826 * Return 0 on error, non-zero on success
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 build_link_name(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830 char *link_path,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831 const char *link_name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832 const char *shell_folder_name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 {
15892
e43b5e6d9190 patch 8.1.0952: compilation warnings when building the MS-Windows installer
Bram Moolenaar <Bram@vim.org>
parents: 15758
diff changeset
1834 char shell_folder_path[MAX_PATH];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 if (get_shell_folder_path(shell_folder_path, shell_folder_name) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838 printf("An error occurred while attempting to find the path to %s.\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1839 shell_folder_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1843 // Make sure the directory exists (create Start Menu\Programs\Vim).
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1844 // Ignore errors if it already exists.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845 vim_mkdir(shell_folder_path, 0755);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1847 // build the path to the shortcut and the path to gvim.exe
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848 sprintf(link_path, "%s\\%s.lnk", shell_folder_path, link_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1850 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1851 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 build_shortcut(
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1855 const char *name, // Name of the shortcut
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1856 const char *exename, // Name of the executable (e.g., vim.exe)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 const char *args,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 const char *shell_folder,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859 const char *workingdir)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 char executable_path[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 char link_name[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 sprintf(executable_path, "%s\\%s", installdir, exename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 if (build_link_name(link_name, name, shell_folder) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 printf("An error has occurred. A shortcut to %s will not be created %s.\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 *shell_folder == 'd' ? "on the desktop" : "in the Start menu");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1874 // Create the shortcut:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 return create_shortcut(link_name, executable_path, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 executable_path, args, workingdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1879 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880 * We used to use "homedir" as the working directory, but that is a bad choice
5454
53bc55e58fef updated for version 7.4.077
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1881 * on multi-user systems. However, not specifying a directory results in the
53bc55e58fef updated for version 7.4.077
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1882 * current directory to be c:\Windows\system32 on Windows 7. Use environment
53bc55e58fef updated for version 7.4.077
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1883 * variables instead.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884 */
5454
53bc55e58fef updated for version 7.4.077
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1885 #define WORKDIR "%HOMEDRIVE%%HOMEPATH%"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888 * Create shortcut(s) in the Start Menu\Programs\Vim folder.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1889 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 install_start_menu(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1893 need_uninstall_entry = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1894 printf("Creating start menu\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1895 if (has_vim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 if (build_shortcut("Vim", "vim.exe", "",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 VIM_STARTMENU, WORKDIR) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 if (build_shortcut("Vim Read-only", "vim.exe", "-R",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 VIM_STARTMENU, WORKDIR) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 if (build_shortcut("Vim Diff", "vim.exe", "-d",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 VIM_STARTMENU, WORKDIR) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 if (has_gvim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 if (build_shortcut("gVim", "gvim.exe", "",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 VIM_STARTMENU, WORKDIR) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 if (build_shortcut("gVim Easy", "gvim.exe", "-y",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 VIM_STARTMENU, WORKDIR) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 if (build_shortcut("gVim Read-only", "gvim.exe", "-R",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 VIM_STARTMENU, WORKDIR) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 if (build_shortcut("gVim Diff", "gvim.exe", "-d",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1919 VIM_STARTMENU, WORKDIR) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1921 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 if (build_shortcut("Uninstall",
18174
1ec6539cef68 patch 8.1.2082: some files have a weird name to fit in 8.3 characters
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
1923 interactive ? "uninstall.exe" : "uninstall-gui.exe", "",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 VIM_STARTMENU, installdir) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925 return;
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1926 // For Windows NT the working dir of the vimtutor.bat must be right,
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1927 // otherwise gvim.exe won't be found and using gvimbat doesn't work.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 if (build_shortcut("Vim tutor", "vimtutor.bat", "",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 VIM_STARTMENU, installdir) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 if (build_shortcut("Help", has_gvim ? "gvim.exe" : "vim.exe", "-c h",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 VIM_STARTMENU, WORKDIR) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1935 char shell_folder_path[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1937 // Creating the URL shortcut works a bit differently...
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1938 if (get_shell_folder_path(shell_folder_path, VIM_STARTMENU) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940 printf("Finding the path of the Start menu failed\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1941 return ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 add_pathsep(shell_folder_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944 strcat(shell_folder_path, "Vim Online.url");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 if (!WritePrivateProfileString("InternetShortcut", "URL",
14200
66e592f0bbf4 patch 8.1.0117: URL in install program still points to SourceForge
Christian Brabandt <cb@256bit.org>
parents: 13917
diff changeset
1946 "https://www.vim.org/", shell_folder_path))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 printf("Creating the Vim online URL failed\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1951 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1955 toggle_startmenu_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1957 if (choices[idx].installfunc == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 choices[idx].installfunc = install_start_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960 choices[idx].text = "Add Vim to the Start menu";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964 choices[idx].installfunc = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965 choices[idx].text = "Do NOT add Vim to the Start menu";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970 * Function to actually create the shortcuts
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1972 * Currently I am supplying no working directory to the shortcut. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 * means that the initial working dir will be:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1974 * - the location of the shortcut if no file is supplied
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1975 * - the location of the file being edited if a file is supplied (ie via
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1976 * drag and drop onto the shortcut).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1977 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1978 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979 install_shortcut_gvim(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
1981 // Create shortcut(s) on the desktop
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 if (choices[idx].arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 (void)build_shortcut(icon_names[0], "gvim.exe",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985 "", "desktop", WORKDIR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1986 need_uninstall_entry = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1987 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 install_shortcut_evim(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993 if (choices[idx].arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995 (void)build_shortcut(icon_names[1], "gvim.exe",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 "-y", "desktop", WORKDIR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 need_uninstall_entry = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 install_shortcut_gview(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004 if (choices[idx].arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 (void)build_shortcut(icon_names[2], "gvim.exe",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 "-R", "desktop", WORKDIR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 need_uninstall_entry = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013 toggle_shortcut_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2015 char *arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2017 if (choices[idx].installfunc == install_shortcut_gvim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2018 arg = "gVim";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2019 else if (choices[idx].installfunc == install_shortcut_evim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2020 arg = "gVim Easy";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022 arg = "gVim Read-only";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 if (choices[idx].arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025 choices[idx].arg = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2026 alloc_text(idx, "Do NOT create a desktop icon for %s", arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 choices[idx].arg = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031 alloc_text(idx, "Create a desktop icon for %s", arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036 init_startmenu_choice(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2038 // Start menu
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2039 choices[choice_count].changefunc = toggle_startmenu_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040 choices[choice_count].installfunc = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 choices[choice_count].active = 1;
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2042 toggle_startmenu_choice(choice_count); // set the text
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047 * Add the choice for the desktop shortcuts.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 init_shortcut_choices(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2052 // Shortcut to gvim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 choices[choice_count].text = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054 choices[choice_count].arg = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 choices[choice_count].active = has_gvim;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056 choices[choice_count].changefunc = toggle_shortcut_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 choices[choice_count].installfunc = install_shortcut_gvim;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058 toggle_shortcut_choice(choice_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2061 // Shortcut to evim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 choices[choice_count].text = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 choices[choice_count].arg = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 choices[choice_count].active = has_gvim;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 choices[choice_count].changefunc = toggle_shortcut_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066 choices[choice_count].installfunc = install_shortcut_evim;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067 toggle_shortcut_choice(choice_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2070 // Shortcut to gview
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 choices[choice_count].text = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 choices[choice_count].arg = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 choices[choice_count].active = has_gvim;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 choices[choice_count].changefunc = toggle_shortcut_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 choices[choice_count].installfunc = install_shortcut_gview;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 toggle_shortcut_choice(choice_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 * Attempt to register OLE for Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2084 install_OLE_register(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2085 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086 char register_command_string[BUFSIZE + 30];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2087
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2088 printf("\n--- Attempting to register Vim with OLE ---\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2089 printf("(There is no message whether this works or not.)\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091 sprintf(register_command_string, "\"%s\\gvim.exe\" -silent -register", installdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2092 system(register_command_string);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2093 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2094
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 * Remove the last part of directory "path[]" to get its parent, and put the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097 * result in "to[]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2098 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2099 static void
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
2100 dir_remove_last(const char *path, char to[MAX_PATH])
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2101 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2102 char c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2103 long last_char_to_copy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2104 long path_length = strlen(path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2105
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2106 // skip the last character just in case it is a '\\'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2107 last_char_to_copy = path_length - 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2108 c = path[last_char_to_copy];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2110 while (c != '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2111 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112 last_char_to_copy--;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2113 c = path[last_char_to_copy];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2116 strncpy(to, path, (size_t)last_char_to_copy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2117 to[last_char_to_copy] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2118 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 set_directories_text(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 {
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2123 int vimfiles_dir_choice = choices[idx].arg;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2124
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 if (vimfiles_dir_choice == (int)vimfiles_dir_none)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 alloc_text(idx, "Do NOT create plugin directories%s", "");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2128 alloc_text(idx, "Create plugin directories: %s",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2129 vimfiles_dir_choices[vimfiles_dir_choice]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2130 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2131
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132 /*
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2133 * To get the "real" home directory:
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2134 * - get value of $HOME
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2135 * - if not found, get value of $HOMEDRIVE$HOMEPATH
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2136 * - if not found, get value of $USERPROFILE
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2137 *
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2138 * This code is based on init_homedir() in misc1.c, keep in sync!
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2139 */
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2140 static char *homedir = NULL;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2141
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2142 void
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2143 init_homedir(void)
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2144 {
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2145 char *var;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2146 char buf[MAX_PATH];
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2147
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2148 if (homedir != NULL)
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2149 {
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2150 free(homedir);
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2151 homedir = NULL;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2152 }
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2153
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2154 var = getenv("HOME");
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2155
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2156 /*
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2157 * Typically, $HOME is not defined on Windows, unless the user has
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2158 * specifically defined it for Vim's sake. However, on Windows NT
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2159 * platforms, $HOMEDRIVE and $HOMEPATH are automatically defined for
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2160 * each user. Try constructing $HOME from these.
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2161 */
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2162 if (var == NULL || *var == NUL)
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2163 {
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2164 char *homedrive, *homepath;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2165
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2166 homedrive = getenv("HOMEDRIVE");
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2167 homepath = getenv("HOMEPATH");
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2168 if (homepath == NULL || *homepath == NUL)
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2169 homepath = "\\";
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2170 if (homedrive != NULL
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
2171 && strlen(homedrive) + strlen(homepath) < sizeof(buf))
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2172 {
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2173 sprintf(buf, "%s%s", homedrive, homepath);
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2174 if (buf[0] != NUL)
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2175 var = buf;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2176 }
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2177 }
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2178
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2179 if (var == NULL)
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2180 var = getenv("USERPROFILE");
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2181
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2182 /*
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2183 * Weird but true: $HOME may contain an indirect reference to another
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2184 * variable, esp. "%USERPROFILE%". Happens when $USERPROFILE isn't set
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2185 * when $HOME is being set.
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2186 */
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2187 if (var != NULL && *var == '%')
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2188 {
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2189 char *p;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2190 char *exp;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2191
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2192 p = strchr(var + 1, '%');
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2193 if (p != NULL)
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2194 {
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2195 strncpy(buf, var + 1, p - (var + 1));
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2196 buf[p - (var + 1)] = NUL;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2197 exp = getenv(buf);
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2198 if (exp != NULL && *exp != NUL
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
2199 && strlen(exp) + strlen(p) < sizeof(buf))
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2200 {
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
2201 sprintf(buf, "%s%s", exp, p + 1);
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2202 var = buf;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2203 }
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2204 }
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2205 }
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2206
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2207 if (var != NULL && *var == NUL) // empty is same as not set
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2208 var = NULL;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2209
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2210 if (var == NULL)
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2211 homedir = NULL;
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2212 else
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2213 homedir = _strdup(var);
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2214 }
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2215
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2216 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 * Change the directory that the vim plugin directories will be created in:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2218 * $HOME, $VIM or nowhere.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2220 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2221 change_directories_choice(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2222 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2223 int choice_count = TABLE_SIZE(vimfiles_dir_choices);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2225 // Don't offer the $HOME choice if $HOME isn't set.
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2226 if (homedir == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227 --choice_count;
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2228 choices[idx].arg = get_choice(vimfiles_dir_choices, choice_count);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2229 set_directories_text(idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2230 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2231
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2232 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2233 * Create the plugin directories...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2234 */
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2235 //ARGSUSED
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2236 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2237 install_vimfilesdir(int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2238 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2239 int i;
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2240 int vimfiles_dir_choice = choices[idx].arg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2241 char *p;
15892
e43b5e6d9190 patch 8.1.0952: compilation warnings when building the MS-Windows installer
Bram Moolenaar <Bram@vim.org>
parents: 15758
diff changeset
2242 char vimdir_path[MAX_PATH];
e43b5e6d9190 patch 8.1.0952: compilation warnings when building the MS-Windows installer
Bram Moolenaar <Bram@vim.org>
parents: 15758
diff changeset
2243 char vimfiles_path[MAX_PATH + 9];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244 char tmp_dirname[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2245
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2246 // switch on the location that the user wants the plugin directories
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2247 // built in
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248 switch (vimfiles_dir_choice)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2250 case vimfiles_dir_vim:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2251 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2252 // Go to the %VIM% directory - check env first, then go one dir
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2253 // below installdir if there is no %VIM% environment variable.
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2254 // The accuracy of $VIM is checked in inspect_system(), so we
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2255 // can be sure it is ok to use here.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 p = getenv("VIM");
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2257 if (p == NULL) // No $VIM in path
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258 dir_remove_last(installdir, vimdir_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2260 strcpy(vimdir_path, p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 case vimfiles_dir_home:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 {
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2265 // Find the $HOME directory. Its existence was already checked.
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2266 p = homedir;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2267 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269 printf("Internal error: $HOME is NULL\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2270 p = "c:\\";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2271 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272 strcpy(vimdir_path, p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2274 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2275 case vimfiles_dir_none:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276 {
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2277 // Do not create vim plugin directory.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2279 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2282 // Now, just create the directory. If it already exists, it will fail
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2283 // silently.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2284 sprintf(vimfiles_path, "%s\\vimfiles", vimdir_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285 vim_mkdir(vimfiles_path, 0755);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2287 printf("Creating the following directories in \"%s\":\n", vimfiles_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2288 for (i = 0; i < TABLE_SIZE(vimfiles_subdirs); i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2289 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2290 sprintf(tmp_dirname, "%s\\%s", vimfiles_path, vimfiles_subdirs[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2291 printf(" %s", vimfiles_subdirs[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2292 vim_mkdir(tmp_dirname, 0755);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294 printf("\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2297 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298 * Add the creation of runtime files to the setup sequence.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2300 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 init_directories_choice(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2303 struct stat st;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 char tmp_dirname[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305 char *p;
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2306 int vimfiles_dir_choice;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 choices[choice_count].text = alloc(150);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309 choices[choice_count].changefunc = change_directories_choice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 choices[choice_count].installfunc = install_vimfilesdir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311 choices[choice_count].active = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2312
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2313 // Check if the "compiler" directory already exists. That's a good
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2314 // indication that the plugin directories were already created.
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
2315 p = getenv("HOME");
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
2316 if (p != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2318 vimfiles_dir_choice = (int)vimfiles_dir_home;
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
2319 sprintf(tmp_dirname, "%s\\vimfiles\\compiler", p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2320 if (stat(tmp_dirname, &st) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321 vimfiles_dir_choice = (int)vimfiles_dir_none;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2322 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2323 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2324 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2325 vimfiles_dir_choice = (int)vimfiles_dir_vim;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2326 p = getenv("VIM");
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2327 if (p == NULL) // No $VIM in path, use the install dir.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2328 dir_remove_last(installdir, tmp_dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2329 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2330 strcpy(tmp_dirname, p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2331 strcat(tmp_dirname, "\\vimfiles\\compiler");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2332 if (stat(tmp_dirname, &st) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 vimfiles_dir_choice = (int)vimfiles_dir_none;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2335
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2336 choices[choice_count].arg = vimfiles_dir_choice;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2337 set_directories_text(choice_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 ++choice_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2342 * Setup the choices and the default values.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2343 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2344 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2345 setup_choices(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2346 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2347 // install the batch files
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2348 init_bat_choices();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2349
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2350 // (over) write _vimrc file
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2351 init_vimrc_choices();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2353 // Whether to add Vim to the popup menu
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2354 init_popup_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2355
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2356 // Whether to add Vim to the "Open With..." menu
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2357 init_openwith_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2358
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2359 // Whether to add Vim to the Start Menu.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2360 init_startmenu_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2361
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2362 // Whether to add shortcuts to the Desktop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2363 init_shortcut_choices();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2364
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2365 // Whether to create the runtime directories.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366 init_directories_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370 print_cmd_line_help(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2372 printf("Vim installer non-interactive command line arguments:\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2373 printf("\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2374 printf("-create-batfiles [vim gvim evim view gview vimdiff gvimdiff]\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2375 printf(" Create .bat files for Vim variants in the Windows directory.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2376 printf("-create-vimrc\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2377 printf(" Create a default _vimrc file if one does not already exist.\n");
12708
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2378 printf("-vimrc-remap [no|win]\n");
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2379 printf(" Remap keys when creating a default _vimrc file.\n");
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2380 printf("-vimrc-behave [unix|mswin|default]\n");
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2381 printf(" Set mouse behavior when creating a default _vimrc file.\n");
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2382 printf("-vimrc-compat [vi|vim|defaults|all]\n");
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2383 printf(" Set Vi compatibility when creating a default _vimrc file.\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2384 printf("-install-popup\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 printf(" Install the Edit-with-Vim context menu entry\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386 printf("-install-openwith\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2387 printf(" Add Vim to the \"Open With...\" context menu list\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2388 printf("-add-start-menu");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2389 printf(" Add Vim to the start menu\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2390 printf("-install-icons");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391 printf(" Create icons for gVim executables on the desktop\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2392 printf("-create-directories [vim|home]\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2393 printf(" Create runtime directories to drop plugins into; in the $VIM\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2394 printf(" or $HOME directory\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2395 printf("-register-OLE");
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 7
diff changeset
2396 printf(" Ignored\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 printf("\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2400 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401 * Setup installation choices based on command line switches
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2402 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2403 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2404 command_line_setup_choices(int argc, char **argv)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2405 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2406 int i, j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2408 for (i = 1; i < argc; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2410 if (strcmp(argv[i], "-create-batfiles") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2411 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2412 if (i + 1 == argc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2413 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2414 while (argv[i + 1][0] != '-' && i < argc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2416 i++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2417 for (j = 1; j < TARGET_COUNT; ++j)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418 if ((targets[j].exenamearg[0] == 'g' ? has_gvim : has_vim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419 && strcmp(argv[i], targets[j].name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2420 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2421 init_bat_choice(j);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2422 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2423 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2424 if (j == TARGET_COUNT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425 printf("%s is not a valid choice for -create-batfiles\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2426 argv[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2428 if (i + 1 == argc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2429 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432 else if (strcmp(argv[i], "-create-vimrc") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2433 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2434 // Setup default vimrc choices. If there is already a _vimrc file,
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2435 // it will NOT be overwritten.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2436 init_vimrc_choices();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2437 }
12708
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2438 else if (strcmp(argv[i], "-vimrc-remap") == 0)
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2439 {
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2440 if (i + 1 == argc)
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2441 break;
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2442 i++;
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2443 if (strcmp(argv[i], "no") == 0)
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2444 remap_choice = remap_no;
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2445 else if (strcmp(argv[i], "win") == 0)
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2446 remap_choice = remap_win;
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2447 }
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2448 else if (strcmp(argv[i], "-vimrc-behave") == 0)
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2449 {
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2450 if (i + 1 == argc)
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2451 break;
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2452 i++;
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2453 if (strcmp(argv[i], "unix") == 0)
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2454 mouse_choice = mouse_xterm;
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2455 else if (strcmp(argv[i], "mswin") == 0)
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2456 mouse_choice = mouse_mswin;
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2457 else if (strcmp(argv[i], "default") == 0)
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2458 mouse_choice = mouse_default;
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2459 }
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2460 else if (strcmp(argv[i], "-vimrc-compat") == 0)
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2461 {
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2462 if (i + 1 == argc)
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2463 break;
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2464 i++;
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2465 if (strcmp(argv[i], "vi") == 0)
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2466 compat_choice = compat_vi;
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2467 else if (strcmp(argv[i], "vim") == 0)
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2468 compat_choice = compat_vim;
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2469 else if (strcmp(argv[i], "defaults") == 0)
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2470 compat_choice = compat_some_enhancements;
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2471 else if (strcmp(argv[i], "all") == 0)
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2472 compat_choice = compat_all_enhancements;
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2473 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2474 else if (strcmp(argv[i], "-install-popup") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2475 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2476 init_popup_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 else if (strcmp(argv[i], "-install-openwith") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2479 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2480 init_openwith_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2481 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482 else if (strcmp(argv[i], "-add-start-menu") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484 init_startmenu_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 else if (strcmp(argv[i], "-install-icons") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 init_shortcut_choices();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 else if (strcmp(argv[i], "-create-directories") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 {
15158
a9340baa872f patch 8.1.0589: compilation error in gvimext.cpp
Bram Moolenaar <Bram@vim.org>
parents: 15060
diff changeset
2492 int vimfiles_dir_choice = (int)vimfiles_dir_none;
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2493
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494 init_directories_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495 if (argv[i + 1][0] != '-')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2497 i++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2498 if (strcmp(argv[i], "vim") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 vimfiles_dir_choice = (int)vimfiles_dir_vim;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2500 else if (strcmp(argv[i], "home") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2501 {
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2502 if (homedir == NULL) // No $HOME in environment
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2503 vimfiles_dir_choice = (int)vimfiles_dir_none;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2504 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 vimfiles_dir_choice = (int)vimfiles_dir_home;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2509 printf("Unknown argument for -create-directories: %s\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510 argv[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511 print_cmd_line_help();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513 }
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2514 else // No choice specified, default to vim directory
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2515 vimfiles_dir_choice = (int)vimfiles_dir_vim;
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2516 choices[choice_count - 1].arg = vimfiles_dir_choice;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2518 else if (strcmp(argv[i], "-register-OLE") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2519 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2520 // This is always done when gvim is found
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 }
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2522 else // Unknown switch
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2523 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 printf("Got unknown argument argv[%d] = %s\n", i, argv[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525 print_cmd_line_help();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532 * Show a few screens full of helpful information.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 show_help(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2537 static char *(items[]) =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2539 "Installing .bat files\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 "---------------------\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541 "The vim.bat file is written in one of the directories in $PATH.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 "This makes it possible to start Vim from the command line.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 "If vim.exe can be found in $PATH, the choice for vim.bat will not be\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544 "present. It is assumed you will use the existing vim.exe.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 "If vim.bat can already be found in $PATH this is probably for an old\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 "version of Vim (but this is not checked!). You can overwrite it.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 "If no vim.bat already exists, you can select one of the directories in\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548 "$PATH for creating the batch file, or disable creating a vim.bat file.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549 "\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2550 "If you choose not to create the vim.bat file, Vim can still be executed\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551 "in other ways, but not from the command line.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2552 "\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553 "The same applies to choices for gvim, evim, (g)view, and (g)vimdiff.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2554 "The first item can be used to change the path for all of them.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2555 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 "Creating a _vimrc file\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 "----------------------\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 "The _vimrc file is used to set options for how Vim behaves.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 "The install program can create a _vimrc file with a few basic choices.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 "You can edit this file later to tune your preferences.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 "If you already have a _vimrc or .vimrc file it can be overwritten.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 "Don't do that if you have made changes to it.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 "Vim features\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 "------------\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 "(this choice is only available when creating a _vimrc file)\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2567 "1. Vim can run in Vi-compatible mode. Many nice Vim features are then\n"
15060
a7b9fa73d238 patch 8.1.0541: help message in dosinst.c is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15046
diff changeset
2568 " disabled. Only choose Vi-compatible if you really need full Vi\n"
a7b9fa73d238 patch 8.1.0541: help message in dosinst.c is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15046
diff changeset
2569 " compatibility.\n"
a7b9fa73d238 patch 8.1.0541: help message in dosinst.c is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15046
diff changeset
2570 "2. Vim runs in not-Vi-compatible mode. Vim is still mostly Vi compatible,\n"
a7b9fa73d238 patch 8.1.0541: help message in dosinst.c is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15046
diff changeset
2571 " but adds nice features like multi-level undo.\n"
a7b9fa73d238 patch 8.1.0541: help message in dosinst.c is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15046
diff changeset
2572 "3. Running Vim with some enhancements is useful when you want some of\n"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 " the nice Vim features, but have a slow computer and want to keep it\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574 " really fast.\n"
15060
a7b9fa73d238 patch 8.1.0541: help message in dosinst.c is outdated
Bram Moolenaar <Bram@vim.org>
parents: 15046
diff changeset
2575 "4. Syntax highlighting shows many files in color. Not only does this look\n"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576 " nice, it also makes it easier to spot errors and you can work faster.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2577 " The other features include editing compressed files.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2579 "Windows key mapping\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580 "-------------------\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 "(this choice is only available when creating a _vimrc file)\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582 "Under MS-Windows the CTRL-C key copies text to the clipboard and CTRL-V\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2583 "pastes text from the clipboard. There are a few more keys like these.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2584 "Unfortunately, in Vim these keys normally have another meaning.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2585 "1. Choose to have the keys like they normally are in Vim (useful if you\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 " also use Vim on other systems).\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587 "2. Choose to have the keys work like they are used on MS-Windows (useful\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588 " if you mostly work on MS-Windows).\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 "Mouse use\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2591 "---------\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592 "(this choice is only available when creating a _vimrc file)\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 "The right mouse button can be used in two ways:\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 "1. The Unix way is to extend an existing selection. The popup menu is\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595 " not available.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2596 "2. The MS-Windows way is to show a popup menu, which allows you to\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2597 " copy/paste text, undo/redo, etc. Extending the selection can still be\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2598 " done by keeping SHIFT pressed while using the left mouse button\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2599 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2600 "Edit-with-Vim context menu entry\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2601 "--------------------------------\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 "(this choice is only available when gvim.exe and gvimext.dll are present)\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603 "You can associate different file types with Vim, so that you can (double)\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 "click on a file to edit it with Vim. This means you have to individually\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2605 "select each file type.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 "An alternative is the option offered here: Install an \"Edit with Vim\"\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2607 "entry in the popup menu for the right mouse button. This means you can\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 "edit any file with Vim.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2609 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610 "\"Open With...\" context menu entry\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611 "--------------------------------\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 "(this choice is only available when gvim.exe is present)\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613 "This option adds Vim to the \"Open With...\" entry in the popup menu for\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 "the right mouse button. This also makes it possible to edit HTML files\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615 "directly from Internet Explorer.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2616 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 "Add Vim to the Start menu\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 "-------------------------\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619 "In Windows 95 and later, Vim can be added to the Start menu. This will\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 "create a submenu with an entry for vim, gvim, evim, vimdiff, etc..\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2621 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2622 "Icons on the desktop\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2623 "--------------------\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2624 "(these choices are only available when installing gvim)\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2625 "In Windows 95 and later, shortcuts (icons) can be created on the Desktop.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2626 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2627 "Create plugin directories\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2628 "-------------------------\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2629 "Plugin directories allow extending Vim by dropping a file into a directory.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2630 "This choice allows creating them in $HOME (if you have a home directory) or\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2631 "$VIM (used for everybody on the system).\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633 NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2634 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2635 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2636 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2637
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2638 rewind(stdin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2639 printf("\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2640 for (i = 0; items[i] != NULL; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2641 {
12708
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 12626
diff changeset
2642 puts(items[i]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2643 printf("Hit Enter to continue, b (back) or q (quit help): ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2644 c = getchar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645 rewind(stdin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2646 if (c == 'b' || c == 'B')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2647 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 if (i == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2649 --i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2650 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2651 i -= 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2652 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2653 if (c == 'q' || c == 'Q')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2654 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 printf("\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2656 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2658
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2659 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2660 * Install the choices.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2663 install(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2666
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2667 // Install the selected choices.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2668 for (i = 0; i < choice_count; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2669 if (choices[i].installfunc != NULL && choices[i].active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2670 (choices[i].installfunc)(i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2672 // Add some entries to the registry, if needed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673 if (install_popup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2674 || install_openwith
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2675 || (need_uninstall_entry && interactive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2676 || !interactive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 install_registry();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2679 // Register gvim with OLE.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 if (has_gvim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 install_OLE_register();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2682 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2683
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685 * request_choice
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688 request_choice(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2691
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2692 printf("\n\nInstall will do for you:\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693 for (i = 0; i < choice_count; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2694 if (choices[i].active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2695 printf("%2d %s\n", i + 1, choices[i].text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2696 printf("To change an item, enter its number\n\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2697 printf("Enter item number, h (help), d (do it) or q (quit): ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2699
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2700 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2701 main(int argc, char **argv)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2702 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2703 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704 char buf[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2705
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 * Run interactively if there are no command line arguments.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2709 if (argc > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2710 interactive = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712 interactive = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2714 // Initialize this program.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2715 do_inits(argv);
15046
c1be7c8bb602 patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents: 14921
diff changeset
2716 init_homedir();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2718 if (argc > 1 && strcmp(argv[1], "-uninstall-check") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2720 // Only check for already installed Vims. Used by NSIS installer.
2217
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
2721 i = uninstall_check(1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2723 // Find the value of $VIM, because NSIS isn't able to do this by
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2724 // itself.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2725 get_vim_env();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2727 // When nothing found exit quietly. If something found wait for
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2728 // a little while, so that the user can read the messages.
14921
b2308693cb87 patch 8.1.0472: dosinst command has a few flaws
Bram Moolenaar <Bram@vim.org>
parents: 14558
diff changeset
2729 if (i && _isatty(1))
2287
573da4dac306 Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents: 2286
diff changeset
2730 sleep(3);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731 exit(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 printf("This program sets up the installation of Vim "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735 VIM_VERSION_MEDIUM "\n\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2737 // Check if the user unpacked the archives properly.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2738 check_unpack();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2740 // Check for already installed Vims.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 if (interactive)
2217
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
2742 uninstall_check(0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2743
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2744 // Find out information about the system.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2745 inspect_system();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2746
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2747 if (interactive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2748 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2749 // Setup all the choices.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750 setup_choices();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2752 // Let the user change choices and finally install (or quit).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2754 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 request_choice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2756 rewind(stdin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2757 if (scanf("%99s", buf) == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2759 if (isdigit(buf[0]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2760 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2761 // Change a choice.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762 i = atoi(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2763 if (i > 0 && i <= choice_count && choices[i - 1].active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2764 (choices[i - 1].changefunc)(i - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2765 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2766 printf("\nIllegal choice\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2767 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 else if (buf[0] == 'h' || buf[0] == 'H')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2769 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2770 // Help
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2771 show_help();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2772 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 else if (buf[0] == 'd' || buf[0] == 'D')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2774 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2775 // Install!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2776 install();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777 printf("\nThat finishes the installation. Happy Vimming!\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2778 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2779 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2780 else if (buf[0] == 'q' || buf[0] == 'Q')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2782 // Quit
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2783 printf("\nExiting without anything done\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2784 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2785 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2787 printf("\nIllegal choice\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2790 printf("\n");
2217
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
2791 myexit(0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2792 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2793 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796 * Run non-interactive - setup according to the command line switches
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2798 command_line_setup_choices(argc, argv);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2799 install();
2217
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
2800
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2801 // Avoid that the user has to hit Enter, just wait a little bit to
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
2802 // allow reading the messages.
2287
573da4dac306 Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents: 2286
diff changeset
2803 sleep(2);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2805
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2806 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807 }