1717
1818#include <stdio.h>
1919#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
2223#endif
24+ #include <windows.h>
2325
2426#ifdef __BORLANDC__
25- extern char *
26- #ifdef _RTLDLL
27- __import
28- #endif
29- _oscmd ;
3027# define _kbhit kbhit
3128# 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
4929#endif
5030
5131 int
5232main (void )
5333{
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 ();
5842
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
6843 /*
6944 * Skip the executable name, which might be in "".
7045 */
7146 while (* p )
7247 {
73- if (* p == '"' )
48+ if (* p == L '"' )
7449 inquote = !inquote ;
75- else if (!inquote && * p == ' ' )
50+ else if (!inquote && * p == L ' ' )
7651 {
7752 ++ p ;
7853 break ;
7954 }
8055 ++ p ;
8156 }
82- while (* p == ' ' )
57+ while (* p == L ' ' )
8358 ++ p ;
8459
8560 /*
8661 * "-s" argument: don't wait for a key hit.
8762 */
88- if (p [0 ] == '-' && p [1 ] == 's' && p [2 ] == ' ' )
63+ if (p [0 ] == L '-' && p [1 ] == L 's' && p [2 ] == L ' ' )
8964 {
9065 silent = 1 ;
9166 p += 3 ;
92- while (* p == ' ' )
67+ while (* p == L ' ' )
9368 ++ p ;
9469 }
9570
9671 /* 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 );
9875
9976 /*
10077 * Do it!
10178 */
102- retval = system (p );
79+ retval = _wsystem (p );
10380
10481 if (retval == -1 )
10582 perror ("vimrun system(): " );
@@ -110,10 +87,8 @@ main(void)
11087 {
11188 puts ("Hit any key to close this window..." );
11289
113- #ifndef __CYGWIN__
11490 while (_kbhit ())
11591 (void )_getch ();
116- #endif
11792 (void )_getch ();
11893 }
11994
0 commit comments