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