annotate src/evalfunc.c @ 29247:5f314b2ed494 v8.2.5142

patch 8.2.5142: startup test fails if there is a status bar Commit: https://github.com/vim/vim/commit/fa04eae5a5b9394079bde2d37ce6f9f8a5567d48 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 21 14:38:40 2022 +0100 patch 8.2.5142: startup test fails if there is a status bar Problem: Startup test fails if there is a status bar at the top of the screen. (Ernie Rael) Solution: Use a larger vertical offset in the test.
author Bram Moolenaar <Bram@vim.org>
date Tue, 21 Jun 2022 18:45:07 +0200
parents d1e263ecf634
children f27ec19f2034
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 10009
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 * evalfunc.c: Builtin functions
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 #define USING_FLOAT_STUFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 #include "vim.h"
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 #if defined(FEAT_EVAL) || defined(PROTO)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 #ifdef VMS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 # include <float.h>
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 static void f_and(typval_T *argvars, typval_T *rettv);
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
24 #ifdef FEAT_BEVAL
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
25 static void f_balloon_gettext(typval_T *argvars, typval_T *rettv);
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
26 static void f_balloon_show(typval_T *argvars, typval_T *rettv);
12885
10cb5c3df3f5 patch 8.0.1319: can't build GUI on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
27 # if defined(FEAT_BEVAL_TERM)
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
28 static void f_balloon_split(typval_T *argvars, typval_T *rettv);
12885
10cb5c3df3f5 patch 8.0.1319: can't build GUI on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
29 # endif
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
30 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 static void f_byte2line(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 static void f_call(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 static void f_changenr(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 static void f_char2nr(typval_T *argvars, typval_T *rettv);
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
35 static void f_charcol(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 static void f_col(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 static void f_confirm(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 static void f_copy(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 static void f_cursor(typval_T *argsvars, typval_T *rettv);
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
40 #ifdef MSWIN
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
41 static void f_debugbreak(typval_T *argvars, typval_T *rettv);
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
42 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 static void f_deepcopy(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 static void f_did_filetype(typval_T *argvars, typval_T *rettv);
19400
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
45 static void f_echoraw(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 static void f_empty(typval_T *argvars, typval_T *rettv);
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
47 static void f_environ(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 static void f_escape(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 static void f_eval(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 static void f_eventhandler(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 static void f_execute(typval_T *argvars, typval_T *rettv);
25555
446f478d6fb1 patch 8.2.3314: behavior of exists() in a :def function is unpredictable
Bram Moolenaar <Bram@vim.org>
parents: 25527
diff changeset
52 static void f_exists_compiled(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 static void f_expand(typval_T *argvars, typval_T *rettv);
17020
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
54 static void f_expandcmd(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 static void f_feedkeys(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 static void f_fnameescape(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 static void f_foreground(typval_T *argvars, typval_T *rettv);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
58 static void f_funcref(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 static void f_function(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 static void f_garbagecollect(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 static void f_get(typval_T *argvars, typval_T *rettv);
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
62 static void f_getchangelist(typval_T *argvars, typval_T *rettv);
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
63 static void f_getcharpos(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 static void f_getcharsearch(typval_T *argvars, typval_T *rettv);
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
65 static void f_getenv(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 static void f_getfontname(typval_T *argvars, typval_T *rettv);
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
67 static void f_getjumplist(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 static void f_getpid(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 static void f_getcurpos(typval_T *argvars, typval_T *rettv);
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
70 static void f_getcursorcharpos(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 static void f_getpos(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 static void f_getreg(typval_T *argvars, typval_T *rettv);
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
73 static void f_getreginfo(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 static void f_getregtype(typval_T *argvars, typval_T *rettv);
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
75 static void f_gettagstack(typval_T *argvars, typval_T *rettv);
21989
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
76 static void f_gettext(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 static void f_haslocaldir(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 static void f_hasmapto(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 static void f_hlID(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 static void f_hlexists(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 static void f_hostname(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 static void f_index(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 static void f_input(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 static void f_inputdialog(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 static void f_inputlist(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 static void f_inputrestore(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 static void f_inputsave(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 static void f_inputsecret(typval_T *argvars, typval_T *rettv);
18699
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
89 static void f_interrupt(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 static void f_invert(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 static void f_islocked(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 static void f_last_buffer_nr(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 static void f_libcall(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 static void f_libcallnr(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 static void f_line(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 static void f_line2byte(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 #ifdef FEAT_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 static void f_luaeval(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 static void f_match(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 static void f_matchend(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 static void f_matchlist(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 static void f_matchstr(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 static void f_matchstrpos(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 static void f_max(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 static void f_min(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 #ifdef FEAT_MZSCHEME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 static void f_mzeval(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 static void f_nextnonblank(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 static void f_nr2char(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 static void f_or(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 #ifdef FEAT_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 static void f_perleval(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 static void f_prevnonblank(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 static void f_printf(typval_T *argvars, typval_T *rettv);
17756
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
118 static void f_pum_getpos(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 static void f_pumvisible(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 #ifdef FEAT_PYTHON3
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 static void f_py3eval(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 #ifdef FEAT_PYTHON
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 static void f_pyeval(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 #endif
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
126 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
127 static void f_pyxeval(typval_T *argvars, typval_T *rettv);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
128 #endif
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
129 static void f_test_srand_seed(typval_T *argvars, typval_T *rettv);
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
130 static void f_rand(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 static void f_range(typval_T *argvars, typval_T *rettv);
14004
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
132 static void f_reg_executing(typval_T *argvars, typval_T *rettv);
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
133 static void f_reg_recording(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 static void f_rename(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 static void f_repeat(typval_T *argvars, typval_T *rettv);
16103
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
136 #ifdef FEAT_RUBY
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
137 static void f_rubyeval(typval_T *argvars, typval_T *rettv);
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
138 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 static void f_screenattr(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 static void f_screenchar(typval_T *argvars, typval_T *rettv);
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
141 static void f_screenchars(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 static void f_screencol(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 static void f_screenrow(typval_T *argvars, typval_T *rettv);
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
144 static void f_screenstring(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 static void f_search(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 static void f_searchdecl(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 static void f_searchpair(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 static void f_searchpairpos(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 static void f_searchpos(typval_T *argvars, typval_T *rettv);
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
150 static void f_setcharpos(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 static void f_setcharsearch(typval_T *argvars, typval_T *rettv);
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
152 static void f_setcursorcharpos(typval_T *argvars, typval_T *rettv);
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
153 static void f_setenv(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 static void f_setfperm(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 static void f_setpos(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 static void f_setreg(typval_T *argvars, typval_T *rettv);
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
157 static void f_settagstack(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 #ifdef FEAT_CRYPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 static void f_sha256(typval_T *argvars, typval_T *rettv);
17966
46f95606b9ec patch 8.1.1979: code for handling file names is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17964
diff changeset
160 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 static void f_shellescape(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 static void f_shiftwidth(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 static void f_soundfold(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 static void f_spellbadword(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 static void f_spellsuggest(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 static void f_split(typval_T *argvars, typval_T *rettv);
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
167 static void f_srand(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 static void f_submatch(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 static void f_substitute(typval_T *argvars, typval_T *rettv);
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
170 static void f_swapinfo(typval_T *argvars, typval_T *rettv);
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
171 static void f_swapname(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 static void f_synID(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 static void f_synIDattr(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 static void f_synIDtrans(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 static void f_synstack(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 static void f_synconcealed(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 static void f_tabpagebuflist(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 static void f_taglist(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 static void f_tagfiles(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 static void f_type(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 static void f_virtcol(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 static void f_visualmode(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 static void f_wildmenumode(typval_T *argvars, typval_T *rettv);
18973
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
184 static void f_windowsversion(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 static void f_wordcount(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 static void f_xor(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
188
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
189 /*
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
190 * Functions that check the argument type of a builtin function.
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
191 * Each function returns FAIL and gives an error message if the type is wrong.
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
192 */
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
193
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
194 // Context passed to an arg_ function.
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
195 typedef struct {
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
196 int arg_count; // actual argument count
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
197 type2_T *arg_types; // list of argument types
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
198 int arg_idx; // current argument index (first arg is zero)
23640
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
199 cctx_T *arg_cctx;
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
200 } argcontext_T;
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
201
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
202 // A function to check one argument type. The first argument is the type to
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
203 // check. If needed, other argument types can be obtained with the context.
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
204 // E.g. if "arg_idx" is 1, then (type - 1) is the first argument type.
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
205 typedef int (*argcheck_T)(type_T *, type_T *, argcontext_T *);
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
206
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
207 /*
23640
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
208 * Call need_type() to check an argument type.
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
209 */
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
210 static int
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
211 check_arg_type(
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
212 type_T *expected,
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
213 type_T *actual,
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
214 argcontext_T *context)
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
215 {
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
216 // TODO: would be useful to know if "actual" is a constant and pass it to
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
217 // need_type() to get a compile time error if possible.
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
218 return need_type(actual, expected,
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
219 context->arg_idx - context->arg_count, context->arg_idx + 1,
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
220 context->arg_cctx, FALSE, FALSE);
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
221 }
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
222
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
223 /*
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
224 * Check "type" is a float or a number.
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
225 */
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
226 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
227 arg_float_or_nr(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
228 {
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
229 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
230 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
231 || type->tt_type == VAR_FLOAT
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
232 || type->tt_type == VAR_NUMBER)
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
233 return OK;
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
234 arg_type_mismatch(&t_number, type, context->arg_idx + 1);
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
235 return FAIL;
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
236 }
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
237
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
238 /*
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
239 * Check "type" is a number.
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
240 */
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
241 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
242 arg_number(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
243 {
23640
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
244 return check_arg_type(&t_number, type, context);
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
245 }
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
246
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
247 /*
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
248 * Check "type" is a dict of 'any'.
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
249 */
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
250 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
251 arg_dict_any(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
252 {
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
253 return check_arg_type(&t_dict_any, type, context);
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
254 }
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
255
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
256 /*
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
257 * Check "type" is a list of 'any'.
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
258 */
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
259 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
260 arg_list_any(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
261 {
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
262 return check_arg_type(&t_list_any, type, context);
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
263 }
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
264
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
265 /*
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
266 * Check "type" is a list of numbers.
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
267 */
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
268 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
269 arg_list_number(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
270 {
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
271 return check_arg_type(&t_list_number, type, context);
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
272 }
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
273
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
274 /*
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
275 * Check "type" is a list of strings.
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
276 */
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
277 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
278 arg_list_string(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
279 {
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
280 return check_arg_type(&t_list_string, type, context);
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
281 }
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
282
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
283 /*
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
284 * Check "type" is a string.
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
285 */
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
286 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
287 arg_string(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
288 {
23640
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
289 return check_arg_type(&t_string, type, context);
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
290 }
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
291
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
292 /*
25806
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
293 * Check "type" is a blob
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
294 */
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
295 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
296 arg_blob(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25806
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
297 {
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
298 return check_arg_type(&t_blob, type, context);
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
299 }
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
300
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
301 /*
23786
0512923e54e1 patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
302 * Check "type" is a bool or number 0 or 1.
0512923e54e1 patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
303 */
0512923e54e1 patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
304 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
305 arg_bool(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
23786
0512923e54e1 patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
306 {
0512923e54e1 patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
307 return check_arg_type(&t_bool, type, context);
0512923e54e1 patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
308 }
0512923e54e1 patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
309
0512923e54e1 patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
310 /*
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
311 * Check "type" is a list of 'any' or a blob.
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
312 */
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
313 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
314 arg_list_or_blob(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
315 {
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
316 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
317 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
318 || type->tt_type == VAR_LIST
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
319 || type->tt_type == VAR_BLOB)
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
320 return OK;
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
321 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
322 return FAIL;
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
323 }
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
324
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
325 /*
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
326 * Check "type" is a string or a number
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
327 */
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
328 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
329 arg_string_or_nr(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
330 {
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
331 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
332 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
333 || type->tt_type == VAR_STRING
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
334 || type->tt_type == VAR_NUMBER)
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
335 return OK;
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
336 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
337 return FAIL;
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
338 }
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
339
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
340 /*
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
341 * Check "type" is a buffer (string or a number)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
342 */
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
343 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
344 arg_buffer(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
345 {
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
346 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
347 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
348 || type->tt_type == VAR_STRING
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
349 || type->tt_type == VAR_NUMBER)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
350 return OK;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
351 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
352 return FAIL;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
353 }
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
354
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
355 /*
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
356 * Check "type" is a buffer or a dict of any
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
357 */
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
358 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
359 arg_buffer_or_dict_any(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
360 {
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
361 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
362 || type->tt_type == VAR_UNKNOWN
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
363 || type->tt_type == VAR_STRING
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
364 || type->tt_type == VAR_NUMBER
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
365 || type->tt_type == VAR_DICT)
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
366 return OK;
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
367 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
368 return FAIL;
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
369 }
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
370
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
371 /*
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
372 * Check "type" is a line (string or a number)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
373 */
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
374 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
375 arg_lnum(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
376 {
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
377 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
378 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
379 || type->tt_type == VAR_STRING
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
380 || type->tt_type == VAR_NUMBER)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
381 return OK;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
382 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
383 return FAIL;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
384 }
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
385
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
386 /*
24972
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
387 * Check "type" is a string or a list of strings.
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
388 */
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
389 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
390 arg_string_or_list_string(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
24972
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
391 {
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
392 if (type->tt_type == VAR_ANY
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
393 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
394 || type->tt_type == VAR_STRING)
24972
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
395 return OK;
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
396 if (type->tt_type != VAR_LIST)
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
397 {
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
398 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
399 return FAIL;
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
400 }
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
401 if (type->tt_member->tt_type == VAR_ANY
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
402 || type->tt_member->tt_type == VAR_STRING)
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
403 return OK;
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
404
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
405 arg_type_mismatch(&t_list_string, type, context->arg_idx + 1);
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
406 return FAIL;
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
407 }
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
408
b11f38f77006 patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
409 /*
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
410 * Check "type" is a string or a list of 'any'
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
411 */
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
412 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
413 arg_string_or_list_any(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
414 {
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
415 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
416 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
417 || type->tt_type == VAR_STRING
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
418 || type->tt_type == VAR_LIST)
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
419 return OK;
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
420 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
421 return FAIL;
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
422 }
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
423
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
424 /*
28674
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
425 * Check "type" is a string or a dict of 'any'
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
426 */
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
427 static int
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
428 arg_string_or_dict_any(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
429 {
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
430 if (type->tt_type == VAR_ANY
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
431 || type->tt_type == VAR_UNKNOWN
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
432 || type->tt_type == VAR_STRING
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
433 || type->tt_type == VAR_DICT)
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
434 return OK;
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
435 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
436 return FAIL;
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
437 }
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
438
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
439 /*
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
440 * Check "type" is a string or a blob
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
441 */
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
442 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
443 arg_string_or_blob(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
444 {
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
445 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
446 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
447 || type->tt_type == VAR_STRING
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
448 || type->tt_type == VAR_BLOB)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
449 return OK;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
450 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
451 return FAIL;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
452 }
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
453
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
454 /*
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
455 * Check "type" is a list of 'any' or a dict of 'any'.
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
456 */
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
457 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
458 arg_list_or_dict(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
459 {
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
460 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
461 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
462 || type->tt_type == VAR_LIST
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
463 || type->tt_type == VAR_DICT)
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
464 return OK;
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
465 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
466 return FAIL;
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
467 }
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
468
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
469 /*
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
470 * Check "type" is a list of 'any' or a dict of 'any' or a blob.
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
471 */
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
472 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
473 arg_list_or_dict_or_blob(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
474 {
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
475 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
476 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
477 || type->tt_type == VAR_LIST
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
478 || type->tt_type == VAR_DICT
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
479 || type->tt_type == VAR_BLOB)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
480 return OK;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
481 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
482 return FAIL;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
483 }
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
484
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
485 /*
26585
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
486 * Check "type" is a list of 'any' or a dict of 'any' or a blob or a string.
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
487 */
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
488 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
489 arg_list_or_dict_or_blob_or_string(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
26585
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
490 {
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
491 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
492 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
493 || type->tt_type == VAR_LIST
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
494 || type->tt_type == VAR_DICT
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
495 || type->tt_type == VAR_BLOB
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
496 || type->tt_type == VAR_STRING)
26585
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
497 return OK;
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
498 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
499 return FAIL;
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
500 }
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
501
0d2a709e2ff0 patch 8.2.3822: leaking memory in map() and filter(), no string in Vim9
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
502 /*
27831
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
503 * Check second argument of map() or filter().
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
504 */
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
505 static int
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
506 check_map_filter_arg2(type_T *type, argcontext_T *context, int is_map)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
507 {
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
508 type_T *expected_member = NULL;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
509 type_T *(args[2]);
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
510 type_T t_func_exp = {VAR_FUNC, 2, 0, 0, NULL, args};
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
511
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
512 if (context->arg_types[0].type_curr->tt_type == VAR_LIST
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
513 || context->arg_types[0].type_curr->tt_type == VAR_DICT)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
514 {
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
515 // Use the declared type if possible, so that an error is given if
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
516 // a declared list changes type, but not if a constant list changes
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
517 // type.
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
518 if (context->arg_types[0].type_decl->tt_type == VAR_LIST
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
519 || context->arg_types[0].type_decl->tt_type == VAR_DICT)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
520 expected_member = context->arg_types[0].type_decl->tt_member;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
521 else
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
522 expected_member = context->arg_types[0].type_curr->tt_member;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
523 }
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
524 else if (context->arg_types[0].type_curr->tt_type == VAR_STRING)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
525 expected_member = &t_string;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
526 else if (context->arg_types[0].type_curr->tt_type == VAR_BLOB)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
527 expected_member = &t_number;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
528
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
529 args[0] = NULL;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
530 args[1] = &t_unknown;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
531 if (type->tt_argcount != -1)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
532 {
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
533 if (!(type->tt_argcount == 2 || (type->tt_argcount == 1
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
534 && (type->tt_flags & TTFLAG_VARARGS))))
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
535 {
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
536 emsg(_(e_invalid_number_of_arguments));
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
537 return FAIL;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
538 }
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
539 if (type->tt_flags & TTFLAG_VARARGS)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
540 // check the argument types at runtime
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
541 t_func_exp.tt_argcount = -1;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
542 else
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
543 {
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
544 if (context->arg_types[0].type_curr->tt_type == VAR_STRING
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
545 || context->arg_types[0].type_curr->tt_type == VAR_BLOB
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
546 || context->arg_types[0].type_curr->tt_type == VAR_LIST)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
547 args[0] = &t_number;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
548 else if (context->arg_types[0].type_decl->tt_type == VAR_DICT)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
549 args[0] = &t_string;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
550 if (args[0] != NULL)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
551 args[1] = expected_member;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
552 }
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
553 }
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
554
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
555 if ((type->tt_member != &t_any && type->tt_member != &t_unknown)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
556 || args[0] != NULL)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
557 {
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
558 where_T where = WHERE_INIT;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
559
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
560 if (is_map)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
561 t_func_exp.tt_member = expected_member == NULL
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
562 || type->tt_member == &t_any
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
563 || type->tt_member == &t_unknown
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
564 ? &t_any : expected_member;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
565 else
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
566 t_func_exp.tt_member = &t_bool;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
567 if (args[0] == NULL)
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
568 args[0] = &t_unknown;
27865
05d222e5246a patch 8.2.4458: Vim9: compiling filter() call fails with unknown arguments
Bram Moolenaar <Bram@vim.org>
parents: 27863
diff changeset
569 if (type->tt_argcount == -1)
05d222e5246a patch 8.2.4458: Vim9: compiling filter() call fails with unknown arguments
Bram Moolenaar <Bram@vim.org>
parents: 27863
diff changeset
570 t_func_exp.tt_argcount = -1;
27831
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
571
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
572 where.wt_index = 2;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
573 return check_type(&t_func_exp, type, TRUE, where);
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
574 }
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
575 return OK;
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
576 }
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
577
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
578 /*
26737
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
579 * Check second argument of filter(): func must return a bool.
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
580 */
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
581 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
582 arg_filter_func(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
26737
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
583 {
27392
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
584 if (type->tt_type == VAR_STRING
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
585 || type->tt_type == VAR_PARTIAL
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
586 || type == &t_unknown
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
587 || type == &t_any)
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
588 return OK;
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
589
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
590 if (type->tt_type == VAR_FUNC)
27831
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
591 return check_map_filter_arg2(type, context, FALSE);
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
592 semsg(_(e_string_or_function_required_for_argument_nr), 2);
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
593 return FAIL;
26737
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
594 }
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
595
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
596 /*
27798
324d394e314e patch 8.2.4425: map() function does not check function arguments
Bram Moolenaar <Bram@vim.org>
parents: 27752
diff changeset
597 * Check second argument of map(), the function.
26737
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
598 */
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
599 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
600 arg_map_func(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
26737
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
601 {
27392
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
602 if (type->tt_type == VAR_STRING
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
603 || type->tt_type == VAR_PARTIAL
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
604 || type == &t_unknown
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
605 || type == &t_any)
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
606 return OK;
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
607
ec2ba9acec1b patch 8.2.4224: Vim9: no error when using a number for map() second argument
Bram Moolenaar <Bram@vim.org>
parents: 27295
diff changeset
608 if (type->tt_type == VAR_FUNC)
27831
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
609 return check_map_filter_arg2(type, context, TRUE);
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
610 semsg(_(e_string_or_function_required_for_argument_nr), 2);
0a3ab3216b75 patch 8.2.4441: Vim9: function argument of filter() not checked like map()
Bram Moolenaar <Bram@vim.org>
parents: 27819
diff changeset
611 return FAIL;
26737
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
612 }
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
613
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
614 /*
27847
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
615 * Check second argument of sort() and uniq(), the "how" argument.
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
616 */
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
617 static int
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
618 arg_sort_how(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
619 {
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
620 if (type->tt_type == VAR_STRING
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
621 || type->tt_type == VAR_PARTIAL
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
622 || type == &t_unknown
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
623 || type == &t_any)
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
624 return OK;
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
625
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
626 if (type->tt_type == VAR_FUNC)
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
627 {
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
628 type_T *(args[2]);
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
629 type_T t_func_exp = {VAR_FUNC, 2, 0, 0, &t_number, args};
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
630
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
631 if (context->arg_types[0].type_curr->tt_type == VAR_LIST)
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
632 args[0] = context->arg_types[0].type_curr->tt_member;
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
633 else
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
634 args[0] = &t_unknown;
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
635 if ((type->tt_member != &t_any && type->tt_member != &t_unknown)
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
636 || args[0] != &t_unknown)
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
637 {
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
638 where_T where = WHERE_INIT;
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
639
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
640 args[1] = args[0];
27867
1b75d767d9e4 patch 8.2.4459: Vim9: compiling sort() call fails with unknown arguments
Bram Moolenaar <Bram@vim.org>
parents: 27865
diff changeset
641 if (type->tt_argcount == -1)
1b75d767d9e4 patch 8.2.4459: Vim9: compiling sort() call fails with unknown arguments
Bram Moolenaar <Bram@vim.org>
parents: 27865
diff changeset
642 t_func_exp.tt_argcount = -1;
27847
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
643 where.wt_index = 2;
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
644 return check_type(&t_func_exp, type, TRUE, where);
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
645 }
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
646
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
647 return OK;
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
648 }
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
649 semsg(_(e_string_or_function_required_for_argument_nr), 2);
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
650 return FAIL;
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
651 }
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
652
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
653 /*
26751
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
654 * Check an expression argument, can be a string, funcref or partial.
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
655 * Also accept a bool, a constant resulting from compiling a string argument.
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
656 * Also accept a number, one and zero are accepted.
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
657 */
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
658 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
659 arg_string_or_func(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
26751
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
660 {
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
661 if (type->tt_type == VAR_ANY
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
662 || type->tt_type == VAR_UNKNOWN
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
663 || type->tt_type == VAR_STRING
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
664 || type->tt_type == VAR_PARTIAL
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
665 || type->tt_type == VAR_FUNC
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
666 || type->tt_type == VAR_BOOL
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
667 || type->tt_type == VAR_NUMBER)
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
668 return OK;
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
669 arg_type_mismatch(&t_func_any, type, context->arg_idx + 1);
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
670 return FAIL;
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
671 }
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
672
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
673 /*
26638
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
674 * Check "type" is a list of 'any' or a blob or a string.
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
675 */
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
676 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
677 arg_string_list_or_blob(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
26638
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
678 {
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
679 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
680 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
681 || type->tt_type == VAR_LIST
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
682 || type->tt_type == VAR_BLOB
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
683 || type->tt_type == VAR_STRING)
26638
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
684 return OK;
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
685 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
686 return FAIL;
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
687 }
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
688
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
689 /*
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
690 * Check "type" is a job.
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
691 */
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
692 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
693 arg_job(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
694 {
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
695 return check_arg_type(&t_job, type, context);
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
696 }
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
697
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
698 /*
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
699 * Check "type" is a channel or a job.
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
700 */
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
701 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
702 arg_chan_or_job(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
703 {
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
704 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
705 || type->tt_type == VAR_UNKNOWN
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
706 || type->tt_type == VAR_CHANNEL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
707 || type->tt_type == VAR_JOB)
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
708 return OK;
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
709 arg_type_mismatch(&t_channel, type, context->arg_idx + 1);
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
710 return FAIL;
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
711 }
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
712
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
713 /*
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
714 * Check "type" can be used as the type_decl of the previous argument.
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
715 * Must not be used for the first argcheck_T entry.
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
716 */
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
717 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
718 arg_same_as_prev(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
719 {
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
720 type_T *prev_type = context->arg_types[context->arg_idx - 1].type_decl;
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
721
23640
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
722 return check_arg_type(prev_type, type, context);
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
723 }
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
724
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
725 /*
23588
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
726 * Check "type" is the same basic type as the previous argument, checks list or
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
727 * dict vs other type, but not member type.
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
728 * Must not be used for the first argcheck_T entry.
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
729 */
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
730 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
731 arg_same_struct_as_prev(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
732 {
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
733 type_T *prev_type = context->arg_types[context->arg_idx - 1].type_curr;
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
734
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
735 if (prev_type->tt_type != context->arg_types[context->arg_idx].type_curr->tt_type)
23640
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
736 return check_arg_type(prev_type, type, context);
23588
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
737 return OK;
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
738 }
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
739
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
740 /*
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
741 * Check "type" is an item of the list or blob of the previous arg.
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
742 * Must not be used for the first argcheck_T entry.
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
743 */
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
744 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
745 arg_item_of_prev(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
746 {
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
747 type_T *prev_type = context->arg_types[context->arg_idx - 1].type_curr;
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
748 type_T *expected;
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
749
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
750 if (prev_type->tt_type == VAR_LIST)
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
751 expected = prev_type->tt_member;
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
752 else if (prev_type->tt_type == VAR_BLOB)
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
753 expected = &t_number;
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
754 else
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
755 // probably VAR_ANY, can't check
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
756 return OK;
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
757
23640
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
758 return check_arg_type(expected, type, context);
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
759 }
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
760
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
761 /*
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
762 * Check "type" is a string or a number or a list
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
763 */
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
764 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
765 arg_str_or_nr_or_list(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
766 {
25236
2c83f7b316d3 patch 8.2.3154: Vim9: some type checks for builtin functions fail
Bram Moolenaar <Bram@vim.org>
parents: 25228
diff changeset
767 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
768 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
769 || type->tt_type == VAR_STRING
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
770 || type->tt_type == VAR_NUMBER
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
771 || type->tt_type == VAR_LIST)
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
772 return OK;
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
773 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
774 return FAIL;
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
775 }
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
776
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
777 /*
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
778 * Check "type" is a dict of 'any' or a string
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
779 */
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
780 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
781 arg_dict_any_or_string(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
782 {
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
783 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
784 || type->tt_type == VAR_UNKNOWN
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
785 || type->tt_type == VAR_DICT
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
786 || type->tt_type == VAR_STRING)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
787 return OK;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
788 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
789 return FAIL;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
790 }
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
791
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
792 /*
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
793 * Check "type" which is the third argument of extend() (number or string or
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
794 * any)
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
795 */
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
796 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
797 arg_extend3(type_T *type, type_T *decl_type, argcontext_T *context)
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
798 {
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
799 type_T *first_type = context->arg_types[context->arg_idx - 2].type_curr;
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
800
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
801 if (first_type->tt_type == VAR_LIST)
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
802 return arg_number(type, decl_type, context);
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
803 if (first_type->tt_type == VAR_DICT)
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
804 return arg_string(type, decl_type, context);
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
805 return OK;
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
806 }
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
807
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
808 /*
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
809 * Check "type" which is the first argument of get() (blob or list or dict or
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
810 * funcref)
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
811 */
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
812 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
813 arg_get1(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
814 {
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
815 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
816 || type->tt_type == VAR_UNKNOWN
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
817 || type->tt_type == VAR_BLOB
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
818 || type->tt_type == VAR_LIST
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
819 || type->tt_type == VAR_DICT
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
820 || type->tt_type == VAR_FUNC
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
821 || type->tt_type == VAR_PARTIAL)
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
822 return OK;
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
823
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
824 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
825 return FAIL;
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
826 }
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
827
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
828 /*
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
829 * Check "type" which is the first argument of len() (number or string or
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
830 * blob or list or dict)
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
831 */
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
832 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
833 arg_len1(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
834 {
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
835 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
836 || type->tt_type == VAR_UNKNOWN
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
837 || type->tt_type == VAR_STRING
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
838 || type->tt_type == VAR_NUMBER
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
839 || type->tt_type == VAR_BLOB
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
840 || type->tt_type == VAR_LIST
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
841 || type->tt_type == VAR_DICT)
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
842 return OK;
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
843
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
844 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
845 return FAIL;
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
846 }
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
847
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
848 /*
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
849 * Check "type" which is the second argument of remove() (number or string or
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
850 * any)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
851 */
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
852 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
853 arg_remove2(type_T *type, type_T *decl_type, argcontext_T *context)
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
854 {
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
855 type_T *first_type = context->arg_types[context->arg_idx - 1].type_curr;
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
856
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
857 if (first_type->tt_type == VAR_LIST || first_type->tt_type == VAR_BLOB)
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
858 return arg_number(type, decl_type, context);
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
859 if (first_type->tt_type == VAR_DICT)
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
860 return arg_string_or_nr(type, decl_type, context);
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
861 return OK;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
862 }
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
863
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
864 /*
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
865 * Check "type" which is the first argument of repeat() (string or number or
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
866 * list or any)
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
867 */
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
868 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
869 arg_repeat1(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
870 {
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
871 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
872 || type->tt_type == VAR_UNKNOWN
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
873 || type->tt_type == VAR_STRING
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
874 || type->tt_type == VAR_NUMBER
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
875 || type->tt_type == VAR_LIST)
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
876 return OK;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
877
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
878 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
879 return FAIL;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
880 }
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
881
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
882 /*
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
883 * Check "type" which is the first argument of slice() (list or blob or string
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
884 * or any)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
885 */
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
886 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
887 arg_slice1(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
888 {
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
889 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
890 || type->tt_type == VAR_UNKNOWN
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
891 || type->tt_type == VAR_LIST
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
892 || type->tt_type == VAR_BLOB
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
893 || type->tt_type == VAR_STRING)
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
894 return OK;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
895
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
896 arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
897 return FAIL;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
898 }
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
899
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
900 /*
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
901 * Check "type" which is the first argument of count() (string or list or dict
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
902 * or any)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
903 */
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
904 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
905 arg_count1(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
906 {
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
907 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
908 || type->tt_type == VAR_UNKNOWN
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
909 || type->tt_type == VAR_STRING
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
910 || type->tt_type == VAR_LIST
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
911 || type->tt_type == VAR_DICT)
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
912 return OK;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
913
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
914 arg_type_mismatch(&t_string, type, context->arg_idx + 1);
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
915 return FAIL;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
916 }
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
917
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
918 /*
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
919 * Check "type" which is the first argument of cursor() (number or string or
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
920 * list or any)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
921 */
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
922 static int
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
923 arg_cursor1(type_T *type, type_T *decl_type UNUSED, argcontext_T *context)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
924 {
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
925 if (type->tt_type == VAR_ANY
26674
38a270fdd3f6 patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 26656
diff changeset
926 || type->tt_type == VAR_UNKNOWN
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
927 || type->tt_type == VAR_NUMBER
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
928 || type->tt_type == VAR_STRING
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
929 || type->tt_type == VAR_LIST)
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
930 return OK;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
931
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
932 arg_type_mismatch(&t_number, type, context->arg_idx + 1);
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
933 return FAIL;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
934 }
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
935
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
936 /*
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
937 * Lists of functions that check the argument types of a builtin function.
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
938 */
25806
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
939 static argcheck_T arg1_blob[] = {arg_blob};
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
940 static argcheck_T arg1_bool[] = {arg_bool};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
941 static argcheck_T arg1_buffer[] = {arg_buffer};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
942 static argcheck_T arg1_buffer_or_dict_any[] = {arg_buffer_or_dict_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
943 static argcheck_T arg1_chan_or_job[] = {arg_chan_or_job};
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
944 static argcheck_T arg1_dict_any[] = {arg_dict_any};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
945 static argcheck_T arg1_dict_or_string[] = {arg_dict_any_or_string};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
946 static argcheck_T arg1_float_or_nr[] = {arg_float_or_nr};
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
947 static argcheck_T arg1_job[] = {arg_job};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
948 static argcheck_T arg1_list_any[] = {arg_list_any};
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
949 static argcheck_T arg1_list_number[] = {arg_list_number};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
950 static argcheck_T arg1_list_or_blob[] = {arg_list_or_blob};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
951 static argcheck_T arg1_list_or_dict[] = {arg_list_or_dict};
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
952 static argcheck_T arg1_list_string[] = {arg_list_string};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
953 static argcheck_T arg1_lnum[] = {arg_lnum};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
954 static argcheck_T arg1_number[] = {arg_number};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
955 static argcheck_T arg1_string[] = {arg_string};
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
956 static argcheck_T arg1_string_or_list_any[] = {arg_string_or_list_any};
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
957 static argcheck_T arg1_string_or_list_string[] = {arg_string_or_list_string};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
958 static argcheck_T arg1_string_or_nr[] = {arg_string_or_nr};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
959 static argcheck_T arg2_any_buffer[] = {NULL, arg_buffer};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
960 static argcheck_T arg2_buffer_any[] = {arg_buffer, NULL};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
961 static argcheck_T arg2_buffer_bool[] = {arg_buffer, arg_bool};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
962 static argcheck_T arg2_buffer_list_any[] = {arg_buffer, arg_list_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
963 static argcheck_T arg2_buffer_lnum[] = {arg_buffer, arg_lnum};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
964 static argcheck_T arg2_buffer_number[] = {arg_buffer, arg_number};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
965 static argcheck_T arg2_buffer_string[] = {arg_buffer, arg_string};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
966 static argcheck_T arg2_chan_or_job_dict[] = {arg_chan_or_job, arg_dict_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
967 static argcheck_T arg2_chan_or_job_string[] = {arg_chan_or_job, arg_string};
25640
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25601
diff changeset
968 static argcheck_T arg2_dict_any_list_any[] = {arg_dict_any, arg_list_any};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
969 static argcheck_T arg2_dict_any_string_or_nr[] = {arg_dict_any, arg_string_or_nr};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
970 static argcheck_T arg2_dict_string[] = {arg_dict_any, arg_string};
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
971 static argcheck_T arg2_float_or_nr[] = {arg_float_or_nr, arg_float_or_nr};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
972 static argcheck_T arg2_job_dict[] = {arg_job, arg_dict_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
973 static argcheck_T arg2_job_string_or_number[] = {arg_job, arg_string_or_nr};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
974 static argcheck_T arg2_list_any_number[] = {arg_list_any, arg_number};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
975 static argcheck_T arg2_list_any_string[] = {arg_list_any, arg_string};
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
976 static argcheck_T arg2_list_number[] = {arg_list_number, arg_list_number};
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
977 static argcheck_T arg2_list_number_bool[] = {arg_list_number, arg_bool};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
978 static argcheck_T arg2_listblob_item[] = {arg_list_or_blob, arg_item_of_prev};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
979 static argcheck_T arg2_lnum[] = {arg_lnum, arg_lnum};
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
980 static argcheck_T arg2_lnum_number[] = {arg_lnum, arg_number};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
981 static argcheck_T arg2_number[] = {arg_number, arg_number};
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
982 static argcheck_T arg2_number_any[] = {arg_number, NULL};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
983 static argcheck_T arg2_number_bool[] = {arg_number, arg_bool};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
984 static argcheck_T arg2_number_dict_any[] = {arg_number, arg_dict_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
985 static argcheck_T arg2_number_list[] = {arg_number, arg_list_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
986 static argcheck_T arg2_number_string[] = {arg_number, arg_string};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
987 static argcheck_T arg2_number_string_or_list[] = {arg_number, arg_string_or_list_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
988 static argcheck_T arg2_str_or_nr_or_list_dict[] = {arg_str_or_nr_or_list, arg_dict_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
989 static argcheck_T arg2_string[] = {arg_string, arg_string};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
990 static argcheck_T arg2_string_any[] = {arg_string, NULL};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
991 static argcheck_T arg2_string_bool[] = {arg_string, arg_bool};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
992 static argcheck_T arg2_string_chan_or_job[] = {arg_string, arg_chan_or_job};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
993 static argcheck_T arg2_string_dict[] = {arg_string, arg_dict_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
994 static argcheck_T arg2_string_list_number[] = {arg_string, arg_list_number};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
995 static argcheck_T arg2_string_number[] = {arg_string, arg_number};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
996 static argcheck_T arg2_string_or_list_dict[] = {arg_string_or_list_any, arg_dict_any};
28994
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
997 static argcheck_T arg2_string_or_list_bool[] = {arg_string_or_list_any, arg_bool};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
998 static argcheck_T arg2_string_string_or_number[] = {arg_string, arg_string_or_nr};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
999 static argcheck_T arg3_any_list_dict[] = {NULL, arg_list_any, arg_dict_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1000 static argcheck_T arg3_buffer_lnum_lnum[] = {arg_buffer, arg_lnum, arg_lnum};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1001 static argcheck_T arg3_buffer_number_number[] = {arg_buffer, arg_number, arg_number};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1002 static argcheck_T arg3_buffer_string_any[] = {arg_buffer, arg_string, NULL};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1003 static argcheck_T arg3_buffer_string_dict[] = {arg_buffer, arg_string, arg_dict_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1004 static argcheck_T arg3_dict_number_number[] = {arg_dict_any, arg_number, arg_number};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1005 static argcheck_T arg3_list_string_dict[] = {arg_list_any, arg_string, arg_dict_any};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1006 static argcheck_T arg3_lnum_number_bool[] = {arg_lnum, arg_number, arg_bool};
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1007 static argcheck_T arg3_number[] = {arg_number, arg_number, arg_number};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1008 static argcheck_T arg3_number_any_dict[] = {arg_number, NULL, arg_dict_any};
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1009 static argcheck_T arg3_number_number_dict[] = {arg_number, arg_number, arg_dict_any};
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1010 static argcheck_T arg3_number_string_any[] = {arg_number, arg_string, NULL};
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1011 static argcheck_T arg3_number_string_buffer[] = {arg_number, arg_string, arg_buffer};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1012 static argcheck_T arg3_number_string_string[] = {arg_number, arg_string, arg_string};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1013 static argcheck_T arg3_string[] = {arg_string, arg_string, arg_string};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1014 static argcheck_T arg3_string_any_dict[] = {arg_string, NULL, arg_dict_any};
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
1015 static argcheck_T arg3_string_any_string[] = {arg_string, NULL, arg_string};
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1016 static argcheck_T arg3_string_bool_bool[] = {arg_string, arg_bool, arg_bool};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1017 static argcheck_T arg3_string_number_bool[] = {arg_string, arg_number, arg_bool};
28674
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
1018 static argcheck_T arg3_string_or_dict_bool_dict[] = {arg_string_or_dict_any, arg_bool, arg_dict_any};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1019 static argcheck_T arg3_string_string_bool[] = {arg_string, arg_string, arg_bool};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1020 static argcheck_T arg3_string_string_dict[] = {arg_string, arg_string, arg_dict_any};
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
1021 static argcheck_T arg3_string_string_number[] = {arg_string, arg_string, arg_number};
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1022 static argcheck_T arg4_number_number_string_any[] = {arg_number, arg_number, arg_string, NULL};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1023 static argcheck_T arg4_string_string_any_string[] = {arg_string, arg_string, NULL, arg_string};
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1024 static argcheck_T arg4_string_string_number_string[] = {arg_string, arg_string, arg_number, arg_string};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1025 /* Function specific argument types (not covered by the above) */
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
1026 static argcheck_T arg15_assert_fails[] = {arg_string_or_nr, arg_string_or_list_any, NULL, arg_number, arg_string};
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
1027 static argcheck_T arg34_assert_inrange[] = {arg_float_or_nr, arg_float_or_nr, arg_float_or_nr, arg_string};
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1028 static argcheck_T arg4_browse[] = {arg_bool, arg_string, arg_string, arg_string};
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1029 static argcheck_T arg23_chanexpr[] = {arg_chan_or_job, NULL, arg_dict_any};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1030 static argcheck_T arg23_chanraw[] = {arg_chan_or_job, arg_string_or_blob, arg_dict_any};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1031 static argcheck_T arg24_count[] = {arg_count1, NULL, arg_bool, arg_number};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1032 static argcheck_T arg13_cursor[] = {arg_cursor1, arg_number, arg_number};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1033 static argcheck_T arg12_deepcopy[] = {NULL, arg_bool};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1034 static argcheck_T arg12_execute[] = {arg_string_or_list_string, arg_string};
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1035 static argcheck_T arg23_extend[] = {arg_list_or_dict, arg_same_as_prev, arg_extend3};
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1036 static argcheck_T arg23_extendnew[] = {arg_list_or_dict, arg_same_struct_as_prev, arg_extend3};
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
1037 static argcheck_T arg23_get[] = {arg_get1, arg_string_or_nr, NULL};
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1038 static argcheck_T arg14_glob[] = {arg_string, arg_bool, arg_bool, arg_bool};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1039 static argcheck_T arg25_globpath[] = {arg_string, arg_string, arg_bool, arg_bool, arg_bool};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1040 static argcheck_T arg24_index[] = {arg_list_or_blob, arg_item_of_prev, arg_number, arg_bool};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1041 static argcheck_T arg23_insert[] = {arg_list_or_blob, arg_item_of_prev, arg_number};
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
1042 static argcheck_T arg1_len[] = {arg_len1};
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1043 static argcheck_T arg3_libcall[] = {arg_string, arg_string, arg_string_or_nr};
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1044 static argcheck_T arg14_maparg[] = {arg_string, arg_string, arg_bool, arg_bool};
26737
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
1045 static argcheck_T arg2_filter[] = {arg_list_or_dict_or_blob_or_string, arg_filter_func};
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
1046 static argcheck_T arg2_map[] = {arg_list_or_dict_or_blob_or_string, arg_map_func};
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
1047 static argcheck_T arg2_mapnew[] = {arg_list_or_dict_or_blob_or_string, NULL};
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1048 static argcheck_T arg25_matchadd[] = {arg_string, arg_string, arg_number, arg_number, arg_dict_any};
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1049 static argcheck_T arg25_matchaddpos[] = {arg_string, arg_list_any, arg_number, arg_number, arg_dict_any};
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
1050 static argcheck_T arg119_printf[] = {arg_string_or_nr, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
26638
6fd15d82e898 patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1051 static argcheck_T arg23_reduce[] = {arg_string_list_or_blob, NULL, NULL};
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1052 static argcheck_T arg24_remote_expr[] = {arg_string, arg_string, arg_string, arg_number};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1053 static argcheck_T arg23_remove[] = {arg_list_or_dict_or_blob, arg_remove2, arg_number};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1054 static argcheck_T arg2_repeat[] = {arg_repeat1, arg_number};
26751
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
1055 static argcheck_T arg15_search[] = {arg_string, arg_string, arg_number, arg_number, arg_string_or_func};
4ea53126f78f patch 8.2.3904: Vim9: skip expression type is not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 26741
diff changeset
1056 static argcheck_T arg37_searchpair[] = {arg_string, arg_string, arg_string, arg_string, arg_string_or_func, arg_number, arg_number};
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1057 static argcheck_T arg3_setbufline[] = {arg_buffer, arg_lnum, arg_str_or_nr_or_list};
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1058 static argcheck_T arg2_setline[] = {arg_lnum, NULL};
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1059 static argcheck_T arg24_setloclist[] = {arg_number, arg_list_any, arg_string, arg_dict_any};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1060 static argcheck_T arg13_setqflist[] = {arg_list_any, arg_string, arg_dict_any};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1061 static argcheck_T arg23_settagstack[] = {arg_number, arg_dict_any, arg_string};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1062 static argcheck_T arg02_sign_getplaced[] = {arg_buffer, arg_dict_any};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1063 static argcheck_T arg45_sign_place[] = {arg_number, arg_string, arg_string, arg_buffer, arg_dict_any};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1064 static argcheck_T arg23_slice[] = {arg_slice1, arg_number, arg_number};
27847
780818e65dff patch 8.2.4449: vim9: function argument of sort() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 27831
diff changeset
1065 static argcheck_T arg13_sortuniq[] = {arg_list_any, arg_sort_how, arg_dict_any};
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1066 static argcheck_T arg24_strpart[] = {arg_string, arg_number, arg_number, arg_bool};
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1067 static argcheck_T arg12_system[] = {arg_string, arg_str_or_nr_or_list};
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
1068 static argcheck_T arg23_win_execute[] = {arg_number, arg_string_or_list_string, arg_string};
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1069 static argcheck_T arg23_writefile[] = {arg_list_or_blob, arg_string, arg_string};
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
1070 static argcheck_T arg24_match_func[] = {arg_string_or_list_any, arg_string, arg_number, arg_number};
25332
34fe6aca48c2 patch 8.2.3203: Vim9: compiled string expression causes type error
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
1071
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1072
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1073 /*
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1074 * Functions that return the return type of a builtin function.
22671
ad54acb1bf2c patch 8.2.1884: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 22661
diff changeset
1075 * Note that "argtypes" is NULL if "argcount" is zero.
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1076 */
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1077 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1078 ret_void(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1079 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1080 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1081 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1082 return &t_void;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1083 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1084 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1085 ret_any(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1086 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1087 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1088 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1089 return &t_any;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1090 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1091 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1092 ret_bool(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1093 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1094 type_T **decl_type UNUSED)
22620
b5d68d8a5187 patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents: 22446
diff changeset
1095 {
b5d68d8a5187 patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents: 22446
diff changeset
1096 return &t_bool;
b5d68d8a5187 patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents: 22446
diff changeset
1097 }
b5d68d8a5187 patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents: 22446
diff changeset
1098 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1099 ret_number_bool(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1100 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1101 type_T **decl_type UNUSED)
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1102 {
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1103 return &t_number_bool;
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1104 }
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1105 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1106 ret_number(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1107 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1108 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1109 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1110 return &t_number;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1111 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1112 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1113 ret_float(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1114 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1115 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1116 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1117 return &t_float;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1118 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1119 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1120 ret_string(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1121 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1122 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1123 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1124 return &t_string;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1125 }
19874
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19814
diff changeset
1126 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1127 ret_list_any(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1128 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1129 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1130 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1131 return &t_list_any;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1132 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1133 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1134 ret_list_number(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1135 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1136 type_T **decl_type)
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1137 {
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1138 *decl_type = &t_list_any;
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1139 return &t_list_number;
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1140 }
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1141 static type_T *
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1142 ret_list_string(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1143 type2_T *argtypes UNUSED,
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1144 type_T **decl_type)
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1145 {
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1146 *decl_type = &t_list_any;
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1147 return &t_list_string;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1148 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1149 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1150 ret_list_dict_any(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1151 type2_T *argtypes UNUSED,
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1152 type_T **decl_type)
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1153 {
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1154 *decl_type = &t_list_any;
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1155 return &t_list_dict_any;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1156 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1157 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1158 ret_list_items(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1159 type2_T *argtypes UNUSED,
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1160 type_T **decl_type)
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1161 {
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1162 *decl_type = &t_list_any;
25162
c44d6ac81c42 patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents: 25126
diff changeset
1163 return &t_list_list_any;
c44d6ac81c42 patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents: 25126
diff changeset
1164 }
25294
c626fd34b66f patch 8.2.3184: cannot add a digraph with a leading space
Bram Moolenaar <Bram@vim.org>
parents: 25272
diff changeset
1165
c626fd34b66f patch 8.2.3184: cannot add a digraph with a leading space
Bram Moolenaar <Bram@vim.org>
parents: 25272
diff changeset
1166 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1167 ret_list_string_items(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1168 type2_T *argtypes UNUSED,
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1169 type_T **decl_type)
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1170 {
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1171 *decl_type = &t_list_any;
25294
c626fd34b66f patch 8.2.3184: cannot add a digraph with a leading space
Bram Moolenaar <Bram@vim.org>
parents: 25272
diff changeset
1172 return &t_list_list_string;
c626fd34b66f patch 8.2.3184: cannot add a digraph with a leading space
Bram Moolenaar <Bram@vim.org>
parents: 25272
diff changeset
1173 }
25162
c44d6ac81c42 patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents: 25126
diff changeset
1174 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1175 ret_dict_any(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1176 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1177 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1178 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1179 return &t_dict_any;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1180 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1181 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1182 ret_job_info(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1183 type2_T *argtypes UNUSED,
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1184 type_T **decl_type)
23592
2322b643e329 patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents: 23588
diff changeset
1185 {
2322b643e329 patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents: 23588
diff changeset
1186 if (argcount == 0)
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1187 {
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1188 *decl_type = &t_list_any;
23592
2322b643e329 patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents: 23588
diff changeset
1189 return &t_list_job;
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1190 }
23592
2322b643e329 patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents: 23588
diff changeset
1191 return &t_dict_any;
2322b643e329 patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents: 23588
diff changeset
1192 }
2322b643e329 patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents: 23588
diff changeset
1193 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1194 ret_dict_number(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1195 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1196 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1197 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1198 return &t_dict_number;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1199 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1200 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1201 ret_dict_string(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1202 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1203 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1204 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1205 return &t_dict_string;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1206 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1207 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1208 ret_blob(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1209 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1210 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1211 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1212 return &t_blob;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1213 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1214 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1215 ret_func_any(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1216 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1217 type_T **decl_type UNUSED)
19874
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19814
diff changeset
1218 {
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19814
diff changeset
1219 return &t_func_any;
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19814
diff changeset
1220 }
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19814
diff changeset
1221 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1222 ret_func_unknown(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1223 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1224 type_T **decl_type UNUSED)
26656
ab46f0976435 patch 8.2.3857: Vim9: inconsistent error for using function()
Bram Moolenaar <Bram@vim.org>
parents: 26638
diff changeset
1225 {
ab46f0976435 patch 8.2.3857: Vim9: inconsistent error for using function()
Bram Moolenaar <Bram@vim.org>
parents: 26638
diff changeset
1226 return &t_func_unknown;
ab46f0976435 patch 8.2.3857: Vim9: inconsistent error for using function()
Bram Moolenaar <Bram@vim.org>
parents: 26638
diff changeset
1227 }
ab46f0976435 patch 8.2.3857: Vim9: inconsistent error for using function()
Bram Moolenaar <Bram@vim.org>
parents: 26638
diff changeset
1228 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1229 ret_channel(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1230 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1231 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1232 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1233 return &t_channel;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1234 }
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1235 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1236 ret_job(int argcount UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1237 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1238 type_T **decl_type UNUSED)
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1239 {
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1240 return &t_job;
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1241 }
20903
54ffae914876 patch 8.2.1003: Vim9: return type of sort() is too generic
Bram Moolenaar <Bram@vim.org>
parents: 20873
diff changeset
1242 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1243 ret_first_arg(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1244 type2_T *argtypes,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1245 type_T **decl_type)
20903
54ffae914876 patch 8.2.1003: Vim9: return type of sort() is too generic
Bram Moolenaar <Bram@vim.org>
parents: 20873
diff changeset
1246 {
54ffae914876 patch 8.2.1003: Vim9: return type of sort() is too generic
Bram Moolenaar <Bram@vim.org>
parents: 20873
diff changeset
1247 if (argcount > 0)
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1248 {
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1249 *decl_type = argtypes[0].type_decl;
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1250 return argtypes[0].type_curr;
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1251 }
20903
54ffae914876 patch 8.2.1003: Vim9: return type of sort() is too generic
Bram Moolenaar <Bram@vim.org>
parents: 20873
diff changeset
1252 return &t_void;
54ffae914876 patch 8.2.1003: Vim9: return type of sort() is too generic
Bram Moolenaar <Bram@vim.org>
parents: 20873
diff changeset
1253 }
25449
5dce28f92d04 patch 8.2.3261: Vim9: when compiling repeat(123, N) return type is number
Bram Moolenaar <Bram@vim.org>
parents: 25431
diff changeset
1254 static type_T *
27555
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1255 ret_slice(int argcount,
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1256 type2_T *argtypes,
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1257 type_T **decl_type)
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1258 {
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1259 if (argcount > 0)
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1260 {
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1261 if (argtypes[0].type_decl != NULL)
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1262 {
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1263 switch (argtypes[0].type_decl->tt_type)
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1264 {
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1265 case VAR_STRING: *decl_type = &t_string; break;
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1266 case VAR_BLOB: *decl_type = &t_blob; break;
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1267 case VAR_LIST: *decl_type = &t_list_any; break;
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1268 default: break;
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1269 }
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1270 }
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1271 return argtypes[0].type_curr;
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1272 }
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1273 return &t_void;
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1274 }
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
1275 static type_T *
27517
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1276 ret_copy(int argcount,
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1277 type2_T *argtypes,
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1278 type_T **decl_type)
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1279 {
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1280 if (argcount > 0)
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1281 {
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1282 if (argtypes[0].type_decl != NULL)
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1283 {
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1284 if (argtypes[0].type_decl->tt_type == VAR_LIST)
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1285 *decl_type = &t_list_any;
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1286 else if (argtypes[0].type_decl->tt_type == VAR_DICT)
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1287 *decl_type = &t_dict_any;
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1288 else
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1289 *decl_type = argtypes[0].type_decl;
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1290 }
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1291 if (argtypes[0].type_curr != NULL)
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1292 {
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1293 if (argtypes[0].type_curr->tt_type == VAR_LIST)
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1294 return &t_list_any;
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1295 else if (argtypes[0].type_curr->tt_type == VAR_DICT)
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1296 return &t_dict_any;
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1297 }
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1298 return argtypes[0].type_curr;
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1299 }
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1300 return &t_void;
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1301 }
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1302 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1303 ret_extend(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1304 type2_T *argtypes,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1305 type_T **decl_type)
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1306 {
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1307 if (argcount > 0)
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1308 {
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1309 *decl_type = argtypes[0].type_decl;
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1310 // if the second argument has a different current type then the current
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1311 // type is "any"
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1312 if (argcount > 1 && !equal_type(argtypes[0].type_curr,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1313 argtypes[1].type_curr, 0))
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1314 {
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1315 if (argtypes[0].type_curr->tt_type == VAR_LIST)
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1316 return &t_list_any;
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1317 if (argtypes[0].type_curr->tt_type == VAR_DICT)
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1318 return &t_dict_any;
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1319 }
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1320 return argtypes[0].type_curr;
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1321 }
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1322 return &t_void;
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1323 }
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1324 static type_T *
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1325 ret_repeat(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1326 type2_T *argtypes,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1327 type_T **decl_type UNUSED)
25465
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1328 {
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1329 if (argcount == 0)
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1330 return &t_any;
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1331 if (argtypes[0].type_curr == &t_number)
25449
5dce28f92d04 patch 8.2.3261: Vim9: when compiling repeat(123, N) return type is number
Bram Moolenaar <Bram@vim.org>
parents: 25431
diff changeset
1332 return &t_string;
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1333 return argtypes[0].type_curr;
25449
5dce28f92d04 patch 8.2.3261: Vim9: when compiling repeat(123, N) return type is number
Bram Moolenaar <Bram@vim.org>
parents: 25431
diff changeset
1334 }
22844
36fc73078bce patch 8.2.1969: Vim9: map() may change the list or dict item type
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1335 // for map(): returns first argument but item type may differ
36fc73078bce patch 8.2.1969: Vim9: map() may change the list or dict item type
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1336 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1337 ret_first_cont(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1338 type2_T *argtypes,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1339 type_T **decl_type UNUSED)
25465
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1340 {
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1341 if (argcount > 0)
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1342 {
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1343 if (argtypes[0].type_curr->tt_type == VAR_LIST)
25465
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1344 return &t_list_any;
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1345 if (argtypes[0].type_curr->tt_type == VAR_DICT)
25465
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1346 return &t_dict_any;
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1347 if (argtypes[0].type_curr->tt_type == VAR_BLOB)
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1348 return argtypes[0].type_curr;
25465
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1349 }
22844
36fc73078bce patch 8.2.1969: Vim9: map() may change the list or dict item type
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1350 return &t_any;
36fc73078bce patch 8.2.1969: Vim9: map() may change the list or dict item type
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1351 }
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1352 // for getline()
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1353 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1354 ret_getline(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1355 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1356 type_T **decl_type UNUSED)
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1357 {
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1358 if (argcount == 1)
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1359 return &t_string;
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1360 *decl_type = &t_list_any;
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1361 return &t_list_string;
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1362 }
26686
c04b28fad0cc patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents: 26674
diff changeset
1363 // for finddir()
c04b28fad0cc patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents: 26674
diff changeset
1364 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1365 ret_finddir(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1366 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1367 type_T **decl_type UNUSED)
26686
c04b28fad0cc patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents: 26674
diff changeset
1368 {
c04b28fad0cc patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents: 26674
diff changeset
1369 if (argcount < 3)
c04b28fad0cc patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents: 26674
diff changeset
1370 return &t_string;
c04b28fad0cc patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents: 26674
diff changeset
1371 // Depending on the count would be a string or a list of strings.
c04b28fad0cc patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents: 26674
diff changeset
1372 return &t_any;
c04b28fad0cc patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents: 26674
diff changeset
1373 }
20903
54ffae914876 patch 8.2.1003: Vim9: return type of sort() is too generic
Bram Moolenaar <Bram@vim.org>
parents: 20873
diff changeset
1374
21089
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1375 /*
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1376 * Used for getqflist(): returns list if there is no argument, dict if there is
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1377 * one.
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1378 */
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1379 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1380 ret_list_or_dict_0(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1381 type2_T *argtypes UNUSED,
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1382 type_T **decl_type)
21089
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1383 {
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1384 if (argcount > 0)
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1385 return &t_dict_any;
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1386 *decl_type = &t_list_any;
21089
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1387 return &t_list_dict_any;
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1388 }
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1389
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1390 /*
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1391 * Used for getloclist(): returns list if there is one argument, dict if there
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1392 * are two.
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1393 */
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1394 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1395 ret_list_or_dict_1(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1396 type2_T *argtypes UNUSED,
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1397 type_T **decl_type)
21089
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1398 {
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1399 if (argcount > 1)
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1400 return &t_dict_any;
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1401 *decl_type = &t_list_any;
21089
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1402 return &t_list_dict_any;
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1403 }
d69ead03ba93 patch 8.2.1096: Vim9: return type of getqflist() is wrong
Bram Moolenaar <Bram@vim.org>
parents: 21062
diff changeset
1404
21170
8c494353c6bc patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents: 21164
diff changeset
1405 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1406 ret_argv(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1407 type2_T *argtypes UNUSED,
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1408 type_T **decl_type)
21170
8c494353c6bc patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents: 21164
diff changeset
1409 {
8c494353c6bc patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents: 21164
diff changeset
1410 // argv() returns list of strings
8c494353c6bc patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents: 21164
diff changeset
1411 if (argcount == 0)
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1412 {
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1413 *decl_type = &t_list_any;
21170
8c494353c6bc patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents: 21164
diff changeset
1414 return &t_list_string;
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1415 }
21170
8c494353c6bc patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents: 21164
diff changeset
1416
8c494353c6bc patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents: 21164
diff changeset
1417 // argv(0) returns a string, but argv(-1] returns a list
8c494353c6bc patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents: 21164
diff changeset
1418 return &t_any;
8c494353c6bc patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents: 21164
diff changeset
1419 }
8c494353c6bc patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents: 21164
diff changeset
1420
21184
2113e94dc726 patch 8.2.1143: Vim9: return type of remove() is any
Bram Moolenaar <Bram@vim.org>
parents: 21182
diff changeset
1421 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1422 ret_remove(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1423 type2_T *argtypes,
28806
3754393e05bc patch 8.2.4927: return type of remove() incorrect when using three arguments
Bram Moolenaar <Bram@vim.org>
parents: 28775
diff changeset
1424 type_T **decl_type)
25465
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1425 {
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
1426 if (argcount > 0)
22284
6b385c2b9ff5 patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents: 22232
diff changeset
1427 {
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1428 if (argtypes[0].type_curr->tt_type == VAR_LIST
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1429 || argtypes[0].type_curr->tt_type == VAR_DICT)
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1430 {
28806
3754393e05bc patch 8.2.4927: return type of remove() incorrect when using three arguments
Bram Moolenaar <Bram@vim.org>
parents: 28775
diff changeset
1431 if (argcount == 3)
3754393e05bc patch 8.2.4927: return type of remove() incorrect when using three arguments
Bram Moolenaar <Bram@vim.org>
parents: 28775
diff changeset
1432 {
3754393e05bc patch 8.2.4927: return type of remove() incorrect when using three arguments
Bram Moolenaar <Bram@vim.org>
parents: 28775
diff changeset
1433 *decl_type = argtypes[0].type_decl;
3754393e05bc patch 8.2.4927: return type of remove() incorrect when using three arguments
Bram Moolenaar <Bram@vim.org>
parents: 28775
diff changeset
1434 return argtypes[0].type_curr;
3754393e05bc patch 8.2.4927: return type of remove() incorrect when using three arguments
Bram Moolenaar <Bram@vim.org>
parents: 28775
diff changeset
1435 }
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1436 if (argtypes[0].type_curr->tt_type
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1437 == argtypes[0].type_decl->tt_type)
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1438 *decl_type = argtypes[0].type_decl->tt_member;
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1439 return argtypes[0].type_curr->tt_member;
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1440 }
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1441 if (argtypes[0].type_curr->tt_type == VAR_BLOB)
22284
6b385c2b9ff5 patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents: 22232
diff changeset
1442 return &t_number;
6b385c2b9ff5 patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents: 22232
diff changeset
1443 }
21184
2113e94dc726 patch 8.2.1143: Vim9: return type of remove() is any
Bram Moolenaar <Bram@vim.org>
parents: 21182
diff changeset
1444 return &t_any;
2113e94dc726 patch 8.2.1143: Vim9: return type of remove() is any
Bram Moolenaar <Bram@vim.org>
parents: 21182
diff changeset
1445 }
2113e94dc726 patch 8.2.1143: Vim9: return type of remove() is any
Bram Moolenaar <Bram@vim.org>
parents: 21182
diff changeset
1446
21660
9a2ce62b93e9 patch 8.2.1380: Vim9: return type of getreg() is always a string
Bram Moolenaar <Bram@vim.org>
parents: 21461
diff changeset
1447 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1448 ret_getreg(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1449 type2_T *argtypes UNUSED,
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1450 type_T **decl_type)
21660
9a2ce62b93e9 patch 8.2.1380: Vim9: return type of getreg() is always a string
Bram Moolenaar <Bram@vim.org>
parents: 21461
diff changeset
1451 {
9a2ce62b93e9 patch 8.2.1380: Vim9: return type of getreg() is always a string
Bram Moolenaar <Bram@vim.org>
parents: 21461
diff changeset
1452 // Assume that if the third argument is passed it's non-zero
9a2ce62b93e9 patch 8.2.1380: Vim9: return type of getreg() is always a string
Bram Moolenaar <Bram@vim.org>
parents: 21461
diff changeset
1453 if (argcount == 3)
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1454 {
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1455 *decl_type = &t_list_any;
21660
9a2ce62b93e9 patch 8.2.1380: Vim9: return type of getreg() is always a string
Bram Moolenaar <Bram@vim.org>
parents: 21461
diff changeset
1456 return &t_list_string;
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1457 }
21660
9a2ce62b93e9 patch 8.2.1380: Vim9: return type of getreg() is always a string
Bram Moolenaar <Bram@vim.org>
parents: 21461
diff changeset
1458 return &t_string;
9a2ce62b93e9 patch 8.2.1380: Vim9: return type of getreg() is always a string
Bram Moolenaar <Bram@vim.org>
parents: 21461
diff changeset
1459 }
9a2ce62b93e9 patch 8.2.1380: Vim9: return type of getreg() is always a string
Bram Moolenaar <Bram@vim.org>
parents: 21461
diff changeset
1460
21695
f27187782dc6 patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents: 21660
diff changeset
1461 static type_T *
28994
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1462 ret_virtcol(int argcount,
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1463 type2_T *argtypes UNUSED,
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1464 type_T **decl_type)
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1465 {
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1466 // Assume that if the second argument is passed it's non-zero
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1467 if (argcount == 2)
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1468 {
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1469 *decl_type = &t_list_any;
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1470 return &t_list_number;
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1471 }
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1472 return &t_number;
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1473 }
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1474
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
1475 static type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1476 ret_maparg(int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1477 type2_T *argtypes UNUSED,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1478 type_T **decl_type UNUSED)
21695
f27187782dc6 patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents: 21660
diff changeset
1479 {
f27187782dc6 patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents: 21660
diff changeset
1480 // Assume that if the fourth argument is passed it's non-zero
f27187782dc6 patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents: 21660
diff changeset
1481 if (argcount == 4)
f27187782dc6 patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents: 21660
diff changeset
1482 return &t_dict_any;
f27187782dc6 patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents: 21660
diff changeset
1483 return &t_string;
f27187782dc6 patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents: 21660
diff changeset
1484 }
f27187782dc6 patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents: 21660
diff changeset
1485
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1486 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1487 * Array with names and number of arguments of all internal functions
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1488 * MUST BE KEPT SORTED IN strcmp() ORDER FOR BINARY SEARCH!
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1489 */
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
1490 typedef struct
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1491 {
17620
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1492 char *f_name; // function name
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1493 char f_min_argc; // minimal number of arguments
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1494 char f_max_argc; // maximal number of arguments
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1495 char f_argtype; // for method: FEARG_ values
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1496 argcheck_T *f_argcheck; // list of functions to check argument types
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1497 type_T *(*f_retfunc)(int argcount, type2_T *argtypes,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1498 type_T **decl_type);
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19554
diff changeset
1499 // return type function
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1500 void (*f_func)(typval_T *args, typval_T *rvar);
17620
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1501 // implementation of function
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
1502 } funcentry_T;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
1503
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1504 // values for f_argtype; zero means it cannot be used as a method
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1505 #define FEARG_1 1 // base is the first argument
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1506 #define FEARG_2 2 // base is the second argument
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
1507 #define FEARG_3 3 // base is the third argument
18000
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
1508 #define FEARG_4 4 // base is the fourth argument
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1509
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1510 #ifdef FEAT_FLOAT
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1511 # define FLOAT_FUNC(name) name
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1512 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1513 # define FLOAT_FUNC(name) NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1514 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1515 #if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1516 # define MATH_FUNC(name) name
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1517 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1518 # define MATH_FUNC(name) NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1519 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1520 #ifdef FEAT_TIMERS
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1521 # define TIMER_FUNC(name) name
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1522 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1523 # define TIMER_FUNC(name) NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1524 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1525 #ifdef FEAT_JOB_CHANNEL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1526 # define JOB_FUNC(name) name
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1527 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1528 # define JOB_FUNC(name) NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1529 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1530 #ifdef FEAT_PROP_POPUP
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1531 # define PROP_FUNC(name) name
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1532 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1533 # define PROP_FUNC(name) NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1534 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1535 #ifdef FEAT_SIGNS
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1536 # define SIGN_FUNC(name) name
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1537 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1538 # define SIGN_FUNC(name) NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1539 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1540 #ifdef FEAT_SOUND
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1541 # define SOUND_FUNC(name) name
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1542 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1543 # define SOUND_FUNC(name) NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1544 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1545 #ifdef FEAT_TERMINAL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1546 # define TERM_FUNC(name) name
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1547 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1548 # define TERM_FUNC(name) NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1549 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1550
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
1551 static funcentry_T global_functions[] =
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1552 {
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1553 {"abs", 1, 1, FEARG_1, arg1_float_or_nr,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1554 ret_any, FLOAT_FUNC(f_abs)},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1555 {"acos", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1556 ret_float, FLOAT_FUNC(f_acos)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1557 {"add", 2, 2, FEARG_1, arg2_listblob_item,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1558 ret_first_arg, f_add},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1559 {"and", 2, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1560 ret_number, f_and},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1561 {"append", 2, 2, FEARG_2, arg2_setline,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1562 ret_number_bool, f_append},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1563 {"appendbufline", 3, 3, FEARG_3, arg3_setbufline,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1564 ret_number_bool, f_appendbufline},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1565 {"argc", 0, 1, 0, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1566 ret_number, f_argc},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1567 {"argidx", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1568 ret_number, f_argidx},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1569 {"arglistid", 0, 2, 0, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1570 ret_number, f_arglistid},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1571 {"argv", 0, 2, 0, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1572 ret_argv, f_argv},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1573 {"asin", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1574 ret_float, FLOAT_FUNC(f_asin)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1575 {"assert_beeps", 1, 1, FEARG_1, arg1_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1576 ret_number_bool, f_assert_beeps},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1577 {"assert_equal", 2, 3, FEARG_2, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1578 ret_number_bool, f_assert_equal},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1579 {"assert_equalfile", 2, 3, FEARG_1, arg3_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1580 ret_number_bool, f_assert_equalfile},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1581 {"assert_exception", 1, 2, 0, arg2_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1582 ret_number_bool, f_assert_exception},
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
1583 {"assert_fails", 1, 5, FEARG_1, arg15_assert_fails,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1584 ret_number_bool, f_assert_fails},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1585 {"assert_false", 1, 2, FEARG_1, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1586 ret_number_bool, f_assert_false},
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
1587 {"assert_inrange", 3, 4, FEARG_3, arg34_assert_inrange,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1588 ret_number_bool, f_assert_inrange},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1589 {"assert_match", 2, 3, FEARG_2, arg3_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1590 ret_number_bool, f_assert_match},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1591 {"assert_nobeep", 1, 1, FEARG_1, arg1_string,
24307
55f458d35292 patch 8.2.2694: when 'matchpairs' is empty every character beeps
Bram Moolenaar <Bram@vim.org>
parents: 24250
diff changeset
1592 ret_number_bool, f_assert_nobeep},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1593 {"assert_notequal", 2, 3, FEARG_2, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1594 ret_number_bool, f_assert_notequal},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1595 {"assert_notmatch", 2, 3, FEARG_2, arg3_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1596 ret_number_bool, f_assert_notmatch},
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
1597 {"assert_report", 1, 1, FEARG_1, arg1_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1598 ret_number_bool, f_assert_report},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1599 {"assert_true", 1, 2, FEARG_1, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1600 ret_number_bool, f_assert_true},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1601 {"atan", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1602 ret_float, FLOAT_FUNC(f_atan)},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1603 {"atan2", 2, 2, FEARG_1, arg2_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1604 ret_float, FLOAT_FUNC(f_atan2)},
28917
c5862dfaf0bd patch 8.2.4981: it is not possible to manipulate autocommands
Bram Moolenaar <Bram@vim.org>
parents: 28871
diff changeset
1605 {"autocmd_add", 1, 1, FEARG_1, arg1_list_any,
c5862dfaf0bd patch 8.2.4981: it is not possible to manipulate autocommands
Bram Moolenaar <Bram@vim.org>
parents: 28871
diff changeset
1606 ret_number_bool, f_autocmd_add},
c5862dfaf0bd patch 8.2.4981: it is not possible to manipulate autocommands
Bram Moolenaar <Bram@vim.org>
parents: 28871
diff changeset
1607 {"autocmd_delete", 1, 1, FEARG_1, arg1_list_any,
c5862dfaf0bd patch 8.2.4981: it is not possible to manipulate autocommands
Bram Moolenaar <Bram@vim.org>
parents: 28871
diff changeset
1608 ret_number_bool, f_autocmd_delete},
c5862dfaf0bd patch 8.2.4981: it is not possible to manipulate autocommands
Bram Moolenaar <Bram@vim.org>
parents: 28871
diff changeset
1609 {"autocmd_get", 0, 1, FEARG_1, arg1_dict_any,
c5862dfaf0bd patch 8.2.4981: it is not possible to manipulate autocommands
Bram Moolenaar <Bram@vim.org>
parents: 28871
diff changeset
1610 ret_list_dict_any, f_autocmd_get},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1611 {"balloon_gettext", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1612 ret_string,
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1613 #ifdef FEAT_BEVAL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1614 f_balloon_gettext
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1615 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1616 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1617 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1618 },
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
1619 {"balloon_show", 1, 1, FEARG_1, arg1_string_or_list_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1620 ret_void,
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1621 #ifdef FEAT_BEVAL
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1622 f_balloon_show
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1623 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1624 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1625 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1626 },
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1627 {"balloon_split", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1628 ret_list_string,
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1629 #if defined(FEAT_BEVAL_TERM)
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1630 f_balloon_split
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1631 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1632 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1633 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1634 },
25806
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
1635 {"blob2list", 1, 1, FEARG_1, arg1_blob,
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
1636 ret_list_number, f_blob2list},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1637 {"browse", 4, 4, 0, arg4_browse,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1638 ret_string, f_browse},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1639 {"browsedir", 2, 2, 0, arg2_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1640 ret_string, f_browsedir},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1641 {"bufadd", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1642 ret_number, f_bufadd},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1643 {"bufexists", 1, 1, FEARG_1, arg1_buffer,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1644 ret_number_bool, f_bufexists},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1645 {"buffer_exists", 1, 1, FEARG_1, arg1_buffer, // obsolete
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1646 ret_number_bool, f_bufexists},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1647 {"buffer_name", 0, 1, FEARG_1, arg1_buffer, // obsolete
22657
3ccd2fa6b713 patch 8.2.1877: test for function list fails
Bram Moolenaar <Bram@vim.org>
parents: 22655
diff changeset
1648 ret_string, f_bufname},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1649 {"buffer_number", 0, 1, FEARG_1, arg1_buffer, // obsolete
22657
3ccd2fa6b713 patch 8.2.1877: test for function list fails
Bram Moolenaar <Bram@vim.org>
parents: 22655
diff changeset
1650 ret_number, f_bufnr},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1651 {"buflisted", 1, 1, FEARG_1, arg1_buffer,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1652 ret_number_bool, f_buflisted},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1653 {"bufload", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1654 ret_void, f_bufload},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1655 {"bufloaded", 1, 1, FEARG_1, arg1_buffer,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1656 ret_number_bool, f_bufloaded},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1657 {"bufname", 0, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1658 ret_string, f_bufname},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1659 {"bufnr", 0, 2, FEARG_1, arg2_buffer_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1660 ret_number, f_bufnr},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1661 {"bufwinid", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1662 ret_number, f_bufwinid},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1663 {"bufwinnr", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1664 ret_number, f_bufwinnr},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1665 {"byte2line", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1666 ret_number, f_byte2line},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1667 {"byteidx", 2, 2, FEARG_1, arg2_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1668 ret_number, f_byteidx},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1669 {"byteidxcomp", 2, 2, FEARG_1, arg2_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1670 ret_number, f_byteidxcomp},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1671 {"call", 2, 3, FEARG_1, arg3_any_list_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1672 ret_any, f_call},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1673 {"ceil", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1674 ret_float, FLOAT_FUNC(f_ceil)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1675 {"ch_canread", 1, 1, FEARG_1, arg1_chan_or_job,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1676 ret_number_bool, JOB_FUNC(f_ch_canread)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1677 {"ch_close", 1, 1, FEARG_1, arg1_chan_or_job,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1678 ret_void, JOB_FUNC(f_ch_close)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1679 {"ch_close_in", 1, 1, FEARG_1, arg1_chan_or_job,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1680 ret_void, JOB_FUNC(f_ch_close_in)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1681 {"ch_evalexpr", 2, 3, FEARG_1, arg23_chanexpr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1682 ret_any, JOB_FUNC(f_ch_evalexpr)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1683 {"ch_evalraw", 2, 3, FEARG_1, arg23_chanraw,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1684 ret_any, JOB_FUNC(f_ch_evalraw)},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1685 {"ch_getbufnr", 2, 2, FEARG_1, arg2_chan_or_job_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1686 ret_number, JOB_FUNC(f_ch_getbufnr)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1687 {"ch_getjob", 1, 1, FEARG_1, arg1_chan_or_job,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1688 ret_job, JOB_FUNC(f_ch_getjob)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1689 {"ch_info", 1, 1, FEARG_1, arg1_chan_or_job,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1690 ret_dict_any, JOB_FUNC(f_ch_info)},
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1691 {"ch_log", 1, 2, FEARG_1, arg2_string_chan_or_job,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1692 ret_void, JOB_FUNC(f_ch_log)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1693 {"ch_logfile", 1, 2, FEARG_1, arg2_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1694 ret_void, JOB_FUNC(f_ch_logfile)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1695 {"ch_open", 1, 2, FEARG_1, arg2_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1696 ret_channel, JOB_FUNC(f_ch_open)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1697 {"ch_read", 1, 2, FEARG_1, arg2_chan_or_job_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1698 ret_string, JOB_FUNC(f_ch_read)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1699 {"ch_readblob", 1, 2, FEARG_1, arg2_chan_or_job_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1700 ret_blob, JOB_FUNC(f_ch_readblob)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1701 {"ch_readraw", 1, 2, FEARG_1, arg2_chan_or_job_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1702 ret_string, JOB_FUNC(f_ch_readraw)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1703 {"ch_sendexpr", 2, 3, FEARG_1, arg23_chanexpr,
28467
3beb14b12bbd patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents: 28459
diff changeset
1704 ret_any, JOB_FUNC(f_ch_sendexpr)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1705 {"ch_sendraw", 2, 3, FEARG_1, arg23_chanraw,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1706 ret_void, JOB_FUNC(f_ch_sendraw)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1707 {"ch_setoptions", 2, 2, FEARG_1, arg2_chan_or_job_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1708 ret_void, JOB_FUNC(f_ch_setoptions)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1709 {"ch_status", 1, 2, FEARG_1, arg2_chan_or_job_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1710 ret_string, JOB_FUNC(f_ch_status)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1711 {"changenr", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1712 ret_number, f_changenr},
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
1713 {"char2nr", 1, 2, FEARG_1, arg2_string_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1714 ret_number, f_char2nr},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1715 {"charclass", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1716 ret_number, f_charclass},
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
1717 {"charcol", 1, 1, FEARG_1, arg1_string_or_list_any,
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
1718 ret_number, f_charcol},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1719 {"charidx", 2, 3, FEARG_1, arg3_string_number_bool,
23380
2351b40af967 patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents: 23276
diff changeset
1720 ret_number, f_charidx},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1721 {"chdir", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1722 ret_string, f_chdir},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1723 {"cindent", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1724 ret_number, f_cindent},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1725 {"clearmatches", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1726 ret_void, f_clearmatches},
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
1727 {"col", 1, 1, FEARG_1, arg1_string_or_list_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1728 ret_number, f_col},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1729 {"complete", 2, 2, FEARG_2, arg2_number_list,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1730 ret_void, f_complete},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1731 {"complete_add", 1, 1, FEARG_1, arg1_dict_or_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1732 ret_number, f_complete_add},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1733 {"complete_check", 0, 0, 0, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1734 ret_number_bool, f_complete_check},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1735 {"complete_info", 0, 1, FEARG_1, arg1_list_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1736 ret_dict_any, f_complete_info},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1737 {"confirm", 1, 4, FEARG_1, arg4_string_string_number_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1738 ret_number, f_confirm},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1739 {"copy", 1, 1, FEARG_1, NULL,
27517
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1740 ret_copy, f_copy},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1741 {"cos", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1742 ret_float, FLOAT_FUNC(f_cos)},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1743 {"cosh", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1744 ret_float, FLOAT_FUNC(f_cosh)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1745 {"count", 2, 4, FEARG_1, arg24_count,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1746 ret_number, f_count},
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1747 {"cscope_connection",0,3, 0, arg3_number_string_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1748 ret_number, f_cscope_connection},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1749 {"cursor", 1, 3, FEARG_1, arg13_cursor,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1750 ret_number, f_cursor},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1751 {"debugbreak", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1752 ret_number,
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
1753 #ifdef MSWIN
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1754 f_debugbreak
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1755 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1756 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1757 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
1758 },
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1759 {"deepcopy", 1, 2, FEARG_1, arg12_deepcopy,
27517
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
1760 ret_copy, f_deepcopy},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1761 {"delete", 1, 2, FEARG_1, arg2_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1762 ret_number_bool, f_delete},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1763 {"deletebufline", 2, 3, FEARG_1, arg3_buffer_lnum_lnum,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1764 ret_number_bool, f_deletebufline},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1765 {"did_filetype", 0, 0, 0, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1766 ret_number_bool, f_did_filetype},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1767 {"diff_filler", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1768 ret_number, f_diff_filler},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1769 {"diff_hlID", 2, 2, FEARG_1, arg2_lnum_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1770 ret_number, f_diff_hlID},
25378
890fd8211202 patch 8.2.3226: new digraph functions use old naming scheme
Bram Moolenaar <Bram@vim.org>
parents: 25368
diff changeset
1771 {"digraph_get", 1, 1, FEARG_1, arg1_string,
890fd8211202 patch 8.2.3226: new digraph functions use old naming scheme
Bram Moolenaar <Bram@vim.org>
parents: 25368
diff changeset
1772 ret_string, f_digraph_get},
25759
ea0820d05257 patch 8.2.3415: Vim9: not all function argument types are properly checked
Bram Moolenaar <Bram@vim.org>
parents: 25731
diff changeset
1773 {"digraph_getlist",0, 1, FEARG_1, arg1_bool,
25378
890fd8211202 patch 8.2.3226: new digraph functions use old naming scheme
Bram Moolenaar <Bram@vim.org>
parents: 25368
diff changeset
1774 ret_list_string_items, f_digraph_getlist},
25759
ea0820d05257 patch 8.2.3415: Vim9: not all function argument types are properly checked
Bram Moolenaar <Bram@vim.org>
parents: 25731
diff changeset
1775 {"digraph_set", 2, 2, FEARG_1, arg2_string,
25378
890fd8211202 patch 8.2.3226: new digraph functions use old naming scheme
Bram Moolenaar <Bram@vim.org>
parents: 25368
diff changeset
1776 ret_bool, f_digraph_set},
890fd8211202 patch 8.2.3226: new digraph functions use old naming scheme
Bram Moolenaar <Bram@vim.org>
parents: 25368
diff changeset
1777 {"digraph_setlist",1, 1, FEARG_1, arg1_list_string,
890fd8211202 patch 8.2.3226: new digraph functions use old naming scheme
Bram Moolenaar <Bram@vim.org>
parents: 25368
diff changeset
1778 ret_bool, f_digraph_setlist},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1779 {"echoraw", 1, 1, FEARG_1, arg1_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1780 ret_void, f_echoraw},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1781 {"empty", 1, 1, FEARG_1, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1782 ret_number_bool, f_empty},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1783 {"environ", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1784 ret_dict_string, f_environ},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1785 {"escape", 2, 2, FEARG_1, arg2_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1786 ret_string, f_escape},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1787 {"eval", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1788 ret_any, f_eval},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1789 {"eventhandler", 0, 0, 0, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1790 ret_number_bool, f_eventhandler},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1791 {"executable", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1792 ret_number, f_executable},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1793 {"execute", 1, 2, FEARG_1, arg12_execute,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1794 ret_string, f_execute},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1795 {"exepath", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1796 ret_string, f_exepath},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1797 {"exists", 1, 1, FEARG_1, arg1_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1798 ret_number_bool, f_exists},
25555
446f478d6fb1 patch 8.2.3314: behavior of exists() in a :def function is unpredictable
Bram Moolenaar <Bram@vim.org>
parents: 25527
diff changeset
1799 {"exists_compiled", 1, 1, FEARG_1, arg1_string,
446f478d6fb1 patch 8.2.3314: behavior of exists() in a :def function is unpredictable
Bram Moolenaar <Bram@vim.org>
parents: 25527
diff changeset
1800 ret_number_bool, f_exists_compiled},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1801 {"exp", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1802 ret_float, FLOAT_FUNC(f_exp)},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1803 {"expand", 1, 3, FEARG_1, arg3_string_bool_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1804 ret_any, f_expand},
28307
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
1805 {"expandcmd", 1, 2, FEARG_1, arg2_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1806 ret_string, f_expandcmd},
22766
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22671
diff changeset
1807 {"extend", 2, 3, FEARG_1, arg23_extend,
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
1808 ret_extend, f_extend},
23588
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
1809 {"extendnew", 2, 3, FEARG_1, arg23_extendnew,
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
1810 ret_first_cont, f_extendnew},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1811 {"feedkeys", 1, 2, FEARG_1, arg2_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1812 ret_void, f_feedkeys},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1813 {"file_readable", 1, 1, FEARG_1, arg1_string, // obsolete
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1814 ret_number_bool, f_filereadable},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1815 {"filereadable", 1, 1, FEARG_1, arg1_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1816 ret_number_bool, f_filereadable},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1817 {"filewritable", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1818 ret_number, f_filewritable},
26737
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
1819 {"filter", 2, 2, FEARG_1, arg2_filter,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1820 ret_first_arg, f_filter},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
1821 {"finddir", 1, 3, FEARG_1, arg3_string_string_number,
26686
c04b28fad0cc patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents: 26674
diff changeset
1822 ret_finddir, f_finddir},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
1823 {"findfile", 1, 3, FEARG_1, arg3_string_string_number,
25731
f35efe44dacd patch 8.2.3401: Vim9: cannot use negative count with finddir() and findfile()
Bram Moolenaar <Bram@vim.org>
parents: 25721
diff changeset
1824 ret_any, f_findfile},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1825 {"flatten", 1, 2, FEARG_1, arg2_list_any_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1826 ret_list_any, f_flatten},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1827 {"flattennew", 1, 2, FEARG_1, arg2_list_any_number,
23816
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
1828 ret_list_any, f_flattennew},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1829 {"float2nr", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1830 ret_number, FLOAT_FUNC(f_float2nr)},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1831 {"floor", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1832 ret_float, FLOAT_FUNC(f_floor)},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1833 {"fmod", 2, 2, FEARG_1, arg2_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1834 ret_float, FLOAT_FUNC(f_fmod)},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1835 {"fnameescape", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1836 ret_string, f_fnameescape},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1837 {"fnamemodify", 2, 2, FEARG_1, arg2_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1838 ret_string, f_fnamemodify},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1839 {"foldclosed", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1840 ret_number, f_foldclosed},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1841 {"foldclosedend", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1842 ret_number, f_foldclosedend},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1843 {"foldlevel", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1844 ret_number, f_foldlevel},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1845 {"foldtext", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1846 ret_string, f_foldtext},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1847 {"foldtextresult", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1848 ret_string, f_foldtextresult},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1849 {"foreground", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1850 ret_void, f_foreground},
23853
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23849
diff changeset
1851 {"fullcommand", 1, 1, FEARG_1, arg1_string,
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23849
diff changeset
1852 ret_string, f_fullcommand},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1853 {"funcref", 1, 3, FEARG_1, arg3_any_list_dict,
26656
ab46f0976435 patch 8.2.3857: Vim9: inconsistent error for using function()
Bram Moolenaar <Bram@vim.org>
parents: 26638
diff changeset
1854 ret_func_unknown, f_funcref},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
1855 {"function", 1, 3, FEARG_1, arg3_any_list_dict,
26656
ab46f0976435 patch 8.2.3857: Vim9: inconsistent error for using function()
Bram Moolenaar <Bram@vim.org>
parents: 26638
diff changeset
1856 ret_func_unknown, f_function},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1857 {"garbagecollect", 0, 1, 0, arg1_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1858 ret_void, f_garbagecollect},
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
1859 {"get", 2, 3, FEARG_1, arg23_get,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1860 ret_any, f_get},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1861 {"getbufinfo", 0, 1, FEARG_1, arg1_buffer_or_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1862 ret_list_dict_any, f_getbufinfo},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1863 {"getbufline", 2, 3, FEARG_1, arg3_buffer_lnum_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1864 ret_list_string, f_getbufline},
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1865 {"getbufvar", 2, 3, FEARG_1, arg3_buffer_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1866 ret_any, f_getbufvar},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1867 {"getchangelist", 0, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1868 ret_list_any, f_getchangelist},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1869 {"getchar", 0, 1, 0, arg1_bool,
24838
3f9053c21765 patch 8.2.2957: using getchar() in Vim9 script is problematic
Bram Moolenaar <Bram@vim.org>
parents: 24822
diff changeset
1870 ret_any, f_getchar},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1871 {"getcharmod", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1872 ret_number, f_getcharmod},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1873 {"getcharpos", 1, 1, FEARG_1, arg1_string,
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
1874 ret_list_number, f_getcharpos},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1875 {"getcharsearch", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1876 ret_dict_any, f_getcharsearch},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1877 {"getcharstr", 0, 1, 0, arg1_bool,
24838
3f9053c21765 patch 8.2.2957: using getchar() in Vim9 script is problematic
Bram Moolenaar <Bram@vim.org>
parents: 24822
diff changeset
1878 ret_string, f_getcharstr},
28757
add09d468c0d patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
1879 {"getcmdcompltype", 0, 0, 0, NULL,
add09d468c0d patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
1880 ret_string, f_getcmdcompltype},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1881 {"getcmdline", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1882 ret_string, f_getcmdline},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1883 {"getcmdpos", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1884 ret_number, f_getcmdpos},
28757
add09d468c0d patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
1885 {"getcmdscreenpos", 0, 0, 0, NULL,
add09d468c0d patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
1886 ret_number, f_getcmdscreenpos},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1887 {"getcmdtype", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1888 ret_string, f_getcmdtype},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1889 {"getcmdwintype", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1890 ret_string, f_getcmdwintype},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1891 {"getcompletion", 2, 3, FEARG_1, arg3_string_string_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1892 ret_list_string, f_getcompletion},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1893 {"getcurpos", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1894 ret_list_number, f_getcurpos},
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
1895 {"getcursorcharpos", 0, 1, FEARG_1, arg1_number,
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
1896 ret_list_number, f_getcursorcharpos},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1897 {"getcwd", 0, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1898 ret_string, f_getcwd},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1899 {"getenv", 1, 1, FEARG_1, arg1_string,
24083
1765b5b0f08d patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents: 23952
diff changeset
1900 ret_any, f_getenv},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1901 {"getfontname", 0, 1, 0, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1902 ret_string, f_getfontname},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1903 {"getfperm", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1904 ret_string, f_getfperm},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1905 {"getfsize", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1906 ret_number, f_getfsize},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1907 {"getftime", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1908 ret_number, f_getftime},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1909 {"getftype", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1910 ret_string, f_getftype},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1911 {"getimstatus", 0, 0, 0, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1912 ret_number_bool, f_getimstatus},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1913 {"getjumplist", 0, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1914 ret_list_any, f_getjumplist},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1915 {"getline", 1, 2, FEARG_1, arg2_lnum,
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
1916 ret_getline, f_getline},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1917 {"getloclist", 1, 2, 0, arg2_number_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1918 ret_list_or_dict_1, f_getloclist},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1919 {"getmarklist", 0, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1920 ret_list_dict_any, f_getmarklist},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1921 {"getmatches", 0, 1, 0, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1922 ret_list_dict_any, f_getmatches},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1923 {"getmousepos", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1924 ret_dict_number, f_getmousepos},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1925 {"getpid", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1926 ret_number, f_getpid},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1927 {"getpos", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1928 ret_list_number, f_getpos},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
1929 {"getqflist", 0, 1, 0, arg1_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1930 ret_list_or_dict_0, f_getqflist},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1931 {"getreg", 0, 3, FEARG_1, arg3_string_bool_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1932 ret_getreg, f_getreg},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1933 {"getreginfo", 0, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1934 ret_dict_any, f_getreginfo},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1935 {"getregtype", 0, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1936 ret_string, f_getregtype},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1937 {"gettabinfo", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1938 ret_list_dict_any, f_gettabinfo},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1939 {"gettabvar", 2, 3, FEARG_1, arg3_number_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1940 ret_any, f_gettabvar},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1941 {"gettabwinvar", 3, 4, FEARG_1, arg4_number_number_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1942 ret_any, f_gettabwinvar},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1943 {"gettagstack", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1944 ret_dict_any, f_gettagstack},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1945 {"gettext", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1946 ret_string, f_gettext},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1947 {"getwininfo", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1948 ret_list_dict_any, f_getwininfo},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1949 {"getwinpos", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1950 ret_list_number, f_getwinpos},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1951 {"getwinposx", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1952 ret_number, f_getwinposx},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1953 {"getwinposy", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1954 ret_number, f_getwinposy},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1955 {"getwinvar", 2, 3, FEARG_1, arg3_number_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1956 ret_any, f_getwinvar},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1957 {"glob", 1, 4, FEARG_1, arg14_glob,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1958 ret_any, f_glob},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1959 {"glob2regpat", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1960 ret_string, f_glob2regpat},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1961 {"globpath", 2, 5, FEARG_2, arg25_globpath,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1962 ret_any, f_globpath},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1963 {"has", 1, 2, 0, arg2_string_bool,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1964 ret_number_bool, f_has},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1965 {"has_key", 2, 2, FEARG_1, arg2_dict_any_string_or_nr,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1966 ret_number_bool, f_has_key},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
1967 {"haslocaldir", 0, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1968 ret_number, f_haslocaldir},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1969 {"hasmapto", 1, 3, FEARG_1, arg3_string_string_bool,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1970 ret_number_bool, f_hasmapto},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1971 {"highlightID", 1, 1, FEARG_1, arg1_string, // obsolete
22657
3ccd2fa6b713 patch 8.2.1877: test for function list fails
Bram Moolenaar <Bram@vim.org>
parents: 22655
diff changeset
1972 ret_number, f_hlID},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1973 {"highlight_exists",1, 1, FEARG_1, arg1_string, // obsolete
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1974 ret_number_bool, f_hlexists},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1975 {"histadd", 2, 2, FEARG_2, arg2_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1976 ret_number_bool, f_histadd},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1977 {"histdel", 1, 2, FEARG_1, arg2_string_string_or_number,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1978 ret_number_bool, f_histdel},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
1979 {"histget", 1, 2, FEARG_1, arg2_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1980 ret_string, f_histget},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1981 {"histnr", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1982 ret_number, f_histnr},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1983 {"hlID", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1984 ret_number, f_hlID},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1985 {"hlexists", 1, 1, FEARG_1, arg1_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
1986 ret_number_bool, f_hlexists},
26089
c544eacaf066 patch 8.2.3578: manipulating highlighting is complicated
Bram Moolenaar <Bram@vim.org>
parents: 26085
diff changeset
1987 {"hlget", 0, 2, FEARG_1, arg2_string_bool,
c544eacaf066 patch 8.2.3578: manipulating highlighting is complicated
Bram Moolenaar <Bram@vim.org>
parents: 26085
diff changeset
1988 ret_list_dict_any, f_hlget},
c544eacaf066 patch 8.2.3578: manipulating highlighting is complicated
Bram Moolenaar <Bram@vim.org>
parents: 26085
diff changeset
1989 {"hlset", 1, 1, FEARG_1, arg1_list_any,
c544eacaf066 patch 8.2.3578: manipulating highlighting is complicated
Bram Moolenaar <Bram@vim.org>
parents: 26085
diff changeset
1990 ret_number_bool, f_hlset},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1991 {"hostname", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1992 ret_string, f_hostname},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
1993 {"iconv", 3, 3, FEARG_1, arg3_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1994 ret_string, f_iconv},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
1995 {"indent", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1996 ret_number, f_indent},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
1997 {"index", 2, 4, FEARG_1, arg24_index,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
1998 ret_number, f_index},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
1999 {"input", 1, 3, FEARG_1, arg3_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2000 ret_string, f_input},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2001 {"inputdialog", 1, 3, FEARG_1, arg3_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2002 ret_string, f_inputdialog},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2003 {"inputlist", 1, 1, FEARG_1, arg1_list_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2004 ret_number, f_inputlist},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2005 {"inputrestore", 0, 0, 0, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2006 ret_number_bool, f_inputrestore},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2007 {"inputsave", 0, 0, 0, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2008 ret_number_bool, f_inputsave},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2009 {"inputsecret", 1, 2, FEARG_1, arg2_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2010 ret_string, f_inputsecret},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2011 {"insert", 2, 3, FEARG_1, arg23_insert,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2012 ret_first_arg, f_insert},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2013 {"interrupt", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2014 ret_void, f_interrupt},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2015 {"invert", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2016 ret_number, f_invert},
28629
5ef46b938c6e patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents: 28602
diff changeset
2017 {"isabsolutepath", 1, 1, FEARG_1, arg1_string,
5ef46b938c6e patch 8.2.4838: checking for absolute path is not trivial
Bram Moolenaar <Bram@vim.org>
parents: 28602
diff changeset
2018 ret_number_bool, f_isabsolutepath},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2019 {"isdirectory", 1, 1, FEARG_1, arg1_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2020 ret_number_bool, f_isdirectory},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2021 {"isinf", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2022 ret_number, MATH_FUNC(f_isinf)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2023 {"islocked", 1, 1, FEARG_1, arg1_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2024 ret_number_bool, f_islocked},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2025 {"isnan", 1, 1, FEARG_1, arg1_float_or_nr,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2026 ret_number_bool, MATH_FUNC(f_isnan)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2027 {"items", 1, 1, FEARG_1, arg1_dict_any,
25162
c44d6ac81c42 patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents: 25126
diff changeset
2028 ret_list_items, f_items},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2029 {"job_getchannel", 1, 1, FEARG_1, arg1_job,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2030 ret_channel, JOB_FUNC(f_job_getchannel)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2031 {"job_info", 0, 1, FEARG_1, arg1_job,
23592
2322b643e329 patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents: 23588
diff changeset
2032 ret_job_info, JOB_FUNC(f_job_info)},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2033 {"job_setoptions", 2, 2, FEARG_1, arg2_job_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2034 ret_void, JOB_FUNC(f_job_setoptions)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2035 {"job_start", 1, 2, FEARG_1, arg2_string_or_list_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2036 ret_job, JOB_FUNC(f_job_start)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2037 {"job_status", 1, 1, FEARG_1, arg1_job,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2038 ret_string, JOB_FUNC(f_job_status)},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2039 {"job_stop", 1, 2, FEARG_1, arg2_job_string_or_number,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2040 ret_number_bool, JOB_FUNC(f_job_stop)},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2041 {"join", 1, 2, FEARG_1, arg2_list_any_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2042 ret_string, f_join},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2043 {"js_decode", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2044 ret_any, f_js_decode},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2045 {"js_encode", 1, 1, FEARG_1, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2046 ret_string, f_js_encode},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2047 {"json_decode", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2048 ret_any, f_json_decode},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2049 {"json_encode", 1, 1, FEARG_1, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2050 ret_string, f_json_encode},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2051 {"keys", 1, 1, FEARG_1, arg1_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2052 ret_list_string, f_keys},
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
2053 {"last_buffer_nr", 0, 0, 0, NULL, // obsolete
22657
3ccd2fa6b713 patch 8.2.1877: test for function list fails
Bram Moolenaar <Bram@vim.org>
parents: 22655
diff changeset
2054 ret_number, f_last_buffer_nr},
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
2055 {"len", 1, 1, FEARG_1, arg1_len,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2056 ret_number, f_len},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2057 {"libcall", 3, 3, FEARG_3, arg3_libcall,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2058 ret_string, f_libcall},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2059 {"libcallnr", 3, 3, FEARG_3, arg3_libcall,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2060 ret_number, f_libcallnr},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2061 {"line", 1, 2, FEARG_1, arg2_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2062 ret_number, f_line},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2063 {"line2byte", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2064 ret_number, f_line2byte},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2065 {"lispindent", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2066 ret_number, f_lispindent},
25806
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
2067 {"list2blob", 1, 1, FEARG_1, arg1_list_number,
8d55e978f95b patch 8.2.3438: cannot manipulate blobs
Bram Moolenaar <Bram@vim.org>
parents: 25759
diff changeset
2068 ret_blob, f_list2blob},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2069 {"list2str", 1, 2, FEARG_1, arg2_list_number_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2070 ret_string, f_list2str},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2071 {"listener_add", 1, 2, FEARG_2, arg2_any_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2072 ret_number, f_listener_add},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2073 {"listener_flush", 0, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2074 ret_void, f_listener_flush},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2075 {"listener_remove", 1, 1, FEARG_1, arg1_number,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2076 ret_number_bool, f_listener_remove},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2077 {"localtime", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2078 ret_number, f_localtime},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2079 {"log", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2080 ret_float, FLOAT_FUNC(f_log)},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2081 {"log10", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2082 ret_float, FLOAT_FUNC(f_log10)},
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
2083 {"luaeval", 1, 2, FEARG_1, arg2_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2084 ret_any,
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2085 #ifdef FEAT_LUA
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2086 f_luaeval
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2087 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2088 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2089 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2090 },
26737
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
2091 {"map", 2, 2, FEARG_1, arg2_map,
22844
36fc73078bce patch 8.2.1969: Vim9: map() may change the list or dict item type
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
2092 ret_first_cont, f_map},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2093 {"maparg", 1, 4, FEARG_1, arg14_maparg,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2094 ret_maparg, f_maparg},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2095 {"mapcheck", 1, 3, FEARG_1, arg3_string_string_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2096 ret_string, f_mapcheck},
28602
398c5b3211f9 patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents: 28592
diff changeset
2097 {"maplist", 0, 1, 0, arg1_bool,
398c5b3211f9 patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents: 28592
diff changeset
2098 ret_list_dict_any, f_maplist},
26737
10d3105030ab patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents: 26733
diff changeset
2099 {"mapnew", 2, 2, FEARG_1, arg2_mapnew,
22844
36fc73078bce patch 8.2.1969: Vim9: map() may change the list or dict item type
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
2100 ret_first_cont, f_mapnew},
28674
38f7a132bba3 patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
2101 {"mapset", 1, 3, FEARG_1, arg3_string_or_dict_bool_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2102 ret_void, f_mapset},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
2103 {"match", 2, 4, FEARG_1, arg24_match_func,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2104 ret_any, f_match},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2105 {"matchadd", 2, 5, FEARG_1, arg25_matchadd,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2106 ret_number, f_matchadd},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2107 {"matchaddpos", 2, 5, FEARG_1, arg25_matchaddpos,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2108 ret_number, f_matchaddpos},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2109 {"matcharg", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2110 ret_list_string, f_matcharg},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2111 {"matchdelete", 1, 2, FEARG_1, arg2_number,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2112 ret_number_bool, f_matchdelete},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
2113 {"matchend", 2, 4, FEARG_1, arg24_match_func,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2114 ret_number, f_matchend},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2115 {"matchfuzzy", 2, 3, FEARG_1, arg3_list_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2116 ret_list_string, f_matchfuzzy},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2117 {"matchfuzzypos", 2, 3, FEARG_1, arg3_list_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2118 ret_list_any, f_matchfuzzypos},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
2119 {"matchlist", 2, 4, FEARG_1, arg24_match_func,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2120 ret_list_string, f_matchlist},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
2121 {"matchstr", 2, 4, FEARG_1, arg24_match_func,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2122 ret_string, f_matchstr},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
2123 {"matchstrpos", 2, 4, FEARG_1, arg24_match_func,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2124 ret_list_any, f_matchstrpos},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2125 {"max", 1, 1, FEARG_1, arg1_list_or_dict,
23705
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23654
diff changeset
2126 ret_number, f_max},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2127 {"menu_info", 1, 2, FEARG_1, arg2_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2128 ret_dict_any,
19677
ad60bc3a8087 patch 8.2.0395: build fails with FEAT_EVAL but without FEAT_MENU
Bram Moolenaar <Bram@vim.org>
parents: 19659
diff changeset
2129 #ifdef FEAT_MENU
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2130 f_menu_info
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2131 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2132 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2133 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2134 },
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2135 {"min", 1, 1, FEARG_1, arg1_list_or_dict,
23705
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23654
diff changeset
2136 ret_number, f_min},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
2137 {"mkdir", 1, 3, FEARG_1, arg3_string_string_number,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2138 ret_number_bool, f_mkdir},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2139 {"mode", 0, 1, FEARG_1, arg1_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2140 ret_string, f_mode},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2141 {"mzeval", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2142 ret_any,
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2143 #ifdef FEAT_MZSCHEME
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2144 f_mzeval
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2145 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2146 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2147 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2148 },
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2149 {"nextnonblank", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2150 ret_number, f_nextnonblank},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2151 {"nr2char", 1, 2, FEARG_1, arg2_number_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2152 ret_string, f_nr2char},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2153 {"or", 2, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2154 ret_number, f_or},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2155 {"pathshorten", 1, 2, FEARG_1, arg2_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2156 ret_string, f_pathshorten},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2157 {"perleval", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2158 ret_any,
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2159 #ifdef FEAT_PERL
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2160 f_perleval
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2161 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2162 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2163 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2164 },
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
2165 {"popup_atcursor", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2166 ret_number, PROP_FUNC(f_popup_atcursor)},
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
2167 {"popup_beval", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2168 ret_number, PROP_FUNC(f_popup_beval)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2169 {"popup_clear", 0, 1, 0, arg1_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2170 ret_void, PROP_FUNC(f_popup_clear)},
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
2171 {"popup_close", 1, 2, FEARG_1, arg2_number_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2172 ret_void, PROP_FUNC(f_popup_close)},
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
2173 {"popup_create", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2174 ret_number, PROP_FUNC(f_popup_create)},
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
2175 {"popup_dialog", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2176 ret_number, PROP_FUNC(f_popup_dialog)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2177 {"popup_filter_menu", 2, 2, 0, arg2_number_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2178 ret_bool, PROP_FUNC(f_popup_filter_menu)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2179 {"popup_filter_yesno", 2, 2, 0, arg2_number_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2180 ret_bool, PROP_FUNC(f_popup_filter_yesno)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2181 {"popup_findinfo", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2182 ret_number, PROP_FUNC(f_popup_findinfo)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2183 {"popup_findpreview", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2184 ret_number, PROP_FUNC(f_popup_findpreview)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2185 {"popup_getoptions", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2186 ret_dict_any, PROP_FUNC(f_popup_getoptions)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2187 {"popup_getpos", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2188 ret_dict_any, PROP_FUNC(f_popup_getpos)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2189 {"popup_hide", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2190 ret_void, PROP_FUNC(f_popup_hide)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2191 {"popup_list", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2192 ret_list_number, PROP_FUNC(f_popup_list)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2193 {"popup_locate", 2, 2, 0, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2194 ret_number, PROP_FUNC(f_popup_locate)},
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
2195 {"popup_menu", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2196 ret_number, PROP_FUNC(f_popup_menu)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2197 {"popup_move", 2, 2, FEARG_1, arg2_number_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2198 ret_void, PROP_FUNC(f_popup_move)},
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
2199 {"popup_notification", 2, 2, FEARG_1, arg2_str_or_nr_or_list_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2200 ret_number, PROP_FUNC(f_popup_notification)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2201 {"popup_setoptions", 2, 2, FEARG_1, arg2_number_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2202 ret_void, PROP_FUNC(f_popup_setoptions)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2203 {"popup_settext", 2, 2, FEARG_1, arg2_number_string_or_list,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2204 ret_void, PROP_FUNC(f_popup_settext)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2205 {"popup_show", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2206 ret_void, PROP_FUNC(f_popup_show)},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2207 {"pow", 2, 2, FEARG_1, arg2_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2208 ret_float, FLOAT_FUNC(f_pow)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2209 {"prevnonblank", 1, 1, FEARG_1, arg1_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2210 ret_number, f_prevnonblank},
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
2211 {"printf", 1, 19, FEARG_2, arg119_printf,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2212 ret_string, f_printf},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2213 {"prompt_getprompt", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2214 ret_string, JOB_FUNC(f_prompt_getprompt)},
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2215 {"prompt_setcallback", 2, 2, FEARG_1, arg2_buffer_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2216 ret_void, JOB_FUNC(f_prompt_setcallback)},
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2217 {"prompt_setinterrupt", 2, 2, FEARG_1, arg2_buffer_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2218 ret_void, JOB_FUNC(f_prompt_setinterrupt)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2219 {"prompt_setprompt", 2, 2, FEARG_1, arg2_buffer_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2220 ret_void, JOB_FUNC(f_prompt_setprompt)},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2221 {"prop_add", 3, 3, FEARG_1, arg3_number_number_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2222 ret_void, PROP_FUNC(f_prop_add)},
25640
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25601
diff changeset
2223 {"prop_add_list", 2, 2, FEARG_1, arg2_dict_any_list_any,
78ef12e0ce8c patch 8.2.3356: adding many text properties requires a lot of function calls
Bram Moolenaar <Bram@vim.org>
parents: 25601
diff changeset
2224 ret_void, PROP_FUNC(f_prop_add_list)},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2225 {"prop_clear", 1, 3, FEARG_1, arg3_number_number_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2226 ret_void, PROP_FUNC(f_prop_clear)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2227 {"prop_find", 1, 2, FEARG_1, arg2_dict_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2228 ret_dict_any, PROP_FUNC(f_prop_find)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2229 {"prop_list", 1, 2, FEARG_1, arg2_number_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2230 ret_list_dict_any, PROP_FUNC(f_prop_list)},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2231 {"prop_remove", 1, 3, FEARG_1, arg3_dict_number_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2232 ret_number, PROP_FUNC(f_prop_remove)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2233 {"prop_type_add", 2, 2, FEARG_1, arg2_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2234 ret_void, PROP_FUNC(f_prop_type_add)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2235 {"prop_type_change", 2, 2, FEARG_1, arg2_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2236 ret_void, PROP_FUNC(f_prop_type_change)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2237 {"prop_type_delete", 1, 2, FEARG_1, arg2_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2238 ret_void, PROP_FUNC(f_prop_type_delete)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2239 {"prop_type_get", 1, 2, FEARG_1, arg2_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2240 ret_dict_any, PROP_FUNC(f_prop_type_get)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2241 {"prop_type_list", 0, 1, FEARG_1, arg1_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2242 ret_list_string, PROP_FUNC(f_prop_type_list)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2243 {"pum_getpos", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2244 ret_dict_number, f_pum_getpos},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2245 {"pumvisible", 0, 0, 0, NULL,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2246 ret_number_bool, f_pumvisible},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2247 {"py3eval", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2248 ret_any,
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2249 #ifdef FEAT_PYTHON3
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2250 f_py3eval
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2251 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2252 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2253 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2254 },
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2255 {"pyeval", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2256 ret_any,
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2257 #ifdef FEAT_PYTHON
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2258 f_pyeval
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2259 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2260 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2261 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2262 },
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2263 {"pyxeval", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2264 ret_any,
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
2265 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2266 f_pyxeval
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2267 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2268 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2269 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2270 },
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2271 {"rand", 0, 1, FEARG_1, arg1_list_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2272 ret_number, f_rand},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2273 {"range", 1, 3, FEARG_1, arg3_number,
27551
845e518cda11 patch 8.2.4302: Vim9: return type of getline() is too strict
Bram Moolenaar <Bram@vim.org>
parents: 27533
diff changeset
2274 ret_list_number, f_range},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2275 {"readblob", 1, 1, FEARG_1, arg1_string,
23602
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23600
diff changeset
2276 ret_blob, f_readblob},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2277 {"readdir", 1, 3, FEARG_1, arg3_string_any_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2278 ret_list_string, f_readdir},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2279 {"readdirex", 1, 3, FEARG_1, arg3_string_any_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2280 ret_list_dict_any, f_readdirex},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
2281 {"readfile", 1, 3, FEARG_1, arg3_string_string_number,
23602
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23600
diff changeset
2282 ret_list_string, f_readfile},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2283 {"reduce", 2, 3, FEARG_1, arg23_reduce,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2284 ret_any, f_reduce},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2285 {"reg_executing", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2286 ret_string, f_reg_executing},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2287 {"reg_recording", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2288 ret_string, f_reg_recording},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2289 {"reltime", 0, 2, FEARG_1, arg2_list_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2290 ret_list_any, f_reltime},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2291 {"reltimefloat", 1, 1, FEARG_1, arg1_list_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2292 ret_float, FLOAT_FUNC(f_reltimefloat)},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2293 {"reltimestr", 1, 1, FEARG_1, arg1_list_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2294 ret_string, f_reltimestr},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2295 {"remote_expr", 2, 4, FEARG_1, arg24_remote_expr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2296 ret_string, f_remote_expr},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2297 {"remote_foreground", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2298 ret_string, f_remote_foreground},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2299 {"remote_peek", 1, 2, FEARG_1, arg2_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2300 ret_number, f_remote_peek},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2301 {"remote_read", 1, 2, FEARG_1, arg2_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2302 ret_string, f_remote_read},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2303 {"remote_send", 2, 3, FEARG_1, arg3_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2304 ret_string, f_remote_send},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2305 {"remote_startserver", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2306 ret_void, f_remote_startserver},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2307 {"remove", 2, 3, FEARG_1, arg23_remove,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2308 ret_remove, f_remove},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2309 {"rename", 2, 2, FEARG_1, arg2_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2310 ret_number_bool, f_rename},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2311 {"repeat", 2, 2, FEARG_1, arg2_repeat,
25449
5dce28f92d04 patch 8.2.3261: Vim9: when compiling repeat(123, N) return type is number
Bram Moolenaar <Bram@vim.org>
parents: 25431
diff changeset
2312 ret_repeat, f_repeat},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2313 {"resolve", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2314 ret_string, f_resolve},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2315 {"reverse", 1, 1, FEARG_1, arg1_list_or_blob,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2316 ret_first_arg, f_reverse},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2317 {"round", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2318 ret_float, FLOAT_FUNC(f_round)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2319 {"rubyeval", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2320 ret_any,
16103
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
2321 #ifdef FEAT_RUBY
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2322 f_rubyeval
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2323 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2324 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2325 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2326 },
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2327 {"screenattr", 2, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2328 ret_number, f_screenattr},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2329 {"screenchar", 2, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2330 ret_number, f_screenchar},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2331 {"screenchars", 2, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2332 ret_list_number, f_screenchars},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2333 {"screencol", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2334 ret_number, f_screencol},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2335 {"screenpos", 3, 3, FEARG_1, arg3_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2336 ret_dict_number, f_screenpos},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2337 {"screenrow", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2338 ret_number, f_screenrow},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2339 {"screenstring", 2, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2340 ret_string, f_screenstring},
25332
34fe6aca48c2 patch 8.2.3203: Vim9: compiled string expression causes type error
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2341 {"search", 1, 5, FEARG_1, arg15_search,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2342 ret_number, f_search},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2343 {"searchcount", 0, 1, FEARG_1, arg1_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2344 ret_dict_any, f_searchcount},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2345 {"searchdecl", 1, 3, FEARG_1, arg3_string_bool_bool,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2346 ret_number_bool, f_searchdecl},
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2347 {"searchpair", 3, 7, 0, arg37_searchpair,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2348 ret_number, f_searchpair},
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2349 {"searchpairpos", 3, 7, 0, arg37_searchpair,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2350 ret_list_number, f_searchpairpos},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2351 {"searchpos", 1, 5, FEARG_1, arg15_search,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2352 ret_list_number, f_searchpos},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2353 {"server2client", 2, 2, FEARG_1, arg2_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2354 ret_number_bool, f_server2client},
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2355 {"serverlist", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2356 ret_string, f_serverlist},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2357 {"setbufline", 3, 3, FEARG_3, arg3_setbufline,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2358 ret_number_bool, f_setbufline},
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2359 {"setbufvar", 3, 3, FEARG_3, arg3_buffer_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2360 ret_void, f_setbufvar},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2361 {"setcellwidths", 1, 1, FEARG_1, arg1_list_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2362 ret_void, f_setcellwidths},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2363 {"setcharpos", 2, 2, FEARG_2, arg2_string_list_number,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2364 ret_number_bool, f_setcharpos},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2365 {"setcharsearch", 1, 1, FEARG_1, arg1_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2366 ret_void, f_setcharsearch},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2367 {"setcmdpos", 1, 1, FEARG_1, arg1_number,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2368 ret_number_bool, f_setcmdpos},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2369 {"setcursorcharpos", 1, 3, FEARG_1, arg13_cursor,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2370 ret_number_bool, f_setcursorcharpos},
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
2371 {"setenv", 2, 2, FEARG_2, arg2_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2372 ret_void, f_setenv},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2373 {"setfperm", 2, 2, FEARG_1, arg2_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2374 ret_number_bool, f_setfperm},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2375 {"setline", 2, 2, FEARG_2, arg2_setline,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2376 ret_number_bool, f_setline},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2377 {"setloclist", 2, 4, FEARG_2, arg24_setloclist,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2378 ret_number_bool, f_setloclist},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2379 {"setmatches", 1, 2, FEARG_1, arg2_list_any_number,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2380 ret_number_bool, f_setmatches},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2381 {"setpos", 2, 2, FEARG_2, arg2_string_list_number,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2382 ret_number_bool, f_setpos},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2383 {"setqflist", 1, 3, FEARG_1, arg13_setqflist,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2384 ret_number_bool, f_setqflist},
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
2385 {"setreg", 2, 3, FEARG_2, arg3_string_any_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2386 ret_number_bool, f_setreg},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2387 {"settabvar", 3, 3, FEARG_3, arg3_number_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2388 ret_void, f_settabvar},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2389 {"settabwinvar", 4, 4, FEARG_4, arg4_number_number_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2390 ret_void, f_settabwinvar},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2391 {"settagstack", 2, 3, FEARG_2, arg23_settagstack,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2392 ret_number_bool, f_settagstack},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2393 {"setwinvar", 3, 3, FEARG_3, arg3_number_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2394 ret_void, f_setwinvar},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2395 {"sha256", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2396 ret_string,
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2397 #ifdef FEAT_CRYPT
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2398 f_sha256
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2399 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2400 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2401 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2402 },
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2403 {"shellescape", 1, 2, FEARG_1, arg2_string_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2404 ret_string, f_shellescape},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2405 {"shiftwidth", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2406 ret_number, f_shiftwidth},
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
2407 {"sign_define", 1, 2, FEARG_1, arg2_string_or_list_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2408 ret_any, SIGN_FUNC(f_sign_define)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2409 {"sign_getdefined", 0, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2410 ret_list_dict_any, SIGN_FUNC(f_sign_getdefined)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2411 {"sign_getplaced", 0, 2, FEARG_1, arg02_sign_getplaced,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2412 ret_list_dict_any, SIGN_FUNC(f_sign_getplaced)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2413 {"sign_jump", 3, 3, FEARG_1, arg3_number_string_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2414 ret_number, SIGN_FUNC(f_sign_jump)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2415 {"sign_place", 4, 5, FEARG_1, arg45_sign_place,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2416 ret_number, SIGN_FUNC(f_sign_place)},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2417 {"sign_placelist", 1, 1, FEARG_1, arg1_list_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2418 ret_list_number, SIGN_FUNC(f_sign_placelist)},
25228
a703b3f28ef4 patch 8.2.3150: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25224
diff changeset
2419 {"sign_undefine", 0, 1, FEARG_1, arg1_string_or_list_string,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2420 ret_number_bool, SIGN_FUNC(f_sign_undefine)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2421 {"sign_unplace", 1, 2, FEARG_1, arg2_string_dict,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2422 ret_number_bool, SIGN_FUNC(f_sign_unplace)},
26085
afc5987e9670 patch 8.2.3576: some functions are not documented for use with a method
Bram Moolenaar <Bram@vim.org>
parents: 25994
diff changeset
2423 {"sign_unplacelist", 1, 1, FEARG_1, arg1_list_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2424 ret_list_number, SIGN_FUNC(f_sign_unplacelist)},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2425 {"simplify", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2426 ret_string, f_simplify},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2427 {"sin", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2428 ret_float, FLOAT_FUNC(f_sin)},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2429 {"sinh", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2430 ret_float, FLOAT_FUNC(f_sinh)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2431 {"slice", 2, 3, FEARG_1, arg23_slice,
27555
829aec0d0387 patch 8.2.4304: Vim9: slice() makes a copy but doesn't change the type
Bram Moolenaar <Bram@vim.org>
parents: 27551
diff changeset
2432 ret_slice, f_slice},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2433 {"sort", 1, 3, FEARG_1, arg13_sortuniq,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2434 ret_first_arg, f_sort},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2435 {"sound_clear", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2436 ret_void, SOUND_FUNC(f_sound_clear)},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2437 {"sound_playevent", 1, 2, FEARG_1, arg2_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2438 ret_number, SOUND_FUNC(f_sound_playevent)},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2439 {"sound_playfile", 1, 2, FEARG_1, arg2_string_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2440 ret_number, SOUND_FUNC(f_sound_playfile)},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2441 {"sound_stop", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2442 ret_void, SOUND_FUNC(f_sound_stop)},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2443 {"soundfold", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2444 ret_string, f_soundfold},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2445 {"spellbadword", 0, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2446 ret_list_string, f_spellbadword},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2447 {"spellsuggest", 1, 3, FEARG_1, arg3_string_number_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2448 ret_list_string, f_spellsuggest},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2449 {"split", 1, 3, FEARG_1, arg3_string_string_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2450 ret_list_string, f_split},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2451 {"sqrt", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2452 ret_float, FLOAT_FUNC(f_sqrt)},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2453 {"srand", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2454 ret_list_number, f_srand},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2455 {"state", 0, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2456 ret_string, f_state},
25559
4b07859e1646 patch 8.2.3316: float test fails
Bram Moolenaar <Bram@vim.org>
parents: 25555
diff changeset
2457 {"str2float", 1, 2, FEARG_1, arg2_string_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2458 ret_float, FLOAT_FUNC(f_str2float)},
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
2459 {"str2list", 1, 2, FEARG_1, arg2_string_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2460 ret_list_number, f_str2list},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2461 {"str2nr", 1, 3, FEARG_1, arg3_string_number_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2462 ret_number, f_str2nr},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2463 {"strcharlen", 1, 1, FEARG_1, arg1_string_or_nr,
24130
c3d1f65365c4 patch 8.2.2606: strchars() defaults to counting composing characters
Bram Moolenaar <Bram@vim.org>
parents: 24083
diff changeset
2464 ret_number, f_strcharlen},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2465 {"strcharpart", 2, 4, FEARG_1, arg24_strpart,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2466 ret_string, f_strcharpart},
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
2467 {"strchars", 1, 2, FEARG_1, arg2_string_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2468 ret_number, f_strchars},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2469 {"strdisplaywidth", 1, 2, FEARG_1, arg2_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2470 ret_number, f_strdisplaywidth},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2471 {"strftime", 1, 2, FEARG_1, arg2_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2472 ret_string,
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2473 #ifdef HAVE_STRFTIME
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2474 f_strftime
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2475 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2476 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2477 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2478 },
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2479 {"strgetchar", 2, 2, FEARG_1, arg2_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2480 ret_number, f_strgetchar},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
2481 {"stridx", 2, 3, FEARG_1, arg3_string_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2482 ret_number, f_stridx},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2483 {"string", 1, 1, FEARG_1, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2484 ret_string, f_string},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2485 {"strlen", 1, 1, FEARG_1, arg1_string_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2486 ret_number, f_strlen},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2487 {"strpart", 2, 4, FEARG_1, arg24_strpart,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2488 ret_string, f_strpart},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2489 {"strptime", 2, 2, FEARG_1, arg2_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2490 ret_number,
18669
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
2491 #ifdef HAVE_STRPTIME
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2492 f_strptime
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2493 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2494 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2495 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2496 },
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
2497 {"strridx", 2, 3, FEARG_1, arg3_string_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2498 ret_number, f_strridx},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2499 {"strtrans", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2500 ret_string, f_strtrans},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2501 {"strwidth", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2502 ret_number, f_strwidth},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2503 {"submatch", 1, 2, FEARG_1, arg2_number_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2504 ret_string, f_submatch},
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
2505 {"substitute", 4, 4, FEARG_1, arg4_string_string_any_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2506 ret_string, f_substitute},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2507 {"swapinfo", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2508 ret_dict_any, f_swapinfo},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2509 {"swapname", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2510 ret_string, f_swapname},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2511 {"synID", 3, 3, 0, arg3_lnum_number_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2512 ret_number, f_synID},
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2513 {"synIDattr", 2, 3, FEARG_1, arg3_number_string_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2514 ret_string, f_synIDattr},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2515 {"synIDtrans", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2516 ret_number, f_synIDtrans},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2517 {"synconcealed", 2, 2, 0, arg2_lnum_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2518 ret_list_any, f_synconcealed},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2519 {"synstack", 2, 2, 0, arg2_lnum_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2520 ret_list_number, f_synstack},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2521 {"system", 1, 2, FEARG_1, arg12_system,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2522 ret_string, f_system},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2523 {"systemlist", 1, 2, FEARG_1, arg12_system,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2524 ret_list_string, f_systemlist},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2525 {"tabpagebuflist", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2526 ret_list_number, f_tabpagebuflist},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2527 {"tabpagenr", 0, 1, 0, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2528 ret_number, f_tabpagenr},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2529 {"tabpagewinnr", 1, 2, FEARG_1, arg2_number_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2530 ret_number, f_tabpagewinnr},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2531 {"tagfiles", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2532 ret_list_string, f_tagfiles},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2533 {"taglist", 1, 2, FEARG_1, arg2_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2534 ret_list_dict_any, f_taglist},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2535 {"tan", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2536 ret_float, FLOAT_FUNC(f_tan)},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2537 {"tanh", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2538 ret_float, FLOAT_FUNC(f_tanh)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2539 {"tempname", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2540 ret_string, f_tempname},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2541 {"term_dumpdiff", 2, 3, FEARG_1, arg3_string_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2542 ret_number, TERM_FUNC(f_term_dumpdiff)},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2543 {"term_dumpload", 1, 2, FEARG_1, arg2_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2544 ret_number, TERM_FUNC(f_term_dumpload)},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2545 {"term_dumpwrite", 2, 3, FEARG_2, arg3_buffer_string_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2546 ret_void, TERM_FUNC(f_term_dumpwrite)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2547 {"term_getaltscreen", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2548 ret_number, TERM_FUNC(f_term_getaltscreen)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2549 {"term_getansicolors", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2550 ret_list_string,
19807
13f34e46c269 patch 8.2.0460: build failure because of wrong feature name
Bram Moolenaar <Bram@vim.org>
parents: 19805
diff changeset
2551 #if defined(FEAT_TERMINAL) && (defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS))
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2552 f_term_getansicolors
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2553 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2554 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2555 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2556 },
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2557 {"term_getattr", 2, 2, FEARG_1, arg2_number_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2558 ret_number, TERM_FUNC(f_term_getattr)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2559 {"term_getcursor", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2560 ret_list_any, TERM_FUNC(f_term_getcursor)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2561 {"term_getjob", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2562 ret_job, TERM_FUNC(f_term_getjob)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2563 {"term_getline", 2, 2, FEARG_1, arg2_buffer_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2564 ret_string, TERM_FUNC(f_term_getline)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2565 {"term_getscrolled", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2566 ret_number, TERM_FUNC(f_term_getscrolled)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2567 {"term_getsize", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2568 ret_list_number, TERM_FUNC(f_term_getsize)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2569 {"term_getstatus", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2570 ret_string, TERM_FUNC(f_term_getstatus)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2571 {"term_gettitle", 1, 1, FEARG_1, arg1_buffer,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2572 ret_string, TERM_FUNC(f_term_gettitle)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2573 {"term_gettty", 1, 2, FEARG_1, arg2_buffer_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2574 ret_string, TERM_FUNC(f_term_gettty)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2575 {"term_list", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2576 ret_list_number, TERM_FUNC(f_term_list)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2577 {"term_scrape", 2, 2, FEARG_1, arg2_buffer_lnum,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2578 ret_list_dict_any, TERM_FUNC(f_term_scrape)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2579 {"term_sendkeys", 2, 2, FEARG_1, arg2_buffer_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2580 ret_void, TERM_FUNC(f_term_sendkeys)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2581 {"term_setansicolors", 2, 2, FEARG_1, arg2_buffer_list_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2582 ret_void,
19807
13f34e46c269 patch 8.2.0460: build failure because of wrong feature name
Bram Moolenaar <Bram@vim.org>
parents: 19805
diff changeset
2583 #if defined(FEAT_TERMINAL) && (defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS))
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2584 f_term_setansicolors
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2585 #else
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2586 NULL
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2587 #endif
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2588 },
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2589 {"term_setapi", 2, 2, FEARG_1, arg2_buffer_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2590 ret_void, TERM_FUNC(f_term_setapi)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2591 {"term_setkill", 2, 2, FEARG_1, arg2_buffer_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2592 ret_void, TERM_FUNC(f_term_setkill)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2593 {"term_setrestore", 2, 2, FEARG_1, arg2_buffer_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2594 ret_void, TERM_FUNC(f_term_setrestore)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2595 {"term_setsize", 3, 3, FEARG_1, arg3_buffer_number_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2596 ret_void, TERM_FUNC(f_term_setsize)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2597 {"term_start", 1, 2, FEARG_1, arg2_string_or_list_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2598 ret_number, TERM_FUNC(f_term_start)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2599 {"term_wait", 1, 2, FEARG_1, arg2_buffer_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2600 ret_void, TERM_FUNC(f_term_wait)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2601 {"terminalprops", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2602 ret_dict_string, f_terminalprops},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2603 {"test_alloc_fail", 3, 3, FEARG_1, arg3_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2604 ret_void, f_test_alloc_fail},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2605 {"test_autochdir", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2606 ret_void, f_test_autochdir},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2607 {"test_feedinput", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2608 ret_void, f_test_feedinput},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2609 {"test_garbagecollect_now", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2610 ret_void, f_test_garbagecollect_now},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2611 {"test_garbagecollect_soon", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2612 ret_void, f_test_garbagecollect_soon},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2613 {"test_getvalue", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2614 ret_number, f_test_getvalue},
27462
b43f6c879d52 patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
2615 {"test_gui_event", 2, 2, FEARG_1, arg2_string_dict,
b43f6c879d52 patch 8.2.4259: number of test functions for GUI events is growing
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
2616 ret_bool, f_test_gui_event},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2617 {"test_ignore_error", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2618 ret_void, f_test_ignore_error},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2619 {"test_null_blob", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2620 ret_blob, f_test_null_blob},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2621 {"test_null_channel", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2622 ret_channel, JOB_FUNC(f_test_null_channel)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2623 {"test_null_dict", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2624 ret_dict_any, f_test_null_dict},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2625 {"test_null_function", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2626 ret_func_any, f_test_null_function},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2627 {"test_null_job", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2628 ret_job, JOB_FUNC(f_test_null_job)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2629 {"test_null_list", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2630 ret_list_any, f_test_null_list},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2631 {"test_null_partial", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2632 ret_func_any, f_test_null_partial},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2633 {"test_null_string", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2634 ret_string, f_test_null_string},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2635 {"test_option_not_set", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2636 ret_void, f_test_option_not_set},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2637 {"test_override", 2, 2, FEARG_2, arg2_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2638 ret_void, f_test_override},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2639 {"test_refcount", 1, 1, FEARG_1, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2640 ret_number, f_test_refcount},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2641 {"test_setmouse", 2, 2, 0, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2642 ret_void, f_test_setmouse},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2643 {"test_settime", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2644 ret_void, f_test_settime},
25198
eafc0e07b188 patch 8.2.3135: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25166
diff changeset
2645 {"test_srand_seed", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2646 ret_void, f_test_srand_seed},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2647 {"test_unknown", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2648 ret_any, f_test_unknown},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2649 {"test_void", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2650 ret_void, f_test_void},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2651 {"timer_info", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2652 ret_list_dict_any, TIMER_FUNC(f_timer_info)},
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2653 {"timer_pause", 2, 2, FEARG_1, arg2_number_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2654 ret_void, TIMER_FUNC(f_timer_pause)},
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2655 {"timer_start", 2, 3, FEARG_1, arg3_number_any_dict,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2656 ret_number, TIMER_FUNC(f_timer_start)},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2657 {"timer_stop", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2658 ret_void, TIMER_FUNC(f_timer_stop)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2659 {"timer_stopall", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2660 ret_void, TIMER_FUNC(f_timer_stopall)},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2661 {"tolower", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2662 ret_string, f_tolower},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2663 {"toupper", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2664 ret_string, f_toupper},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2665 {"tr", 3, 3, FEARG_1, arg3_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2666 ret_string, f_tr},
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
2667 {"trim", 1, 3, FEARG_1, arg3_string_string_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2668 ret_string, f_trim},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2669 {"trunc", 1, 1, FEARG_1, arg1_float_or_nr,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2670 ret_float, FLOAT_FUNC(f_trunc)},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2671 {"type", 1, 1, FEARG_1, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2672 ret_number, f_type},
23594
d3e064f54890 patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23592
diff changeset
2673 {"typename", 1, 1, FEARG_1, NULL,
d3e064f54890 patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23592
diff changeset
2674 ret_string, f_typename},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2675 {"undofile", 1, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2676 ret_string, f_undofile},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2677 {"undotree", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2678 ret_dict_any, f_undotree},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2679 {"uniq", 1, 3, FEARG_1, arg13_sortuniq,
26686
c04b28fad0cc patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents: 26674
diff changeset
2680 ret_first_arg, f_uniq},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2681 {"values", 1, 1, FEARG_1, arg1_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2682 ret_list_any, f_values},
28994
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
2683 {"virtcol", 1, 2, FEARG_1, arg2_string_or_list_bool,
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
2684 ret_virtcol, f_virtcol},
29024
9f25e0ed831d patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents: 28994
diff changeset
2685 {"virtcol2col", 3, 3, FEARG_1, arg3_number,
9f25e0ed831d patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents: 28994
diff changeset
2686 ret_number, f_virtcol2col},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2687 {"visualmode", 0, 1, 0, arg1_bool,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2688 ret_string, f_visualmode},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2689 {"wildmenumode", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2690 ret_number, f_wildmenumode},
25224
10a5eb15a3bf patch 8.2.3148: Vim9: function arg type check does not handle base offset
Bram Moolenaar <Bram@vim.org>
parents: 25212
diff changeset
2691 {"win_execute", 2, 3, FEARG_2, arg23_win_execute,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2692 ret_string, f_win_execute},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2693 {"win_findbuf", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2694 ret_list_number, f_win_findbuf},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2695 {"win_getid", 0, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2696 ret_number, f_win_getid},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2697 {"win_gettype", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2698 ret_string, f_win_gettype},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2699 {"win_gotoid", 1, 1, FEARG_1, arg1_number,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2700 ret_number_bool, f_win_gotoid},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2701 {"win_id2tabwin", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2702 ret_list_number, f_win_id2tabwin},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2703 {"win_id2win", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2704 ret_number, f_win_id2win},
27047
b94cdb5ef20e patch 8.2.4052: not easy to resize a window from a plugin
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2705 {"win_move_separator", 2, 2, FEARG_1, arg2_number,
b94cdb5ef20e patch 8.2.4052: not easy to resize a window from a plugin
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2706 ret_number_bool, f_win_move_separator},
b94cdb5ef20e patch 8.2.4052: not easy to resize a window from a plugin
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2707 {"win_move_statusline", 2, 2, FEARG_1, arg2_number,
b94cdb5ef20e patch 8.2.4052: not easy to resize a window from a plugin
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2708 ret_number_bool, f_win_move_statusline},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2709 {"win_screenpos", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2710 ret_list_number, f_win_screenpos},
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
2711 {"win_splitmove", 2, 3, FEARG_1, arg3_number_number_dict,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2712 ret_number_bool, f_win_splitmove},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2713 {"winbufnr", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2714 ret_number, f_winbufnr},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2715 {"wincol", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2716 ret_number, f_wincol},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2717 {"windowsversion", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2718 ret_string, f_windowsversion},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2719 {"winheight", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2720 ret_number, f_winheight},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2721 {"winlayout", 0, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2722 ret_list_any, f_winlayout},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2723 {"winline", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2724 ret_number, f_winline},
25094
99494ef94fc2 patch 8.2.3084: Vim9: builtin function argument types are not checked
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
2725 {"winnr", 0, 1, FEARG_1, arg1_string,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2726 ret_number, f_winnr},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2727 {"winrestcmd", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2728 ret_string, f_winrestcmd},
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
2729 {"winrestview", 1, 1, FEARG_1, arg1_dict_any,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2730 ret_void, f_winrestview},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2731 {"winsaveview", 0, 0, 0, NULL,
23535
98185d3dd369 patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents: 23527
diff changeset
2732 ret_dict_number, f_winsaveview},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2733 {"winwidth", 1, 1, FEARG_1, arg1_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2734 ret_number, f_winwidth},
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2735 {"wordcount", 0, 0, 0, NULL,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2736 ret_dict_number, f_wordcount},
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
2737 {"writefile", 2, 3, FEARG_1, arg23_writefile,
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
2738 ret_number_bool, f_writefile},
24998
3b1770226f85 patch 8.2.3036: Vim9: builtin function arguments not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24982
diff changeset
2739 {"xor", 2, 2, FEARG_1, arg2_number,
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2740 ret_number, f_xor},
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2741 };
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2742
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2743 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2744 * Function given to ExpandGeneric() to obtain the list of internal
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2745 * or user defined function names.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2746 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2747 char_u *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2748 get_function_name(expand_T *xp, int idx)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2749 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2750 static int intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2751 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2752
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2753 if (idx == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2754 intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2755 if (intidx < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2756 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2757 name = get_user_func_name(xp, idx);
25648
46e2b5f66800 patch 8.2.3360: user function completion fails with dict function
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
2758 if (name != NULL)
46e2b5f66800 patch 8.2.3360: user function completion fails with dict function
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
2759 {
46e2b5f66800 patch 8.2.3360: user function completion fails with dict function
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
2760 if (*name != NUL && *name != '<'
46e2b5f66800 patch 8.2.3360: user function completion fails with dict function
Bram Moolenaar <Bram@vim.org>
parents: 25640
diff changeset
2761 && STRNCMP("g:", xp->xp_pattern, 2) == 0)
23598
a9433f834693 patch 8.2.2341: expresison command line completion incomplete after "g:"
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
2762 return cat_prefix_varname('g', name);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2763 return name;
23598
a9433f834693 patch 8.2.2341: expresison command line completion incomplete after "g:"
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
2764 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2765 }
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 24665
diff changeset
2766 if (++intidx < (int)ARRAY_LENGTH(global_functions))
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2767 {
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2768 STRCPY(IObuff, global_functions[intidx].f_name);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2769 STRCAT(IObuff, "(");
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2770 if (global_functions[intidx].f_max_argc == 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2771 STRCAT(IObuff, ")");
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2772 return IObuff;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2773 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2774
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2775 return NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2776 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2777
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2778 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2779 * Function given to ExpandGeneric() to obtain the list of internal or
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2780 * user defined variable or function names.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2781 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2782 char_u *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2783 get_expr_name(expand_T *xp, int idx)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2784 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2785 static int intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2786 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2787
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2788 if (idx == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2789 intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2790 if (intidx < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2791 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2792 name = get_function_name(xp, idx);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2793 if (name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2794 return name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2795 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2796 return get_user_var_name(xp, ++intidx);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2797 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2798
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2799 /*
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
2800 * Find internal function "name" in table "global_functions".
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2801 * Return index, or -1 if not found or "implemented" is TRUE and the function
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2802 * is not implemented.
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2803 */
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2804 static int
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2805 find_internal_func_opt(char_u *name, int implemented)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2806 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2807 int first = 0;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2808 int last;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2809 int cmp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2810 int x;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2811
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 24665
diff changeset
2812 last = (int)ARRAY_LENGTH(global_functions) - 1;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2813
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2814 // Find the function name in the table. Binary search.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2815 while (first <= last)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2816 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2817 x = first + ((unsigned)(last - first) >> 1);
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
2818 cmp = STRCMP(name, global_functions[x].f_name);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2819 if (cmp < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2820 last = x - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2821 else if (cmp > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2822 first = x + 1;
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2823 else if (implemented && global_functions[x].f_func == NULL)
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2824 break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2825 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2826 return x;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2827 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2828 return -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2829 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2830
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2831 /*
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2832 * Find internal function "name" in table "global_functions".
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2833 * Return index, or -1 if not found or the function is not implemented.
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2834 */
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2835 int
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2836 find_internal_func(char_u *name)
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2837 {
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2838 return find_internal_func_opt(name, TRUE);
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2839 }
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2840
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2841 int
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2842 has_internal_func(char_u *name)
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2843 {
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2844 return find_internal_func_opt(name, TRUE) >= 0;
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2845 }
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2846
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2847 static int
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2848 has_internal_func_name(char_u *name)
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2849 {
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
2850 return find_internal_func_opt(name, FALSE) >= 0;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2851 }
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2852
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2853 char *
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2854 internal_func_name(int idx)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2855 {
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2856 return global_functions[idx].f_name;
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2857 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2858
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2859 /*
24618
4aebea72c397 patch 8.2.2848: crash whn calling partial
Bram Moolenaar <Bram@vim.org>
parents: 24614
diff changeset
2860 * Check the argument types for builtin function "idx".
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2861 * Uses the list of types on the type stack: "types".
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2862 * Return FAIL and gives an error message when a type is wrong.
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2863 */
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2864 int
23640
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
2865 internal_func_check_arg_types(
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
2866 type2_T *types,
23640
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
2867 int idx,
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
2868 int argcount,
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
2869 cctx_T *cctx)
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2870 {
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2871 argcheck_T *argchecks = global_functions[idx].f_argcheck;
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2872 int i;
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2873
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2874 if (argchecks != NULL)
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2875 {
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2876 argcontext_T context;
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2877
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2878 context.arg_count = argcount;
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22657
diff changeset
2879 context.arg_types = types;
23640
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
2880 context.arg_cctx = cctx;
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2881 for (i = 0; i < argcount; ++i)
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2882 if (argchecks[i] != NULL)
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2883 {
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2884 context.arg_idx = i;
26935
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
2885 if (argchecks[i](types[i].type_curr, types[i].type_decl,
ccb9be1cdd71 patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents: 26895
diff changeset
2886 &context) == FAIL)
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2887 return FAIL;
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2888 }
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2889 }
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2890 return OK;
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2891 }
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22620
diff changeset
2892
22671
ad54acb1bf2c patch 8.2.1884: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 22661
diff changeset
2893 /*
25126
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2894 * Get the argument count for function "idx".
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2895 * "argcount" is the total argument count, "min_argcount" the non-optional
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2896 * argument count.
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2897 */
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2898 void
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2899 internal_func_get_argcount(int idx, int *argcount, int *min_argcount)
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2900 {
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2901 *argcount = global_functions[idx].f_max_argc;
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2902 *min_argcount = global_functions[idx].f_min_argc;
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2903 }
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2904
b825efff9790 patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents: 25094
diff changeset
2905 /*
22671
ad54acb1bf2c patch 8.2.1884: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 22661
diff changeset
2906 * Call the "f_retfunc" function to obtain the return type of function "idx".
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2907 * "decl_type" is set to the declared type.
22671
ad54acb1bf2c patch 8.2.1884: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 22661
diff changeset
2908 * "argtypes" is the list of argument types or NULL when there are no
ad54acb1bf2c patch 8.2.1884: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 22661
diff changeset
2909 * arguments.
25465
b8a6a0007dc3 patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents: 25449
diff changeset
2910 * "argcount" may be less than the actual count when only getting the type.
22671
ad54acb1bf2c patch 8.2.1884: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 22661
diff changeset
2911 */
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2912 type_T *
27503
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2913 internal_func_ret_type(
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2914 int idx,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2915 int argcount,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2916 type2_T *argtypes,
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2917 type_T **decl_type)
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2918 {
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2919 type_T *ret;
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2920
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2921 *decl_type = NULL;
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2922 ret = global_functions[idx].f_retfunc(argcount, argtypes, decl_type);
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2923 if (*decl_type == NULL)
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2924 *decl_type = ret;
4cea92e99a5a patch 8.2.4279: Vim9: cannot change item type with map() after range()
Bram Moolenaar <Bram@vim.org>
parents: 27497
diff changeset
2925 return ret;
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2926 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2927
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2928 /*
23565
34aa2907082a patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents: 23563
diff changeset
2929 * Return TRUE if "idx" is for the map() function.
34aa2907082a patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents: 23563
diff changeset
2930 */
34aa2907082a patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents: 23563
diff changeset
2931 int
34aa2907082a patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents: 23563
diff changeset
2932 internal_func_is_map(int idx)
34aa2907082a patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents: 23563
diff changeset
2933 {
34aa2907082a patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents: 23563
diff changeset
2934 return global_functions[idx].f_func == f_map;
34aa2907082a patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents: 23563
diff changeset
2935 }
34aa2907082a patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents: 23563
diff changeset
2936
34aa2907082a patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents: 23563
diff changeset
2937 /*
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2938 * Check the argument count to use for internal function "idx".
21232
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21186
diff changeset
2939 * Returns -1 for failure, 0 if no method base accepted, 1 if method base is
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21186
diff changeset
2940 * first argument, 2 if method base is second argument, etc. 9 if method base
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21186
diff changeset
2941 * is last argument.
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2942 */
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2943 int
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2944 check_internal_func(int idx, int argcount)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2945 {
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2946 int res;
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2947 char *name;
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2948
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2949 if (argcount < global_functions[idx].f_min_argc)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2950 res = FCERR_TOOFEW;
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2951 else if (argcount > global_functions[idx].f_max_argc)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2952 res = FCERR_TOOMANY;
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2953 else
21232
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21186
diff changeset
2954 return global_functions[idx].f_argtype;
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2955
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2956 name = internal_func_name(idx);
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2957 if (res == FCERR_TOOMANY)
26602
fac6673086df patch 8.2.3830: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26585
diff changeset
2958 semsg(_(e_too_many_arguments_for_function_str), name);
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2959 else
26602
fac6673086df patch 8.2.3830: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26585
diff changeset
2960 semsg(_(e_not_enough_arguments_for_function_str), name);
21232
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21186
diff changeset
2961 return -1;
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2962 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2963
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2964 int
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2965 call_internal_func(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2966 char_u *name,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2967 int argcount,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2968 typval_T *argvars,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2969 typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2970 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2971 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2972
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
2973 i = find_internal_func(name);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2974 if (i < 0)
19013
dd9ab0674eec patch 8.2.0067: ERROR_UNKNOWN clashes on some systems
Bram Moolenaar <Bram@vim.org>
parents: 18973
diff changeset
2975 return FCERR_UNKNOWN;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2976 if (argcount < global_functions[i].f_min_argc)
19013
dd9ab0674eec patch 8.2.0067: ERROR_UNKNOWN clashes on some systems
Bram Moolenaar <Bram@vim.org>
parents: 18973
diff changeset
2977 return FCERR_TOOFEW;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2978 if (argcount > global_functions[i].f_max_argc)
19013
dd9ab0674eec patch 8.2.0067: ERROR_UNKNOWN clashes on some systems
Bram Moolenaar <Bram@vim.org>
parents: 18973
diff changeset
2979 return FCERR_TOOMANY;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2980 argvars[argcount].v_type = VAR_UNKNOWN;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2981 global_functions[i].f_func(argvars, rettv);
19013
dd9ab0674eec patch 8.2.0067: ERROR_UNKNOWN clashes on some systems
Bram Moolenaar <Bram@vim.org>
parents: 18973
diff changeset
2982 return FCERR_NONE;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2983 }
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2984
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2985 void
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2986 call_internal_func_by_idx(
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2987 int idx,
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2988 typval_T *argvars,
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2989 typval_T *rettv)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2990 {
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2991 global_functions[idx].f_func(argvars, rettv);
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2992 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
2993
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2994 /*
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2995 * Invoke a method for base->method().
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2996 */
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2997 int
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2998 call_internal_method(
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
2999 char_u *name,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3000 int argcount,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3001 typval_T *argvars,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3002 typval_T *rettv,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3003 typval_T *basetv)
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3004 {
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3005 int i;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3006 int fi;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3007 typval_T argv[MAX_FUNC_ARGS + 1];
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3008
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
3009 fi = find_internal_func(name);
17732
1726c2db81bf patch 8.1.1863: confusing error when using a builtin function as method
Bram Moolenaar <Bram@vim.org>
parents: 17728
diff changeset
3010 if (fi < 0)
19013
dd9ab0674eec patch 8.2.0067: ERROR_UNKNOWN clashes on some systems
Bram Moolenaar <Bram@vim.org>
parents: 18973
diff changeset
3011 return FCERR_UNKNOWN;
17732
1726c2db81bf patch 8.1.1863: confusing error when using a builtin function as method
Bram Moolenaar <Bram@vim.org>
parents: 17728
diff changeset
3012 if (global_functions[fi].f_argtype == 0)
19013
dd9ab0674eec patch 8.2.0067: ERROR_UNKNOWN clashes on some systems
Bram Moolenaar <Bram@vim.org>
parents: 18973
diff changeset
3013 return FCERR_NOTMETHOD;
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
3014 if (argcount + 1 < global_functions[fi].f_min_argc)
19013
dd9ab0674eec patch 8.2.0067: ERROR_UNKNOWN clashes on some systems
Bram Moolenaar <Bram@vim.org>
parents: 18973
diff changeset
3015 return FCERR_TOOFEW;
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
3016 if (argcount + 1 > global_functions[fi].f_max_argc)
19013
dd9ab0674eec patch 8.2.0067: ERROR_UNKNOWN clashes on some systems
Bram Moolenaar <Bram@vim.org>
parents: 18973
diff changeset
3017 return FCERR_TOOMANY;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3018
26895
46e6ef4cf18b patch 8.2.3976: FEARG_LAST is never used
Bram Moolenaar <Bram@vim.org>
parents: 26887
diff changeset
3019 if (global_functions[fi].f_argtype == FEARG_2)
17620
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3020 {
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3021 // base value goes second
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3022 argv[0] = argvars[0];
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3023 argv[1] = *basetv;
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3024 for (i = 1; i < argcount; ++i)
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3025 argv[i + 1] = argvars[i];
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3026 }
17728
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
3027 else if (global_functions[fi].f_argtype == FEARG_3)
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
3028 {
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
3029 // base value goes third
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
3030 argv[0] = argvars[0];
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
3031 argv[1] = argvars[1];
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
3032 argv[2] = *basetv;
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
3033 for (i = 2; i < argcount; ++i)
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
3034 argv[i + 1] = argvars[i];
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
3035 }
18000
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
3036 else if (global_functions[fi].f_argtype == FEARG_4)
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
3037 {
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
3038 // base value goes fourth
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
3039 argv[0] = argvars[0];
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
3040 argv[1] = argvars[1];
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
3041 argv[2] = argvars[2];
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
3042 argv[3] = *basetv;
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
3043 for (i = 3; i < argcount; ++i)
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
3044 argv[i + 1] = argvars[i];
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
3045 }
17620
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3046 else
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3047 {
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
3048 // FEARG_1: base value goes first
17620
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3049 argv[0] = *basetv;
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3050 for (i = 0; i < argcount; ++i)
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3051 argv[i + 1] = argvars[i];
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
3052 }
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3053 argv[argcount + 1].v_type = VAR_UNKNOWN;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3054
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
3055 global_functions[fi].f_func(argv, rettv);
19013
dd9ab0674eec patch 8.2.0067: ERROR_UNKNOWN clashes on some systems
Bram Moolenaar <Bram@vim.org>
parents: 18973
diff changeset
3056 return FCERR_NONE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3057 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3058
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3059 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3060 * Return TRUE for a non-zero Number and a non-empty String.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3061 */
18104
e59ff7b5d7a7 patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents: 18094
diff changeset
3062 int
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3063 non_zero_arg(typval_T *argvars)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3064 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3065 return ((argvars[0].v_type == VAR_NUMBER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3066 && argvars[0].vval.v_number != 0)
19102
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
3067 || (argvars[0].v_type == VAR_BOOL
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3068 && argvars[0].vval.v_number == VVAL_TRUE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3069 || (argvars[0].v_type == VAR_STRING
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3070 && argvars[0].vval.v_string != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3071 && *argvars[0].vval.v_string != NUL));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3072 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3073
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3074 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3075 * "and(expr, expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3076 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3077 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3078 f_and(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3079 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3080 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3081 && (check_for_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3082 || check_for_number_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3083 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3084
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3085 rettv->vval.v_number = tv_get_number_chk(&argvars[0], NULL)
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3086 & tv_get_number_chk(&argvars[1], NULL);
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 14019
diff changeset
3087 }
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 14019
diff changeset
3088
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3089 /*
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
3090 * "balloon_show()" function
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
3091 */
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
3092 #ifdef FEAT_BEVAL
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
3093 static void
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3094 f_balloon_gettext(typval_T *argvars UNUSED, typval_T *rettv)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3095 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3096 rettv->v_type = VAR_STRING;
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3097 if (balloonEval != NULL)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3098 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3099 if (balloonEval->msg == NULL)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3100 rettv->vval.v_string = NULL;
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3101 else
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3102 rettv->vval.v_string = vim_strsave(balloonEval->msg);
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3103 }
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3104 }
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3105
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3106 static void
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
3107 f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
3108 {
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 11014
diff changeset
3109 if (balloonEval != NULL)
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3110 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3111 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3112 && check_for_string_or_list_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3113 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3114
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3115 if (argvars[0].v_type == VAR_LIST
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3116 # ifdef FEAT_GUI
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3117 && !gui.in_use
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3118 # endif
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3119 )
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3120 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3121 list_T *l = argvars[0].vval.v_list;
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3122
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3123 // empty list removes the balloon
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3124 post_balloon(balloonEval, NULL,
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3125 l == NULL || l->lv_len == 0 ? NULL : l);
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3126 }
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3127 else
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3128 {
24246
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3129 char_u *mesg;
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3130
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3131 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3132 return;
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3133
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3134 mesg = tv_get_string_chk(&argvars[0]);
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3135 if (mesg != NULL)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3136 // empty string removes the balloon
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3137 post_balloon(balloonEval, *mesg == NUL ? NULL : mesg, NULL);
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
3138 }
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3139 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3140 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3141
12885
10cb5c3df3f5 patch 8.0.1319: can't build GUI on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
3142 # if defined(FEAT_BEVAL_TERM)
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3143 static void
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3144 f_balloon_split(typval_T *argvars, typval_T *rettv UNUSED)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3145 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3146 if (rettv_list_alloc(rettv) == OK)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3147 {
24246
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3148 char_u *msg;
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3149
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3150 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3151 return;
35603c7991d7 patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24198
diff changeset
3152 msg = tv_get_string_chk(&argvars[0]);
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3153 if (msg != NULL)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3154 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3155 pumitem_T *array;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3156 int size = split_message(msg, &array);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3157 int i;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3158
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3159 // Skip the first and last item, they are always empty.
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3160 for (i = 1; i < size - 1; ++i)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3161 list_append_string(rettv->vval.v_list, array[i].pum_text, -1);
13236
fee03d646e42 patch 8.0.1492: memory leak in balloon_split()
Christian Brabandt <cb@256bit.org>
parents: 13229
diff changeset
3162 while (size > 0)
fee03d646e42 patch 8.0.1492: memory leak in balloon_split()
Christian Brabandt <cb@256bit.org>
parents: 13229
diff changeset
3163 vim_free(array[--size].pum_text);
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3164 vim_free(array);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3165 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
3166 }
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
3167 }
12885
10cb5c3df3f5 patch 8.0.1319: can't build GUI on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
3168 # endif
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
3169 #endif
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
3170
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
3171 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3172 * Get the buffer from "arg" and give an error and return NULL if it is not
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3173 * valid.
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3174 */
16638
4790302965fc patch 8.1.1321: no docs or tests for listener functions
Bram Moolenaar <Bram@vim.org>
parents: 16634
diff changeset
3175 buf_T *
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3176 get_buf_arg(typval_T *arg)
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3177 {
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3178 buf_T *buf;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3179
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3180 ++emsg_off;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3181 buf = tv_get_buf(arg, FALSE);
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3182 --emsg_off;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3183 if (buf == NULL)
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
3184 semsg(_(e_invalid_buffer_name_str), tv_get_string(arg));
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3185 return buf;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3186 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3187
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
3188 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3189 * "byte2line(byte)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3190 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3191 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3192 f_byte2line(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3193 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3194 #ifndef FEAT_BYTEOFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3195 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3196 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3197 long boff = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3198
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3199 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3200 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3201
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3202 boff = tv_get_number(&argvars[0]) - 1; // boff gets -1 on type error
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3203 if (boff < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3204 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3205 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3206 rettv->vval.v_number = ml_find_line_or_offset(curbuf,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3207 (linenr_T)0, &boff);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3208 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3209 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3210
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3211 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3212 * "call(func, arglist [, dict])" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3213 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3214 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3215 f_call(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3216 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3217 char_u *func;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3218 partial_T *partial = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3219 dict_T *selfdict = NULL;
27295
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3220 char_u *dot;
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3221 char_u *tofree = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3222
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
3223 if (in_vim9script()
26731
7f4cc4e58f75 patch 8.2.3894: Vim9: no proper type check for first argument of call()
Bram Moolenaar <Bram@vim.org>
parents: 26721
diff changeset
3224 && (check_for_string_or_func_arg(argvars, 0) == FAIL
7f4cc4e58f75 patch 8.2.3894: Vim9: no proper type check for first argument of call()
Bram Moolenaar <Bram@vim.org>
parents: 26721
diff changeset
3225 || check_for_list_arg(argvars, 1) == FAIL
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
3226 || check_for_opt_dict_arg(argvars, 2) == FAIL))
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
3227 return;
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
3228
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3229 if (argvars[1].v_type != VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3230 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
3231 emsg(_(e_list_required));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3232 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3233 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3234 if (argvars[1].vval.v_list == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3235 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3236
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3237 if (argvars[0].v_type == VAR_FUNC)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3238 func = argvars[0].vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3239 else if (argvars[0].v_type == VAR_PARTIAL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3240 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3241 partial = argvars[0].vval.v_partial;
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
3242 func = partial_name(partial);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3243 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3244 else
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3245 func = tv_get_string(&argvars[0]);
24618
4aebea72c397 patch 8.2.2848: crash whn calling partial
Bram Moolenaar <Bram@vim.org>
parents: 24614
diff changeset
3246 if (func == NULL || *func == NUL)
4aebea72c397 patch 8.2.2848: crash whn calling partial
Bram Moolenaar <Bram@vim.org>
parents: 24614
diff changeset
3247 return; // type error, empty name or null function
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3248
27295
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3249 dot = vim_strchr(func, '.');
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3250 if (dot != NULL)
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3251 {
27698
3813036f19cb patch 8.2.4375: ctx_imports is not used
Bram Moolenaar <Bram@vim.org>
parents: 27657
diff changeset
3252 imported_T *import = find_imported(func, dot - func, TRUE);
27295
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3253
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3254 if (import != NULL && SCRIPT_ID_VALID(import->imp_sid))
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3255 {
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3256 scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3257
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3258 if (si->sn_autoload_prefix != NULL)
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3259 {
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3260 // Turn "import.Func" into "scriptname#Func".
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3261 tofree = concat_str(si->sn_autoload_prefix, dot + 1);
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3262 if (tofree == NULL)
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3263 return;
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3264 func = tofree;
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3265 }
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3266 }
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3267 }
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3268
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3269 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3270 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3271 if (argvars[2].v_type != VAR_DICT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3272 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
3273 emsg(_(e_dictionary_required));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3274 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3275 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3276 selfdict = argvars[2].vval.v_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3277 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3278
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3279 (void)func_call(func, &argvars[1], partial, selfdict, rettv);
27295
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3280
69aa20a6e7ae patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
3281 vim_free(tofree);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3282 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3283
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3284 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3285 * "changenr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3286 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3287 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3288 f_changenr(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3289 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3290 rettv->vval.v_number = curbuf->b_u_seq_cur;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3291 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3292
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3293 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3294 * "char2nr(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3295 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3296 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3297 f_char2nr(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3298 {
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
3299 if (in_vim9script()
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
3300 && (check_for_string_arg(argvars, 0) == FAIL
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
3301 || check_for_opt_bool_arg(argvars, 1) == FAIL))
24250
01b274c3f69b patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24246
diff changeset
3302 return;
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
3303
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3304 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3305 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3306 int utf8 = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3307
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3308 if (argvars[1].v_type != VAR_UNKNOWN)
22085
79dd6062d15c patch 8.2.1592: Vim9: passing "true" to char2nr() fails
Bram Moolenaar <Bram@vim.org>
parents: 22077
diff changeset
3309 utf8 = (int)tv_get_bool_chk(&argvars[1], NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3310
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3311 if (utf8)
15967
ddd82b1c9e9d patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents: 15955
diff changeset
3312 rettv->vval.v_number = utf_ptr2char(tv_get_string(&argvars[0]));
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3313 else
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3314 rettv->vval.v_number = (*mb_ptr2char)(tv_get_string(&argvars[0]));
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3315 }
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3316 else
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
3317 rettv->vval.v_number = tv_get_string(&argvars[0])[0];
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3318 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3319
23380
2351b40af967 patch 8.2.2233: cannot convert a byte index into a character index
Bram Moolenaar <Bram@vim.org>
parents: 23276
diff changeset
3320 /*
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3321 * Get the current cursor column and store it in 'rettv'. If 'charcol' is TRUE,
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3322 * returns the character index of the column. Otherwise, returns the byte index
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3323 * of the column.
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3324 */
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3325 static void
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3326 get_col(typval_T *argvars, typval_T *rettv, int charcol)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3327 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3328 colnr_T col = 0;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3329 pos_T *fp;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3330 int fnum = curbuf->b_fnum;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3331
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3332 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3333 && check_for_string_or_list_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3334 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3335
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3336 fp = var2fpos(&argvars[0], FALSE, &fnum, charcol);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3337 if (fp != NULL && fnum == curbuf->b_fnum)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3338 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3339 if (fp->col == MAXCOL)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3340 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3341 // '> can be MAXCOL, get the length of the line then
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3342 if (fp->lnum <= curbuf->b_ml.ml_line_count)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3343 col = (colnr_T)STRLEN(ml_get(fp->lnum)) + 1;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3344 else
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3345 col = MAXCOL;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3346 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3347 else
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3348 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3349 col = fp->col + 1;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3350 // col(".") when the cursor is on the NUL at the end of the line
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3351 // because of "coladd" can be seen as an extra column.
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3352 if (virtual_active() && fp == &curwin->w_cursor)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3353 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3354 char_u *p = ml_get_cursor();
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3355
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3356 if (curwin->w_cursor.coladd >= (colnr_T)chartabsize(p,
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3357 curwin->w_virtcol - curwin->w_cursor.coladd))
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3358 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3359 int l;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3360
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3361 if (*p != NUL && p[(l = (*mb_ptr2len)(p))] == NUL)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3362 col += l;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3363 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3364 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3365 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3366 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3367 rettv->vval.v_number = col;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3368 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3369
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3370 /*
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3371 * "charcol()" function
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3372 */
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3373 static void
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3374 f_charcol(typval_T *argvars, typval_T *rettv)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3375 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3376 get_col(argvars, rettv, TRUE);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3377 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3378
17472
dfd87ef822aa patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17377
diff changeset
3379 win_T *
16158
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3380 get_optional_window(typval_T *argvars, int idx)
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3381 {
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3382 win_T *win = curwin;
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3383
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3384 if (argvars[idx].v_type != VAR_UNKNOWN)
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3385 {
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3386 win = find_win_by_nr_or_id(&argvars[idx]);
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3387 if (win == NULL)
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3388 {
26887
612339679616 patch 8.2.3972: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
3389 emsg(_(e_invalid_window_number));
16158
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3390 return NULL;
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3391 }
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3392 }
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3393 return win;
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3394 }
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
3395
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3396 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3397 * "col(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3398 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3399 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3400 f_col(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3401 {
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3402 get_col(argvars, rettv, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3403 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3404
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3405 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3406 * "confirm(message, buttons[, default [, type]])" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3407 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3408 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3409 f_confirm(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3410 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3411 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3412 char_u *message;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3413 char_u *buttons = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3414 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3415 char_u buf2[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3416 int def = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3417 int type = VIM_GENERIC;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3418 char_u *typestr;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3419 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3420
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
3421 if (in_vim9script()
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
3422 && (check_for_string_arg(argvars, 0) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
3423 || (check_for_opt_string_arg(argvars, 1) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
3424 || (argvars[1].v_type != VAR_UNKNOWN
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
3425 && (check_for_opt_number_arg(argvars, 2) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
3426 || (argvars[2].v_type != VAR_UNKNOWN
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
3427 && check_for_opt_string_arg(argvars, 3) == FAIL))))))
24250
01b274c3f69b patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24246
diff changeset
3428 return;
01b274c3f69b patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24246
diff changeset
3429
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3430 message = tv_get_string_chk(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3431 if (message == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3432 error = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3433 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3434 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3435 buttons = tv_get_string_buf_chk(&argvars[1], buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3436 if (buttons == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3437 error = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3438 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3439 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3440 def = (int)tv_get_number_chk(&argvars[2], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3441 if (argvars[3].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3442 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3443 typestr = tv_get_string_buf_chk(&argvars[3], buf2);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3444 if (typestr == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3445 error = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3446 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3447 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3448 switch (TOUPPER_ASC(*typestr))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3449 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3450 case 'E': type = VIM_ERROR; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3451 case 'Q': type = VIM_QUESTION; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3452 case 'I': type = VIM_INFO; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3453 case 'W': type = VIM_WARNING; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3454 case 'G': type = VIM_GENERIC; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3455 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3456 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3457 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3458 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3459 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3460
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3461 if (buttons == NULL || *buttons == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3462 buttons = (char_u *)_("&Ok");
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3463
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3464 if (!error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3465 rettv->vval.v_number = do_dialog(type, NULL, message, buttons,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3466 def, NULL, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3467 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3468 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3469
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3470 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3471 * "copy()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3472 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3473 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3474 f_copy(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3475 {
27517
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
3476 item_copy(&argvars[0], rettv, FALSE, TRUE, 0);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3477 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3478
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3479 /*
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3480 * Set the cursor position.
24618
4aebea72c397 patch 8.2.2848: crash whn calling partial
Bram Moolenaar <Bram@vim.org>
parents: 24614
diff changeset
3481 * If 'charcol' is TRUE, then use the column number as a character offset.
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3482 * Otherwise use the column number as a byte offset.
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3483 */
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3484 static void
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3485 set_cursorpos(typval_T *argvars, typval_T *rettv, int charcol)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3486 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3487 long line, col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3488 long coladd = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3489 int set_curswant = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3490
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
3491 if (in_vim9script()
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3492 && (check_for_string_or_number_or_list_arg(argvars, 0) == FAIL
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
3493 || check_for_opt_number_arg(argvars, 1) == FAIL
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
3494 || (argvars[1].v_type != VAR_UNKNOWN
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
3495 && check_for_opt_number_arg(argvars, 2) == FAIL)))
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
3496 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
3497
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3498 rettv->vval.v_number = -1;
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3499 if (argvars[0].v_type == VAR_LIST)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3500 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3501 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3502 colnr_T curswant = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3503
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3504 if (list2fpos(argvars, &pos, NULL, &curswant, charcol) == FAIL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3505 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
3506 emsg(_(e_invalid_argument));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3507 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3508 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3509 line = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3510 col = pos.col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3511 coladd = pos.coladd;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3512 if (curswant >= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3513 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3514 curwin->w_curswant = curswant - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3515 set_curswant = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3516 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3517 }
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3518 else if ((argvars[0].v_type == VAR_NUMBER ||
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3519 argvars[0].v_type == VAR_STRING)
23642
8df4e9e2394f patch 8.2.2363: curpos() does not accept a string argument as before
Bram Moolenaar <Bram@vim.org>
parents: 23640
diff changeset
3520 && (argvars[1].v_type == VAR_NUMBER ||
8df4e9e2394f patch 8.2.2363: curpos() does not accept a string argument as before
Bram Moolenaar <Bram@vim.org>
parents: 23640
diff changeset
3521 argvars[1].v_type == VAR_STRING))
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3522 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3523 line = tv_get_lnum(argvars);
23276
b79cdad3ea2e patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents: 22898
diff changeset
3524 if (line < 0)
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
3525 semsg(_(e_invalid_argument_str), tv_get_string(&argvars[0]));
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3526 col = (long)tv_get_number_chk(&argvars[1], NULL);
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3527 if (charcol)
23600
f4347a61ed38 patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents: 23598
diff changeset
3528 col = buf_charidx_to_byteidx(curbuf, line, col) + 1;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3529 if (argvars[2].v_type != VAR_UNKNOWN)
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3530 coladd = (long)tv_get_number_chk(&argvars[2], NULL);
15636
6f1c7e9a6393 patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15615
diff changeset
3531 }
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3532 else
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3533 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
3534 emsg(_(e_invalid_argument));
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3535 return;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3536 }
15636
6f1c7e9a6393 patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15615
diff changeset
3537 if (line < 0 || col < 0 || coladd < 0)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3538 return; // type error; errmsg already given
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3539 if (line > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3540 curwin->w_cursor.lnum = line;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3541 if (col > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3542 curwin->w_cursor.col = col - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3543 curwin->w_cursor.coladd = coladd;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3544
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3545 // Make sure the cursor is in a valid position.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3546 check_cursor();
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3547 // Correct cursor for multi-byte character.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3548 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3549 mb_adjust_cursor();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3550
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3551 curwin->w_set_curswant = set_curswant;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3552 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3553 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3554
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3555 /*
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3556 * "cursor(lnum, col)" function, or
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3557 * "cursor(list)"
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3558 *
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3559 * Moves the cursor to the specified line and column.
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3560 * Returns 0 when the position could be set, -1 otherwise.
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3561 */
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3562 static void
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3563 f_cursor(typval_T *argvars, typval_T *rettv)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3564 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3565 set_cursorpos(argvars, rettv, FALSE);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3566 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
3567
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3568 #ifdef MSWIN
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3569 /*
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3570 * "debugbreak()" function
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3571 */
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3572 static void
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3573 f_debugbreak(typval_T *argvars, typval_T *rettv)
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3574 {
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3575 int pid;
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3576
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3577 rettv->vval.v_number = FAIL;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3578 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3579 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3580
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3581 pid = (int)tv_get_number(&argvars[0]);
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3582 if (pid == 0)
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
3583 emsg(_(e_invalid_argument));
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3584 else
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3585 {
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3586 HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3587
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3588 if (hProcess != NULL)
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3589 {
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3590 DebugBreakProcess(hProcess);
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3591 CloseHandle(hProcess);
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3592 rettv->vval.v_number = OK;
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3593 }
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3594 }
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3595 }
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3596 #endif
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
3597
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3598 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3599 * "deepcopy()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3600 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3601 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3602 f_deepcopy(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3603 {
23650
83a69ada0274 patch 8.2.2367: test failures on some less often used systems
Bram Moolenaar <Bram@vim.org>
parents: 23642
diff changeset
3604 varnumber_T noref = 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3605 int copyID;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3606
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
3607 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
3608 && (check_for_opt_bool_arg(argvars, 1) == FAIL))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
3609 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
3610
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3611 if (argvars[1].v_type != VAR_UNKNOWN)
23650
83a69ada0274 patch 8.2.2367: test failures on some less often used systems
Bram Moolenaar <Bram@vim.org>
parents: 23642
diff changeset
3612 noref = tv_get_bool_chk(&argvars[1], NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3613 if (noref < 0 || noref > 1)
22405
0ef3ae4ec70e patch 8.2.1751: using 2 where bool is expected may throw an error
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
3614 semsg(_(e_using_number_as_bool_nr), noref);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3615 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3616 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3617 copyID = get_copyID();
27517
f00a7a2bee21 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents: 27503
diff changeset
3618 item_copy(&argvars[0], rettv, TRUE, TRUE, noref == 0 ? copyID : 0);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3619 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3620 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3621
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3622 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3623 * "did_filetype()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3624 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3625 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3626 f_did_filetype(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3627 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3628 rettv->vval.v_number = did_filetype;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3629 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3630
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3631 /*
19400
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3632 * "echoraw({expr})" function
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3633 */
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3634 static void
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3635 f_echoraw(typval_T *argvars, typval_T *rettv UNUSED)
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3636 {
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
3637 char_u *str;
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
3638
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
3639 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
3640 return;
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
3641
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
3642 str = tv_get_string_chk(&argvars[0]);
19400
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3643 if (str != NULL && *str != NUL)
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3644 {
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3645 out_str(str);
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3646 out_flush();
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3647 }
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3648 }
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3649
bd9069d21c5d patch 8.2.0258: modifyOtherKeys cannot be temporarily disabled
Bram Moolenaar <Bram@vim.org>
parents: 19398
diff changeset
3650 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3651 * "empty({expr})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3652 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3653 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3654 f_empty(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3655 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3656 int n = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3657
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3658 switch (argvars[0].v_type)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3659 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3660 case VAR_STRING:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3661 case VAR_FUNC:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3662 n = argvars[0].vval.v_string == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3663 || *argvars[0].vval.v_string == NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3664 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3665 case VAR_PARTIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3666 n = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3667 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3668 case VAR_NUMBER:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3669 n = argvars[0].vval.v_number == 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3670 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3671 case VAR_FLOAT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3672 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3673 n = argvars[0].vval.v_float == 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3674 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3675 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3676 case VAR_LIST:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3677 n = argvars[0].vval.v_list == NULL
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
3678 || argvars[0].vval.v_list->lv_len == 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3679 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3680 case VAR_DICT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3681 n = argvars[0].vval.v_dict == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3682 || argvars[0].vval.v_dict->dv_hashtab.ht_used == 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3683 break;
19102
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
3684 case VAR_BOOL:
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3685 case VAR_SPECIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3686 n = argvars[0].vval.v_number != VVAL_TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3687 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3688
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3689 case VAR_BLOB:
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3690 n = argvars[0].vval.v_blob == NULL
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3691 || argvars[0].vval.v_blob->bv_ga.ga_len == 0;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3692 break;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3693
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3694 case VAR_JOB:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3695 #ifdef FEAT_JOB_CHANNEL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3696 n = argvars[0].vval.v_job == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3697 || argvars[0].vval.v_job->jv_status != JOB_STARTED;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3698 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3699 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3700 case VAR_CHANNEL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3701 #ifdef FEAT_JOB_CHANNEL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3702 n = argvars[0].vval.v_channel == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3703 || !channel_is_open(argvars[0].vval.v_channel);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3704 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3705 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3706 case VAR_UNKNOWN:
19922
1f42c49c3d29 patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents: 19920
diff changeset
3707 case VAR_ANY:
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
3708 case VAR_VOID:
24606
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24307
diff changeset
3709 case VAR_INSTR:
19554
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
3710 internal_error_no_abort("f_empty(UNKNOWN)");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3711 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3712 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3713 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3714
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3715 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3716 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3717
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3718 /*
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3719 * "environ()" function
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3720 */
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3721 static void
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3722 f_environ(typval_T *argvars UNUSED, typval_T *rettv)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3723 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3724 #if !defined(AMIGA)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3725 int i = 0;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3726 char_u *entry, *value;
28489
922cd0dced4b patch 8.2.4769: build warning with UCRT
Bram Moolenaar <Bram@vim.org>
parents: 28467
diff changeset
3727 # if defined (MSWIN)
922cd0dced4b patch 8.2.4769: build warning with UCRT
Bram Moolenaar <Bram@vim.org>
parents: 28467
diff changeset
3728 # if !defined(_UCRT)
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3729 extern wchar_t **_wenviron;
28489
922cd0dced4b patch 8.2.4769: build warning with UCRT
Bram Moolenaar <Bram@vim.org>
parents: 28467
diff changeset
3730 # endif
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3731 # else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3732 extern char **environ;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3733 # endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3734
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
3735 if (rettv_dict_alloc(rettv) == FAIL)
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3736 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3737
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3738 # ifdef MSWIN
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3739 if (*_wenviron == NULL)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3740 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3741 # else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3742 if (*environ == NULL)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3743 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3744 # endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3745
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3746 for (i = 0; ; ++i)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3747 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3748 # ifdef MSWIN
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3749 short_u *p;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3750
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3751 if ((p = (short_u *)_wenviron[i]) == NULL)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3752 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3753 entry = utf16_to_enc(p, NULL);
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3754 # else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3755 if ((entry = (char_u *)environ[i]) == NULL)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3756 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3757 entry = vim_strsave(entry);
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3758 # endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3759 if (entry == NULL) // out of memory
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3760 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3761 if ((value = vim_strchr(entry, '=')) == NULL)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3762 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3763 vim_free(entry);
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3764 continue;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3765 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3766 *value++ = NUL;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3767 dict_add_string(rettv->vval.v_dict, (char *)entry, value);
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3768 vim_free(entry);
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3769 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3770 #endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3771 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3772
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
3773 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3774 * "escape({string}, {chars})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3775 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3776 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3777 f_escape(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3778 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3779 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3780
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3781 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3782 && (check_for_string_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3783 || check_for_string_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3784 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3785
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3786 rettv->vval.v_string = vim_strsave_escaped(tv_get_string(&argvars[0]),
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3787 tv_get_string_buf(&argvars[1], buf));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3788 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3789 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3790
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3791 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3792 * "eval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3793 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3794 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3795 f_eval(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3796 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3797 char_u *s, *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3798
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3799 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3800 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
3801
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3802 s = tv_get_string_chk(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3803 if (s != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3804 s = skipwhite(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3805
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3806 p = s;
20992
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20968
diff changeset
3807 if (s == NULL || eval1(&s, rettv, &EVALARG_EVALUATE) == FAIL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3808 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3809 if (p != NULL && !aborting())
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25060
diff changeset
3810 semsg(_(e_invalid_expression_str), p);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3811 need_clr_eos = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3812 rettv->v_type = VAR_NUMBER;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3813 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3814 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3815 else if (*s != NUL)
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
3816 semsg(_(e_trailing_characters_str), s);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3817 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3818
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3819 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3820 * "eventhandler()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3821 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3822 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3823 f_eventhandler(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3824 {
20213
8d9229c4781a patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
3825 rettv->vval.v_number = vgetc_busy || input_busy;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3826 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3827
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3828 static garray_T redir_execute_ga;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3829
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3830 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3831 * Append "value[value_len]" to the execute() output.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3832 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3833 void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3834 execute_redir_str(char_u *value, int value_len)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3835 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3836 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3837
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3838 if (value_len == -1)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3839 len = (int)STRLEN(value); // Append the entire string
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3840 else
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3841 len = value_len; // Append only "value_len" characters
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3842 if (ga_grow(&redir_execute_ga, len) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3843 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3844 mch_memmove((char *)redir_execute_ga.ga_data
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3845 + redir_execute_ga.ga_len, value, len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3846 redir_execute_ga.ga_len += len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3847 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3848 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3849
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
3850 #if defined(FEAT_LUA) || defined(PROTO)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3851 /*
25527
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3852 * Get next line from a string containing NL separated lines.
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3853 * Called by do_cmdline() to get the next line.
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3854 * Returns an allocated string, or NULL when at the end of the string.
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3855 */
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3856 static char_u *
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3857 get_str_line(
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3858 int c UNUSED,
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3859 void *cookie,
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3860 int indent UNUSED,
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3861 getline_opt_T options UNUSED)
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3862 {
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3863 char_u *start = *(char_u **)cookie;
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3864 char_u *line;
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3865 char_u *p;
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3866
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3867 p = start;
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3868 if (p == NULL || *p == NUL)
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3869 return NULL;
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3870 p = vim_strchr(p, '\n');
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3871 if (p == NULL)
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3872 line = vim_strsave(start);
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3873 else
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3874 {
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3875 line = vim_strnsave(start, p - start);
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3876 p++;
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3877 }
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3878
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3879 *(char_u **)cookie = p;
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3880 return line;
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3881 }
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3882
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3883 /*
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3884 * Execute a series of Ex commands in 'str'
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3885 */
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3886 void
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3887 execute_cmds_from_string(char_u *str)
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3888 {
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3889 do_cmdline(NULL, get_str_line, (void *)&str,
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3890 DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT|DOCMD_KEYTYPED);
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3891 }
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26978
diff changeset
3892 #endif
25527
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3893
d5e9c05b4811 patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents: 25525
diff changeset
3894 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3895 * Get next line from a list.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3896 * Called by do_cmdline() to get the next line.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3897 * Returns allocated string, or NULL for end of function.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3898 */
28775
7fd3a9f05037 patch 8.2.4912: using execute() to define a lambda doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 28773
diff changeset
3899 char_u *
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3900 get_list_line(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3901 int c UNUSED,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3902 void *cookie,
17178
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17170
diff changeset
3903 int indent UNUSED,
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
3904 getline_opt_T options UNUSED)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3905 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3906 listitem_T **p = (listitem_T **)cookie;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3907 listitem_T *item = *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3908 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3909 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3910
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3911 if (item == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3912 return NULL;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3913 s = tv_get_string_buf_chk(&item->li_tv, buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3914 *p = item->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3915 return s == NULL ? NULL : vim_strsave(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3916 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3917
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3918 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3919 * "execute()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3920 */
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
3921 void
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
3922 execute_common(typval_T *argvars, typval_T *rettv, int arg_off)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3923 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3924 char_u *cmd = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3925 list_T *list = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3926 int save_msg_silent = msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3927 int save_emsg_silent = emsg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3928 int save_emsg_noredir = emsg_noredir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3929 int save_redir_execute = redir_execute;
13101
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 13088
diff changeset
3930 int save_redir_off = redir_off;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3931 garray_T save_ga;
15117
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15062
diff changeset
3932 int save_msg_col = msg_col;
15121
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
3933 int echo_output = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3934
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3935 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3936 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3937
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
3938 if (argvars[arg_off].v_type == VAR_LIST)
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
3939 {
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
3940 list = argvars[arg_off].vval.v_list;
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
3941 if (list == NULL || list->lv_len == 0)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3942 // empty list, no commands, empty output
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3943 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3944 ++list->lv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3945 }
19085
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 19033
diff changeset
3946 else if (argvars[arg_off].v_type == VAR_JOB
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 19033
diff changeset
3947 || argvars[arg_off].v_type == VAR_CHANNEL)
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 19033
diff changeset
3948 {
24614
07b3d21a8b4b patch 8.2.2846: Vim9: "echo Func()" does not give an error for using void
Bram Moolenaar <Bram@vim.org>
parents: 24606
diff changeset
3949 semsg(_(e_using_invalid_value_as_string_str),
07b3d21a8b4b patch 8.2.2846: Vim9: "echo Func()" does not give an error for using void
Bram Moolenaar <Bram@vim.org>
parents: 24606
diff changeset
3950 vartype_name(argvars[arg_off].v_type));
19085
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 19033
diff changeset
3951 return;
fd1070ff696b patch 8.2.0103: using null object with execute() has strange effects
Bram Moolenaar <Bram@vim.org>
parents: 19033
diff changeset
3952 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3953 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3954 {
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
3955 cmd = tv_get_string_chk(&argvars[arg_off]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3956 if (cmd == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3957 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3958 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3959
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
3960 if (argvars[arg_off + 1].v_type != VAR_UNKNOWN)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3961 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3962 char_u buf[NUMBUFLEN];
24822
5f8dd7b3ae41 patch 8.2.2949: tests failing because no error for float to string conversion
Bram Moolenaar <Bram@vim.org>
parents: 24780
diff changeset
3963 char_u *s = tv_get_string_buf_chk_strict(&argvars[arg_off + 1], buf,
5f8dd7b3ae41 patch 8.2.2949: tests failing because no error for float to string conversion
Bram Moolenaar <Bram@vim.org>
parents: 24780
diff changeset
3964 in_vim9script());
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3965
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3966 if (s == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3967 return;
15121
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
3968 if (*s == NUL)
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
3969 echo_output = TRUE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3970 if (STRNCMP(s, "silent", 6) == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3971 ++msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3972 if (STRCMP(s, "silent!") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3973 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3974 emsg_silent = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3975 emsg_noredir = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3976 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3977 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3978 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3979 ++msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3980
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3981 if (redir_execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3982 save_ga = redir_execute_ga;
27028
c9474ae175f4 patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
3983 ga_init2(&redir_execute_ga, sizeof(char), 500);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3984 redir_execute = TRUE;
13101
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 13088
diff changeset
3985 redir_off = FALSE;
15121
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
3986 if (!echo_output)
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
3987 msg_col = 0; // prevent leading spaces
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3988
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3989 if (cmd != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3990 do_cmdline_cmd(cmd);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3991 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3992 {
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
3993 listitem_T *item;
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
3994
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
3995 CHECK_LIST_MATERIALIZE(list);
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
3996 item = list->lv_first;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3997 do_cmdline(NULL, get_list_line, (void *)&item,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3998 DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT|DOCMD_KEYTYPED);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3999 --list->lv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4000 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4001
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4002 // Need to append a NUL to the result.
10749
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
4003 if (ga_grow(&redir_execute_ga, 1) == OK)
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
4004 {
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
4005 ((char *)redir_execute_ga.ga_data)[redir_execute_ga.ga_len] = NUL;
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
4006 rettv->vval.v_string = redir_execute_ga.ga_data;
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
4007 }
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
4008 else
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
4009 {
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
4010 ga_clear(&redir_execute_ga);
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
4011 rettv->vval.v_string = NULL;
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
4012 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4013 msg_silent = save_msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4014 emsg_silent = save_emsg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4015 emsg_noredir = save_emsg_noredir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4016
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4017 redir_execute = save_redir_execute;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4018 if (redir_execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4019 redir_execute_ga = save_ga;
13101
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 13088
diff changeset
4020 redir_off = save_redir_off;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4021
15117
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15062
diff changeset
4022 // "silent reg" or "silent echo x" leaves msg_col somewhere in the line.
15121
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
4023 if (echo_output)
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
4024 // When not working silently: put it in column zero. A following
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
4025 // "echon" will overwrite the message, unavoidably.
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
4026 msg_col = 0;
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
4027 else
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
4028 // When working silently: Put it back where it was, since nothing
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
4029 // should have been written.
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
4030 msg_col = save_msg_col;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4031 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4032
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4033 /*
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
4034 * "execute()" function
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
4035 */
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
4036 static void
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
4037 f_execute(typval_T *argvars, typval_T *rettv)
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
4038 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4039 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4040 && (check_for_string_or_list_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4041 || check_for_opt_string_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4042 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4043
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
4044 execute_common(argvars, rettv, 0);
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
4045 }
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
4046
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
4047 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4048 * "exists()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4049 */
25479
fbdfa533001c patch 8.2.3276: Vim9: exists() can only be evaluated at runtime
Bram Moolenaar <Bram@vim.org>
parents: 25465
diff changeset
4050 void
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4051 f_exists(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4052 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4053 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4054 int n = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4055
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4056 if (in_vim9script() && check_for_nonempty_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4057 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4058
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4059 p = tv_get_string(&argvars[0]);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4060 if (*p == '$') // environment variable
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4061 {
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4062 // first try "normal" environment variables (fast)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4063 if (mch_getenv(p + 1) != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4064 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4065 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4066 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4067 // try expanding things like $VIM and ${HOME}
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4068 p = expand_env_save(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4069 if (p != NULL && *p != '$')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4070 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4071 vim_free(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4072 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4073 }
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4074 else if (*p == '&' || *p == '+') // option
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4075 {
21120
4d844a65183d patch 8.2.1111: inconsistent naming of get_list_tv() and eval_dict()
Bram Moolenaar <Bram@vim.org>
parents: 21089
diff changeset
4076 n = (eval_option(&p, NULL, TRUE) == OK);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4077 if (*skipwhite(p) != NUL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4078 n = FALSE; // trailing garbage
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4079 }
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4080 else if (*p == '*') // internal or user defined function
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4081 {
9717
6226de5f8137 commit https://github.com/vim/vim/commit/b54c3ff3174dbb5dfbfcabdf95200b047beaa644
Christian Brabandt <cb@256bit.org>
parents: 9707
diff changeset
4082 n = function_exists(p + 1, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4083 }
19805
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
4084 else if (*p == '?') // internal function only
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
4085 {
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
4086 n = has_internal_func_name(p + 1);
2dc5e6ddeb4c patch 8.2.0459: cannot check if a function name is correct
Bram Moolenaar <Bram@vim.org>
parents: 19742
diff changeset
4087 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4088 else if (*p == ':')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4089 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4090 n = cmd_exists(p + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4091 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4092 else if (*p == '#')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4093 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4094 if (p[1] == '#')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4095 n = autocmd_supported(p + 2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4096 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4097 n = au_exists(p + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4098 }
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4099 else // internal variable
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4100 {
13262
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13248
diff changeset
4101 n = var_exists(p);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4102 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4103
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4104 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4105 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4106
25555
446f478d6fb1 patch 8.2.3314: behavior of exists() in a :def function is unpredictable
Bram Moolenaar <Bram@vim.org>
parents: 25527
diff changeset
4107 static void
446f478d6fb1 patch 8.2.3314: behavior of exists() in a :def function is unpredictable
Bram Moolenaar <Bram@vim.org>
parents: 25527
diff changeset
4108 f_exists_compiled(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
446f478d6fb1 patch 8.2.3314: behavior of exists() in a :def function is unpredictable
Bram Moolenaar <Bram@vim.org>
parents: 25527
diff changeset
4109 {
446f478d6fb1 patch 8.2.3314: behavior of exists() in a :def function is unpredictable
Bram Moolenaar <Bram@vim.org>
parents: 25527
diff changeset
4110 emsg(_(e_exists_compiled_can_only_be_used_in_def_function));
446f478d6fb1 patch 8.2.3314: behavior of exists() in a :def function is unpredictable
Bram Moolenaar <Bram@vim.org>
parents: 25527
diff changeset
4111 }
446f478d6fb1 patch 8.2.3314: behavior of exists() in a :def function is unpredictable
Bram Moolenaar <Bram@vim.org>
parents: 25527
diff changeset
4112
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4113 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4114 * "expand()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4115 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4116 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4117 f_expand(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4118 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4119 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4120 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4121 int options = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4122 expand_T xpc;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4123 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4124 char_u *result;
22397
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22385
diff changeset
4125 #ifdef BACKSLASH_IN_FILENAME
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22385
diff changeset
4126 char_u *p_csl_save = p_csl;
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
4127 #endif
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
4128
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
4129 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
4130 && (check_for_string_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
4131 || check_for_opt_bool_arg(argvars, 1) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
4132 || (argvars[1].v_type != VAR_UNKNOWN
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
4133 && check_for_opt_bool_arg(argvars, 2) == FAIL)))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
4134 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
4135
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
4136 #ifdef BACKSLASH_IN_FILENAME
22397
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22385
diff changeset
4137 // avoid using 'completeslash' here
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22385
diff changeset
4138 p_csl = empty_option;
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22385
diff changeset
4139 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4140
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4141 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4142 if (argvars[1].v_type != VAR_UNKNOWN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4143 && argvars[2].v_type != VAR_UNKNOWN
22045
47ff9e5be532 patch 8.2.1572: Vim9: expand() does not take "true" as argument
Bram Moolenaar <Bram@vim.org>
parents: 22039
diff changeset
4144 && tv_get_bool_chk(&argvars[2], &error)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4145 && !error)
11418
162bcd0debd7 patch 8.0.0593: duplication of code for adding a list or dict return value
Christian Brabandt <cb@256bit.org>
parents: 11341
diff changeset
4146 rettv_list_set(rettv, NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4147
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4148 s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4149 if (*s == '%' || *s == '#' || *s == '<')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4150 {
28431
4fbdd4ce9edb patch 8.2.4740: when expand() fails there is no error message
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
4151 char *errormsg = NULL;
4fbdd4ce9edb patch 8.2.4740: when expand() fails there is no error message
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
4152
4fbdd4ce9edb patch 8.2.4740: when expand() fails there is no error message
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
4153 if (p_verbose == 0)
4fbdd4ce9edb patch 8.2.4740: when expand() fails there is no error message
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
4154 ++emsg_off;
28635
dfe18756f2ad patch 8.2.4841: empty string considered an error for expand()
Bram Moolenaar <Bram@vim.org>
parents: 28629
diff changeset
4155 result = eval_vars(s, s, &len, NULL, &errormsg, NULL, FALSE);
28431
4fbdd4ce9edb patch 8.2.4740: when expand() fails there is no error message
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
4156 if (p_verbose == 0)
4fbdd4ce9edb patch 8.2.4740: when expand() fails there is no error message
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
4157 --emsg_off;
4fbdd4ce9edb patch 8.2.4740: when expand() fails there is no error message
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
4158 else if (errormsg != NULL)
4fbdd4ce9edb patch 8.2.4740: when expand() fails there is no error message
Bram Moolenaar <Bram@vim.org>
parents: 28413
diff changeset
4159 emsg(errormsg);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4160 if (rettv->v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4161 {
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
4162 if (rettv_list_alloc(rettv) == OK && result != NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4163 list_append_string(rettv->vval.v_list, result, -1);
18225
6c3a8312486d patch 8.1.2107: various memory leaks reported by asan
Bram Moolenaar <Bram@vim.org>
parents: 18203
diff changeset
4164 vim_free(result);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4165 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4166 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4167 rettv->vval.v_string = result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4168 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4169 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4170 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4171 // When the optional second argument is non-zero, don't remove matches
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4172 // for 'wildignore' and don't put matches for 'suffixes' at the end.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4173 if (argvars[1].v_type != VAR_UNKNOWN
22045
47ff9e5be532 patch 8.2.1572: Vim9: expand() does not take "true" as argument
Bram Moolenaar <Bram@vim.org>
parents: 22039
diff changeset
4174 && tv_get_bool_chk(&argvars[1], &error))
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4175 options |= WILD_KEEP_ALL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4176 if (!error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4177 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4178 ExpandInit(&xpc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4179 xpc.xp_context = EXPAND_FILES;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4180 if (p_wic)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4181 options += WILD_ICASE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4182 if (rettv->v_type == VAR_STRING)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4183 rettv->vval.v_string = ExpandOne(&xpc, s, NULL,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4184 options, WILD_ALL);
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
4185 else if (rettv_list_alloc(rettv) == OK)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4186 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4187 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4188
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4189 ExpandOne(&xpc, s, NULL, options, WILD_ALL_KEEP);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4190 for (i = 0; i < xpc.xp_numfiles; i++)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4191 list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4192 ExpandCleanup(&xpc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4193 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4194 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4195 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4196 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4197 }
22397
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22385
diff changeset
4198 #ifdef BACKSLASH_IN_FILENAME
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22385
diff changeset
4199 p_csl = p_csl_save;
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22385
diff changeset
4200 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4201 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4202
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4203 /*
17020
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4204 * "expandcmd()" function
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4205 * Expand all the special characters in a command string.
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4206 */
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4207 static void
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4208 f_expandcmd(typval_T *argvars, typval_T *rettv)
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4209 {
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4210 exarg_T eap;
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4211 char_u *cmdstr;
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4212 char *errormsg = NULL;
28307
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4213 int emsgoff = TRUE;
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4214
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4215 if (in_vim9script()
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4216 && (check_for_string_arg(argvars, 0) == FAIL
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4217 || check_for_opt_dict_arg(argvars, 1) == FAIL))
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4218 return;
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4219
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4220 if (argvars[1].v_type == VAR_DICT
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4221 && dict_get_bool(argvars[1].vval.v_dict, (char_u *)"errmsg",
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4222 VVAL_FALSE))
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4223 emsgoff = FALSE;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4224
17020
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4225 rettv->v_type = VAR_STRING;
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4226 cmdstr = vim_strsave(tv_get_string(&argvars[0]));
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4227
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4228 memset(&eap, 0, sizeof(eap));
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4229 eap.cmd = cmdstr;
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4230 eap.arg = cmdstr;
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
4231 eap.argt |= EX_NOSPC;
17020
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4232 eap.usefilter = FALSE;
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4233 eap.nextcmd = NULL;
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4234 eap.cmdidx = CMD_USER;
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4235
28307
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4236 if (emsgoff)
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4237 ++emsg_off;
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4238 if (expand_filename(&eap, &cmdstr, &errormsg) == FAIL)
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4239 if (!emsgoff && errormsg != NULL && *errormsg != NUL)
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4240 emsg(errormsg);
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4241 if (emsgoff)
425700af491b patch 8.2.4679: cannot have expandcmd() give an error message for mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28303
diff changeset
4242 --emsg_off;
17020
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4243
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4244 rettv->vval.v_string = cmdstr;
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4245 }
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4246
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
4247 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4248 * "feedkeys()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4249 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4250 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4251 f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4252 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4253 int remap = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4254 int insert = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4255 char_u *keys, *flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4256 char_u nbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4257 int typed = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4258 int execute = FALSE;
27156
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4259 int context = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4260 int dangerous = FALSE;
15615
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
4261 int lowlevel = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4262 char_u *keys_esc;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4263
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4264 // This is not allowed in the sandbox. If the commands would still be
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4265 // executed in the sandbox it would be OK, but it probably happens later,
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4266 // when "sandbox" is no longer set.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4267 if (check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4268 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4269
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4270 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4271 && (check_for_string_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4272 || check_for_opt_string_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4273 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4274
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4275 keys = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4276
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4277 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4278 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4279 flags = tv_get_string_buf(&argvars[1], nbuf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4280 for ( ; *flags != NUL; ++flags)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4281 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4282 switch (*flags)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4283 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4284 case 'n': remap = FALSE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4285 case 'm': remap = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4286 case 't': typed = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4287 case 'i': insert = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4288 case 'x': execute = TRUE; break;
27156
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4289 case 'c': context = TRUE; break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4290 case '!': dangerous = TRUE; break;
15615
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
4291 case 'L': lowlevel = TRUE; break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4292 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4293 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4294 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4295
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4296 if (*keys != NUL || execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4297 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4298 // Need to escape K_SPECIAL and CSI before putting the string in the
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4299 // typeahead buffer.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4300 keys_esc = vim_strsave_escape_csi(keys);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4301 if (keys_esc != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4302 {
15615
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
4303 if (lowlevel)
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
4304 {
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
4305 #ifdef USE_INPUT_BUF
19730
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4306 int idx;
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4307 int len = (int)STRLEN(keys);
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4308
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4309 for (idx = 0; idx < len; ++idx)
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4310 {
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4311 // if a CTRL-C was typed, set got_int, similar to what
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4312 // happens in fill_input_buf()
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4313 if (keys[idx] == 3 && ctrl_c_interrupts && typed)
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4314 got_int = TRUE;
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4315 add_to_input_buf(keys + idx, 1);
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19677
diff changeset
4316 }
15615
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
4317 #else
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
4318 emsg(_(e_lowlevel_input_not_supported));
15615
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
4319 #endif
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
4320 }
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
4321 else
15687
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
4322 {
15615
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
4323 ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4324 insert ? 0 : typebuf.tb_len, !typed, FALSE);
15687
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
4325 if (vgetc_busy
11583
ef8b233f07ae patch 8.0.0674: cannot build with eval but without timers
Christian Brabandt <cb@256bit.org>
parents: 11575
diff changeset
4326 #ifdef FEAT_TIMERS
15687
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
4327 || timer_busy
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
4328 #endif
20213
8d9229c4781a patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
4329 || input_busy)
15687
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
4330 typebuf_was_filled = TRUE;
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
4331 }
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
4332 vim_free(keys_esc);
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
4333
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4334 if (execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4335 {
27156
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4336 int save_msg_scroll = msg_scroll;
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4337 sctx_T save_sctx;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4338
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4339 // Avoid a 1 second delay when the keys start Insert mode.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4340 msg_scroll = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4341
27156
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4342 if (context)
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4343 {
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4344 save_sctx = current_sctx;
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4345 current_sctx.sc_sid = 0;
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4346 current_sctx.sc_version = 0;
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4347 }
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4348
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
4349 if (!dangerous)
22442
73be82f278c0 patch 8.2.1769: popup filter interferes with using :normal to move the cursor
Bram Moolenaar <Bram@vim.org>
parents: 22405
diff changeset
4350 {
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
4351 ++ex_normal_busy;
22442
73be82f278c0 patch 8.2.1769: popup filter interferes with using :normal to move the cursor
Bram Moolenaar <Bram@vim.org>
parents: 22405
diff changeset
4352 ++in_feedkeys;
73be82f278c0 patch 8.2.1769: popup filter interferes with using :normal to move the cursor
Bram Moolenaar <Bram@vim.org>
parents: 22405
diff changeset
4353 }
16263
d3377393e3d9 patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16253
diff changeset
4354 exec_normal(TRUE, lowlevel, TRUE);
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
4355 if (!dangerous)
22361
00f2eebe74d9 patch 8.2.1729: endless loop when ":normal" feeds popup window filter
Bram Moolenaar <Bram@vim.org>
parents: 22357
diff changeset
4356 {
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
4357 --ex_normal_busy;
22442
73be82f278c0 patch 8.2.1769: popup filter interferes with using :normal to move the cursor
Bram Moolenaar <Bram@vim.org>
parents: 22405
diff changeset
4358 --in_feedkeys;
22361
00f2eebe74d9 patch 8.2.1729: endless loop when ":normal" feeds popup window filter
Bram Moolenaar <Bram@vim.org>
parents: 22357
diff changeset
4359 }
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
4360
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4361 msg_scroll |= save_msg_scroll;
27156
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4362
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4363 if (context)
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27114
diff changeset
4364 current_sctx = save_sctx;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4365 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4366 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4367 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4368 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4369
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4370 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4371 * "fnameescape({string})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4372 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4373 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4374 f_fnameescape(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4375 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4376 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4377 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4378
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4379 rettv->vval.v_string = vim_strsave_fnameescape(
25994
e8873138ffbb patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents: 25953
diff changeset
4380 tv_get_string(&argvars[0]), VSE_NONE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4381 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4382 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4383
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4384 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4385 * "foreground()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4386 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4387 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4388 f_foreground(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4389 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4390 #ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4391 if (gui.in_use)
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
4392 {
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4393 gui_mch_set_foreground();
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
4394 return;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
4395 }
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
4396 #endif
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
4397 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4398 win32_set_foreground();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4399 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4400 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4401
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4402 static void
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4403 common_function(typval_T *argvars, typval_T *rettv, int is_funcref)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4404 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4405 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4406 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4407 int use_string = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4408 partial_T *arg_pt = NULL;
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4409 char_u *trans_name = NULL;
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
4410 int is_global = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4411
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
4412 if (in_vim9script()
26733
3aa38eaa5a11 patch 8.2.3895: Vim9: confusing error when using function() with a number
Bram Moolenaar <Bram@vim.org>
parents: 26731
diff changeset
4413 && (check_for_string_or_func_arg(argvars, 0) == FAIL
3aa38eaa5a11 patch 8.2.3895: Vim9: confusing error when using function() with a number
Bram Moolenaar <Bram@vim.org>
parents: 26731
diff changeset
4414 || check_for_opt_list_arg(argvars, 1) == FAIL
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
4415 || (argvars[1].v_type != VAR_UNKNOWN
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
4416 && check_for_opt_dict_arg(argvars, 2) == FAIL)))
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
4417 return;
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
4418
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4419 if (argvars[0].v_type == VAR_FUNC)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4420 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4421 // function(MyFunc, [arg], dict)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4422 s = argvars[0].vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4423 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4424 else if (argvars[0].v_type == VAR_PARTIAL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4425 && argvars[0].vval.v_partial != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4426 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4427 // function(dict.MyFunc, [arg])
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4428 arg_pt = argvars[0].vval.v_partial;
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4429 s = partial_name(arg_pt);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4430 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4431 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4432 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4433 // function('MyFunc', [arg], dict)
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4434 s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4435 use_string = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4436 }
25688
c07b6c54146a patch 8.2.3380: crash when using NULL string for funcref()
Bram Moolenaar <Bram@vim.org>
parents: 25648
diff changeset
4437 if (s == NULL)
c07b6c54146a patch 8.2.3380: crash when using NULL string for funcref()
Bram Moolenaar <Bram@vim.org>
parents: 25648
diff changeset
4438 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
4439 semsg(_(e_invalid_argument_str), "NULL");
25688
c07b6c54146a patch 8.2.3380: crash when using NULL string for funcref()
Bram Moolenaar <Bram@vim.org>
parents: 25648
diff changeset
4440 return;
c07b6c54146a patch 8.2.3380: crash when using NULL string for funcref()
Bram Moolenaar <Bram@vim.org>
parents: 25648
diff changeset
4441 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4442
9919
885e3c9c0e10 commit https://github.com/vim/vim/commit/843b884461de1c79a1d2748549776fb13fc94360
Christian Brabandt <cb@256bit.org>
parents: 9904
diff changeset
4443 if ((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL) || is_funcref)
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4444 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4445 name = s;
26348
bf1a7ce3f14a patch 8.2.3705: cannot pass a lambda name to function() or funcref()
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
4446 trans_name = save_function_name(&name, &is_global, FALSE,
bf1a7ce3f14a patch 8.2.3705: cannot pass a lambda name to function() or funcref()
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
4447 TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD | TFN_NO_DEREF, NULL);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4448 if (*name != NUL)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4449 s = NULL;
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4450 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4451
9919
885e3c9c0e10 commit https://github.com/vim/vim/commit/843b884461de1c79a1d2748549776fb13fc94360
Christian Brabandt <cb@256bit.org>
parents: 9904
diff changeset
4452 if (s == NULL || *s == NUL || (use_string && VIM_ISDIGIT(*s))
885e3c9c0e10 commit https://github.com/vim/vim/commit/843b884461de1c79a1d2748549776fb13fc94360
Christian Brabandt <cb@256bit.org>
parents: 9904
diff changeset
4453 || (is_funcref && trans_name == NULL))
27986
c724906134a3 patch 8.2.4518: the binary tag search feature is always enabled
Bram Moolenaar <Bram@vim.org>
parents: 27867
diff changeset
4454 semsg(_(e_invalid_argument_str),
c724906134a3 patch 8.2.4518: the binary tag search feature is always enabled
Bram Moolenaar <Bram@vim.org>
parents: 27867
diff changeset
4455 use_string ? tv_get_string(&argvars[0]) : s);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4456 // Don't check an autoload name for existence here.
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4457 else if (trans_name != NULL && (is_funcref
27114
98a01021e465 patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused
Bram Moolenaar <Bram@vim.org>
parents: 27047
diff changeset
4458 ? find_func(trans_name, is_global) == NULL
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
4459 : !translated_function_exists(trans_name, is_global)))
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26950
diff changeset
4460 semsg(_(e_unknown_function_str_2), s);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4461 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4462 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4463 int dict_idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4464 int arg_idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4465 list_T *list = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4466
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4467 if (STRNCMP(s, "s:", 2) == 0 || STRNCMP(s, "<SID>", 5) == 0)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4468 // Expand s: and <SID> into <SNR>nr_, so that the function can
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4469 // also be called from another script. Using trans_function_name()
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4470 // would also work, but some plugins depend on the name being
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4471 // printable text.
26721
9c9b8d95b05f patch 8.2.3889: duplicate code for translating script-local function name
Bram Moolenaar <Bram@vim.org>
parents: 26706
diff changeset
4472 name = get_scriptlocal_funcname(s);
27807
292a6bd86c30 patch 8.2.4429: using script-local function from the wrong script
Bram Moolenaar <Bram@vim.org>
parents: 27800
diff changeset
4473 else if (trans_name != NULL && *trans_name == K_SPECIAL)
292a6bd86c30 patch 8.2.4429: using script-local function from the wrong script
Bram Moolenaar <Bram@vim.org>
parents: 27800
diff changeset
4474 name = alloc_printable_func_name(trans_name);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4475 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4476 name = vim_strsave(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4477
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4478 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4479 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4480 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4481 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4482 // function(name, [args], dict)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4483 arg_idx = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4484 dict_idx = 2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4485 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4486 else if (argvars[1].v_type == VAR_DICT)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4487 // function(name, dict)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4488 dict_idx = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4489 else
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4490 // function(name, [args])
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4491 arg_idx = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4492 if (dict_idx > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4493 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4494 if (argvars[dict_idx].v_type != VAR_DICT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4495 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
4496 emsg(_(e_expected_dict));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4497 vim_free(name);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4498 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4499 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4500 if (argvars[dict_idx].vval.v_dict == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4501 dict_idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4502 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4503 if (arg_idx > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4504 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4505 if (argvars[arg_idx].v_type != VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4506 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
4507 emsg(_(e_second_argument_of_function_must_be_list_or_dict));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4508 vim_free(name);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4509 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4510 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4511 list = argvars[arg_idx].vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4512 if (list == NULL || list->lv_len == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4513 arg_idx = 0;
18576
e9675870c480 patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
4514 else if (list->lv_len > MAX_FUNC_ARGS)
e9675870c480 patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
4515 {
28283
2fd2ce8a556c patch 8.2.4667: expandcmd() fails on an error
Bram Moolenaar <Bram@vim.org>
parents: 27986
diff changeset
4516 emsg_funcname(e_too_many_arguments_for_function_str, s);
18576
e9675870c480 patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
4517 vim_free(name);
e9675870c480 patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
4518 goto theend;
e9675870c480 patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
4519 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4520 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4521 }
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4522 if (dict_idx > 0 || arg_idx > 0 || arg_pt != NULL || is_funcref)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4523 {
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
4524 partial_T *pt = ALLOC_CLEAR_ONE(partial_T);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4525
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4526 // result is a VAR_PARTIAL
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4527 if (pt == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4528 vim_free(name);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4529 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4530 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4531 if (arg_idx > 0 || (arg_pt != NULL && arg_pt->pt_argc > 0))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4532 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4533 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4534 int i = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4535 int arg_len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4536 int lv_len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4537
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4538 if (arg_pt != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4539 arg_len = arg_pt->pt_argc;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4540 if (list != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4541 lv_len = list->lv_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4542 pt->pt_argc = arg_len + lv_len;
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
4543 pt->pt_argv = ALLOC_MULT(typval_T, pt->pt_argc);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4544 if (pt->pt_argv == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4545 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4546 vim_free(pt);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4547 vim_free(name);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4548 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4549 }
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4550 for (i = 0; i < arg_len; i++)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4551 copy_tv(&arg_pt->pt_argv[i], &pt->pt_argv[i]);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4552 if (lv_len > 0)
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
4553 {
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
4554 CHECK_LIST_MATERIALIZE(list);
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
4555 FOR_ALL_LIST_ITEMS(list, li)
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4556 copy_tv(&li->li_tv, &pt->pt_argv[i++]);
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
4557 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4558 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4559
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4560 // For "function(dict.func, [], dict)" and "func" is a partial
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4561 // use "dict". That is backwards compatible.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4562 if (dict_idx > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4563 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4564 // The dict is bound explicitly, pt_auto is FALSE.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4565 pt->pt_dict = argvars[dict_idx].vval.v_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4566 ++pt->pt_dict->dv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4567 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4568 else if (arg_pt != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4569 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4570 // If the dict was bound automatically the result is also
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4571 // bound automatically.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4572 pt->pt_dict = arg_pt->pt_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4573 pt->pt_auto = arg_pt->pt_auto;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4574 if (pt->pt_dict != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4575 ++pt->pt_dict->dv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4576 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4577
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4578 pt->pt_refcount = 1;
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4579 if (arg_pt != NULL && arg_pt->pt_func != NULL)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4580 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4581 pt->pt_func = arg_pt->pt_func;
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4582 func_ptr_ref(pt->pt_func);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4583 vim_free(name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4584 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4585 else if (is_funcref)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4586 {
27114
98a01021e465 patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused
Bram Moolenaar <Bram@vim.org>
parents: 27047
diff changeset
4587 pt->pt_func = find_func(trans_name, is_global);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4588 func_ptr_ref(pt->pt_func);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4589 vim_free(name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4590 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4591 else
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4592 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4593 pt->pt_name = name;
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4594 func_ref(name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4595 }
27589
ecea41486e8a patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents: 27555
diff changeset
4596
ecea41486e8a patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents: 27555
diff changeset
4597 if (arg_pt != NULL)
27591
d91be28bbdbb patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents: 27589
diff changeset
4598 {
d91be28bbdbb patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents: 27589
diff changeset
4599 pt->pt_outer_partial = arg_pt;
d91be28bbdbb patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents: 27589
diff changeset
4600 ++arg_pt->pt_refcount;
d91be28bbdbb patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents: 27589
diff changeset
4601 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4602 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4603 rettv->v_type = VAR_PARTIAL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4604 rettv->vval.v_partial = pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4605 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4606 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4607 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4608 // result is a VAR_FUNC
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4609 rettv->v_type = VAR_FUNC;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4610 rettv->vval.v_string = name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4611 func_ref(name);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4612 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4613 }
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4614 theend:
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4615 vim_free(trans_name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4616 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4617
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4618 /*
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4619 * "funcref()" function
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4620 */
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4621 static void
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4622 f_funcref(typval_T *argvars, typval_T *rettv)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4623 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4624 common_function(argvars, rettv, TRUE);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4625 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4626
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4627 /*
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4628 * "function()" function
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4629 */
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4630 static void
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4631 f_function(typval_T *argvars, typval_T *rettv)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4632 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4633 common_function(argvars, rettv, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4634 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4635
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4636 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4637 * "garbagecollect()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4638 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4639 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4640 f_garbagecollect(typval_T *argvars, typval_T *rettv UNUSED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4641 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4642 if (in_vim9script() && check_for_opt_bool_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4643 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4644
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4645 // This is postponed until we are back at the toplevel, because we may be
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4646 // using Lists and Dicts internally. E.g.: ":echo [garbagecollect()]".
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4647 want_garbage_collect = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4648
22103
0825ae9948f7 patch 8.2.1601: Vim9: cannot use 'true" with garbagecollect()
Bram Moolenaar <Bram@vim.org>
parents: 22101
diff changeset
4649 if (argvars[0].v_type != VAR_UNKNOWN && tv_get_bool(&argvars[0]) == 1)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4650 garbage_collect_at_exit = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4651 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4652
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4653 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4654 * "get()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4655 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4656 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4657 f_get(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4658 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4659 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4660 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4661 dictitem_T *di;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4662 dict_T *d;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4663 typval_T *tv = NULL;
17534
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4664 int what_is_dict = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4665
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4666 if (argvars[0].v_type == VAR_BLOB)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4667 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4668 int error = FALSE;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4669 int idx = tv_get_number_chk(&argvars[1], &error);
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4670
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4671 if (!error)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4672 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4673 rettv->v_type = VAR_NUMBER;
15494
74a8f44b5322 patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
4674 if (idx < 0)
74a8f44b5322 patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
4675 idx = blob_len(argvars[0].vval.v_blob) + idx;
74a8f44b5322 patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
4676 if (idx < 0 || idx >= blob_len(argvars[0].vval.v_blob))
74a8f44b5322 patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
4677 rettv->vval.v_number = -1;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4678 else
15494
74a8f44b5322 patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
4679 {
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4680 rettv->vval.v_number = blob_get(argvars[0].vval.v_blob, idx);
15494
74a8f44b5322 patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
4681 tv = rettv;
74a8f44b5322 patch 8.1.0755: error message for get() on a Blob with invalid index
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
4682 }
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4683 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4684 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4685 else if (argvars[0].v_type == VAR_LIST)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4686 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4687 if ((l = argvars[0].vval.v_list) != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4688 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4689 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4690
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4691 li = list_find(l, (long)tv_get_number_chk(&argvars[1], &error));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4692 if (!error && li != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4693 tv = &li->li_tv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4694 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4695 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4696 else if (argvars[0].v_type == VAR_DICT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4697 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4698 if ((d = argvars[0].vval.v_dict) != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4699 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4700 di = dict_find(d, tv_get_string(&argvars[1]), -1);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4701 if (di != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4702 tv = &di->di_tv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4703 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4704 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4705 else if (argvars[0].v_type == VAR_PARTIAL || argvars[0].v_type == VAR_FUNC)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4706 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4707 partial_T *pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4708 partial_T fref_pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4709
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4710 if (argvars[0].v_type == VAR_PARTIAL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4711 pt = argvars[0].vval.v_partial;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4712 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4713 {
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 20003
diff changeset
4714 CLEAR_FIELD(fref_pt);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4715 fref_pt.pt_name = argvars[0].vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4716 pt = &fref_pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4717 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4718
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4719 if (pt != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4720 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4721 char_u *what = tv_get_string(&argvars[1]);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4722 char_u *n;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4723
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4724 if (STRCMP(what, "func") == 0 || STRCMP(what, "name") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4725 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4726 rettv->v_type = (*what == 'f' ? VAR_FUNC : VAR_STRING);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4727 n = partial_name(pt);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4728 if (n == NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4729 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4730 else
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4731 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4732 rettv->vval.v_string = vim_strsave(n);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4733 if (rettv->v_type == VAR_FUNC)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4734 func_ref(rettv->vval.v_string);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
4735 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4736 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4737 else if (STRCMP(what, "dict") == 0)
17534
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4738 {
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4739 what_is_dict = TRUE;
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4740 if (pt->pt_dict != NULL)
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4741 rettv_dict_set(rettv, pt->pt_dict);
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4742 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4743 else if (STRCMP(what, "args") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4744 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4745 rettv->v_type = VAR_LIST;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4746 if (rettv_list_alloc(rettv) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4747 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4748 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4749
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4750 for (i = 0; i < pt->pt_argc; ++i)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4751 list_append_tv(rettv->vval.v_list, &pt->pt_argv[i]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4752 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4753 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4754 else
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
4755 semsg(_(e_invalid_argument_str), what);
17534
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4756
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4757 // When {what} == "dict" and pt->pt_dict == NULL, evaluate the
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4758 // third argument
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4759 if (!what_is_dict)
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
4760 return;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4761 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4762 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4763 else
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
4764 semsg(_(e_argument_of_str_must_be_list_dictionary_or_blob), "get()");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4765
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4766 if (tv == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4767 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4768 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4769 copy_tv(&argvars[2], rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4770 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4771 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4772 copy_tv(tv, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4773 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4774
9858
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9850
diff changeset
4775 /*
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4776 * "getchangelist()" function
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4777 */
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4778 static void
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4779 f_getchangelist(typval_T *argvars, typval_T *rettv)
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4780 {
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4781 buf_T *buf;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4782 int i;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4783 list_T *l;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4784 dict_T *d;
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4785 int changelistindex;
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4786
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
4787 if (rettv_list_alloc(rettv) == FAIL)
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4788 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4789
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4790 if (in_vim9script() && check_for_opt_buffer_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4791 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4792
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
4793 if (argvars[0].v_type == VAR_UNKNOWN)
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
4794 buf = curbuf;
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
4795 else
22039
f040df1bd219 patch 8.2.1569: Vim9: fixes not tested; failure in getchangelist()
Bram Moolenaar <Bram@vim.org>
parents: 21989
diff changeset
4796 buf = tv_get_buf_from_arg(&argvars[0]);
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4797 if (buf == NULL)
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4798 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4799
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4800 l = list_alloc();
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4801 if (l == NULL)
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4802 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4803
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4804 if (list_append_list(rettv->vval.v_list, l) == FAIL)
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4805 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4806 /*
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4807 * The current window change list index tracks only the position for the
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4808 * current buffer. For other buffers use the stored index for the current
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4809 * window, or, if that's not available, the change list length.
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4810 */
28413
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4811 if (buf == curwin->w_buffer)
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4812 {
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4813 changelistindex = curwin->w_changelistidx;
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4814 }
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4815 else
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4816 {
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4817 wininfo_T *wip;
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4818
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4819 FOR_ALL_BUF_WININFO(buf, wip)
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4820 if (wip->wi_win == curwin)
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4821 break;
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4822 changelistindex = wip != NULL ? wip->wi_changelistidx
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4823 : buf->b_changelistlen;
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4824 }
1170b35651a5 patch 8.2.4731: the changelist index is not remembered per buffer
Bram Moolenaar <Bram@vim.org>
parents: 28307
diff changeset
4825 list_append_number(rettv->vval.v_list, (varnumber_T)changelistindex);
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4826
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4827 for (i = 0; i < buf->b_changelistlen; ++i)
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4828 {
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4829 if (buf->b_changelist[i].lnum == 0)
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4830 continue;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4831 if ((d = dict_alloc()) == NULL)
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4832 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4833 if (list_append_dict(l, d) == FAIL)
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4834 return;
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
4835 dict_add_number(d, "lnum", (long)buf->b_changelist[i].lnum);
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
4836 dict_add_number(d, "col", (long)buf->b_changelist[i].col);
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
4837 dict_add_number(d, "coladd", (long)buf->b_changelist[i].coladd);
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4838 }
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
4839 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4840
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4841 static void
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4842 getpos_both(
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4843 typval_T *argvars,
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4844 typval_T *rettv,
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4845 int getcurpos,
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4846 int charcol)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4847 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4848 pos_T *fp = NULL;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4849 pos_T pos;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4850 win_T *wp = curwin;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4851 list_T *l;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4852 int fnum = -1;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4853
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4854 if (rettv_list_alloc(rettv) == OK)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4855 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4856 l = rettv->vval.v_list;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4857 if (getcurpos)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4858 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4859 if (argvars[0].v_type != VAR_UNKNOWN)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4860 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4861 wp = find_win_by_nr_or_id(&argvars[0]);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4862 if (wp != NULL)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4863 fp = &wp->w_cursor;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4864 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4865 else
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4866 fp = &curwin->w_cursor;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4867 if (fp != NULL && charcol)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4868 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4869 pos = *fp;
23600
f4347a61ed38 patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents: 23598
diff changeset
4870 pos.col =
f4347a61ed38 patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents: 23598
diff changeset
4871 buf_byteidx_to_charidx(wp->w_buffer, pos.lnum, pos.col);
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4872 fp = &pos;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4873 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4874 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4875 else
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4876 fp = var2fpos(&argvars[0], TRUE, &fnum, charcol);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4877 if (fnum != -1)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4878 list_append_number(l, (varnumber_T)fnum);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4879 else
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4880 list_append_number(l, (varnumber_T)0);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4881 list_append_number(l, (fp != NULL) ? (varnumber_T)fp->lnum
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4882 : (varnumber_T)0);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4883 list_append_number(l, (fp != NULL)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4884 ? (varnumber_T)(fp->col == MAXCOL ? MAXCOL : fp->col + 1)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4885 : (varnumber_T)0);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4886 list_append_number(l, (fp != NULL) ? (varnumber_T)fp->coladd :
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4887 (varnumber_T)0);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4888 if (getcurpos)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4889 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4890 int save_set_curswant = curwin->w_set_curswant;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4891 colnr_T save_curswant = curwin->w_curswant;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4892 colnr_T save_virtcol = curwin->w_virtcol;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4893
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4894 if (wp == curwin)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4895 update_curswant();
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4896 list_append_number(l, wp == NULL ? 0 : wp->w_curswant == MAXCOL
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4897 ? (varnumber_T)MAXCOL : (varnumber_T)wp->w_curswant + 1);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4898
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4899 // Do not change "curswant", as it is unexpected that a get
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4900 // function has a side effect.
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4901 if (wp == curwin && save_set_curswant)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4902 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4903 curwin->w_set_curswant = save_set_curswant;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4904 curwin->w_curswant = save_curswant;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4905 curwin->w_virtcol = save_virtcol;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4906 curwin->w_valid &= ~VALID_VIRTCOL;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4907 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4908 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4909 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4910 else
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4911 rettv->vval.v_number = FALSE;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4912 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4913
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4914 /*
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4915 * "getcharpos()" function
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4916 */
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4917 static void
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4918 f_getcharpos(typval_T *argvars UNUSED, typval_T *rettv)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4919 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4920 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4921 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4922
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4923 getpos_both(argvars, rettv, FALSE, TRUE);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4924 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
4925
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4926 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4927 * "getcharsearch()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4928 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4929 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4930 f_getcharsearch(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4931 {
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
4932 if (rettv_dict_alloc(rettv) == OK)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4933 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4934 dict_T *dict = rettv->vval.v_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4935
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
4936 dict_add_string(dict, "char", last_csearch());
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
4937 dict_add_number(dict, "forward", last_csearch_forward());
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
4938 dict_add_number(dict, "until", last_csearch_until());
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4939 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4940 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4941
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4942 /*
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4943 * "getenv()" function
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4944 */
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4945 static void
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4946 f_getenv(typval_T *argvars, typval_T *rettv)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4947 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4948 int mustfree = FALSE;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4949 char_u *p;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4950
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4951 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4952 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4953
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4954 p = vim_getenv(tv_get_string(&argvars[0]), &mustfree);
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4955 if (p == NULL)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4956 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4957 rettv->v_type = VAR_SPECIAL;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4958 rettv->vval.v_number = VVAL_NULL;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4959 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4960 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4961 if (!mustfree)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4962 p = vim_strsave(p);
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4963 rettv->vval.v_string = p;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4964 rettv->v_type = VAR_STRING;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4965 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4966
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
4967 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4968 * "getfontname()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4969 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4970 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4971 f_getfontname(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4972 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4973 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4974 rettv->vval.v_string = NULL;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4975
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4976 if (in_vim9script() && check_for_opt_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4977 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
4978
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4979 #ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4980 if (gui.in_use)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4981 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4982 GuiFont font;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4983 char_u *name = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4984
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4985 if (argvars[0].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4986 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4987 // Get the "Normal" font. Either the name saved by
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4988 // hl_set_font_name() or from the font ID.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4989 font = gui.norm_font;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4990 name = hl_get_font_name();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4991 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4992 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4993 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4994 name = tv_get_string(&argvars[0]);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4995 if (STRCMP(name, "*") == 0) // don't use font dialog
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4996 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4997 font = gui_mch_get_font(name, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4998 if (font == NOFONT)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4999 return; // Invalid font name, return empty string.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5000 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5001 rettv->vval.v_string = gui_mch_get_fontname(font, name);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5002 if (argvars[0].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5003 gui_mch_free_font(font);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5004 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5005 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5006 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5007
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5008 /*
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5009 * "getjumplist()" function
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5010 */
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5011 static void
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5012 f_getjumplist(typval_T *argvars, typval_T *rettv)
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5013 {
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5014 win_T *wp;
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5015 int i;
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5016 list_T *l;
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5017 dict_T *d;
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5018
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
5019 if (rettv_list_alloc(rettv) == FAIL)
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5020 return;
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5021
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5022 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5023 && (check_for_opt_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5024 || (argvars[0].v_type != VAR_UNKNOWN
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5025 && check_for_opt_number_arg(argvars, 1) == FAIL)))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5026 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5027
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
5028 wp = find_tabwin(&argvars[0], &argvars[1], NULL);
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5029 if (wp == NULL)
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5030 return;
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5031
15788
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
5032 cleanup_jumplist(wp, TRUE);
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
5033
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5034 l = list_alloc();
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5035 if (l == NULL)
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5036 return;
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5037
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5038 if (list_append_list(rettv->vval.v_list, l) == FAIL)
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5039 return;
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5040 list_append_number(rettv->vval.v_list, (varnumber_T)wp->w_jumplistidx);
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5041
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5042 for (i = 0; i < wp->w_jumplistlen; ++i)
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5043 {
13248
5958573d8a72 patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13246
diff changeset
5044 if (wp->w_jumplist[i].fmark.mark.lnum == 0)
5958573d8a72 patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13246
diff changeset
5045 continue;
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5046 if ((d = dict_alloc()) == NULL)
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5047 return;
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5048 if (list_append_dict(l, d) == FAIL)
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5049 return;
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
5050 dict_add_number(d, "lnum", (long)wp->w_jumplist[i].fmark.mark.lnum);
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
5051 dict_add_number(d, "col", (long)wp->w_jumplist[i].fmark.mark.col);
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
5052 dict_add_number(d, "coladd", (long)wp->w_jumplist[i].fmark.mark.coladd);
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
5053 dict_add_number(d, "bufnr", (long)wp->w_jumplist[i].fmark.fnum);
13248
5958573d8a72 patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13246
diff changeset
5054 if (wp->w_jumplist[i].fname != NULL)
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
5055 dict_add_string(d, "filename", wp->w_jumplist[i].fname);
13246
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5056 }
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5057 }
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5058
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
5059 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5060 * "getpid()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5061 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5062 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5063 f_getpid(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5064 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5065 rettv->vval.v_number = mch_get_pid();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5066 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5067
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5068 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5069 * "getcurpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5070 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5071 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5072 f_getcurpos(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5073 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5074 if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5075 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5076
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
5077 getpos_both(argvars, rettv, TRUE, FALSE);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
5078 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
5079
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
5080 static void
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
5081 f_getcursorcharpos(typval_T *argvars, typval_T *rettv)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
5082 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5083 if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5084 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5085
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
5086 getpos_both(argvars, rettv, TRUE, TRUE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5087 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5088
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5089 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5090 * "getpos(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5091 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5092 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5093 f_getpos(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5094 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5095 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5096 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5097
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
5098 getpos_both(argvars, rettv, FALSE, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5099 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5100
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5101 /*
26706
71e6e67b2898 patch 8.2.3882: more duplicated code in f_getreginfo()
Bram Moolenaar <Bram@vim.org>
parents: 26700
diff changeset
5102 * Common between getreg(), getreginfo() and getregtype(): get the register
71e6e67b2898 patch 8.2.3882: more duplicated code in f_getreginfo()
Bram Moolenaar <Bram@vim.org>
parents: 26700
diff changeset
5103 * name from the first argument.
26700
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5104 * Returns zero on error.
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5105 */
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5106 static int
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5107 getreg_get_regname(typval_T *argvars)
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5108 {
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5109 char_u *strregname;
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5110
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5111 if (argvars[0].v_type != VAR_UNKNOWN)
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5112 {
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5113 strregname = tv_get_string_chk(&argvars[0]);
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5114 if (strregname != NULL && in_vim9script() && STRLEN(strregname) > 1)
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5115 {
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5116 semsg(_(e_register_name_must_be_one_char_str), strregname);
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5117 strregname = NULL;
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5118 }
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5119 if (strregname == NULL) // type error; errmsg already given
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5120 return 0;
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5121 }
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5122 else
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5123 // Default to v:register
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5124 strregname = get_vim_var_str(VV_REG);
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5125
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5126 return *strregname == 0 ? '"' : *strregname;
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5127 }
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5128
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5129 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5130 * "getreg()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5131 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5132 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5133 f_getreg(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5134 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5135 int regname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5136 int arg2 = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5137 int return_list = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5138
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
5139 if (in_vim9script()
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5140 && (check_for_opt_string_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5141 || (argvars[0].v_type != VAR_UNKNOWN
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5142 && (check_for_opt_bool_arg(argvars, 1) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5143 || (argvars[1].v_type != VAR_UNKNOWN
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5144 && check_for_opt_bool_arg(argvars, 2) == FAIL)))))
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
5145 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
5146
26700
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5147 regname = getreg_get_regname(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5148 if (regname == 0)
26700
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5149 return;
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5150
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5151 if (argvars[0].v_type != VAR_UNKNOWN && argvars[1].v_type != VAR_UNKNOWN)
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5152 {
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5153 int error = FALSE;
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5154
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5155 arg2 = (int)tv_get_bool_chk(&argvars[1], &error);
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5156
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5157 if (!error && argvars[2].v_type != VAR_UNKNOWN)
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5158 return_list = (int)tv_get_bool_chk(&argvars[2], &error);
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5159 if (error)
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5160 return;
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5161 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5162
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5163 if (return_list)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5164 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5165 rettv->v_type = VAR_LIST;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5166 rettv->vval.v_list = (list_T *)get_reg_contents(regname,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5167 (arg2 ? GREG_EXPR_SRC : 0) | GREG_LIST);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5168 if (rettv->vval.v_list == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5169 (void)rettv_list_alloc(rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5170 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5171 ++rettv->vval.v_list->lv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5172 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5173 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5174 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5175 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5176 rettv->vval.v_string = get_reg_contents(regname,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5177 arg2 ? GREG_EXPR_SRC : 0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5178 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5179 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5180
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5181 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5182 * "getregtype()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5183 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5184 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5185 f_getregtype(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5186 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5187 int regname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5188 char_u buf[NUMBUFLEN + 2];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5189 long reglen = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5190
26700
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5191 // on error return an empty string
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5192 rettv->v_type = VAR_STRING;
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5193 rettv->vval.v_string = NULL;
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5194
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5195 if (in_vim9script() && check_for_opt_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5196 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5197
26700
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5198 regname = getreg_get_regname(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5199 if (regname == 0)
26700
c9a83dc9081b patch 8.2.3879: getreg() and getregtype() contain dead code
Bram Moolenaar <Bram@vim.org>
parents: 26686
diff changeset
5200 return;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5201
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5202 buf[0] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5203 buf[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5204 switch (get_reg_type(regname, &reglen))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5205 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5206 case MLINE: buf[0] = 'V'; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5207 case MCHAR: buf[0] = 'v'; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5208 case MBLOCK:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5209 buf[0] = Ctrl_V;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5210 sprintf((char *)buf + 1, "%ld", reglen + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5211 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5212 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5213 rettv->vval.v_string = vim_strsave(buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5214 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5215
9858
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9850
diff changeset
5216 /*
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5217 * "gettagstack()" function
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5218 */
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5219 static void
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5220 f_gettagstack(typval_T *argvars, typval_T *rettv)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5221 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5222 win_T *wp = curwin; // default is current window
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5223
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
5224 if (rettv_dict_alloc(rettv) == FAIL)
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5225 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5226
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5227 if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5228 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5229
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5230 if (argvars[0].v_type != VAR_UNKNOWN)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5231 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5232 wp = find_win_by_nr_or_id(&argvars[0]);
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5233 if (wp == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5234 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5235 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5236
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5237 get_tagstack(wp, rettv->vval.v_dict);
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5238 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
5239
21989
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5240 /*
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5241 * "gettext()" function
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5242 */
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5243 static void
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5244 f_gettext(typval_T *argvars, typval_T *rettv)
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5245 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5246 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5247 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
5248
21989
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5249 if (argvars[0].v_type != VAR_STRING
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5250 || argvars[0].vval.v_string == NULL
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5251 || *argvars[0].vval.v_string == NUL)
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5252 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
5253 semsg(_(e_invalid_argument_str), tv_get_string(&argvars[0]));
21989
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5254 }
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5255 else
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5256 {
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5257 rettv->v_type = VAR_STRING;
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5258 rettv->vval.v_string = vim_strsave(
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5259 (char_u *)_(argvars[0].vval.v_string));
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5260 }
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5261 }
52e970719f4b patch 8.2.1544: cannot translate messages in a Vim script
Bram Moolenaar <Bram@vim.org>
parents: 21973
diff changeset
5262
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5263 // for VIM_VERSION_ defines
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5264 #include "version.h"
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5265
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5266 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5267 * "has()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5268 */
19253
a8d2d3c8f0b3 patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines
Bram Moolenaar <Bram@vim.org>
parents: 19247
diff changeset
5269 void
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5270 f_has(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5271 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5272 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5273 char_u *name;
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5274 int x = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5275 int n = FALSE;
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5276 typedef struct {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5277 char *name;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5278 short present;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5279 } has_item_T;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5280 static has_item_T has_list[] =
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5281 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5282 {"amiga",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5283 #ifdef AMIGA
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5284 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5285 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5286 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5287 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5288 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5289 {"arp",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5290 #if defined(AMIGA) && defined(FEAT_ARP)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5291 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5292 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5293 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5294 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5295 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5296 {"haiku",
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
5297 #ifdef __HAIKU__
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5298 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5299 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5300 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5301 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5302 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5303 {"bsd",
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
5304 #if defined(BSD) && !defined(MACOS_X)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5305 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5306 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5307 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5308 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5309 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5310 {"hpux",
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
5311 #ifdef hpux
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5312 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5313 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5314 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5315 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5316 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5317 {"linux",
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
5318 #ifdef __linux__
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5319 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5320 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5321 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5322 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5323 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5324 {"mac", // Mac OS X (and, once, Mac OS Classic)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5325 #ifdef MACOS_X
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5326 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5327 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5328 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5329 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5330 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5331 {"osx", // Mac OS X
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12564
diff changeset
5332 #ifdef MACOS_X
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5333 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5334 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5335 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5336 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5337 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5338 {"macunix", // Mac OS X, with the darwin feature
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5339 #if defined(MACOS_X) && defined(MACOS_X_DARWIN)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5340 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5341 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5342 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5343 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5344 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5345 {"osxdarwin", // synonym for macunix
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5346 #if defined(MACOS_X) && defined(MACOS_X_DARWIN)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5347 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5348 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5349 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5350 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5351 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5352 {"qnx",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5353 #ifdef __QNX__
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5354 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5355 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5356 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5357 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5358 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5359 {"sun",
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
5360 #ifdef SUN_SYSTEM
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5361 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5362 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5363 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5364 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5365 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5366 {"unix",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5367 #ifdef UNIX
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5368 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5369 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5370 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5371 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5372 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5373 {"vms",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5374 #ifdef VMS
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5375 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5376 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5377 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5378 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5379 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5380 {"win32",
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5381 #ifdef MSWIN
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5382 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5383 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5384 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5385 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5386 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5387 {"win32unix",
27533
4f1c67a5f446 patch 8.2.4294: MS-Windows: #ifdefs for Cygwin are too complicated
Bram Moolenaar <Bram@vim.org>
parents: 27517
diff changeset
5388 #ifdef WIN32UNIX
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5389 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5390 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5391 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5392 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5393 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5394 {"win64",
15890
de2c2a378cd1 patch 8.1.0951: using WIN64 even though it is never defined
Bram Moolenaar <Bram@vim.org>
parents: 15868
diff changeset
5395 #ifdef _WIN64
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5396 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5397 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5398 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5399 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5400 },
27490
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27484
diff changeset
5401 {"ebcdic", 0 },
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5402 {"fname_case",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5403 #ifndef CASE_INSENSITIVE_FILENAME
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5404 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5405 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5406 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5407 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5408 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5409 {"acl",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5410 #ifdef HAVE_ACL
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5411 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5412 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5413 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5414 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5415 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5416 {"arabic",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5417 #ifdef FEAT_ARABIC
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5418 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5419 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5420 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5421 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5422 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5423 {"autocmd", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5424 {"autochdir",
14399
e7d1bc5ee3b8 patch 8.1.0214: +autochdir feature not reported by has() or :version
Christian Brabandt <cb@256bit.org>
parents: 14393
diff changeset
5425 #ifdef FEAT_AUTOCHDIR
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5426 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5427 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5428 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5429 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5430 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5431 {"autoservername",
12837
963cdeb42c41 patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
5432 #ifdef FEAT_AUTOSERVERNAME
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5433 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5434 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5435 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5436 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5437 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5438 {"balloon_eval",
12871
1a450ce6980c patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
5439 #ifdef FEAT_BEVAL_GUI
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5440 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5441 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5442 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5443 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5444 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5445 {"balloon_multiline",
27293
e91b577be192 patch 8.2.4175: MS-Windows: runtime check for multi-line balloon is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
5446 #ifdef FEAT_BEVAL_GUI
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5447 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5448 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5449 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5450 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5451 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5452 {"balloon_eval_term",
12871
1a450ce6980c patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
5453 #ifdef FEAT_BEVAL_TERM
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5454 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5455 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5456 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5457 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5458 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5459 {"builtin_terms",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5460 #if defined(SOME_BUILTIN_TCAPS) || defined(ALL_BUILTIN_TCAPS)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5461 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5462 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5463 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5464 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5465 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5466 {"all_builtin_terms",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5467 #if defined(ALL_BUILTIN_TCAPS)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5468 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5469 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5470 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5471 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5472 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5473 {"browsefilter",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5474 #if defined(FEAT_BROWSE) && (defined(USE_FILE_CHOOSER) \
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5475 || defined(FEAT_GUI_MSWIN) \
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5476 || defined(FEAT_GUI_MOTIF))
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5477 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5478 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5479 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5480 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5481 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5482 {"byte_offset",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5483 #ifdef FEAT_BYTEOFF
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5484 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5485 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5486 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5487 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5488 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5489 {"channel",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5490 #ifdef FEAT_JOB_CHANNEL
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5491 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5492 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5493 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5494 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5495 },
28942
6cdf55afaae9 patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents: 28917
diff changeset
5496 {"cindent", 1},
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5497 {"clientserver",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5498 #ifdef FEAT_CLIENTSERVER
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5499 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5500 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5501 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5502 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5503 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5504 {"clipboard",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5505 #ifdef FEAT_CLIPBOARD
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5506 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5507 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5508 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5509 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5510 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5511 {"cmdline_compl", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5512 {"cmdline_hist", 1},
23748
93f90f2ff4e9 patch 8.2.2415: no way to check for the cmdwin feature
Bram Moolenaar <Bram@vim.org>
parents: 23705
diff changeset
5513 {"cmdwin",
93f90f2ff4e9 patch 8.2.2415: no way to check for the cmdwin feature
Bram Moolenaar <Bram@vim.org>
parents: 23705
diff changeset
5514 #ifdef FEAT_CMDWIN
93f90f2ff4e9 patch 8.2.2415: no way to check for the cmdwin feature
Bram Moolenaar <Bram@vim.org>
parents: 23705
diff changeset
5515 1
93f90f2ff4e9 patch 8.2.2415: no way to check for the cmdwin feature
Bram Moolenaar <Bram@vim.org>
parents: 23705
diff changeset
5516 #else
93f90f2ff4e9 patch 8.2.2415: no way to check for the cmdwin feature
Bram Moolenaar <Bram@vim.org>
parents: 23705
diff changeset
5517 0
93f90f2ff4e9 patch 8.2.2415: no way to check for the cmdwin feature
Bram Moolenaar <Bram@vim.org>
parents: 23705
diff changeset
5518 #endif
93f90f2ff4e9 patch 8.2.2415: no way to check for the cmdwin feature
Bram Moolenaar <Bram@vim.org>
parents: 23705
diff changeset
5519 },
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5520 {"comments", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5521 {"conceal",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5522 #ifdef FEAT_CONCEAL
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5523 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5524 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5525 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5526 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5527 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5528 {"cryptv",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5529 #ifdef FEAT_CRYPT
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5530 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5531 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5532 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5533 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5534 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5535 {"crypt-blowfish",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5536 #ifdef FEAT_CRYPT
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5537 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5538 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5539 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5540 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5541 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5542 {"crypt-blowfish2",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5543 #ifdef FEAT_CRYPT
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5544 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5545 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5546 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5547 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5548 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5549 {"cscope",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5550 #ifdef FEAT_CSCOPE
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5551 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5552 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5553 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5554 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5555 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5556 {"cursorbind", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5557 {"cursorshape",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5558 #ifdef CURSOR_SHAPE
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5559 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5560 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5561 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5562 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5563 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5564 {"debug",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5565 #ifdef DEBUG
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5566 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5567 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5568 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5569 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5570 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5571 {"dialog_con",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5572 #ifdef FEAT_CON_DIALOG
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5573 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5574 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5575 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5576 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5577 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5578 {"dialog_gui",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5579 #ifdef FEAT_GUI_DIALOG
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5580 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5581 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5582 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5583 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5584 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5585 {"diff",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5586 #ifdef FEAT_DIFF
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5587 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5588 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5589 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5590 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5591 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5592 {"digraphs",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5593 #ifdef FEAT_DIGRAPHS
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5594 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5595 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5596 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5597 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5598 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5599 {"directx",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5600 #ifdef FEAT_DIRECTX
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5601 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5602 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5603 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5604 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5605 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5606 {"dnd",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5607 #ifdef FEAT_DND
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5608 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5609 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5610 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5611 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5612 },
25060
54c0cb81e6a7 patch 8.2.3067: building fails with Athena
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
5613 {"drop_file",
54c0cb81e6a7 patch 8.2.3067: building fails with Athena
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
5614 #ifdef HAVE_DROP_FILE
54c0cb81e6a7 patch 8.2.3067: building fails with Athena
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
5615 1
54c0cb81e6a7 patch 8.2.3067: building fails with Athena
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
5616 #else
54c0cb81e6a7 patch 8.2.3067: building fails with Athena
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
5617 0
54c0cb81e6a7 patch 8.2.3067: building fails with Athena
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
5618 #endif
54c0cb81e6a7 patch 8.2.3067: building fails with Athena
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
5619 },
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5620 {"emacs_tags",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5621 #ifdef FEAT_EMACS_TAGS
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5622 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5623 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5624 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5625 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5626 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5627 {"eval", 1}, // always present, of course!
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5628 {"ex_extra", 1}, // graduated feature
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5629 {"extra_search",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5630 #ifdef FEAT_SEARCH_EXTRA
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5631 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5632 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5633 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5634 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5635 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5636 {"file_in_path",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5637 #ifdef FEAT_SEARCHPATH
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5638 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5639 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5640 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5641 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5642 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5643 {"filterpipe",
18742
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18738
diff changeset
5644 #if defined(FEAT_FILTERPIPE) && !defined(VIMDLL)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5645 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5646 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5647 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5648 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5649 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5650 {"find_in_path",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5651 #ifdef FEAT_FIND_ID
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5652 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5653 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5654 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5655 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5656 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5657 {"float",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5658 #ifdef FEAT_FLOAT
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5659 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5660 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5661 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5662 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5663 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5664 {"folding",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5665 #ifdef FEAT_FOLDING
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5666 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5667 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5668 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5669 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5670 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5671 {"footer",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5672 #ifdef FEAT_FOOTER
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5673 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5674 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5675 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5676 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5677 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5678 {"fork",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5679 #if !defined(USE_SYSTEM) && defined(UNIX)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5680 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5681 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5682 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5683 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5684 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5685 {"gettext",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5686 #ifdef FEAT_GETTEXT
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5687 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5688 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5689 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5690 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5691 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5692 {"gui",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5693 #ifdef FEAT_GUI
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5694 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5695 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5696 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5697 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5698 },
28303
9849df834f1d patch 8.2.4677: the Athena GUI support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 28287
diff changeset
5699 {"gui_neXtaw", 0 },
9849df834f1d patch 8.2.4677: the Athena GUI support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 28287
diff changeset
5700 {"gui_athena", 0 },
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5701 {"gui_gtk",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5702 #ifdef FEAT_GUI_GTK
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5703 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5704 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5705 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5706 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5707 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5708 {"gui_gtk2",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5709 #if defined(FEAT_GUI_GTK) && !defined(USE_GTK3)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5710 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5711 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5712 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5713 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5714 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5715 {"gui_gtk3",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5716 #if defined(FEAT_GUI_GTK) && defined(USE_GTK3)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5717 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5718 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5719 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5720 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5721 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5722 {"gui_gnome",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5723 #ifdef FEAT_GUI_GNOME
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5724 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5725 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5726 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5727 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5728 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5729 {"gui_haiku",
19526
22f0dda71638 patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
5730 #ifdef FEAT_GUI_HAIKU
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5731 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5732 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5733 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5734 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5735 },
21745
35921b7fc07a patch 8.2.1422: the Mac GUI implementation is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21695
diff changeset
5736 {"gui_mac", 0},
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5737 {"gui_motif",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5738 #ifdef FEAT_GUI_MOTIF
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5739 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5740 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5741 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5742 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5743 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5744 {"gui_photon",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5745 #ifdef FEAT_GUI_PHOTON
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5746 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5747 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5748 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5749 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5750 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5751 {"gui_win32",
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5752 #ifdef FEAT_GUI_MSWIN
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5753 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5754 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5755 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5756 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5757 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5758 {"iconv",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5759 #if defined(HAVE_ICONV_H) && defined(USE_ICONV)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5760 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5761 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5762 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5763 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5764 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5765 {"insert_expand", 1},
20003
e373843e2980 patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
5766 {"ipv6",
e373843e2980 patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
5767 #ifdef FEAT_IPV6
e373843e2980 patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
5768 1
e373843e2980 patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
5769 #else
e373843e2980 patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
5770 0
e373843e2980 patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
5771 #endif
e373843e2980 patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents: 19952
diff changeset
5772 },
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5773 {"job",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5774 #ifdef FEAT_JOB_CHANNEL
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5775 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5776 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5777 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5778 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5779 },
26532
255bc9a08e58 patch 8.2.3795: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 26348
diff changeset
5780 {"jumplist", 1},
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5781 {"keymap",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5782 #ifdef FEAT_KEYMAP
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5783 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5784 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5785 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5786 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5787 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5788 {"lambda", 1}, // always with FEAT_EVAL, since 7.4.2120 with closure
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5789 {"langmap",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5790 #ifdef FEAT_LANGMAP
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5791 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5792 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5793 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5794 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5795 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5796 {"libcall",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5797 #ifdef FEAT_LIBCALL
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5798 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5799 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5800 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5801 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5802 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5803 {"linebreak",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5804 #ifdef FEAT_LINEBREAK
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5805 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5806 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5807 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5808 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5809 },
28942
6cdf55afaae9 patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents: 28917
diff changeset
5810 {"lispindent", 1},
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5811 {"listcmds", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5812 {"localmap", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5813 {"lua",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5814 #if defined(FEAT_LUA) && !defined(DYNAMIC_LUA)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5815 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5816 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5817 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5818 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5819 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5820 {"menu",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5821 #ifdef FEAT_MENU
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5822 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5823 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5824 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5825 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5826 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5827 {"mksession",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5828 #ifdef FEAT_SESSION
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5829 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5830 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5831 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5832 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5833 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5834 {"modify_fname", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5835 {"mouse", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5836 {"mouseshape",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5837 #ifdef FEAT_MOUSESHAPE
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5838 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5839 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5840 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5841 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5842 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5843 {"mouse_dec",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5844 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_MOUSE_DEC)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5845 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5846 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5847 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5848 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5849 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5850 {"mouse_gpm",
27863
f1799ba16729 patch 8.2.4457: the GPM library can only be linked statically
Bram Moolenaar <Bram@vim.org>
parents: 27859
diff changeset
5851 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_MOUSE_GPM) && !defined(DYNAMIC_GPM)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5852 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5853 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5854 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5855 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5856 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5857 {"mouse_jsbterm",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5858 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_MOUSE_JSB)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5859 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5860 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5861 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5862 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5863 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5864 {"mouse_netterm",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5865 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_MOUSE_NET)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5866 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5867 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5868 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5869 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5870 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5871 {"mouse_pterm",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5872 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_MOUSE_PTERM)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5873 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5874 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5875 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5876 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5877 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5878 {"mouse_sgr",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5879 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_MOUSE_XTERM)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5880 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5881 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5882 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5883 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5884 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5885 {"mouse_sysmouse",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5886 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_SYSMOUSE)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5887 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5888 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5889 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5890 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5891 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5892 {"mouse_urxvt",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5893 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_MOUSE_URXVT)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5894 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5895 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5896 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5897 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5898 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5899 {"mouse_xterm",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5900 #if (defined(UNIX) || defined(VMS)) && defined(FEAT_MOUSE_XTERM)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5901 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5902 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5903 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5904 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5905 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5906 {"multi_byte", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5907 {"multi_byte_ime",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5908 #ifdef FEAT_MBYTE_IME
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5909 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5910 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5911 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5912 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5913 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5914 {"multi_lang",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5915 #ifdef FEAT_MULTI_LANG
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5916 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5917 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5918 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5919 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5920 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5921 {"mzscheme",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5922 #if defined(FEAT_MZSCHEME) && !defined(DYNAMIC_MZSCHEME)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5923 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5924 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5925 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5926 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5927 },
25953
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 25844
diff changeset
5928 {"nanotime",
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 25844
diff changeset
5929 #ifdef ST_MTIM_NSEC
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 25844
diff changeset
5930 1
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 25844
diff changeset
5931 #else
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 25844
diff changeset
5932 0
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 25844
diff changeset
5933 #endif
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 25844
diff changeset
5934 },
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5935 {"num64", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5936 {"ole",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5937 #ifdef FEAT_OLE
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5938 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5939 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5940 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5941 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5942 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5943 {"packages",
14375
e5d7dd985b53 patch 8.1.0202: :version always shows +packages
Christian Brabandt <cb@256bit.org>
parents: 14368
diff changeset
5944 #ifdef FEAT_EVAL
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5945 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5946 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5947 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5948 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5949 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5950 {"path_extra",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5951 #ifdef FEAT_PATH_EXTRA
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5952 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5953 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5954 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5955 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5956 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5957 {"perl",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5958 #if defined(FEAT_PERL) && !defined(DYNAMIC_PERL)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5959 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5960 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5961 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5962 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5963 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5964 {"persistent_undo",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5965 #ifdef FEAT_PERSISTENT_UNDO
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5966 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5967 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5968 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5969 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5970 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5971 {"python_compiled",
13123
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
5972 #if defined(FEAT_PYTHON)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5973 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5974 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5975 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5976 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5977 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5978 {"python_dynamic",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5979 #if defined(FEAT_PYTHON) && defined(DYNAMIC_PYTHON)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5980 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5981 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5982 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5983 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5984 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5985 {"python",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5986 #if defined(FEAT_PYTHON) && !defined(DYNAMIC_PYTHON)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5987 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5988 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5989 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5990 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5991 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5992 {"pythonx",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5993 #if (defined(FEAT_PYTHON) && !defined(DYNAMIC_PYTHON)) \
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5994 || (defined(FEAT_PYTHON3) && !defined(DYNAMIC_PYTHON3))
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5995 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5996 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5997 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5998 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
5999 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6000 {"python3_compiled",
13123
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
6001 #if defined(FEAT_PYTHON3)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6002 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6003 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6004 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6005 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6006 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6007 {"python3_dynamic",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6008 #if defined(FEAT_PYTHON3) && defined(DYNAMIC_PYTHON3)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6009 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6010 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6011 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6012 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6013 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6014 {"python3",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6015 #if defined(FEAT_PYTHON3) && !defined(DYNAMIC_PYTHON3)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6016 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6017 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6018 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6019 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6020 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6021 {"popupwin",
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18742
diff changeset
6022 #ifdef FEAT_PROP_POPUP
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6023 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6024 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6025 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6026 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6027 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6028 {"postscript",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6029 #ifdef FEAT_POSTSCRIPT
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6030 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6031 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6032 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6033 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6034 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6035 {"printer",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6036 #ifdef FEAT_PRINTER
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6037 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6038 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6039 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6040 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6041 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6042 {"profile",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6043 #ifdef FEAT_PROFILE
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6044 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6045 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6046 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6047 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6048 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6049 {"reltime",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6050 #ifdef FEAT_RELTIME
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6051 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6052 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6053 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6054 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6055 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6056 {"quickfix",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6057 #ifdef FEAT_QUICKFIX
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6058 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6059 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6060 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6061 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6062 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6063 {"rightleft",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6064 #ifdef FEAT_RIGHTLEFT
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6065 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6066 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6067 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6068 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6069 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6070 {"ruby",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6071 #if defined(FEAT_RUBY) && !defined(DYNAMIC_RUBY)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6072 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6073 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6074 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6075 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6076 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6077 {"scrollbind", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6078 {"showcmd",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6079 #ifdef FEAT_CMDL_INFO
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6080 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6081 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6082 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6083 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6084 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6085 {"cmdline_info",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6086 #ifdef FEAT_CMDL_INFO
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6087 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6088 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6089 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6090 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6091 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6092 {"signs",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6093 #ifdef FEAT_SIGNS
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6094 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6095 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6096 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6097 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6098 },
28942
6cdf55afaae9 patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents: 28917
diff changeset
6099 {"smartindent", 1},
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6100 {"startuptime",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6101 #ifdef STARTUPTIME
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6102 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6103 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6104 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6105 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6106 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6107 {"statusline",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6108 #ifdef FEAT_STL_OPT
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6109 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6110 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6111 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6112 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6113 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6114 {"netbeans_intg",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6115 #ifdef FEAT_NETBEANS_INTG
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6116 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6117 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6118 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6119 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6120 },
24970
7e9e53a0368f patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents: 24846
diff changeset
6121 {"sodium",
27657
a077948be0f4 patch 8.2.4354: dynamic loading of libsodium not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 27597
diff changeset
6122 #if defined(FEAT_SODIUM) && !defined(DYNAMIC_SODIUM)
24970
7e9e53a0368f patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents: 24846
diff changeset
6123 1
7e9e53a0368f patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents: 24846
diff changeset
6124 #else
7e9e53a0368f patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents: 24846
diff changeset
6125 0
7e9e53a0368f patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents: 24846
diff changeset
6126 #endif
7e9e53a0368f patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents: 24846
diff changeset
6127 },
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6128 {"sound",
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
6129 #ifdef FEAT_SOUND
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6130 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6131 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6132 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6133 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6134 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6135 {"spell",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6136 #ifdef FEAT_SPELL
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6137 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6138 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6139 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6140 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6141 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6142 {"syntax",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6143 #ifdef FEAT_SYN_HL
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6144 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6145 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6146 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6147 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6148 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6149 {"system",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6150 #if defined(USE_SYSTEM) || !defined(UNIX)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6151 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6152 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6153 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6154 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6155 },
27986
c724906134a3 patch 8.2.4518: the binary tag search feature is always enabled
Bram Moolenaar <Bram@vim.org>
parents: 27867
diff changeset
6156 {"tag_binary", 1}, // graduated feature
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6157 {"tcl",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6158 #if defined(FEAT_TCL) && !defined(DYNAMIC_TCL)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6159 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6160 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6161 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6162 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6163 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6164 {"termguicolors",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6165 #ifdef FEAT_TERMGUICOLORS
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6166 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6167 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6168 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6169 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6170 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6171 {"terminal",
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
6172 #if defined(FEAT_TERMINAL) && !defined(MSWIN)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6173 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6174 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6175 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6176 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6177 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6178 {"terminfo",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6179 #ifdef TERMINFO
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6180 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6181 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6182 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6183 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6184 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6185 {"termresponse",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6186 #ifdef FEAT_TERMRESPONSE
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6187 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6188 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6189 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6190 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6191 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6192 {"textobjects",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6193 #ifdef FEAT_TEXTOBJ
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6194 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6195 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6196 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6197 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6198 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6199 {"textprop",
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18742
diff changeset
6200 #ifdef FEAT_PROP_POPUP
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6201 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6202 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6203 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6204 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6205 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6206 {"tgetent",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6207 #ifdef HAVE_TGETENT
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6208 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6209 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6210 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6211 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6212 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6213 {"timers",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6214 #ifdef FEAT_TIMERS
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6215 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6216 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6217 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6218 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6219 },
26336
a2e6da79274d patch 8.2.3699: the +title feature adds a lot of #ifdef but little code
Bram Moolenaar <Bram@vim.org>
parents: 26089
diff changeset
6220 {"title", 1},
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6221 {"toolbar",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6222 #ifdef FEAT_TOOLBAR
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6223 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6224 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6225 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6226 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6227 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6228 {"unnamedplus",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6229 #if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6230 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6231 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6232 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6233 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6234 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6235 {"user-commands", 1}, // was accidentally included in 5.4
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6236 {"user_commands", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6237 {"vartabs",
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14161
diff changeset
6238 #ifdef FEAT_VARTABS
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6239 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6240 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6241 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6242 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6243 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6244 {"vertsplit", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6245 {"viminfo",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6246 #ifdef FEAT_VIMINFO
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6247 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6248 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6249 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6250 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6251 },
26873
be85735650f7 patch 8.2.3965: Vim9: no easy way to check if Vim9 script is supported
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
6252 {"vim9script", 1},
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6253 {"vimscript-1", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6254 {"vimscript-2", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6255 {"vimscript-3", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6256 {"vimscript-4", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6257 {"virtualedit", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6258 {"visual", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6259 {"visualextra", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6260 {"vreplace", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6261 {"vtp",
13454
1720b96e53b6 patch 8.0.1601: highlight test fails on Win32
Christian Brabandt <cb@256bit.org>
parents: 13438
diff changeset
6262 #ifdef FEAT_VTP
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6263 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6264 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6265 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6266 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6267 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6268 {"wildignore",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6269 #ifdef FEAT_WILDIGN
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6270 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6271 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6272 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6273 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6274 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6275 {"wildmenu",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6276 #ifdef FEAT_WILDMENU
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6277 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6278 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6279 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6280 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6281 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6282 {"windows", 1},
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6283 {"winaltkeys",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6284 #ifdef FEAT_WAK
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6285 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6286 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6287 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6288 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6289 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6290 {"writebackup",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6291 #ifdef FEAT_WRITEBACKUP
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6292 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6293 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6294 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6295 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6296 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6297 {"xim",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6298 #ifdef FEAT_XIM
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6299 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6300 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6301 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6302 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6303 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6304 {"xfontset",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6305 #ifdef FEAT_XFONTSET
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6306 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6307 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6308 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6309 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6310 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6311 {"xpm",
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6312 #if defined(FEAT_XPM_W32) || defined(HAVE_XPM)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6313 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6314 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6315 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6316 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6317 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6318 {"xpm_w32", // for backward compatibility
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6319 #ifdef FEAT_XPM_W32
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6320 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6321 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6322 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6323 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6324 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6325 {"xsmp",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6326 #ifdef USE_XSMP
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6327 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6328 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6329 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6330 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6331 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6332 {"xsmp_interact",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6333 #ifdef USE_XSMP_INTERACT
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6334 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6335 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6336 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6337 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6338 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6339 {"xterm_clipboard",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6340 #ifdef FEAT_XCLIPBOARD
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6341 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6342 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6343 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6344 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6345 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6346 {"xterm_save",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6347 #ifdef FEAT_XTERM_SAVE
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6348 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6349 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6350 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6351 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6352 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6353 {"X11",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6354 #if defined(UNIX) && defined(FEAT_X11)
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6355 1
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6356 #else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6357 0
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6358 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6359 },
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6360 {NULL, 0}
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6361 };
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6362
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6363 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6364 && (check_for_string_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6365 || check_for_opt_bool_arg(argvars, 1) == FAIL))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6366 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6367
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6368 name = tv_get_string(&argvars[0]);
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6369 for (i = 0; has_list[i].name != NULL; ++i)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6370 if (STRICMP(name, has_list[i].name) == 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6371 {
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6372 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6373 n = has_list[i].present;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6374 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6375 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6376
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6377 // features also in has_list[] but sometimes enabled at runtime
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6378 if (x == TRUE && n == FALSE)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6379 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6380 if (0)
19940
724417668d42 patch 8.2.0526: Gcc 9 complains about empty statement
Bram Moolenaar <Bram@vim.org>
parents: 19934
diff changeset
6381 {
724417668d42 patch 8.2.0526: Gcc 9 complains about empty statement
Bram Moolenaar <Bram@vim.org>
parents: 19934
diff changeset
6382 // intentionally empty
724417668d42 patch 8.2.0526: Gcc 9 complains about empty statement
Bram Moolenaar <Bram@vim.org>
parents: 19934
diff changeset
6383 }
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6384 #ifdef VIMDLL
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6385 else if (STRICMP(name, "filterpipe") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6386 n = gui.in_use || gui.starting;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6387 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6388 #if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6389 else if (STRICMP(name, "iconv") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6390 n = iconv_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6391 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6392 #ifdef DYNAMIC_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6393 else if (STRICMP(name, "lua") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6394 n = lua_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6395 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6396 #ifdef DYNAMIC_MZSCHEME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6397 else if (STRICMP(name, "mzscheme") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6398 n = mzscheme_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6399 #endif
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6400 #ifdef DYNAMIC_PERL
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6401 else if (STRICMP(name, "perl") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6402 n = perl_enabled(FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6403 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6404 #ifdef DYNAMIC_PYTHON
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6405 else if (STRICMP(name, "python") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6406 n = python_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6407 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6408 #ifdef DYNAMIC_PYTHON3
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6409 else if (STRICMP(name, "python3") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6410 n = python3_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6411 #endif
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6412 #if defined(DYNAMIC_PYTHON) || defined(DYNAMIC_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6413 else if (STRICMP(name, "pythonx") == 0)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6414 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6415 # if defined(DYNAMIC_PYTHON) && defined(DYNAMIC_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6416 if (p_pyx == 0)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6417 n = python3_enabled(FALSE) || python_enabled(FALSE);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6418 else if (p_pyx == 3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6419 n = python3_enabled(FALSE);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6420 else if (p_pyx == 2)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6421 n = python_enabled(FALSE);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6422 # elif defined(DYNAMIC_PYTHON)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6423 n = python_enabled(FALSE);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6424 # elif defined(DYNAMIC_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6425 n = python3_enabled(FALSE);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6426 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
6427 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6428 #endif
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6429 #ifdef DYNAMIC_RUBY
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6430 else if (STRICMP(name, "ruby") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6431 n = ruby_enabled(FALSE);
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6432 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6433 #ifdef DYNAMIC_TCL
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6434 else if (STRICMP(name, "tcl") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6435 n = tcl_enabled(FALSE);
16527
5412fcd03ecb patch 8.1.1267: cannot check if GPM mouse support is working
Bram Moolenaar <Bram@vim.org>
parents: 16517
diff changeset
6436 #endif
27657
a077948be0f4 patch 8.2.4354: dynamic loading of libsodium not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 27597
diff changeset
6437 #ifdef DYNAMIC_SODIUM
a077948be0f4 patch 8.2.4354: dynamic loading of libsodium not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 27597
diff changeset
6438 else if (STRICMP(name, "sodium") == 0)
a077948be0f4 patch 8.2.4354: dynamic loading of libsodium not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 27597
diff changeset
6439 n = sodium_enabled(FALSE);
a077948be0f4 patch 8.2.4354: dynamic loading of libsodium not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 27597
diff changeset
6440 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
6441 #if defined(FEAT_TERMINAL) && defined(MSWIN)
12144
abd69cea3459 patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents: 12136
diff changeset
6442 else if (STRICMP(name, "terminal") == 0)
abd69cea3459 patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents: 12136
diff changeset
6443 n = terminal_enabled();
abd69cea3459 patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents: 12136
diff changeset
6444 #endif
27863
f1799ba16729 patch 8.2.4457: the GPM library can only be linked statically
Bram Moolenaar <Bram@vim.org>
parents: 27859
diff changeset
6445 #ifdef DYNAMIC_GPM
f1799ba16729 patch 8.2.4457: the GPM library can only be linked statically
Bram Moolenaar <Bram@vim.org>
parents: 27859
diff changeset
6446 else if (STRICMP(name, "mouse_gpm") == 0)
f1799ba16729 patch 8.2.4457: the GPM library can only be linked statically
Bram Moolenaar <Bram@vim.org>
parents: 27859
diff changeset
6447 n = gpm_available();
f1799ba16729 patch 8.2.4457: the GPM library can only be linked statically
Bram Moolenaar <Bram@vim.org>
parents: 27859
diff changeset
6448 #endif
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6449 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6450
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6451 // features not in has_list[]
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6452 if (x == FALSE)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6453 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6454 if (STRNICMP(name, "patch", 5) == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6455 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6456 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6457 if (name[5] == '-'
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6458 && STRLEN(name) >= 11
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6459 && vim_isdigit(name[6])
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6460 && vim_isdigit(name[8])
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6461 && vim_isdigit(name[10]))
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6462 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6463 int major = atoi((char *)name + 6);
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6464 int minor = atoi((char *)name + 8);
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6465
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6466 // Expect "patch-9.9.01234".
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6467 n = (major < VIM_VERSION_MAJOR
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6468 || (major == VIM_VERSION_MAJOR
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6469 && (minor < VIM_VERSION_MINOR
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6470 || (minor == VIM_VERSION_MINOR
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6471 && has_patch(atoi((char *)name + 10))))));
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6472 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6473 else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6474 n = has_patch(atoi((char *)name + 5));
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6475 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6476 else if (STRICMP(name, "vim_starting") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6477 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6478 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6479 n = (starting != 0);
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6480 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6481 else if (STRICMP(name, "ttyin") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6482 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6483 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6484 n = mch_input_isatty();
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6485 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6486 else if (STRICMP(name, "ttyout") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6487 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6488 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6489 n = stdout_isatty;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6490 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6491 else if (STRICMP(name, "multi_byte_encoding") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6492 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6493 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6494 n = has_mbyte;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6495 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6496 else if (STRICMP(name, "gui_running") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6497 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6498 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6499 #ifdef FEAT_GUI
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6500 n = (gui.in_use || gui.starting);
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6501 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6502 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6503 else if (STRICMP(name, "browse") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6504 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6505 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6506 #if defined(FEAT_GUI) && defined(FEAT_BROWSE)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6507 n = gui.in_use; // gui_mch_browse() works when GUI is running
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6508 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6509 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6510 else if (STRICMP(name, "syntax_items") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6511 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6512 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6513 #ifdef FEAT_SYN_HL
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6514 n = syntax_present(curwin);
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6515 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6516 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6517 else if (STRICMP(name, "vcon") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6518 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6519 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6520 #ifdef FEAT_VTP
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6521 n = is_term_win32() && has_vtp_working();
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6522 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6523 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6524 else if (STRICMP(name, "netbeans_enabled") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6525 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6526 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6527 #ifdef FEAT_NETBEANS_INTG
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6528 n = netbeans_active();
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6529 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6530 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6531 else if (STRICMP(name, "mouse_gpm_enabled") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6532 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6533 x = TRUE;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6534 #ifdef FEAT_MOUSE_GPM
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6535 n = gpm_enabled();
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6536 #endif
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6537 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6538 else if (STRICMP(name, "conpty") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6539 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6540 x = TRUE;
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
6541 #if defined(FEAT_TERMINAL) && defined(MSWIN)
15725
a3e2e7948ee4 patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
6542 n = use_conpty();
a3e2e7948ee4 patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
6543 #endif
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6544 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6545 else if (STRICMP(name, "clipboard_working") == 0)
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6546 {
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6547 x = TRUE;
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17676
diff changeset
6548 #ifdef FEAT_CLIPBOARD
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17676
diff changeset
6549 n = clip_star.available;
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17676
diff changeset
6550 #endif
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6551 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6552 }
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6553
22113
a71d7dcba862 patch 8.2.1606: Vim9: cannot use "true" with has()
Bram Moolenaar <Bram@vim.org>
parents: 22103
diff changeset
6554 if (argvars[1].v_type != VAR_UNKNOWN && tv_get_bool(&argvars[1]))
19742
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6555 // return whether feature could ever be enabled
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6556 rettv->vval.v_number = x;
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6557 else
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6558 // return whether feature is enabled
810eee1b42e3 patch 8.2.0427: it is not possible to check for a typo in a feature name
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
6559 rettv->vval.v_number = n;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6560 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6561
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6562 /*
22842
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6563 * Return TRUE if "feature" can change later.
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6564 * Also when checking for the feature has side effects, such as loading a DLL.
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6565 */
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6566 int
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6567 dynamic_feature(char_u *feature)
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6568 {
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6569 return (feature == NULL
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6570 #if defined(FEAT_GUI) && defined(FEAT_BROWSE)
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6571 || (STRICMP(feature, "browse") == 0 && !gui.in_use)
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6572 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6573 #ifdef VIMDLL
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6574 || STRICMP(feature, "filterpipe") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6575 #endif
22854
eea4e7b67f24 patch 8.2.1974: Vim9: test for has('gui_running') fails with VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 22844
diff changeset
6576 #if defined(FEAT_GUI) && !defined(ALWAYS_USE_GUI) && !defined(VIMDLL)
22842
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6577 // this can only change on Unix where the ":gui" command could be
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6578 // used.
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6579 || (STRICMP(feature, "gui_running") == 0 && !gui.in_use)
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6580 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6581 #if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6582 || STRICMP(feature, "iconv") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6583 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6584 #ifdef DYNAMIC_LUA
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6585 || STRICMP(feature, "lua") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6586 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6587 #ifdef FEAT_MOUSE_GPM
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6588 || (STRICMP(feature, "mouse_gpm_enabled") == 0 && !gpm_enabled())
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6589 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6590 #ifdef DYNAMIC_MZSCHEME
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6591 || STRICMP(feature, "mzscheme") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6592 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6593 #ifdef FEAT_NETBEANS_INTG
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6594 || STRICMP(feature, "netbeans_enabled") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6595 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6596 #ifdef DYNAMIC_PERL
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6597 || STRICMP(feature, "perl") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6598 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6599 #ifdef DYNAMIC_PYTHON
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6600 || STRICMP(feature, "python") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6601 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6602 #ifdef DYNAMIC_PYTHON3
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6603 || STRICMP(feature, "python3") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6604 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6605 #if defined(DYNAMIC_PYTHON) || defined(DYNAMIC_PYTHON3)
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6606 || STRICMP(feature, "pythonx") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6607 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6608 #ifdef DYNAMIC_RUBY
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6609 || STRICMP(feature, "ruby") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6610 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6611 #ifdef FEAT_SYN_HL
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6612 || STRICMP(feature, "syntax_items") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6613 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6614 #ifdef DYNAMIC_TCL
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6615 || STRICMP(feature, "tcl") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6616 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6617 // once "starting" is zero it will stay that way
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6618 || (STRICMP(feature, "vim_starting") == 0 && starting != 0)
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6619 || STRICMP(feature, "multi_byte_encoding") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6620 #if defined(FEAT_TERMINAL) && defined(MSWIN)
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6621 || STRICMP(feature, "conpty") == 0
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6622 #endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6623 );
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6624 }
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6625
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22825
diff changeset
6626 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6627 * "haslocaldir()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6628 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6629 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6630 f_haslocaldir(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6631 {
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6632 tabpage_T *tp = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6633 win_T *wp = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6634
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6635 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6636 && (check_for_opt_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6637 || (argvars[0].v_type != VAR_UNKNOWN
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6638 && check_for_opt_number_arg(argvars, 1) == FAIL)))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6639 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6640
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6641 wp = find_tabwin(&argvars[0], &argvars[1], &tp);
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6642
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6643 // Check for window-local and tab-local directories
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6644 if (wp != NULL && wp->w_localdir != NULL)
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6645 rettv->vval.v_number = 1;
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6646 else if (tp != NULL && tp->tp_localdir != NULL)
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6647 rettv->vval.v_number = 2;
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6648 else
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6649 rettv->vval.v_number = 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6650 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6651
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6652 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6653 * "hasmapto()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6654 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6655 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6656 f_hasmapto(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6657 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6658 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6659 char_u *mode;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6660 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6661 int abbr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6662
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6663 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6664 && (check_for_string_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6665 || check_for_opt_string_arg(argvars, 1) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6666 || (argvars[1].v_type != VAR_UNKNOWN
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6667 && check_for_opt_bool_arg(argvars, 2) == FAIL)))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6668 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6669
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6670 name = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6671 if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6672 mode = (char_u *)"nvo";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6673 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6674 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6675 mode = tv_get_string_buf(&argvars[1], buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6676 if (argvars[2].v_type != VAR_UNKNOWN)
22055
88bedbb4ba75 patch 8.2.1577: Vim9: hasmapto()/mapcheck()/maparg() do nottake "true" arg
Bram Moolenaar <Bram@vim.org>
parents: 22053
diff changeset
6677 abbr = (int)tv_get_bool(&argvars[2]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6678 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6679
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6680 if (map_to_exists(name, mode, abbr))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6681 rettv->vval.v_number = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6682 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6683 rettv->vval.v_number = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6684 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6685
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6686 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6687 * "highlightID(name)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6688 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6689 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6690 f_hlID(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6691 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6692 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6693 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6694
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6695 rettv->vval.v_number = syn_name2id(tv_get_string(&argvars[0]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6696 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6697
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6698 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6699 * "highlight_exists()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6700 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6701 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6702 f_hlexists(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6703 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6704 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6705 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6706
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6707 rettv->vval.v_number = highlight_exists(tv_get_string(&argvars[0]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6708 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6709
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6710 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6711 * "hostname()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6712 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6713 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6714 f_hostname(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6715 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6716 char_u hostname[256];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6717
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6718 mch_get_host_name(hostname, 256);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6719 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6720 rettv->vval.v_string = vim_strsave(hostname);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6721 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6722
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6723 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6724 * "index()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6725 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6726 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6727 f_index(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6728 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6729 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6730 listitem_T *item;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6731 blob_T *b;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6732 long idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6733 int ic = FALSE;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6734 int error = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6735
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6736 rettv->vval.v_number = -1;
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6737
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6738 if (in_vim9script()
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
6739 && (check_for_list_or_blob_arg(argvars, 0) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
6740 || (argvars[0].v_type == VAR_BLOB
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
6741 && check_for_number_arg(argvars, 1) == FAIL)
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6742 || check_for_opt_number_arg(argvars, 2) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6743 || (argvars[2].v_type != VAR_UNKNOWN
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6744 && check_for_opt_bool_arg(argvars, 3) == FAIL)))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6745 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
6746
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6747 if (argvars[0].v_type == VAR_BLOB)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6748 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6749 typval_T tv;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6750 int start = 0;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6751
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6752 if (argvars[2].v_type != VAR_UNKNOWN)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6753 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6754 start = tv_get_number_chk(&argvars[2], &error);
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6755 if (error)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6756 return;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6757 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6758 b = argvars[0].vval.v_blob;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6759 if (b == NULL)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6760 return;
15468
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
6761 if (start < 0)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
6762 {
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
6763 start = blob_len(b) + start;
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
6764 if (start < 0)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
6765 start = 0;
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
6766 }
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
6767
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6768 for (idx = start; idx < blob_len(b); ++idx)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6769 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6770 tv.v_type = VAR_NUMBER;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6771 tv.vval.v_number = blob_get(b, idx);
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6772 if (tv_equal(&tv, &argvars[1], ic, FALSE))
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6773 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6774 rettv->vval.v_number = idx;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6775 return;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6776 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6777 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6778 return;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6779 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6780 else if (argvars[0].v_type != VAR_LIST)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6781 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
6782 emsg(_(e_list_or_blob_required));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6783 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6784 }
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
6785
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6786 l = argvars[0].vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6787 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6788 {
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
6789 CHECK_LIST_MATERIALIZE(l);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6790 item = l->lv_first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6791 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6792 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6793 // Start at specified item. Use the cached index that list_find()
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6794 // sets, so that a negative number also works.
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6795 item = list_find(l, (long)tv_get_number_chk(&argvars[2], &error));
19229
d776967d0f0d patch 8.2.0173: build fails with old compiler
Bram Moolenaar <Bram@vim.org>
parents: 19201
diff changeset
6796 idx = l->lv_u.mat.lv_idx;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6797 if (argvars[3].v_type != VAR_UNKNOWN)
22053
0794909e2988 patch 8.2.1576: Vim9: index() does not take "true" as argument
Bram Moolenaar <Bram@vim.org>
parents: 22047
diff changeset
6798 ic = (int)tv_get_bool_chk(&argvars[3], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6799 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6800 item = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6801 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6802
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6803 for ( ; item != NULL; item = item->li_next, ++idx)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6804 if (tv_equal(&item->li_tv, &argvars[1], ic, FALSE))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6805 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6806 rettv->vval.v_number = idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6807 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6808 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6809 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6810 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6811
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6812 static int inputsecret_flag = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6813
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6814 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6815 * "input()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6816 * Also handles inputsecret() when inputsecret is set.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6817 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6818 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6819 f_input(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6820 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6821 get_user_input(argvars, rettv, FALSE, inputsecret_flag);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6822 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6823
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6824 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6825 * "inputdialog()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6826 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6827 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6828 f_inputdialog(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6829 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6830 #if defined(FEAT_GUI_TEXTDIALOG)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6831 // Use a GUI dialog if the GUI is running and 'c' is not in 'guioptions'
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6832 if (gui.in_use && vim_strchr(p_go, GO_CONDIALOG) == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6833 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6834 char_u *message;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6835 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6836 char_u *defstr = (char_u *)"";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6837
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6838 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6839 && (check_for_string_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6840 || check_for_opt_string_arg(argvars, 1) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6841 || (argvars[1].v_type != VAR_UNKNOWN
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6842 && check_for_opt_string_arg(argvars, 2) == FAIL)))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6843 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6844
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6845 message = tv_get_string_chk(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6846 if (argvars[1].v_type != VAR_UNKNOWN
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6847 && (defstr = tv_get_string_buf_chk(&argvars[1], buf)) != NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6848 vim_strncpy(IObuff, defstr, IOSIZE - 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6849 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6850 IObuff[0] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6851 if (message != NULL && defstr != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6852 && do_dialog(VIM_QUESTION, NULL, message,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6853 (char_u *)_("&OK\n&Cancel"), 1, IObuff, FALSE) == 1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6854 rettv->vval.v_string = vim_strsave(IObuff);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6855 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6856 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6857 if (message != NULL && defstr != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6858 && argvars[1].v_type != VAR_UNKNOWN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6859 && argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6860 rettv->vval.v_string = vim_strsave(
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6861 tv_get_string_buf(&argvars[2], buf));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6862 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6863 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6864 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6865 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6866 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6867 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6868 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6869 get_user_input(argvars, rettv, TRUE, inputsecret_flag);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6870 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6871
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6872 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6873 * "inputlist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6874 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6875 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6876 f_inputlist(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6877 {
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
6878 list_T *l;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6879 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6880 int selected;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6881 int mouse_used;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6882
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6883 #ifdef NO_CONSOLE_INPUT
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6884 // While starting up, there is no place to enter text. When running tests
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6885 // with --not-a-term we assume feedkeys() will be used.
11848
f5968ca369b5 patch 8.0.0804: running tests fails when stdin is /dev/null
Christian Brabandt <cb@256bit.org>
parents: 11846
diff changeset
6886 if (no_console_input() && !is_not_a_term())
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6887 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6888 #endif
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6889 if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6890 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6891
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6892 if (argvars[0].v_type != VAR_LIST || argvars[0].vval.v_list == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6893 {
26887
612339679616 patch 8.2.3972: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
6894 semsg(_(e_argument_of_str_must_be_list), "inputlist()");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6895 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6896 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6897
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6898 msg_start();
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6899 msg_row = Rows - 1; // for when 'cmdheight' > 1
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6900 lines_left = Rows; // avoid more prompt
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6901 msg_scroll = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6902 msg_clr_eos();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6903
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
6904 l = argvars[0].vval.v_list;
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
6905 CHECK_LIST_MATERIALIZE(l);
19934
3ff714d765ba patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents: 19922
diff changeset
6906 FOR_ALL_LIST_ITEMS(l, li)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6907 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
6908 msg_puts((char *)tv_get_string(&li->li_tv));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6909 msg_putchar('\n');
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6910 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6911
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6912 // Ask for choice.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6913 selected = prompt_for_number(&mouse_used);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6914 if (mouse_used)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6915 selected -= lines_left;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6916
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6917 rettv->vval.v_number = selected;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6918 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6919
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6920 static garray_T ga_userinput = {0, 0, sizeof(tasave_T), 4, NULL};
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6921
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6922 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6923 * "inputrestore()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6924 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6925 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6926 f_inputrestore(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6927 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6928 if (ga_userinput.ga_len > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6929 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6930 --ga_userinput.ga_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6931 restore_typeahead((tasave_T *)(ga_userinput.ga_data)
24846
fdc6a7769045 patch 8.2.2961: keys typed during a :normal command are discarded
Bram Moolenaar <Bram@vim.org>
parents: 24838
diff changeset
6932 + ga_userinput.ga_len, TRUE);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6933 // default return is zero == OK
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6934 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6935 else if (p_verbose > 1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6936 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
6937 verb_msg(_("called inputrestore() more often than inputsave()"));
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6938 rettv->vval.v_number = 1; // Failed
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6939 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6940 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6941
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6942 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6943 * "inputsave()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6944 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6945 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6946 f_inputsave(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6947 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6948 // Add an entry to the stack of typeahead storage.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6949 if (ga_grow(&ga_userinput, 1) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6950 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6951 save_typeahead((tasave_T *)(ga_userinput.ga_data)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6952 + ga_userinput.ga_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6953 ++ga_userinput.ga_len;
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6954 // default return is zero == OK
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6955 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6956 else
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6957 rettv->vval.v_number = 1; // Failed
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6958 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6959
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6960 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6961 * "inputsecret()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6962 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6963 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6964 f_inputsecret(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6965 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6966 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6967 && (check_for_string_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6968 || check_for_opt_string_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6969 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6970
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6971 ++cmdline_star;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6972 ++inputsecret_flag;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6973 f_input(argvars, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6974 --cmdline_star;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6975 --inputsecret_flag;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6976 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6977
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6978 /*
18699
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
6979 * "interrupt()" function
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
6980 */
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
6981 static void
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
6982 f_interrupt(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
6983 {
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
6984 got_int = TRUE;
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
6985 }
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
6986
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
6987 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6988 * "invert(expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6989 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6990 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6991 f_invert(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6992 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6993 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6994 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
6995
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6996 rettv->vval.v_number = ~tv_get_number_chk(&argvars[0], NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6997 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6998
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6999 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7000 * "islocked()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7001 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7002 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7003 f_islocked(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7004 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7005 lval_T lv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7006 char_u *end;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7007 dictitem_T *di;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7008
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7009 rettv->vval.v_number = -1;
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
7010
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
7011 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
7012 return;
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
7013
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7014 end = get_lval(tv_get_string(&argvars[0]), NULL, &lv, FALSE, FALSE,
25595
c4e29355cd8b patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25559
diff changeset
7015 GLV_NO_AUTOLOAD | GLV_READ_ONLY | GLV_NO_DECL,
c4e29355cd8b patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25559
diff changeset
7016 FNE_CHECK_START);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7017 if (end != NULL && lv.ll_name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7018 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7019 if (*end != NUL)
25244
11ed1f0adb01 patch 8.2.3158: strange error message when using islocked() with a number
Bram Moolenaar <Bram@vim.org>
parents: 25236
diff changeset
7020 {
11ed1f0adb01 patch 8.2.3158: strange error message when using islocked() with a number
Bram Moolenaar <Bram@vim.org>
parents: 25236
diff changeset
7021 semsg(_(lv.ll_name == lv.ll_name_end
27293
e91b577be192 patch 8.2.4175: MS-Windows: runtime check for multi-line balloon is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
7022 ? e_invalid_argument_str : e_trailing_characters_str), end);
25244
11ed1f0adb01 patch 8.2.3158: strange error message when using islocked() with a number
Bram Moolenaar <Bram@vim.org>
parents: 25236
diff changeset
7023 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7024 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7025 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7026 if (lv.ll_tv == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7027 {
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
7028 di = find_var(lv.ll_name, NULL, TRUE);
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
7029 if (di != NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7030 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7031 // Consider a variable locked when:
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7032 // 1. the variable itself is locked
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7033 // 2. the value of the variable is locked.
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7034 // 3. the List or Dict value is locked.
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
7035 rettv->vval.v_number = ((di->di_flags & DI_FLAGS_LOCK)
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
7036 || tv_islocked(&di->di_tv));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7037 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7038 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7039 else if (lv.ll_range)
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26952
diff changeset
7040 emsg(_(e_range_not_allowed));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7041 else if (lv.ll_newkey != NULL)
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
7042 semsg(_(e_key_not_present_in_dictionary), lv.ll_newkey);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7043 else if (lv.ll_list != NULL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7044 // List item.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7045 rettv->vval.v_number = tv_islocked(&lv.ll_li->li_tv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7046 else
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7047 // Dictionary item.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7048 rettv->vval.v_number = tv_islocked(&lv.ll_di->di_tv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7049 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7050 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7051
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7052 clear_lval(&lv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7053 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7054
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7055 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7056 * "last_buffer_nr()" function.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7057 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7058 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7059 f_last_buffer_nr(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7060 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7061 int n = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7062 buf_T *buf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7063
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9636
diff changeset
7064 FOR_ALL_BUFFERS(buf)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7065 if (n < buf->b_fnum)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7066 n = buf->b_fnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7067
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7068 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7069 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7070
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7071 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7072 * "len()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7073 */
28287
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28283
diff changeset
7074 void
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7075 f_len(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7076 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7077 switch (argvars[0].v_type)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7078 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7079 case VAR_STRING:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7080 case VAR_NUMBER:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7081 rettv->vval.v_number = (varnumber_T)STRLEN(
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7082 tv_get_string(&argvars[0]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7083 break;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
7084 case VAR_BLOB:
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
7085 rettv->vval.v_number = blob_len(argvars[0].vval.v_blob);
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
7086 break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7087 case VAR_LIST:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7088 rettv->vval.v_number = list_len(argvars[0].vval.v_list);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7089 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7090 case VAR_DICT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7091 rettv->vval.v_number = dict_len(argvars[0].vval.v_dict);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7092 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7093 case VAR_UNKNOWN:
19922
1f42c49c3d29 patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents: 19920
diff changeset
7094 case VAR_ANY:
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
7095 case VAR_VOID:
19102
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
7096 case VAR_BOOL:
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7097 case VAR_SPECIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7098 case VAR_FLOAT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7099 case VAR_FUNC:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7100 case VAR_PARTIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7101 case VAR_JOB:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7102 case VAR_CHANNEL:
24606
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24307
diff changeset
7103 case VAR_INSTR:
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26950
diff changeset
7104 emsg(_(e_invalid_type_for_len));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7105 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7106 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7107 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7108
10620
2198b53b9ffe patch 8.0.0199: compiler warnings for libcall
Christian Brabandt <cb@256bit.org>
parents: 10567
diff changeset
7109 static void
2198b53b9ffe patch 8.0.0199: compiler warnings for libcall
Christian Brabandt <cb@256bit.org>
parents: 10567
diff changeset
7110 libcall_common(typval_T *argvars UNUSED, typval_T *rettv, int type)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7111 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7112 #ifdef FEAT_LIBCALL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7113 char_u *string_in;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7114 char_u **string_result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7115 int nr_result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7116 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7117
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7118 rettv->v_type = type;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7119 if (type != VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7120 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7121
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7122 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7123 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7124
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
7125 if (in_vim9script()
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
7126 && (check_for_string_arg(argvars, 0) == FAIL
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
7127 || check_for_string_arg(argvars, 1) == FAIL
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
7128 || check_for_string_or_number_arg(argvars, 2) == FAIL))
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
7129 return;
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
7130
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7131 #ifdef FEAT_LIBCALL
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7132 // The first two args must be strings, otherwise it's meaningless
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7133 if (argvars[0].v_type == VAR_STRING && argvars[1].v_type == VAR_STRING)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7134 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7135 string_in = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7136 if (argvars[2].v_type == VAR_STRING)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7137 string_in = argvars[2].vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7138 if (type == VAR_NUMBER)
25721
0612d28321e8 patch 8.2.3396: when libcall() fails invalid pointer may be used
Bram Moolenaar <Bram@vim.org>
parents: 25688
diff changeset
7139 {
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7140 string_result = NULL;
25721
0612d28321e8 patch 8.2.3396: when libcall() fails invalid pointer may be used
Bram Moolenaar <Bram@vim.org>
parents: 25688
diff changeset
7141 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7142 else
25721
0612d28321e8 patch 8.2.3396: when libcall() fails invalid pointer may be used
Bram Moolenaar <Bram@vim.org>
parents: 25688
diff changeset
7143 {
0612d28321e8 patch 8.2.3396: when libcall() fails invalid pointer may be used
Bram Moolenaar <Bram@vim.org>
parents: 25688
diff changeset
7144 rettv->vval.v_string = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7145 string_result = &rettv->vval.v_string;
25721
0612d28321e8 patch 8.2.3396: when libcall() fails invalid pointer may be used
Bram Moolenaar <Bram@vim.org>
parents: 25688
diff changeset
7146 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7147 if (mch_libcall(argvars[0].vval.v_string,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7148 argvars[1].vval.v_string,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7149 string_in,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7150 argvars[2].vval.v_number,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7151 string_result,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7152 &nr_result) == OK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7153 && type == VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7154 rettv->vval.v_number = nr_result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7155 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7156 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7157 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7158
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7159 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7160 * "libcall()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7161 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7162 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7163 f_libcall(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7164 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7165 libcall_common(argvars, rettv, VAR_STRING);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7166 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7167
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7168 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7169 * "libcallnr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7170 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7171 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7172 f_libcallnr(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7173 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7174 libcall_common(argvars, rettv, VAR_NUMBER);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7175 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7176
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7177 /*
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7178 * "line(string, [winid])" function
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7179 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7180 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7181 f_line(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7182 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7183 linenr_T lnum = 0;
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7184 pos_T *fp = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7185 int fnum;
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7186 int id;
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7187 tabpage_T *tp;
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7188 win_T *wp;
26978
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7189 switchwin_T switchwin;
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7190
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
7191 if (in_vim9script()
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
7192 && (check_for_string_arg(argvars, 0) == FAIL
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
7193 || check_for_opt_number_arg(argvars, 1) == FAIL))
25252
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
7194 return;
acda780ffc3e patch 8.2.3162: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25244
diff changeset
7195
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7196 if (argvars[1].v_type != VAR_UNKNOWN)
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7197 {
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7198 // use window specified in the second argument
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7199 id = (int)tv_get_number(&argvars[1]);
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7200 wp = win_id2wp_tp(id, &tp);
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7201 if (wp != NULL && tp != NULL)
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7202 {
26978
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7203 if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7204 {
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7205 check_cursor();
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
7206 fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE);
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7207 }
26978
aa613a3084b9 patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7208 restore_win_noblock(&switchwin, TRUE);
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7209 }
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7210 }
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7211 else
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7212 // use current window
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
7213 fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE);
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
7214
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7215 if (fp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7216 lnum = fp->lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7217 rettv->vval.v_number = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7218 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7219
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7220 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7221 * "line2byte(lnum)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7222 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7223 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7224 f_line2byte(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7225 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7226 #ifndef FEAT_BYTEOFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7227 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7228 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7229 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7230
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7231 if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7232 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7233
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7234 lnum = tv_get_lnum(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7235 if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7236 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7237 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7238 rettv->vval.v_number = ml_find_line_or_offset(curbuf, lnum, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7239 if (rettv->vval.v_number >= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7240 ++rettv->vval.v_number;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7241 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7242 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7243
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7244 #ifdef FEAT_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7245 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7246 * "luaeval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7247 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7248 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7249 f_luaeval(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7250 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7251 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7252 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7253
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7254 if (check_restricted() || check_secure())
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7255 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7256
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
7257 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
7258 return;
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
7259
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7260 str = tv_get_string_buf(&argvars[0], buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7261 do_luaeval(str, argvars + 1, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7262 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7263 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7264
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7265 typedef enum
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7266 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7267 MATCH_END, // matchend()
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7268 MATCH_MATCH, // match()
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7269 MATCH_STR, // matchstr()
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7270 MATCH_LIST, // matchlist()
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7271 MATCH_POS // matchstrpos()
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7272 } matchtype_T;
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7273
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7274 static void
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7275 find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7276 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7277 char_u *str = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7278 long len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7279 char_u *expr = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7280 char_u *pat;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7281 regmatch_T regmatch;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7282 char_u patbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7283 char_u strbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7284 char_u *save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7285 long start = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7286 long nth = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7287 colnr_T startcol = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7288 int match = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7289 list_T *l = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7290 listitem_T *li = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7291 long idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7292 char_u *tofree = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7293
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7294 // Make 'cpoptions' empty, the 'l' flag should not be used here.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7295 save_cpo = p_cpo;
23493
f8382c4e6551 patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents: 23380
diff changeset
7296 p_cpo = empty_option;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7297
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7298 rettv->vval.v_number = -1;
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7299 if (type == MATCH_LIST || type == MATCH_POS)
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7300 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7301 // type MATCH_LIST: return empty list when there are no matches.
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7302 // type MATCH_POS: return ["", -1, -1, -1]
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7303 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7304 goto theend;
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7305 if (type == MATCH_POS
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7306 && (list_append_string(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7307 (char_u *)"", 0) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7308 || list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7309 (varnumber_T)-1) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7310 || list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7311 (varnumber_T)-1) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7312 || list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7313 (varnumber_T)-1) == FAIL))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7314 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7315 list_free(rettv->vval.v_list);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7316 rettv->vval.v_list = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7317 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7318 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7319 }
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7320 else if (type == MATCH_STR)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7321 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7322 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7323 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7324 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7325
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
7326 if (in_vim9script()
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7327 && (check_for_string_or_list_arg(argvars, 0) == FAIL
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
7328 || check_for_string_arg(argvars, 1) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
7329 || check_for_opt_number_arg(argvars, 2) == FAIL
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
7330 || (argvars[2].v_type != VAR_UNKNOWN
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
7331 && check_for_opt_number_arg(argvars, 3) == FAIL)))
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
7332 goto theend;
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
7333
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7334 if (argvars[0].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7335 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7336 if ((l = argvars[0].vval.v_list) == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7337 goto theend;
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
7338 CHECK_LIST_MATERIALIZE(l);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7339 li = l->lv_first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7340 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7341 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7342 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7343 expr = str = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7344 len = (long)STRLEN(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7345 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7346
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7347 pat = tv_get_string_buf_chk(&argvars[1], patbuf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7348 if (pat == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7349 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7350
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7351 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7352 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7353 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7354
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7355 start = (long)tv_get_number_chk(&argvars[2], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7356 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7357 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7358 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7359 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7360 li = list_find(l, start);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7361 if (li == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7362 goto theend;
19229
d776967d0f0d patch 8.2.0173: build fails with old compiler
Bram Moolenaar <Bram@vim.org>
parents: 19201
diff changeset
7363 idx = l->lv_u.mat.lv_idx; // use the cached index
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7364 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7365 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7366 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7367 if (start < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7368 start = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7369 if (start > len)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7370 goto theend;
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7371 // When "count" argument is there ignore matches before "start",
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7372 // otherwise skip part of the string. Differs when pattern is "^"
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7373 // or "\<".
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7374 if (argvars[3].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7375 startcol = start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7376 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7377 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7378 str += start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7379 len -= start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7380 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7381 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7382
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7383 if (argvars[3].v_type != VAR_UNKNOWN)
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7384 nth = (long)tv_get_number_chk(&argvars[3], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7385 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7386 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7387 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7388
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7389 regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7390 if (regmatch.regprog != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7391 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7392 regmatch.rm_ic = p_ic;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7393
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7394 for (;;)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7395 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7396 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7397 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7398 if (li == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7399 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7400 match = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7401 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7402 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7403 vim_free(tofree);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7404 expr = str = echo_string(&li->li_tv, &tofree, strbuf, 0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7405 if (str == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7406 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7407 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7408
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 27406
diff changeset
7409 match = vim_regexec_nl(&regmatch, str, startcol);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7410
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7411 if (match && --nth <= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7412 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7413 if (l == NULL && !match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7414 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7415
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7416 // Advance to just after the match.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7417 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7418 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7419 li = li->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7420 ++idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7421 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7422 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7423 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7424 startcol = (colnr_T)(regmatch.startp[0]
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7425 + (*mb_ptr2len)(regmatch.startp[0]) - str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7426 if (startcol > (colnr_T)len
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7427 || str + startcol <= regmatch.startp[0])
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7428 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7429 match = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7430 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7431 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7432 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7433 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7434
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7435 if (match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7436 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7437 if (type == MATCH_POS)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7438 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7439 listitem_T *li1 = rettv->vval.v_list->lv_first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7440 listitem_T *li2 = li1->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7441 listitem_T *li3 = li2->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7442 listitem_T *li4 = li3->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7443
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7444 vim_free(li1->li_tv.vval.v_string);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7445 li1->li_tv.vval.v_string = vim_strnsave(regmatch.startp[0],
20751
d9a2e5dcfd9f patch 8.2.0928: many type casts are used for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents: 20743
diff changeset
7446 regmatch.endp[0] - regmatch.startp[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7447 li3->li_tv.vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7448 (varnumber_T)(regmatch.startp[0] - expr);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7449 li4->li_tv.vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7450 (varnumber_T)(regmatch.endp[0] - expr);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7451 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7452 li2->li_tv.vval.v_number = (varnumber_T)idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7453 }
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7454 else if (type == MATCH_LIST)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7455 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7456 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7457
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7458 // return list with matched string and submatches
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7459 for (i = 0; i < NSUBEXP; ++i)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7460 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7461 if (regmatch.endp[i] == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7462 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7463 if (list_append_string(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7464 (char_u *)"", 0) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7465 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7466 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7467 else if (list_append_string(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7468 regmatch.startp[i],
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7469 (int)(regmatch.endp[i] - regmatch.startp[i]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7470 == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7471 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7472 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7473 }
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7474 else if (type == MATCH_STR)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7475 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7476 // return matched string
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7477 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7478 copy_tv(&li->li_tv, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7479 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7480 rettv->vval.v_string = vim_strnsave(regmatch.startp[0],
20751
d9a2e5dcfd9f patch 8.2.0928: many type casts are used for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents: 20743
diff changeset
7481 regmatch.endp[0] - regmatch.startp[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7482 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7483 else if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7484 rettv->vval.v_number = idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7485 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7486 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7487 if (type != MATCH_END)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7488 rettv->vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7489 (varnumber_T)(regmatch.startp[0] - str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7490 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7491 rettv->vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7492 (varnumber_T)(regmatch.endp[0] - str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7493 rettv->vval.v_number += (varnumber_T)(str - expr);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7494 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7495 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7496 vim_regfree(regmatch.regprog);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7497 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7498
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7499 theend:
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7500 if (type == MATCH_POS && l == NULL && rettv->vval.v_list != NULL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7501 // matchstrpos() without a list: drop the second item.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7502 listitem_remove(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7503 rettv->vval.v_list->lv_first->li_next);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7504 vim_free(tofree);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7505 p_cpo = save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7506 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7507
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7508 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7509 * "match()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7510 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7511 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7512 f_match(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7513 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7514 find_some_match(argvars, rettv, MATCH_MATCH);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7515 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7516
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7517 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7518 * "matchend()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7519 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7520 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7521 f_matchend(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7522 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7523 find_some_match(argvars, rettv, MATCH_END);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7524 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7525
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7526 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7527 * "matchlist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7528 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7529 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7530 f_matchlist(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7531 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7532 find_some_match(argvars, rettv, MATCH_LIST);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7533 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7534
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7535 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7536 * "matchstr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7537 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7538 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7539 f_matchstr(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7540 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7541 find_some_match(argvars, rettv, MATCH_STR);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7542 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7543
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7544 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7545 * "matchstrpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7546 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7547 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7548 f_matchstrpos(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7549 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
7550 find_some_match(argvars, rettv, MATCH_POS);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7551 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7552
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7553 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7554 max_min(typval_T *argvars, typval_T *rettv, int domax)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7555 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7556 varnumber_T n = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7557 varnumber_T i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7558 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7559
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7560 if (in_vim9script() && check_for_list_or_dict_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7561 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7562
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7563 if (argvars[0].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7564 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7565 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7566 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7567
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7568 l = argvars[0].vval.v_list;
19247
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7569 if (l != NULL && l->lv_len > 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7570 {
19247
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7571 if (l->lv_first == &range_list_item)
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7572 {
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7573 if ((l->lv_u.nonmat.lv_stride > 0) ^ domax)
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7574 n = l->lv_u.nonmat.lv_start;
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7575 else
27453
c7f614c9ceb3 patch 8.2.4255: theoretical computation overflow
Bram Moolenaar <Bram@vim.org>
parents: 27447
diff changeset
7576 n = l->lv_u.nonmat.lv_start + ((varnumber_T)l->lv_len - 1)
19247
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7577 * l->lv_u.nonmat.lv_stride;
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7578 }
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7579 else
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7580 {
19247
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7581 li = l->lv_first;
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7582 if (li != NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7583 {
19247
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7584 n = tv_get_number_chk(&li->li_tv, &error);
23849
a45a922832d4 patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents: 23816
diff changeset
7585 if (error)
a45a922832d4 patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents: 23816
diff changeset
7586 return; // type error; errmsg already given
19247
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7587 for (;;)
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7588 {
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7589 li = li->li_next;
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7590 if (li == NULL)
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7591 break;
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7592 i = tv_get_number_chk(&li->li_tv, &error);
23849
a45a922832d4 patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents: 23816
diff changeset
7593 if (error)
a45a922832d4 patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents: 23816
diff changeset
7594 return; // type error; errmsg already given
19247
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7595 if (domax ? i > n : i < n)
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7596 n = i;
c077438ceb93 patch 8.2.0182: min() and max() materialize a range() list
Bram Moolenaar <Bram@vim.org>
parents: 19229
diff changeset
7597 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7598 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7599 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7600 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7601 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7602 else if (argvars[0].v_type == VAR_DICT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7603 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7604 dict_T *d;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7605 int first = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7606 hashitem_T *hi;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7607 int todo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7608
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7609 d = argvars[0].vval.v_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7610 if (d != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7611 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7612 todo = (int)d->dv_hashtab.ht_used;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7613 for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7614 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7615 if (!HASHITEM_EMPTY(hi))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7616 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7617 --todo;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7618 i = tv_get_number_chk(&HI2DI(hi)->di_tv, &error);
23849
a45a922832d4 patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents: 23816
diff changeset
7619 if (error)
a45a922832d4 patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents: 23816
diff changeset
7620 return; // type error; errmsg already given
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7621 if (first)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7622 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7623 n = i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7624 first = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7625 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7626 else if (domax ? i > n : i < n)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7627 n = i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7628 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7629 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7630 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7631 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7632 else
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
7633 semsg(_(e_argument_of_str_must_be_list_or_dictionary), domax ? "max()" : "min()");
23849
a45a922832d4 patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents: 23816
diff changeset
7634
a45a922832d4 patch 8.2.2466: max() and min() can give many error messages
Bram Moolenaar <Bram@vim.org>
parents: 23816
diff changeset
7635 rettv->vval.v_number = n;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7636 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7637
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7638 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7639 * "max()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7640 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7641 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7642 f_max(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7643 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7644 max_min(argvars, rettv, TRUE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7645 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7646
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7647 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7648 * "min()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7649 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7650 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7651 f_min(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7652 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7653 max_min(argvars, rettv, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7654 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7655
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7656 #if defined(FEAT_MZSCHEME) || defined(PROTO)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7657 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7658 * "mzeval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7659 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7660 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7661 f_mzeval(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7662 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7663 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7664 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7665
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7666 if (check_restricted() || check_secure())
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7667 return;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7668
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7669 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7670 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7671
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7672 str = tv_get_string_buf(&argvars[0], buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7673 do_mzeval(str, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7674 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7675
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7676 void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7677 mzscheme_call_vim(char_u *name, typval_T *args, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7678 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7679 typval_T argvars[3];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7680
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7681 argvars[0].v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7682 argvars[0].vval.v_string = name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7683 copy_tv(args, &argvars[1]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7684 argvars[2].v_type = VAR_UNKNOWN;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7685 f_call(argvars, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7686 clear_tv(&argvars[1]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7687 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7688 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7689
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7690 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7691 * "nextnonblank()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7692 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7693 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7694 f_nextnonblank(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7695 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7696 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7697
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7698 if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7699 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7700
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7701 for (lnum = tv_get_lnum(argvars); ; ++lnum)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7702 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7703 if (lnum < 0 || lnum > curbuf->b_ml.ml_line_count)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7704 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7705 lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7706 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7707 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7708 if (*skipwhite(ml_get(lnum)) != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7709 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7710 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7711 rettv->vval.v_number = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7712 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7713
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7714 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7715 * "nr2char()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7716 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7717 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7718 f_nr2char(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7719 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7720 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7721
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
7722 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
7723 && (check_for_number_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
7724 || check_for_opt_bool_arg(argvars, 1) == FAIL))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
7725 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
7726
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7727 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7728 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7729 int utf8 = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7730
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7731 if (argvars[1].v_type != VAR_UNKNOWN)
22123
978f91276449 patch 8.2.1611: Vim9: cannot pass "true" to nr2char()
Bram Moolenaar <Bram@vim.org>
parents: 22121
diff changeset
7732 utf8 = (int)tv_get_bool_chk(&argvars[1], NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7733 if (utf8)
15967
ddd82b1c9e9d patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents: 15955
diff changeset
7734 buf[utf_char2bytes((int)tv_get_number(&argvars[0]), buf)] = NUL;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7735 else
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7736 buf[(*mb_char2bytes)((int)tv_get_number(&argvars[0]), buf)] = NUL;
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7737 }
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7738 else
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7739 {
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7740 buf[0] = (char_u)tv_get_number(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7741 buf[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7742 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7743 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7744 rettv->vval.v_string = vim_strsave(buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7745 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7746
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7747 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7748 * "or(expr, expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7749 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7750 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7751 f_or(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7752 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7753 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7754 && (check_for_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7755 || check_for_number_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7756 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7757
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7758 rettv->vval.v_number = tv_get_number_chk(&argvars[0], NULL)
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7759 | tv_get_number_chk(&argvars[1], NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7760 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7761
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7762 #ifdef FEAT_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7763 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7764 * "perleval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7765 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7766 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7767 f_perleval(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7768 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7769 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7770 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7771
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7772 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7773 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7774
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7775 str = tv_get_string_buf(&argvars[0], buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7776 do_perleval(str, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7777 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7778 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7779
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7780 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7781 * "prevnonblank()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7782 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7783 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7784 f_prevnonblank(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7785 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7786 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7787
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7788 if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7789 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7790
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7791 lnum = tv_get_lnum(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7792 if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7793 lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7794 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7795 while (lnum >= 1 && *skipwhite(ml_get(lnum)) == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7796 --lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7797 rettv->vval.v_number = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7798 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7799
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7800 // This dummy va_list is here because:
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7801 // - passing a NULL pointer doesn't work when va_list isn't a pointer
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7802 // - locally in the function results in a "used before set" warning
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7803 // - using va_start() to initialize it gives "function with fixed args" error
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7804 static va_list ap;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7805
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7806 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7807 * "printf()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7808 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7809 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7810 f_printf(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7811 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7812 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7813 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7814 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7815 int saved_did_emsg = did_emsg;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7816 char *fmt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7817
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7818 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7819 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7820
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
7821 if (in_vim9script() && check_for_string_or_number_arg(argvars, 0) == FAIL)
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
7822 return;
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
7823
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7824 // Get the required length, allocate the buffer and do it for real.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7825 did_emsg = FALSE;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7826 fmt = (char *)tv_get_string_buf(&argvars[0], buf);
11653
67cf0d45b006 patch 8.0.0709: libvterm cannot use vsnprintf()
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
7827 len = vim_vsnprintf_typval(NULL, 0, fmt, ap, argvars + 1);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7828 if (!did_emsg)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7829 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7830 s = alloc(len + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7831 if (s != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7832 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7833 rettv->vval.v_string = s;
11653
67cf0d45b006 patch 8.0.0709: libvterm cannot use vsnprintf()
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
7834 (void)vim_vsnprintf_typval((char *)s, len + 1, fmt,
67cf0d45b006 patch 8.0.0709: libvterm cannot use vsnprintf()
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
7835 ap, argvars + 1);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7836 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7837 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7838 did_emsg |= saved_did_emsg;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7839 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7840
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7841 /*
17756
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
7842 * "pum_getpos()" function
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
7843 */
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
7844 static void
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
7845 f_pum_getpos(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
7846 {
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
7847 if (rettv_dict_alloc(rettv) == FAIL)
17756
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
7848 return;
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
7849 pum_set_event_info(rettv->vval.v_dict);
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
7850 }
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
7851
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
7852 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7853 * "pumvisible()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7854 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7855 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7856 f_pumvisible(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7857 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7858 if (pum_visible())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7859 rettv->vval.v_number = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7860 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7861
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7862 #ifdef FEAT_PYTHON3
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7863 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7864 * "py3eval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7865 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7866 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7867 f_py3eval(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7868 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7869 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7870 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7871
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7872 if (check_restricted() || check_secure())
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7873 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7874
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7875 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7876 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7877
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7878 if (p_pyx == 0)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7879 p_pyx = 3;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7880
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7881 str = tv_get_string_buf(&argvars[0], buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7882 do_py3eval(str, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7883 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7884 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7885
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7886 #ifdef FEAT_PYTHON
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7887 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7888 * "pyeval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7889 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7890 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7891 f_pyeval(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7892 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7893 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7894 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7895
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7896 if (check_restricted() || check_secure())
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7897 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7898
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7899 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7900 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7901
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7902 if (p_pyx == 0)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7903 p_pyx = 2;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7904
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7905 str = tv_get_string_buf(&argvars[0], buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7906 do_pyeval(str, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7907 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7908 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7909
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7910 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7911 /*
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7912 * "pyxeval()" function
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7913 */
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7914 static void
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7915 f_pyxeval(typval_T *argvars, typval_T *rettv)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7916 {
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7917 if (check_restricted() || check_secure())
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7918 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
7919
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7920 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7921 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7922
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7923 # if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7924 init_pyxversion();
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7925 if (p_pyx == 2)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7926 f_pyeval(argvars, rettv);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7927 else
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7928 f_py3eval(argvars, rettv);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7929 # elif defined(FEAT_PYTHON)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7930 f_pyeval(argvars, rettv);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7931 # elif defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7932 f_py3eval(argvars, rettv);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7933 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7934 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7935 #endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
7936
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7937 static UINT32_T srand_seed_for_testing = 0;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7938 static int srand_seed_for_testing_is_used = FALSE;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7939
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7940 static void
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7941 f_test_srand_seed(typval_T *argvars, typval_T *rettv UNUSED)
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7942 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7943 if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7944 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
7945
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7946 if (argvars[0].v_type == VAR_UNKNOWN)
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
7947 srand_seed_for_testing_is_used = FALSE;
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7948 else
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7949 {
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
7950 srand_seed_for_testing = (UINT32_T)tv_get_number(&argvars[0]);
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
7951 srand_seed_for_testing_is_used = TRUE;
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7952 }
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7953 }
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7954
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7955 static void
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7956 init_srand(UINT32_T *x)
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7957 {
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7958 #ifndef MSWIN
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7959 static int dev_urandom_state = NOTDONE; // FAIL or OK once tried
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7960 #endif
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7961
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7962 if (srand_seed_for_testing_is_used)
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7963 {
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
7964 *x = srand_seed_for_testing;
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7965 return;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7966 }
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7967 #ifndef MSWIN
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7968 if (dev_urandom_state != FAIL)
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7969 {
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7970 int fd = open("/dev/urandom", O_RDONLY);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7971 struct {
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7972 union {
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7973 UINT32_T number;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7974 char bytes[sizeof(UINT32_T)];
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7975 } contents;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7976 } buf;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7977
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7978 // Attempt reading /dev/urandom.
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7979 if (fd == -1)
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7980 dev_urandom_state = FAIL;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7981 else
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7982 {
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7983 buf.contents.number = 0;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7984 if (read(fd, buf.contents.bytes, sizeof(UINT32_T))
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7985 != sizeof(UINT32_T))
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7986 dev_urandom_state = FAIL;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7987 else
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7988 {
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7989 dev_urandom_state = OK;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7990 *x = buf.contents.number;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7991 }
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7992 close(fd);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7993 }
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7994 }
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7995 if (dev_urandom_state != OK)
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7996 // Reading /dev/urandom doesn't work, fall back to time().
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7997 #endif
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7998 *x = vim_time();
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
7999 }
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8000
27752
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8001 #define ROTL(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8002 #define SPLITMIX32(x, z) ( \
27752
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8003 (z) = ((x) += 0x9e3779b9), \
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8004 (z) = ((z) ^ ((z) >> 16)) * 0x85ebca6b, \
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8005 (z) = ((z) ^ ((z) >> 13)) * 0xc2b2ae35, \
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8006 (z) ^ ((z) >> 16) \
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8007 )
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8008 #define SHUFFLE_XOSHIRO128STARSTAR(x, y, z, w) \
27752
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8009 result = ROTL((y) * 5, 7) * 9; \
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8010 t = (y) << 9; \
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8011 (z) ^= (x); \
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8012 (w) ^= (y); \
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8013 (y) ^= (z), (x) ^= (w); \
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8014 (z) ^= t; \
c1d1639b52dd patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents: 27698
diff changeset
8015 (w) = ROTL(w, 11);
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8016
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8017 /*
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8018 * "rand()" function
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8019 */
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8020 static void
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8021 f_rand(typval_T *argvars, typval_T *rettv)
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8022 {
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8023 list_T *l = NULL;
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8024 static UINT32_T gx, gy, gz, gw;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8025 static int initialized = FALSE;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8026 listitem_T *lx, *ly, *lz, *lw;
22825
3996539f38b4 patch 8.2.1960: warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 22766
diff changeset
8027 UINT32_T x = 0, y, z, w, t, result;
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8028
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8029 if (in_vim9script() && check_for_opt_list_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8030 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8031
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8032 if (argvars[0].v_type == VAR_UNKNOWN)
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8033 {
18732
2513e666aa82 patch 8.1.2356: rand() does not use the best algorithm
Bram Moolenaar <Bram@vim.org>
parents: 18703
diff changeset
8034 // When no argument is given use the global seed list.
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8035 if (initialized == FALSE)
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8036 {
18732
2513e666aa82 patch 8.1.2356: rand() does not use the best algorithm
Bram Moolenaar <Bram@vim.org>
parents: 18703
diff changeset
8037 // Initialize the global seed list.
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8038 init_srand(&x);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8039
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8040 gx = SPLITMIX32(x, z);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8041 gy = SPLITMIX32(x, z);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8042 gz = SPLITMIX32(x, z);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8043 gw = SPLITMIX32(x, z);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8044 initialized = TRUE;
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8045 }
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8046
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8047 SHUFFLE_XOSHIRO128STARSTAR(gx, gy, gz, gw);
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8048 }
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8049 else if (argvars[0].v_type == VAR_LIST)
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8050 {
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8051 l = argvars[0].vval.v_list;
18732
2513e666aa82 patch 8.1.2356: rand() does not use the best algorithm
Bram Moolenaar <Bram@vim.org>
parents: 18703
diff changeset
8052 if (l == NULL || list_len(l) != 4)
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8053 goto theend;
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8054
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8055 lx = list_find(l, 0L);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8056 ly = list_find(l, 1L);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8057 lz = list_find(l, 2L);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8058 lw = list_find(l, 3L);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8059 if (lx->li_tv.v_type != VAR_NUMBER) goto theend;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8060 if (ly->li_tv.v_type != VAR_NUMBER) goto theend;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8061 if (lz->li_tv.v_type != VAR_NUMBER) goto theend;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8062 if (lw->li_tv.v_type != VAR_NUMBER) goto theend;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8063 x = (UINT32_T)lx->li_tv.vval.v_number;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8064 y = (UINT32_T)ly->li_tv.vval.v_number;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8065 z = (UINT32_T)lz->li_tv.vval.v_number;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8066 w = (UINT32_T)lw->li_tv.vval.v_number;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8067
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8068 SHUFFLE_XOSHIRO128STARSTAR(x, y, z, w);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8069
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8070 lx->li_tv.vval.v_number = (varnumber_T)x;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8071 ly->li_tv.vval.v_number = (varnumber_T)y;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8072 lz->li_tv.vval.v_number = (varnumber_T)z;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8073 lw->li_tv.vval.v_number = (varnumber_T)w;
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8074 }
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8075 else
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8076 goto theend;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8077
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8078 rettv->v_type = VAR_NUMBER;
18732
2513e666aa82 patch 8.1.2356: rand() does not use the best algorithm
Bram Moolenaar <Bram@vim.org>
parents: 18703
diff changeset
8079 rettv->vval.v_number = (varnumber_T)result;
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8080 return;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8081
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8082 theend:
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
8083 semsg(_(e_invalid_argument_str), tv_get_string(&argvars[0]));
18732
2513e666aa82 patch 8.1.2356: rand() does not use the best algorithm
Bram Moolenaar <Bram@vim.org>
parents: 18703
diff changeset
8084 rettv->v_type = VAR_NUMBER;
2513e666aa82 patch 8.1.2356: rand() does not use the best algorithm
Bram Moolenaar <Bram@vim.org>
parents: 18703
diff changeset
8085 rettv->vval.v_number = -1;
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8086 }
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8087
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
8088 /*
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8089 * "srand()" function
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8090 */
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8091 static void
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8092 f_srand(typval_T *argvars, typval_T *rettv)
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8093 {
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8094 UINT32_T x = 0, z;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8095
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8096 if (rettv_list_alloc(rettv) == FAIL)
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8097 return;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8098
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8099 if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8100 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8101
19350
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8102 if (argvars[0].v_type == VAR_UNKNOWN)
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8103 {
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8104 init_srand(&x);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8105 }
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8106 else
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8107 {
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8108 int error = FALSE;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8109
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8110 x = (UINT32_T)tv_get_number_chk(&argvars[0], &error);
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8111 if (error)
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8112 return;
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8113 }
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8114
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8115 list_append_number(rettv->vval.v_list, (varnumber_T)SPLITMIX32(x, z));
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8116 list_append_number(rettv->vval.v_list, (varnumber_T)SPLITMIX32(x, z));
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8117 list_append_number(rettv->vval.v_list, (varnumber_T)SPLITMIX32(x, z));
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8118 list_append_number(rettv->vval.v_list, (varnumber_T)SPLITMIX32(x, z));
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8119 }
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8120
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8121 #undef ROTL
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8122 #undef SPLITMIX32
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8123 #undef SHUFFLE_XOSHIRO128STARSTAR
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8124
76cb39bf1871 patch 8.2.0233: crash when using garbagecollect() in between rand()
Bram Moolenaar <Bram@vim.org>
parents: 19308
diff changeset
8125 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8126 * "range()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8127 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8128 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8129 f_range(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8130 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8131 varnumber_T start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8132 varnumber_T end;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8133 varnumber_T stride = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8134 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8135
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
8136 if (rettv_list_alloc(rettv) == FAIL)
29138
175eacde28b8 patch 8.2.5089: some functions return a different value on failure
Bram Moolenaar <Bram@vim.org>
parents: 29071
diff changeset
8137 return;
175eacde28b8 patch 8.2.5089: some functions return a different value on failure
Bram Moolenaar <Bram@vim.org>
parents: 29071
diff changeset
8138
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8139 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8140 && (check_for_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8141 || check_for_opt_number_arg(argvars, 1) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8142 || (argvars[1].v_type != VAR_UNKNOWN
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8143 && check_for_opt_number_arg(argvars, 2) == FAIL)))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8144 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8145
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8146 start = tv_get_number_chk(&argvars[0], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8147 if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8148 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8149 end = start - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8150 start = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8151 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8152 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8153 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8154 end = tv_get_number_chk(&argvars[1], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8155 if (argvars[2].v_type != VAR_UNKNOWN)
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8156 stride = tv_get_number_chk(&argvars[2], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8157 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8158
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8159 if (error)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8160 return; // type error; errmsg already given
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8161 if (stride == 0)
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26950
diff changeset
8162 emsg(_(e_stride_is_zero));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8163 else if (stride > 0 ? end + 1 < start : end - 1 > start)
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26950
diff changeset
8164 emsg(_(e_start_past_end));
29138
175eacde28b8 patch 8.2.5089: some functions return a different value on failure
Bram Moolenaar <Bram@vim.org>
parents: 29071
diff changeset
8165 else
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8166 {
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8167 list_T *list = rettv->vval.v_list;
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8168
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8169 // Create a non-materialized list. This is much more efficient and
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8170 // works with ":for". If used otherwise CHECK_LIST_MATERIALIZE() must
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8171 // be called.
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8172 list->lv_first = &range_list_item;
19229
d776967d0f0d patch 8.2.0173: build fails with old compiler
Bram Moolenaar <Bram@vim.org>
parents: 19201
diff changeset
8173 list->lv_u.nonmat.lv_start = start;
d776967d0f0d patch 8.2.0173: build fails with old compiler
Bram Moolenaar <Bram@vim.org>
parents: 19201
diff changeset
8174 list->lv_u.nonmat.lv_end = end;
d776967d0f0d patch 8.2.0173: build fails with old compiler
Bram Moolenaar <Bram@vim.org>
parents: 19201
diff changeset
8175 list->lv_u.nonmat.lv_stride = stride;
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
8176 list->lv_len = (end - start) / stride + 1;
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8177 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8178 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8179
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8180 /*
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8181 * Materialize "list".
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8182 * Do not call directly, use CHECK_LIST_MATERIALIZE()
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8183 */
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8184 void
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8185 range_list_materialize(list_T *list)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
8186 {
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8187 varnumber_T start = list->lv_u.nonmat.lv_start;
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8188 varnumber_T end = list->lv_u.nonmat.lv_end;
27394
69a48bcd1d80 patch 8.2.4225: Vim9: depth argument of :lockvar not parsed in :def function
Bram Moolenaar <Bram@vim.org>
parents: 27392
diff changeset
8189 int stride = list->lv_u.nonmat.lv_stride;
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8190 varnumber_T i;
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8191
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8192 list->lv_first = NULL;
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8193 list->lv_u.mat.lv_last = NULL;
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8194 list->lv_len = 0;
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8195 list->lv_u.mat.lv_idx_item = NULL;
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8196 for (i = start; stride > 0 ? i <= end : i >= end; i += stride)
27394
69a48bcd1d80 patch 8.2.4225: Vim9: depth argument of :lockvar not parsed in :def function
Bram Moolenaar <Bram@vim.org>
parents: 27392
diff changeset
8197 {
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 27406
diff changeset
8198 if (list_append_number(list, i) == FAIL)
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
8199 break;
27394
69a48bcd1d80 patch 8.2.4225: Vim9: depth argument of :lockvar not parsed in :def function
Bram Moolenaar <Bram@vim.org>
parents: 27392
diff changeset
8200 if (list->lv_lock & VAR_ITEMS_LOCKED)
69a48bcd1d80 patch 8.2.4225: Vim9: depth argument of :lockvar not parsed in :def function
Bram Moolenaar <Bram@vim.org>
parents: 27392
diff changeset
8201 list->lv_u.mat.lv_last->li_tv.v_lock = VAR_LOCKED;
69a48bcd1d80 patch 8.2.4225: Vim9: depth argument of :lockvar not parsed in :def function
Bram Moolenaar <Bram@vim.org>
parents: 27392
diff changeset
8202 }
69a48bcd1d80 patch 8.2.4225: Vim9: depth argument of :lockvar not parsed in :def function
Bram Moolenaar <Bram@vim.org>
parents: 27392
diff changeset
8203 list->lv_lock &= ~VAR_ITEMS_LOCKED;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8204 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8205
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8206 /*
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8207 * "getreginfo()" function
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8208 */
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8209 static void
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8210 f_getreginfo(typval_T *argvars, typval_T *rettv)
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8211 {
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8212 int regname;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8213 char_u buf[NUMBUFLEN + 2];
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8214 long reglen = 0;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8215 dict_T *dict;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8216 list_T *list;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8217
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8218 if (in_vim9script() && check_for_opt_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8219 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8220
26706
71e6e67b2898 patch 8.2.3882: more duplicated code in f_getreginfo()
Bram Moolenaar <Bram@vim.org>
parents: 26700
diff changeset
8221 regname = getreg_get_regname(argvars);
71e6e67b2898 patch 8.2.3882: more duplicated code in f_getreginfo()
Bram Moolenaar <Bram@vim.org>
parents: 26700
diff changeset
8222 if (regname == 0)
71e6e67b2898 patch 8.2.3882: more duplicated code in f_getreginfo()
Bram Moolenaar <Bram@vim.org>
parents: 26700
diff changeset
8223 return;
71e6e67b2898 patch 8.2.3882: more duplicated code in f_getreginfo()
Bram Moolenaar <Bram@vim.org>
parents: 26700
diff changeset
8224
71e6e67b2898 patch 8.2.3882: more duplicated code in f_getreginfo()
Bram Moolenaar <Bram@vim.org>
parents: 26700
diff changeset
8225 if (regname == '@')
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8226 regname = '"';
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8227
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8228 if (rettv_dict_alloc(rettv) == FAIL)
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8229 return;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8230 dict = rettv->vval.v_dict;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8231
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8232 list = (list_T *)get_reg_contents(regname, GREG_EXPR_SRC | GREG_LIST);
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8233 if (list == NULL)
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8234 return;
21062
c2a368193769 patch 8.2.1082: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents: 20992
diff changeset
8235 (void)dict_add_list(dict, "regcontents", list);
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8236
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8237 buf[0] = NUL;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8238 buf[1] = NUL;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8239 switch (get_reg_type(regname, &reglen))
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8240 {
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8241 case MLINE: buf[0] = 'V'; break;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8242 case MCHAR: buf[0] = 'v'; break;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8243 case MBLOCK:
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8244 vim_snprintf((char *)buf, sizeof(buf), "%c%ld", Ctrl_V,
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8245 reglen + 1);
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8246 break;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8247 }
21062
c2a368193769 patch 8.2.1082: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents: 20992
diff changeset
8248 (void)dict_add_string(dict, (char *)"regtype", buf);
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8249
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8250 buf[0] = get_register_name(get_unname_register());
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8251 buf[1] = NUL;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8252 if (regname == '"')
21062
c2a368193769 patch 8.2.1082: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents: 20992
diff changeset
8253 (void)dict_add_string(dict, (char *)"points_to", buf);
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8254 else
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8255 {
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8256 dictitem_T *item = dictitem_alloc((char_u *)"isunnamed");
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8257
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8258 if (item != NULL)
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8259 {
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8260 item->di_tv.v_type = VAR_SPECIAL;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8261 item->di_tv.vval.v_number = regname == buf[0]
23909
5db7d275543c patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents: 23853
diff changeset
8262 ? VVAL_TRUE : VVAL_FALSE;
21062
c2a368193769 patch 8.2.1082: Coverity complains about ignoring dict_add() return value
Bram Moolenaar <Bram@vim.org>
parents: 20992
diff changeset
8263 (void)dict_add(dict, item);
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8264 }
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8265 }
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8266 }
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
8267
14004
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8268 static void
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8269 return_register(int regname, typval_T *rettv)
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8270 {
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8271 char_u buf[2] = {0, 0};
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8272
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8273 buf[0] = (char_u)regname;
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8274 rettv->v_type = VAR_STRING;
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8275 rettv->vval.v_string = vim_strsave(buf);
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8276 }
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8277
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8278 /*
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8279 * "reg_executing()" function
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8280 */
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8281 static void
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8282 f_reg_executing(typval_T *argvars UNUSED, typval_T *rettv)
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8283 {
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8284 return_register(reg_executing, rettv);
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8285 }
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8286
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8287 /*
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8288 * "reg_recording()" function
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8289 */
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8290 static void
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8291 f_reg_recording(typval_T *argvars UNUSED, typval_T *rettv)
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8292 {
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8293 return_register(reg_recording, rettv);
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8294 }
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
8295
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
8296 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8297 * "rename({from}, {to})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8298 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8299 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8300 f_rename(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8301 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8302 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8303
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8304 rettv->vval.v_number = -1;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8305 if (check_restricted() || check_secure())
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8306 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8307
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8308 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8309 && (check_for_string_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8310 || check_for_string_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8311 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8312
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8313 rettv->vval.v_number = vim_rename(tv_get_string(&argvars[0]),
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8314 tv_get_string_buf(&argvars[1], buf));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8315 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8316
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8317 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8318 * "repeat()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8319 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8320 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8321 f_repeat(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8322 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8323 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8324 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8325 int slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8326 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8327 char_u *r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8328 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8329
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8330 if (in_vim9script()
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8331 && (check_for_string_or_number_or_list_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8332 || check_for_number_arg(argvars, 1) == FAIL))
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8333 return;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8334
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8335 n = (int)tv_get_number(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8336 if (argvars[0].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8337 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8338 if (rettv_list_alloc(rettv) == OK && argvars[0].vval.v_list != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8339 while (n-- > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8340 if (list_extend(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8341 argvars[0].vval.v_list, NULL) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8342 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8343 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8344 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8345 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8346 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8347 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8348 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8349
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8350 slen = (int)STRLEN(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8351 len = slen * n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8352 if (len <= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8353 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8354
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8355 r = alloc(len + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8356 if (r != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8357 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8358 for (i = 0; i < n; i++)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8359 mch_memmove(r + i * slen, p, (size_t)slen);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8360 r[len] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8361 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8362
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8363 rettv->vval.v_string = r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8364 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8365 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8366
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8367 #define SP_NOMOVE 0x01 // don't move cursor
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8368 #define SP_REPEAT 0x02 // repeat to find outer pair
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8369 #define SP_RETCOUNT 0x04 // return matchcount
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8370 #define SP_SETPCMARK 0x08 // set previous context mark
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8371 #define SP_START 0x10 // accept match at start position
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8372 #define SP_SUBPAT 0x20 // return nr of matching sub-pattern
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8373 #define SP_END 0x40 // leave cursor at end of match
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8374 #define SP_COLUMN 0x80 // start at cursor column
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8375
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8376 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8377 * Get flags for a search function.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8378 * Possibly sets "p_ws".
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8379 * Returns BACKWARD, FORWARD or zero (for an error).
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8380 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8381 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8382 get_search_arg(typval_T *varp, int *flagsp)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8383 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8384 int dir = FORWARD;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8385 char_u *flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8386 char_u nbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8387 int mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8388
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8389 if (varp->v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8390 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8391 flags = tv_get_string_buf_chk(varp, nbuf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8392 if (flags == NULL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8393 return 0; // type error; errmsg already given
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8394 while (*flags != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8395 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8396 switch (*flags)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8397 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8398 case 'b': dir = BACKWARD; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8399 case 'w': p_ws = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8400 case 'W': p_ws = FALSE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8401 default: mask = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8402 if (flagsp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8403 switch (*flags)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8404 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8405 case 'c': mask = SP_START; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8406 case 'e': mask = SP_END; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8407 case 'm': mask = SP_RETCOUNT; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8408 case 'n': mask = SP_NOMOVE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8409 case 'p': mask = SP_SUBPAT; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8410 case 'r': mask = SP_REPEAT; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8411 case 's': mask = SP_SETPCMARK; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8412 case 'z': mask = SP_COLUMN; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8413 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8414 if (mask == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8415 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
8416 semsg(_(e_invalid_argument_str), flags);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8417 dir = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8418 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8419 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8420 *flagsp |= mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8421 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8422 if (dir == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8423 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8424 ++flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8425 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8426 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8427 return dir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8428 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8429
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8430 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8431 * Shared by search() and searchpos() functions.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8432 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8433 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8434 search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8435 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8436 int flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8437 char_u *pat;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8438 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8439 pos_T save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8440 int save_p_ws = p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8441 int dir;
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8442 int retval = 0; // default: FAIL
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8443 long lnum_stop = 0;
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
8444 #ifdef FEAT_RELTIME
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8445 long time_limit = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8446 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8447 int options = SEARCH_KEEP;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8448 int subpatnum;
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
8449 searchit_arg_T sia;
20731
ab27db64f1fb patch 8.2.0918: duplicate code for evaluating expression argument
Bram Moolenaar <Bram@vim.org>
parents: 20725
diff changeset
8450 int use_skip = FALSE;
20725
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8451 pos_T firstpos;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8452
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8453 if (in_vim9script()
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8454 && (check_for_string_arg(argvars, 0) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8455 || check_for_opt_string_arg(argvars, 1) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8456 || (argvars[1].v_type != VAR_UNKNOWN
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8457 && (check_for_opt_number_arg(argvars, 2) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8458 || (argvars[2].v_type != VAR_UNKNOWN
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8459 && check_for_opt_number_arg(argvars, 3) == FAIL)))))
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8460 goto theend;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25332
diff changeset
8461
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8462 pat = tv_get_string(&argvars[0]);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8463 dir = get_search_arg(&argvars[1], flagsp); // may set p_ws
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8464 if (dir == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8465 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8466 flags = *flagsp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8467 if (flags & SP_START)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8468 options |= SEARCH_START;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8469 if (flags & SP_END)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8470 options |= SEARCH_END;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8471 if (flags & SP_COLUMN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8472 options |= SEARCH_COL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8473
20725
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8474 // Optional arguments: line number to stop searching, timeout and skip.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8475 if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8476 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8477 lnum_stop = (long)tv_get_number_chk(&argvars[2], NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8478 if (lnum_stop < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8479 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8480 if (argvars[3].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8481 {
20725
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8482 #ifdef FEAT_RELTIME
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8483 time_limit = (long)tv_get_number_chk(&argvars[3], NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8484 if (time_limit < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8485 goto theend;
20725
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8486 #endif
20731
ab27db64f1fb patch 8.2.0918: duplicate code for evaluating expression argument
Bram Moolenaar <Bram@vim.org>
parents: 20725
diff changeset
8487 use_skip = eval_expr_valid_arg(&argvars[4]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8488 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8489 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8490
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8491 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8492 * This function does not accept SP_REPEAT and SP_RETCOUNT flags.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8493 * Check to make sure only those flags are set.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8494 * Also, Only the SP_NOMOVE or the SP_SETPCMARK flag can be set. Both
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8495 * flags cannot be set. Check for that condition also.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8496 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8497 if (((flags & (SP_REPEAT | SP_RETCOUNT)) != 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8498 || ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK)))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8499 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
8500 semsg(_(e_invalid_argument_str), tv_get_string(&argvars[1]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8501 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8502 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8503
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8504 pos = save_cursor = curwin->w_cursor;
20725
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8505 CLEAR_FIELD(firstpos);
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 20003
diff changeset
8506 CLEAR_FIELD(sia);
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
8507 sia.sa_stop_lnum = (linenr_T)lnum_stop;
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
8508 #ifdef FEAT_RELTIME
29071
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 29024
diff changeset
8509 sia.sa_tm = time_limit;
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
8510 #endif
20725
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8511
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8512 // Repeat until {skip} returns FALSE.
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8513 for (;;)
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8514 {
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8515 subpatnum = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L,
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
8516 options, RE_SEARCH, &sia);
20725
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8517 // finding the first match again means there is no match where {skip}
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8518 // evaluates to zero.
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8519 if (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos))
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8520 subpatnum = FAIL;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8521
20731
ab27db64f1fb patch 8.2.0918: duplicate code for evaluating expression argument
Bram Moolenaar <Bram@vim.org>
parents: 20725
diff changeset
8522 if (subpatnum == FAIL || !use_skip)
20725
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8523 // didn't find it or no skip argument
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8524 break;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8525 firstpos = pos;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8526
20731
ab27db64f1fb patch 8.2.0918: duplicate code for evaluating expression argument
Bram Moolenaar <Bram@vim.org>
parents: 20725
diff changeset
8527 // If the skip expression matches, ignore this match.
20725
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8528 {
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8529 int do_skip;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8530 int err;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8531 pos_T save_pos = curwin->w_cursor;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8532
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8533 curwin->w_cursor = pos;
20731
ab27db64f1fb patch 8.2.0918: duplicate code for evaluating expression argument
Bram Moolenaar <Bram@vim.org>
parents: 20725
diff changeset
8534 err = FALSE;
ab27db64f1fb patch 8.2.0918: duplicate code for evaluating expression argument
Bram Moolenaar <Bram@vim.org>
parents: 20725
diff changeset
8535 do_skip = eval_expr_to_bool(&argvars[4], &err);
20725
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8536 curwin->w_cursor = save_pos;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8537 if (err)
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8538 {
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8539 // Evaluating {skip} caused an error, break here.
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8540 subpatnum = FAIL;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8541 break;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8542 }
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8543 if (!do_skip)
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8544 break;
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8545 }
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8546 }
f4455c71a8aa patch 8.2.0915: search() cannot skip over matches like searchpair() can
Bram Moolenaar <Bram@vim.org>
parents: 20679
diff changeset
8547
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8548 if (subpatnum != FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8549 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8550 if (flags & SP_SUBPAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8551 retval = subpatnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8552 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8553 retval = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8554 if (flags & SP_SETPCMARK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8555 setpcmark();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8556 curwin->w_cursor = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8557 if (match_pos != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8558 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8559 // Store the match cursor position
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8560 match_pos->lnum = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8561 match_pos->col = pos.col + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8562 }
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8563 // "/$" will put the cursor after the end of the line, may need to
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8564 // correct that here
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8565 check_cursor();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8566 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8567
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8568 // If 'n' flag is used: restore cursor position.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8569 if (flags & SP_NOMOVE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8570 curwin->w_cursor = save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8571 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8572 curwin->w_set_curswant = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8573 theend:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8574 p_ws = save_p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8575
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8576 return retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8577 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8578
16103
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8579 #ifdef FEAT_RUBY
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8580 /*
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8581 * "rubyeval()" function
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8582 */
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8583 static void
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8584 f_rubyeval(typval_T *argvars, typval_T *rettv)
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8585 {
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8586 char_u *str;
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8587 char_u buf[NUMBUFLEN];
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8588
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8589 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8590 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8591
16103
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8592 str = tv_get_string_buf(&argvars[0], buf);
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8593 do_rubyeval(str, rettv);
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8594 }
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8595 #endif
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
8596
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8597 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8598 * "screenattr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8599 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8600 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8601 f_screenattr(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8602 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8603 int row;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8604 int col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8605 int c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8606
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8607 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8608 && (check_for_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8609 || check_for_number_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8610 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8611
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8612 row = (int)tv_get_number_chk(&argvars[0], NULL) - 1;
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8613 col = (int)tv_get_number_chk(&argvars[1], NULL) - 1;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8614 if (row < 0 || row >= screen_Rows
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8615 || col < 0 || col >= screen_Columns)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8616 c = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8617 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8618 c = ScreenAttrs[LineOffset[row] + col];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8619 rettv->vval.v_number = c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8620 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8621
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8622 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8623 * "screenchar()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8624 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8625 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8626 f_screenchar(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8627 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8628 int row;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8629 int col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8630 int off;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8631 int c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8632
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8633 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8634 && (check_for_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8635 || check_for_number_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8636 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8637
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8638 row = (int)tv_get_number_chk(&argvars[0], NULL) - 1;
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8639 col = (int)tv_get_number_chk(&argvars[1], NULL) - 1;
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8640 if (row < 0 || row >= screen_Rows || col < 0 || col >= screen_Columns)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8641 c = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8642 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8643 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8644 off = LineOffset[row] + col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8645 if (enc_utf8 && ScreenLinesUC[off] != 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8646 c = ScreenLinesUC[off];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8647 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8648 c = ScreenLines[off];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8649 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8650 rettv->vval.v_number = c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8651 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8652
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8653 /*
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8654 * "screenchars()" function
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8655 */
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8656 static void
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8657 f_screenchars(typval_T *argvars, typval_T *rettv)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8658 {
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8659 int row;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8660 int col;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8661 int off;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8662 int c;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8663 int i;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8664
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8665 if (rettv_list_alloc(rettv) == FAIL)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8666 return;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8667
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8668 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8669 && (check_for_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8670 || check_for_number_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8671 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8672
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8673 row = (int)tv_get_number_chk(&argvars[0], NULL) - 1;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8674 col = (int)tv_get_number_chk(&argvars[1], NULL) - 1;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8675 if (row < 0 || row >= screen_Rows || col < 0 || col >= screen_Columns)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8676 return;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8677
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8678 off = LineOffset[row] + col;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8679 if (enc_utf8 && ScreenLinesUC[off] != 0)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8680 c = ScreenLinesUC[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8681 else
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8682 c = ScreenLines[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8683 list_append_number(rettv->vval.v_list, (varnumber_T)c);
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8684
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8685 if (enc_utf8)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8686
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8687 for (i = 0; i < Screen_mco && ScreenLinesC[i][off] != 0; ++i)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8688 list_append_number(rettv->vval.v_list,
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8689 (varnumber_T)ScreenLinesC[i][off]);
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8690 }
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8691
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8692 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8693 * "screencol()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8694 *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8695 * First column is 1 to be consistent with virtcol().
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8696 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8697 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8698 f_screencol(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8699 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8700 rettv->vval.v_number = screen_screencol() + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8701 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8702
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8703 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8704 * "screenrow()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8705 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8706 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8707 f_screenrow(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8708 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8709 rettv->vval.v_number = screen_screenrow() + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8710 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8711
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8712 /*
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8713 * "screenstring()" function
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8714 */
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8715 static void
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8716 f_screenstring(typval_T *argvars, typval_T *rettv)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8717 {
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8718 int row;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8719 int col;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8720 int off;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8721 int c;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8722 int i;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8723 char_u buf[MB_MAXBYTES + 1];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8724 int buflen = 0;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8725
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8726 rettv->vval.v_string = NULL;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8727 rettv->v_type = VAR_STRING;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8728
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8729 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8730 && (check_for_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8731 || check_for_number_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8732 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
8733
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8734 row = (int)tv_get_number_chk(&argvars[0], NULL) - 1;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8735 col = (int)tv_get_number_chk(&argvars[1], NULL) - 1;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8736 if (row < 0 || row >= screen_Rows || col < 0 || col >= screen_Columns)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8737 return;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8738
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8739 off = LineOffset[row] + col;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8740 if (enc_utf8 && ScreenLinesUC[off] != 0)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8741 c = ScreenLinesUC[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8742 else
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8743 c = ScreenLines[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8744 buflen += mb_char2bytes(c, buf);
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8745
24198
c784e176334c patch 8.2.2640: screenstring() returns non-existing composing characters
Bram Moolenaar <Bram@vim.org>
parents: 24132
diff changeset
8746 if (enc_utf8 && ScreenLinesUC[off] != 0)
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8747 for (i = 0; i < Screen_mco && ScreenLinesC[i][off] != 0; ++i)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8748 buflen += mb_char2bytes(ScreenLinesC[i][off], buf + buflen);
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8749
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8750 buf[buflen] = NUL;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8751 rettv->vval.v_string = vim_strsave(buf);
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8752 }
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8753
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
8754 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8755 * "search()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8756 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8757 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8758 f_search(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8759 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8760 int flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8761
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8762 rettv->vval.v_number = search_cmn(argvars, NULL, &flags);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8763 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8764
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8765 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8766 * "searchdecl()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8767 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8768 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8769 f_searchdecl(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8770 {
22131
bd3541849208 patch 8.2.1615: Vim9: cannot pass "true" to searchdecl()
Bram Moolenaar <Bram@vim.org>
parents: 22123
diff changeset
8771 int locally = TRUE;
bd3541849208 patch 8.2.1615: Vim9: cannot pass "true" to searchdecl()
Bram Moolenaar <Bram@vim.org>
parents: 22123
diff changeset
8772 int thisblock = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8773 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8774 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8775
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8776 rettv->vval.v_number = 1; // default: FAIL
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8777
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
8778 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
8779 && (check_for_string_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
8780 || check_for_opt_bool_arg(argvars, 1) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
8781 || (argvars[1].v_type != VAR_UNKNOWN
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
8782 && check_for_opt_bool_arg(argvars, 2) == FAIL)))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
8783 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
8784
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8785 name = tv_get_string_chk(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8786 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8787 {
22131
bd3541849208 patch 8.2.1615: Vim9: cannot pass "true" to searchdecl()
Bram Moolenaar <Bram@vim.org>
parents: 22123
diff changeset
8788 locally = !(int)tv_get_bool_chk(&argvars[1], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8789 if (!error && argvars[2].v_type != VAR_UNKNOWN)
22131
bd3541849208 patch 8.2.1615: Vim9: cannot pass "true" to searchdecl()
Bram Moolenaar <Bram@vim.org>
parents: 22123
diff changeset
8790 thisblock = (int)tv_get_bool_chk(&argvars[2], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8791 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8792 if (!error && name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8793 rettv->vval.v_number = find_decl(name, (int)STRLEN(name),
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8794 locally, thisblock, SEARCH_KEEP) == FAIL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8795 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8796
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8797 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8798 * Used by searchpair() and searchpairpos()
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8799 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8800 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8801 searchpair_cmn(typval_T *argvars, pos_T *match_pos)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8802 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8803 char_u *spat, *mpat, *epat;
12722
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
8804 typval_T *skip;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8805 int save_p_ws = p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8806 int dir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8807 int flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8808 char_u nbuf1[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8809 char_u nbuf2[NUMBUFLEN];
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8810 int retval = 0; // default: FAIL
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8811 long lnum_stop = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8812 long time_limit = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8813
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8814 if (in_vim9script()
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8815 && (check_for_string_arg(argvars, 0) == FAIL
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8816 || check_for_string_arg(argvars, 1) == FAIL
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8817 || check_for_string_arg(argvars, 2) == FAIL
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8818 || check_for_opt_string_arg(argvars, 3) == FAIL
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8819 || (argvars[3].v_type != VAR_UNKNOWN
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8820 && argvars[4].v_type != VAR_UNKNOWN
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8821 && (check_for_opt_number_arg(argvars, 5) == FAIL
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8822 || (argvars[5].v_type != VAR_UNKNOWN
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8823 && check_for_opt_number_arg(argvars, 6) == FAIL)))))
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8824 goto theend;
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
8825
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8826 // Get the three pattern arguments: start, middle, end. Will result in an
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8827 // error if not a valid argument.
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8828 spat = tv_get_string_chk(&argvars[0]);
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8829 mpat = tv_get_string_buf_chk(&argvars[1], nbuf1);
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8830 epat = tv_get_string_buf_chk(&argvars[2], nbuf2);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8831 if (spat == NULL || mpat == NULL || epat == NULL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8832 goto theend; // type error
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8833
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8834 // Handle the optional fourth argument: flags
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8835 dir = get_search_arg(&argvars[3], &flags); // may set p_ws
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8836 if (dir == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8837 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8838
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8839 // Don't accept SP_END or SP_SUBPAT.
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8840 // Only one of the SP_NOMOVE or SP_SETPCMARK flags can be set.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8841 if ((flags & (SP_END | SP_SUBPAT)) != 0
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8842 || ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK)))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8843 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
8844 semsg(_(e_invalid_argument_str), tv_get_string(&argvars[3]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8845 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8846 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8847
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8848 // Using 'r' implies 'W', otherwise it doesn't work.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8849 if (flags & SP_REPEAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8850 p_ws = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8851
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8852 // Optional fifth argument: skip expression
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8853 if (argvars[3].v_type == VAR_UNKNOWN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8854 || argvars[4].v_type == VAR_UNKNOWN)
12722
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
8855 skip = NULL;
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
8856 else
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
8857 {
20731
ab27db64f1fb patch 8.2.0918: duplicate code for evaluating expression argument
Bram Moolenaar <Bram@vim.org>
parents: 20725
diff changeset
8858 // Type is checked later.
12722
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
8859 skip = &argvars[4];
20731
ab27db64f1fb patch 8.2.0918: duplicate code for evaluating expression argument
Bram Moolenaar <Bram@vim.org>
parents: 20725
diff changeset
8860
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8861 if (argvars[5].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8862 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8863 lnum_stop = (long)tv_get_number_chk(&argvars[5], NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8864 if (lnum_stop < 0)
14189
0181a2cad0a1 patch 8.1.0112: no error when using bad arguments with searchpair()
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
8865 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
8866 semsg(_(e_invalid_argument_str), tv_get_string(&argvars[5]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8867 goto theend;
14189
0181a2cad0a1 patch 8.1.0112: no error when using bad arguments with searchpair()
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
8868 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8869 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8870 if (argvars[6].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8871 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8872 time_limit = (long)tv_get_number_chk(&argvars[6], NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8873 if (time_limit < 0)
14189
0181a2cad0a1 patch 8.1.0112: no error when using bad arguments with searchpair()
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
8874 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
8875 semsg(_(e_invalid_argument_str), tv_get_string(&argvars[6]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8876 goto theend;
14189
0181a2cad0a1 patch 8.1.0112: no error when using bad arguments with searchpair()
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
8877 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8878 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8879 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8880 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8881 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8882
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8883 retval = do_searchpair(spat, mpat, epat, dir, skip, flags,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8884 match_pos, lnum_stop, time_limit);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8885
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8886 theend:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8887 p_ws = save_p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8888
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8889 return retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8890 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8891
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8892 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8893 * "searchpair()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8894 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8895 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8896 f_searchpair(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8897 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8898 rettv->vval.v_number = searchpair_cmn(argvars, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8899 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8900
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8901 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8902 * "searchpairpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8903 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8904 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8905 f_searchpairpos(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8906 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8907 pos_T match_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8908 int lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8909 int col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8910
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8911 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8912 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8913
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8914 if (searchpair_cmn(argvars, &match_pos) > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8915 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8916 lnum = match_pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8917 col = match_pos.col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8918 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8919
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8920 list_append_number(rettv->vval.v_list, (varnumber_T)lnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8921 list_append_number(rettv->vval.v_list, (varnumber_T)col);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8922 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8923
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8924 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8925 * Search for a start/middle/end thing.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8926 * Used by searchpair(), see its documentation for the details.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8927 * Returns 0 or -1 for no match,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8928 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8929 long
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8930 do_searchpair(
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8931 char_u *spat, // start pattern
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8932 char_u *mpat, // middle pattern
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8933 char_u *epat, // end pattern
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8934 int dir, // BACKWARD or FORWARD
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8935 typval_T *skip, // skip expression
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8936 int flags, // SP_SETPCMARK and other SP_ values
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8937 pos_T *match_pos,
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8938 linenr_T lnum_stop, // stop at this line if not zero
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8939 long time_limit UNUSED) // stop after this many msec
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8940 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8941 char_u *save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8942 char_u *pat, *pat2 = NULL, *pat3 = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8943 long retval = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8944 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8945 pos_T firstpos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8946 pos_T foundpos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8947 pos_T save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8948 pos_T save_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8949 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8950 int r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8951 int nest = 1;
12722
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
8952 int use_skip = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8953 int err;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8954 int options = SEARCH_KEEP;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8955
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8956 // Make 'cpoptions' empty, the 'l' flag should not be used here.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8957 save_cpo = p_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8958 p_cpo = empty_option;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8959
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8960 // Make two search patterns: start/end (pat2, for in nested pairs) and
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8961 // start/middle/end (pat3, for the top pair).
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
8962 pat2 = alloc(STRLEN(spat) + STRLEN(epat) + 17);
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16752
diff changeset
8963 pat3 = alloc(STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 25);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8964 if (pat2 == NULL || pat3 == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8965 goto theend;
10514
1435e45ee6fa commit https://github.com/vim/vim/commit/6e450a57541676036203a72d40b2e604e938371e
Christian Brabandt <cb@256bit.org>
parents: 10501
diff changeset
8966 sprintf((char *)pat2, "\\m\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8967 if (*mpat == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8968 STRCPY(pat3, pat2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8969 else
10514
1435e45ee6fa commit https://github.com/vim/vim/commit/6e450a57541676036203a72d40b2e604e938371e
Christian Brabandt <cb@256bit.org>
parents: 10501
diff changeset
8970 sprintf((char *)pat3, "\\m\\(%s\\m\\)\\|\\(%s\\m\\)\\|\\(%s\\m\\)",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8971 spat, epat, mpat);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8972 if (flags & SP_START)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8973 options |= SEARCH_START;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8974
12722
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
8975 if (skip != NULL)
20731
ab27db64f1fb patch 8.2.0918: duplicate code for evaluating expression argument
Bram Moolenaar <Bram@vim.org>
parents: 20725
diff changeset
8976 use_skip = eval_expr_valid_arg(skip);
12722
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
8977
29189
d1e263ecf634 patch 8.2.5114: time limit on searchpair() does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
8978 #ifdef FEAT_RELTIME
d1e263ecf634 patch 8.2.5114: time limit on searchpair() does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
8979 if (time_limit > 0)
d1e263ecf634 patch 8.2.5114: time limit on searchpair() does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
8980 init_regexp_timeout(time_limit);
d1e263ecf634 patch 8.2.5114: time limit on searchpair() does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
8981 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8982 save_cursor = curwin->w_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8983 pos = curwin->w_cursor;
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11105
diff changeset
8984 CLEAR_POS(&firstpos);
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11105
diff changeset
8985 CLEAR_POS(&foundpos);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8986 pat = pat3;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8987 for (;;)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8988 {
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
8989 searchit_arg_T sia;
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
8990
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 20003
diff changeset
8991 CLEAR_FIELD(sia);
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
8992 sia.sa_stop_lnum = lnum_stop;
15239
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 15219
diff changeset
8993 n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L,
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
8994 options, RE_SEARCH, &sia);
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11105
diff changeset
8995 if (n == FAIL || (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos)))
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8996 // didn't find it or found the first match again: FAIL
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8997 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8998
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8999 if (firstpos.lnum == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9000 firstpos = pos;
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11105
diff changeset
9001 if (EQUAL_POS(pos, foundpos))
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9002 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9003 // Found the same position again. Can happen with a pattern that
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9004 // has "\zs" at the end and searching backwards. Advance one
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9005 // character and try again.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9006 if (dir == BACKWARD)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9007 decl(&pos);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9008 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9009 incl(&pos);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9010 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9011 foundpos = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9012
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9013 // clear the start flag to avoid getting stuck here
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9014 options &= ~SEARCH_START;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9015
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9016 // If the skip pattern matches, ignore this match.
12722
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
9017 if (use_skip)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9018 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9019 save_pos = curwin->w_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9020 curwin->w_cursor = pos;
12722
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
9021 err = FALSE;
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
9022 r = eval_expr_to_bool(skip, &err);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9023 curwin->w_cursor = save_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9024 if (err)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9025 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9026 // Evaluating {skip} caused an error, break here.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9027 curwin->w_cursor = save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9028 retval = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9029 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9030 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9031 if (r)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9032 continue;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9033 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9034
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9035 if ((dir == BACKWARD && n == 3) || (dir == FORWARD && n == 2))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9036 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9037 // Found end when searching backwards or start when searching
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9038 // forward: nested pair.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9039 ++nest;
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9040 pat = pat2; // nested, don't search for middle
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9041 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9042 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9043 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9044 // Found end when searching forward or start when searching
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9045 // backward: end of (nested) pair; or found middle in outer pair.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9046 if (--nest == 1)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9047 pat = pat3; // outer level, search for middle
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9048 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9049
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9050 if (nest == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9051 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9052 // Found the match: return matchcount or line number.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9053 if (flags & SP_RETCOUNT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9054 ++retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9055 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9056 retval = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9057 if (flags & SP_SETPCMARK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9058 setpcmark();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9059 curwin->w_cursor = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9060 if (!(flags & SP_REPEAT))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9061 break;
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9062 nest = 1; // search for next unmatched
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9063 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9064 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9065
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9066 if (match_pos != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9067 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9068 // Store the match cursor position
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9069 match_pos->lnum = curwin->w_cursor.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9070 match_pos->col = curwin->w_cursor.col + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9071 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9072
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9073 // If 'n' flag is used or search failed: restore cursor position.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9074 if ((flags & SP_NOMOVE) || retval == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9075 curwin->w_cursor = save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9076
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9077 theend:
29189
d1e263ecf634 patch 8.2.5114: time limit on searchpair() does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
9078 #ifdef FEAT_RELTIME
d1e263ecf634 patch 8.2.5114: time limit on searchpair() does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
9079 disable_regexp_timeout();
d1e263ecf634 patch 8.2.5114: time limit on searchpair() does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
9080 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9081 vim_free(pat2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9082 vim_free(pat3);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9083 if (p_cpo == empty_option)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9084 p_cpo = save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9085 else
23493
f8382c4e6551 patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents: 23380
diff changeset
9086 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9087 // Darn, evaluating the {skip} expression changed the value.
23493
f8382c4e6551 patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents: 23380
diff changeset
9088 // If it's still empty it was changed and restored, need to restore in
f8382c4e6551 patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents: 23380
diff changeset
9089 // the complicated way.
f8382c4e6551 patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents: 23380
diff changeset
9090 if (*p_cpo == NUL)
28457
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28431
diff changeset
9091 set_option_value_give_err((char_u *)"cpo", 0L, save_cpo, 0);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9092 free_string_option(save_cpo);
23493
f8382c4e6551 patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents: 23380
diff changeset
9093 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9094
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9095 return retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9096 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9097
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9098 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9099 * "searchpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9100 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9101 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9102 f_searchpos(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9103 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9104 pos_T match_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9105 int lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9106 int col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9107 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9108 int flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9109
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9110 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9111 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9112
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9113 n = search_cmn(argvars, &match_pos, &flags);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9114 if (n > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9115 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9116 lnum = match_pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9117 col = match_pos.col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9118 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9119
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9120 list_append_number(rettv->vval.v_list, (varnumber_T)lnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9121 list_append_number(rettv->vval.v_list, (varnumber_T)col);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9122 if (flags & SP_SUBPAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9123 list_append_number(rettv->vval.v_list, (varnumber_T)n);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9124 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9125
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9126 /*
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9127 * Set the cursor or mark position.
25016
e321dbddc076 patch 8.2.3045: minor typos
Bram Moolenaar <Bram@vim.org>
parents: 25006
diff changeset
9128 * If 'charpos' is TRUE, then use the column number as a character offset.
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9129 * Otherwise use the column number as a byte offset.
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9130 */
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9131 static void
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9132 set_position(typval_T *argvars, typval_T *rettv, int charpos)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9133 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9134 pos_T pos;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9135 int fnum;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9136 char_u *name;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9137 colnr_T curswant = -1;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9138
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9139 rettv->vval.v_number = -1;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9140
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9141 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9142 && (check_for_string_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9143 || check_for_list_arg(argvars, 1) == FAIL))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9144 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9145
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9146 name = tv_get_string_chk(argvars);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9147 if (name != NULL)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9148 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9149 if (list2fpos(&argvars[1], &pos, &fnum, &curswant, charpos) == OK)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9150 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9151 if (pos.col != MAXCOL && --pos.col < 0)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9152 pos.col = 0;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9153 if ((name[0] == '.' && name[1] == NUL))
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9154 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9155 // set cursor; "fnum" is ignored
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9156 curwin->w_cursor = pos;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9157 if (curswant >= 0)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9158 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9159 curwin->w_curswant = curswant - 1;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9160 curwin->w_set_curswant = FALSE;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9161 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9162 check_cursor();
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9163 rettv->vval.v_number = 0;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9164 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9165 else if (name[0] == '\'' && name[1] != NUL && name[2] == NUL)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9166 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9167 // set mark
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9168 if (setmark_pos(name[1], &pos, fnum) == OK)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9169 rettv->vval.v_number = 0;
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9170 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9171 else
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
9172 emsg(_(e_invalid_argument));
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9173 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9174 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9175 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9176 /*
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9177 * "setcharpos()" function
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9178 */
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9179 static void
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9180 f_setcharpos(typval_T *argvars, typval_T *rettv)
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9181 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9182 set_position(argvars, rettv, TRUE);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9183 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9184
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9185 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9186 f_setcharsearch(typval_T *argvars, typval_T *rettv UNUSED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9187 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9188 dict_T *d;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9189 dictitem_T *di;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9190 char_u *csearch;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9191
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9192 if (in_vim9script() && check_for_dict_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9193 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9194
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9195 if (argvars[0].v_type != VAR_DICT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9196 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
9197 emsg(_(e_dictionary_required));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9198 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9199 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9200
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9201 if ((d = argvars[0].vval.v_dict) != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9202 {
15146
7903dce131d4 patch 8.1.0583: using illogical name for get_dict_number()/get_dict_string()
Bram Moolenaar <Bram@vim.org>
parents: 15138
diff changeset
9203 csearch = dict_get_string(d, (char_u *)"char", FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9204 if (csearch != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9205 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9206 if (enc_utf8)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9207 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9208 int pcc[MAX_MCO];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9209 int c = utfc_ptr2char(csearch, pcc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9210
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9211 set_last_csearch(c, csearch, utfc_ptr2len(csearch));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9212 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9213 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9214 set_last_csearch(PTR2CHAR(csearch),
18251
c8a53c0daeed patch 8.1.2120: some MB_ macros are more complicated than necessary
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
9215 csearch, mb_ptr2len(csearch));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9216 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9217
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9218 di = dict_find(d, (char_u *)"forward", -1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9219 if (di != NULL)
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9220 set_csearch_direction((int)tv_get_number(&di->di_tv)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9221 ? FORWARD : BACKWARD);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9222
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9223 di = dict_find(d, (char_u *)"until", -1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9224 if (di != NULL)
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9225 set_csearch_until(!!tv_get_number(&di->di_tv));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9226 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9227 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9228
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9229 /*
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9230 * "setcursorcharpos" function
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9231 */
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9232 static void
23654
1974c5122506 patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents: 23650
diff changeset
9233 f_setcursorcharpos(typval_T *argvars, typval_T *rettv)
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9234 {
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9235 set_cursorpos(argvars, rettv, TRUE);
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9236 }
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9237
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9238 /*
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9239 * "setenv()" function
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9240 */
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9241 static void
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9242 f_setenv(typval_T *argvars, typval_T *rettv UNUSED)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9243 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9244 char_u namebuf[NUMBUFLEN];
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9245 char_u valbuf[NUMBUFLEN];
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9246 char_u *name;
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9247
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9248 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9249 return;
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9250
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9251 name = tv_get_string_buf(&argvars[0], namebuf);
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9252 if (argvars[1].v_type == VAR_SPECIAL
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9253 && argvars[1].vval.v_number == VVAL_NULL)
28459
52ef65c0637f patch 8.2.4754: using cached values after unsetting some environment variables
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
9254 vim_unsetenv_ext(name);
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9255 else
28459
52ef65c0637f patch 8.2.4754: using cached values after unsetting some environment variables
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
9256 vim_setenv_ext(name, tv_get_string_buf(&argvars[1], valbuf));
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9257 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9258
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
9259 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9260 * "setfperm({fname}, {mode})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9261 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9262 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9263 f_setfperm(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9264 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9265 char_u *fname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9266 char_u modebuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9267 char_u *mode_str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9268 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9269 int mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9270 int mode = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9271
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9272 rettv->vval.v_number = 0;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9273
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9274 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9275 && (check_for_string_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9276 || check_for_string_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9277 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9278
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9279 fname = tv_get_string_chk(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9280 if (fname == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9281 return;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9282 mode_str = tv_get_string_buf_chk(&argvars[1], modebuf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9283 if (mode_str == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9284 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9285 if (STRLEN(mode_str) != 9)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9286 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
9287 semsg(_(e_invalid_argument_str), mode_str);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9288 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9289 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9290
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9291 mask = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9292 for (i = 8; i >= 0; --i)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9293 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9294 if (mode_str[i] != '-')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9295 mode |= mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9296 mask = mask << 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9297 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9298 rettv->vval.v_number = mch_setperm(fname, mode) == OK;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9299 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9300
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9301 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9302 * "setpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9303 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9304 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9305 f_setpos(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9306 {
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
9307 set_position(argvars, rettv, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9308 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9309
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9310 /*
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9311 * Translate a register type string to the yank type and block length
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9312 */
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9313 static int
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9314 get_yank_type(char_u **pp, char_u *yank_type, long *block_len)
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9315 {
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9316 char_u *stropt = *pp;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9317 switch (*stropt)
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9318 {
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9319 case 'v': case 'c': // character-wise selection
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9320 *yank_type = MCHAR;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9321 break;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9322 case 'V': case 'l': // line-wise selection
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9323 *yank_type = MLINE;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9324 break;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9325 case 'b': case Ctrl_V: // block-wise selection
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9326 *yank_type = MBLOCK;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9327 if (VIM_ISDIGIT(stropt[1]))
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9328 {
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9329 ++stropt;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9330 *block_len = getdigits(&stropt) - 1;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9331 --stropt;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9332 }
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9333 break;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9334 default:
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9335 return FAIL;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9336 }
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9337 *pp = stropt;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9338 return OK;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9339 }
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9340
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9341 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9342 * "setreg()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9343 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9344 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9345 f_setreg(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9346 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9347 int regname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9348 char_u *strregname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9349 char_u *stropt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9350 char_u *strval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9351 int append;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9352 char_u yank_type;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9353 long block_len;
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9354 typval_T *regcontents;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9355 int pointreg;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9356
25368
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9357 if (in_vim9script()
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9358 && (check_for_string_arg(argvars, 0) == FAIL
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9359 || check_for_opt_string_arg(argvars, 2) == FAIL))
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9360 return;
1ffa8eb30353 patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25356
diff changeset
9361
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9362 pointreg = 0;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9363 regcontents = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9364 block_len = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9365 yank_type = MAUTO;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9366 append = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9367
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9368 strregname = tv_get_string_chk(argvars);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9369 rettv->vval.v_number = 1; // FAIL is default
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9370
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9371 if (strregname == NULL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9372 return; // type error; errmsg already given
23909
5db7d275543c patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents: 23853
diff changeset
9373 if (in_vim9script() && STRLEN(strregname) > 1)
5db7d275543c patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents: 23853
diff changeset
9374 {
5db7d275543c patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents: 23853
diff changeset
9375 semsg(_(e_register_name_must_be_one_char_str), strregname);
5db7d275543c patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents: 23853
diff changeset
9376 return;
5db7d275543c patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents: 23853
diff changeset
9377 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9378 regname = *strregname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9379 if (regname == 0 || regname == '@')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9380 regname = '"';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9381
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9382 if (argvars[1].v_type == VAR_DICT)
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9383 {
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9384 dict_T *d = argvars[1].vval.v_dict;
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9385 dictitem_T *di;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9386
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9387 if (d == NULL || d->dv_hashtab.ht_used == 0)
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9388 {
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9389 // Empty dict, clear the register (like setreg(0, []))
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9390 char_u *lstval[2] = {NULL, NULL};
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9391 write_reg_contents_lst(regname, lstval, 0, FALSE, MAUTO, -1);
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9392 return;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9393 }
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9394
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9395 di = dict_find(d, (char_u *)"regcontents", -1);
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9396 if (di != NULL)
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9397 regcontents = &di->di_tv;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9398
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9399 stropt = dict_get_string(d, (char_u *)"regtype", FALSE);
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9400 if (stropt != NULL)
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9401 {
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9402 int ret = get_yank_type(&stropt, &yank_type, &block_len);
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9403
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9404 if (ret == FAIL || *++stropt != NUL)
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9405 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26855
diff changeset
9406 semsg(_(e_invalid_value_for_argument_str), "value");
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9407 return;
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9408 }
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9409 }
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9410
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9411 if (regname == '"')
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9412 {
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9413 stropt = dict_get_string(d, (char_u *)"points_to", FALSE);
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9414 if (stropt != NULL)
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9415 {
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9416 pointreg = *stropt;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9417 regname = pointreg;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9418 }
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9419 }
21967
bf68435a695a patch 8.2.1533: Vim9: error when passing getreginfo() result to setreg()
Bram Moolenaar <Bram@vim.org>
parents: 21935
diff changeset
9420 else if (dict_get_bool(d, (char_u *)"isunnamed", -1) > 0)
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9421 pointreg = regname;
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9422 }
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9423 else
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9424 regcontents = &argvars[1];
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9425
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9426 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9427 {
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9428 if (yank_type != MAUTO)
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9429 {
26602
fac6673086df patch 8.2.3830: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26585
diff changeset
9430 semsg(_(e_too_many_arguments_for_function_str), "setreg");
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9431 return;
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9432 }
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9433
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9434 stropt = tv_get_string_chk(&argvars[2]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9435 if (stropt == NULL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9436 return; // type error
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9437 for (; *stropt != NUL; ++stropt)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9438 switch (*stropt)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9439 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9440 case 'a': case 'A': // append
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9441 append = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9442 break;
20968
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9443 default:
1c36b96522ae patch 8.2.1035: setreg() does not always clear the register
Bram Moolenaar <Bram@vim.org>
parents: 20903
diff changeset
9444 get_yank_type(&stropt, &yank_type, &block_len);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9445 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9446 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9447
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9448 if (regcontents && regcontents->v_type == VAR_LIST)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9449 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9450 char_u **lstval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9451 char_u **allocval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9452 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9453 char_u **curval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9454 char_u **curallocval;
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9455 list_T *ll = regcontents->vval.v_list;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9456 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9457 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9458
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9459 // If the list is NULL handle like an empty list.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9460 len = ll == NULL ? 0 : ll->lv_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9461
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9462 // First half: use for pointers to result lines; second half: use for
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9463 // pointers to allocated copies.
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
9464 lstval = ALLOC_MULT(char_u *, (len + 1) * 2);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9465 if (lstval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9466 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9467 curval = lstval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9468 allocval = lstval + len + 2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9469 curallocval = allocval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9470
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9471 if (ll != NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9472 {
20392
4c317d8c1051 patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents: 20386
diff changeset
9473 CHECK_LIST_MATERIALIZE(ll);
19934
3ff714d765ba patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents: 19922
diff changeset
9474 FOR_ALL_LIST_ITEMS(ll, li)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9475 {
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9476 strval = tv_get_string_buf_chk(&li->li_tv, buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9477 if (strval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9478 goto free_lstval;
19201
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9479 if (strval == buf)
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9480 {
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9481 // Need to make a copy, next tv_get_string_buf_chk() will
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9482 // overwrite the string.
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9483 strval = vim_strsave(buf);
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9484 if (strval == NULL)
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9485 goto free_lstval;
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9486 *curallocval++ = strval;
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9487 }
e7b4fff348dd patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
9488 *curval++ = strval;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9489 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9490 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9491 *curval++ = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9492
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9493 write_reg_contents_lst(regname, lstval, -1,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9494 append, yank_type, block_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9495 free_lstval:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9496 while (curallocval > allocval)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9497 vim_free(*--curallocval);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9498 vim_free(lstval);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9499 }
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9500 else if (regcontents)
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9501 {
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9502 strval = tv_get_string_chk(regcontents);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9503 if (strval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9504 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9505 write_reg_contents_ex(regname, strval, -1,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9506 append, yank_type, block_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9507 }
20743
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9508 if (pointreg != 0)
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9509 get_yank_register(pointreg, TRUE);
a672feb8fc4f patch 8.2.0924: cannot save and restore a register properly
Bram Moolenaar <Bram@vim.org>
parents: 20731
diff changeset
9510
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9511 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9512 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9513
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9514 /*
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9515 * "settagstack()" function
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9516 */
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9517 static void
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9518 f_settagstack(typval_T *argvars, typval_T *rettv)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9519 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9520 win_T *wp;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9521 dict_T *d;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9522 int action = 'r';
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9523
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9524 rettv->vval.v_number = -1;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9525
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9526 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9527 && (check_for_number_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9528 || check_for_dict_arg(argvars, 1) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9529 || check_for_opt_string_arg(argvars, 2) == FAIL))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9530 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9531
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9532 // first argument: window number or id
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9533 wp = find_win_by_nr_or_id(&argvars[0]);
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9534 if (wp == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9535 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9536
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9537 // second argument: dict with items to set in the tag stack
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9538 if (argvars[1].v_type != VAR_DICT)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9539 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
9540 emsg(_(e_dictionary_required));
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9541 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9542 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9543 d = argvars[1].vval.v_dict;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9544 if (d == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9545 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9546
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9547 // third argument: action - 'a' for append and 'r' for replace.
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9548 // default is to replace the stack.
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9549 if (argvars[2].v_type == VAR_UNKNOWN)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9550 action = 'r';
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9551 else if (argvars[2].v_type == VAR_STRING)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9552 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9553 char_u *actstr;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9554 actstr = tv_get_string_chk(&argvars[2]);
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9555 if (actstr == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9556 return;
19033
f0312cf3c792 patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents: 19013
diff changeset
9557 if ((*actstr == 'r' || *actstr == 'a' || *actstr == 't')
f0312cf3c792 patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents: 19013
diff changeset
9558 && actstr[1] == NUL)
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9559 action = *actstr;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9560 else
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9561 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
9562 semsg(_(e_invalid_action_str_2), actstr);
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9563 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9564 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9565 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9566 else
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9567 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
9568 emsg(_(e_string_required));
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9569 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9570 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9571
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9572 if (set_tagstack(wp, d, action) == OK)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9573 rettv->vval.v_number = 0;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9574 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
9575
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9576 #ifdef FEAT_CRYPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9577 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9578 * "sha256({string})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9579 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9580 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9581 f_sha256(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9582 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9583 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9584
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9585 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9586 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9587
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9588 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9589 rettv->vval.v_string = vim_strsave(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9590 sha256_bytes(p, (int)STRLEN(p), NULL, 0));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9591 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9592 }
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9593 #endif // FEAT_CRYPT
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9594
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9595 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9596 * "shellescape({string})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9597 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9598 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9599 f_shellescape(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9600 {
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9601 int do_special;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9602
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9603 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9604 && (check_for_string_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9605 || check_for_opt_bool_arg(argvars, 1) == FAIL))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9606 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9607
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9608 do_special = non_zero_arg(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9609 rettv->vval.v_string = vim_strsave_shellescape(
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9610 tv_get_string(&argvars[0]), do_special, do_special);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9611 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9612 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9613
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9614 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9615 * shiftwidth() function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9616 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9617 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9618 f_shiftwidth(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9619 {
15062
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9620 rettv->vval.v_number = 0;
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9621
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9622 if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9623 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9624
15062
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9625 if (argvars[0].v_type != VAR_UNKNOWN)
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9626 {
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9627 long col;
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9628
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9629 col = (long)tv_get_number_chk(argvars, NULL);
15062
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9630 if (col < 0)
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9631 return; // type error; errmsg already given
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9632 #ifdef FEAT_VARTABS
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9633 rettv->vval.v_number = get_sw_value_col(curbuf, col);
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9634 return;
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9635 #endif
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9636 }
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
9637
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9638 rettv->vval.v_number = get_sw_value(curbuf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9639 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9640
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9641 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9642 * "soundfold({word})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9643 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9644 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9645 f_soundfold(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9646 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9647 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9648
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9649 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9650 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9651
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9652 rettv->v_type = VAR_STRING;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9653 s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9654 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9655 rettv->vval.v_string = eval_soundfold(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9656 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9657 rettv->vval.v_string = vim_strsave(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9658 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9659 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9660
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9661 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9662 * "spellbadword()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9663 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9664 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9665 f_spellbadword(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9666 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9667 char_u *word = (char_u *)"";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9668 hlf_T attr = HLF_COUNT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9669 int len = 0;
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9670 #ifdef FEAT_SPELL
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9671 int wo_spell_save = curwin->w_p_spell;
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9672
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9673 if (in_vim9script() && check_for_opt_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9674 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9675
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9676 if (!curwin->w_p_spell)
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9677 {
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9678 did_set_spelllang(curwin);
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9679 curwin->w_p_spell = TRUE;
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9680 }
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9681
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9682 if (*curwin->w_s->b_p_spl == NUL)
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9683 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
9684 emsg(_(e_spell_checking_is_not_possible));
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9685 curwin->w_p_spell = wo_spell_save;
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9686 return;
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9687 }
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9688 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9689
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9690 if (rettv_list_alloc(rettv) == FAIL)
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9691 {
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9692 #ifdef FEAT_SPELL
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9693 curwin->w_p_spell = wo_spell_save;
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9694 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9695 return;
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9696 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9697
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9698 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9699 if (argvars[0].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9700 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9701 // Find the start and length of the badly spelled word.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9702 len = spell_move_to(curwin, FORWARD, TRUE, TRUE, &attr);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9703 if (len != 0)
13088
3dd37eec73f0 patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
9704 {
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9705 word = ml_get_cursor();
13088
3dd37eec73f0 patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
9706 curwin->w_set_curswant = TRUE;
3dd37eec73f0 patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents: 13070
diff changeset
9707 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9708 }
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9709 else if (*curbuf->b_s.b_p_spl != NUL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9710 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9711 char_u *str = tv_get_string_chk(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9712 int capcol = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9713
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9714 if (str != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9715 {
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9716 // Check the argument for spelling.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9717 while (*str != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9718 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9719 len = spell_check(curwin, str, &attr, &capcol, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9720 if (attr != HLF_COUNT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9721 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9722 word = str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9723 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9724 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9725 str += len;
14368
e78ce11f310b patch 8.1.0199: spellbadword() does not check for caps error
Christian Brabandt <cb@256bit.org>
parents: 14343
diff changeset
9726 capcol -= len;
17672
d63b44015f4d patch 8.1.1833: allocating a bit too much when there is no bad word.
Bram Moolenaar <Bram@vim.org>
parents: 17670
diff changeset
9727 len = 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9728 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9729 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9730 }
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9731 curwin->w_p_spell = wo_spell_save;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9732 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9733
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9734 list_append_string(rettv->vval.v_list, word, len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9735 list_append_string(rettv->vval.v_list, (char_u *)(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9736 attr == HLF_SPB ? "bad" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9737 attr == HLF_SPR ? "rare" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9738 attr == HLF_SPL ? "local" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9739 attr == HLF_SPC ? "caps" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9740 ""), -1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9741 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9742
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9743 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9744 * "spellsuggest()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9745 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9746 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9747 f_spellsuggest(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9748 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9749 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9750 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9751 int typeerr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9752 int maxcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9753 garray_T ga;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9754 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9755 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9756 int need_capital = FALSE;
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9757 int wo_spell_save = curwin->w_p_spell;
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9758
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9759 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9760 && (check_for_string_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9761 || check_for_opt_number_arg(argvars, 1) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9762 || (argvars[1].v_type != VAR_UNKNOWN
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9763 && check_for_opt_bool_arg(argvars, 2) == FAIL)))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9764 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9765
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9766 if (!curwin->w_p_spell)
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9767 {
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9768 did_set_spelllang(curwin);
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9769 curwin->w_p_spell = TRUE;
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9770 }
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9771
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9772 if (*curwin->w_s->b_p_spl == NUL)
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9773 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26873
diff changeset
9774 emsg(_(e_spell_checking_is_not_possible));
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9775 curwin->w_p_spell = wo_spell_save;
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9776 return;
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9777 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9778 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9779
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9780 if (rettv_list_alloc(rettv) == FAIL)
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9781 {
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9782 #ifdef FEAT_SPELL
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9783 curwin->w_p_spell = wo_spell_save;
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9784 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9785 return;
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9786 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9787
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9788 #ifdef FEAT_SPELL
28871
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9789 str = tv_get_string(&argvars[0]);
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9790 if (argvars[1].v_type != VAR_UNKNOWN)
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9791 {
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9792 maxcount = (int)tv_get_number_chk(&argvars[1], &typeerr);
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9793 if (maxcount <= 0)
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9794 return;
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9795 if (argvars[2].v_type != VAR_UNKNOWN)
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9796 {
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9797 need_capital = (int)tv_get_bool_chk(&argvars[2], &typeerr);
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9798 if (typeerr)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9799 return;
28871
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9800 }
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9801 }
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9802 else
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9803 maxcount = 25;
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9804
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9805 spell_suggest_list(&ga, str, maxcount, need_capital, FALSE);
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9806
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9807 for (i = 0; i < ga.ga_len; ++i)
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9808 {
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9809 str = ((char_u **)ga.ga_data)[i];
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9810
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9811 li = listitem_alloc();
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9812 if (li == NULL)
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9813 vim_free(str);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9814 else
28871
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9815 {
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9816 li->li_tv.v_type = VAR_STRING;
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9817 li->li_tv.v_lock = 0;
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9818 li->li_tv.vval.v_string = str;
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9819 list_append(rettv->vval.v_list, li);
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9820 }
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9821 }
18604231a1d1 patch 8.2.4958: a couple conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 28806
diff changeset
9822 ga_clear(&ga);
20786
90b96fa35e4b patch 8.2.0945: cannot use "z=" when 'spell' is off
Bram Moolenaar <Bram@vim.org>
parents: 20766
diff changeset
9823 curwin->w_p_spell = wo_spell_save;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9824 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9825 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9826
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9827 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9828 f_split(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9829 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9830 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9831 char_u *end;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9832 char_u *pat = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9833 regmatch_T regmatch;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9834 char_u patbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9835 char_u *save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9836 int match;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9837 colnr_T col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9838 int keepempty = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9839 int typeerr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9840
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9841 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9842 && (check_for_string_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9843 || check_for_opt_string_arg(argvars, 1) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9844 || (argvars[1].v_type != VAR_UNKNOWN
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9845 && check_for_opt_bool_arg(argvars, 2) == FAIL)))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9846 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9847
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9848 // Make 'cpoptions' empty, the 'l' flag should not be used here.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9849 save_cpo = p_cpo;
23493
f8382c4e6551 patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents: 23380
diff changeset
9850 p_cpo = empty_option;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9851
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9852 str = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9853 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9854 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9855 pat = tv_get_string_buf_chk(&argvars[1], patbuf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9856 if (pat == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9857 typeerr = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9858 if (argvars[2].v_type != VAR_UNKNOWN)
22149
49b3a95adf04 patch 8.2.1624: Vim9: cannot pass "true" to split(), str2nr() and strchars()
Bram Moolenaar <Bram@vim.org>
parents: 22139
diff changeset
9859 keepempty = (int)tv_get_bool_chk(&argvars[2], &typeerr);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9860 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9861 if (pat == NULL || *pat == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9862 pat = (char_u *)"[\\x01- ]\\+";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9863
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9864 if (rettv_list_alloc(rettv) == FAIL)
21429
16bc2bd050e0 patch 8.2.1265: crash with EXITFREE when split() fails
Bram Moolenaar <Bram@vim.org>
parents: 21381
diff changeset
9865 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9866 if (typeerr)
21429
16bc2bd050e0 patch 8.2.1265: crash with EXITFREE when split() fails
Bram Moolenaar <Bram@vim.org>
parents: 21381
diff changeset
9867 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9868
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9869 regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9870 if (regmatch.regprog != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9871 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9872 regmatch.rm_ic = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9873 while (*str != NUL || keepempty)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9874 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9875 if (*str == NUL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9876 match = FALSE; // empty item at the end
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9877 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9878 match = vim_regexec_nl(&regmatch, str, col);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9879 if (match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9880 end = regmatch.startp[0];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9881 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9882 end = str + STRLEN(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9883 if (keepempty || end > str || (rettv->vval.v_list->lv_len > 0
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9884 && *str != NUL && match && end < regmatch.endp[0]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9885 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9886 if (list_append_string(rettv->vval.v_list, str,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9887 (int)(end - str)) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9888 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9889 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9890 if (!match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9891 break;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
9892 // Advance to just after the match.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9893 if (regmatch.endp[0] > str)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9894 col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9895 else
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
9896 // Don't get stuck at the same match.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9897 col = (*mb_ptr2len)(regmatch.endp[0]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9898 str = regmatch.endp[0];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9899 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9900
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9901 vim_regfree(regmatch.regprog);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9902 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9903
21429
16bc2bd050e0 patch 8.2.1265: crash with EXITFREE when split() fails
Bram Moolenaar <Bram@vim.org>
parents: 21381
diff changeset
9904 theend:
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9905 p_cpo = save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9906 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9907
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9908 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9909 * "submatch()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9910 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9911 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9912 f_submatch(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9913 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9914 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9915 int no;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9916 int retList = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9917
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9918 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9919 && (check_for_number_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9920 || check_for_opt_bool_arg(argvars, 1) == FAIL))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9921 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
9922
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9923 no = (int)tv_get_number_chk(&argvars[0], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9924 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9925 return;
9923
935e13935848 commit https://github.com/vim/vim/commit/989f592f7ffcbafdc4ec35cee4dc65bd053e2077
Christian Brabandt <cb@256bit.org>
parents: 9919
diff changeset
9926 if (no < 0 || no >= NSUBEXP)
935e13935848 commit https://github.com/vim/vim/commit/989f592f7ffcbafdc4ec35cee4dc65bd053e2077
Christian Brabandt <cb@256bit.org>
parents: 9919
diff changeset
9927 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
9928 semsg(_(e_invalid_submatch_number_nr), no);
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
9929 return;
9923
935e13935848 commit https://github.com/vim/vim/commit/989f592f7ffcbafdc4ec35cee4dc65bd053e2077
Christian Brabandt <cb@256bit.org>
parents: 9919
diff changeset
9930 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9931 if (argvars[1].v_type != VAR_UNKNOWN)
22155
de47cb7b41e6 patch 8.2.1627: Vim9: cannot pass "true" to submatch/term_gettty/term_start
Bram Moolenaar <Bram@vim.org>
parents: 22149
diff changeset
9932 retList = (int)tv_get_bool_chk(&argvars[1], &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9933 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9934 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9935
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9936 if (retList == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9937 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9938 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9939 rettv->vval.v_string = reg_submatch(no);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9940 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9941 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9942 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9943 rettv->v_type = VAR_LIST;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9944 rettv->vval.v_list = reg_submatch_list(no);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9945 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9946 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9947
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9948 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9949 * "substitute()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9950 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9951 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9952 f_substitute(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9953 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9954 char_u patbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9955 char_u subbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9956 char_u flagsbuf[NUMBUFLEN];
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9957 char_u *str;
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9958 char_u *pat;
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
9959 char_u *sub = NULL;
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
9960 typval_T *expr = NULL;
25356
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9961 char_u *flg;
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9962
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9963 if (in_vim9script()
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9964 && (check_for_string_arg(argvars, 0) == FAIL
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9965 || check_for_string_arg(argvars, 1) == FAIL
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9966 || check_for_string_arg(argvars, 3) == FAIL))
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9967 return;
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9968
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9969 str = tv_get_string_chk(&argvars[0]);
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9970 pat = tv_get_string_buf_chk(&argvars[1], patbuf);
1cde96e768e4 patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25348
diff changeset
9971 flg = tv_get_string_buf_chk(&argvars[3], flagsbuf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9972
28692
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28674
diff changeset
9973 if (argvars[2].v_type == VAR_FUNC
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28674
diff changeset
9974 || argvars[2].v_type == VAR_PARTIAL
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28674
diff changeset
9975 || argvars[2].v_type == VAR_INSTR)
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
9976 expr = &argvars[2];
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
9977 else
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9978 sub = tv_get_string_buf_chk(&argvars[2], subbuf);
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
9979
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9980 rettv->v_type = VAR_STRING;
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
9981 if (str == NULL || pat == NULL || (sub == NULL && expr == NULL)
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
9982 || flg == NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9983 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9984 else
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
9985 rettv->vval.v_string = do_string_sub(str, pat, sub, expr, flg);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9986 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9987
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9988 /*
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
9989 * "swapinfo(swap_filename)" function
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
9990 */
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
9991 static void
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
9992 f_swapinfo(typval_T *argvars, typval_T *rettv)
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
9993 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9994 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9995 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
9996
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
9997 if (rettv_dict_alloc(rettv) == OK)
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
9998 get_b0_dict(tv_get_string(argvars), rettv->vval.v_dict);
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
9999 }
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
10000
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
10001 /*
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10002 * "swapname(expr)" function
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10003 */
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10004 static void
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10005 f_swapname(typval_T *argvars, typval_T *rettv)
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10006 {
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10007 buf_T *buf;
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10008
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10009 rettv->v_type = VAR_STRING;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10010
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10011 if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10012 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10013
15355
73b153ed5af8 patch 8.1.0685: get_buf_tv() is named inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 15343
diff changeset
10014 buf = tv_get_buf(&argvars[0], FALSE);
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10015 if (buf == NULL || buf->b_ml.ml_mfp == NULL
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10016 || buf->b_ml.ml_mfp->mf_fname == NULL)
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10017 rettv->vval.v_string = NULL;
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10018 else
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10019 rettv->vval.v_string = vim_strsave(buf->b_ml.ml_mfp->mf_fname);
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10020 }
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10021
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
10022 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10023 * "synID(lnum, col, trans)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10024 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10025 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10026 f_synID(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10027 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10028 int id = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10029 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10030 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10031 colnr_T col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10032 int trans;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10033 int transerr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10034
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
10035 if (in_vim9script()
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
10036 && (check_for_lnum_arg(argvars, 0) == FAIL
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
10037 || check_for_number_arg(argvars, 1) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
10038 || check_for_bool_arg(argvars, 2) == FAIL))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
10039 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
10040
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10041 lnum = tv_get_lnum(argvars); // -1 on type error
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10042 col = (linenr_T)tv_get_number(&argvars[1]) - 1; // -1 on type error
22133
4fd33ca087e1 patch 8.2.1616: Vim9: cannot pass "true" to synID()
Bram Moolenaar <Bram@vim.org>
parents: 22131
diff changeset
10043 trans = (int)tv_get_bool_chk(&argvars[2], &transerr);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10044
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10045 if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10046 && col >= 0 && col < (long)STRLEN(ml_get(lnum)))
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 27406
diff changeset
10047 id = syn_get_id(curwin, lnum, col, trans, NULL, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10048 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10049
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10050 rettv->vval.v_number = id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10051 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10052
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10053 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10054 * "synIDattr(id, what [, mode])" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10055 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10056 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10057 f_synIDattr(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10058 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10059 char_u *p = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10060 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10061 int id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10062 char_u *what;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10063 char_u *mode;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10064 char_u modebuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10065 int modec;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10066
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
10067 if (in_vim9script()
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
10068 && (check_for_number_arg(argvars, 0) == FAIL
25844
29bbe650f2a1 patch 8.2.3456: Vim9: not all functions are tested with empty string argument
Bram Moolenaar <Bram@vim.org>
parents: 25806
diff changeset
10069 || check_for_string_arg(argvars, 1) == FAIL
29bbe650f2a1 patch 8.2.3456: Vim9: not all functions are tested with empty string argument
Bram Moolenaar <Bram@vim.org>
parents: 25806
diff changeset
10070 || check_for_opt_string_arg(argvars, 2) == FAIL))
25348
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
10071 return;
75031a22be39 patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
10072
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
10073 id = (int)tv_get_number(&argvars[0]);
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
10074 what = tv_get_string(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10075 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10076 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
10077 mode = tv_get_string_buf(&argvars[2], modebuf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10078 modec = TOLOWER_ASC(mode[0]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10079 if (modec != 't' && modec != 'c' && modec != 'g')
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10080 modec = 0; // replace invalid with current
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10081 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10082 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10083 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10084 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10085 if (USE_24BIT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10086 modec = 'g';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10087 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10088 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10089 if (t_colors > 1)
24665
661d15592d3c patch 8.2.2871: unnessary VIM_ISDIGIT() calls, badly indented code
Bram Moolenaar <Bram@vim.org>
parents: 24618
diff changeset
10090 modec = 'c';
661d15592d3c patch 8.2.2871: unnessary VIM_ISDIGIT() calls, badly indented code
Bram Moolenaar <Bram@vim.org>
parents: 24618
diff changeset
10091 else
661d15592d3c patch 8.2.2871: unnessary VIM_ISDIGIT() calls, badly indented code
Bram Moolenaar <Bram@vim.org>
parents: 24618
diff changeset
10092 modec = 't';
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10093 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10094
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10095 switch (TOLOWER_ASC(what[0]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10096 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10097 case 'b':
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10098 if (TOLOWER_ASC(what[1]) == 'g') // bg[#]
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10099 p = highlight_color(id, what, modec);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10100 else // bold
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10101 p = highlight_has_attr(id, HL_BOLD, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10102 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10103
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10104 case 'f': // fg[#] or font
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10105 p = highlight_color(id, what, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10106 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10107
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10108 case 'i':
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10109 if (TOLOWER_ASC(what[1]) == 'n') // inverse
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10110 p = highlight_has_attr(id, HL_INVERSE, modec);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10111 else // italic
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10112 p = highlight_has_attr(id, HL_ITALIC, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10113 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10114
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10115 case 'n': // name
11254
918942a3b0ef patch 8.0.0513: getting name of cleared highlight group is wrong
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
10116 p = get_highlight_name_ext(NULL, id - 1, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10117 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10118
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10119 case 'r': // reverse
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10120 p = highlight_has_attr(id, HL_INVERSE, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10121 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10122
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10123 case 's':
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10124 if (TOLOWER_ASC(what[1]) == 'p') // sp[#]
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10125 p = highlight_color(id, what, modec);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10126 // strikeout
12317
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
10127 else if (TOLOWER_ASC(what[1]) == 't' &&
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
10128 TOLOWER_ASC(what[2]) == 'r')
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
10129 p = highlight_has_attr(id, HL_STRIKETHROUGH, modec);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10130 else // standout
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10131 p = highlight_has_attr(id, HL_STANDOUT, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10132 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10133
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10134 case 'u':
22446
0cdb03e73ce9 patch 8.2.1771: synIDattr() cannot get the value of ctermul
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
10135 if (TOLOWER_ASC(what[1]) == 'l') // ul
0cdb03e73ce9 patch 8.2.1771: synIDattr() cannot get the value of ctermul
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
10136 p = highlight_color(id, what, modec);
0cdb03e73ce9 patch 8.2.1771: synIDattr() cannot get the value of ctermul
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
10137 else if (STRLEN(what) <= 5 || TOLOWER_ASC(what[5]) != 'c')
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10138 // underline
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10139 p = highlight_has_attr(id, HL_UNDERLINE, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10140 else
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10141 // undercurl
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10142 p = highlight_has_attr(id, HL_UNDERCURL, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10143 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10144 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10145
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10146 if (p != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10147 p = vim_strsave(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10148 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10149 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10150 rettv->vval.v_string = p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10151 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10152
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10153 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10154 * "synIDtrans(id)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10155 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10156 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10157 f_synIDtrans(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10158 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10159 int id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10160
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10161 #ifdef FEAT_SYN_HL
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10162 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10163 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10164
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
10165 id = (int)tv_get_number(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10166
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10167 if (id > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10168 id = syn_get_final_id(id);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10169 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10170 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10171 id = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10172
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10173 rettv->vval.v_number = id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10174 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10175
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10176 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10177 * "synconcealed(lnum, col)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10178 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10179 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10180 f_synconcealed(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10181 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10182 #if defined(FEAT_SYN_HL) && defined(FEAT_CONCEAL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10183 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10184 colnr_T col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10185 int syntax_flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10186 int cchar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10187 int matchid = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10188 char_u str[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10189 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10190
11418
162bcd0debd7 patch 8.0.0593: duplication of code for adding a list or dict return value
Christian Brabandt <cb@256bit.org>
parents: 11341
diff changeset
10191 rettv_list_set(rettv, NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10192
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
10193 if (in_vim9script()
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
10194 && (check_for_lnum_arg(argvars, 0) == FAIL
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
10195 || check_for_number_arg(argvars, 1) == FAIL))
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
10196 return;
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
10197
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10198 #if defined(FEAT_SYN_HL) && defined(FEAT_CONCEAL)
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10199 lnum = tv_get_lnum(argvars); // -1 on type error
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10200 col = (colnr_T)tv_get_number(&argvars[1]) - 1; // -1 on type error
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10201
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 20003
diff changeset
10202 CLEAR_FIELD(str);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10203
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
10204 if (rettv_list_alloc(rettv) == OK)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10205 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10206 if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10207 && col >= 0 && col <= (long)STRLEN(ml_get(lnum))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10208 && curwin->w_p_cole > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10209 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10210 (void)syn_get_id(curwin, lnum, col, FALSE, NULL, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10211 syntax_flags = get_syntax_info(&matchid);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10212
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10213 // get the conceal character
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10214 if ((syntax_flags & HL_CONCEAL) && curwin->w_p_cole < 3)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10215 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10216 cchar = syn_get_sub_char();
11553
cbceef33af7a patch 8.0.0659: no test for conceal mode
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
10217 if (cchar == NUL && curwin->w_p_cole == 1)
23952
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
10218 cchar = (curwin->w_lcs_chars.conceal == NUL) ? ' '
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
10219 : curwin->w_lcs_chars.conceal;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10220 if (cchar != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10221 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10222 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10223 (*mb_char2bytes)(cchar, str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10224 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10225 str[0] = cchar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10226 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10227 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10228 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10229
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10230 list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10231 (syntax_flags & HL_CONCEAL) != 0);
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10232 // -1 to auto-determine strlen
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10233 list_append_string(rettv->vval.v_list, str, -1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10234 list_append_number(rettv->vval.v_list, matchid);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10235 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10236 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10237 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10238
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10239 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10240 * "synstack(lnum, col)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10241 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10242 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10243 f_synstack(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10244 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10245 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10246 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10247 colnr_T col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10248 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10249 int id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10250 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10251
11418
162bcd0debd7 patch 8.0.0593: duplication of code for adding a list or dict return value
Christian Brabandt <cb@256bit.org>
parents: 11341
diff changeset
10252 rettv_list_set(rettv, NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10253
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
10254 if (in_vim9script()
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
10255 && (check_for_lnum_arg(argvars, 0) == FAIL
25272
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
10256 || check_for_number_arg(argvars, 1) == FAIL))
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
10257 return;
712e867f9721 patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
10258
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10259 #ifdef FEAT_SYN_HL
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10260 lnum = tv_get_lnum(argvars); // -1 on type error
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10261 col = (colnr_T)tv_get_number(&argvars[1]) - 1; // -1 on type error
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10262
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10263 if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10264 && col >= 0 && col <= (long)STRLEN(ml_get(lnum))
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
10265 && rettv_list_alloc(rettv) == OK)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10266 {
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 27406
diff changeset
10267 (void)syn_get_id(curwin, lnum, col, FALSE, NULL, TRUE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10268 for (i = 0; ; ++i)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10269 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10270 id = syn_get_stack_item(i);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10271 if (id < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10272 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10273 if (list_append_number(rettv->vval.v_list, id) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10274 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10275 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10276 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10277 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10278 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10279
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10280 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10281 * "tabpagebuflist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10282 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10283 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10284 f_tabpagebuflist(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10285 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10286 tabpage_T *tp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10287 win_T *wp = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10288
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10289 if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10290 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10291
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10292 if (argvars[0].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10293 wp = firstwin;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10294 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10295 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
10296 tp = find_tabpage((int)tv_get_number(&argvars[0]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10297 if (tp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10298 wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10299 }
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 29138
diff changeset
10300 if (wp != NULL && rettv_list_alloc(rettv) == OK)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10301 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10302 for (; wp != NULL; wp = wp->w_next)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10303 if (list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10304 wp->w_buffer->b_fnum) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10305 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10306 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10307 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10308
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10309 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10310 * "tagfiles()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10311 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10312 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10313 f_tagfiles(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10314 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10315 char_u *fname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10316 tagname_T tn;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10317 int first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10318
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10319 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10320 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10321 fname = alloc(MAXPATHL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10322 if (fname == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10323 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10324
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10325 for (first = TRUE; ; first = FALSE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10326 if (get_tagfname(&tn, first, fname) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10327 || list_append_string(rettv->vval.v_list, fname, -1) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10328 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10329 tagname_free(&tn);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10330 vim_free(fname);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10331 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10332
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10333 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10334 * "taglist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10335 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10336 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10337 f_taglist(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10338 {
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents: 11215
diff changeset
10339 char_u *fname = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10340 char_u *tag_pattern;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10341
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10342 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10343 && (check_for_string_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10344 || check_for_opt_string_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10345 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10346
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
10347 tag_pattern = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10348
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10349 rettv->vval.v_number = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10350 if (*tag_pattern == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10351 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10352
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents: 11215
diff changeset
10353 if (argvars[1].v_type != VAR_UNKNOWN)
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
10354 fname = tv_get_string(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10355 if (rettv_list_alloc(rettv) == OK)
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents: 11215
diff changeset
10356 (void)get_tags(rettv->vval.v_list, tag_pattern, fname);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10357 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10358
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10359 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10360 * "type(expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10361 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10362 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10363 f_type(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10364 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10365 int n = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10366
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10367 switch (argvars[0].v_type)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10368 {
19102
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
10369 case VAR_NUMBER: n = VAR_TYPE_NUMBER; break;
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
10370 case VAR_STRING: n = VAR_TYPE_STRING; break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10371 case VAR_PARTIAL:
19102
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
10372 case VAR_FUNC: n = VAR_TYPE_FUNC; break;
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
10373 case VAR_LIST: n = VAR_TYPE_LIST; break;
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
10374 case VAR_DICT: n = VAR_TYPE_DICT; break;
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
10375 case VAR_FLOAT: n = VAR_TYPE_FLOAT; break;
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
10376 case VAR_BOOL: n = VAR_TYPE_BOOL; break;
ba9f50bfda83 patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents: 19100
diff changeset
10377 case VAR_SPECIAL: n = VAR_TYPE_NONE; break;
9587
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
10378 case VAR_JOB: n = VAR_TYPE_JOB; break;
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
10379 case VAR_CHANNEL: n = VAR_TYPE_CHANNEL; break;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
10380 case VAR_BLOB: n = VAR_TYPE_BLOB; break;
24606
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24307
diff changeset
10381 case VAR_INSTR: n = VAR_TYPE_INSTR; break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10382 case VAR_UNKNOWN:
19922
1f42c49c3d29 patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents: 19920
diff changeset
10383 case VAR_ANY:
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19121
diff changeset
10384 case VAR_VOID:
19554
b38d73f36467 patch 8.2.0334: abort called when using test_void()
Bram Moolenaar <Bram@vim.org>
parents: 19548
diff changeset
10385 internal_error_no_abort("f_type(UNKNOWN)");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10386 n = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10387 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10388 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10389 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10390 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10391
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10392 /*
28994
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10393 * "virtcol(string, bool)" function
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10394 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10395 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10396 f_virtcol(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10397 {
28994
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10398 colnr_T vcol_start = 0;
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10399 colnr_T vcol_end = 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10400 pos_T *fp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10401 int fnum = curbuf->b_fnum;
19121
a51fee786930 patch 8.2.0120: virtcol() does not check arguments to be valid
Bram Moolenaar <Bram@vim.org>
parents: 19102
diff changeset
10402 int len;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10403
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10404 if (in_vim9script()
28994
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10405 && (check_for_string_or_list_arg(argvars, 0) == FAIL
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10406 || (argvars[1].v_type != VAR_UNKNOWN
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10407 && check_for_bool_arg(argvars, 1) == FAIL)))
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10408 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10409
23563
87671ccc6c6b patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents: 23535
diff changeset
10410 fp = var2fpos(&argvars[0], FALSE, &fnum, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10411 if (fp != NULL && fp->lnum <= curbuf->b_ml.ml_line_count
28994
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10412 && fnum == curbuf->b_fnum)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10413 {
19121
a51fee786930 patch 8.2.0120: virtcol() does not check arguments to be valid
Bram Moolenaar <Bram@vim.org>
parents: 19102
diff changeset
10414 // Limit the column to a valid value, getvvcol() doesn't check.
a51fee786930 patch 8.2.0120: virtcol() does not check arguments to be valid
Bram Moolenaar <Bram@vim.org>
parents: 19102
diff changeset
10415 if (fp->col < 0)
a51fee786930 patch 8.2.0120: virtcol() does not check arguments to be valid
Bram Moolenaar <Bram@vim.org>
parents: 19102
diff changeset
10416 fp->col = 0;
a51fee786930 patch 8.2.0120: virtcol() does not check arguments to be valid
Bram Moolenaar <Bram@vim.org>
parents: 19102
diff changeset
10417 else
a51fee786930 patch 8.2.0120: virtcol() does not check arguments to be valid
Bram Moolenaar <Bram@vim.org>
parents: 19102
diff changeset
10418 {
a51fee786930 patch 8.2.0120: virtcol() does not check arguments to be valid
Bram Moolenaar <Bram@vim.org>
parents: 19102
diff changeset
10419 len = (int)STRLEN(ml_get(fp->lnum));
a51fee786930 patch 8.2.0120: virtcol() does not check arguments to be valid
Bram Moolenaar <Bram@vim.org>
parents: 19102
diff changeset
10420 if (fp->col > len)
a51fee786930 patch 8.2.0120: virtcol() does not check arguments to be valid
Bram Moolenaar <Bram@vim.org>
parents: 19102
diff changeset
10421 fp->col = len;
a51fee786930 patch 8.2.0120: virtcol() does not check arguments to be valid
Bram Moolenaar <Bram@vim.org>
parents: 19102
diff changeset
10422 }
28994
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10423 getvvcol(curwin, fp, &vcol_start, NULL, &vcol_end);
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10424 ++vcol_start;
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10425 ++vcol_end;
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10426 }
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10427
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10428 if (argvars[1].v_type != VAR_UNKNOWN && tv_get_bool(&argvars[1]))
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10429 {
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10430 if (rettv_list_alloc(rettv) == OK)
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10431 {
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10432 list_append_number(rettv->vval.v_list, vcol_start);
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10433 list_append_number(rettv->vval.v_list, vcol_end);
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10434 }
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10435 else
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10436 rettv->vval.v_number = 0;
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10437 }
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10438 else
644b0f0541de patch 8.2.5019: cannot get the first screen column of a character
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
10439 rettv->vval.v_number = vcol_end;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10440 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10441
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10442 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10443 * "visualmode()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10444 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10445 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10446 f_visualmode(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10447 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10448 char_u str[2];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10449
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10450 if (in_vim9script() && check_for_opt_bool_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10451 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10452
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10453 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10454 str[0] = curbuf->b_visual_mode_eval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10455 str[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10456 rettv->vval.v_string = vim_strsave(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10457
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10458 // A non-zero number or non-empty string argument: reset mode.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10459 if (non_zero_arg(&argvars[0]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10460 curbuf->b_visual_mode_eval = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10461 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10462
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10463 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10464 * "wildmenumode()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10465 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10466 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10467 f_wildmenumode(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10468 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10469 #ifdef FEAT_WILDMENU
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 28757
diff changeset
10470 if (wild_menu_showing || ((State & MODE_CMDLINE) && cmdline_pum_active()))
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10471 rettv->vval.v_number = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10472 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10473 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10474
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10475 /*
18973
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
10476 * "windowsversion()" function
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
10477 */
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
10478 static void
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
10479 f_windowsversion(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
10480 {
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
10481 rettv->v_type = VAR_STRING;
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
10482 rettv->vval.v_string = vim_strsave((char_u *)windowsVersion);
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
10483 }
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
10484
bf8eb950df61 patch 8.2.0047: cannot skip tests for specific MS-Windows platform
Bram Moolenaar <Bram@vim.org>
parents: 18777
diff changeset
10485 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10486 * "wordcount()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10487 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10488 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10489 f_wordcount(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10490 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10491 if (rettv_dict_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10492 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10493 cursor_pos_info(rettv->vval.v_dict);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10494 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10495
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10496 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10497 * "xor(expr, expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10498 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10499 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10500 f_xor(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10501 {
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10502 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10503 && (check_for_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10504 || check_for_number_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10505 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25378
diff changeset
10506
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
10507 rettv->vval.v_number = tv_get_number_chk(&argvars[0], NULL)
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
10508 ^ tv_get_number_chk(&argvars[1], NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10509 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10510
18777
3a68dc2a1bc1 patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
10511 #endif // FEAT_EVAL