annotate src/os_w32exe.c @ 14864:40ef13331e02

Update runtime files. commit https://github.com/vim/vim/commit/95bafa296ae97bf420d5c74dd6db517b404c5df7 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Oct 2 13:26:25 2018 +0200 Update runtime files.
author Christian Brabandt <cb@256bit.org>
date Tue, 02 Oct 2018 13:30:07 +0200
parents 04eb70c77cf4
children 639b8318472c
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: 7805
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 * GUI support by Robert Webb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * See README.txt for an overview of the Vim source code.
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 * Windows GUI: main program (EXE) entry point:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 * Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 #ifdef __MINGW32__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 # ifndef _cdecl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 # define _cdecl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 /* cproto doesn't create a prototype for main() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 int _cdecl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 #if defined(FEAT_GUI_W32)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 VimMain
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 main
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 #endif
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7613
diff changeset
30 (int argc, char **argv);
379
d6d6ca943713 updated for version 7.0098
vimboss
parents: 323
diff changeset
31 static int (_cdecl *pmain)(int, char **);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 #ifndef PROTO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 #ifndef VIMDLL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 void _cdecl SaveInst(HINSTANCE hInst);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #endif
379
d6d6ca943713 updated for version 7.0098
vimboss
parents: 323
diff changeset
38 static void (_cdecl *pSaveInst)(HINSTANCE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 int WINAPI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 WinMain(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
43 HINSTANCE hInstance UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
44 HINSTANCE hPrevInst UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 LPSTR lpszCmdLine,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
46 int nCmdShow UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 {
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 7
diff changeset
48 int argc = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 char **argv;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 char *tofree;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 char prog[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 #ifdef VIMDLL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 HANDLE hLib;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 /* Ron: added full path name so that the $VIM variable will get set to our
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 * startup path (so the .vimrc file can be found w/o a VIM env. var.) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 GetModuleFileName(NULL, prog, 255);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
26
404aac550f35 updated for version 7.0017
vimboss
parents: 23
diff changeset
61 argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree);
404aac550f35 updated for version 7.0017
vimboss
parents: 23
diff changeset
62 if (argc == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 {
26
404aac550f35 updated for version 7.0017
vimboss
parents: 23
diff changeset
64 MessageBox(0, "Could not allocate memory for command line.",
404aac550f35 updated for version 7.0017
vimboss
parents: 23
diff changeset
65 "VIM Error", 0);
404aac550f35 updated for version 7.0017
vimboss
parents: 23
diff changeset
66 return 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 #ifdef DYNAMIC_GETTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 /* Initialize gettext library */
7613
4456fa2d22e8 commit https://github.com/vim/vim/commit/286eacd3f6631e985089176fb1dff1bcf1a1d6b5
Christian Brabandt <cb@256bit.org>
parents: 1738
diff changeset
71 dyn_libintl_init();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 #ifdef VIMDLL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 // LoadLibrary - get name of dll to load in here:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 p = strrchr(prog, '\\');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 # ifdef DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 strcpy(p+1, "vim32d.dll");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 strcpy(p+1, "vim32.dll");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 hLib = LoadLibrary(prog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 if (hLib == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 MessageBox(0, _("Could not load vim32.dll!"), _("VIM Error"), 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 goto errout;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 // fix up the function pointers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 pSaveInst = GetProcAddress(hLib, (LPCSTR)2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 pmain = GetProcAddress(hLib, (LPCSTR)1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 if (pmain == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 MessageBox(0, _("Could not fix up function pointers to the DLL!"),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 _("VIM Error"),0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 goto errout;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 pSaveInst = SaveInst;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 pmain =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 # if defined(FEAT_GUI_W32)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 //&& defined(__MINGW32__)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 VimMain
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 main
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 pSaveInst(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 #ifdef __MINGW32__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 GetModuleHandle(NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 hInstance
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 pmain(argc, argv);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 #ifdef VIMDLL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 FreeLibrary(hLib);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 errout:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 free(argv);
1738
1ddec6983d9e updated for version 7.2-036
vimboss
parents: 379
diff changeset
131 if (tofree != NULL)
1ddec6983d9e updated for version 7.2-036
vimboss
parents: 379
diff changeset
132 free(tofree);
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 7
diff changeset
133 #ifdef FEAT_MBYTE
26
404aac550f35 updated for version 7.0017
vimboss
parents: 23
diff changeset
134 free_cmd_argsW();
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 7
diff changeset
135 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 #endif