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