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