annotate src/vimrun.c @ 14467:16cccc953909 v8.1.0247

patch 8.1.0247: Python: error message for failing import is incorrect commit https://github.com/vim/vim/commit/447bd5a346b5c4bf4d91280700bdb4b45e0aa667 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 7 19:45:27 2018 +0200 patch 8.1.0247: Python: error message for failing import is incorrect Problem: Python: error message for failing import is incorrect. Solution: Adjust how modules are loaded. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/3162)
author Christian Brabandt <cb@256bit.org>
date Tue, 07 Aug 2018 20:00:06 +0200
parents 8412df1479a3
children 7e733046db1d
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: 9840
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 * this file by Vince Negri
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 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 * vimrun.c - Tiny Win32 program to safely run an external command in a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 * DOS console.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 * This program is required to avoid that typing CTRL-C in the DOS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * console kills Vim. Now it only kills vimrun.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #include <stdio.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 #include <stdlib.h>
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
20 #include <conio.h>
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
21 #ifndef WIN32_LEAN_AND_MEAN
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
22 # define WIN32_LEAN_AND_MEAN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 #endif
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
24 #include <windows.h>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 #ifdef __BORLANDC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 # define _kbhit kbhit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 # define _getch getch
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 main(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 {
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
34 const wchar_t *p;
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
35 int retval;
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
36 int inquote = 0;
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
37 int silent = 0;
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
38 HANDLE hstdout;
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
39 DWORD written;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
41 p = (const wchar_t *)GetCommandLineW();
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
42
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 * Skip the executable name, which might be in "".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 while (*p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 {
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
48 if (*p == L'"')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 inquote = !inquote;
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
50 else if (!inquote && *p == L' ')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 }
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
57 while (*p == L' ')
13353
8412df1479a3 patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
58 ++p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 * "-s" argument: don't wait for a key hit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 */
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
63 if (p[0] == L'-' && p[1] == L's' && p[2] == L' ')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 silent = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 p += 3;
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
67 while (*p == L' ')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 /* Print the command, including quotes and redirection. */
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
72 hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
73 WriteConsoleW(hstdout, p, wcslen(p), &written, NULL);
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
74 WriteConsoleW(hstdout, L"\r\n", 2, &written, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 * Do it!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 */
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
79 retval = _wsystem(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 7
diff changeset
81 if (retval == -1)
e63691e7c504 updated for version 7.1a
vimboss
parents: 7
diff changeset
82 perror("vimrun system(): ");
e63691e7c504 updated for version 7.1a
vimboss
parents: 7
diff changeset
83 else if (retval != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 printf("shell returned %d\n", retval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 if (!silent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 puts("Hit any key to close this window...");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 while (_kbhit())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 (void)_getch();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 (void)_getch();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 }