vimrun.c

来自「VIM文本编辑器」· C语言 代码 · 共 72 行

C
72
字号
/* 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 returned\n", retval);

    puts("Hit any key to close this window...");

    while (_kbhit())
	(void)_getch();
    (void)_getch();

    return retval;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?