annotate src/vimrun.c @ 17129:4fb68abc770f v8.1.1564

patch 8.1.1564: sign column takes up space commit https://github.com/vim/vim/commit/394c5d8870b15150fc91a4c058dc571fd5eaa97e Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 17 21:48:05 2019 +0200 patch 8.1.1564: sign column takes up space Problem: Sign column takes up space. (Adam Stankiewicz) Solution: Optionally put signs in the number column. (Yegappan Lakshmanan, closes #4555, closes #4515)
author Bram Moolenaar <Bram@vim.org>
date Mon, 17 Jun 2019 22:00:09 +0200
parents 7e733046db1d
children 85160a3649b9
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 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 main(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 {
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
29 const wchar_t *p;
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
30 int retval;
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
31 int inquote = 0;
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
32 int silent = 0;
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
33 HANDLE hstdout;
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
34 DWORD written;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
36 p = (const wchar_t *)GetCommandLineW();
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
37
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 * Skip the executable name, which might be in "".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 while (*p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 {
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
43 if (*p == L'"')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 inquote = !inquote;
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
45 else if (!inquote && *p == L' ')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 }
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
52 while (*p == L' ')
13353
8412df1479a3 patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
53 ++p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 * "-s" argument: don't wait for a key hit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 */
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
58 if (p[0] == L'-' && p[1] == L's' && p[2] == L' ')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 silent = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 p += 3;
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
62 while (*p == L' ')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 /* 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
67 hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
68 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
69 WriteConsoleW(hstdout, L"\r\n", 2, &written, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 * Do it!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 */
9840
da7307987ed1 commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents: 7166
diff changeset
74 retval = _wsystem(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 7
diff changeset
76 if (retval == -1)
e63691e7c504 updated for version 7.1a
vimboss
parents: 7
diff changeset
77 perror("vimrun system(): ");
e63691e7c504 updated for version 7.1a
vimboss
parents: 7
diff changeset
78 else if (retval != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 printf("shell returned %d\n", retval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 if (!silent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 puts("Hit any key to close this window...");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 while (_kbhit())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 (void)_getch();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 (void)_getch();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 }