When building vi with PERLINTERP=yes the build errors out with the
following message:

/usr/src/usr.bin/vi/build/../ex/ex_perl.c: In function 'ex_perl':
/usr/src/usr.bin/vi/build/../ex/ex_perl.c:59: error: implicit declaration of 
function 'perl_ex_perl'
/usr/src/usr.bin/vi/build/../ex/ex_perl.c:60: error: implicit declaration of 
function 'perl_ex_perldo'

This can be easily fixed by adding a missing '#include "perl_extern.h"'
to ex_perl.c. After adding the missing include, there is another error:

/usr/src/usr.bin/vi/build/../ex/ex_script.c: In function 'sscr_init':
/usr/src/usr.bin/vi/build/../ex/ex_script.c:118: error: implicit declaration of 
function 'openpty'

The system util.h header is shadowed by the eponymous perl header. This
specific errors exists since December 2012. I strongly suspect that no
one uses the perl extension of vi - Let's remove it!

See the diff below.

cheers,
natano


Index: LAYOUT
===================================================================
RCS file: /cvs/src/usr.bin/vi/LAYOUT,v
retrieving revision 1.5
diff -u -r1.5 LAYOUT
--- LAYOUT      6 Nov 2014 11:35:02 -0000       1.5
+++ LAYOUT      15 Nov 2014 07:50:26 -0000
@@ -91,11 +91,5 @@
 include/
        Replacement include files.
 
-perl_api/
-       Source code supporting the Perl scripting language for nvi.
-
-perl_scripts/
-       Scripts for Perl included with nvi.
-
 vi/
        The vi source code.
Index: README
===================================================================
RCS file: /cvs/src/usr.bin/vi/README,v
retrieving revision 1.11
diff -u -r1.11 README
--- README      6 Nov 2014 11:35:02 -0000       1.11
+++ README      15 Nov 2014 07:50:40 -0000
@@ -23,8 +23,6 @@
     docs/USD.doc/vitut .... An Introduction to Display Editing with Vi.
     ex .................... Ex source code.
     include ............... Replacement include files.
-    perl_api .............. Perl scripting language support.
-    perl_scripts .......... Perl scripts.
     vi .................... Vi source code.
 
 Bug fixes and updated versions of this software will periodically be made
Index: build/Makefile
===================================================================
RCS file: /cvs/src/usr.bin/vi/build/Makefile,v
retrieving revision 1.20
diff -u -r1.20 Makefile
--- build/Makefile      14 Nov 2014 20:26:12 -0000      1.20
+++ build/Makefile      15 Nov 2014 07:50:05 -0000
@@ -3,9 +3,6 @@
 
 PROG=  vi
 
-# Uncomment to build with an embedded perl interpreter
-#PERLINTERP=   yes
-
 # Modern curses (ncurses)
 CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include
 LDADD+=-lcurses
@@ -24,7 +21,7 @@
        ex_at.c ex_bang.c ex_cd.c ex_cmd.c ex_cscope.c ex_delete.c \
        ex_display.c ex_edit.c ex_equal.c ex_file.c ex_filter.c \
        ex_global.c ex_init.c ex_join.c ex_map.c ex_mark.c ex_mkexrc.c \
-       ex_move.c ex_open.c ex_perl.c ex_preserve.c ex_print.c ex_put.c \
+       ex_move.c ex_open.c ex_preserve.c ex_print.c ex_put.c \
        ex_quit.c ex_read.c ex_screen.c ex_script.c ex_set.c ex_shell.c \
        ex_shift.c ex_source.c ex_stop.c ex_subst.c ex_tag.c \
        ex_txt.c ex_undo.c ex_usage.c ex_util.c ex_version.c ex_visual.c \
@@ -38,29 +35,12 @@
        v_zexit.c vi.c vs_line.c vs_msg.c vs_refresh.c vs_relative.c \
        vs_smap.c vs_split.c
 
-.ifdef PERLINTERP
-SRCS+= api.c perl.c perlsfio.c
-PERLARCH!=perl -MConfig -e 'print $$Config{archlibexp}'
-CFLAGS+=-DHAVE_PERL_5_003_01 -DHAVE_PERL_INTERP -I${PERLARCH}/CORE
-LDADD+= -lperl ${PERLARCH}/auto/DynaLoader/DynaLoader.a
-DPADD+= ${LIBPERL}
-.endif
-
 LINKS= ${BINDIR}/vi ${BINDIR}/ex
 LINKS+=        ${BINDIR}/vi ${BINDIR}/view
 MLINKS=        vi.1 ex.1
 MLINKS+=       vi.1 view.1
 
-CLEANFILES+= VI.pm perl.c
-
-.PATH: ${.CURDIR}/../vi ${.CURDIR}/../ex ${.CURDIR}/../cl ${.CURDIR}/../common 
${.CURDIR}/../perl_api ${.CURDIR}/../docs/USD.doc/vi.man
-
-perl.c: ${.CURDIR}/../perl_api/perl.xs ${.CURDIR}/../perl_api/typemap
-       echo "#define _PATH_PERLSCRIPTS \"${SHAREDIR}/vi/perl\"" > ${.TARGET}
-       perl /usr/libdata/perl5/ExtUtils/xsubpp -typemap \
-           /usr/libdata/perl5/ExtUtils/typemap ${.CURDIR}/../perl_api/perl.xs 
>> ${.TARGET}
-       (perl  -ne 'print "sub $$1 {\$$curscr->$$1(\@_)}\n" \
-           if /newXS\("VI::([^":]*)"/;' ${.TARGET} ; echo "1;") > VI.pm
+.PATH: ${.CURDIR}/../vi ${.CURDIR}/../ex ${.CURDIR}/../cl ${.CURDIR}/../common 
${.CURDIR}/../docs/USD.doc/vi.man
 
 .include "../../Makefile.inc"
 .include <bsd.prog.mk>
@@ -71,7 +51,3 @@
        ${INSTALL} -d ${DESTDIR}${SHAREDIR}/vi/catalog
        (cd ${.CURDIR}/../catalog && ${INSTALL} -m ${NONBINMODE} -c ${CATALOGS} 
${DESTDIR}/usr/share/vi/catalog )
        ${INSTALL} -m ${BINMODE} -o ${BINOWN} -g ${BINGRP} -c 
