if_perl.xs
资源名称:vim53src.zip [点击查看]
上传用户:gddssl
上传日期:2007-01-06
资源大小:1003k
文件大小:15k
源码类别:
编辑器/阅读器
开发平台:
DOS
- /* vi:set ts=8 sts=4 sw=4:
- *
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
- /*
- * if_perl.xs: Main code for Perl interface support.
- * Mostly written by Sven Verdoolaege.
- */
- #define _memory_h /* avoid memset redeclaration */
- #define IN_PERL_FILE /* don't include if_perl.pro from proto.h */
- #include "vim.h"
- /*
- * Avoid clashes between Perl and Vim namespace.
- */
- #undef MAGIC
- #undef NORMAL
- #undef STRLEN
- #undef FF
- #undef OP_DELETE
- #ifdef __BORLANDC__
- #define NOPROTO 1
- #endif
- #include <EXTERN.h>
- #include <perl.h>
- #include <XSUB.h>
- /*
- * Work around clashes between Perl and Vim namespace. proto.h doesn't
- * include if_perl.pro and perlsfio.pro when IN_PERL_FILE is defined, because
- * we need the CV typedef. proto.h can't be moved to after including
- * if_perl.h, because we get all sorts of name clashes then.
- */
- #ifndef PROTO
- # include "proto/if_perl.pro"
- # include "proto/if_perlsfio.pro"
- #endif
- static void *perl_interp = NULL;
- static void xs_init __ARGS((void));
- static void VIM_init __ARGS((void));
- /*
- * perl_init(): initialize perl interpreter
- * We have to call perl_parse to initialize some structures,
- * there's nothing to actually parse.
- */
- static void
- perl_init()
- {
- char *bootargs[] = { "VI", NULL };
- static char *args[] = { "", "-e", "" };
- perl_interp = perl_alloc();
- perl_construct(perl_interp);
- perl_parse(perl_interp, xs_init, 3, args, 0);
- perl_call_argv("VIM::bootstrap", (long)G_DISCARD, bootargs);
- VIM_init();
- #ifdef USE_SFIO
- sfdisc(PerlIO_stdout(), sfdcnewvim());
- sfdisc(PerlIO_stderr(), sfdcnewvim());
- sfsetbuf(PerlIO_stdout(), NULL, 0);
- sfsetbuf(PerlIO_stderr(), NULL, 0);
- #endif
- }
- /*
- * perl_end(): clean up after ourselves
- */
- void
- perl_end()
- {
- if (perl_interp)
- {
- perl_run(perl_interp);
- perl_destruct(perl_interp);
- perl_free(perl_interp);
- }
- }
- /*
- * msg_split(): send a message to the message handling routines
- * split at 'n' first though.
- */
- void
- msg_split(s, attr)
- char_u *s;
- int attr; /* highlighting attributes */
- {
- char *next;
- char *token = (char *)s;
- while ((next = strchr(token, 'n')))
- {
- *next++ = ' '; /* replace n with