1 /* $NetBSD: ex_perl.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
3 * Copyright (c) 1992, 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1992, 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * George V. Neville-Neil. All rights reserved.
10 * Sven Verdoolaege. All rights reserved.
12 * See the LICENSE file for redistribution information.
17 #include <sys/cdefs.h>
20 static const char sccsid
[] = "Id: ex_perl.c,v 8.11 2001/06/25 15:19:18 skimo Exp (Berkeley) Date: 2001/06/25 15:19:18 ";
23 __RCSID("$NetBSD: ex_perl.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
26 #include <sys/types.h>
27 #include <sys/queue.h>
30 #include <bitstring.h>
38 #include "../common/common.h"
41 * ex_perl -- :[line [,line]] perl [command]
42 * Run a command through the perl interpreter.
44 * ex_perldo -- :[line [,line]] perldo [command]
45 * Run a set of lines through the perl interpreter.
47 * PUBLIC: int ex_perl __P((SCR*, EXCMD *));
50 ex_perl(SCR
*sp
, EXCMD
*cmdp
)
52 #ifdef HAVE_PERL_INTERP
56 /* Skip leading white space. */
58 for (p
= cmdp
->argv
[0]->bp
,
59 len
= cmdp
->argv
[0]->len
; len
> 0; --len
, ++p
)
60 if (!ISBLANK((UCHAR_T
)*p
))
62 if (cmdp
->argc
== 0 || len
== 0) {
63 ex_emsg(sp
, cmdp
->cmd
->usage
, EXM_USAGE
);
66 return (cmdp
->cmd
== &cmds
[C_PERLCMD
] ?
67 perl_ex_perl(sp
, p
, len
, cmdp
->addr1
.lno
, cmdp
->addr2
.lno
) :
68 perl_ex_perldo(sp
, p
, len
, cmdp
->addr1
.lno
, cmdp
->addr2
.lno
));
70 msgq(sp
, M_ERR
, "306|Vi was not loaded with a Perl interpreter");