${.CURDIR}/recover ${DESTDIR}/usr/libexec/vi.recover
-.ifdef PERLINTERP
-       ${INSTALL} -d ${DESTDIR}${SHAREDIR}/vi/perl
-       (cd ${.CURDIR}/../perl_scripts; for i in *.pl; do ${INSTALL} -m 
${NONBINMODE} -c $$i ${DESTDIR}/usr/share/vi/perl; done)
-.endif
Index: common/api.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/api.c,v
retrieving revision 1.16
diff -u -r1.16 api.c
--- common/api.c        12 Nov 2014 04:28:41 -0000      1.16
+++ common/api.c        15 Nov 2014 07:46:25 -0000
@@ -1,473 +0,0 @@
-/*     $OpenBSD: api.c,v 1.16 2014/11/12 04:28:41 bentley Exp $        */
-
-/*-
- * 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.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-
-extern GS *__global_list;                      /* XXX */
-
-/*
- * api_fscreen --
- *     Return a pointer to the screen specified by the screen id
- *     or a file name.
- *
- * PUBLIC: SCR *api_fscreen(int, char *);
- */
-SCR *
-api_fscreen(int id, char *name)
-{
-       GS *gp;
-       SCR *tsp;
-
-       gp = __global_list;
-
-       /* Search the displayed list. */
-       TAILQ_FOREACH(tsp, &gp->dq, q)
-               if (name == NULL) {
-                       if (id == tsp->id)
-                               return (tsp);
-               } else if (!strcmp(name, tsp->frp->name))
-                       return (tsp);
-
-       /* Search the hidden list. */
-       TAILQ_FOREACH(tsp, &gp->hq, q)
-               if (name == NULL) {
-                       if (id == tsp->id)
-                               return (tsp);
-               } else if (!strcmp(name, tsp->frp->name))
-                       return (tsp);
-       return (NULL);
-}
-
-/*
- * api_aline --
- *     Append a line.
- *
- * PUBLIC: int api_aline(SCR *, recno_t, char *, size_t);
- */
-int
-api_aline(SCR *sp, recno_t lno, char *line, size_t len)
-{
-       return (db_append(sp, 1, lno, line, len));
-}
-
-/*
- * api_dline --
- *     Delete a line.
- *
- * PUBLIC: int api_dline(SCR *, recno_t);
- */
-int
-api_dline(SCR *sp, recno_t lno)
-{
-       return (db_delete(sp, lno));
-}
-
-/*
- * api_gline --
- *     Get a line.
- *
- * PUBLIC: int api_gline(SCR *, recno_t, char **, size_t *);
- */
-int
-api_gline(SCR *sp, recno_t lno, char **linepp, size_t *lenp)
-{
-       int isempty;
-
-       if (db_eget(sp, lno, linepp, lenp, &isempty)) {
-               if (isempty)
-                       msgq(sp, M_ERR, "209|The file is empty");
-               return (1);
-       }
-       return (0);
-}
-
-/*
- * api_iline --
- *     Insert a line.
- *
- * PUBLIC: int api_iline(SCR *, recno_t, char *, size_t);
- */
-int
-api_iline(SCR *sp, recno_t lno, char *line, size_t len)
-{
-       return (db_insert(sp, lno, line, len));
-}
-
-/*
- * api_lline --
- *     Return the line number of the last line in the file.
- *
- * PUBLIC: int api_lline(SCR *, recno_t *);
- */
-int
-api_lline(SCR *sp, recno_t *lnop)
-{
-       return (db_last(sp, lnop));
-}
-
-/*
- * api_sline --
- *     Set a line.
- *
- * PUBLIC: int api_sline(SCR *, recno_t, char *, size_t);
- */
-int
-api_sline(SCR *sp, recno_t lno, char *line, size_t len)
-{
-       return (db_set(sp, lno, line, len));
-}
-
-/*
- * api_getmark --
- *     Get the mark.
- *
- * PUBLIC: int api_getmark(SCR *, int, MARK *);
- */
-int
-api_getmark(SCR *sp, int markname, MARK *mp)
-{
-       return (mark_get(sp, (ARG_CHAR_T)markname, mp, M_ERR));
-}
-
-/*
- * api_setmark --
- *     Set the mark.
- *
- * PUBLIC: int api_setmark(SCR *, int, MARK *);
- */
-int
-api_setmark(SCR *sp, int markname, MARK *mp)
-{
-       return (mark_set(sp, (ARG_CHAR_T)markname, mp, 1));
-}
-
-/*
- * api_nextmark --
- *     Return the first mark if next not set, otherwise return the
- *     subsequent mark.
- *
- * PUBLIC: int api_nextmark(SCR *, int, char *);
- */
-int
-api_nextmark(SCR *sp, int next, char *namep)
-{
-       LMARK *mp;
-
-       mp = LIST_FIRST(&sp->ep->marks);
-       if (next)
-               LIST_FOREACH(mp, &sp->ep->marks, q)
-                       if (mp->name == *namep) {
-                               mp = LIST_NEXT(mp, q);
-                               break;
-                       }
-       if (mp == NULL)
-               return (1);
-       *namep = mp->name;
-       return (0);
-}
-
-/*
- * api_getcursor --
- *     Get the cursor.
- *
- * PUBLIC: int api_getcursor(SCR *, MARK *);
- */
-int
-api_getcursor(SCR *sp, MARK *mp)
-{
-       mp->lno = sp->lno;
-       mp->cno = sp->cno;
-       return (0);
-}
-
-/*
- * api_setcursor --
- *     Set the cursor.
- *
- * PUBLIC: int api_setcursor(SCR *, MARK *);
- */
-int
-api_setcursor(SCR *sp, MARK *mp)
-{
-       size_t len;
-
-       if (db_get(sp, mp->lno, DBG_FATAL, NULL, &len))
-               return (1);
-       if (mp->cno < 0 || mp->cno > len) {
-               msgq(sp, M_ERR, "Cursor set to nonexistent column");
-               return (1);
-       }
-
-       /* Set the cursor. */
-       sp->lno = mp->lno;
-       sp->cno = mp->cno;
-       return (0);
-}
-
-/*
- * api_emessage --
- *     Print an error message.
- *
- * PUBLIC: void api_emessage(SCR *, char *);
- */
-void
-api_emessage(SCR *sp, char *text)
-{
-       msgq(sp, M_ERR, "%s", text);
-}
-
-/*
- * api_imessage --
- *     Print an informational message.
- *
- * PUBLIC: void api_imessage(SCR *, char *);
- */
-void
-api_imessage(SCR *sp, char *text)
-{
-       msgq(sp, M_INFO, "%s", text);
-}
-
-/*
- * api_edit
- *     Create a new screen and return its id 
- *     or edit a new file in the current screen.
- *
- * PUBLIC: int api_edit(SCR *, char *, SCR **, int);
- */
-int
-api_edit(SCR *sp, char *file, SCR **spp, int newscreen)
-{
-       ARGS *ap[2], a;
-       EXCMD cmd;
-
-       if (file) {
-               ex_cinit(&cmd, C_EDIT, 0, OOBLNO, OOBLNO, 0, ap);
-               ex_cadd(&cmd, &a, file, strlen(file));
-       } else
-               ex_cinit(&cmd, C_EDIT, 0, OOBLNO, OOBLNO, 0, NULL);
-       if (newscreen)
-               cmd.flags |= E_NEWSCREEN;               /* XXX */
-       if (cmd.cmd->fn(sp, &cmd))
-               return (1);
-       *spp = sp->nextdisp;
-       return (0);
-}
-
-/*
- * api_escreen
- *     End a screen.
- *
- * PUBLIC: int api_escreen(SCR *);
- */
-int
-api_escreen(SCR *sp)
-{
-       EXCMD cmd;
-
-       /*
-        * XXX
-        * If the interpreter exits anything other than the current
-        * screen, vi isn't going to update everything correctly.
-        */
-       ex_cinit(&cmd, C_QUIT, 0, OOBLNO, OOBLNO, 0, NULL);
-       return (cmd.cmd->fn(sp, &cmd));
-}
-
-/*
- * api_swscreen --
- *    Switch to a new screen.
- *
- * PUBLIC: int api_swscreen(SCR *, SCR *);
- */
-int
-api_swscreen(SCR *sp, SCR *new)
-{
-       /*
-        * XXX
-        * If the interpreter switches from anything other than the
-        * current screen, vi isn't going to update everything correctly.
-        */
-       sp->nextdisp = new;
-       F_SET(sp, SC_SSWITCH);
-
-       return (0);
-}
-
-/*
- * api_map --
- *     Map a key.
- *
- * PUBLIC: int api_map(SCR *, char *, char *, size_t);
- */
-int
-api_map(SCR *sp, char *name, char *map, size_t len)
-{
-       ARGS *ap[3], a, b;
-       EXCMD cmd;
-
-       ex_cinit(&cmd, C_MAP, 0, OOBLNO, OOBLNO, 0, ap);
-       ex_cadd(&cmd, &a, name, strlen(name));
-       ex_cadd(&cmd, &b, map, len);
-       return (cmd.cmd->fn(sp, &cmd));
-}
-
-/*
- * api_unmap --
- *     Unmap a key.
- *
- * PUBLIC: int api_unmap(SCR *, char *);
- */
-int 
-api_unmap(SCR *sp, char *name)
-{
-       ARGS *ap[2], a;
-       EXCMD cmd;
-
-       ex_cinit(&cmd, C_UNMAP, 0, OOBLNO, OOBLNO, 0, ap);
-       ex_cadd(&cmd, &a, name, strlen(name));
-       return (cmd.cmd->fn(sp, &cmd));
-}
-
-/*
- * api_opts_get --
- *     Return a option value as a string, in allocated memory.
- *     If the option is of type boolean, boolvalue is (un)set
- *     according to the value; otherwise boolvalue is -1.
- *
- * PUBLIC: int api_opts_get(SCR *, char *, char **, int *);
- */
-int
-api_opts_get(SCR *sp, char *name, char **value, int *boolvalue)
-{
-       OPTLIST const *op;
-       int offset;
-       size_t len;
-
-       if ((op = opts_search(name)) == NULL) {
-               opts_nomatch(sp, name);
-               return (1);
-       }
-
-       offset = op - optlist;
-       if (boolvalue != NULL)
-               *boolvalue = -1;
-       switch (op->type) {
-       case OPT_0BOOL:
-       case OPT_1BOOL:
-               len = strlen(op->name) + 2 + 1;
-               MALLOC_RET(sp, *value, char *, len);
-               (void)snprintf(*value, len,
-                   "%s%s", O_ISSET(sp, offset) ? "" : "no", op->name);
-               if (boolvalue != NULL)
-                       *boolvalue = O_ISSET(sp, offset);
-               break;
-       case OPT_NUM:
-               len = 20;
-               MALLOC_RET(sp, *value, char *, len);
-               (void)snprintf(*value, len, "%lu", (u_long)O_VAL(sp, offset));
-               break;
-       case OPT_STR:
-               if (O_STR(sp, offset) == NULL) {
-                       MALLOC_RET(sp, *value, char *, 2);
-                       value[0] = '\0';
-               } else {
-                       len = strlen(O_STR(sp, offset)) + 1;
-                       MALLOC_RET(sp,
-                           *value, char *, len);
-                       (void)snprintf(*value, len, "%s", O_STR(sp, offset));
-               }
-               break;
-       }
-       return (0);
-}
-
-/*
- * api_opts_set --
- *     Set options.
- *
- * PUBLIC: int api_opts_set(SCR *, char *, char *, u_long, int);
- */
-int
-api_opts_set(SCR *sp, char *name, char *str_value, u_long num_value,
-    int bool_value)
-{
-       ARGS *ap[2], a, b;
-       OPTLIST const *op;
-       int rval;
-       size_t blen;
-       char *bp;
-
-       if ((op = opts_search(name)) == NULL) {
-               opts_nomatch(sp, name);
-               return (1);
-       }
-
-       switch (op->type) {
-       case OPT_0BOOL:
-       case OPT_1BOOL:
-               GET_SPACE_RET(sp, bp, blen, 64);
-               a.len = snprintf(bp, 64, "%s%s", bool_value ? "" : "no", name);
-               if (a.len > 63)
-                       a.len = 63;
-               break;
-       case OPT_NUM:
-               GET_SPACE_RET(sp, bp, blen, 64);
-               a.len = snprintf(bp, 64, "%s=%lu", name, num_value);
-               if (a.len > 63)
-                       a.len = 63;
-               break;
-       case OPT_STR:
-               GET_SPACE_RET(sp, bp, blen, 1024);
-               a.len = snprintf(bp, 1024, "%s=%s", name, str_value);
-               if (a.len > 1023)
-                       a.len = 1023;
-               break;
-       }
-       a.bp = bp;
-       b.len = 0;
-       b.bp = NULL;
-       ap[0] = &a;
-       ap[1] = &b;
-       rval = opts_set(sp, ap, NULL);
-
-       FREE_SPACE(sp, bp, blen);
-
-       return (rval);
-}
-
-/*
- * api_run_str --
- *      Execute a string as an ex command.
- *
- * PUBLIC: int api_run_str(SCR *, char *);
- */
-int     
-api_run_str(SCR *sp, char *cmd)
-{
-       return (ex_run_str(sp, NULL, cmd, strlen(cmd), 0, 0));
-}
Index: common/gs.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/gs.h,v
retrieving revision 1.12
diff -u -r1.12 gs.h
--- common/gs.h 14 Nov 2014 20:26:12 -0000      1.12
+++ common/gs.h 15 Nov 2014 07:51:17 -0000
@@ -63,8 +63,6 @@
 
        SCR     *ccl_sp;                /* Colon command-line screen. */
 
