2005-02-12 15:53:22 +03:00
|
|
|
/* $NetBSD: ex_perl.c,v 1.5 2005/02/12 12:53:23 aymeric Exp $ */
|
1998-01-09 11:03:16 +03:00
|
|
|
|
1996-05-20 05:53:18 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1992, 1993, 1994
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
* Copyright (c) 1992, 1993, 1994, 1995, 1996
|
|
|
|
* Keith Bostic. All rights reserved.
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* George V. Neville-Neil. All rights reserved.
|
|
|
|
* Copyright (c) 1996
|
|
|
|
* Sven Verdoolaege. All rights reserved.
|
|
|
|
*
|
|
|
|
* See the LICENSE file for redistribution information.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-04-09 05:47:30 +04:00
|
|
|
#include <sys/cdefs.h>
|
1996-05-20 05:53:18 +04:00
|
|
|
#ifndef lint
|
2002-04-09 05:47:30 +04:00
|
|
|
#if 0
|
2001-03-31 15:37:44 +04:00
|
|
|
static const char sccsid[] = "@(#)ex_perl.c 8.10 (Berkeley) 9/15/96";
|
2002-04-09 05:47:30 +04:00
|
|
|
#else
|
2005-02-12 15:53:22 +03:00
|
|
|
__RCSID("$NetBSD: ex_perl.c,v 1.5 2005/02/12 12:53:23 aymeric Exp $");
|
2002-04-09 05:47:30 +04:00
|
|
|
#endif
|
1996-05-20 05:53:18 +04:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
#include <bitstring.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "../common/common.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ex_perl -- :[line [,line]] perl [command]
|
|
|
|
* Run a command through the perl interpreter.
|
|
|
|
*
|
2001-03-31 15:37:44 +04:00
|
|
|
* ex_perldo -- :[line [,line]] perldo [command]
|
1996-05-20 05:53:18 +04:00
|
|
|
* Run a set of lines through the perl interpreter.
|
|
|
|
*
|
2001-03-31 15:37:44 +04:00
|
|
|
* PUBLIC: int ex_perl __P((SCR*, EXCMD *));
|
1996-05-20 05:53:18 +04:00
|
|
|
*/
|
|
|
|
int
|
2001-03-31 15:37:44 +04:00
|
|
|
ex_perl(sp, cmdp)
|
|
|
|
SCR *sp;
|
1996-05-20 05:53:18 +04:00
|
|
|
EXCMD *cmdp;
|
|
|
|
{
|
|
|
|
#ifdef HAVE_PERL_INTERP
|
|
|
|
CHAR_T *p;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
/* Skip leading white space. */
|
|
|
|
if (cmdp->argc != 0)
|
|
|
|
for (p = cmdp->argv[0]->bp,
|
|
|
|
len = cmdp->argv[0]->len; len > 0; --len, ++p)
|
|
|
|
if (!isblank(*p))
|
|
|
|
break;
|
|
|
|
if (cmdp->argc == 0 || len == 0) {
|
2001-03-31 15:37:44 +04:00
|
|
|
ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
|
1996-05-20 05:53:18 +04:00
|
|
|
return (1);
|
|
|
|
}
|
2001-03-31 15:37:44 +04:00
|
|
|
return (cmdp->cmd == &cmds[C_PERLCMD] ?
|
|
|
|
perl_ex_perl(sp, p, len, cmdp->addr1.lno, cmdp->addr2.lno) :
|
|
|
|
perl_ex_perldo(sp, p, len, cmdp->addr1.lno, cmdp->addr2.lno));
|
1996-05-20 05:53:18 +04:00
|
|
|
#else
|
2001-03-31 15:37:44 +04:00
|
|
|
msgq(sp, M_ERR, "306|Vi was not loaded with a Perl interpreter");
|
1996-05-20 05:53:18 +04:00
|
|
|
return (1);
|
2001-03-31 15:37:44 +04:00
|
|
|
#endif
|
1996-05-20 05:53:18 +04:00
|
|
|
}
|