17
17
18
18
#include <stdio.h>
19
19
#include <stdlib.h>
20
- #ifndef __CYGWIN__
21
- # include <conio.h>
20
+ #include <conio.h>
21
+ #ifndef WIN32_LEAN_AND_MEAN
22
+ # define WIN32_LEAN_AND_MEAN
22
23
#endif
24
+ #include <windows.h>
23
25
24
26
#ifdef __BORLANDC__
25
- extern char *
26
- #ifdef _RTLDLL
27
- __import
28
- #endif
29
- _oscmd ;
30
27
# define _kbhit kbhit
31
28
# define _getch getch
32
- #else
33
- # ifdef __MINGW32__
34
- # ifndef WIN32_LEAN_AND_MEAN
35
- # define WIN32_LEAN_AND_MEAN
36
- # endif
37
- # include <windows.h>
38
- # else
39
- # ifdef __CYGWIN__
40
- # ifndef WIN32_LEAN_AND_MEAN
41
- # define WIN32_LEAN_AND_MEAN
42
- # endif
43
- # include <windows.h>
44
- # define _getch getchar
45
- # else
46
- extern char * _acmdln ;
47
- # endif
48
- # endif
49
29
#endif
50
30
51
31
int
52
32
main (void )
53
33
{
54
- const char * p ;
55
- int retval ;
56
- int inquote = 0 ;
57
- int silent = 0 ;
34
+ const wchar_t * p ;
35
+ int retval ;
36
+ int inquote = 0 ;
37
+ int silent = 0 ;
38
+ HANDLE hstdout ;
39
+ DWORD written ;
40
+
41
+ p = (const wchar_t * )GetCommandLineW ();
58
42
59
- #ifdef __BORLANDC__
60
- p = _oscmd ;
61
- #else
62
- # if defined(__MINGW32__ ) || defined(__CYGWIN__ )
63
- p = (const char * )GetCommandLine ();
64
- # else
65
- p = _acmdln ;
66
- # endif
67
- #endif
68
43
/*
69
44
* Skip the executable name, which might be in "".
70
45
*/
71
46
while (* p )
72
47
{
73
- if (* p == '"' )
48
+ if (* p == L '"' )
74
49
inquote = !inquote ;
75
- else if (!inquote && * p == ' ' )
50
+ else if (!inquote && * p == L ' ' )
76
51
{
77
52
++ p ;
78
53
break ;
79
54
}
80
55
++ p ;
81
56
}
82
- while (* p == ' ' )
57
+ while (* p == L ' ' )
83
58
++ p ;
84
59
85
60
/*
86
61
* "-s" argument: don't wait for a key hit.
87
62
*/
88
- if (p [0 ] == '-' && p [1 ] == 's' && p [2 ] == ' ' )
63
+ if (p [0 ] == L '-' && p [1 ] == L 's' && p [2 ] == L ' ' )
89
64
{
90
65
silent = 1 ;
91
66
p += 3 ;
92
- while (* p == ' ' )
67
+ while (* p == L ' ' )
93
68
++ p ;
94
69
}
95
70
96
71
/* Print the command, including quotes and redirection. */
97
- puts (p );
72
+ hstdout = GetStdHandle (STD_OUTPUT_HANDLE );
73
+ WriteConsoleW (hstdout , p , wcslen (p ), & written , NULL );
74
+ WriteConsoleW (hstdout , L"\r\n" , 2 , & written , NULL );
98
75
99
76
/*
100
77
* Do it!
101
78
*/
102
- retval = system (p );
79
+ retval = _wsystem (p );
103
80
104
81
if (retval == -1 )
105
82
perror ("vimrun system(): " );
@@ -110,10 +87,8 @@ main(void)
110
87
{
111
88
puts ("Hit any key to close this window..." );
112
89
113
- #ifndef __CYGWIN__
114
90
while (_kbhit ())
115
91
(void )_getch ();
116
- #endif
117
92
(void )_getch ();
118
93
}
119
94
0 commit comments