-       void    *perl_interp;           /* Perl interpreter. */
-
        void    *cl_private;            /* Curses support private area. */
        void    *ip_private;            /* IP support private area. */
        void    *tk_private;            /* Tk/Tcl support private area. */
Index: common/main.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/main.c,v
retrieving revision 1.24
diff -u -r1.24 main.c
--- common/main.c       14 Nov 2014 20:27:03 -0000      1.24
+++ common/main.c       15 Nov 2014 07:48:40 -0000
@@ -457,10 +457,6 @@
        while ((sp = TAILQ_FIRST(&gp->hq)))
                (void)screen_end(sp);   /* Removes sp from the queue. */
 
-#ifdef HAVE_PERL_INTERP
-       perl_end(gp);
-#endif
-
 #if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
        { FREF *frp;
                /* Free FREF's. */
Index: common/screen.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/screen.c,v
retrieving revision 1.11
diff -u -r1.11 screen.c
--- common/screen.c     12 Nov 2014 04:28:41 -0000      1.11
+++ common/screen.c     15 Nov 2014 07:48:34 -0000
@@ -157,10 +157,6 @@
        F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
 
        rval = 0;
-#ifdef HAVE_PERL_INTERP
-       if (perl_screen_end(sp))                /* End perl. */
-               rval = 1;
-#endif
        if (v_screen_end(sp))                   /* End vi. */
                rval = 1;
        if (ex_screen_end(sp))                  /* End ex. */
Index: common/screen.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/screen.h,v
retrieving revision 1.6
diff -u -r1.6 screen.h
--- common/screen.h     28 Nov 2013 22:12:40 -0000      1.6
+++ common/screen.h     15 Nov 2014 07:51:33 -0000
@@ -91,7 +91,6 @@
 
        void    *ex_private;            /* Ex private area. */
        void    *vi_private;            /* Vi private area. */
-       void    *perl_private;          /* Perl private area. */
 
 /* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */
        char    *alt_name;              /* Ex/vi: alternate file name. */
Index: docs/help
===================================================================
RCS file: /cvs/src/usr.bin/vi/docs/help,v
retrieving revision 1.4
diff -u -r1.4 help
--- docs/help   14 Nov 2014 20:26:13 -0000      1.4
+++ docs/help   15 Nov 2014 07:51:51 -0000
@@ -165,8 +165,6 @@
       number: change display to number lines
        open: enter "open" mode (not implemented)
        print: display lines
-       perl: run the perl interpreter with the command
-      perldo: run the perl interpreter with the command, on each line
     preserve: preserve an edit session for recovery
  [Pp]revious: edit the previous file in the file argument list
         put: append a cut buffer to the line
Index: docs/USD.doc/vi.ref/vi.ref
===================================================================
RCS file: /cvs/src/usr.bin/vi/docs/USD.doc/vi.ref/vi.ref,v
retrieving revision 1.10
diff -u -r1.10 vi.ref
--- docs/USD.doc/vi.ref/vi.ref  24 Jan 2004 12:26:47 -0000      1.10
+++ docs/USD.doc/vi.ref/vi.ref  15 Nov 2014 07:54:13 -0000
@@ -272,17 +272,6 @@
 The
 .CO previous
 command edits the previous file from the argument list.
-.IP "Scripting languages"
-The
-.CO ":pe[rl] cmd" ,
-.CO ":perld[o] cmd"
-and
-.CO ":tc[l] cmd"
-commands execute Perl and Tcl/Tk commands, respectively,
-on lines from the edit buffer.
-See the
-.QB "Scripting Languages"
-section and the specific commands for more information.
 .\".IP "Shell screens"
 .\"The
 .\".CO ":sc[ript] [file ...]"
@@ -1202,128 +1191,6 @@
 (The
 .LI <control-M>
 will be discarded.)
-.SH 1 "Scripting Languages"
-.pp
-The
-.CO nvi
-editor currently supports two scripting languages, Tcl/Tk and Perl.
-(Note that Perl4 isn't sufficient, and that the Perl5 used must be
-version 5.002 or later.
-See the
-.QB "Building Nvi"
-section for more information.)
-Note that the Tcl/Tk interface is not supported in the current version
-of OpenBSD.
-.pp
-The scripting language interface is still being worked on,
-therefore the following information is probably incomplete,
-probably wrong in cases, and likely to change.
-See the
-.LI perl_api
-and
-.LI tcl_api
-source directories for more information.
-As a quick reference, the following function calls are provided for
-both the Perl and Tcl interfaces.
-The Perl interface uses a slightly different naming convention,
-e.g. ``viFindScreen'' is named ``VI::FindScreen''.
-.IP "viFindScreen file"
-Return the
-.LI "screenId" associated with
-.LI file .
-.IP "viAppendLine screenId lineNumber text"
-Append
-.LI text
-as a new line after line number
-.LI lineNumber ,
-in the screen
-.LI screenId .
-.IP "viDelLine screenId lineNum"
-Delete the line
-.LI lineNumber
-from the screen
-.LI screenId .
-.IP "viGetLine screenId lineNumber"
-Return the line
-.LI lineNumber
-from the screen
-.LI screenId .
-.IP "viInsertLine screenId lineNumber text"
-Insert
-.LI text
-as a new line before line number
-.LI lineNumber
-in the screen
-.LI screenId .
-.IP "viLastLine screenId"
-Return the line number of the last line in the screen
-.LI screenId .
-.IP "viSetLine screenId lineNumber text"
-Change the line
-.LI lineNumber
-in the screen
-.LI screenId
-to match the specified
-.LI text .
-.IP "viGetMark screenId mark"
-Return the current line and column for the specified
-.LI mark
-from the screen
-.LI screenId .
-.IP "viSetMark screenId mark line column"
-Set the specified
-.LI mark
-to be at line
-.LI line ,
-column
-.LI column ,
-in the screen
-.LI screenId .
-.IP "viGetCursor screenId"
-Return the current line and column for the cursor in the screen
-.LI screenId .
-.IP "viSetCursor screenId line column"
-Set the cursor in the screen
-.LI screenId
-to the specified
-.LI line
-and
-.LI column .
-.IP "viMsg screenId text"
-Display the specified
-.LI text
-as a vi message in the screen
-.LI screenId .
-.IP "viNewScreen screenId [file]"
-Create a new screen.
-.IP "viEndScreen screenId"
-Exit the screen
-.LI screenId .
-.IP "viSwitchScreen screenId screenId"
-Switch from the screen
-.LI screenId
-to the screen
-.LI screenId .
-.IP "viMapKey screenId key tclproc"
-Map the specified
-.LI key
-in the screen
-.LI screenId
-to the Tcl procedure
-.LI tclproc .
-.IP "viUnmMapKey screenId key"
-Unmap the specified
-.LI key
-in the screen
-.LI screenId
-.IP "viGetOpt screenId option"
-Return the value of the specified
-.LI option
-from the screen
-.LI screenId .
-.IP "viSetOpt screenId command"
-Set one or more options in the screen
-.LI screenId .
 .SH 1 "General Editor Description"
 .pp
 When
Index: ex/ex_cmd.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_cmd.c,v
retrieving revision 1.8
diff -u -r1.8 ex_cmd.c
--- ex/ex_cmd.c 14 Nov 2014 20:26:13 -0000      1.8
+++ ex/ex_cmd.c 15 Nov 2014 07:47:00 -0000
@@ -247,18 +247,6 @@
            "ca1",
            "[line [,line]] p[rint] [count] [#l]",
            "display lines"},
-/* C_PERLCMD */
-       {"perl",        ex_perl,        E_ADDR2_ALL|E_ADDR_ZERO|
-                                           E_ADDR_ZERODEF|E_SECURE,
-           "s",
-           "pe[rl] cmd",
-           "run the perl interpreter with the command"},
-/* C_PERLDOCMD */
-       {"perldo",      ex_perl,        E_ADDR2_ALL|E_ADDR_ZERO|
-                                           E_ADDR_ZERODEF|E_SECURE,
-           "s",
-           "perld[o] cmd",
-           "run the perl interpreter with the command, on each line"},
 /* C_PRESERVE */
        {"preserve",    ex_preserve,    0,
            "",
Index: ex/ex_perl.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_perl.c,v
retrieving revision 1.7
diff -u -r1.7 ex_perl.c
--- ex/ex_perl.c        12 Nov 2014 04:28:41 -0000      1.7
+++ ex/ex_perl.c        15 Nov 2014 07:46:18 -0000
@@ -1,65 +0,0 @@
-/*     $OpenBSD: ex_perl.c,v 1.7 2014/11/12 04:28:41 bentley Exp $     */
-
-/*-
- * 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"
-
-#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.
- *
- * ex_perldo -- :[line [,line]] perldo [command]
- *     Run a set of lines through the perl interpreter.
- *
- * PUBLIC: int ex_perl(SCR*, EXCMD *);
- */
-int 
-ex_perl(SCR *sp, 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) {
-               ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
-               return (1);
-       }
-       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));
-#else
-       msgq(sp, M_ERR, "306|Vi was not loaded with a Perl interpreter");
-       return (1);
-#endif
-}
Index: include/com_extern.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/include/com_extern.h,v
retrieving revision 1.6
diff -u -r1.6 com_extern.h
--- include/com_extern.h        10 Nov 2014 21:40:11 -0000      1.6
+++ include/com_extern.h        15 Nov 2014 08:00:08 -0000
@@ -1,27 +1,5 @@
 /*     $OpenBSD: com_extern.h,v 1.6 2014/11/10 21:40:11 tedu Exp $     */
 
