vimrun.c
资源名称:vim53src.zip [点击查看]
上传用户:gddssl
上传日期:2007-01-06
资源大小:1003k
文件大小:1k
源码类别:
编辑器/阅读器
开发平台:
DOS
- /* vi:set ts=8 sts=4 sw=4:
- *
- * VIM - Vi IMproved by Bram Moolenaar
- * this file by Vince Negri
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
- /*
- * vimrun.c - Tiny Win32 program to safely run an external command in a
- * DOS console.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #ifdef __BORLANDC__
- extern char *
- #ifdef _RTLDLL
- __import
- #endif
- _oscmd;
- # define _kbhit kbhit
- # define _getch getch
- #else
- extern char *_acmdln;
- #endif
- int
- main(void)
- {
- const char *p;
- int retval;
- int inquote = 0;
- #ifdef __BORLANDC__
- p = _oscmd;
- #else
- p = _acmdln;
- #endif
- /*
- * Skip the executable name
- */
- while (*p)
- {
- if (*p == '"')
- inquote = !inquote;
- else if (!inquote && *p == ' ')
- {
- ++p;
- break;
- }
- ++p;
- }
- /* Print the command, including quotes and redirection. */
- puts(p);
- retval = system(p);
- if (retval != 0)
- printf("%d returnedn", retval);
- puts("Hit any key to close this window...");
- while (_kbhit())
- (void)_getch();
- (void)_getch();
- return retval;
- }