use three-argument AC_DEFINE instead of acconfig.h
[nvi.git] / ex / ex_perl.c
blob872045ecab521b3a88d3dd8cadc81b0d8791296a
1 /*-
2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
6 * Copyright (c) 1995
7 * George V. Neville-Neil. All rights reserved.
8 * Copyright (c) 1996
9 * Sven Verdoolaege. All rights reserved.
11 * See the LICENSE file for redistribution information.
14 #include "config.h"
16 #ifndef lint
17 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 $";
18 #endif /* not lint */
20 #include <sys/types.h>
21 #include <sys/queue.h>
22 #include <sys/time.h>
24 #include <bitstring.h>
25 #include <ctype.h>
26 #include <limits.h>
27 #include <stdio.h>
28 #include <string.h>
29 #include <termios.h>
30 #include <unistd.h>
32 #include "../common/common.h"
34 /*
35 * ex_perl -- :[line [,line]] perl [command]
36 * Run a command through the perl interpreter.
38 * ex_perldo -- :[line [,line]] perldo [command]
39 * Run a set of lines through the perl interpreter.
41 * PUBLIC: int ex_perl __P((SCR*, EXCMD *));
43 int
44 ex_perl(SCR *sp, EXCMD *cmdp)
46 #ifdef HAVE_PERL_INTERP
47 CHAR_T *p;
48 size_t len;
50 /* Skip leading white space. */
51 if (cmdp->argc != 0)
52 for (p = cmdp->argv[0]->bp,
53 len = cmdp->argv[0]->len; len > 0; --len, ++p)
54 if (!isblank(*p))
55 break;
56 if (cmdp->argc == 0 || len == 0) {
57 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
58 return (1);
60 return (cmdp->cmd == &cmds[C_PERLCMD] ?
61 perl_ex_perl(sp, p, len, cmdp->addr1.lno, cmdp->addr2.lno) :
62 perl_ex_perldo(sp, p, len, cmdp->addr1.lno, cmdp->addr2.lno));
63 #else
64 msgq(sp, M_ERR, "306|Vi was not loaded with a Perl interpreter");
65 return (1);
66 #endif