-SCR *api_fscreen(int, char *);
-int api_aline(SCR *, recno_t, char *, size_t);
-int api_dline(SCR *, recno_t);
-int api_gline(SCR *, recno_t, char **, size_t *);
-int api_iline(SCR *, recno_t, char *, size_t);
-int api_lline(SCR *, recno_t *);
-int api_sline(SCR *, recno_t, char *, size_t);
-int api_getmark(SCR *, int, MARK *);
-int api_setmark(SCR *, int, MARK *);
-int api_nextmark(SCR *, int, char *);
-int api_getcursor(SCR *, MARK *);
-int api_setcursor(SCR *, MARK *);
-void api_emessage(SCR *, char *);
-void api_imessage(SCR *, char *);
-int api_edit(SCR *, char *, SCR **, int);
-int api_escreen(SCR *);
-int api_swscreen(SCR *, SCR *);
-int api_map(SCR *, char *, char *, size_t);
-int api_unmap(SCR *, char *);
-int api_opts_get(SCR *, char *, char **, int *);
-int api_opts_set(SCR *, char *, char *, u_long, int);
-int api_run_str(SCR *, char *);
 int cut(SCR *, CHAR_T *, MARK *, MARK *, int);
 int cut_line(SCR *, recno_t, size_t, size_t, CB *);
 void cut_close(GS *);
Index: include/ex_def.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/include/ex_def.h,v
retrieving revision 1.3
diff -u -r1.3 ex_def.h
--- include/ex_def.h    14 Nov 2014 20:26:13 -0000      1.3
+++ include/ex_def.h    15 Nov 2014 07:48:21 -0000
@@ -39,41 +39,39 @@
 #define C_NUMBER 36
 #define C_OPEN 37
 #define C_PRINT 38
-#define C_PERLCMD 39
-#define C_PERLDOCMD 40
-#define C_PRESERVE 41
-#define C_PREVIOUS 42
-#define C_PUT 43
-#define C_QUIT 44
-#define C_READ 45
-#define C_RECOVER 46
-#define C_RESIZE 47
-#define C_REWIND 48
-#define C_SUBSTITUTE 49
-#define C_SCRIPT 50
-#define C_SET 51
-#define C_SHELL 52
-#define C_SOURCE 53
-#define C_STOP 54
-#define C_SUSPEND 55
-#define C_T 56
-#define C_TAG 57
-#define C_TAGNEXT 58
-#define C_TAGPOP 59
-#define C_TAGPREV 60
-#define C_TAGTOP 61
-#define C_UNDO 62
-#define C_UNABBREVIATE 63
-#define C_UNMAP 64
-#define C_V 65
-#define C_VERSION 66
-#define C_VISUAL_EX 67
-#define C_VISUAL_VI 68
-#define C_VIUSAGE 69
-#define C_WRITE 70
-#define C_WN 71
-#define C_WQ 72
-#define C_XIT 73
-#define C_YANK 74
-#define C_Z 75
-#define C_SUBTILDE 76
+#define C_PRESERVE 39
+#define C_PREVIOUS 40
+#define C_PUT 41
+#define C_QUIT 42
+#define C_READ 43
+#define C_RECOVER 44
+#define C_RESIZE 45
+#define C_REWIND 46
+#define C_SUBSTITUTE 47
+#define C_SCRIPT 48
+#define C_SET 49
+#define C_SHELL 50
+#define C_SOURCE 51
+#define C_STOP 52
+#define C_SUSPEND 53
+#define C_T 54
+#define C_TAG 55
+#define C_TAGNEXT 56
+#define C_TAGPOP 57
+#define C_TAGPREV 58
+#define C_TAGTOP 59
+#define C_UNDO 60
+#define C_UNABBREVIATE 61
+#define C_UNMAP 62
+#define C_V 63
+#define C_VERSION 64
+#define C_VISUAL_EX 65
+#define C_VISUAL_VI 66
+#define C_VIUSAGE 67
+#define C_WRITE 68
+#define C_WN 69
+#define C_WQ 70
+#define C_XIT 71
+#define C_YANK 72
+#define C_Z 73
+#define C_SUBTILDE 74
Index: include/ex_extern.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/include/ex_extern.h,v
retrieving revision 1.11
diff -u -r1.11 ex_extern.h
--- include/ex_extern.h 14 Nov 2014 20:26:13 -0000      1.11
+++ include/ex_extern.h 15 Nov 2014 07:54:51 -0000
@@ -51,7 +51,6 @@
 int ex_copy(SCR *, EXCMD *);
 int ex_move(SCR *, EXCMD *);
 int ex_open(SCR *, EXCMD *);
-int ex_perl(SCR*, EXCMD *);
 int ex_preserve(SCR *, EXCMD *);
 int ex_recover(SCR *, EXCMD *);
 int ex_list(SCR *, EXCMD *);
