Mercurial > vim
annotate src/if_perl.xs @ 9297:9c663cda189f v7.4.1931
commit https://github.com/vim/vim/commit/a641e1d4da3f9152c489318c06a93fcd1c746637
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 13 21:16:03 2016 +0200
patch 7.4.1931
Problem: Using both old and new style file mark lines from viminfo.
Solution: Skip the old style lines if the viminfo file was written with a
Vim version that supports the new style.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 13 Jun 2016 21:30:08 +0200 |
parents | ee0564e3257d |
children | 82cb3ed4781b |
rev | line source |
---|---|
7 | 1 /* vi:set ts=8 sts=4 sw=4: |
2 * | |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 */ | |
8 /* | |
9 * if_perl.xs: Main code for Perl interface support. | |
10 * Mostly written by Sven Verdoolaege. | |
11 */ | |
12 | |
13 #define _memory_h /* avoid memset redeclaration */ | |
14 #define IN_PERL_FILE /* don't include if_perl.pro from proto.h */ | |
15 | |
5261
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
16 /* |
5537 | 17 * Currently 32-bit version of ActivePerl is built with VC6 (or MinGW since |
18 * ActivePerl 5.18). | |
5261
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
19 * (http://community.activestate.com/faq/windows-compilers-perl-modules) |
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
20 * It means that time_t should be 32-bit. However the default size of |
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
21 * time_t is 64-bit since VC8. So we have to define _USE_32BIT_TIME_T. |
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
22 */ |
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
23 #if defined(WIN32) && !defined(_WIN64) |
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
24 # define _USE_32BIT_TIME_T |
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
25 #endif |
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
26 |
5537 | 27 /* |
28 * Prevent including winsock.h. perl.h tries to detect whether winsock.h is | |
29 * already included before including winsock2.h, because winsock2.h isn't | |
30 * compatible with winsock.h. However the detection doesn't work with some | |
31 * versions of MinGW. If WIN32_LEAN_AND_MEAN is defined, windows.h will not | |
32 * include winsock.h. | |
33 */ | |
34 #ifdef WIN32 | |
35 # define WIN32_LEAN_AND_MEAN | |
36 #endif | |
37 | |
7 | 38 #include "vim.h" |
39 | |
5558 | 40 /* Work around for perl-5.18. |
41 * Don't include "perl\lib\CORE\inline.h" for now, | |
42 * include it after Perl_sv_free2 is defined. */ | |
43 #ifdef DYNAMIC_PERL | |
44 # define PERL_NO_INLINE_FUNCTIONS | |
45 #endif | |
46 | |
5560 | 47 /* Work around for using MSVC and ActivePerl 5.18. */ |
48 #ifdef _MSC_VER | |
49 # define __inline__ __inline | |
50 #endif | |
51 | |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7856
diff
changeset
|
52 #ifdef __GNUC__ |
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7856
diff
changeset
|
53 # pragma GCC diagnostic push |
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7856
diff
changeset
|
54 # pragma GCC diagnostic ignored "-Wunused-variable" |
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7856
diff
changeset
|
55 #endif |
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7856
diff
changeset
|
56 |
5261
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
57 #include <EXTERN.h> |
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
58 #include <perl.h> |
b882d4b14e00
updated for version 7.4b.007
Bram Moolenaar <bram@vim.org>
parents:
4905
diff
changeset
|
59 #include <XSUB.h> |
8885
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
60 #if defined(PERLIO_LAYERS) && !defined(USE_SFIO) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
61 # include <perliol.h> |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
62 #endif |
7 | 63 |
9171
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
64 /* Workaround for perl < 5.8.7 */ |
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
65 #ifndef PERLIO_FUNCS_DECL |
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
66 # ifdef PERLIO_FUNCS_CONST |
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
67 # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs |
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
68 # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs) |
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
69 # else |
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
70 # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs |
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
71 # define PERLIO_FUNCS_CAST(funcs) (funcs) |
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
72 # endif |
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
73 #endif |
9177
ee0564e3257d
commit https://github.com/vim/vim/commit/c4bc0e6542185b659d2a165b635f9561549071ea
Christian Brabandt <cb@256bit.org>
parents:
9171
diff
changeset
|
74 #ifndef SvREFCNT_inc_void_NN |
ee0564e3257d
commit https://github.com/vim/vim/commit/c4bc0e6542185b659d2a165b635f9561549071ea
Christian Brabandt <cb@256bit.org>
parents:
9171
diff
changeset
|
75 # define SvREFCNT_inc_void_NN SvREFCNT_inc |
ee0564e3257d
commit https://github.com/vim/vim/commit/c4bc0e6542185b659d2a165b635f9561549071ea
Christian Brabandt <cb@256bit.org>
parents:
9171
diff
changeset
|
76 #endif |
9171
20e7b99c33d4
commit https://github.com/vim/vim/commit/cf190c6f017563de1bdbf854b3376522b8b2748f
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
77 |
7 | 78 /* |
79 * Work around clashes between Perl and Vim namespace. proto.h doesn't | |
80 * include if_perl.pro and perlsfio.pro when IN_PERL_FILE is defined, because | |
81 * we need the CV typedef. proto.h can't be moved to after including | |
82 * if_perl.h, because we get all sorts of name clashes then. | |
83 */ | |
84 #ifndef PROTO | |
85 #ifndef __MINGW32__ | |
86 # include "proto/if_perl.pro" | |
87 # include "proto/if_perlsfio.pro" | |
88 #endif | |
89 #endif | |
90 | |
91 /* Perl compatibility stuff. This should ensure compatibility with older | |
92 * versions of Perl. | |
93 */ | |
94 | |
95 #ifndef PERL_VERSION | |
96 # include <patchlevel.h> | |
97 # define PERL_REVISION 5 | |
98 # define PERL_VERSION PATCHLEVEL | |
99 # define PERL_SUBVERSION SUBVERSION | |
100 #endif | |
101 | |
1387 | 102 /* |
103 * Quoting Jan Dubois of Active State: | |
104 * ActivePerl build 822 still identifies itself as 5.8.8 but already | |
105 * contains many of the changes from the upcoming Perl 5.8.9 release. | |
106 * | |
107 * The changes include addition of two symbols (Perl_sv_2iv_flags, | |
108 * Perl_newXS_flags) not present in earlier releases. | |
109 * | |
1395 | 110 * Jan Dubois suggested the following guarding scheme. |
111 * | |
112 * Active State defined ACTIVEPERL_VERSION as a string in versions before | |
113 * 5.8.8; and so the comparison to 822 below needs to be guarded. | |
1387 | 114 */ |
1395 | 115 #if (PERL_REVISION == 5) && (PERL_VERSION == 8) && (PERL_SUBVERSION >= 8) |
116 # if (ACTIVEPERL_VERSION >= 822) || (PERL_SUBVERSION >= 9) | |
117 # define PERL589_OR_LATER | |
118 # endif | |
1387 | 119 #endif |
120 #if (PERL_REVISION == 5) && (PERL_VERSION >= 9) | |
121 # define PERL589_OR_LATER | |
122 #endif | |
123 | |
2096
6510d834609f
updated for version 7.2.380
Bram Moolenaar <bram@zimbu.org>
parents:
2079
diff
changeset
|
124 #if (PERL_REVISION == 5) && ((PERL_VERSION > 10) || \ |
6510d834609f
updated for version 7.2.380
Bram Moolenaar <bram@zimbu.org>
parents:
2079
diff
changeset
|
125 (PERL_VERSION == 10) && (PERL_SUBVERSION >= 1)) |
6510d834609f
updated for version 7.2.380
Bram Moolenaar <bram@zimbu.org>
parents:
2079
diff
changeset
|
126 # define PERL5101_OR_LATER |
6510d834609f
updated for version 7.2.380
Bram Moolenaar <bram@zimbu.org>
parents:
2079
diff
changeset
|
127 #endif |
6510d834609f
updated for version 7.2.380
Bram Moolenaar <bram@zimbu.org>
parents:
2079
diff
changeset
|
128 |
7 | 129 #ifndef pTHX |
130 # define pTHX void | |
131 # define pTHX_ | |
132 #endif | |
133 | |
134 #ifndef EXTERN_C | |
135 # define EXTERN_C | |
136 #endif | |
137 | |
3728 | 138 #if (PERL_REVISION == 5) && (PERL_VERSION >= 14) && defined(_MSC_VER) |
139 /* Using PL_errgv to get the error message after perl_eval_sv() causes a crash | |
140 * with MSVC and Perl version 5.14. */ | |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
141 # define CHECK_EVAL_ERR(len) SvPV(perl_get_sv("@", GV_ADD), (len)); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
142 #else |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
143 # define CHECK_EVAL_ERR(len) SvPV(GvSV(PL_errgv), (len)); |
3728 | 144 #endif |
145 | |
7 | 146 /* Compatibility hacks over */ |
147 | |
148 static PerlInterpreter *perl_interp = NULL; | |
7807
1a5d34492798
commit https://github.com/vim/vim/commit/d99df423c559d85c17779b3685426c489554908c
Christian Brabandt <cb@256bit.org>
parents:
7651
diff
changeset
|
149 static void xs_init(pTHX); |
1a5d34492798
commit https://github.com/vim/vim/commit/d99df423c559d85c17779b3685426c489554908c
Christian Brabandt <cb@256bit.org>
parents:
7651
diff
changeset
|
150 static void VIM_init(void); |
1a5d34492798
commit https://github.com/vim/vim/commit/d99df423c559d85c17779b3685426c489554908c
Christian Brabandt <cb@256bit.org>
parents:
7651
diff
changeset
|
151 EXTERN_C void boot_DynaLoader(pTHX_ CV*); |
7 | 152 |
153 /* | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
154 * For dynamic linked perl. |
7 | 155 */ |
156 #if defined(DYNAMIC_PERL) || defined(PROTO) | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
157 |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
158 #ifndef DYNAMIC_PERL /* just generating prototypes */ |
2372
a42d19b78c93
Fix building with Perl on Windows with MingW. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2370
diff
changeset
|
159 #ifdef WIN3264 |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
160 typedef int HANDLE; |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
161 #endif |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
162 typedef int XSINIT_t; |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
163 typedef int XSUBADDR_t; |
5706 | 164 #endif |
165 #ifndef USE_ITHREADS | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
166 typedef int perl_key; |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
167 #endif |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
168 |
2372
a42d19b78c93
Fix building with Perl on Windows with MingW. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2370
diff
changeset
|
169 #ifndef WIN3264 |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
170 #include <dlfcn.h> |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
171 #define HANDLE void* |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
172 #define PERL_PROC void* |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
173 #define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
174 #define symbol_from_dll dlsym |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
175 #define close_dll dlclose |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
176 #else |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
177 #define PERL_PROC FARPROC |
2612 | 178 #define load_dll vimLoadLib |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
179 #define symbol_from_dll GetProcAddress |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
180 #define close_dll FreeLibrary |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
181 #endif |
7 | 182 /* |
183 * Wrapper defines | |
184 */ | |
185 # define perl_alloc dll_perl_alloc | |
186 # define perl_construct dll_perl_construct | |
187 # define perl_parse dll_perl_parse | |
188 # define perl_run dll_perl_run | |
189 # define perl_destruct dll_perl_destruct | |
190 # define perl_free dll_perl_free | |
191 # define Perl_get_context dll_Perl_get_context | |
192 # define Perl_croak dll_Perl_croak | |
2096
6510d834609f
updated for version 7.2.380
Bram Moolenaar <bram@zimbu.org>
parents:
2079
diff
changeset
|
193 # ifdef PERL5101_OR_LATER |
2079
5abd3e3c0085
updated for version 7.2.363
Bram Moolenaar <bram@zimbu.org>
parents:
1990
diff
changeset
|
194 # define Perl_croak_xs_usage dll_Perl_croak_xs_usage |
5abd3e3c0085
updated for version 7.2.363
Bram Moolenaar <bram@zimbu.org>
parents:
1990
diff
changeset
|
195 # endif |
7 | 196 # ifndef PROTO |
197 # define Perl_croak_nocontext dll_Perl_croak_nocontext | |
198 # define Perl_call_argv dll_Perl_call_argv | |
199 # define Perl_call_pv dll_Perl_call_pv | |
200 # define Perl_eval_sv dll_Perl_eval_sv | |
201 # define Perl_get_sv dll_Perl_get_sv | |
202 # define Perl_eval_pv dll_Perl_eval_pv | |
203 # define Perl_call_method dll_Perl_call_method | |
204 # endif | |
205 # define Perl_dowantarray dll_Perl_dowantarray | |
206 # define Perl_free_tmps dll_Perl_free_tmps | |
207 # define Perl_gv_stashpv dll_Perl_gv_stashpv | |
208 # define Perl_markstack_grow dll_Perl_markstack_grow | |
209 # define Perl_mg_find dll_Perl_mg_find | |
210 # define Perl_newXS dll_Perl_newXS | |
211 # define Perl_newSV dll_Perl_newSV | |
212 # define Perl_newSViv dll_Perl_newSViv | |
213 # define Perl_newSVpv dll_Perl_newSVpv | |
214 # define Perl_pop_scope dll_Perl_pop_scope | |
215 # define Perl_push_scope dll_Perl_push_scope | |
216 # define Perl_save_int dll_Perl_save_int | |
5960 | 217 # if (PERL_REVISION == 5) && (PERL_VERSION >= 20) |
218 # define Perl_save_strlen dll_Perl_save_strlen | |
219 # endif | |
7 | 220 # define Perl_stack_grow dll_Perl_stack_grow |
221 # define Perl_set_context dll_Perl_set_context | |
3050 | 222 # if (PERL_REVISION == 5) && (PERL_VERSION >= 14) |
6872 | 223 # define Perl_sv_2bool_flags dll_Perl_sv_2bool_flags |
224 # if (PERL_REVISION == 5) && (PERL_VERSION < 22) | |
225 # define Perl_xs_apiversion_bootcheck dll_Perl_xs_apiversion_bootcheck | |
226 # endif | |
3050 | 227 # else |
6872 | 228 # define Perl_sv_2bool dll_Perl_sv_2bool |
3050 | 229 # endif |
7 | 230 # define Perl_sv_2iv dll_Perl_sv_2iv |
231 # define Perl_sv_2mortal dll_Perl_sv_2mortal | |
232 # if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
233 # define Perl_sv_2pv_flags dll_Perl_sv_2pv_flags | |
234 # define Perl_sv_2pv_nolen dll_Perl_sv_2pv_nolen | |
235 # else | |
236 # define Perl_sv_2pv dll_Perl_sv_2pv | |
237 # endif | |
238 # define Perl_sv_bless dll_Perl_sv_bless | |
239 # if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
240 # define Perl_sv_catpvn_flags dll_Perl_sv_catpvn_flags | |
241 # else | |
242 # define Perl_sv_catpvn dll_Perl_sv_catpvn | |
243 # endif | |
1387 | 244 #ifdef PERL589_OR_LATER |
245 # define Perl_sv_2iv_flags dll_Perl_sv_2iv_flags | |
246 # define Perl_newXS_flags dll_Perl_newXS_flags | |
247 #endif | |
7 | 248 # define Perl_sv_free dll_Perl_sv_free |
1711 | 249 # if (PERL_REVISION == 5) && (PERL_VERSION >= 10) |
250 # define Perl_sv_free2 dll_Perl_sv_free2 | |
251 # endif | |
7 | 252 # define Perl_sv_isa dll_Perl_sv_isa |
253 # define Perl_sv_magic dll_Perl_sv_magic | |
254 # define Perl_sv_setiv dll_Perl_sv_setiv | |
255 # define Perl_sv_setpv dll_Perl_sv_setpv | |
256 # define Perl_sv_setpvn dll_Perl_sv_setpvn | |
257 # if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
258 # define Perl_sv_setsv_flags dll_Perl_sv_setsv_flags | |
259 # else | |
260 # define Perl_sv_setsv dll_Perl_sv_setsv | |
261 # endif | |
262 # define Perl_sv_upgrade dll_Perl_sv_upgrade | |
263 # define Perl_Tstack_sp_ptr dll_Perl_Tstack_sp_ptr | |
264 # define Perl_Top_ptr dll_Perl_Top_ptr | |
265 # define Perl_Tstack_base_ptr dll_Perl_Tstack_base_ptr | |
266 # define Perl_Tstack_max_ptr dll_Perl_Tstack_max_ptr | |
267 # define Perl_Ttmps_ix_ptr dll_Perl_Ttmps_ix_ptr | |
268 # define Perl_Ttmps_floor_ptr dll_Perl_Ttmps_floor_ptr | |
269 # define Perl_Tmarkstack_ptr_ptr dll_Perl_Tmarkstack_ptr_ptr | |
270 # define Perl_Tmarkstack_max_ptr dll_Perl_Tmarkstack_max_ptr | |
271 # define Perl_TSv_ptr dll_Perl_TSv_ptr | |
272 # define Perl_TXpv_ptr dll_Perl_TXpv_ptr | |
273 # define Perl_Tna_ptr dll_Perl_Tna_ptr | |
274 # define Perl_Idefgv_ptr dll_Perl_Idefgv_ptr | |
275 # define Perl_Ierrgv_ptr dll_Perl_Ierrgv_ptr | |
276 # define Perl_Isv_yes_ptr dll_Perl_Isv_yes_ptr | |
277 # define boot_DynaLoader dll_boot_DynaLoader | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
278 # define Perl_Gthr_key_ptr dll_Perl_Gthr_key_ptr |
7 | 279 |
1765 | 280 # define Perl_sys_init dll_Perl_sys_init |
1668 | 281 # define Perl_sys_term dll_Perl_sys_term |
282 # define Perl_ISv_ptr dll_Perl_ISv_ptr | |
283 # define Perl_Istack_max_ptr dll_Perl_Istack_max_ptr | |
284 # define Perl_Istack_base_ptr dll_Perl_Istack_base_ptr | |
285 # define Perl_Itmps_ix_ptr dll_Perl_Itmps_ix_ptr | |
286 # define Perl_Itmps_floor_ptr dll_Perl_Itmps_floor_ptr | |
287 # define Perl_IXpv_ptr dll_Perl_IXpv_ptr | |
288 # define Perl_Ina_ptr dll_Perl_Ina_ptr | |
289 # define Perl_Imarkstack_ptr_ptr dll_Perl_Imarkstack_ptr_ptr | |
290 # define Perl_Imarkstack_max_ptr dll_Perl_Imarkstack_max_ptr | |
291 # define Perl_Istack_sp_ptr dll_Perl_Istack_sp_ptr | |
292 # define Perl_Iop_ptr dll_Perl_Iop_ptr | |
293 # define Perl_call_list dll_Perl_call_list | |
294 # define Perl_Iscopestack_ix_ptr dll_Perl_Iscopestack_ix_ptr | |
295 # define Perl_Iunitcheckav_ptr dll_Perl_Iunitcheckav_ptr | |
6872 | 296 # if (PERL_REVISION == 5) && (PERL_VERSION >= 22) |
297 # define Perl_xs_handshake dll_Perl_xs_handshake | |
298 # define Perl_xs_boot_epilog dll_Perl_xs_boot_epilog | |
299 # endif | |
3820 | 300 # if (PERL_REVISION == 5) && (PERL_VERSION >= 14) |
5706 | 301 # ifdef USE_ITHREADS |
302 # define PL_thr_key *dll_PL_thr_key | |
303 # endif | |
3820 | 304 # endif |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
305 # define Perl_hv_iternext_flags dll_Perl_hv_iternext_flags |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
306 # define Perl_hv_iterinit dll_Perl_hv_iterinit |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
307 # define Perl_hv_iterkey dll_Perl_hv_iterkey |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
308 # define Perl_hv_iterval dll_Perl_hv_iterval |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
309 # define Perl_av_fetch dll_Perl_av_fetch |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
310 # define Perl_av_len dll_Perl_av_len |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
311 # define Perl_sv_2nv_flags dll_Perl_sv_2nv_flags |
8885
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
312 # if defined(PERLIO_LAYERS) && !defined(USE_SFIO) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
313 # define PerlIOBase_pushed dll_PerlIOBase_pushed |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
314 # define PerlIO_define_layer dll_PerlIO_define_layer |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
315 # endif |
9129
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
316 # if (PERL_REVISION == 5) && (PERL_VERSION >= 24) |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
317 # define Perl_savetmps dll_Perl_savetmps |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
318 # endif |
1668 | 319 |
7 | 320 /* |
321 * Declare HANDLE for perl.dll and function pointers. | |
322 */ | |
323 static HANDLE hPerlLib = NULL; | |
324 | |
325 static PerlInterpreter* (*perl_alloc)(); | |
326 static void (*perl_construct)(PerlInterpreter*); | |
327 static void (*perl_destruct)(PerlInterpreter*); | |
328 static void (*perl_free)(PerlInterpreter*); | |
329 static int (*perl_run)(PerlInterpreter*); | |
330 static int (*perl_parse)(PerlInterpreter*, XSINIT_t, int, char**, char**); | |
331 static void* (*Perl_get_context)(void); | |
8810
83d0b976d9b3
commit https://github.com/vim/vim/commit/864733ad92e30cd603314604af73f25106db4c90
Christian Brabandt <cb@256bit.org>
parents:
8214
diff
changeset
|
332 static void (*Perl_croak)(pTHX_ const char*, ...) __attribute__noreturn__; |
2096
6510d834609f
updated for version 7.2.380
Bram Moolenaar <bram@zimbu.org>
parents:
2079
diff
changeset
|
333 #ifdef PERL5101_OR_LATER |
5537 | 334 /* Perl-5.18 has a different Perl_croak_xs_usage signature. */ |
335 # if (PERL_REVISION == 5) && (PERL_VERSION >= 18) | |
8810
83d0b976d9b3
commit https://github.com/vim/vim/commit/864733ad92e30cd603314604af73f25106db4c90
Christian Brabandt <cb@256bit.org>
parents:
8214
diff
changeset
|
336 static void (*Perl_croak_xs_usage)(const CV *const, const char *const params) |
83d0b976d9b3
commit https://github.com/vim/vim/commit/864733ad92e30cd603314604af73f25106db4c90
Christian Brabandt <cb@256bit.org>
parents:
8214
diff
changeset
|
337 __attribute__noreturn__; |
5537 | 338 # else |
8810
83d0b976d9b3
commit https://github.com/vim/vim/commit/864733ad92e30cd603314604af73f25106db4c90
Christian Brabandt <cb@256bit.org>
parents:
8214
diff
changeset
|
339 static void (*Perl_croak_xs_usage)(pTHX_ const CV *const, const char *const params) |
83d0b976d9b3
commit https://github.com/vim/vim/commit/864733ad92e30cd603314604af73f25106db4c90
Christian Brabandt <cb@256bit.org>
parents:
8214
diff
changeset
|
340 __attribute__noreturn__; |
5537 | 341 # endif |
4905
517fa1a34c7c
updated for version 7.3.1198
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
342 #endif |
8810
83d0b976d9b3
commit https://github.com/vim/vim/commit/864733ad92e30cd603314604af73f25106db4c90
Christian Brabandt <cb@256bit.org>
parents:
8214
diff
changeset
|
343 static void (*Perl_croak_nocontext)(const char*, ...) __attribute__noreturn__; |
7 | 344 static I32 (*Perl_dowantarray)(pTHX); |
345 static void (*Perl_free_tmps)(pTHX); | |
346 static HV* (*Perl_gv_stashpv)(pTHX_ const char*, I32); | |
6872 | 347 #if (PERL_REVISION == 5) && (PERL_VERSION >= 22) |
348 static I32* (*Perl_markstack_grow)(pTHX); | |
349 #else | |
7 | 350 static void (*Perl_markstack_grow)(pTHX); |
6872 | 351 #endif |
7 | 352 static MAGIC* (*Perl_mg_find)(pTHX_ SV*, int); |
353 static CV* (*Perl_newXS)(pTHX_ char*, XSUBADDR_t, char*); | |
354 static SV* (*Perl_newSV)(pTHX_ STRLEN); | |
355 static SV* (*Perl_newSViv)(pTHX_ IV); | |
356 static SV* (*Perl_newSVpv)(pTHX_ const char*, STRLEN); | |
357 static I32 (*Perl_call_argv)(pTHX_ const char*, I32, char**); | |
358 static I32 (*Perl_call_pv)(pTHX_ const char*, I32); | |
359 static I32 (*Perl_eval_sv)(pTHX_ SV*, I32); | |
360 static SV* (*Perl_get_sv)(pTHX_ const char*, I32); | |
361 static SV* (*Perl_eval_pv)(pTHX_ const char*, I32); | |
362 static SV* (*Perl_call_method)(pTHX_ const char*, I32); | |
363 static void (*Perl_pop_scope)(pTHX); | |
364 static void (*Perl_push_scope)(pTHX); | |
365 static void (*Perl_save_int)(pTHX_ int*); | |
5960 | 366 #if (PERL_REVISION == 5) && (PERL_VERSION >= 20) |
367 static void (*Perl_save_strlen)(pTHX_ STRLEN* ptr); | |
368 #endif | |
7 | 369 static SV** (*Perl_stack_grow)(pTHX_ SV**, SV**p, int); |
370 static SV** (*Perl_set_context)(void*); | |
3050 | 371 #if (PERL_REVISION == 5) && (PERL_VERSION >= 14) |
372 static bool (*Perl_sv_2bool_flags)(pTHX_ SV*, I32); | |
6872 | 373 # if (PERL_REVISION == 5) && (PERL_VERSION < 22) |
3050 | 374 static void (*Perl_xs_apiversion_bootcheck)(pTHX_ SV *module, const char *api_p, STRLEN api_len); |
6872 | 375 # endif |
3050 | 376 #else |
7 | 377 static bool (*Perl_sv_2bool)(pTHX_ SV*); |
3050 | 378 #endif |
7 | 379 static IV (*Perl_sv_2iv)(pTHX_ SV*); |
380 static SV* (*Perl_sv_2mortal)(pTHX_ SV*); | |
381 #if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
382 static char* (*Perl_sv_2pv_flags)(pTHX_ SV*, STRLEN*, I32); | |
383 static char* (*Perl_sv_2pv_nolen)(pTHX_ SV*); | |
384 #else | |
385 static char* (*Perl_sv_2pv)(pTHX_ SV*, STRLEN*); | |
386 #endif | |
387 static SV* (*Perl_sv_bless)(pTHX_ SV*, HV*); | |
388 #if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
389 static void (*Perl_sv_catpvn_flags)(pTHX_ SV* , const char*, STRLEN, I32); | |
390 #else | |
391 static void (*Perl_sv_catpvn)(pTHX_ SV*, const char*, STRLEN); | |
392 #endif | |
1387 | 393 #ifdef PERL589_OR_LATER |
394 static IV (*Perl_sv_2iv_flags)(pTHX_ SV* sv, I32 flags); | |
395 static CV * (*Perl_newXS_flags)(pTHX_ const char *name, XSUBADDR_t subaddr, const char *const filename, const char *const proto, U32 flags); | |
396 #endif | |
7 | 397 static void (*Perl_sv_free)(pTHX_ SV*); |
398 static int (*Perl_sv_isa)(pTHX_ SV*, const char*); | |
399 static void (*Perl_sv_magic)(pTHX_ SV*, SV*, int, const char*, I32); | |
400 static void (*Perl_sv_setiv)(pTHX_ SV*, IV); | |
401 static void (*Perl_sv_setpv)(pTHX_ SV*, const char*); | |
402 static void (*Perl_sv_setpvn)(pTHX_ SV*, const char*, STRLEN); | |
403 #if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
404 static void (*Perl_sv_setsv_flags)(pTHX_ SV*, SV*, I32); | |
405 #else | |
406 static void (*Perl_sv_setsv)(pTHX_ SV*, SV*); | |
407 #endif | |
408 static bool (*Perl_sv_upgrade)(pTHX_ SV*, U32); | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
409 #if (PERL_REVISION == 5) && (PERL_VERSION < 10) |
7 | 410 static SV*** (*Perl_Tstack_sp_ptr)(register PerlInterpreter*); |
411 static OP** (*Perl_Top_ptr)(register PerlInterpreter*); | |
412 static SV*** (*Perl_Tstack_base_ptr)(register PerlInterpreter*); | |
413 static SV*** (*Perl_Tstack_max_ptr)(register PerlInterpreter*); | |
414 static I32* (*Perl_Ttmps_ix_ptr)(register PerlInterpreter*); | |
415 static I32* (*Perl_Ttmps_floor_ptr)(register PerlInterpreter*); | |
416 static I32** (*Perl_Tmarkstack_ptr_ptr)(register PerlInterpreter*); | |
417 static I32** (*Perl_Tmarkstack_max_ptr)(register PerlInterpreter*); | |
418 static SV** (*Perl_TSv_ptr)(register PerlInterpreter*); | |
419 static XPV** (*Perl_TXpv_ptr)(register PerlInterpreter*); | |
420 static STRLEN* (*Perl_Tna_ptr)(register PerlInterpreter*); | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
421 #else |
5537 | 422 /* Perl-5.18 has a different Perl_sv_free2 signature. */ |
423 # if (PERL_REVISION == 5) && (PERL_VERSION >= 18) | |
424 static void (*Perl_sv_free2)(pTHX_ SV*, const U32); | |
425 # else | |
1711 | 426 static void (*Perl_sv_free2)(pTHX_ SV*); |
5537 | 427 # endif |
1765 | 428 static void (*Perl_sys_init)(int* argc, char*** argv); |
1668 | 429 static void (*Perl_sys_term)(void); |
3818 | 430 static void (*Perl_call_list)(pTHX_ I32, AV*); |
431 # if (PERL_REVISION == 5) && (PERL_VERSION >= 14) | |
432 # else | |
1668 | 433 static SV** (*Perl_ISv_ptr)(register PerlInterpreter*); |
434 static SV*** (*Perl_Istack_max_ptr)(register PerlInterpreter*); | |
435 static SV*** (*Perl_Istack_base_ptr)(register PerlInterpreter*); | |
436 static XPV** (*Perl_IXpv_ptr)(register PerlInterpreter*); | |
437 static I32* (*Perl_Itmps_ix_ptr)(register PerlInterpreter*); | |
438 static I32* (*Perl_Itmps_floor_ptr)(register PerlInterpreter*); | |
439 static STRLEN* (*Perl_Ina_ptr)(register PerlInterpreter*); | |
440 static I32** (*Perl_Imarkstack_ptr_ptr)(register PerlInterpreter*); | |
441 static I32** (*Perl_Imarkstack_max_ptr)(register PerlInterpreter*); | |
442 static SV*** (*Perl_Istack_sp_ptr)(register PerlInterpreter*); | |
443 static OP** (*Perl_Iop_ptr)(register PerlInterpreter*); | |
444 static I32* (*Perl_Iscopestack_ix_ptr)(register PerlInterpreter*); | |
445 static AV** (*Perl_Iunitcheckav_ptr)(register PerlInterpreter*); | |
3818 | 446 # endif |
1668 | 447 #endif |
6872 | 448 #if (PERL_REVISION == 5) && (PERL_VERSION >= 22) |
449 static I32 (*Perl_xs_handshake)(const U32, void *, const char *, ...); | |
450 static void (*Perl_xs_boot_epilog)(pTHX_ const U32); | |
451 #endif | |
7 | 452 |
3818 | 453 #if (PERL_REVISION == 5) && (PERL_VERSION >= 14) |
5706 | 454 # ifdef USE_ITHREADS |
3820 | 455 static perl_key* dll_PL_thr_key; |
5706 | 456 # endif |
3818 | 457 #else |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
458 static GV** (*Perl_Idefgv_ptr)(register PerlInterpreter*); |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
459 static GV** (*Perl_Ierrgv_ptr)(register PerlInterpreter*); |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
460 static SV* (*Perl_Isv_yes_ptr)(register PerlInterpreter*); |
3818 | 461 static perl_key* (*Perl_Gthr_key_ptr)_((pTHX)); |
462 #endif | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
463 static void (*boot_DynaLoader)_((pTHX_ CV*)); |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
464 static HE * (*Perl_hv_iternext_flags)(pTHX_ HV *, I32); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
465 static I32 (*Perl_hv_iterinit)(pTHX_ HV *); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
466 static char * (*Perl_hv_iterkey)(pTHX_ HE *, I32 *); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
467 static SV * (*Perl_hv_iterval)(pTHX_ HV *, HE *); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
468 static SV** (*Perl_av_fetch)(pTHX_ AV *, SSize_t, I32); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
469 static SSize_t (*Perl_av_len)(pTHX_ AV *); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
470 static NV (*Perl_sv_2nv_flags)(pTHX_ SV *const, const I32); |
8885
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
471 #if defined(PERLIO_LAYERS) && !defined(USE_SFIO) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
472 static IV (*PerlIOBase_pushed)(pTHX_ PerlIO *, const char *, SV *, PerlIO_funcs *); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
473 static void (*PerlIO_define_layer)(pTHX_ PerlIO_funcs *); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
474 #endif |
9129
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
475 #if (PERL_REVISION == 5) && (PERL_VERSION >= 24) |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
476 static void (*Perl_savetmps)(pTHX); |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
477 #endif |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
478 |
7 | 479 /* |
480 * Table of name to function pointer of perl. | |
481 */ | |
482 static struct { | |
483 char* name; | |
484 PERL_PROC* ptr; | |
485 } perl_funcname_table[] = { | |
486 {"perl_alloc", (PERL_PROC*)&perl_alloc}, | |
487 {"perl_construct", (PERL_PROC*)&perl_construct}, | |
488 {"perl_destruct", (PERL_PROC*)&perl_destruct}, | |
489 {"perl_free", (PERL_PROC*)&perl_free}, | |
490 {"perl_run", (PERL_PROC*)&perl_run}, | |
491 {"perl_parse", (PERL_PROC*)&perl_parse}, | |
492 {"Perl_get_context", (PERL_PROC*)&Perl_get_context}, | |
493 {"Perl_croak", (PERL_PROC*)&Perl_croak}, | |
2096
6510d834609f
updated for version 7.2.380
Bram Moolenaar <bram@zimbu.org>
parents:
2079
diff
changeset
|
494 #ifdef PERL5101_OR_LATER |
2079
5abd3e3c0085
updated for version 7.2.363
Bram Moolenaar <bram@zimbu.org>
parents:
1990
diff
changeset
|
495 {"Perl_croak_xs_usage", (PERL_PROC*)&Perl_croak_xs_usage}, |
5abd3e3c0085
updated for version 7.2.363
Bram Moolenaar <bram@zimbu.org>
parents:
1990
diff
changeset
|
496 #endif |
5706 | 497 #ifdef PERL_IMPLICIT_CONTEXT |
7 | 498 {"Perl_croak_nocontext", (PERL_PROC*)&Perl_croak_nocontext}, |
5706 | 499 #endif |
7 | 500 {"Perl_dowantarray", (PERL_PROC*)&Perl_dowantarray}, |
501 {"Perl_free_tmps", (PERL_PROC*)&Perl_free_tmps}, | |
502 {"Perl_gv_stashpv", (PERL_PROC*)&Perl_gv_stashpv}, | |
503 {"Perl_markstack_grow", (PERL_PROC*)&Perl_markstack_grow}, | |
504 {"Perl_mg_find", (PERL_PROC*)&Perl_mg_find}, | |
505 {"Perl_newXS", (PERL_PROC*)&Perl_newXS}, | |
506 {"Perl_newSV", (PERL_PROC*)&Perl_newSV}, | |
507 {"Perl_newSViv", (PERL_PROC*)&Perl_newSViv}, | |
508 {"Perl_newSVpv", (PERL_PROC*)&Perl_newSVpv}, | |
509 {"Perl_call_argv", (PERL_PROC*)&Perl_call_argv}, | |
510 {"Perl_call_pv", (PERL_PROC*)&Perl_call_pv}, | |
511 {"Perl_eval_sv", (PERL_PROC*)&Perl_eval_sv}, | |
512 {"Perl_get_sv", (PERL_PROC*)&Perl_get_sv}, | |
513 {"Perl_eval_pv", (PERL_PROC*)&Perl_eval_pv}, | |
514 {"Perl_call_method", (PERL_PROC*)&Perl_call_method}, | |
515 {"Perl_pop_scope", (PERL_PROC*)&Perl_pop_scope}, | |
516 {"Perl_push_scope", (PERL_PROC*)&Perl_push_scope}, | |
517 {"Perl_save_int", (PERL_PROC*)&Perl_save_int}, | |
5960 | 518 #if (PERL_REVISION == 5) && (PERL_VERSION >= 20) |
519 {"Perl_save_strlen", (PERL_PROC*)&Perl_save_strlen}, | |
520 #endif | |
7 | 521 {"Perl_stack_grow", (PERL_PROC*)&Perl_stack_grow}, |
522 {"Perl_set_context", (PERL_PROC*)&Perl_set_context}, | |
3050 | 523 #if (PERL_REVISION == 5) && (PERL_VERSION >= 14) |
524 {"Perl_sv_2bool_flags", (PERL_PROC*)&Perl_sv_2bool_flags}, | |
6872 | 525 # if (PERL_REVISION == 5) && (PERL_VERSION < 22) |
3050 | 526 {"Perl_xs_apiversion_bootcheck",(PERL_PROC*)&Perl_xs_apiversion_bootcheck}, |
6872 | 527 # endif |
3050 | 528 #else |
7 | 529 {"Perl_sv_2bool", (PERL_PROC*)&Perl_sv_2bool}, |
3050 | 530 #endif |
7 | 531 {"Perl_sv_2iv", (PERL_PROC*)&Perl_sv_2iv}, |
532 {"Perl_sv_2mortal", (PERL_PROC*)&Perl_sv_2mortal}, | |
533 #if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
534 {"Perl_sv_2pv_flags", (PERL_PROC*)&Perl_sv_2pv_flags}, | |
535 {"Perl_sv_2pv_nolen", (PERL_PROC*)&Perl_sv_2pv_nolen}, | |
536 #else | |
537 {"Perl_sv_2pv", (PERL_PROC*)&Perl_sv_2pv}, | |
538 #endif | |
1387 | 539 #ifdef PERL589_OR_LATER |
540 {"Perl_sv_2iv_flags", (PERL_PROC*)&Perl_sv_2iv_flags}, | |
541 {"Perl_newXS_flags", (PERL_PROC*)&Perl_newXS_flags}, | |
542 #endif | |
7 | 543 {"Perl_sv_bless", (PERL_PROC*)&Perl_sv_bless}, |
544 #if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
545 {"Perl_sv_catpvn_flags", (PERL_PROC*)&Perl_sv_catpvn_flags}, | |
546 #else | |
547 {"Perl_sv_catpvn", (PERL_PROC*)&Perl_sv_catpvn}, | |
548 #endif | |
549 {"Perl_sv_free", (PERL_PROC*)&Perl_sv_free}, | |
550 {"Perl_sv_isa", (PERL_PROC*)&Perl_sv_isa}, | |
551 {"Perl_sv_magic", (PERL_PROC*)&Perl_sv_magic}, | |
552 {"Perl_sv_setiv", (PERL_PROC*)&Perl_sv_setiv}, | |
553 {"Perl_sv_setpv", (PERL_PROC*)&Perl_sv_setpv}, | |
554 {"Perl_sv_setpvn", (PERL_PROC*)&Perl_sv_setpvn}, | |
555 #if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
556 {"Perl_sv_setsv_flags", (PERL_PROC*)&Perl_sv_setsv_flags}, | |
557 #else | |
558 {"Perl_sv_setsv", (PERL_PROC*)&Perl_sv_setsv}, | |
559 #endif | |
560 {"Perl_sv_upgrade", (PERL_PROC*)&Perl_sv_upgrade}, | |
1668 | 561 #if (PERL_REVISION == 5) && (PERL_VERSION < 10) |
7 | 562 {"Perl_Tstack_sp_ptr", (PERL_PROC*)&Perl_Tstack_sp_ptr}, |
563 {"Perl_Top_ptr", (PERL_PROC*)&Perl_Top_ptr}, | |
564 {"Perl_Tstack_base_ptr", (PERL_PROC*)&Perl_Tstack_base_ptr}, | |
565 {"Perl_Tstack_max_ptr", (PERL_PROC*)&Perl_Tstack_max_ptr}, | |
566 {"Perl_Ttmps_ix_ptr", (PERL_PROC*)&Perl_Ttmps_ix_ptr}, | |
567 {"Perl_Ttmps_floor_ptr", (PERL_PROC*)&Perl_Ttmps_floor_ptr}, | |
568 {"Perl_Tmarkstack_ptr_ptr", (PERL_PROC*)&Perl_Tmarkstack_ptr_ptr}, | |
569 {"Perl_Tmarkstack_max_ptr", (PERL_PROC*)&Perl_Tmarkstack_max_ptr}, | |
570 {"Perl_TSv_ptr", (PERL_PROC*)&Perl_TSv_ptr}, | |
571 {"Perl_TXpv_ptr", (PERL_PROC*)&Perl_TXpv_ptr}, | |
572 {"Perl_Tna_ptr", (PERL_PROC*)&Perl_Tna_ptr}, | |
1668 | 573 #else |
1711 | 574 {"Perl_sv_free2", (PERL_PROC*)&Perl_sv_free2}, |
1765 | 575 {"Perl_sys_init", (PERL_PROC*)&Perl_sys_init}, |
1668 | 576 {"Perl_sys_term", (PERL_PROC*)&Perl_sys_term}, |
3050 | 577 {"Perl_call_list", (PERL_PROC*)&Perl_call_list}, |
578 # if (PERL_REVISION == 5) && (PERL_VERSION >= 14) | |
579 # else | |
1668 | 580 {"Perl_ISv_ptr", (PERL_PROC*)&Perl_ISv_ptr}, |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
581 {"Perl_Istack_max_ptr", (PERL_PROC*)&Perl_Istack_max_ptr}, |
1668 | 582 {"Perl_Istack_base_ptr", (PERL_PROC*)&Perl_Istack_base_ptr}, |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
583 {"Perl_IXpv_ptr", (PERL_PROC*)&Perl_IXpv_ptr}, |
1668 | 584 {"Perl_Itmps_ix_ptr", (PERL_PROC*)&Perl_Itmps_ix_ptr}, |
585 {"Perl_Itmps_floor_ptr", (PERL_PROC*)&Perl_Itmps_floor_ptr}, | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
586 {"Perl_Ina_ptr", (PERL_PROC*)&Perl_Ina_ptr}, |
1668 | 587 {"Perl_Imarkstack_ptr_ptr", (PERL_PROC*)&Perl_Imarkstack_ptr_ptr}, |
588 {"Perl_Imarkstack_max_ptr", (PERL_PROC*)&Perl_Imarkstack_max_ptr}, | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
589 {"Perl_Istack_sp_ptr", (PERL_PROC*)&Perl_Istack_sp_ptr}, |
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
590 {"Perl_Iop_ptr", (PERL_PROC*)&Perl_Iop_ptr}, |
1668 | 591 {"Perl_Iscopestack_ix_ptr", (PERL_PROC*)&Perl_Iscopestack_ix_ptr}, |
592 {"Perl_Iunitcheckav_ptr", (PERL_PROC*)&Perl_Iunitcheckav_ptr}, | |
3050 | 593 # endif |
1668 | 594 #endif |
6872 | 595 #if (PERL_REVISION == 5) && (PERL_VERSION >= 22) |
596 {"Perl_xs_handshake", (PERL_PROC*)&Perl_xs_handshake}, | |
597 {"Perl_xs_boot_epilog", (PERL_PROC*)&Perl_xs_boot_epilog}, | |
598 #endif | |
3050 | 599 #if (PERL_REVISION == 5) && (PERL_VERSION >= 14) |
5706 | 600 # ifdef USE_ITHREADS |
3820 | 601 {"PL_thr_key", (PERL_PROC*)&dll_PL_thr_key}, |
5706 | 602 # endif |
3050 | 603 #else |
7 | 604 {"Perl_Idefgv_ptr", (PERL_PROC*)&Perl_Idefgv_ptr}, |
605 {"Perl_Ierrgv_ptr", (PERL_PROC*)&Perl_Ierrgv_ptr}, | |
606 {"Perl_Isv_yes_ptr", (PERL_PROC*)&Perl_Isv_yes_ptr}, | |
3050 | 607 {"Perl_Gthr_key_ptr", (PERL_PROC*)&Perl_Gthr_key_ptr}, |
608 #endif | |
7 | 609 {"boot_DynaLoader", (PERL_PROC*)&boot_DynaLoader}, |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
610 {"Perl_hv_iternext_flags", (PERL_PROC*)&Perl_hv_iternext_flags}, |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
611 {"Perl_hv_iterinit", (PERL_PROC*)&Perl_hv_iterinit}, |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
612 {"Perl_hv_iterkey", (PERL_PROC*)&Perl_hv_iterkey}, |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
613 {"Perl_hv_iterval", (PERL_PROC*)&Perl_hv_iterval}, |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
614 {"Perl_av_fetch", (PERL_PROC*)&Perl_av_fetch}, |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
615 {"Perl_av_len", (PERL_PROC*)&Perl_av_len}, |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
616 {"Perl_sv_2nv_flags", (PERL_PROC*)&Perl_sv_2nv_flags}, |
8885
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
617 #if defined(PERLIO_LAYERS) && !defined(USE_SFIO) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
618 {"PerlIOBase_pushed", (PERL_PROC*)&PerlIOBase_pushed}, |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
619 {"PerlIO_define_layer", (PERL_PROC*)&PerlIO_define_layer}, |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
620 #endif |
9129
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
621 #if (PERL_REVISION == 5) && (PERL_VERSION >= 24) |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
622 {"Perl_savetmps", (PERL_PROC*)&Perl_savetmps}, |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
623 #endif |
7 | 624 {"", NULL}, |
625 }; | |
626 | |
5537 | 627 /* Work around for perl-5.18. |
9129
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
628 * For now, only the definitions of S_SvREFCNT_dec are needed in |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
629 * "perl\lib\CORE\inline.h". */ |
5537 | 630 #if (PERL_REVISION == 5) && (PERL_VERSION >= 18) |
9129
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
631 static void |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
632 S_SvREFCNT_dec(pTHX_ SV *sv) |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
633 { |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
634 if (LIKELY(sv != NULL)) { |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
635 U32 rc = SvREFCNT(sv); |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
636 if (LIKELY(rc > 1)) |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
637 SvREFCNT(sv) = rc - 1; |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
638 else |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
639 Perl_sv_free2(aTHX_ sv, rc); |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
640 } |
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
641 } |
5537 | 642 #endif |
643 | |
7 | 644 /* |
645 * Make all runtime-links of perl. | |
646 * | |
5267
585b623a1aa3
updated for version 7.4b.010
Bram Moolenaar <bram@vim.org>
parents:
5261
diff
changeset
|
647 * 1. Get module handle using dlopen() or vimLoadLib(). |
7 | 648 * 2. Get pointer to perl function by GetProcAddress. |
649 * 3. Repeat 2, until get all functions will be used. | |
650 * | |
651 * Parameter 'libname' provides name of DLL. | |
652 * Return OK or FAIL. | |
653 */ | |
654 static int | |
655 perl_runtime_link_init(char *libname, int verbose) | |
656 { | |
657 int i; | |
658 | |
659 if (hPerlLib != NULL) | |
660 return OK; | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
661 if ((hPerlLib = load_dll(libname)) == NULL) |
7 | 662 { |
663 if (verbose) | |
664 EMSG2(_("E370: Could not load library %s"), libname); | |
665 return FAIL; | |
666 } | |
667 for (i = 0; perl_funcname_table[i].ptr; ++i) | |
668 { | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
669 if (!(*perl_funcname_table[i].ptr = symbol_from_dll(hPerlLib, |
7 | 670 perl_funcname_table[i].name))) |
671 { | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
672 close_dll(hPerlLib); |
7 | 673 hPerlLib = NULL; |
674 if (verbose) | |
675 EMSG2(_(e_loadfunc), perl_funcname_table[i].name); | |
676 return FAIL; | |
677 } | |
678 } | |
679 return OK; | |
680 } | |
681 | |
682 /* | |
683 * If runtime-link-perl(DLL) was loaded successfully, return TRUE. | |
684 * There were no DLL loaded, return FALSE. | |
685 */ | |
686 int | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
687 perl_enabled(int verbose) |
7 | 688 { |
7528
53163e4d9e4f
commit https://github.com/vim/vim/commit/25e4fcde767084d1a79e0926bc301c92987c0cce
Christian Brabandt <cb@256bit.org>
parents:
7198
diff
changeset
|
689 return perl_runtime_link_init((char *)p_perldll, verbose) == OK; |
7 | 690 } |
691 #endif /* DYNAMIC_PERL */ | |
692 | |
8885
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
693 #if defined(PERLIO_LAYERS) && !defined(USE_SFIO) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
694 static void vim_IOLayer_init(void); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
695 #endif |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
696 |
7 | 697 /* |
698 * perl_init(): initialize perl interpreter | |
699 * We have to call perl_parse to initialize some structures, | |
700 * there's nothing to actually parse. | |
701 */ | |
702 static void | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
703 perl_init(void) |
7 | 704 { |
1668 | 705 char *bootargs[] = { "VI", NULL }; |
706 int argc = 3; | |
707 static char *argv[] = { "", "-e", "" }; | |
7 | 708 |
1668 | 709 #if (PERL_REVISION == 5) && (PERL_VERSION >= 10) |
1765 | 710 Perl_sys_init(&argc, (char***)&argv); |
1668 | 711 #endif |
7 | 712 perl_interp = perl_alloc(); |
713 perl_construct(perl_interp); | |
1668 | 714 perl_parse(perl_interp, xs_init, argc, argv, 0); |
7 | 715 perl_call_argv("VIM::bootstrap", (long)G_DISCARD, bootargs); |
716 VIM_init(); | |
717 #ifdef USE_SFIO | |
718 sfdisc(PerlIO_stdout(), sfdcnewvim()); | |
719 sfdisc(PerlIO_stderr(), sfdcnewvim()); | |
720 sfsetbuf(PerlIO_stdout(), NULL, 0); | |
721 sfsetbuf(PerlIO_stderr(), NULL, 0); | |
8885
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
722 #elif defined(PERLIO_LAYERS) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
723 vim_IOLayer_init(); |
7 | 724 #endif |
725 } | |
726 | |
727 /* | |
728 * perl_end(): clean up after ourselves | |
729 */ | |
730 void | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
731 perl_end(void) |
7 | 732 { |
733 if (perl_interp) | |
734 { | |
735 perl_run(perl_interp); | |
736 perl_destruct(perl_interp); | |
737 perl_free(perl_interp); | |
738 perl_interp = NULL; | |
1668 | 739 #if (PERL_REVISION == 5) && (PERL_VERSION >= 10) |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
740 Perl_sys_term(); |
1668 | 741 #endif |
7 | 742 } |
743 #ifdef DYNAMIC_PERL | |
744 if (hPerlLib) | |
745 { | |
2370
454f314d0e61
Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2255
diff
changeset
|
746 close_dll(hPerlLib); |
7 | 747 hPerlLib = NULL; |
748 } | |
749 #endif | |
750 } | |
751 | |
752 /* | |
753 * msg_split(): send a message to the message handling routines | |
754 * split at '\n' first though. | |
755 */ | |
756 void | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
757 msg_split( |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
758 char_u *s, |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
759 int attr) /* highlighting attributes */ |
7 | 760 { |
761 char *next; | |
762 char *token = (char *)s; | |
763 | |
1423 | 764 while ((next = strchr(token, '\n')) && !got_int) |
7 | 765 { |
766 *next++ = '\0'; /* replace \n with \0 */ | |
767 msg_attr((char_u *)token, attr); | |
768 token = next; | |
769 } | |
1423 | 770 if (*token && !got_int) |
7 | 771 msg_attr((char_u *)token, attr); |
772 } | |
773 | |
774 #ifndef FEAT_EVAL | |
775 /* | |
776 * This stub is needed because an "#ifdef FEAT_EVAL" around Eval() doesn't | |
777 * work properly. | |
778 */ | |
779 char_u * | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
780 eval_to_string( |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
781 char_u *arg UNUSED, |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
782 char_u **nextcmd UNUSED, |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
783 int dolist UNUSED) |
7 | 784 { |
785 return NULL; | |
786 } | |
787 #endif | |
788 | |
789 /* | |
790 * Create a new reference to an SV pointing to the SCR structure | |
502 | 791 * The b_perl_private/w_perl_private part of the SCR structure points to the |
792 * SV, so there can only be one such SV for a particular SCR structure. When | |
793 * the last reference has gone (DESTROY is called), | |
794 * b_perl_private/w_perl_private is reset; When the screen goes away before | |
7 | 795 * all references are gone, the value of the SV is reset; |
796 * any subsequent use of any of those reference will produce | |
797 * a warning. (see typemap) | |
798 */ | |
502 | 799 |
800 static SV * | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
801 newWINrv(SV *rv, win_T *ptr) |
502 | 802 { |
803 sv_upgrade(rv, SVt_RV); | |
804 if (ptr->w_perl_private == NULL) | |
805 { | |
806 ptr->w_perl_private = newSV(0); | |
3344 | 807 sv_setiv(ptr->w_perl_private, PTR2IV(ptr)); |
502 | 808 } |
809 else | |
9129
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
810 SvREFCNT_inc_void_NN(ptr->w_perl_private); |
502 | 811 SvRV(rv) = ptr->w_perl_private; |
812 SvROK_on(rv); | |
813 return sv_bless(rv, gv_stashpv("VIWIN", TRUE)); | |
7 | 814 } |
815 | |
502 | 816 static SV * |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
817 newBUFrv(SV *rv, buf_T *ptr) |
502 | 818 { |
819 sv_upgrade(rv, SVt_RV); | |
820 if (ptr->b_perl_private == NULL) | |
821 { | |
822 ptr->b_perl_private = newSV(0); | |
3344 | 823 sv_setiv(ptr->b_perl_private, PTR2IV(ptr)); |
502 | 824 } |
825 else | |
9129
95fd0de7a8f1
commit https://github.com/vim/vim/commit/6727bf861776cfbb93c97dfea5f87a095cf9f364
Christian Brabandt <cb@256bit.org>
parents:
8919
diff
changeset
|
826 SvREFCNT_inc_void_NN(ptr->b_perl_private); |
502 | 827 SvRV(rv) = ptr->b_perl_private; |
828 SvROK_on(rv); | |
829 return sv_bless(rv, gv_stashpv("VIBUF", TRUE)); | |
830 } | |
7 | 831 |
832 /* | |
833 * perl_win_free | |
4352 | 834 * Remove all references to the window to be destroyed |
7 | 835 */ |
836 void | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
837 perl_win_free(win_T *wp) |
7 | 838 { |
502 | 839 if (wp->w_perl_private) |
840 sv_setiv((SV *)wp->w_perl_private, 0); | |
7 | 841 return; |
842 } | |
843 | |
844 void | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
845 perl_buf_free(buf_T *bp) |
7 | 846 { |
502 | 847 if (bp->b_perl_private) |
848 sv_setiv((SV *)bp->b_perl_private, 0); | |
7 | 849 return; |
850 } | |
851 | |
852 #ifndef PROTO | |
853 # if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
854 I32 cur_val(pTHX_ IV iv, SV *sv); | |
855 # else | |
856 I32 cur_val(IV iv, SV *sv); | |
857 #endif | |
858 | |
859 /* | |
860 * Handler for the magic variables $main::curwin and $main::curbuf. | |
861 * The handler is put into the magic vtbl for these variables. | |
862 * (This is effectively a C-level equivalent of a tied variable). | |
863 * There is no "set" function as the variables are read-only. | |
864 */ | |
865 # if (PERL_REVISION == 5) && (PERL_VERSION >= 8) | |
866 I32 cur_val(pTHX_ IV iv, SV *sv) | |
867 # else | |
868 I32 cur_val(IV iv, SV *sv) | |
869 # endif | |
870 { | |
871 SV *rv; | |
872 if (iv == 0) | |
873 rv = newWINrv(newSV(0), curwin); | |
874 else | |
875 rv = newBUFrv(newSV(0), curbuf); | |
876 sv_setsv(sv, rv); | |
8919
240ad5a78199
commit https://github.com/vim/vim/commit/95509e18f8806046eeee27482c77666bbec515da
Christian Brabandt <cb@256bit.org>
parents:
8885
diff
changeset
|
877 SvREFCNT_dec(SvRV(rv)); |
7 | 878 return 0; |
879 } | |
880 #endif /* !PROTO */ | |
881 | |
882 struct ufuncs cw_funcs = { cur_val, 0, 0 }; | |
883 struct ufuncs cb_funcs = { cur_val, 0, 1 }; | |
884 | |
885 /* | |
886 * VIM_init(): Vim-specific initialisation. | |
887 * Make the magical main::curwin and main::curbuf variables | |
888 */ | |
889 static void | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
890 VIM_init(void) |
7 | 891 { |
892 static char cw[] = "main::curwin"; | |
893 static char cb[] = "main::curbuf"; | |
894 SV *sv; | |
895 | |
896 sv = perl_get_sv(cw, TRUE); | |
897 sv_magic(sv, NULL, 'U', (char *)&cw_funcs, sizeof(cw_funcs)); | |
898 SvREADONLY_on(sv); | |
899 | |
900 sv = perl_get_sv(cb, TRUE); | |
901 sv_magic(sv, NULL, 'U', (char *)&cb_funcs, sizeof(cb_funcs)); | |
902 SvREADONLY_on(sv); | |
903 | |
904 /* | |
905 * Setup the Safe compartment. | |
906 * It shouldn't be a fatal error if the Safe module is missing. | |
907 * XXX: Only shares the 'Msg' routine (which has to be called | |
908 * like 'Msg(...)'). | |
909 */ | |
910 (void)perl_eval_pv( "if ( eval( 'require Safe' ) ) { $VIM::safe = Safe->new(); $VIM::safe->share_from( 'VIM', ['Msg'] ); }", G_DISCARD | G_VOID ); | |
911 | |
912 } | |
913 | |
914 #ifdef DYNAMIC_PERL | |
915 static char *e_noperl = N_("Sorry, this command is disabled: the Perl library could not be loaded."); | |
916 #endif | |
917 | |
918 /* | |
919 * ":perl" | |
920 */ | |
921 void | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
922 ex_perl(exarg_T *eap) |
7 | 923 { |
924 char *err; | |
925 char *script; | |
926 STRLEN length; | |
927 SV *sv; | |
2255 | 928 #ifdef HAVE_SANDBOX |
7 | 929 SV *safe; |
2255 | 930 #endif |
7 | 931 |
932 script = (char *)script_get(eap, eap->arg); | |
933 if (eap->skip) | |
934 { | |
935 vim_free(script); | |
936 return; | |
937 } | |
938 | |
939 if (perl_interp == NULL) | |
940 { | |
941 #ifdef DYNAMIC_PERL | |
942 if (!perl_enabled(TRUE)) | |
943 { | |
944 EMSG(_(e_noperl)); | |
945 vim_free(script); | |
946 return; | |
947 } | |
948 #endif | |
949 perl_init(); | |
950 } | |
951 | |
952 { | |
953 dSP; | |
954 ENTER; | |
955 SAVETMPS; | |
956 | |
957 if (script == NULL) | |
958 sv = newSVpv((char *)eap->arg, 0); | |
959 else | |
960 { | |
961 sv = newSVpv(script, 0); | |
962 vim_free(script); | |
963 } | |
964 | |
965 #ifdef HAVE_SANDBOX | |
966 if (sandbox) | |
967 { | |
2982 | 968 safe = perl_get_sv("VIM::safe", FALSE); |
1934 | 969 # ifndef MAKE_TEST /* avoid a warning for unreachable code */ |
1990 | 970 if (safe == NULL || !SvTRUE(safe)) |
7 | 971 EMSG(_("E299: Perl evaluation forbidden in sandbox without the Safe module")); |
972 else | |
1934 | 973 # endif |
7 | 974 { |
975 PUSHMARK(SP); | |
976 XPUSHs(safe); | |
977 XPUSHs(sv); | |
978 PUTBACK; | |
979 perl_call_method("reval", G_DISCARD); | |
980 } | |
981 } | |
982 else | |
983 #endif | |
984 perl_eval_sv(sv, G_DISCARD | G_NOARGS); | |
985 | |
986 SvREFCNT_dec(sv); | |
987 | |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
988 err = CHECK_EVAL_ERR(length); |
7 | 989 |
990 FREETMPS; | |
991 LEAVE; | |
992 | |
993 if (!length) | |
994 return; | |
995 | |
996 msg_split((char_u *)err, highlight_attr[HLF_E]); | |
997 return; | |
998 } | |
999 } | |
1000 | |
1001 static int | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1002 replace_line(linenr_T *line, linenr_T *end) |
7 | 1003 { |
1004 char *str; | |
1005 | |
1006 if (SvOK(GvSV(PL_defgv))) | |
1007 { | |
1008 str = SvPV(GvSV(PL_defgv), PL_na); | |
1009 ml_replace(*line, (char_u *)str, 1); | |
1010 changed_bytes(*line, 0); | |
1011 } | |
1012 else | |
1013 { | |
1014 ml_delete(*line, FALSE); | |
1015 deleted_lines_mark(*line, 1L); | |
1016 --(*end); | |
1017 --(*line); | |
1018 } | |
1019 return OK; | |
1020 } | |
1021 | |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1022 static struct ref_map_S { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1023 void *vim_ref; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1024 SV *perl_ref; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1025 struct ref_map_S *next; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1026 } *ref_map = NULL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1027 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1028 static void |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1029 ref_map_free(void) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1030 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1031 struct ref_map_S *tofree; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1032 struct ref_map_S *refs = ref_map; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1033 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1034 while (refs) { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1035 tofree = refs; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1036 refs = refs->next; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1037 vim_free(tofree); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1038 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1039 ref_map = NULL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1040 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1041 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1042 static struct ref_map_S * |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1043 ref_map_find_SV(SV *const sv) |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1044 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1045 struct ref_map_S *refs = ref_map; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1046 int count = 350; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1047 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1048 while (refs) { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1049 if (refs->perl_ref == sv) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1050 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1051 refs = refs->next; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1052 count--; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1053 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1054 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1055 if (!refs && count > 0) { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1056 refs = (struct ref_map_S *)alloc(sizeof(struct ref_map_S)); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1057 if (!refs) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1058 return NULL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1059 refs->perl_ref = sv; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1060 refs->vim_ref = NULL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1061 refs->next = ref_map; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1062 ref_map = refs; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1063 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1064 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1065 return refs; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1066 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1067 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1068 static int |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1069 perl_to_vim(SV *sv, typval_T *rettv) |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1070 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1071 if (SvROK(sv)) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1072 sv = SvRV(sv); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1073 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1074 switch (SvTYPE(sv)) { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1075 case SVt_NULL: |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1076 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1077 case SVt_NV: /* float */ |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1078 #ifdef FEAT_FLOAT |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1079 rettv->v_type = VAR_FLOAT; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1080 rettv->vval.v_float = SvNV(sv); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1081 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1082 #endif |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1083 case SVt_IV: /* integer */ |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1084 if (!SvROK(sv)) { /* references should be string */ |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1085 rettv->vval.v_number = SvIV(sv); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1086 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1087 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1088 case SVt_PV: /* string */ |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1089 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1090 size_t len = 0; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1091 char * str_from = SvPV(sv, len); |
9159
6b003ff07234
commit https://github.com/vim/vim/commit/9b0ac229bcfc91acabd35fc576055a94c1687c32
Christian Brabandt <cb@256bit.org>
parents:
9129
diff
changeset
|
1092 char_u *str_to = (char_u*)alloc( |
6b003ff07234
commit https://github.com/vim/vim/commit/9b0ac229bcfc91acabd35fc576055a94c1687c32
Christian Brabandt <cb@256bit.org>
parents:
9129
diff
changeset
|
1093 (unsigned)(sizeof(char_u) * (len + 1))); |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1094 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1095 if (str_to) { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1096 str_to[len] = '\0'; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1097 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1098 while (len--) { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1099 if (str_from[len] == '\0') |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1100 str_to[len] = '\n'; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1101 else |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1102 str_to[len] = str_from[len]; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1103 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1104 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1105 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1106 rettv->v_type = VAR_STRING; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1107 rettv->vval.v_string = str_to; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1108 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1109 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1110 case SVt_PVAV: /* list */ |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1111 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1112 SSize_t size; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1113 listitem_T * item; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1114 SV ** item2; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1115 list_T * list; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1116 struct ref_map_S * refs; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1117 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1118 if ((refs = ref_map_find_SV(sv)) == NULL) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1119 return FAIL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1120 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1121 if (refs->vim_ref) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1122 list = (list_T *) refs->vim_ref; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1123 else |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1124 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1125 if ((list = list_alloc()) == NULL) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1126 return FAIL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1127 refs->vim_ref = list; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1128 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1129 for (size = av_len((AV*)sv); size >= 0; size--) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1130 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1131 if ((item = listitem_alloc()) == NULL) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1132 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1133 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1134 item->li_tv.v_type = VAR_NUMBER; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1135 item->li_tv.v_lock = 0; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1136 item->li_tv.vval.v_number = 0; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1137 list_insert(list, item, list->lv_first); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1138 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1139 item2 = av_fetch((AV *)sv, size, 0); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1140 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1141 if (item2 == NULL || *item2 == NULL || |
7807
1a5d34492798
commit https://github.com/vim/vim/commit/d99df423c559d85c17779b3685426c489554908c
Christian Brabandt <cb@256bit.org>
parents:
7651
diff
changeset
|
1142 perl_to_vim(*item2, &item->li_tv) == FAIL) |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1143 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1144 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1145 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1146 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1147 list->lv_refcount++; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1148 rettv->v_type = VAR_LIST; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1149 rettv->vval.v_list = list; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1150 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1151 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1152 case SVt_PVHV: /* dictionary */ |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1153 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1154 HE * entry; |
8214
51b4fba718bf
commit https://github.com/vim/vim/commit/254ebaf068919407de6bd83ac905bd2f36ad944e
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
1155 I32 key_len; |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1156 char * key; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1157 dictitem_T * item; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1158 SV * item2; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1159 dict_T * dict; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1160 struct ref_map_S * refs; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1161 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1162 if ((refs = ref_map_find_SV(sv)) == NULL) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1163 return FAIL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1164 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1165 if (refs->vim_ref) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1166 dict = (dict_T *) refs->vim_ref; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1167 else |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1168 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1169 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1170 if ((dict = dict_alloc()) == NULL) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1171 return FAIL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1172 refs->vim_ref = dict; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1173 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1174 hv_iterinit((HV *)sv); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1175 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1176 for (entry = hv_iternext((HV *)sv); entry; entry = hv_iternext((HV *)sv)) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1177 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1178 key_len = 0; |
8214
51b4fba718bf
commit https://github.com/vim/vim/commit/254ebaf068919407de6bd83ac905bd2f36ad944e
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
1179 key = hv_iterkey(entry, &key_len); |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1180 |
8214
51b4fba718bf
commit https://github.com/vim/vim/commit/254ebaf068919407de6bd83ac905bd2f36ad944e
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
1181 if (!key || !key_len || strlen(key) < (size_t)key_len) { |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1182 EMSG2("Malformed key Dictionary '%s'", key && *key ? key : "(empty)"); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1183 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1184 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1185 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1186 if ((item = dictitem_alloc((char_u *)key)) == NULL) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1187 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1188 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1189 item->di_tv.v_type = VAR_NUMBER; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1190 item->di_tv.v_lock = 0; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1191 item->di_tv.vval.v_number = 0; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1192 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1193 if (dict_add(dict, item) == FAIL) { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1194 dictitem_free(item); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1195 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1196 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1197 item2 = hv_iterval((HV *)sv, entry); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1198 if (item2 == NULL || perl_to_vim(item2, &item->di_tv) == FAIL) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1199 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1200 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1201 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1202 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1203 dict->dv_refcount++; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1204 rettv->v_type = VAR_DICT; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1205 rettv->vval.v_dict = dict; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1206 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1207 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1208 default: /* not convertible */ |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1209 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1210 char *val = SvPV_nolen(sv); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1211 rettv->v_type = VAR_STRING; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1212 rettv->vval.v_string = val ? vim_strsave((char_u *)val) : NULL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1213 break; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1214 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1215 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1216 return OK; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1217 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1218 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1219 /* |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1220 * "perleval()" |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1221 */ |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1222 void |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1223 do_perleval(char_u *str, typval_T *rettv) |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1224 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1225 char *err = NULL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1226 STRLEN err_len = 0; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1227 SV *sv = NULL; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1228 #ifdef HAVE_SANDBOX |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1229 SV *safe; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1230 #endif |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1231 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1232 if (perl_interp == NULL) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1233 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1234 #ifdef DYNAMIC_PERL |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1235 if (!perl_enabled(TRUE)) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1236 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1237 EMSG(_(e_noperl)); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1238 return; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1239 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1240 #endif |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1241 perl_init(); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1242 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1243 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1244 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1245 dSP; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1246 ENTER; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1247 SAVETMPS; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1248 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1249 #ifdef HAVE_SANDBOX |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1250 if (sandbox) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1251 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1252 safe = get_sv("VIM::safe", FALSE); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1253 # ifndef MAKE_TEST /* avoid a warning for unreachable code */ |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1254 if (safe == NULL || !SvTRUE(safe)) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1255 EMSG(_("E299: Perl evaluation forbidden in sandbox without the Safe module")); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1256 else |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1257 # endif |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1258 { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1259 sv = newSVpv((char *)str, 0); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1260 PUSHMARK(SP); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1261 XPUSHs(safe); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1262 XPUSHs(sv); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1263 PUTBACK; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1264 call_method("reval", G_SCALAR); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1265 SPAGAIN; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1266 SvREFCNT_dec(sv); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1267 sv = POPs; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1268 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1269 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1270 else |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1271 #endif /* HAVE_SANDBOX */ |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1272 sv = eval_pv((char *)str, 0); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1273 |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1274 if (sv) { |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1275 perl_to_vim(sv, rettv); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1276 ref_map_free(); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1277 err = CHECK_EVAL_ERR(err_len); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1278 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1279 PUTBACK; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1280 FREETMPS; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1281 LEAVE; |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1282 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1283 if (err_len) |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1284 msg_split((char_u *)err, highlight_attr[HLF_E]); |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1285 } |
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1286 |
7 | 1287 /* |
1288 * ":perldo". | |
1289 */ | |
1290 void | |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1291 ex_perldo(exarg_T *eap) |
7 | 1292 { |
1293 STRLEN length; | |
1294 SV *sv; | |
1295 char *str; | |
1296 linenr_T i; | |
1297 | |
1298 if (bufempty()) | |
1299 return; | |
1300 | |
1301 if (perl_interp == NULL) | |
1302 { | |
1303 #ifdef DYNAMIC_PERL | |
1304 if (!perl_enabled(TRUE)) | |
1305 { | |
1306 EMSG(_(e_noperl)); | |
1307 return; | |
1308 } | |
1309 #endif | |
1310 perl_init(); | |
1311 } | |
1312 { | |
1313 dSP; | |
1314 length = strlen((char *)eap->arg); | |
129 | 1315 sv = newSV(length + sizeof("sub VIM::perldo {") - 1 + 1); |
1316 sv_setpvn(sv, "sub VIM::perldo {", sizeof("sub VIM::perldo {") - 1); | |
7 | 1317 sv_catpvn(sv, (char *)eap->arg, length); |
1318 sv_catpvn(sv, "}", 1); | |
1319 perl_eval_sv(sv, G_DISCARD | G_NOARGS); | |
1320 SvREFCNT_dec(sv); | |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1321 str = CHECK_EVAL_ERR(length); |
7 | 1322 if (length) |
1323 goto err; | |
1324 | |
1325 if (u_save(eap->line1 - 1, eap->line2 + 1) != OK) | |
1326 return; | |
1327 | |
1328 ENTER; | |
1329 SAVETMPS; | |
1330 for (i = eap->line1; i <= eap->line2; i++) | |
1331 { | |
129 | 1332 sv_setpv(GvSV(PL_defgv), (char *)ml_get(i)); |
7 | 1333 PUSHMARK(sp); |
1334 perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL); | |
7651
c7575b07de98
commit https://github.com/vim/vim/commit/e9b892ebcd8596bf813793a1eed5a460a9495a28
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
1335 str = CHECK_EVAL_ERR(length); |
7 | 1336 if (length) |
1337 break; | |
1338 SPAGAIN; | |
1339 if (SvTRUEx(POPs)) | |
1340 { | |
1341 if (replace_line(&i, &eap->line2) != OK) | |
1342 { | |
1343 PUTBACK; | |
1344 break; | |
1345 } | |
1346 } | |
1347 PUTBACK; | |
1348 } | |
1349 FREETMPS; | |
1350 LEAVE; | |
1351 check_cursor(); | |
1352 update_screen(NOT_VALID); | |
1353 if (!length) | |
1354 return; | |
1355 | |
1356 err: | |
1357 msg_split((char_u *)str, highlight_attr[HLF_E]); | |
1358 return; | |
1359 } | |
1360 } | |
1361 | |
8885
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1362 #if defined(PERLIO_LAYERS) && !defined(USE_SFIO) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1363 typedef struct { |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1364 struct _PerlIO base; |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1365 int attr; |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1366 } PerlIOVim; |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1367 |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1368 static IV |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1369 PerlIOVim_pushed(pTHX_ PerlIO *f, const char *mode, |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1370 SV *arg, PerlIO_funcs *tab) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1371 { |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1372 PerlIOVim *s = PerlIOSelf(f, PerlIOVim); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1373 s->attr = 0; |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1374 if (arg && SvPOK(arg)) { |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1375 int id = syn_name2id((char_u *)SvPV_nolen(arg)); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1376 if (id != 0) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1377 s->attr = syn_id2attr(id); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1378 } |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1379 return PerlIOBase_pushed(aTHX_ f, mode, (SV *)NULL, tab); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1380 } |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1381 |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1382 static SSize_t |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1383 PerlIOVim_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1384 { |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1385 char_u *str; |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1386 PerlIOVim * s = PerlIOSelf(f, PerlIOVim); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1387 |
9159
6b003ff07234
commit https://github.com/vim/vim/commit/9b0ac229bcfc91acabd35fc576055a94c1687c32
Christian Brabandt <cb@256bit.org>
parents:
9129
diff
changeset
|
1388 str = vim_strnsave((char_u *)vbuf, (int)count); |
8885
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1389 if (str == NULL) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1390 return 0; |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1391 msg_split((char_u *)str, s->attr); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1392 vim_free(str); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1393 |
9159
6b003ff07234
commit https://github.com/vim/vim/commit/9b0ac229bcfc91acabd35fc576055a94c1687c32
Christian Brabandt <cb@256bit.org>
parents:
9129
diff
changeset
|
1394 return (SSize_t)count; |
8885
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1395 } |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1396 |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1397 static PERLIO_FUNCS_DECL(PerlIO_Vim) = { |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1398 sizeof(PerlIO_funcs), |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1399 "Vim", |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1400 sizeof(PerlIOVim), |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1401 PERLIO_K_DUMMY, /* flags */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1402 PerlIOVim_pushed, |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1403 NULL, /* popped */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1404 NULL, /* open */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1405 NULL, /* binmode */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1406 NULL, /* arg */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1407 NULL, /* fileno */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1408 NULL, /* dup */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1409 NULL, /* read */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1410 NULL, /* unread */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1411 PerlIOVim_write, |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1412 NULL, /* seek */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1413 NULL, /* tell */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1414 NULL, /* close */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1415 NULL, /* flush */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1416 NULL, /* fill */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1417 NULL, /* eof */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1418 NULL, /* error */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1419 NULL, /* clearerr */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1420 NULL, /* setlinebuf */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1421 NULL, /* get_base */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1422 NULL, /* get_bufsiz */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1423 NULL, /* get_ptr */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1424 NULL, /* get_cnt */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1425 NULL /* set_ptrcnt */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1426 }; |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1427 |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1428 /* Use Vim routine for print operator */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1429 static void |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1430 vim_IOLayer_init(void) |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1431 { |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1432 PerlIO_define_layer(aTHX_ PERLIO_FUNCS_CAST(&PerlIO_Vim)); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1433 (void)eval_pv( "binmode(STDOUT, ':Vim')" |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1434 " && binmode(STDERR, ':Vim(ErrorMsg)');", 0); |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1435 } |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1436 #endif /* PERLIO_LAYERS && !USE_SFIO */ |
54a380c74547
commit https://github.com/vim/vim/commit/6244a0fc29163ba1c734f92b55a89e01e6cf2a67
Christian Brabandt <cb@256bit.org>
parents:
8810
diff
changeset
|
1437 |
1681 | 1438 #ifndef FEAT_WINDOWS |
7856
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1439 int |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1440 win_valid(win_T *w) |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1441 { |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1442 return TRUE; |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1443 } |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1444 int |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1445 win_count(void) |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1446 { |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1447 return 1; |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1448 } |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1449 win_T * |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1450 win_find_nr(int n) |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1451 { |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1452 return curwin; |
226ed297307f
commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1453 } |
1681 | 1454 #endif |
1455 | |
7 | 1456 XS(boot_VIM); |
1457 | |
1458 static void | |
1459 xs_init(pTHX) | |
1460 { | |
1461 char *file = __FILE__; | |
1462 | |
1463 /* DynaLoader is a special case */ | |
1464 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); | |
1465 newXS("VIM::bootstrap", boot_VIM, file); | |
1466 } | |
1467 | |
1468 typedef win_T * VIWIN; | |
1469 typedef buf_T * VIBUF; | |
1470 | |
1471 MODULE = VIM PACKAGE = VIM | |
1472 | |
1473 void | |
1474 Msg(text, hl=NULL) | |
1475 char *text; | |
1476 char *hl; | |
1477 | |
1478 PREINIT: | |
1479 int attr; | |
1480 int id; | |
1481 | |
1482 PPCODE: | |
1483 if (text != NULL) | |
1484 { | |
1485 attr = 0; | |
1486 if (hl != NULL) | |
1487 { | |
1488 id = syn_name2id((char_u *)hl); | |
1489 if (id != 0) | |
1490 attr = syn_id2attr(id); | |
1491 } | |
1492 msg_split((char_u *)text, attr); | |
1493 } | |
1494 | |
1495 void | |
1496 SetOption(line) | |
1497 char *line; | |
1498 | |
1499 PPCODE: | |
1500 if (line != NULL) | |
1501 do_set((char_u *)line, 0); | |
1502 update_screen(NOT_VALID); | |
1503 | |
1504 void | |
1505 DoCommand(line) | |
1506 char *line; | |
1507 | |
1508 PPCODE: | |
1509 if (line != NULL) | |
1510 do_cmdline_cmd((char_u *)line); | |
1511 | |
1512 void | |
1513 Eval(str) | |
1514 char *str; | |
1515 | |
1516 PREINIT: | |
1517 char_u *value; | |
1518 PPCODE: | |
714 | 1519 value = eval_to_string((char_u *)str, (char_u **)0, TRUE); |
7 | 1520 if (value == NULL) |
1521 { | |
1522 XPUSHs(sv_2mortal(newSViv(0))); | |
1523 XPUSHs(sv_2mortal(newSVpv("", 0))); | |
1524 } | |
1525 else | |
1526 { | |
1527 XPUSHs(sv_2mortal(newSViv(1))); | |
1528 XPUSHs(sv_2mortal(newSVpv((char *)value, 0))); | |
1529 vim_free(value); | |
1530 } | |
1531 | |
1532 void | |
1533 Buffers(...) | |
1534 | |
1535 PREINIT: | |
1536 buf_T *vimbuf; | |
1537 int i, b; | |
1538 | |
1539 PPCODE: | |
1540 if (items == 0) | |
1541 { | |
1542 if (GIMME == G_SCALAR) | |
1543 { | |
1544 i = 0; | |
1545 for (vimbuf = firstbuf; vimbuf; vimbuf = vimbuf->b_next) | |
1546 ++i; | |
1547 | |
1548 XPUSHs(sv_2mortal(newSViv(i))); | |
1549 } | |
1550 else | |
1551 { | |
1552 for (vimbuf = firstbuf; vimbuf; vimbuf = vimbuf->b_next) | |
1553 XPUSHs(newBUFrv(newSV(0), vimbuf)); | |
1554 } | |
1555 } | |
1556 else | |
1557 { | |
1558 for (i = 0; i < items; i++) | |
1559 { | |
1560 SV *sv = ST(i); | |
1561 if (SvIOK(sv)) | |
4105 | 1562 b = (int) SvIV(ST(i)); |
7 | 1563 else |
1564 { | |
1565 char_u *pat; | |
1566 STRLEN len; | |
1567 | |
1568 pat = (char_u *)SvPV(sv, len); | |
1569 ++emsg_off; | |
4236 | 1570 b = buflist_findpat(pat, pat+len, FALSE, FALSE, FALSE); |
7 | 1571 --emsg_off; |
1572 } | |
1573 | |
1574 if (b >= 0) | |
1575 { | |
1576 vimbuf = buflist_findnr(b); | |
1577 if (vimbuf) | |
1578 XPUSHs(newBUFrv(newSV(0), vimbuf)); | |
1579 } | |
1580 } | |
1581 } | |
1582 | |
1583 void | |
1584 Windows(...) | |
1585 | |
1586 PREINIT: | |
1587 win_T *vimwin; | |
1588 int i, w; | |
1589 | |
1590 PPCODE: | |
1591 if (items == 0) | |
1592 { | |
1593 if (GIMME == G_SCALAR) | |
1594 XPUSHs(sv_2mortal(newSViv(win_count()))); | |
1595 else | |
1596 { | |
1597 for (vimwin = firstwin; vimwin != NULL; vimwin = W_NEXT(vimwin)) | |
1598 XPUSHs(newWINrv(newSV(0), vimwin)); | |
1599 } | |
1600 } | |
1601 else | |
1602 { | |
1603 for (i = 0; i < items; i++) | |
1604 { | |
4105 | 1605 w = (int) SvIV(ST(i)); |
7 | 1606 vimwin = win_find_nr(w); |
1607 if (vimwin) | |
1608 XPUSHs(newWINrv(newSV(0), vimwin)); | |
1609 } | |
1610 } | |
1611 | |
1612 MODULE = VIM PACKAGE = VIWIN | |
1613 | |
1614 void | |
1615 DESTROY(win) | |
1616 VIWIN win | |
1617 | |
1618 CODE: | |
1619 if (win_valid(win)) | |
502 | 1620 win->w_perl_private = 0; |
7 | 1621 |
1622 SV * | |
1623 Buffer(win) | |
1624 VIWIN win | |
1625 | |
1626 CODE: | |
1627 if (!win_valid(win)) | |
1628 win = curwin; | |
1629 RETVAL = newBUFrv(newSV(0), win->w_buffer); | |
1630 OUTPUT: | |
1631 RETVAL | |
1632 | |
1633 void | |
1634 SetHeight(win, height) | |
1635 VIWIN win | |
1636 int height; | |
1637 | |
1638 PREINIT: | |
1639 win_T *savewin; | |
1640 | |
1641 PPCODE: | |
1642 if (!win_valid(win)) | |
1643 win = curwin; | |
1644 savewin = curwin; | |
1645 curwin = win; | |
1646 win_setheight(height); | |
1647 curwin = savewin; | |
1648 | |
1649 void | |
8810
83d0b976d9b3
commit https://github.com/vim/vim/commit/864733ad92e30cd603314604af73f25106db4c90
Christian Brabandt <cb@256bit.org>
parents:
8214
diff
changeset
|
1650 Cursor(win, ...) |
83d0b976d9b3
commit https://github.com/vim/vim/commit/864733ad92e30cd603314604af73f25106db4c90
Christian Brabandt <cb@256bit.org>
parents:
8214
diff
changeset
|
1651 VIWIN win |
7 | 1652 |
1653 PPCODE: | |
2982 | 1654 if (items == 1) |
7 | 1655 { |
1656 EXTEND(sp, 2); | |
1657 if (!win_valid(win)) | |
1658 win = curwin; | |
1659 PUSHs(sv_2mortal(newSViv(win->w_cursor.lnum))); | |
1660 PUSHs(sv_2mortal(newSViv(win->w_cursor.col))); | |
1661 } | |
2982 | 1662 else if (items == 3) |
7 | 1663 { |
1664 int lnum, col; | |
1665 | |
1666 if (!win_valid(win)) | |
1667 win = curwin; | |
4105 | 1668 lnum = (int) SvIV(ST(1)); |
1669 col = (int) SvIV(ST(2)); | |
7 | 1670 win->w_cursor.lnum = lnum; |
1671 win->w_cursor.col = col; | |
1672 check_cursor(); /* put cursor on an existing line */ | |
1673 update_screen(NOT_VALID); | |
1674 } | |
1675 | |
1676 MODULE = VIM PACKAGE = VIBUF | |
1677 | |
1678 void | |
1679 DESTROY(vimbuf) | |
1680 VIBUF vimbuf; | |
1681 | |
1682 CODE: | |
1683 if (buf_valid(vimbuf)) | |
502 | 1684 vimbuf->b_perl_private = 0; |
7 | 1685 |
1686 void | |
1687 Name(vimbuf) | |
1688 VIBUF vimbuf; | |
1689 | |
1690 PPCODE: | |
1691 if (!buf_valid(vimbuf)) | |
1692 vimbuf = curbuf; | |
1693 /* No file name returns an empty string */ | |
1694 if (vimbuf->b_fname == NULL) | |
1695 XPUSHs(sv_2mortal(newSVpv("", 0))); | |
1696 else | |
1697 XPUSHs(sv_2mortal(newSVpv((char *)vimbuf->b_fname, 0))); | |
1698 | |
1699 void | |
1700 Number(vimbuf) | |
1701 VIBUF vimbuf; | |
1702 | |
1703 PPCODE: | |
1704 if (!buf_valid(vimbuf)) | |
1705 vimbuf = curbuf; | |
1706 XPUSHs(sv_2mortal(newSViv(vimbuf->b_fnum))); | |
1707 | |
1708 void | |
1709 Count(vimbuf) | |
1710 VIBUF vimbuf; | |
1711 | |
1712 PPCODE: | |
1713 if (!buf_valid(vimbuf)) | |
1714 vimbuf = curbuf; | |
1715 XPUSHs(sv_2mortal(newSViv(vimbuf->b_ml.ml_line_count))); | |
1716 | |
1717 void | |
1718 Get(vimbuf, ...) | |
1719 VIBUF vimbuf; | |
1720 | |
1721 PREINIT: | |
1722 char_u *line; | |
1723 int i; | |
1724 long lnum; | |
1725 PPCODE: | |
1726 if (buf_valid(vimbuf)) | |
1727 { | |
1728 for (i = 1; i < items; i++) | |
1729 { | |
4105 | 1730 lnum = (long) SvIV(ST(i)); |
7 | 1731 if (lnum > 0 && lnum <= vimbuf->b_ml.ml_line_count) |
1732 { | |
1733 line = ml_get_buf(vimbuf, lnum, FALSE); | |
1734 XPUSHs(sv_2mortal(newSVpv((char *)line, 0))); | |
1735 } | |
1736 } | |
1737 } | |
1738 | |
1739 void | |
1740 Set(vimbuf, ...) | |
1741 VIBUF vimbuf; | |
1742 | |
1743 PREINIT: | |
1744 int i; | |
1745 long lnum; | |
1746 char *line; | |
1747 PPCODE: | |
1748 if (buf_valid(vimbuf)) | |
1749 { | |
1750 if (items < 3) | |
1751 croak("Usage: VIBUF::Set(vimbuf, lnum, @lines)"); | |
1752 | |
4105 | 1753 lnum = (long) SvIV(ST(1)); |
7 | 1754 for(i = 2; i < items; i++, lnum++) |
1755 { | |
1756 line = SvPV(ST(i),PL_na); | |
1757 if (lnum > 0 && lnum <= vimbuf->b_ml.ml_line_count && line != NULL) | |
1758 { | |
918 | 1759 aco_save_T aco; |
1760 | |
1761 /* set curwin/curbuf for "vimbuf" and save some things */ | |
1762 aucmd_prepbuf(&aco, vimbuf); | |
1763 | |
7 | 1764 if (u_savesub(lnum) == OK) |
1765 { | |
1766 ml_replace(lnum, (char_u *)line, TRUE); | |
1767 changed_bytes(lnum, 0); | |
1768 } | |
934 | 1769 |
918 | 1770 /* restore curwin/curbuf and a few other things */ |
1771 aucmd_restbuf(&aco); | |
1772 /* Careful: autocommands may have made "vimbuf" invalid! */ | |
7 | 1773 } |
1774 } | |
1775 } | |
1776 | |
1777 void | |
1778 Delete(vimbuf, ...) | |
1779 VIBUF vimbuf; | |
1780 | |
1781 PREINIT: | |
1782 long i, lnum = 0, count = 0; | |
1783 PPCODE: | |
1784 if (buf_valid(vimbuf)) | |
1785 { | |
1786 if (items == 2) | |
1787 { | |
4105 | 1788 lnum = (long) SvIV(ST(1)); |
7 | 1789 count = 1; |
1790 } | |
1791 else if (items == 3) | |
1792 { | |
4105 | 1793 lnum = (long) SvIV(ST(1)); |
1794 count = (long) 1 + SvIV(ST(2)) - lnum; | |
2982 | 1795 if (count == 0) |
7 | 1796 count = 1; |
2982 | 1797 if (count < 0) |
7 | 1798 { |
1799 lnum -= count; | |
1800 count = -count; | |
1801 } | |
1802 } | |
1803 if (items >= 2) | |
1804 { | |
1805 for (i = 0; i < count; i++) | |
1806 { | |
1807 if (lnum > 0 && lnum <= vimbuf->b_ml.ml_line_count) | |
1808 { | |
918 | 1809 aco_save_T aco; |
1810 | |
1811 /* set curwin/curbuf for "vimbuf" and save some things */ | |
1812 aucmd_prepbuf(&aco, vimbuf); | |
934 | 1813 |
7 | 1814 if (u_savedel(lnum, 1) == OK) |
1815 { | |
1816 ml_delete(lnum, 0); | |
1929 | 1817 check_cursor(); |
7 | 1818 deleted_lines_mark(lnum, 1L); |
1819 } | |
934 | 1820 |
918 | 1821 /* restore curwin/curbuf and a few other things */ |
1822 aucmd_restbuf(&aco); | |
1823 /* Careful: autocommands may have made "vimbuf" invalid! */ | |
934 | 1824 |
7 | 1825 update_curbuf(VALID); |
1826 } | |
1827 } | |
1828 } | |
1829 } | |
1830 | |
1831 void | |
1832 Append(vimbuf, ...) | |
1833 VIBUF vimbuf; | |
1834 | |
1835 PREINIT: | |
1836 int i; | |
1837 long lnum; | |
1838 char *line; | |
1839 PPCODE: | |
1840 if (buf_valid(vimbuf)) | |
1841 { | |
1842 if (items < 3) | |
1843 croak("Usage: VIBUF::Append(vimbuf, lnum, @lines)"); | |
1844 | |
4105 | 1845 lnum = (long) SvIV(ST(1)); |
7 | 1846 for (i = 2; i < items; i++, lnum++) |
1847 { | |
1848 line = SvPV(ST(i),PL_na); | |
1849 if (lnum >= 0 && lnum <= vimbuf->b_ml.ml_line_count && line != NULL) | |
1850 { | |
918 | 1851 aco_save_T aco; |
1852 | |
1853 /* set curwin/curbuf for "vimbuf" and save some things */ | |
1854 aucmd_prepbuf(&aco, vimbuf); | |
1855 | |
7 | 1856 if (u_inssub(lnum + 1) == OK) |
1857 { | |
1858 ml_append(lnum, (char_u *)line, (colnr_T)0, FALSE); | |
1859 appended_lines_mark(lnum, 1L); | |
1860 } | |
934 | 1861 |
918 | 1862 /* restore curwin/curbuf and a few other things */ |
1863 aucmd_restbuf(&aco); | |
1864 /* Careful: autocommands may have made "vimbuf" invalid! */ | |
934 | 1865 |
7 | 1866 update_curbuf(VALID); |
1867 } | |
1868 } | |
1869 } | |
1870 | |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7856
diff
changeset
|
1871 #ifdef __GNUC__ |
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7856
diff
changeset
|
1872 # pragma GCC diagnostic pop |
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7856
diff
changeset
|
1873 #endif |