Index: include/perl_extern.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/include/perl_extern.h,v
retrieving revision 1.5
diff -u -r1.5 perl_extern.h
--- include/perl_extern.h       16 Feb 2002 21:27:58 -0000      1.5
+++ include/perl_extern.h       15 Nov 2014 07:52:20 -0000
@@ -1,10 +0,0 @@
-/*     $OpenBSD: perl_extern.h,v 1.5 2002/02/16 21:27:58 millert Exp $ */
-
-int perl_end(GS *);
-int perl_init(SCR *);
-int perl_screen_end(SCR*);
-int perl_ex_perl(SCR*, CHAR_T *, size_t, recno_t, recno_t);
-int perl_ex_perldo(SCR*, CHAR_T *, size_t, recno_t, recno_t);
-#ifdef USE_SFIO
-Sfdisc_t* sfdcnewnvi(SCR*);
-#endif
Index: perl_api/VI.pod
===================================================================
RCS file: /cvs/src/usr.bin/vi/perl_api/VI.pod,v
retrieving revision 1.1
diff -u -r1.1 VI.pod
--- perl_api/VI.pod     26 Nov 1999 22:49:09 -0000      1.1
+++ perl_api/VI.pod     15 Nov 2014 07:44:22 -0000
@@ -1,218 +0,0 @@
-=head1 NAME
-
-VI - VI module within perl embedded nvi
-
-=head1 SYNOPSIS
-
-    sub wc {
-      my $words;
-      $i = $VI::StartLine;
-      while ($i <= $VI::StopLine) {
-        $_ = VI::GetLine($VI::ScreenId, $i++);
-        $words+=split;
-      }
-      VI::Msg($VI::ScreenId,"$words words");
-    }
-
-=head1 DESCRIPTION
-
-This pseudo module is available to perl programs run from within nvi and
-provides access to the files being edited and some internal data.
-
-Beware that you should not use this module from within a C<perldo> or
-from within an C<END> block or a C<DESTROY> method.
-
-=head2 Variables
-
-These are set by nvi before starting each perl command.
-
-=over 8
-
-=item * $ScreenId
-
-Screen id of the current screen.
-
-=item * $StartLine
-
-Line number of the first line of the selected range or of the file if no
-range was specified.
-
-=item * $StopLine
-
-Line number of the last line of the selected range or of the file if no
-range was specified.
-
-=back
-
-=head2 Functions
-
-=over 8
-
-=item * AppendLine
-
-    VI::AppendLine(screenId,lineNumber,text);
-
-Append the string text after the line in lineNumber.
-
-=item * DelLine
-
-    VI::DelLine(screenId,lineNum);
-
-Delete lineNum.
-
-=item * EndScreen
-
-VI::EndScreen(screenId);
-
-End a screen.
-
-=item * FindScreen
-
-    VI::FindScreen(file);
-
-Return the screen id associated with file name.
-
-=item * GetCursor
-
-    ($line, $column) = VI::GetCursor(screenId);
-
-Return the current cursor position as a list with two elements.
-
-=item * GetLine
-
-    VI::GetLine(screenId,lineNumber);
-
-Return lineNumber.
-
-=item * GetMark
-
-    ($line, $column) = VI::GetMark(screenId,mark);
-
-Return the mark's cursor position as a list with two elements.
-
-=item * GetOpt
-
-    VI::GetOpt(screenId,option);
-
-Return the value of an option.
-
-=item * InsertLine
-
-    VI::InsertLine(screenId,lineNumber,text);
-
-Insert the string text before the line in lineNumber.
-
-=item * LastLine
-
-    VI::LastLine(screenId);
-
-Return the last line in the screen.
-
-=item * MapKey
-
-    VI::MapKey(screenId,key,perlproc);
-
-Associate a key with a perl procedure.
-
-=item * Msg
-
-    VI::Msg(screenId,text);
-
-Set the message line to text.
-
-=item * NewScreen
-
-    VI::NewScreen(screenId);
-    VI::NewScreen(screenId,file);
-
-Create a new screen.  If a filename is specified then the screen is
-opened with that file.
-
-=item * Run
-
-    VI::Run(screenId,cmd);
-
-Run the ex command cmd.
-
-=item * SetCursor
-
-    VI::SetCursor(screenId,line,column);
-
-Set the cursor to the line and column numbers supplied.
-
-=item * SetLine
-
-    VI::SetLine(screenId,lineNumber,text);
-
-Set lineNumber to the text supplied.
-
-=item * SetMark
-
-    VI::SetMark(screenId,mark,line,column);
-
-Set the mark to the line and column numbers supplied.
-
-=item * SetOpt
-
-    VI::SetOpt(screenId,command);
-
-Set an option.
-
-=item * SwitchScreen
-
-    VI::SwitchScreen(screenId,screenId);
-
-Change the current focus to screen.
-
-=item * UnmapKey
-
-    VI::UnmmapKey(screenId,key);
-
-Unmap a key.
-
-=item * Warn
-
-This is the default warning handler.
-It adds any warnings to the error string.
-
-=back
-
-=head1 EXAMPLES
-
-    sub showmarks {
-      my ($mark, $all);
-      for $mark ('a' .. 'z') {
-        eval {VI::GetMark($VI::ScreenId, $mark)};
-        $all .= $mark unless ($@);
-      }
-      VI::Msg($VI::ScreenId,"Set marks: $all");
-    }
-
-    sub forall {
-      my ($code) = shift;
-      my ($i) = $VI::StartLine-1;
-      while (++$i <= $VI::StopLine) {
-        $_ = VI::GetLine($VI::ScreenId, $i);
-        VI::SetLine($VI::ScreenId, $i, $_) if(&$code);
-      }
-    }
-
-Now you can do
-
-    :perl forall sub{s/perlre/substitution/}
-
-Although you'll probably use
-
-    :perldo s/perlre/substitution/
-
-instead.
-
-See L<perlre> for perl regular expressions.
-
-=head1 SEE ALSO
-
-L<nviperl>
-
-=head1 AUTHOR
-
-Sven Verdoolaege <[email protected]>
Index: perl_api/nviperl.pod
===================================================================
RCS file: /cvs/src/usr.bin/vi/perl_api/nviperl.pod,v
retrieving revision 1.1
diff -u -r1.1 nviperl.pod
--- perl_api/nviperl.pod        26 Nov 1999 22:49:09 -0000      1.1
+++ perl_api/nviperl.pod        15 Nov 2014 07:44:25 -0000
@@ -1,43 +0,0 @@
-=head1 NAME
-
-nviperl - nvi with embedded perl
-
-=head1 SYNOPSIS
-
-    :perl require 'wc.pl'
-    :perl wc
-    :,$perldo $_=reverse($_)
-
-=head1 DESCRIPTION
-
-nvi with embedded perl allows you to run perl commands from within nvi.
-Two additional commands are made available when you enable the perl
-interpreter:
-
-=over 8
-
-=item * perl cmd
-
-The perl command passes the specified commands to the perl interpreter.
-The C<$VI::ScreenId>, C<$VI::StartLine> and C<$VI::StopLine> are set.
-To find out how to maniplulate the nvi screens, see L<VI>.
-
-=item * perldo cmd
-
-The perldo command runs the specified commands on each line of the range
-(every line of the file if no range specified).  Before running the
-command the line is copied into $_.  If the command returns a true value
-the line is replaced by the new value of $_.
-
-The perldo commando does B<not> set the C<VI> variables.  (If you think
-this is a bad idea, tell me.)
-
-=back
-
-=head1 SEE ALSO
-
-L<VI>
-
-=head1 AUTHOR
-
-Sven Verdoolaege <[email protected]>
Index: perl_api/perl.xs
===================================================================
RCS file: /cvs/src/usr.bin/vi/perl_api/perl.xs,v
retrieving revision 1.4
diff -u -r1.4 perl.xs
--- perl_api/perl.xs    27 Oct 2009 23:59:47 -0000      1.4
+++ perl_api/perl.xs    15 Nov 2014 07:44:29 -0000
@@ -1,1114 +0,0 @@
-/*     $OpenBSD: perl.xs,v 1.4 2009/10/27 23:59:47 deraadt Exp $       */
-
-/*-
- * 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"
-
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-
-#include <EXTERN.h>
-#include <perl.h>
-#include <XSUB.h>
-
-#include "perl_extern.h"
-
-static void msghandler(SCR *, mtype_t, char *, size_t);
-
-extern GS *__global_list;                      /* XXX */
-
-static char *errmsg = 0;
-
-/*
- * INITMESSAGE --
- *     Macros to point messages at the Perl message handler.
- */
-#define        INITMESSAGE                                                     
\
-       scr_msg = __global_list->scr_msg;                               \
-       __global_list->scr_msg = msghandler;
-#define        ENDMESSAGE                                                      
\
-       __global_list->scr_msg = scr_msg;                               \
-       if (rval) croak(errmsg);
-
-static void xs_init(void);
-
-/*
- * perl_end --
- *     Clean up perl interpreter
- *
- * PUBLIC: int perl_end(GS *);
- */
-int
-perl_end(gp)
-       GS *gp;
-{
-       /*
-        * Call perl_run and perl_destuct to call END blocks and DESTROY
-        * methods.
-        */
-       if (gp->perl_interp) {
-               /*Irestartop = 0;                               / * XXX */
-               perl_run(gp->perl_interp);
-               perl_destruct(gp->perl_interp);
-#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
-               perl_free(gp->perl_interp);
-#endif
-       }
-}
-
-/*
- * perl_eval
- *     Evaluate a string
- *     We don't use mortal SVs because no one will clean up after us
- */
-static void 
-perl_eval(string)
-       char *string;
-{
-#ifdef HAVE_PERL_5_003_01
-       SV* sv = newSVpv(string, 0);
-
-       perl_eval_sv(sv, G_DISCARD | G_NOARGS);
-       SvREFCNT_dec(sv);
-#else
-       char *argv[2];
-
-       argv[0] = string;
-       argv[1] = NULL;
-       perl_call_argv("_eval_", G_EVAL | G_DISCARD | G_KEEPERR, argv);
-#endif
-}
-
-/*
- * perl_init --
- *     Create the perl commands used by nvi.
- *
- * PUBLIC: int perl_init(SCR *);
- */
-int
-perl_init(scrp)
-       SCR *scrp;
-{
-       AV * av;
-       GS *gp;
-       char *bootargs[] = { "VI", NULL };
-#ifndef USE_SFIO
-       SV *svcurscr;
-#endif
-
-#ifndef HAVE_PERL_5_003_01
-       static char *args[] = { "", "-e", "sub _eval_ { eval $_[0] }" };
-#else
-       static char *args[] = { "", "-e", "" };
-#endif
-       STRLEN length;
-       char *file = __FILE__;
-
-       gp = scrp->gp;
-       gp->perl_interp = perl_alloc();
-       perl_construct(gp->perl_interp);
-       if (perl_parse(gp->perl_interp, xs_init, 3, args, 0)) {
-               perl_destruct(gp->perl_interp);
-               perl_free(gp->perl_interp);
-               gp->perl_interp = NULL;
-               return 1;
-       }
-        perl_call_argv("VI::bootstrap", G_DISCARD, bootargs);
-       perl_eval("$SIG{__WARN__}='VI::Warn'");
-
-       av_unshift(av = GvAVn(PL_incgv), 1);
-       av_store(av, 0, newSVpv(_PATH_PERLSCRIPTS,
-                               sizeof(_PATH_PERLSCRIPTS)-1));
-
-#ifdef USE_SFIO
-       sfdisc(PerlIO_stdout(), sfdcnewnvi(scrp));
-       sfdisc(PerlIO_stderr(), sfdcnewnvi(scrp));
-#else
-       svcurscr = perl_get_sv("curscr", TRUE);
-       sv_magic((SV *)gv_fetchpv("STDOUT",TRUE, SVt_PVIO), svcurscr,
-                       'q', Nullch, 0);
-       sv_magic((SV *)gv_fetchpv("STDERR",TRUE, SVt_PVIO), svcurscr,
-                       'q', Nullch, 0);
-#endif /* USE_SFIO */
-       return (0);
-}
-
-/*
- * perl_screen_end
- *     Remove all refences to the screen to be destroyed
- *
- * PUBLIC: int perl_screen_end(SCR*);
- */
-int
-perl_screen_end(scrp)
-       SCR *scrp;
-{
-       if (scrp->perl_private) {
-               sv_setiv((SV*) scrp->perl_private, 0);
-       }
-       return 0;
-}
-
-static void
-my_sighandler(i)
-       int i;
-{
-       croak("Perl command interrupted by SIGINT");
-}
-
-/* Create a new reference to an SV pointing to the SCR structure
- * The perl_private part of the SCR structure points to the SV,
- * so there can only be one such SV for a particular SCR structure.
- * When the last reference has gone (DESTROY is called),
- * perl_private is reset; When the screen goes away before
- * all references are gone, the value of the SV is reset;
- * any subsequent use of any of those reference will produce
- * a warning. (see typemap)
- */
-static SV *
-newVIrv(rv, screen)
-       SV *rv;
-       SCR *screen;
-{
-       sv_upgrade(rv, SVt_RV);
-       if (!screen->perl_private) {
-               screen->perl_private = newSV(0);
-               sv_setiv(screen->perl_private, (IV) screen);
-       } 
-       else SvREFCNT_inc(screen->perl_private);
-       SvRV(rv) = screen->perl_private;
-       SvROK_on(rv);
-       return sv_bless(rv, gv_stashpv("VI", TRUE));
-}
-
-
-/* 
- * perl_ex_perl -- :[line [,line]] perl [command]
- *     Run a command through the perl interpreter.
- *
- * PUBLIC: int perl_ex_perl(SCR*, CHAR_T *, size_t, recno_t, recno_t);
- */
-int 
-perl_ex_perl(scrp, cmdp, cmdlen, f_lno, t_lno)
-       SCR *scrp;
-       CHAR_T *cmdp;
-       size_t cmdlen;
-       recno_t f_lno, t_lno;
-{
-       static SV *svcurscr = 0, *svstart, *svstop, *svid;
-       GS *gp;
-       STRLEN length;
-       size_t len;
-       char *err;
-       Signal_t (*istat)();
-
-       /* Initialize the interpreter. */
-       gp = scrp->gp;
-       if (!svcurscr) {
-               if (gp->perl_interp == NULL && perl_init(scrp))
-                       return (1);
-               SvREADONLY_on(svcurscr = perl_get_sv("curscr", TRUE));
-               SvREADONLY_on(svstart = perl_get_sv("VI::StartLine", TRUE));
-               SvREADONLY_on(svstop = perl_get_sv("VI::StopLine", TRUE));
-               SvREADONLY_on(svid = perl_get_sv("VI::ScreenId", TRUE));
-       }
-
-       sv_setiv(svstart, f_lno);
-       sv_setiv(svstop, t_lno);
-       newVIrv(svcurscr, scrp);
-       /* Backwards compatibility. */
-       newVIrv(svid, scrp);
-
-       istat = signal(SIGINT, my_sighandler);
-       perl_eval(cmdp);
-       signal(SIGINT, istat);
-
-       SvREFCNT_dec(SvRV(svcurscr));
-       SvROK_off(svcurscr);
-       SvREFCNT_dec(SvRV(svid));
-       SvROK_off(svid);
-
-       err = SvPV(GvSV(errgv), length);
-       if (!length)
-               return (0);
-
-       err[length - 1] = '\0';
-       msgq(scrp, M_ERR, "perl: %s", err);
-       return (1);
-}
-
-/*
- * replace_line
- *     replace a line with the contents of the perl variable $_
- *     lines are split at '\n's
- *     if $_ is undef, the line is deleted
- *     returns possibly adjusted linenumber
- */
-static int 
-replace_line(scrp, line, t_lno)
-       SCR *scrp;
-       recno_t line, *t_lno;
-{
-       char *str, *next;
-       size_t len;
-
-       if (SvOK(GvSV(defgv))) {
-               str = SvPV(GvSV(defgv),len);
-               next = memchr(str, '\n', len);
-               api_sline(scrp, line, str, next ? (next - str) : len);
-               while (next++) {
-                       len -= next - str;
-                       next = memchr(str = next, '\n', len);
-                       api_iline(scrp, ++line, str, next ? (next - str) : len);
-                       (*t_lno)++;
-               }
-       } else {
-               api_dline(scrp, line--);
-               (*t_lno)--;
-       }
-       return line;
-}
-
-/* 
- * perl_ex_perldo -- :[line [,line]] perl [command]
- *     Run a set of lines through the perl interpreter.
- *
- * PUBLIC: int perl_ex_perldo(SCR*, CHAR_T *, size_t, recno_t, recno_t);
- */
-int 
-perl_ex_perldo(scrp, cmdp, cmdlen, f_lno, t_lno)
-       SCR *scrp;
-       CHAR_T *cmdp;
-       size_t cmdlen;
-       recno_t f_lno, t_lno;
-{
-       static SV *svcurscr = 0, *svstart, *svstop, *svid;
-       CHAR_T *p;
-       GS *gp;
-       STRLEN length;
-       size_t len;
-       recno_t i;
-       char *str;
-#ifndef HAVE_PERL_5_003_01
-       char *argv[2];
-#else
-       SV* sv;
-#endif
-       dSP;
-
-       /* Initialize the interpreter. */
-       gp = scrp->gp;
-       if (!svcurscr) {
-               if (gp->perl_interp == NULL && perl_init(scrp))
-                       return (1);
-               SPAGAIN;
-               SvREADONLY_on(svcurscr = perl_get_sv("curscr", TRUE));
-               SvREADONLY_on(svstart = perl_get_sv("VI::StartLine", TRUE));
-               SvREADONLY_on(svstop = perl_get_sv("VI::StopLine", TRUE));
-               SvREADONLY_on(svid = perl_get_sv("VI::ScreenId", TRUE));
-       }
-
-#ifndef HAVE_PERL_5_003_01
-       argv[0] = cmdp;
-       argv[1] = NULL;
-#else
-       length = strlen(cmdp);
-       sv = newSV(length + sizeof("sub VI::perldo {")-1 + 1 /* } */);
-       sv_setpvn(sv, "sub VI::perldo {", sizeof("sub VI::perldo {")-1); 
-       sv_catpvn(sv, cmdp, length);
-       sv_catpvn(sv, "}", 1);
-       perl_eval_sv(sv, G_DISCARD | G_NOARGS);
-       SvREFCNT_dec(sv);
-       str = SvPV(GvSV(errgv),length);
-       if (length)
-               goto err;
-#endif
-
-       newVIrv(svcurscr, scrp);
-       /* Backwards compatibility. */
-       newVIrv(svid, scrp);
-
-       ENTER;
-       SAVETMPS;
-       for (i = f_lno; i <= t_lno && !api_gline(scrp, i, &str, &len); i++) {
-               sv_setpvn(GvSV(defgv),str,len);
-               sv_setiv(svstart, i);
-               sv_setiv(svstop, i);
-#ifndef HAVE_PERL_5_003_01
-               perl_call_argv("_eval_", G_SCALAR | G_EVAL | G_KEEPERR, argv);
-#else
-               PUSHMARK(sp);
-                perl_call_pv("VI::perldo", G_SCALAR | G_EVAL);
-#endif
-               str = SvPV(GvSV(errgv), length);
-               if (length) break;
-               SPAGAIN;
-               if(SvTRUEx(POPs)) 
-                       i = replace_line(scrp, i, &t_lno);
-               PUTBACK;
-       }
-       FREETMPS;
-       LEAVE;
-
-       SvREFCNT_dec(SvRV(svcurscr));
-       SvROK_off(svcurscr);
-       SvREFCNT_dec(SvRV(svid));
-       SvROK_off(svid);
-
-       if (!length)
-               return (0);
-
-err:   str[length - 1] = '\0';
-       msgq(scrp, M_ERR, "perl: %s", str);
-       return (1);
-}
-
-/*
- * msghandler --
- *     Perl message routine so that error messages are processed in
- *     Perl, not in nvi.
- */
-static void
-msghandler(sp, mtype, msg, len)
-       SCR *sp;
-       mtype_t mtype;
-       char *msg;
-       size_t len;
-{
-       /* Replace the trailing <newline> with an EOS. */
-       /* Let's do that later instead */
-       if (errmsg) free (errmsg);
-       errmsg = malloc(len + 1);
-       memcpy(errmsg, msg, len);
-       errmsg[len] = '\0';
-}
-
-/* Register any extra external extensions */
-
-extern void boot_DynaLoader _((CV* cv));
-extern void boot_VI _((CV* cv));
-
-static void
-xs_init()
-{
-       char *file = __FILE__;
-
-#ifdef HAVE_PERL_5_003_01
-       dXSUB_SYS;
-#endif
-
-       newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
-       newXS("VI::bootstrap", boot_VI, file);
-}
-
-typedef SCR *  VI;
-typedef SCR *  VI__OPT;
-typedef SCR *  VI__MAP;
-typedef SCR *  VI__MARK;
-typedef AV *   AVREF;
-
-MODULE = VI    PACKAGE = VI
-
-# msg --
-#      Set the message line to text.
-#
-# Perl Command: VI::Msg
-# Usage: VI::Msg screenId text
-
-void
-Msg(screen, text)
-       VI          screen
-       char *      text
- 
-       ALIAS:
-       PRINT = 1
-
-       CODE:
-       api_imessage(screen, text);
-
-# XS_VI_escreen --
-#      End a screen.
-#
-# Perl Command: VI::EndScreen
-# Usage: VI::EndScreen screenId
-
-void
-EndScreen(screen)
-       VI      screen
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       rval = api_escreen(screen);
-       ENDMESSAGE;
-
-# XS_VI_iscreen --
-#      Create a new screen.  If a filename is specified then the screen
-#      is opened with that file.
-#
-# Perl Command: VI::NewScreen
-# Usage: VI::NewScreen screenId [file]
-
-VI
-Edit(screen, ...)
-       VI screen
-
-       ALIAS:
-       NewScreen = 1
-
-       PROTOTYPE: $;$
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-       char *file;
-       SCR *nsp;
-
-       CODE:
-       file = (items == 1) ? NULL : (char *)SvPV(ST(1),na);
-       INITMESSAGE;
-       rval = api_edit(screen, file, &nsp, ix);
-       ENDMESSAGE;
-       
-       RETVAL = ix ? nsp : screen;
-
-       OUTPUT:
-       RETVAL
-
-# XS_VI_fscreen --
-#      Return the screen id associated with file name.
-#
-# Perl Command: VI::FindScreen
-# Usage: VI::FindScreen file
-
-VI
-FindScreen(file)
-       char *file
-
-       PREINIT:
-       SCR *fsp;
-       CODE:
-       RETVAL = api_fscreen(0, file);
-
-# XS_VI_aline --
-#      -- Append the string text after the line in lineNumber.
-#
-# Perl Command: VI::AppendLine
-# Usage: VI::AppendLine screenId lineNumber text
-
-void
-AppendLine(screen, linenumber, text)
-       VI screen
-       int linenumber
-       char *text
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-       STRLEN length;
-
-       CODE:
-       SvPV(ST(2), length);
-       INITMESSAGE;
-       rval = api_aline(screen, linenumber, text, length);
-       ENDMESSAGE;
-
-# XS_VI_dline --
-#      Delete lineNum.
-#
-# Perl Command: VI::DelLine
-# Usage: VI::DelLine screenId lineNum
-
-void 
-DelLine(screen, linenumber)
-       VI screen
-       int linenumber
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       rval = api_dline(screen, (recno_t)linenumber);
-       ENDMESSAGE;
-
-# XS_VI_gline --
-#      Return lineNumber.
-#
-# Perl Command: VI::GetLine
-# Usage: VI::GetLine screenId lineNumber
-
-char *
-GetLine(screen, linenumber)
-       VI screen
-       int linenumber
-
-       PREINIT:
-       size_t len;
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-       char *line, *p;
-
-       PPCODE:
-       INITMESSAGE;
-       rval = api_gline(screen, (recno_t)linenumber, &p, &len);
-       ENDMESSAGE;
-
-       EXTEND(sp,1);
-        PUSHs(sv_2mortal(newSVpv(p, len)));
-
-# XS_VI_sline --
-#      Set lineNumber to the text supplied.
-#
-# Perl Command: VI::SetLine
-# Usage: VI::SetLine screenId lineNumber text
-
-void
-SetLine(screen, linenumber, text)
-       VI screen
-       int linenumber
-       char *text
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-       STRLEN length;
-
-       CODE:
-       SvPV(ST(2), length);
-       INITMESSAGE;
-       rval = api_sline(screen, linenumber, text, length);
-       ENDMESSAGE;
-
-# XS_VI_iline --
-#      Insert the string text before the line in lineNumber.
-#
-# Perl Command: VI::InsertLine
-# Usage: VI::InsertLine screenId lineNumber text
-
-void
-InsertLine(screen, linenumber, text)
-       VI screen
-       int linenumber
-       char *text
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-       STRLEN length;
-
-       CODE:
-       SvPV(ST(2), length);
-       INITMESSAGE;
-       rval = api_iline(screen, linenumber, text, length);
-       ENDMESSAGE;
-
-# XS_VI_lline --
-#      Return the last line in the screen.
-#
-# Perl Command: VI::LastLine
-# Usage: VI::LastLine screenId
-
-int 
-LastLine(screen)
-       VI screen
-
-       PREINIT:
-       recno_t last;
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       rval = api_lline(screen, &last);
-       ENDMESSAGE;
-       RETVAL=last;
-
-       OUTPUT:
-       RETVAL
-
-# XS_VI_getmark --
-#      Return the mark's cursor position as a list with two elements.
-#      {line, column}.
-#
-# Perl Command: VI::GetMark
-# Usage: VI::GetMark screenId mark
-
-void
-GetMark(screen, mark)
-       VI screen
-       char mark
-
-       PREINIT:
-       struct _mark cursor;
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       PPCODE:
-       INITMESSAGE;
-       rval = api_getmark(screen, (int)mark, &cursor);
-       ENDMESSAGE;
-
-       EXTEND(sp,2);
-        PUSHs(sv_2mortal(newSViv(cursor.lno)));
-        PUSHs(sv_2mortal(newSViv(cursor.cno)));
-
-# XS_VI_setmark --
-#      Set the mark to the line and column numbers supplied.
-#
-# Perl Command: VI::SetMark
-# Usage: VI::SetMark screenId mark line column
-
-void
-SetMark(screen, mark, line, column)
-       VI screen
-       char mark
-       int line
-       int column
-
-       PREINIT:
-       struct _mark cursor;
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       cursor.lno = line;
-       cursor.cno = column;
-       rval = api_setmark(screen, (int)mark, &cursor);
-       ENDMESSAGE;
-
-# XS_VI_getcursor --
-#      Return the current cursor position as a list with two elements.
-#      {line, column}.
-#
-# Perl Command: VI::GetCursor
-# Usage: VI::GetCursor screenId
-
-void
-GetCursor(screen)
-       VI screen
-
-       PREINIT:
-       struct _mark cursor;
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       PPCODE:
-       INITMESSAGE;
-       rval = api_getcursor(screen, &cursor);
-       ENDMESSAGE;
-
-       EXTEND(sp,2);
-        PUSHs(sv_2mortal(newSViv(cursor.lno)));
-        PUSHs(sv_2mortal(newSViv(cursor.cno)));
-
-# XS_VI_setcursor --
-#      Set the cursor to the line and column numbers supplied.
-#
-# Perl Command: VI::SetCursor
-# Usage: VI::SetCursor screenId line column
-
-void
-SetCursor(screen, line, column)
-       VI screen
-       int line
-       int column
-
-       PREINIT:
-       struct _mark cursor;
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       cursor.lno = line;
-       cursor.cno = column;
-       rval = api_setcursor(screen, &cursor);
-       ENDMESSAGE;
-
-# XS_VI_swscreen --
-#      Change the current focus to screen.
-#
-# Perl Command: VI::SwitchScreen
-# Usage: VI::SwitchScreen screenId screenId
-
-void
-SwitchScreen(screenFrom, screenTo)
-       VI screenFrom
-       VI screenTo
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       rval = api_swscreen(screenFrom, screenTo);
-       ENDMESSAGE;
-
-# XS_VI_map --
-#      Associate a key with a perl procedure.
-#
-# Perl Command: VI::MapKey
-# Usage: VI::MapKey screenId key perlproc
-
-void
-MapKey(screen, key, perlproc)
-       VI screen
-       char *key
-       SV *perlproc
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-       int length;
-       char *command;
-       SV *svc;
-
-       CODE:
-       INITMESSAGE;
-       svc = sv_2mortal(newSVpv(":perl ", 6));
-       sv_catsv(svc, perlproc);
-       command = SvPV(svc, length);
-       rval = api_map(screen, key, command, length);
-       ENDMESSAGE;
-
-# XS_VI_unmap --
-#      Unmap a key.
-#
-# Perl Command: VI::UnmapKey
-# Usage: VI::UnmmapKey screenId key
-
-void
-UnmapKey(screen, key)
-       VI screen
-       char *key
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       rval = api_unmap(screen, key);
-       ENDMESSAGE;
-
-# XS_VI_opts_set --
-#      Set an option.
-#
-# Perl Command: VI::SetOpt
-# Usage: VI::SetOpt screenId setting
-
-void
-SetOpt(screen, setting)
-       VI screen
-       char *setting
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-       SV *svc;
-
-       CODE:
-       INITMESSAGE;
-       svc = sv_2mortal(newSVpv(":set ", 5));
-       sv_catpv(svc, setting);
-       rval = api_run_str(screen, SvPV(svc, na));
-       ENDMESSAGE;
-
-# XS_VI_opts_get --
-#      Return the value of an option.
-#      
-# Perl Command: VI::GetOpt
-# Usage: VI::GetOpt screenId option
-
-void
-GetOpt(screen, option)
-       VI screen
-       char *option
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-       char *value;
-
-       PPCODE:
-       INITMESSAGE;
-       rval = api_opts_get(screen, option, &value, NULL);
-       ENDMESSAGE;
-
-       EXTEND(SP,1);
-       PUSHs(sv_2mortal(newSVpv(value, 0)));
-       free(value);
-
-# XS_VI_run --
-#      Run the ex command cmd.
-#
-# Perl Command: VI::Run
-# Usage: VI::Run screenId cmd
-
-void
-Run(screen, command)
-       VI screen
-       char *command;
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       rval = api_run_str(screen, command);
-       ENDMESSAGE;
-
-void 
-DESTROY(screen)
-       VI screen
-
-       CODE:
-       screen->perl_private = 0;
-
-void
-Warn(warning)
-       char *warning;
-
-       PREINIT:
-       int i;
-       CODE:
-       sv_catpv(GvSV(errgv),warning);
-
-#define TIED(package) \
-       sv_magic((SV *) (hv = \
-           (HV *)sv_2mortal((SV *)newHV())), \
-               sv_setref_pv(sv_newmortal(), package, \
-                       newVIrv(newSV(0), screen)),\
-               'P', Nullch, 0);\
-       RETVAL = newRV((SV *)hv)
-
-SV *
-Opt(screen)
-       VI screen;
-       PREINIT:
-       HV *hv;
-       CODE:
-       TIED("VI::OPT");
-       OUTPUT:
-       RETVAL
-
-SV *
-Map(screen)
-       VI screen;
-       PREINIT:
-       HV *hv;
-       CODE:
-       TIED("VI::MAP");
-       OUTPUT:
-       RETVAL
-
-SV *
-Mark(screen)
-       VI screen
-       PREINIT:
-       HV *hv;
-       CODE:
-       TIED("VI::MARK");
-       OUTPUT:
-       RETVAL
-
-MODULE = VI    PACKAGE = VI::OPT
-
-void 
-DESTROY(screen)
-       VI::OPT screen
-
-       CODE:
-       # typemap did all the checking
-       SvREFCNT_dec((SV*)SvIV((SV*)SvRV(ST(0))));
-
-void
-FETCH(screen, key)
-       VI::OPT screen
-       char *key
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-       char *value;
-       int boolvalue;
-
-       PPCODE:
-       INITMESSAGE;
-       rval = api_opts_get(screen, key, &value, &boolvalue);
-       if (!rval) {
-               EXTEND(SP,1);
-               PUSHs(sv_2mortal((boolvalue == -1) ? newSVpv(value, 0)
-                                                  : newSViv(boolvalue)));
-               free(value);
-       } else ST(0) = &sv_undef;
-       rval = 0;
-       ENDMESSAGE;
-
-void
-STORE(screen, key, value)
-       VI::OPT screen
-       char    *key
-       SV      *value
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       rval = api_opts_set(screen, key, SvPV(value, na), SvIV(value), 
-                                         SvTRUEx(value));
-       ENDMESSAGE;
-
-MODULE = VI    PACKAGE = VI::MAP
-
-void 
-DESTROY(screen)
-       VI::MAP screen
-
-       CODE:
-       # typemap did all the checking
-       SvREFCNT_dec((SV*)SvIV((SV*)SvRV(ST(0))));
-
-void
-STORE(screen, key, perlproc)
-       VI::MAP screen
-       char *key
-       SV *perlproc
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-       int length;
-       char *command;
-       SV *svc;
-
-       CODE:
-       INITMESSAGE;
-       svc = sv_2mortal(newSVpv(":perl ", 6));
-       sv_catsv(svc, perlproc);
-       command = SvPV(svc, length);
-       rval = api_map(screen, key, command, length);
-       ENDMESSAGE;
-
-void
-DELETE(screen, key)
-       VI::MAP screen
-       char *key
-
-       PREINIT:
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       rval = api_unmap(screen, key);
-       ENDMESSAGE;
-
-MODULE = VI    PACKAGE = VI::MARK
-
-void 
-DESTROY(screen)
-       VI::MARK screen
-
-       CODE:
-       # typemap did all the checking
-       SvREFCNT_dec((SV*)SvIV((SV*)SvRV(ST(0))));
-
-AV *
-FETCH(screen, mark)
-       VI::MARK screen
-       char mark
-
-       PREINIT:
-       struct _mark cursor;
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       INITMESSAGE;
-       rval = api_getmark(screen, (int)mark, &cursor);
-       ENDMESSAGE;
-       RETVAL = newAV();
-       av_push(RETVAL, newSViv(cursor.lno));
-       av_push(RETVAL, newSViv(cursor.cno));
-
-       OUTPUT:
-       RETVAL
-
-void
-STORE(screen, mark, pos)
-       VI::MARK screen
-       char mark
-       AVREF pos
-
-       PREINIT:
-       struct _mark cursor;
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int rval;
-
-       CODE:
-       if (av_len(pos) < 1) 
-           croak("cursor position needs 2 elements");
-       INITMESSAGE;
-       cursor.lno = SvIV(*av_fetch(pos, 0, 0));
-       cursor.cno = SvIV(*av_fetch(pos, 1, 0));
-       rval = api_setmark(screen, (int)mark, &cursor);
-       ENDMESSAGE;
-
-void
-FIRSTKEY(screen, ...)
-       VI::MARK screen
-
-       ALIAS:
-       NEXTKEY = 1
-       
-       PROTOTYPE: $;$
-
-       PREINIT:
-       struct _mark cursor;
-       void (*scr_msg)(SCR *, mtype_t, char *, size_t);
-       int next;
-       char key[] = {0, 0};
-
-       PPCODE:
-       if (items == 2) {
-               next = 1;
-               *key = *(char *)SvPV(ST(1),na);
-       } else next = 0;
-       if (api_nextmark(screen, next, key) != 1) {
-               EXTEND(sp, 1);
-               PUSHs(sv_2mortal(newSVpv(key, 1)));
-       } else ST(0) = &sv_undef;
Index: perl_api/perlsfio.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/perl_api/perlsfio.c,v
retrieving revision 1.5
diff -u -r1.5 perlsfio.c
--- perl_api/perlsfio.c 12 Nov 2014 04:28:41 -0000      1.5
+++ perl_api/perlsfio.c 15 Nov 2014 07:44:33 -0000
@@ -1,78 +0,0 @@
-/*     $OpenBSD: perlsfio.c,v 1.5 2014/11/12 04:28:41 bentley Exp $    */
-
-/*-
- * Copyright (c) 1996
- *     Keith Bostic.  All rights reserved.
- * Copyright (c) 1996
- *     Sven Verdoolaege. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-
-#include <EXTERN.h>
-#include <perl.h>
-#include <XSUB.h>
-
-#include "perl_extern.h"
-
-/*
- * PUBLIC: #ifdef USE_SFIO
- */
-#ifdef USE_SFIO
-
-#define NIL(type)       ((type)0)
-
-static int
-sfnviwrite(Sfio_t *f, char *buf, int n, Sfdisc_t *disc)
-{
-       SCR *scrp;
-
-       scrp = (SCR *)SvIV((SV*)SvRV(perl_get_sv("curscr", FALSE)));
-       msgq(scrp, M_INFO, "%.*s", n, buf);
-       return n;
-}
-
-/*
- * sfdcnewnvi --
- *     Create nvi discipline
- *
- * PUBLIC: Sfdisc_t* sfdcnewnvi(SCR*);
- */
-
-Sfdisc_t *
-sfdcnewnvi(SCR *scrp)
-{
-       Sfdisc_t*   disc;
-
-       MALLOC(scrp, disc, Sfdisc_t*, sizeof(Sfdisc_t));
-       if (!disc) return disc;
-
-       disc->readf = (Sfread_f)NULL;
-       disc->writef = sfnviwrite;
-       disc->seekf = (Sfseek_f)NULL;
-       disc->exceptf = (Sfexcept_f)NULL;
-       return disc;
-}
-
-/*
- * PUBLIC: #endif
- */
-#endif /* USE_SFIO */
Index: perl_api/typemap
===================================================================
RCS file: /cvs/src/usr.bin/vi/perl_api/typemap,v
retrieving revision 1.1
diff -u -r1.1 typemap
--- perl_api/typemap    26 Nov 1999 22:49:09 -0000      1.1
+++ perl_api/typemap    15 Nov 2014 07:44:36 -0000
@@ -1,42 +0,0 @@
-TYPEMAP
-# Grr can't let it end in OBJ 'cause xsubpp would
-# s/OBJ$/REF/ that for the DESTROY function
-VI     T_VIOBJNOMUNGE
-VI::OPT        T_VIOBJREF
-VI::MAP        T_VIOBJREF
-VI::MARK       T_VIOBJREF
-AVREF  T_AVREFREF
-
-INPUT
-T_AVREFREF
-       if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV) 
-           $var = (AV *)SvRV($arg);
-       else
-           croak(\"$var is not a reference to an array\")
-T_VIOBJNOMUNGE
-       if (sv_isa($arg, \"VI\")) {
-           IV tmp = SvIV((SV*)SvRV($arg));
-           $var = ($type) tmp;
-           if (!tmp)
-               croak(\"screen no longer exists\");
-       }
-       else
-           croak(\"$var is not of type ${ntype}\")
-T_VIOBJREF
-       if (sv_isa($arg, \"${ntype}\")) {
-           IV tmp = SvIV((SV*)SvRV($arg));
-           if (sv_isa((SV *)tmp, \"VI\")) {
-               IV tmp2 = SvIV((SV*)SvRV((SV *)tmp));
-               $var = ($type) tmp2;
-               if (!tmp2)
-                   croak(\"screen no longer exists\");
-           }
-           else
-               croak(\"$var is not of type ${ntype}\");
-       }
-       else
-           croak(\"$var is not of type ${ntype}\")
-
-OUTPUT
-T_VIOBJNOMUNGE
-       newVIrv($arg, $var);
Index: perl_scripts/forall.pl
===================================================================
RCS file: /cvs/src/usr.bin/vi/perl_scripts/forall.pl,v
retrieving revision 1.1
diff -u -r1.1 forall.pl
--- perl_scripts/forall.pl      26 Nov 1999 22:49:09 -0000      1.1
+++ perl_scripts/forall.pl      15 Nov 2014 07:44:59 -0000
@@ -1,10 +0,0 @@
-sub forall {
-  my ($code) = shift;
-  my ($i) = $VI::StartLine-1;
-  while (++$i <= $VI::StopLine) {
-    $_ = $curscr->GetLine($i);
-    VI::SetLine($VI::ScreenId, $i, $_) if(&$code);
-  }
-}
-
-1;
Index: perl_scripts/make.pl
===================================================================
RCS file: /cvs/src/usr.bin/vi/perl_scripts/make.pl,v
retrieving revision 1.1
diff -u -r1.1 make.pl
--- perl_scripts/make.pl        26 Nov 1999 22:49:09 -0000      1.1
+++ perl_scripts/make.pl        15 Nov 2014 07:45:01 -0000
@@ -1,27 +0,0 @@
-sub make {
-    open MAKE, "make 2>&1 1>/dev/null |";
-    while(<MAKE>) {
-       if (($file, $line, $msg) = /([^: ]*):(\d*):(.+)/) {
-           if ($file == $prevfile && $line == $prevline) {
-               $error[-1]->[2] .= "\n$msg";
-           } else {
-               push @error, [$file, $line, $msg];
-               ($prevline, $prevfile) = ($line, $file);
-           }
-       }
-    }
-    close MAKE;
-}
-
-sub nexterror {
-    if ($index <= $#error) {
-       my $error = $error[$index++];
-       $curscr->Edit($error->[0]);
-       $curscr->SetCursor($error->[1],0);
-       $curscr->Msg($error->[2]);
-    }
-}
-
-# preverror is left as an exercise
-
-1;
Index: perl_scripts/tk.pl
===================================================================
RCS file: /cvs/src/usr.bin/vi/perl_scripts/tk.pl,v
retrieving revision 1.2
diff -u -r1.2 tk.pl
--- perl_scripts/tk.pl  29 Jan 2001 01:58:48 -0000      1.2
+++ perl_scripts/tk.pl  15 Nov 2014 07:45:04 -0000
@@ -1,22 +0,0 @@
-#      $OpenBSD: tk.pl,v 1.2 2001/01/29 01:58:48 niklas Exp $
-
-# make sure every subprocess has it's exit and that the main one
-# hasn't
-sub fun {
-    unless ($pid = fork) {
-        unless (fork) {
-            use Tk;
-            $MW = MainWindow->new;
-            $hello = $MW->Button(
-                -text    => 'Hello, world',
-                -command => sub {exit;},
-            );
-            $hello->pack;
-            MainLoop;
-        }
-        exit 0;
-    }
-    waitpid($pid, 0);
-}
-
-1;
Index: perl_scripts/wc.pl
===================================================================
RCS file: /cvs/src/usr.bin/vi/perl_scripts/wc.pl,v
retrieving revision 1.1
diff -u -r1.1 wc.pl
--- perl_scripts/wc.pl  26 Nov 1999 22:49:09 -0000      1.1
+++ perl_scripts/wc.pl  15 Nov 2014 07:45:07 -0000
@@ -1,11 +0,0 @@
-sub wc {
-  my $words;
-  $i = $VI::StartLine;
-  while ($i <= $VI::StopLine) {
-    $_ = $curscr->GetLine($i++);
-    $words+=split;
-  }
-  $curscr->Msg("$words words");
-}
-
-1;

Beware: needs cvs remove common/api.c ex/ex_perl.c include/perl_extern.h
perl_api/ perl_scripts/

Reply via email to