annotate src/evalfunc.c @ 18703:aef98a646d3e v8.1.2343

patch 8.1.2343: using time() for srand() is not very random Commit: https://github.com/vim/vim/commit/07e4a197953d12902fb97beb48830a5323a52280 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 26 12:23:30 2019 +0100 patch 8.1.2343: using time() for srand() is not very random Problem: Using time() for srand() is not very random. Solution: use /dev/urandom if available
author Bram Moolenaar <Bram@vim.org>
date Tue, 26 Nov 2019 12:30:04 +0100
parents 128662297ddf
children 2513e666aa82
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
18669
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
23 #if defined(MACOS_X)
17893
e4d3b6c466d4 patch 8.1.1943: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 17873
diff changeset
24 # include <time.h> // for time_t
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 static void f_abs(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 static void f_acos(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 static void 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
32 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 static void f_asin(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_atan(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 static void f_atan2(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 #endif
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
37 #ifdef FEAT_BEVAL
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
38 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
39 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
40 # 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
41 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
42 # endif
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
43 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 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
45 static void byteidx(typval_T *argvars, typval_T *rettv, int comp);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 static void f_byteidx(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 static void f_byteidxcomp(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 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
49 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 static void f_ceil(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 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
53 static void 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
54 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
55 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
56 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
57 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 static void f_cos(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 static void f_cosh(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 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
62 #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
63 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
64 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 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
66 static void f_did_filetype(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 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
68 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
69 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
70 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
71 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
72 static void f_execute(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 static void 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
74 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 static void f_exp(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 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
78 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
79 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
80 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 static void f_float2nr(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_floor(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_fmod(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 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
86 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
87 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
88 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
89 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
90 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
91 static void f_getchangelist(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 static void f_getcharsearch(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_getcmdwintype(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
94 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
95 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
96 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
97 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
98 static void 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
99 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
100 static void 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
101 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
102 static void f_gettagstack(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 static void 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
104 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
105 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
106 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
107 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
108 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
109 static void f_iconv(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 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
119 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
120 #if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
16213
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
121 static void f_isinf(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 static void f_isnan(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 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
125 static void 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
126 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
127 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
128 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
129 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
130 static void f_localtime(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 static void f_log(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 static void f_log10(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 #ifdef FEAT_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 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
137 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 static void f_maparg(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 static void f_mapcheck(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_match(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 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
142 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
143 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
144 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
145 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
146 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
147 #ifdef FEAT_MZSCHEME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 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
149 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 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
151 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
152 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
153 #ifdef FEAT_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 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
155 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 static void f_pow(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 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
160 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
161 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
162 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
163 #ifdef FEAT_PYTHON3
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 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
165 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 #ifdef FEAT_PYTHON
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 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
168 #endif
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
169 #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
170 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
171 #endif
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
172 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
173 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
174 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
175 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
176 static void f_reltime(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 static void f_reltimefloat(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 static void f_reltimestr(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_remote_expr(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_remote_foreground(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_remote_peek(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 static void f_remote_read(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 static void f_remote_send(typval_T *argvars, typval_T *rettv);
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
186 static void f_remote_startserver(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 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
188 static void 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
189 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 static void f_round(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 #endif
16103
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
192 #ifdef FEAT_RUBY
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
193 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
194 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 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
196 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
197 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
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 static void 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
206 static void f_server2client(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 static void f_serverlist(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 static void f_setcharsearch(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
209 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
210 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
211 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
212 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
213 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
214 #ifdef FEAT_CRYPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 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
216 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 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
218 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
219 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 static void f_sin(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 static void f_sinh(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 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
224 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
225 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
226 static void 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
227 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 static void f_sqrt(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
229 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
230 static void f_str2float(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 #endif
16235
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
232 static void f_str2list(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 static void f_str2nr(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 static void f_strchars(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 #ifdef HAVE_STRFTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 static void f_strftime(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 static void f_strgetchar(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 static void f_stridx(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240 static void f_strlen(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 static void f_strcharpart(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242 static void f_strpart(typval_T *argvars, typval_T *rettv);
18669
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
243 #ifdef HAVE_STRPTIME
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
244 static void f_strptime(typval_T *argvars, typval_T *rettv);
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
245 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 static void f_strridx(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247 static void f_strtrans(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 static void f_strdisplaywidth(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 static void f_strwidth(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 static void f_tan(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 static void f_tanh(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 static void f_tolower(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267 static void f_toupper(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 static void f_tr(typval_T *argvars, typval_T *rettv);
13513
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
269 static void f_trim(typval_T *argvars, typval_T *rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
270 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271 static void f_trunc(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 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
274 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
275 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
276 static void f_wildmenumode(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 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
278 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
279
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281 * 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
282 * 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
283 */
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
284 typedef struct
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
285 {
17620
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
286 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
287 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
288 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
289 char f_argtype; // for method: FEARG_ values
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
290 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
291 // implementation of function
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
292 } funcentry_T;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
293
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
294 // 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
295 #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
296 #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
297 #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
298 #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
299 #define FEARG_LAST 9 // base is the last argument
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
300
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
301 static funcentry_T global_functions[] =
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
304 {"abs", 1, 1, FEARG_1, f_abs},
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
305 {"acos", 1, 1, FEARG_1, f_acos}, // WJMc
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
306 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
307 {"add", 2, 2, FEARG_1, f_add},
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
308 {"and", 2, 2, FEARG_1, f_and},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
309 {"append", 2, 2, FEARG_LAST, f_append},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
310 {"appendbufline", 3, 3, FEARG_LAST, f_appendbufline},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
311 {"argc", 0, 1, 0, f_argc},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
312 {"argidx", 0, 0, 0, f_argidx},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
313 {"arglistid", 0, 2, 0, f_arglistid},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
314 {"argv", 0, 2, 0, f_argv},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
316 {"asin", 1, 1, FEARG_1, f_asin}, // WJMc
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
317 #endif
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
318 {"assert_beeps", 1, 2, FEARG_1, f_assert_beeps},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
319 {"assert_equal", 2, 3, FEARG_2, f_assert_equal},
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
320 {"assert_equalfile", 2, 2, FEARG_1, f_assert_equalfile},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
321 {"assert_exception", 1, 2, 0, f_assert_exception},
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
322 {"assert_fails", 1, 3, FEARG_1, f_assert_fails},
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
323 {"assert_false", 1, 2, FEARG_1, f_assert_false},
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
324 {"assert_inrange", 3, 4, FEARG_3, f_assert_inrange},
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
325 {"assert_match", 2, 3, FEARG_2, f_assert_match},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
326 {"assert_notequal", 2, 3, FEARG_2, f_assert_notequal},
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
327 {"assert_notmatch", 2, 3, FEARG_2, f_assert_notmatch},
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
328 {"assert_report", 1, 1, FEARG_1, f_assert_report},
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
329 {"assert_true", 1, 2, FEARG_1, f_assert_true},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
331 {"atan", 1, 1, FEARG_1, f_atan},
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
332 {"atan2", 2, 2, FEARG_1, f_atan2},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333 #endif
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
334 #ifdef FEAT_BEVAL
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
335 {"balloon_gettext", 0, 0, 0, f_balloon_gettext},
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
336 {"balloon_show", 1, 1, FEARG_1, f_balloon_show},
12885
10cb5c3df3f5 patch 8.0.1319: can't build GUI on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
337 # if defined(FEAT_BEVAL_TERM)
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
338 {"balloon_split", 1, 1, FEARG_1, f_balloon_split},
12885
10cb5c3df3f5 patch 8.0.1319: can't build GUI on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
339 # endif
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
340 #endif
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
341 {"browse", 4, 4, 0, f_browse},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
342 {"browsedir", 2, 2, 0, f_browsedir},
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
343 {"bufadd", 1, 1, FEARG_1, f_bufadd},
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
344 {"bufexists", 1, 1, FEARG_1, f_bufexists},
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
345 {"buffer_exists", 1, 1, FEARG_1, f_bufexists}, // obsolete
17855
285f7a700185 patch 8.1.1924: using empty string for current buffer is unexpected
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
346 {"buffer_name", 0, 1, FEARG_1, f_bufname}, // obsolete
285f7a700185 patch 8.1.1924: using empty string for current buffer is unexpected
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
347 {"buffer_number", 0, 1, FEARG_1, f_bufnr}, // obsolete
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
348 {"buflisted", 1, 1, FEARG_1, f_buflisted},
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
349 {"bufload", 1, 1, FEARG_1, f_bufload},
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
350 {"bufloaded", 1, 1, FEARG_1, f_bufloaded},
17855
285f7a700185 patch 8.1.1924: using empty string for current buffer is unexpected
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
351 {"bufname", 0, 1, FEARG_1, f_bufname},
285f7a700185 patch 8.1.1924: using empty string for current buffer is unexpected
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
352 {"bufnr", 0, 2, FEARG_1, f_bufnr},
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
353 {"bufwinid", 1, 1, FEARG_1, f_bufwinid},
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
354 {"bufwinnr", 1, 1, FEARG_1, f_bufwinnr},
17829
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
355 {"byte2line", 1, 1, FEARG_1, f_byte2line},
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
356 {"byteidx", 2, 2, FEARG_1, f_byteidx},
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
357 {"byteidxcomp", 2, 2, FEARG_1, f_byteidxcomp},
1090d6637cfd patch 8.1.1911: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
358 {"call", 2, 3, FEARG_1, f_call},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
360 {"ceil", 1, 1, FEARG_1, f_ceil},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362 #ifdef FEAT_JOB_CHANNEL
17831
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
363 {"ch_canread", 1, 1, FEARG_1, f_ch_canread},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
364 {"ch_close", 1, 1, FEARG_1, f_ch_close},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
365 {"ch_close_in", 1, 1, FEARG_1, f_ch_close_in},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
366 {"ch_evalexpr", 2, 3, FEARG_1, f_ch_evalexpr},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
367 {"ch_evalraw", 2, 3, FEARG_1, f_ch_evalraw},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
368 {"ch_getbufnr", 2, 2, FEARG_1, f_ch_getbufnr},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
369 {"ch_getjob", 1, 1, FEARG_1, f_ch_getjob},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
370 {"ch_info", 1, 1, FEARG_1, f_ch_info},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
371 {"ch_log", 1, 2, FEARG_1, f_ch_log},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
372 {"ch_logfile", 1, 2, FEARG_1, f_ch_logfile},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
373 {"ch_open", 1, 2, FEARG_1, f_ch_open},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
374 {"ch_read", 1, 2, FEARG_1, f_ch_read},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
375 {"ch_readblob", 1, 2, FEARG_1, f_ch_readblob},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
376 {"ch_readraw", 1, 2, FEARG_1, f_ch_readraw},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
377 {"ch_sendexpr", 2, 3, FEARG_1, f_ch_sendexpr},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
378 {"ch_sendraw", 2, 3, FEARG_1, f_ch_sendraw},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
379 {"ch_setoptions", 2, 2, FEARG_1, f_ch_setoptions},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
380 {"ch_status", 1, 2, FEARG_1, f_ch_status},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
381 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
382 {"changenr", 0, 0, 0, f_changenr},
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
383 {"char2nr", 1, 2, FEARG_1, f_char2nr},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
384 {"chdir", 1, 1, FEARG_1, f_chdir},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
385 {"cindent", 1, 1, FEARG_1, f_cindent},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
386 {"clearmatches", 0, 1, FEARG_1, f_clearmatches},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
387 {"col", 1, 1, FEARG_1, f_col},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
388 {"complete", 2, 2, FEARG_2, f_complete},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
389 {"complete_add", 1, 1, FEARG_1, f_complete_add},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
390 {"complete_check", 0, 0, 0, f_complete_check},
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
391 {"complete_info", 0, 1, FEARG_1, f_complete_info},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
392 {"confirm", 1, 4, FEARG_1, f_confirm},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
393 {"copy", 1, 1, FEARG_1, f_copy},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
395 {"cos", 1, 1, FEARG_1, f_cos},
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
396 {"cosh", 1, 1, FEARG_1, f_cosh},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
397 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
398 {"count", 2, 4, FEARG_1, f_count},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
399 {"cscope_connection",0,3, 0, f_cscope_connection},
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
400 {"cursor", 1, 3, FEARG_1, f_cursor},
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
401 #ifdef MSWIN
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
402 {"debugbreak", 1, 1, FEARG_1, f_debugbreak},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
403 #endif
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
404 {"deepcopy", 1, 2, FEARG_1, f_deepcopy},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
405 {"delete", 1, 2, FEARG_1, f_delete},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
406 {"deletebufline", 2, 3, FEARG_1, f_deletebufline},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
407 {"did_filetype", 0, 0, 0, f_did_filetype},
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
408 {"diff_filler", 1, 1, FEARG_1, f_diff_filler},
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
409 {"diff_hlID", 2, 2, FEARG_1, f_diff_hlID},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
410 {"empty", 1, 1, FEARG_1, f_empty},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
411 {"environ", 0, 0, 0, f_environ},
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
412 {"escape", 2, 2, FEARG_1, f_escape},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
413 {"eval", 1, 1, FEARG_1, f_eval},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
414 {"eventhandler", 0, 0, 0, f_eventhandler},
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
415 {"executable", 1, 1, FEARG_1, f_executable},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
416 {"execute", 1, 2, FEARG_1, f_execute},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
417 {"exepath", 1, 1, FEARG_1, f_exepath},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
418 {"exists", 1, 1, FEARG_1, f_exists},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
420 {"exp", 1, 1, FEARG_1, f_exp},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
421 #endif
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
422 {"expand", 1, 3, FEARG_1, f_expand},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
423 {"expandcmd", 1, 1, FEARG_1, f_expandcmd},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
424 {"extend", 2, 3, FEARG_1, f_extend},
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
425 {"feedkeys", 1, 2, FEARG_1, f_feedkeys},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
426 {"file_readable", 1, 1, FEARG_1, f_filereadable}, // obsolete
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
427 {"filereadable", 1, 1, FEARG_1, f_filereadable},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
428 {"filewritable", 1, 1, FEARG_1, f_filewritable},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
429 {"filter", 2, 2, FEARG_1, f_filter},
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
430 {"finddir", 1, 3, FEARG_1, f_finddir},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
431 {"findfile", 1, 3, FEARG_1, f_findfile},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
433 {"float2nr", 1, 1, FEARG_1, f_float2nr},
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
434 {"floor", 1, 1, FEARG_1, f_floor},
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
435 {"fmod", 2, 2, FEARG_1, f_fmod},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
436 #endif
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
437 {"fnameescape", 1, 1, FEARG_1, f_fnameescape},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
438 {"fnamemodify", 2, 2, FEARG_1, f_fnamemodify},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
439 {"foldclosed", 1, 1, FEARG_1, f_foldclosed},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
440 {"foldclosedend", 1, 1, FEARG_1, f_foldclosedend},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
441 {"foldlevel", 1, 1, FEARG_1, f_foldlevel},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
442 {"foldtext", 0, 0, 0, f_foldtext},
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
443 {"foldtextresult", 1, 1, FEARG_1, f_foldtextresult},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
444 {"foreground", 0, 0, 0, f_foreground},
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
445 {"funcref", 1, 3, FEARG_1, f_funcref},
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
446 {"function", 1, 3, FEARG_1, f_function},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
447 {"garbagecollect", 0, 1, 0, f_garbagecollect},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
448 {"get", 2, 3, FEARG_1, f_get},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
449 {"getbufinfo", 0, 1, 0, f_getbufinfo},
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
450 {"getbufline", 2, 3, FEARG_1, f_getbufline},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
451 {"getbufvar", 2, 3, FEARG_1, f_getbufvar},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
452 {"getchangelist", 0, 1, FEARG_1, f_getchangelist},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
453 {"getchar", 0, 1, 0, f_getchar},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
454 {"getcharmod", 0, 0, 0, f_getcharmod},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
455 {"getcharsearch", 0, 0, 0, f_getcharsearch},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
456 {"getcmdline", 0, 0, 0, f_getcmdline},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
457 {"getcmdpos", 0, 0, 0, f_getcmdpos},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
458 {"getcmdtype", 0, 0, 0, f_getcmdtype},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
459 {"getcmdwintype", 0, 0, 0, f_getcmdwintype},
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
460 {"getcompletion", 2, 3, FEARG_1, f_getcompletion},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
461 {"getcurpos", 0, 0, 0, f_getcurpos},
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
462 {"getcwd", 0, 2, FEARG_1, f_getcwd},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
463 {"getenv", 1, 1, FEARG_1, f_getenv},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
464 {"getfontname", 0, 1, 0, f_getfontname},
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
465 {"getfperm", 1, 1, FEARG_1, f_getfperm},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
466 {"getfsize", 1, 1, FEARG_1, f_getfsize},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
467 {"getftime", 1, 1, FEARG_1, f_getftime},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
468 {"getftype", 1, 1, FEARG_1, f_getftype},
18008
8ae333756614 patch 8.1.2000: plugin cannot get the current IME status
Bram Moolenaar <Bram@vim.org>
parents: 18000
diff changeset
469 {"getimstatus", 0, 0, 0, f_getimstatus},
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
470 {"getjumplist", 0, 2, FEARG_1, f_getjumplist},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
471 {"getline", 1, 2, FEARG_1, f_getline},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
472 {"getloclist", 1, 2, 0, f_getloclist},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
473 {"getmatches", 0, 1, 0, f_getmatches},
18623
3089b422b9dc patch 8.1.2304: cannot get the mouse position when getting a mouse click
Bram Moolenaar <Bram@vim.org>
parents: 18576
diff changeset
474 {"getmousepos", 0, 0, 0, f_getmousepos},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
475 {"getpid", 0, 0, 0, f_getpid},
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
476 {"getpos", 1, 1, FEARG_1, f_getpos},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
477 {"getqflist", 0, 1, 0, f_getqflist},
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
478 {"getreg", 0, 3, FEARG_1, f_getreg},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
479 {"getregtype", 0, 1, FEARG_1, f_getregtype},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
480 {"gettabinfo", 0, 1, FEARG_1, f_gettabinfo},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
481 {"gettabvar", 2, 3, FEARG_1, f_gettabvar},
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
482 {"gettabwinvar", 3, 4, FEARG_1, f_gettabwinvar},
17912
9fac6d0de69a patch 8.1.1952: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17893
diff changeset
483 {"gettagstack", 0, 1, FEARG_1, f_gettagstack},
9fac6d0de69a patch 8.1.1952: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17893
diff changeset
484 {"getwininfo", 0, 1, FEARG_1, f_getwininfo},
9fac6d0de69a patch 8.1.1952: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17893
diff changeset
485 {"getwinpos", 0, 1, FEARG_1, f_getwinpos},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
486 {"getwinposx", 0, 0, 0, f_getwinposx},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
487 {"getwinposy", 0, 0, 0, f_getwinposy},
17912
9fac6d0de69a patch 8.1.1952: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17893
diff changeset
488 {"getwinvar", 2, 3, FEARG_1, f_getwinvar},
9fac6d0de69a patch 8.1.1952: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17893
diff changeset
489 {"glob", 1, 4, FEARG_1, f_glob},
9fac6d0de69a patch 8.1.1952: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17893
diff changeset
490 {"glob2regpat", 1, 1, FEARG_1, f_glob2regpat},
9fac6d0de69a patch 8.1.1952: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17893
diff changeset
491 {"globpath", 2, 5, FEARG_2, f_globpath},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
492 {"has", 1, 1, 0, f_has},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
493 {"has_key", 2, 2, FEARG_1, f_has_key},
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
494 {"haslocaldir", 0, 2, FEARG_1, f_haslocaldir},
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
495 {"hasmapto", 1, 3, FEARG_1, f_hasmapto},
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
496 {"highlightID", 1, 1, FEARG_1, f_hlID}, // obsolete
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
497 {"highlight_exists",1, 1, FEARG_1, f_hlexists}, // obsolete
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
498 {"histadd", 2, 2, FEARG_2, f_histadd},
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
499 {"histdel", 1, 2, FEARG_1, f_histdel},
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
500 {"histget", 1, 2, FEARG_1, f_histget},
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
501 {"histnr", 1, 1, FEARG_1, f_histnr},
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
502 {"hlID", 1, 1, FEARG_1, f_hlID},
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
503 {"hlexists", 1, 1, FEARG_1, f_hlexists},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
504 {"hostname", 0, 0, 0, f_hostname},
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
505 {"iconv", 3, 3, FEARG_1, f_iconv},
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
506 {"indent", 1, 1, FEARG_1, f_indent},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
507 {"index", 2, 4, FEARG_1, f_index},
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
508 {"input", 1, 3, FEARG_1, f_input},
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
509 {"inputdialog", 1, 3, FEARG_1, f_inputdialog},
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
510 {"inputlist", 1, 1, FEARG_1, f_inputlist},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
511 {"inputrestore", 0, 0, 0, f_inputrestore},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
512 {"inputsave", 0, 0, 0, f_inputsave},
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
513 {"inputsecret", 1, 2, FEARG_1, f_inputsecret},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
514 {"insert", 2, 3, FEARG_1, f_insert},
18699
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
515 {"interrupt", 0, 0, 0, f_interrupt},
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
516 {"invert", 1, 1, FEARG_1, f_invert},
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
517 {"isdirectory", 1, 1, FEARG_1, f_isdirectory},
16213
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
518 #if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
519 {"isinf", 1, 1, FEARG_1, f_isinf},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
520 #endif
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
521 {"islocked", 1, 1, FEARG_1, f_islocked},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
522 #if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
523 {"isnan", 1, 1, FEARG_1, f_isnan},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
524 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
525 {"items", 1, 1, FEARG_1, f_items},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
526 #ifdef FEAT_JOB_CHANNEL
17831
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
527 {"job_getchannel", 1, 1, FEARG_1, f_job_getchannel},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
528 {"job_info", 0, 1, FEARG_1, f_job_info},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
529 {"job_setoptions", 2, 2, FEARG_1, f_job_setoptions},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
530 {"job_start", 1, 2, FEARG_1, f_job_start},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
531 {"job_status", 1, 1, FEARG_1, f_job_status},
4ab97fdf7ff7 patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17829
diff changeset
532 {"job_stop", 1, 2, FEARG_1, f_job_stop},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
533 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
534 {"join", 1, 2, FEARG_1, f_join},
17916
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
535 {"js_decode", 1, 1, FEARG_1, f_js_decode},
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
536 {"js_encode", 1, 1, FEARG_1, f_js_encode},
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
537 {"json_decode", 1, 1, FEARG_1, f_json_decode},
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
538 {"json_encode", 1, 1, FEARG_1, f_json_encode},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
539 {"keys", 1, 1, FEARG_1, f_keys},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
540 {"last_buffer_nr", 0, 0, 0, f_last_buffer_nr}, // obsolete
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
541 {"len", 1, 1, FEARG_1, f_len},
17916
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
542 {"libcall", 3, 3, FEARG_3, f_libcall},
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
543 {"libcallnr", 3, 3, FEARG_3, f_libcallnr},
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
544 {"line", 1, 2, FEARG_1, f_line},
17916
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
545 {"line2byte", 1, 1, FEARG_1, f_line2byte},
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
546 {"lispindent", 1, 1, FEARG_1, f_lispindent},
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
547 {"list2str", 1, 2, FEARG_1, f_list2str},
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
548 {"listener_add", 1, 2, FEARG_2, f_listener_add},
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
549 {"listener_flush", 0, 1, FEARG_1, f_listener_flush},
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
550 {"listener_remove", 1, 1, FEARG_1, f_listener_remove},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
551 {"localtime", 0, 0, 0, f_localtime},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
553 {"log", 1, 1, FEARG_1, f_log},
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
554 {"log10", 1, 1, FEARG_1, f_log10},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
556 #ifdef FEAT_LUA
17916
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17914
diff changeset
557 {"luaeval", 1, 2, FEARG_1, f_luaeval},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
558 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
559 {"map", 2, 2, FEARG_1, f_map},
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
560 {"maparg", 1, 4, FEARG_1, f_maparg},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
561 {"mapcheck", 1, 3, FEARG_1, f_mapcheck},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
562 {"match", 2, 4, FEARG_1, f_match},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
563 {"matchadd", 2, 5, FEARG_1, f_matchadd},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
564 {"matchaddpos", 2, 5, FEARG_1, f_matchaddpos},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
565 {"matcharg", 1, 1, FEARG_1, f_matcharg},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
566 {"matchdelete", 1, 2, FEARG_1, f_matchdelete},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
567 {"matchend", 2, 4, FEARG_1, f_matchend},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
568 {"matchlist", 2, 4, FEARG_1, f_matchlist},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
569 {"matchstr", 2, 4, FEARG_1, f_matchstr},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
570 {"matchstrpos", 2, 4, FEARG_1, f_matchstrpos},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
571 {"max", 1, 1, FEARG_1, f_max},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
572 {"min", 1, 1, FEARG_1, f_min},
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
573 {"mkdir", 1, 3, FEARG_1, f_mkdir},
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
574 {"mode", 0, 1, FEARG_1, f_mode},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 #ifdef FEAT_MZSCHEME
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17928
diff changeset
576 {"mzeval", 1, 1, FEARG_1, f_mzeval},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
577 #endif
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
578 {"nextnonblank", 1, 1, FEARG_1, f_nextnonblank},
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
579 {"nr2char", 1, 2, FEARG_1, f_nr2char},
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
580 {"or", 2, 2, FEARG_1, f_or},
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
581 {"pathshorten", 1, 1, FEARG_1, f_pathshorten},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582 #ifdef FEAT_PERL
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
583 {"perleval", 1, 1, FEARG_1, f_perleval},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 #endif
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
585 #ifdef FEAT_TEXT_PROP
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
586 {"popup_atcursor", 2, 2, FEARG_1, f_popup_atcursor},
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
587 {"popup_beval", 2, 2, FEARG_1, f_popup_beval},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
588 {"popup_clear", 0, 0, 0, f_popup_clear},
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
589 {"popup_close", 1, 2, FEARG_1, f_popup_close},
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
590 {"popup_create", 2, 2, FEARG_1, f_popup_create},
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
591 {"popup_dialog", 2, 2, FEARG_1, f_popup_dialog},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
592 {"popup_filter_menu", 2, 2, 0, f_popup_filter_menu},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
593 {"popup_filter_yesno", 2, 2, 0, f_popup_filter_yesno},
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17809
diff changeset
594 {"popup_findinfo", 0, 0, 0, f_popup_findinfo},
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17809
diff changeset
595 {"popup_findpreview", 0, 0, 0, f_popup_findpreview},
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
596 {"popup_getoptions", 1, 1, FEARG_1, f_popup_getoptions},
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
597 {"popup_getpos", 1, 1, FEARG_1, f_popup_getpos},
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
598 {"popup_hide", 1, 1, FEARG_1, f_popup_hide},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
599 {"popup_locate", 2, 2, 0, f_popup_locate},
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
600 {"popup_menu", 2, 2, FEARG_1, f_popup_menu},
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
601 {"popup_move", 2, 2, FEARG_1, f_popup_move},
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
602 {"popup_notification", 2, 2, FEARG_1, f_popup_notification},
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
603 {"popup_setoptions", 2, 2, FEARG_1, f_popup_setoptions},
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
604 {"popup_settext", 2, 2, FEARG_1, f_popup_settext},
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17970
diff changeset
605 {"popup_show", 1, 1, FEARG_1, f_popup_show},
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
606 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
608 {"pow", 2, 2, FEARG_1, f_pow},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
609 #endif
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
610 {"prevnonblank", 1, 1, FEARG_1, f_prevnonblank},
17676
14ac8c31e598 patch 8.1.1835: cannot use printf() as a method
Bram Moolenaar <Bram@vim.org>
parents: 17672
diff changeset
611 {"printf", 1, 19, FEARG_2, f_printf},
14019
dc67449d648c patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
612 #ifdef FEAT_JOB_CHANNEL
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
613 {"prompt_setcallback", 2, 2, FEARG_1, f_prompt_setcallback},
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
614 {"prompt_setinterrupt", 2, 2, FEARG_1, f_prompt_setinterrupt},
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
615 {"prompt_setprompt", 2, 2, FEARG_1, f_prompt_setprompt},
14019
dc67449d648c patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents: 14004
diff changeset
616 #endif
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
617 #ifdef FEAT_TEXT_PROP
17980
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17978
diff changeset
618 {"prop_add", 3, 3, FEARG_1, f_prop_add},
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17978
diff changeset
619 {"prop_clear", 1, 3, FEARG_1, f_prop_clear},
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17978
diff changeset
620 {"prop_list", 1, 2, FEARG_1, f_prop_list},
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17978
diff changeset
621 {"prop_remove", 1, 3, FEARG_1, f_prop_remove},
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17978
diff changeset
622 {"prop_type_add", 2, 2, FEARG_1, f_prop_type_add},
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17978
diff changeset
623 {"prop_type_change", 2, 2, FEARG_1, f_prop_type_change},
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17978
diff changeset
624 {"prop_type_delete", 1, 2, FEARG_1, f_prop_type_delete},
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17978
diff changeset
625 {"prop_type_get", 1, 2, FEARG_1, f_prop_type_get},
52f23198af7f patch 8.1.1986: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17978
diff changeset
626 {"prop_type_list", 0, 1, FEARG_1, f_prop_type_list},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
627 #endif
17756
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
628 {"pum_getpos", 0, 0, 0, f_pum_getpos},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
629 {"pumvisible", 0, 0, 0, f_pumvisible},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630 #ifdef FEAT_PYTHON3
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
631 {"py3eval", 1, 1, FEARG_1, f_py3eval},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
632 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
633 #ifdef FEAT_PYTHON
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
634 {"pyeval", 1, 1, FEARG_1, f_pyeval},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
635 #endif
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
636 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
637 {"pyxeval", 1, 1, FEARG_1, f_pyxeval},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
638 #endif
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
639 {"rand", 0, 1, FEARG_1, f_rand},
17982
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
640 {"range", 1, 3, FEARG_1, f_range},
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
641 {"readdir", 1, 2, FEARG_1, f_readdir},
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
642 {"readfile", 1, 3, FEARG_1, f_readfile},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
643 {"reg_executing", 0, 0, 0, f_reg_executing},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
644 {"reg_recording", 0, 0, 0, f_reg_recording},
17982
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
645 {"reltime", 0, 2, FEARG_1, f_reltime},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
646 #ifdef FEAT_FLOAT
17982
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
647 {"reltimefloat", 1, 1, FEARG_1, f_reltimefloat},
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
648 #endif
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
649 {"reltimestr", 1, 1, FEARG_1, f_reltimestr},
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
650 {"remote_expr", 2, 4, FEARG_1, f_remote_expr},
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
651 {"remote_foreground", 1, 1, FEARG_1, f_remote_foreground},
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
652 {"remote_peek", 1, 2, FEARG_1, f_remote_peek},
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
653 {"remote_read", 1, 2, FEARG_1, f_remote_read},
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
654 {"remote_send", 2, 3, FEARG_1, f_remote_send},
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
655 {"remote_startserver", 1, 1, FEARG_1, f_remote_startserver},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
656 {"remove", 2, 3, FEARG_1, f_remove},
17982
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
657 {"rename", 2, 2, FEARG_1, f_rename},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
658 {"repeat", 2, 2, FEARG_1, f_repeat},
17982
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
659 {"resolve", 1, 1, FEARG_1, f_resolve},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
660 {"reverse", 1, 1, FEARG_1, f_reverse},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
661 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
662 {"round", 1, 1, FEARG_1, f_round},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
663 #endif
16103
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
664 #ifdef FEAT_RUBY
17982
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
665 {"rubyeval", 1, 1, FEARG_1, f_rubyeval},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
666 #endif
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
667 {"screenattr", 2, 2, FEARG_1, f_screenattr},
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
668 {"screenchar", 2, 2, FEARG_1, f_screenchar},
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
669 {"screenchars", 2, 2, FEARG_1, f_screenchars},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
670 {"screencol", 0, 0, 0, f_screencol},
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
671 {"screenpos", 3, 3, FEARG_1, f_screenpos},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
672 {"screenrow", 0, 0, 0, f_screenrow},
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
673 {"screenstring", 2, 2, FEARG_1, f_screenstring},
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
674 {"search", 1, 4, FEARG_1, f_search},
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
675 {"searchdecl", 1, 3, FEARG_1, f_searchdecl},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
676 {"searchpair", 3, 7, 0, f_searchpair},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
677 {"searchpairpos", 3, 7, 0, f_searchpairpos},
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
678 {"searchpos", 1, 4, FEARG_1, f_searchpos},
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
679 {"server2client", 2, 2, FEARG_1, f_server2client},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
680 {"serverlist", 0, 0, 0, f_serverlist},
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
681 {"setbufline", 3, 3, FEARG_3, f_setbufline},
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
682 {"setbufvar", 3, 3, FEARG_3, f_setbufvar},
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
683 {"setcharsearch", 1, 1, FEARG_1, f_setcharsearch},
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
684 {"setcmdpos", 1, 1, FEARG_1, f_setcmdpos},
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
685 {"setenv", 2, 2, FEARG_2, f_setenv},
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
686 {"setfperm", 2, 2, FEARG_1, f_setfperm},
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
687 {"setline", 2, 2, FEARG_2, f_setline},
18000
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
688 {"setloclist", 2, 4, FEARG_2, f_setloclist},
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
689 {"setmatches", 1, 2, FEARG_1, f_setmatches},
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
690 {"setpos", 2, 2, FEARG_2, f_setpos},
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
691 {"setqflist", 1, 3, FEARG_1, f_setqflist},
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
692 {"setreg", 2, 3, FEARG_2, f_setreg},
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
693 {"settabvar", 3, 3, FEARG_3, f_settabvar},
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
694 {"settabwinvar", 4, 4, FEARG_4, f_settabwinvar},
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
695 {"settagstack", 2, 3, FEARG_2, f_settagstack},
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
696 {"setwinvar", 3, 3, FEARG_3, f_setwinvar},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
697 #ifdef FEAT_CRYPT
18000
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
698 {"sha256", 1, 1, FEARG_1, f_sha256},
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
699 #endif
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
700 {"shellescape", 1, 2, FEARG_1, f_shellescape},
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
701 {"shiftwidth", 0, 1, FEARG_1, f_shiftwidth},
15209
3a99b2e6d136 patch 8.1.0614: placing signs can be complicated
Bram Moolenaar <Bram@vim.org>
parents: 15146
diff changeset
702 #ifdef FEAT_SIGNS
17998
ea916dbbb9b9 patch 8.1.1995: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
703 {"sign_define", 1, 2, FEARG_1, f_sign_define},
ea916dbbb9b9 patch 8.1.1995: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
704 {"sign_getdefined", 0, 1, FEARG_1, f_sign_getdefined},
ea916dbbb9b9 patch 8.1.1995: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
705 {"sign_getplaced", 0, 2, FEARG_1, f_sign_getplaced},
ea916dbbb9b9 patch 8.1.1995: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
706 {"sign_jump", 3, 3, FEARG_1, f_sign_jump},
ea916dbbb9b9 patch 8.1.1995: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
707 {"sign_place", 4, 5, FEARG_1, f_sign_place},
ea916dbbb9b9 patch 8.1.1995: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
708 {"sign_placelist", 1, 1, FEARG_1, f_sign_placelist},
ea916dbbb9b9 patch 8.1.1995: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
709 {"sign_undefine", 0, 1, FEARG_1, f_sign_undefine},
ea916dbbb9b9 patch 8.1.1995: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
710 {"sign_unplace", 1, 2, FEARG_1, f_sign_unplace},
ea916dbbb9b9 patch 8.1.1995: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
711 {"sign_unplacelist", 1, 2, FEARG_1, f_sign_unplacelist},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
712 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
713 {"simplify", 1, 1, 0, f_simplify},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
715 {"sin", 1, 1, FEARG_1, f_sin},
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
716 {"sinh", 1, 1, FEARG_1, f_sinh},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
717 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
718 {"sort", 1, 3, FEARG_1, f_sort},
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
719 #ifdef FEAT_SOUND
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
720 {"sound_clear", 0, 0, 0, f_sound_clear},
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
721 {"sound_playevent", 1, 2, FEARG_1, f_sound_playevent},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
722 {"sound_playfile", 1, 2, FEARG_1, f_sound_playfile},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
723 {"sound_stop", 1, 1, FEARG_1, f_sound_stop},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
724 #endif
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
725 {"soundfold", 1, 1, FEARG_1, f_soundfold},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
726 {"spellbadword", 0, 1, FEARG_1, f_spellbadword},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
727 {"spellsuggest", 1, 3, FEARG_1, f_spellsuggest},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
728 {"split", 1, 3, FEARG_1, f_split},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
729 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
730 {"sqrt", 1, 1, FEARG_1, f_sqrt},
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
731 {"srand", 0, 1, FEARG_1, f_srand},
18104
e59ff7b5d7a7 patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents: 18094
diff changeset
732 #endif
e59ff7b5d7a7 patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents: 18094
diff changeset
733 {"state", 0, 1, FEARG_1, f_state},
e59ff7b5d7a7 patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents: 18094
diff changeset
734 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
735 {"str2float", 1, 1, FEARG_1, f_str2float},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
736 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
737 {"str2list", 1, 2, FEARG_1, f_str2list},
18080
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
738 {"str2nr", 1, 3, FEARG_1, f_str2nr},
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
739 {"strcharpart", 2, 3, FEARG_1, f_strcharpart},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
740 {"strchars", 1, 2, FEARG_1, f_strchars},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
741 {"strdisplaywidth", 1, 2, FEARG_1, f_strdisplaywidth},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
742 #ifdef HAVE_STRFTIME
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
743 {"strftime", 1, 2, FEARG_1, f_strftime},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
744 #endif
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
745 {"strgetchar", 2, 2, FEARG_1, f_strgetchar},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
746 {"stridx", 2, 3, FEARG_1, f_stridx},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
747 {"string", 1, 1, FEARG_1, f_string},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
748 {"strlen", 1, 1, FEARG_1, f_strlen},
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
749 {"strpart", 2, 3, FEARG_1, f_strpart},
18669
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
750 #ifdef HAVE_STRPTIME
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
751 {"strptime", 2, 2, FEARG_1, f_strptime},
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
752 #endif
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
753 {"strridx", 2, 3, FEARG_1, f_strridx},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
754 {"strtrans", 1, 1, FEARG_1, f_strtrans},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
755 {"strwidth", 1, 1, FEARG_1, f_strwidth},
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
756 {"submatch", 1, 2, FEARG_1, f_submatch},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
757 {"substitute", 4, 4, FEARG_1, f_substitute},
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
758 {"swapinfo", 1, 1, FEARG_1, f_swapinfo},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
759 {"swapname", 1, 1, FEARG_1, f_swapname},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
760 {"synID", 3, 3, 0, f_synID},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
761 {"synIDattr", 2, 3, FEARG_1, f_synIDattr},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
762 {"synIDtrans", 1, 1, FEARG_1, f_synIDtrans},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
763 {"synconcealed", 2, 2, 0, f_synconcealed},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
764 {"synstack", 2, 2, 0, f_synstack},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
765 {"system", 1, 2, FEARG_1, f_system},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
766 {"systemlist", 1, 2, FEARG_1, f_systemlist},
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
767 {"tabpagebuflist", 0, 1, FEARG_1, f_tabpagebuflist},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
768 {"tabpagenr", 0, 1, 0, f_tabpagenr},
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
769 {"tabpagewinnr", 1, 2, FEARG_1, f_tabpagewinnr},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
770 {"tagfiles", 0, 0, 0, f_tagfiles},
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
771 {"taglist", 1, 2, FEARG_1, f_taglist},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
772 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
773 {"tan", 1, 1, FEARG_1, f_tan},
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
774 {"tanh", 1, 1, FEARG_1, f_tanh},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
775 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
776 {"tempname", 0, 0, 0, f_tempname},
11846
1c65cad8b967 patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
777 #ifdef FEAT_TERMINAL
18033
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
778 {"term_dumpdiff", 2, 3, FEARG_1, f_term_dumpdiff},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
779 {"term_dumpload", 1, 2, FEARG_1, f_term_dumpload},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
780 {"term_dumpwrite", 2, 3, FEARG_2, f_term_dumpwrite},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
781 {"term_getaltscreen", 1, 1, FEARG_1, f_term_getaltscreen},
13626
ab89131d30e0 patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents: 13587
diff changeset
782 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
18033
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
783 {"term_getansicolors", 1, 1, FEARG_1, f_term_getansicolors},
13626
ab89131d30e0 patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents: 13587
diff changeset
784 # endif
18033
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
785 {"term_getattr", 2, 2, FEARG_1, f_term_getattr},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
786 {"term_getcursor", 1, 1, FEARG_1, f_term_getcursor},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
787 {"term_getjob", 1, 1, FEARG_1, f_term_getjob},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
788 {"term_getline", 2, 2, FEARG_1, f_term_getline},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
789 {"term_getscrolled", 1, 1, FEARG_1, f_term_getscrolled},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
790 {"term_getsize", 1, 1, FEARG_1, f_term_getsize},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
791 {"term_getstatus", 1, 1, FEARG_1, f_term_getstatus},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
792 {"term_gettitle", 1, 1, FEARG_1, f_term_gettitle},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
793 {"term_gettty", 1, 2, FEARG_1, f_term_gettty},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
794 {"term_list", 0, 0, 0, f_term_list},
18033
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
795 {"term_scrape", 2, 2, FEARG_1, f_term_scrape},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
796 {"term_sendkeys", 2, 2, FEARG_1, f_term_sendkeys},
13626
ab89131d30e0 patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents: 13587
diff changeset
797 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
18033
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
798 {"term_setansicolors", 2, 2, FEARG_1, f_term_setansicolors},
13626
ab89131d30e0 patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents: 13587
diff changeset
799 # endif
18170
4ac8161e92e0 patch 8.1.2080: the terminal API is limited and can't be disabled
Bram Moolenaar <Bram@vim.org>
parents: 18104
diff changeset
800 {"term_setapi", 2, 2, FEARG_1, f_term_setapi},
18033
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
801 {"term_setkill", 2, 2, FEARG_1, f_term_setkill},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
802 {"term_setrestore", 2, 2, FEARG_1, f_term_setrestore},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
803 {"term_setsize", 3, 3, FEARG_1, f_term_setsize},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
804 {"term_start", 1, 2, FEARG_1, f_term_start},
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
805 {"term_wait", 1, 2, FEARG_1, f_term_wait},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
806 #endif
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
807 {"test_alloc_fail", 3, 3, FEARG_1, f_test_alloc_fail},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
808 {"test_autochdir", 0, 0, 0, f_test_autochdir},
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
809 {"test_feedinput", 1, 1, FEARG_1, f_test_feedinput},
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
810 {"test_garbagecollect_now", 0, 0, 0, f_test_garbagecollect_now},
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
811 {"test_garbagecollect_soon", 0, 0, 0, f_test_garbagecollect_soon},
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
812 {"test_getvalue", 1, 1, FEARG_1, f_test_getvalue},
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
813 {"test_ignore_error", 1, 1, FEARG_1, f_test_ignore_error},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
814 {"test_null_blob", 0, 0, 0, f_test_null_blob},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
815 #ifdef FEAT_JOB_CHANNEL
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
816 {"test_null_channel", 0, 0, 0, f_test_null_channel},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
817 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
818 {"test_null_dict", 0, 0, 0, f_test_null_dict},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
819 #ifdef FEAT_JOB_CHANNEL
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
820 {"test_null_job", 0, 0, 0, f_test_null_job},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
821 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
822 {"test_null_list", 0, 0, 0, f_test_null_list},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
823 {"test_null_partial", 0, 0, 0, f_test_null_partial},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
824 {"test_null_string", 0, 0, 0, f_test_null_string},
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
825 {"test_option_not_set", 1, 1, FEARG_1, f_test_option_not_set},
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
826 {"test_override", 2, 2, FEARG_2, f_test_override},
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
827 {"test_refcount", 1, 1, FEARG_1, f_test_refcount},
14756
a179e5cfcab7 patch 8.1.0390: scrollbars are not tested
Christian Brabandt <cb@256bit.org>
parents: 14752
diff changeset
828 #ifdef FEAT_GUI
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
829 {"test_scrollbar", 3, 3, FEARG_2, f_test_scrollbar},
14756
a179e5cfcab7 patch 8.1.0390: scrollbars are not tested
Christian Brabandt <cb@256bit.org>
parents: 14752
diff changeset
830 #endif
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
831 {"test_setmouse", 2, 2, 0, f_test_setmouse},
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
832 {"test_settime", 1, 1, FEARG_1, f_test_settime},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
833 #ifdef FEAT_TIMERS
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
834 {"timer_info", 0, 1, FEARG_1, f_timer_info},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
835 {"timer_pause", 2, 2, FEARG_1, f_timer_pause},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
836 {"timer_start", 2, 3, FEARG_1, f_timer_start},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
837 {"timer_stop", 1, 1, FEARG_1, f_timer_stop},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
838 {"timer_stopall", 0, 0, 0, f_timer_stopall},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
839 #endif
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
840 {"tolower", 1, 1, FEARG_1, f_tolower},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
841 {"toupper", 1, 1, FEARG_1, f_toupper},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
842 {"tr", 3, 3, FEARG_1, f_tr},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
843 {"trim", 1, 2, FEARG_1, f_trim},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
844 #ifdef FEAT_FLOAT
17765
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
845 {"trunc", 1, 1, FEARG_1, f_trunc},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
846 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
847 {"type", 1, 1, FEARG_1, f_type},
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
848 {"undofile", 1, 1, FEARG_1, f_undofile},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
849 {"undotree", 0, 0, 0, f_undotree},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
850 {"uniq", 1, 3, FEARG_1, f_uniq},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
851 {"values", 1, 1, FEARG_1, f_values},
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
852 {"virtcol", 1, 1, FEARG_1, f_virtcol},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
853 {"visualmode", 0, 1, 0, f_visualmode},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
854 {"wildmenumode", 0, 0, 0, f_wildmenumode},
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
855 {"win_execute", 2, 3, FEARG_2, f_win_execute},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
856 {"win_findbuf", 1, 1, FEARG_1, f_win_findbuf},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
857 {"win_getid", 0, 2, FEARG_1, f_win_getid},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
858 {"win_gotoid", 1, 1, FEARG_1, f_win_gotoid},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
859 {"win_id2tabwin", 1, 1, FEARG_1, f_win_id2tabwin},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
860 {"win_id2win", 1, 1, FEARG_1, f_win_id2win},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
861 {"win_screenpos", 1, 1, FEARG_1, f_win_screenpos},
18049
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18035
diff changeset
862 {"win_splitmove", 2, 3, FEARG_1, f_win_splitmove},
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
863 {"winbufnr", 1, 1, FEARG_1, f_winbufnr},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
864 {"wincol", 0, 0, 0, f_wincol},
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
865 {"winheight", 1, 1, FEARG_1, f_winheight},
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
866 {"winlayout", 0, 1, FEARG_1, f_winlayout},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
867 {"winline", 0, 0, 0, f_winline},
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
868 {"winnr", 0, 1, FEARG_1, f_winnr},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
869 {"winrestcmd", 0, 0, 0, f_winrestcmd},
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
870 {"winrestview", 1, 1, FEARG_1, f_winrestview},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
871 {"winsaveview", 0, 0, 0, f_winsaveview},
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
872 {"winwidth", 1, 1, FEARG_1, f_winwidth},
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
873 {"wordcount", 0, 0, 0, f_wordcount},
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
874 {"writefile", 2, 3, FEARG_1, f_writefile},
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
875 {"xor", 2, 2, FEARG_1, f_xor},
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
876 };
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
877
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
878 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
879 * 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
880 * or user defined function names.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
881 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
882 char_u *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
883 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
884 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
885 static int intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
886 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
887
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
888 if (idx == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
889 intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
890 if (intidx < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
891 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
892 name = get_user_func_name(xp, idx);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
893 if (name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
894 return name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
895 }
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
896 if (++intidx < (int)(sizeof(global_functions) / sizeof(funcentry_T)))
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
897 {
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
898 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
899 STRCAT(IObuff, "(");
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
900 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
901 STRCAT(IObuff, ")");
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
902 return IObuff;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
903 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
904
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
905 return NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
906 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
907
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
908 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
909 * 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
910 * user defined variable or function names.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
911 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
912 char_u *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
913 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
914 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
915 static int intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
916 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
917
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
918 if (idx == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
919 intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
920 if (intidx < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
921 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
922 name = get_function_name(xp, idx);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
923 if (name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
924 return name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
925 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
926 return get_user_var_name(xp, ++intidx);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
927 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
928
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
929 /*
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
930 * Find internal function "name" in table "global_functions".
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
931 * Return index, or -1 if not found
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
932 */
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
933 static int
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
934 find_internal_func(char_u *name)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
935 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
936 int first = 0;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
937 int last;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
938 int cmp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
939 int x;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
940
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
941 last = (int)(sizeof(global_functions) / sizeof(funcentry_T)) - 1;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
942
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
943 // 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
944 while (first <= last)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
945 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
946 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
947 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
948 if (cmp < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
949 last = x - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
950 else if (cmp > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
951 first = x + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
952 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
953 return x;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
954 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
955 return -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
956 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
957
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
958 int
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
959 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
960 {
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
961 return find_internal_func(name) >= 0;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
962 }
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
963
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
964 int
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
965 call_internal_func(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
966 char_u *name,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
967 int argcount,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
968 typval_T *argvars,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
969 typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
970 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
971 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
972
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
973 i = find_internal_func(name);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
974 if (i < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
975 return ERROR_UNKNOWN;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
976 if (argcount < global_functions[i].f_min_argc)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
977 return ERROR_TOOFEW;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
978 if (argcount > global_functions[i].f_max_argc)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
979 return ERROR_TOOMANY;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
980 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
981 global_functions[i].f_func(argvars, rettv);
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
982 return ERROR_NONE;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
983 }
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
984
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
985 /*
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
986 * 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
987 */
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
988 int
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
989 call_internal_method(
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
990 char_u *name,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
991 int argcount,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
992 typval_T *argvars,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
993 typval_T *rettv,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
994 typval_T *basetv)
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
995 {
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
996 int i;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
997 int fi;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
998 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
999
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1000 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
1001 if (fi < 0)
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
1002 return ERROR_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
1003 if (global_functions[fi].f_argtype == 0)
1726c2db81bf patch 8.1.1863: confusing error when using a builtin function as method
Bram Moolenaar <Bram@vim.org>
parents: 17728
diff changeset
1004 return ERROR_NOTMETHOD;
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1005 if (argcount + 1 < global_functions[fi].f_min_argc)
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
1006 return ERROR_TOOFEW;
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1007 if (argcount + 1 > global_functions[fi].f_max_argc)
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
1008 return ERROR_TOOMANY;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
1009
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1010 if (global_functions[fi].f_argtype == FEARG_LAST)
17620
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1011 {
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1012 // base value goes last
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1013 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
1014 argv[i] = argvars[i];
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1015 argv[argcount] = *basetv;
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1016 }
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1017 else 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
1018 {
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1019 // 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
1020 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
1021 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
1022 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
1023 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
1024 }
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
1025 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
1026 {
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
1027 // 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
1028 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
1029 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
1030 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
1031 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
1032 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
1033 }
18000
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
1034 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
1035 {
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
1036 // 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
1037 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
1038 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
1039 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
1040 argv[3] = *basetv;
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
1041 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
1042 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
1043 }
17620
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1044 else
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1045 {
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1046 // 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
1047 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
1048 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
1049 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
1050 }
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
1051 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
1052
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1053 global_functions[fi].f_func(argv, rettv);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1054 return ERROR_NONE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1055 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1056
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1057 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1058 * 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
1059 */
18104
e59ff7b5d7a7 patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents: 18094
diff changeset
1060 int
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1061 non_zero_arg(typval_T *argvars)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1062 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1063 return ((argvars[0].v_type == VAR_NUMBER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1064 && argvars[0].vval.v_number != 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1065 || (argvars[0].v_type == VAR_SPECIAL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1066 && argvars[0].vval.v_number == VVAL_TRUE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1067 || (argvars[0].v_type == VAR_STRING
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1068 && argvars[0].vval.v_string != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1069 && *argvars[0].vval.v_string != NUL));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1070 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1071
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1072 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1073 * Get the lnum from the first argument.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1074 * Also accepts ".", "$", etc., but that only works for the current buffer.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1075 * Returns -1 on error.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1076 */
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
1077 linenr_T
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1078 tv_get_lnum(typval_T *argvars)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1079 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1080 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1081
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1082 lnum = (linenr_T)tv_get_number_chk(&argvars[0], NULL);
17956
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1083 if (lnum == 0) // no valid number, try using arg like line()
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1084 {
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1085 int fnum;
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1086 pos_T *fp = var2fpos(&argvars[0], TRUE, &fnum);
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1087
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1088 if (fp != NULL)
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1089 lnum = fp->lnum;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1090 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1091 return lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1092 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1093
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1094 /*
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1095 * Get the lnum from the first argument.
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1096 * Also accepts "$", then "buf" is used.
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1097 * Returns 0 on error.
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1098 */
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
1099 linenr_T
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1100 tv_get_lnum_buf(typval_T *argvars, buf_T *buf)
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1101 {
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1102 if (argvars[0].v_type == VAR_STRING
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1103 && argvars[0].vval.v_string != NULL
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1104 && argvars[0].vval.v_string[0] == '$'
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1105 && buf != NULL)
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1106 return buf->b_ml.ml_line_count;
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1107 return (linenr_T)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
1108 }
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1109
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1110 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1111 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1112 * Get the float value of "argvars[0]" into "f".
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1113 * Returns FAIL when the argument is not a Number or Float.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1114 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1115 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1116 get_float_arg(typval_T *argvars, float_T *f)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1117 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1118 if (argvars[0].v_type == VAR_FLOAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1119 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1120 *f = argvars[0].vval.v_float;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1121 return OK;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1122 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1123 if (argvars[0].v_type == VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1124 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1125 *f = (float_T)argvars[0].vval.v_number;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1126 return OK;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1127 }
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1128 emsg(_("E808: Number or Float required"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1129 return FAIL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1130 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1131
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1132 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1133 * "abs(expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1134 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1135 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1136 f_abs(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1137 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1138 if (argvars[0].v_type == VAR_FLOAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1139 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1140 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1141 rettv->vval.v_float = fabs(argvars[0].vval.v_float);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1142 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1143 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1144 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1145 varnumber_T n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1146 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1147
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1148 n = 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
1149 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1150 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1151 else if (n > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1152 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1153 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1154 rettv->vval.v_number = -n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1155 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1156 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1157
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1158 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1159 * "acos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1160 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1161 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1162 f_acos(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1163 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1164 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1165
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1166 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1167 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1168 rettv->vval.v_float = acos(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1169 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1170 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1171 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1172 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1173
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1174 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1175 * "and(expr, expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1176 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1177 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1178 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
1179 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1180 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
1181 & 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
1182 }
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 14019
diff changeset
1183
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1184 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1185 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1186 * "asin()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1187 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1188 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1189 f_asin(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1190 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1191 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1192
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1193 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1194 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1195 rettv->vval.v_float = asin(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1196 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1197 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1198 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1199
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1200 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1201 * "atan()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1202 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1203 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1204 f_atan(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1205 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1206 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1207
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1208 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1209 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1210 rettv->vval.v_float = atan(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1211 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1212 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1213 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1214
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1215 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1216 * "atan2()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1217 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1218 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1219 f_atan2(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1220 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1221 float_T fx = 0.0, fy = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1222
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1223 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1224 if (get_float_arg(argvars, &fx) == OK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1225 && get_float_arg(&argvars[1], &fy) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1226 rettv->vval.v_float = atan2(fx, fy);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1227 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1228 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1229 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1230 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1231
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1232 /*
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1233 * "balloon_show()" function
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1234 */
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1235 #ifdef FEAT_BEVAL
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1236 static void
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1237 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
1238 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1239 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
1240 if (balloonEval != NULL)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1241 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1242 if (balloonEval->msg == NULL)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1243 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
1244 else
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1245 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
1246 }
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1247 }
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1248
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1249 static void
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1250 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
1251 {
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 11014
diff changeset
1252 if (balloonEval != NULL)
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1253 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1254 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
1255 # ifdef FEAT_GUI
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1256 && !gui.in_use
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1257 # endif
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1258 )
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1259 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1260 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
1261
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1262 // 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
1263 post_balloon(balloonEval, NULL,
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1264 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
1265 }
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1266 else
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1267 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1268 char_u *mesg = tv_get_string_chk(&argvars[0]);
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1269
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1270 if (mesg != NULL)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1271 // 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
1272 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
1273 }
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1274 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1275 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1276
12885
10cb5c3df3f5 patch 8.0.1319: can't build GUI on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
1277 # 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
1278 static void
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1279 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
1280 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1281 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
1282 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1283 char_u *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
1284
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1285 if (msg != NULL)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1286 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1287 pumitem_T *array;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1288 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
1289 int i;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1290
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1291 /* Skip the first and last item, they are always empty. */
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1292 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
1293 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
1294 while (size > 0)
fee03d646e42 patch 8.0.1492: memory leak in balloon_split()
Christian Brabandt <cb@256bit.org>
parents: 13229
diff changeset
1295 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
1296 vim_free(array);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1297 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1298 }
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1299 }
12885
10cb5c3df3f5 patch 8.0.1319: can't build GUI on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
1300 # endif
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1301 #endif
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1302
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1303 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1304 * Get buffer by number or pattern.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1305 */
11846
1c65cad8b967 patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
1306 buf_T *
15355
73b153ed5af8 patch 8.1.0685: get_buf_tv() is named inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 15343
diff changeset
1307 tv_get_buf(typval_T *tv, int curtab_only)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1308 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1309 char_u *name = tv->vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1310 buf_T *buf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1311
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1312 if (tv->v_type == VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1313 return buflist_findnr((int)tv->vval.v_number);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1314 if (tv->v_type != VAR_STRING)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1315 return NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1316 if (name == NULL || *name == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1317 return curbuf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1318 if (name[0] == '$' && name[1] == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1319 return lastbuf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1320
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1321 buf = buflist_find_by_name(name, curtab_only);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1322
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1323 /* If not found, try expanding the name, like done for bufexists(). */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1324 if (buf == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1325 buf = find_buffer(tv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1326
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1327 return buf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1328 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1329
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1330 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1331 * 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
1332 * valid.
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1333 */
16638
4790302965fc patch 8.1.1321: no docs or tests for listener functions
Bram Moolenaar <Bram@vim.org>
parents: 16634
diff changeset
1334 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
1335 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
1336 {
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1337 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
1338
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1339 ++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
1340 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
1341 --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
1342 if (buf == NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1343 semsg(_("E158: Invalid buffer name: %s"), 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
1344 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
1345 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1346
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1347 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1348 * "byte2line(byte)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1349 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1350 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1351 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
1352 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1353 #ifndef FEAT_BYTEOFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1354 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1355 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1356 long boff = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1357
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1358 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
1359 if (boff < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1360 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1361 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1362 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
1363 (linenr_T)0, &boff);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1364 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1365 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1366
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1367 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1368 byteidx(typval_T *argvars, typval_T *rettv, int comp UNUSED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1369 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1370 char_u *t;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1371 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1372 varnumber_T idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1373
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1374 str = 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
1375 idx = 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
1376 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1377 if (str == NULL || idx < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1378 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1379
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1380 t = str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1381 for ( ; idx > 0; idx--)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1382 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1383 if (*t == NUL) /* EOL reached */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1384 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1385 if (enc_utf8 && comp)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1386 t += utf_ptr2len(t);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1387 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1388 t += (*mb_ptr2len)(t);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1389 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1390 rettv->vval.v_number = (varnumber_T)(t - str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1391 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1392
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1393 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1394 * "byteidx()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1395 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1396 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1397 f_byteidx(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1398 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1399 byteidx(argvars, rettv, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1400 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1401
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1402 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1403 * "byteidxcomp()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1404 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1405 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1406 f_byteidxcomp(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1407 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1408 byteidx(argvars, rettv, TRUE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1409 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1410
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1411 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1412 * "call(func, arglist [, dict])" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1413 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1414 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1415 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
1416 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1417 char_u *func;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1418 partial_T *partial = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1419 dict_T *selfdict = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1420
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1421 if (argvars[1].v_type != VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1422 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1423 emsg(_(e_listreq));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1424 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1425 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1426 if (argvars[1].vval.v_list == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1427 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1428
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1429 if (argvars[0].v_type == VAR_FUNC)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1430 func = argvars[0].vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1431 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
1432 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1433 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
1434 func = partial_name(partial);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1435 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1436 else
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1437 func = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1438 if (*func == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1439 return; /* type error or empty name */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1440
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1441 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1442 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1443 if (argvars[2].v_type != VAR_DICT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1444 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1445 emsg(_(e_dictreq));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1446 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1447 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1448 selfdict = argvars[2].vval.v_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1449 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1450
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1451 (void)func_call(func, &argvars[1], partial, selfdict, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1452 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1453
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1454 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1455 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1456 * "ceil({float})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1457 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1458 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1459 f_ceil(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1460 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1461 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1462
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1463 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1464 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1465 rettv->vval.v_float = ceil(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1466 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1467 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1468 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1469 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1470
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1471 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1472 * "changenr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1473 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1474 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1475 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
1476 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1477 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
1478 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1479
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1480 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1481 * "char2nr(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1482 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1483 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1484 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
1485 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1486 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1487 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1488 int utf8 = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1489
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1490 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
1491 utf8 = (int)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
1492
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1493 if (utf8)
15967
ddd82b1c9e9d patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents: 15955
diff changeset
1494 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
1495 else
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1496 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
1497 }
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1498 else
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
1499 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
1500 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1501
17472
dfd87ef822aa patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17377
diff changeset
1502 win_T *
16158
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1503 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
1504 {
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1505 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
1506
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1507 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
1508 {
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1509 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
1510 if (win == NULL)
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1511 {
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1512 emsg(_(e_invalwindow));
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1513 return NULL;
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1514 }
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1515 }
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1516 return win;
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1517 }
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1518
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1519 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1520 * "col(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1521 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1522 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1523 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
1524 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1525 colnr_T col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1526 pos_T *fp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1527 int fnum = curbuf->b_fnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1528
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1529 fp = var2fpos(&argvars[0], FALSE, &fnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1530 if (fp != NULL && fnum == curbuf->b_fnum)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1531 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1532 if (fp->col == MAXCOL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1533 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1534 /* '> can be MAXCOL, get the length of the line then */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1535 if (fp->lnum <= curbuf->b_ml.ml_line_count)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1536 col = (colnr_T)STRLEN(ml_get(fp->lnum)) + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1537 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1538 col = MAXCOL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1539 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1540 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1541 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1542 col = fp->col + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1543 /* col(".") when the cursor is on the NUL at the end of the line
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1544 * because of "coladd" can be seen as an extra column. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1545 if (virtual_active() && fp == &curwin->w_cursor)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1546 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1547 char_u *p = ml_get_cursor();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1548
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1549 if (curwin->w_cursor.coladd >= (colnr_T)chartabsize(p,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1550 curwin->w_virtcol - curwin->w_cursor.coladd))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1551 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1552 int l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1553
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1554 if (*p != NUL && p[(l = (*mb_ptr2len)(p))] == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1555 col += l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1556 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1557 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1558 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1559 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1560 rettv->vval.v_number = col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1561 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1562
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1563 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1564 * "confirm(message, buttons[, default [, type]])" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1565 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1566 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1567 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
1568 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1569 #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
1570 char_u *message;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1571 char_u *buttons = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1572 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1573 char_u buf2[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1574 int def = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1575 int type = VIM_GENERIC;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1576 char_u *typestr;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1577 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1578
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1579 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
1580 if (message == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1581 error = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1582 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1583 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1584 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
1585 if (buttons == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1586 error = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1587 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1588 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1589 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
1590 if (argvars[3].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1591 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1592 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
1593 if (typestr == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1594 error = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1595 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1596 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1597 switch (TOUPPER_ASC(*typestr))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1598 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1599 case 'E': type = VIM_ERROR; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1600 case 'Q': type = VIM_QUESTION; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1601 case 'I': type = VIM_INFO; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1602 case 'W': type = VIM_WARNING; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1603 case 'G': type = VIM_GENERIC; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1604 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1605 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1606 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1607 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1608 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1609
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1610 if (buttons == NULL || *buttons == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1611 buttons = (char_u *)_("&Ok");
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1612
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1613 if (!error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1614 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
1615 def, NULL, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1616 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1617 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1618
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1619 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1620 * "copy()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1621 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1622 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1623 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
1624 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1625 item_copy(&argvars[0], rettv, FALSE, 0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1626 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1627
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1628 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1629 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1630 * "cos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1631 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1632 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1633 f_cos(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1634 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1635 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1636
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1637 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1638 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1639 rettv->vval.v_float = cos(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1640 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1641 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1642 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1643
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1644 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1645 * "cosh()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1646 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1647 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1648 f_cosh(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1649 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1650 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1651
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1652 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1653 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1654 rettv->vval.v_float = cosh(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1655 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1656 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1657 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1658 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1659
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1660 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1661 * "cursor(lnum, col)" function, or
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1662 * "cursor(list)"
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1663 *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1664 * Moves the cursor to the specified line and column.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1665 * Returns 0 when the position could be set, -1 otherwise.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1666 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1667 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1668 f_cursor(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1669 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1670 long line, col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1671 long coladd = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1672 int set_curswant = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1673
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1674 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1675 if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1676 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1677 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1678 colnr_T curswant = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1679
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1680 if (list2fpos(argvars, &pos, NULL, &curswant) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1681 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1682 emsg(_(e_invarg));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1683 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1684 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1685 line = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1686 col = pos.col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1687 coladd = pos.coladd;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1688 if (curswant >= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1689 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1690 curwin->w_curswant = curswant - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1691 set_curswant = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1692 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1693 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1694 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1695 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1696 line = tv_get_lnum(argvars);
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1697 col = (long)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
1698 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
1699 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
1700 }
6f1c7e9a6393 patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15615
diff changeset
1701 if (line < 0 || col < 0 || coladd < 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1702 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1703 if (line > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1704 curwin->w_cursor.lnum = line;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1705 if (col > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1706 curwin->w_cursor.col = col - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1707 curwin->w_cursor.coladd = coladd;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1708
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1709 /* Make sure the cursor is in a valid position. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1710 check_cursor();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1711 /* Correct cursor for multi-byte character. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1712 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1713 mb_adjust_cursor();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1714
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1715 curwin->w_set_curswant = set_curswant;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1716 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1717 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1718
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
1719 #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
1720 /*
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1721 * "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
1722 */
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1723 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
1724 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
1725 {
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1726 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
1727
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1728 rettv->vval.v_number = FAIL;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1729 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
1730 if (pid == 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1731 emsg(_(e_invarg));
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1732 else
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1733 {
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1734 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
1735
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1736 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
1737 {
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1738 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
1739 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
1740 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
1741 }
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1742 }
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1743 }
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1744 #endif
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1745
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1746 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1747 * "deepcopy()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1748 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1749 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1750 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
1751 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1752 int noref = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1753 int copyID;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1754
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1755 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
1756 noref = (int)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
1757 if (noref < 0 || noref > 1)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1758 emsg(_(e_invarg));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1759 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1760 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1761 copyID = get_copyID();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1762 item_copy(&argvars[0], rettv, TRUE, noref == 0 ? copyID : 0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1763 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1764 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1765
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1766 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1767 * "did_filetype()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1768 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1769 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1770 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
1771 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1772 rettv->vval.v_number = did_filetype;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1773 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1774
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1775 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1776 * "empty({expr})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1777 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1778 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1779 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
1780 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1781 int n = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1782
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1783 switch (argvars[0].v_type)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1784 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1785 case VAR_STRING:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1786 case VAR_FUNC:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1787 n = argvars[0].vval.v_string == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1788 || *argvars[0].vval.v_string == NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1789 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1790 case VAR_PARTIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1791 n = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1792 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1793 case VAR_NUMBER:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1794 n = argvars[0].vval.v_number == 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1795 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1796 case VAR_FLOAT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1797 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1798 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
1799 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1800 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1801 case VAR_LIST:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1802 n = argvars[0].vval.v_list == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1803 || argvars[0].vval.v_list->lv_first == NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1804 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1805 case VAR_DICT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1806 n = argvars[0].vval.v_dict == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1807 || 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
1808 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1809 case VAR_SPECIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1810 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
1811 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1812
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
1813 case VAR_BLOB:
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
1814 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
1815 || 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
1816 break;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
1817
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1818 case VAR_JOB:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1819 #ifdef FEAT_JOB_CHANNEL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1820 n = argvars[0].vval.v_job == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1821 || 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
1822 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1823 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1824 case VAR_CHANNEL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1825 #ifdef FEAT_JOB_CHANNEL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1826 n = argvars[0].vval.v_channel == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1827 || !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
1828 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1829 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1830 case VAR_UNKNOWN:
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10277
diff changeset
1831 internal_error("f_empty(UNKNOWN)");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1832 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1833 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1834 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1835
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1836 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1837 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1838
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1839 /*
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1840 * "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
1841 */
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1842 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
1843 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
1844 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1845 #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
1846 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
1847 char_u *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
1848 # 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
1849 extern wchar_t **_wenviron;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1850 # else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1851 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
1852 # endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1853
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1854 if (rettv_dict_alloc(rettv) != OK)
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1855 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1856
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1857 # 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
1858 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
1859 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1860 # else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1861 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
1862 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1863 # endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1864
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1865 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
1866 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1867 # 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
1868 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
1869
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1870 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
1871 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1872 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
1873 # else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1874 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
1875 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1876 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
1877 # endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1878 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
1879 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1880 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
1881 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1882 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
1883 continue;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1884 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1885 *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
1886 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
1887 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
1888 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1889 #endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1890 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1891
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1892 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1893 * "escape({string}, {chars})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1894 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1895 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1896 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
1897 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1898 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1899
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1900 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
1901 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
1902 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1903 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1904
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1905 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1906 * "eval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1907 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1908 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1909 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
1910 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1911 char_u *s, *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1912
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1913 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
1914 if (s != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1915 s = skipwhite(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1916
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1917 p = s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1918 if (s == NULL || eval1(&s, rettv, TRUE) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1919 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1920 if (p != NULL && !aborting())
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1921 semsg(_(e_invexpr2), p);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1922 need_clr_eos = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1923 rettv->v_type = VAR_NUMBER;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1924 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1925 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1926 else if (*s != NUL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1927 emsg(_(e_trailing));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1928 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1929
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1930 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1931 * "eventhandler()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1932 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1933 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1934 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
1935 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1936 rettv->vval.v_number = vgetc_busy;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1937 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1938
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1939 static garray_T redir_execute_ga;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1940
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1941 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1942 * 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
1943 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1944 void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1945 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
1946 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1947 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1948
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1949 if (value_len == -1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1950 len = (int)STRLEN(value); /* Append the entire string */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1951 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1952 len = value_len; /* Append only "value_len" characters */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1953 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
1954 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1955 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
1956 + redir_execute_ga.ga_len, value, len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1957 redir_execute_ga.ga_len += len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1958 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1959 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1960
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1961 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1962 * Get next line from a list.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1963 * 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
1964 * 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
1965 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1966
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1967 static char_u *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1968 get_list_line(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1969 int c UNUSED,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1970 void *cookie,
17178
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17170
diff changeset
1971 int indent UNUSED,
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17170
diff changeset
1972 int do_concat UNUSED)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1973 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1974 listitem_T **p = (listitem_T **)cookie;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1975 listitem_T *item = *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1976 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1977 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1978
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1979 if (item == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1980 return NULL;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1981 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
1982 *p = item->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1983 return s == NULL ? NULL : vim_strsave(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1984 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1985
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1986 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1987 * "execute()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1988 */
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
1989 void
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1990 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
1991 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1992 char_u *cmd = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1993 list_T *list = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1994 int save_msg_silent = msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1995 int save_emsg_silent = emsg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1996 int save_emsg_noredir = emsg_noredir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1997 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
1998 int save_redir_off = redir_off;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1999 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
2000 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
2001 int echo_output = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2002
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2003 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2004 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2005
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2006 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
2007 {
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2008 list = argvars[arg_off].vval.v_list;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2009 if (list == NULL || list->lv_first == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2010 /* empty list, no commands, empty output */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2011 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2012 ++list->lv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2013 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2014 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2015 {
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2016 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
2017 if (cmd == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2018 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2019 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2020
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2021 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
2022 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2023 char_u buf[NUMBUFLEN];
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2024 char_u *s = tv_get_string_buf_chk(&argvars[arg_off + 1], buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2025
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2026 if (s == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2027 return;
15121
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
2028 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
2029 echo_output = TRUE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2030 if (STRNCMP(s, "silent", 6) == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2031 ++msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2032 if (STRCMP(s, "silent!") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2033 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2034 emsg_silent = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2035 emsg_noredir = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2036 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2037 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2038 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2039 ++msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2040
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2041 if (redir_execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2042 save_ga = redir_execute_ga;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2043 ga_init2(&redir_execute_ga, (int)sizeof(char), 500);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2044 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
2045 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
2046 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
2047 msg_col = 0; // prevent leading spaces
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2048
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2049 if (cmd != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2050 do_cmdline_cmd(cmd);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2051 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2052 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2053 listitem_T *item = list->lv_first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2054
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2055 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
2056 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
2057 --list->lv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2058 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2059
10749
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2060 /* Need to append a NUL to the result. */
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2061 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
2062 {
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2063 ((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
2064 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
2065 }
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2066 else
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2067 {
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2068 ga_clear(&redir_execute_ga);
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2069 rettv->vval.v_string = NULL;
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2070 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2071 msg_silent = save_msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2072 emsg_silent = save_emsg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2073 emsg_noredir = save_emsg_noredir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2074
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2075 redir_execute = save_redir_execute;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2076 if (redir_execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2077 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
2078 redir_off = save_redir_off;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2079
15117
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15062
diff changeset
2080 // "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
2081 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
2082 // 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
2083 // "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
2084 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
2085 else
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
2086 // 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
2087 // 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
2088 msg_col = save_msg_col;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2089 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2090
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2091 /*
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2092 * "execute()" function
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2093 */
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2094 static void
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2095 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
2096 {
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2097 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
2098 }
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2099
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2100 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2101 * "exists()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2102 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2103 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2104 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
2105 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2106 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2107 int n = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2108
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2109 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2110 if (*p == '$') /* environment variable */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2111 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2112 /* first try "normal" environment variables (fast) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2113 if (mch_getenv(p + 1) != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2114 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2115 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2116 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2117 /* try expanding things like $VIM and ${HOME} */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2118 p = expand_env_save(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2119 if (p != NULL && *p != '$')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2120 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2121 vim_free(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2122 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2123 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2124 else if (*p == '&' || *p == '+') /* option */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2125 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2126 n = (get_option_tv(&p, NULL, TRUE) == OK);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2127 if (*skipwhite(p) != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2128 n = FALSE; /* trailing garbage */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2129 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2130 else if (*p == '*') /* internal or user defined function */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2131 {
9717
6226de5f8137 commit https://github.com/vim/vim/commit/b54c3ff3174dbb5dfbfcabdf95200b047beaa644
Christian Brabandt <cb@256bit.org>
parents: 9707
diff changeset
2132 n = function_exists(p + 1, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2133 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2134 else if (*p == ':')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2135 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2136 n = cmd_exists(p + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2137 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2138 else if (*p == '#')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2139 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2140 if (p[1] == '#')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2141 n = autocmd_supported(p + 2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2142 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2143 n = au_exists(p + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2144 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2145 else /* internal variable */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2146 {
13262
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13248
diff changeset
2147 n = var_exists(p);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2148 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2149
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2150 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2151 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2152
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2153 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2154 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2155 * "exp()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2156 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2157 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2158 f_exp(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2159 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2160 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2161
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2162 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2163 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2164 rettv->vval.v_float = exp(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2165 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2166 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2167 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2168 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2169
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2170 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2171 * "expand()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2172 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2173 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2174 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
2175 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2176 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2177 int len;
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
2178 char *errormsg;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2179 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
2180 expand_T xpc;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2181 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2182 char_u *result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2183
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2184 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2185 if (argvars[1].v_type != VAR_UNKNOWN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2186 && 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
2187 && 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
2188 && !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
2189 rettv_list_set(rettv, NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2190
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2191 s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2192 if (*s == '%' || *s == '#' || *s == '<')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2193 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2194 ++emsg_off;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2195 result = eval_vars(s, s, &len, NULL, &errormsg, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2196 --emsg_off;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2197 if (rettv->v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2198 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2199 if (rettv_list_alloc(rettv) != FAIL && result != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2200 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
2201 vim_free(result);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2202 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2203 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2204 rettv->vval.v_string = result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2205 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2206 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2207 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2208 /* When the optional second argument is non-zero, don't remove matches
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2209 * for 'wildignore' and don't put matches for 'suffixes' at the end. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2210 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
2211 && 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
2212 options |= WILD_KEEP_ALL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2213 if (!error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2214 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2215 ExpandInit(&xpc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2216 xpc.xp_context = EXPAND_FILES;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2217 if (p_wic)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2218 options += WILD_ICASE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2219 if (rettv->v_type == VAR_STRING)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2220 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
2221 options, WILD_ALL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2222 else if (rettv_list_alloc(rettv) != FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2223 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2224 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2225
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2226 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
2227 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
2228 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
2229 ExpandCleanup(&xpc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2230 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2231 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2232 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2233 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2234 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2235 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2236
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2237 /*
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
2238 * "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
2239 * 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
2240 */
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2241 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
2242 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
2243 {
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2244 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
2245 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
2246 char *errormsg = 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
2247
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2248 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
2249 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
2250
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2251 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
2252 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
2253 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
2254 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
2255 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
2256 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
2257 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
2258
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2259 expand_filename(&eap, &cmdstr, &errormsg);
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2260 if (errormsg != NULL && *errormsg != NUL)
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2261 emsg(errormsg);
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2262
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2263 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
2264 }
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2265
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2266 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2267 * "feedkeys()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2268 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2269 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2270 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
2271 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2272 int remap = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2273 int insert = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2274 char_u *keys, *flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2275 char_u nbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2276 int typed = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2277 int execute = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2278 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
2279 int lowlevel = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2280 char_u *keys_esc;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2281
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2282 /* This is not allowed in the sandbox. If the commands would still be
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2283 * executed in the sandbox it would be OK, but it probably happens later,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2284 * when "sandbox" is no longer set. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2285 if (check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2286 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2287
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2288 keys = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2289
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2290 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2291 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2292 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
2293 for ( ; *flags != NUL; ++flags)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2294 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2295 switch (*flags)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2296 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2297 case 'n': remap = FALSE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2298 case 'm': remap = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2299 case 't': typed = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2300 case 'i': insert = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2301 case 'x': execute = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2302 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
2303 case 'L': lowlevel = TRUE; break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2304 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2305 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2306 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2307
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2308 if (*keys != NUL || execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2309 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2310 /* Need to escape K_SPECIAL and CSI before putting the string in the
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2311 * typeahead buffer. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2312 keys_esc = vim_strsave_escape_csi(keys);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2313 if (keys_esc != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2314 {
15615
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2315 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
2316 {
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2317 #ifdef USE_INPUT_BUF
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2318 add_to_input_buf(keys, (int)STRLEN(keys));
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2319 #else
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2320 emsg(_("E980: lowlevel input not supported"));
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2321 #endif
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2322 }
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2323 else
15687
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
2324 {
15615
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2325 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
2326 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
2327 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
2328 #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
2329 || timer_busy
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
2330 #endif
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
2331 )
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
2332 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
2333 }
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
2334 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
2335
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2336 if (execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2337 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2338 int save_msg_scroll = msg_scroll;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2339
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2340 /* Avoid a 1 second delay when the keys start Insert mode. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2341 msg_scroll = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2342
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
2343 if (!dangerous)
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
2344 ++ex_normal_busy;
16263
d3377393e3d9 patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16253
diff changeset
2345 exec_normal(TRUE, lowlevel, TRUE);
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
2346 if (!dangerous)
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
2347 --ex_normal_busy;
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
2348
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2349 msg_scroll |= save_msg_scroll;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2350 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2351 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2352 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2353 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2354
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2355 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2356 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2357 * "float2nr({float})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2358 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2359 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2360 f_float2nr(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2361 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2362 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2363
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2364 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2365 {
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11418
diff changeset
2366 if (f <= -VARNUM_MAX + DBL_EPSILON)
10658
77d66e9ac0ab patch 8.0.0219: ubsan reports errors for overflow
Christian Brabandt <cb@256bit.org>
parents: 10640
diff changeset
2367 rettv->vval.v_number = -VARNUM_MAX;
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11418
diff changeset
2368 else if (f >= VARNUM_MAX - DBL_EPSILON)
10658
77d66e9ac0ab patch 8.0.0219: ubsan reports errors for overflow
Christian Brabandt <cb@256bit.org>
parents: 10640
diff changeset
2369 rettv->vval.v_number = VARNUM_MAX;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2370 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2371 rettv->vval.v_number = (varnumber_T)f;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2372 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2373 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2374
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2375 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2376 * "floor({float})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2377 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2378 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2379 f_floor(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2380 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2381 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2382
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2383 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2384 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2385 rettv->vval.v_float = floor(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2386 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2387 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2388 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2389
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2390 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2391 * "fmod()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2392 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2393 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2394 f_fmod(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2395 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2396 float_T fx = 0.0, fy = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2397
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2398 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2399 if (get_float_arg(argvars, &fx) == OK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2400 && get_float_arg(&argvars[1], &fy) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2401 rettv->vval.v_float = fmod(fx, fy);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2402 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2403 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2404 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2405 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2406
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2407 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2408 * "fnameescape({string})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2409 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2410 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2411 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
2412 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2413 rettv->vval.v_string = vim_strsave_fnameescape(
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2414 tv_get_string(&argvars[0]), FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2415 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2416 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2417
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2418 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2419 * "foreground()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2420 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2421 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2422 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
2423 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2424 #ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2425 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
2426 {
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2427 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
2428 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
2429 }
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
2430 #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
2431 #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
2432 win32_set_foreground();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2433 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2434 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2435
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2436 static void
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2437 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
2438 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2439 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2440 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2441 int use_string = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2442 partial_T *arg_pt = NULL;
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2443 char_u *trans_name = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2444
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2445 if (argvars[0].v_type == VAR_FUNC)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2446 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2447 /* function(MyFunc, [arg], dict) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2448 s = argvars[0].vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2449 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2450 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
2451 && argvars[0].vval.v_partial != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2452 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2453 /* function(dict.MyFunc, [arg]) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2454 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
2455 s = partial_name(arg_pt);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2456 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2457 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2458 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2459 /* 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
2460 s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2461 use_string = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2462 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2463
9919
885e3c9c0e10 commit https://github.com/vim/vim/commit/843b884461de1c79a1d2748549776fb13fc94360
Christian Brabandt <cb@256bit.org>
parents: 9904
diff changeset
2464 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
2465 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2466 name = s;
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2467 trans_name = trans_function_name(&name, FALSE,
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2468 TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD | TFN_NO_DEREF, NULL, NULL);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2469 if (*name != NUL)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2470 s = NULL;
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2471 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2472
9919
885e3c9c0e10 commit https://github.com/vim/vim/commit/843b884461de1c79a1d2748549776fb13fc94360
Christian Brabandt <cb@256bit.org>
parents: 9904
diff changeset
2473 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
2474 || (is_funcref && trans_name == NULL))
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
2475 semsg(_(e_invarg2), use_string ? tv_get_string(&argvars[0]) : s);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2476 /* 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
2477 else if (trans_name != NULL && (is_funcref
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2478 ? find_func(trans_name) == NULL
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2479 : !translated_function_exists(trans_name)))
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
2480 semsg(_("E700: Unknown function: %s"), s);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2481 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2482 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2483 int dict_idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2484 int arg_idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2485 list_T *list = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2486
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2487 if (STRNCMP(s, "s:", 2) == 0 || STRNCMP(s, "<SID>", 5) == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2488 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2489 char sid_buf[25];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2490 int off = *s == 's' ? 2 : 5;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2491
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2492 /* Expand s: and <SID> into <SNR>nr_, so that the function can
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2493 * also be called from another script. Using trans_function_name()
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2494 * would also work, but some plugins depend on the name being
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2495 * printable text. */
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14673
diff changeset
2496 sprintf(sid_buf, "<SNR>%ld_", (long)current_sctx.sc_sid);
16782
fc58fee685e2 patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2497 name = alloc(STRLEN(sid_buf) + STRLEN(s + off) + 1);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2498 if (name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2499 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2500 STRCPY(name, sid_buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2501 STRCAT(name, s + off);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2502 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2503 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2504 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2505 name = vim_strsave(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2506
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2507 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2508 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2509 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2510 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2511 /* function(name, [args], dict) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2512 arg_idx = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2513 dict_idx = 2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2514 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2515 else if (argvars[1].v_type == VAR_DICT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2516 /* function(name, dict) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2517 dict_idx = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2518 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2519 /* function(name, [args]) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2520 arg_idx = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2521 if (dict_idx > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2522 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2523 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
2524 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
2525 emsg(_("E922: expected a dict"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2526 vim_free(name);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2527 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2528 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2529 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
2530 dict_idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2531 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2532 if (arg_idx > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2533 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2534 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
2535 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
2536 emsg(_("E923: Second argument of function() must be a list or a dict"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2537 vim_free(name);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2538 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2539 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2540 list = argvars[arg_idx].vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2541 if (list == NULL || list->lv_len == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2542 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
2543 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
2544 {
18687
81d34044450f patch 8.1.2335: error message for function arguments may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 18671
diff changeset
2545 emsg_funcname((char *)e_toomanyarg, s);
18576
e9675870c480 patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
2546 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
2547 goto theend;
e9675870c480 patch 8.1.2282: crash when passing many arguments through a partial
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
2548 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2549 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2550 }
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2551 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
2552 {
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
2553 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
2554
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2555 /* result is a VAR_PARTIAL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2556 if (pt == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2557 vim_free(name);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2558 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2559 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2560 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
2561 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2562 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2563 int i = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2564 int arg_len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2565 int lv_len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2566
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2567 if (arg_pt != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2568 arg_len = arg_pt->pt_argc;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2569 if (list != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2570 lv_len = list->lv_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2571 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
2572 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
2573 if (pt->pt_argv == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2574 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2575 vim_free(pt);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2576 vim_free(name);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2577 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2578 }
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2579 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
2580 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
2581 if (lv_len > 0)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2582 for (li = list->lv_first; li != NULL;
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2583 li = li->li_next)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2584 copy_tv(&li->li_tv, &pt->pt_argv[i++]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2585 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2586
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2587 /* For "function(dict.func, [], dict)" and "func" is a partial
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2588 * use "dict". That is backwards compatible. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2589 if (dict_idx > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2590 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2591 /* The dict is bound explicitly, pt_auto is FALSE. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2592 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
2593 ++pt->pt_dict->dv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2594 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2595 else if (arg_pt != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2596 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2597 /* If the dict was bound automatically the result is also
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2598 * bound automatically. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2599 pt->pt_dict = arg_pt->pt_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2600 pt->pt_auto = arg_pt->pt_auto;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2601 if (pt->pt_dict != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2602 ++pt->pt_dict->dv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2603 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2604
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2605 pt->pt_refcount = 1;
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2606 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
2607 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2608 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
2609 func_ptr_ref(pt->pt_func);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2610 vim_free(name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2611 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2612 else if (is_funcref)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2613 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2614 pt->pt_func = find_func(trans_name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2615 func_ptr_ref(pt->pt_func);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2616 vim_free(name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2617 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2618 else
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2619 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2620 pt->pt_name = name;
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2621 func_ref(name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2622 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2623 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2624 rettv->v_type = VAR_PARTIAL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2625 rettv->vval.v_partial = pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2626 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2627 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2628 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2629 /* result is a VAR_FUNC */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2630 rettv->v_type = VAR_FUNC;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2631 rettv->vval.v_string = name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2632 func_ref(name);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2633 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2634 }
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2635 theend:
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2636 vim_free(trans_name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2637 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2638
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2639 /*
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2640 * "funcref()" function
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2641 */
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2642 static void
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2643 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
2644 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2645 common_function(argvars, rettv, TRUE);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2646 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2647
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2648 /*
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2649 * "function()" function
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2650 */
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2651 static void
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2652 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
2653 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2654 common_function(argvars, rettv, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2655 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2656
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2657 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2658 * "garbagecollect()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2659 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2660 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2661 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
2662 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2663 /* This is postponed until we are back at the toplevel, because we may be
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2664 * using Lists and Dicts internally. E.g.: ":echo [garbagecollect()]". */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2665 want_garbage_collect = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2666
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2667 if (argvars[0].v_type != VAR_UNKNOWN && tv_get_number(&argvars[0]) == 1)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2668 garbage_collect_at_exit = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2669 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2670
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2671 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2672 * "get()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2673 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2674 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2675 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
2676 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2677 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2678 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2679 dictitem_T *di;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2680 dict_T *d;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2681 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
2682 int what_is_dict = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2683
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2684 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
2685 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2686 int error = FALSE;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2687 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
2688
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2689 if (!error)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2690 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2691 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
2692 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
2693 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
2694 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
2695 rettv->vval.v_number = -1;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2696 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
2697 {
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2698 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
2699 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
2700 }
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2701 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2702 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2703 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
2704 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2705 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
2706 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2707 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2708
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2709 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
2710 if (!error && li != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2711 tv = &li->li_tv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2712 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2713 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2714 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
2715 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2716 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
2717 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2718 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
2719 if (di != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2720 tv = &di->di_tv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2721 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2722 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2723 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
2724 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2725 partial_T *pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2726 partial_T fref_pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2727
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2728 if (argvars[0].v_type == VAR_PARTIAL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2729 pt = argvars[0].vval.v_partial;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2730 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2731 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2732 vim_memset(&fref_pt, 0, sizeof(fref_pt));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2733 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
2734 pt = &fref_pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2735 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2736
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2737 if (pt != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2738 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2739 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
2740 char_u *n;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2741
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2742 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
2743 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2744 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
2745 n = partial_name(pt);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2746 if (n == NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2747 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2748 else
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2749 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2750 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
2751 if (rettv->v_type == VAR_FUNC)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2752 func_ref(rettv->vval.v_string);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2753 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2754 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2755 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
2756 {
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
2757 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
2758 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
2759 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
2760 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2761 else if (STRCMP(what, "args") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2762 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2763 rettv->v_type = VAR_LIST;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2764 if (rettv_list_alloc(rettv) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2765 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2766 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2767
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2768 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
2769 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
2770 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2771 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2772 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
2773 semsg(_(e_invarg2), what);
17534
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
2774
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
2775 // 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
2776 // third argument
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
2777 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
2778 return;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2779 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2780 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2781 else
15571
4af72c724093 patch 8.1.0793: incorrect error messages for functions that take a Blob
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
2782 semsg(_(e_listdictblobarg), "get()");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2783
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2784 if (tv == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2785 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2786 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2787 copy_tv(&argvars[2], rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2788 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2789 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2790 copy_tv(tv, rettv);
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
9858
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9850
diff changeset
2793 /*
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2794 * "getchangelist()" function
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2795 */
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2796 static void
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2797 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
2798 {
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2799 #ifdef FEAT_JUMPLIST
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2800 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
2801 int i;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2802 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
2803 dict_T *d;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2804 #endif
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2805
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2806 if (rettv_list_alloc(rettv) != OK)
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2807 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2808
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2809 #ifdef FEAT_JUMPLIST
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2810 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
2811 buf = curbuf;
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2812 else
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2813 {
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2814 (void)tv_get_number(&argvars[0]); // issue errmsg if type error
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2815 ++emsg_off;
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2816 buf = tv_get_buf(&argvars[0], FALSE);
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2817 --emsg_off;
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2818 }
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2819 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
2820 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2821
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2822 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
2823 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
2824 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2825
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2826 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
2827 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2828 /*
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2829 * The current window change list index tracks only the position in the
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2830 * current buffer change list. For other buffers, use the change list
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2831 * length as the current index.
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2832 */
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2833 list_append_number(rettv->vval.v_list,
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2834 (varnumber_T)((buf == curwin->w_buffer)
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2835 ? curwin->w_changelistidx : buf->b_changelistlen));
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2836
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2837 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
2838 {
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2839 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
2840 continue;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2841 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
2842 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2843 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
2844 return;
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
2845 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
2846 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
2847 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
2848 }
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2849 #endif
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2850 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2851
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2852 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2853 * "getcharsearch()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2854 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2855 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2856 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
2857 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2858 if (rettv_dict_alloc(rettv) != FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2859 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2860 dict_T *dict = rettv->vval.v_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2861
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
2862 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
2863 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
2864 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
2865 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2866 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2867
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2868 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2869 * "getcmdwintype()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2870 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2871 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2872 f_getcmdwintype(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2873 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2874 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2875 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2876 #ifdef FEAT_CMDWIN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2877 rettv->vval.v_string = alloc(2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2878 if (rettv->vval.v_string != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2879 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2880 rettv->vval.v_string[0] = cmdwin_type;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2881 rettv->vval.v_string[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2882 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2883 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2884 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2885
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2886 /*
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2887 * "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
2888 */
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2889 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
2890 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
2891 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2892 int mustfree = FALSE;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2893 char_u *p = vim_getenv(tv_get_string(&argvars[0]), &mustfree);
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2894
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2895 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
2896 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2897 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
2898 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
2899 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2900 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2901 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
2902 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
2903 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
2904 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
2905 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2906
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2907 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2908 * "getfontname()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2909 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2910 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2911 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
2912 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2913 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2914 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2915 #ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2916 if (gui.in_use)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2917 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2918 GuiFont font;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2919 char_u *name = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2920
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2921 if (argvars[0].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2922 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2923 /* Get the "Normal" font. Either the name saved by
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2924 * hl_set_font_name() or from the font ID. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2925 font = gui.norm_font;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2926 name = hl_get_font_name();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2927 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2928 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2929 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2930 name = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2931 if (STRCMP(name, "*") == 0) /* don't use font dialog */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2932 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2933 font = gui_mch_get_font(name, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2934 if (font == NOFONT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2935 return; /* Invalid font name, return empty string. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2936 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2937 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
2938 if (argvars[0].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2939 gui_mch_free_font(font);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2940 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2941 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2942 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2943
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2944 /*
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
2945 * "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
2946 */
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2947 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
2948 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
2949 {
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2950 #ifdef FEAT_JUMPLIST
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2951 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
2952 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
2953 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
2954 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
2955 #endif
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2956
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2957 if (rettv_list_alloc(rettv) != OK)
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2958 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
2959
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2960 #ifdef FEAT_JUMPLIST
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
2961 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
2962 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
2963 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
2964
15788
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
2965 cleanup_jumplist(wp, TRUE);
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
2966
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
2967 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
2968 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
2969 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
2970
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2971 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
2972 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
2973 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
2974
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2975 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
2976 {
13248
5958573d8a72 patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13246
diff changeset
2977 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
2978 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
2979 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
2980 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
2981 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
2982 return;
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
2983 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
2984 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
2985 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
2986 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
2987 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
2988 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
2989 }
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2990 #endif
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2991 }
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2992
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2993 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2994 * "getpid()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2995 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2996 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2997 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
2998 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2999 rettv->vval.v_number = mch_get_pid();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3000 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3001
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3002 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3003 getpos_both(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3004 typval_T *argvars,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3005 typval_T *rettv,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3006 int getcurpos)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3007 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3008 pos_T *fp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3009 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3010 int fnum = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3011
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3012 if (rettv_list_alloc(rettv) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3013 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3014 l = rettv->vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3015 if (getcurpos)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3016 fp = &curwin->w_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3017 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3018 fp = var2fpos(&argvars[0], TRUE, &fnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3019 if (fnum != -1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3020 list_append_number(l, (varnumber_T)fnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3021 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3022 list_append_number(l, (varnumber_T)0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3023 list_append_number(l, (fp != NULL) ? (varnumber_T)fp->lnum
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3024 : (varnumber_T)0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3025 list_append_number(l, (fp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3026 ? (varnumber_T)(fp->col == MAXCOL ? MAXCOL : fp->col + 1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3027 : (varnumber_T)0);
15636
6f1c7e9a6393 patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15615
diff changeset
3028 list_append_number(l, (fp != NULL) ? (varnumber_T)fp->coladd :
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3029 (varnumber_T)0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3030 if (getcurpos)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3031 {
15985
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3032 int save_set_curswant = curwin->w_set_curswant;
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3033 colnr_T save_curswant = curwin->w_curswant;
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3034 colnr_T save_virtcol = curwin->w_virtcol;
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3035
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3036 update_curswant();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3037 list_append_number(l, curwin->w_curswant == MAXCOL ?
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3038 (varnumber_T)MAXCOL : (varnumber_T)curwin->w_curswant + 1);
15985
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3039
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3040 // Do not change "curswant", as it is unexpected that a get
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3041 // function has a side effect.
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3042 if (save_set_curswant)
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3043 {
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3044 curwin->w_set_curswant = save_set_curswant;
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3045 curwin->w_curswant = save_curswant;
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3046 curwin->w_virtcol = save_virtcol;
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3047 curwin->w_valid &= ~VALID_VIRTCOL;
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3048 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3049 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3050 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3051 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3052 rettv->vval.v_number = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3053 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3054
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3055 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3056 * "getcurpos()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3059 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
3060 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3061 getpos_both(argvars, rettv, TRUE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3062 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3063
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 * "getpos(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3066 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3067 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3068 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
3069 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3070 getpos_both(argvars, rettv, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3071 }
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 * "getreg()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3075 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3076 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3077 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
3078 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3079 char_u *strregname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3080 int regname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3081 int arg2 = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3082 int return_list = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3083 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3084
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3085 if (argvars[0].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3086 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3087 strregname = tv_get_string_chk(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3088 error = strregname == NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3089 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3090 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3091 arg2 = (int)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
3092 if (!error && 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
3093 return_list = (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
3094 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3095 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3096 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3097 strregname = get_vim_var_str(VV_REG);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3098
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3099 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3100 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3101
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3102 regname = (strregname == NULL ? '"' : *strregname);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3103 if (regname == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3104 regname = '"';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3105
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3106 if (return_list)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3107 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3108 rettv->v_type = VAR_LIST;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3109 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
3110 (arg2 ? GREG_EXPR_SRC : 0) | GREG_LIST);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3111 if (rettv->vval.v_list == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3112 (void)rettv_list_alloc(rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3113 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3114 ++rettv->vval.v_list->lv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3115 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3116 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3117 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3118 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3119 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
3120 arg2 ? GREG_EXPR_SRC : 0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3121 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3122 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3123
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3124 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3125 * "getregtype()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3126 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3127 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3128 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
3129 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3130 char_u *strregname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3131 int regname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3132 char_u buf[NUMBUFLEN + 2];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3133 long reglen = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3134
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3135 if (argvars[0].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3136 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3137 strregname = tv_get_string_chk(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3138 if (strregname == NULL) /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3139 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3140 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3141 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3142 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3143 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3144 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3145 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3146 /* Default to v:register */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3147 strregname = get_vim_var_str(VV_REG);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3148
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3149 regname = (strregname == NULL ? '"' : *strregname);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3150 if (regname == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3151 regname = '"';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3152
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3153 buf[0] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3154 buf[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3155 switch (get_reg_type(regname, &reglen))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3156 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3157 case MLINE: buf[0] = 'V'; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3158 case MCHAR: buf[0] = 'v'; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3159 case MBLOCK:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3160 buf[0] = Ctrl_V;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3161 sprintf((char *)buf + 1, "%ld", reglen + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3162 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3163 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3164 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3165 rettv->vval.v_string = vim_strsave(buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3166 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3167
9858
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9850
diff changeset
3168 /*
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3169 * "gettagstack()" function
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3170 */
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3171 static void
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3172 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
3173 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3174 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
3175
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3176 if (rettv_dict_alloc(rettv) != OK)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3177 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3178
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3179 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
3180 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3181 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
3182 if (wp == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3183 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3184 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3185
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3186 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
3187 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3188
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3189 /* for VIM_VERSION_ defines */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3190 #include "version.h"
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3191
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3192 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3193 * "has()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3194 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3195 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3196 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
3197 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3198 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3199 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3200 int n = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3201 static char *(has_list[]) =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3202 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3203 #ifdef AMIGA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3204 "amiga",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3205 # ifdef FEAT_ARP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3206 "arp",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3207 # endif
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 #ifdef __BEOS__
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3210 "beos",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3211 #endif
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3212 #if defined(BSD) && !defined(MACOS_X)
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3213 "bsd",
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3214 #endif
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3215 #ifdef hpux
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3216 "hpux",
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3217 #endif
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3218 #ifdef __linux__
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3219 "linux",
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3220 #endif
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12564
diff changeset
3221 #ifdef MACOS_X
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
3222 "mac", /* Mac OS X (and, once, Mac OS Classic) */
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
3223 "osx", /* Mac OS X */
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12564
diff changeset
3224 # ifdef MACOS_X_DARWIN
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
3225 "macunix", /* Mac OS X, with the darwin feature */
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
3226 "osxdarwin", /* synonym for macunix */
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12564
diff changeset
3227 # endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3228 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3229 #ifdef __QNX__
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3230 "qnx",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3231 #endif
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3232 #ifdef SUN_SYSTEM
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3233 "sun",
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3234 #else
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3235 "moon",
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3236 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3237 #ifdef UNIX
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3238 "unix",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3239 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3240 #ifdef VMS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3241 "vms",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3242 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3243 #ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3244 "win32",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3245 #endif
15955
907481b9260f patch 8.1.0983: checking __CYGWIN32__ unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 15890
diff changeset
3246 #if defined(UNIX) && defined(__CYGWIN__)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3247 "win32unix",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3248 #endif
15890
de2c2a378cd1 patch 8.1.0951: using WIN64 even though it is never defined
Bram Moolenaar <Bram@vim.org>
parents: 15868
diff changeset
3249 #ifdef _WIN64
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3250 "win64",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3251 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3252 #ifdef EBCDIC
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3253 "ebcdic",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3254 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3255 #ifndef CASE_INSENSITIVE_FILENAME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3256 "fname_case",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3257 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3258 #ifdef HAVE_ACL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3259 "acl",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3260 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3261 #ifdef FEAT_ARABIC
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3262 "arabic",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3263 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3264 "autocmd",
14399
e7d1bc5ee3b8 patch 8.1.0214: +autochdir feature not reported by has() or :version
Christian Brabandt <cb@256bit.org>
parents: 14393
diff changeset
3265 #ifdef FEAT_AUTOCHDIR
15677
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3266 "autochdir",
14399
e7d1bc5ee3b8 patch 8.1.0214: +autochdir feature not reported by has() or :version
Christian Brabandt <cb@256bit.org>
parents: 14393
diff changeset
3267 #endif
12837
963cdeb42c41 patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
3268 #ifdef FEAT_AUTOSERVERNAME
963cdeb42c41 patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
3269 "autoservername",
963cdeb42c41 patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
3270 #endif
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
3271 #ifdef FEAT_BEVAL_GUI
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3272 "balloon_eval",
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3273 # ifndef FEAT_GUI_MSWIN /* other GUIs always have multiline balloons */
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3274 "balloon_multiline",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3275 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3276 #endif
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
3277 #ifdef FEAT_BEVAL_TERM
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12857
diff changeset
3278 "balloon_eval_term",
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12857
diff changeset
3279 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3280 #if defined(SOME_BUILTIN_TCAPS) || defined(ALL_BUILTIN_TCAPS)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3281 "builtin_terms",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3282 # ifdef ALL_BUILTIN_TCAPS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3283 "all_builtin_terms",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3284 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3285 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3286 #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
3287 || defined(FEAT_GUI_MSWIN) \
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3288 || defined(FEAT_GUI_MOTIF))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3289 "browsefilter",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3290 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3291 #ifdef FEAT_BYTEOFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3292 "byte_offset",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3293 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3294 #ifdef FEAT_JOB_CHANNEL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3295 "channel",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3296 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3297 #ifdef FEAT_CINDENT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3298 "cindent",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3299 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3300 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3301 "clientserver",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3302 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3303 #ifdef FEAT_CLIPBOARD
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3304 "clipboard",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3305 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3306 "cmdline_compl",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3307 "cmdline_hist",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3308 "comments",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3309 #ifdef FEAT_CONCEAL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3310 "conceal",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3311 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3312 #ifdef FEAT_CRYPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3313 "cryptv",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3314 "crypt-blowfish",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3315 "crypt-blowfish2",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3316 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3317 #ifdef FEAT_CSCOPE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3318 "cscope",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3319 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3320 "cursorbind",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3321 #ifdef CURSOR_SHAPE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3322 "cursorshape",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3323 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3324 #ifdef DEBUG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3325 "debug",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3326 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3327 #ifdef FEAT_CON_DIALOG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3328 "dialog_con",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3329 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3330 #ifdef FEAT_GUI_DIALOG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3331 "dialog_gui",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3332 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3333 #ifdef FEAT_DIFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3334 "diff",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3335 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3336 #ifdef FEAT_DIGRAPHS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3337 "digraphs",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3338 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3339 #ifdef FEAT_DIRECTX
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3340 "directx",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3341 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3342 #ifdef FEAT_DND
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3343 "dnd",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3344 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3345 #ifdef FEAT_EMACS_TAGS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3346 "emacs_tags",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3347 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3348 "eval", /* always present, of course! */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3349 "ex_extra", /* graduated feature */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3350 #ifdef FEAT_SEARCH_EXTRA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3351 "extra_search",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3352 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3353 #ifdef FEAT_SEARCHPATH
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3354 "file_in_path",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3355 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3356 #ifdef FEAT_FILTERPIPE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3357 "filterpipe",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3358 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3359 #ifdef FEAT_FIND_ID
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3360 "find_in_path",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3361 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3362 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3363 "float",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3364 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3365 #ifdef FEAT_FOLDING
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3366 "folding",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3367 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3368 #ifdef FEAT_FOOTER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3369 "footer",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3370 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3371 #if !defined(USE_SYSTEM) && defined(UNIX)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3372 "fork",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3373 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3374 #ifdef FEAT_GETTEXT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3375 "gettext",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3376 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3377 #ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3378 "gui",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3379 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3380 #ifdef FEAT_GUI_ATHENA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3381 # ifdef FEAT_GUI_NEXTAW
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3382 "gui_neXtaw",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3383 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3384 "gui_athena",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3385 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3386 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3387 #ifdef FEAT_GUI_GTK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3388 "gui_gtk",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3389 # ifdef USE_GTK3
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3390 "gui_gtk3",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3391 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3392 "gui_gtk2",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3393 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3394 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3395 #ifdef FEAT_GUI_GNOME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3396 "gui_gnome",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3397 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3398 #ifdef FEAT_GUI_MAC
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3399 "gui_mac",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3400 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3401 #ifdef FEAT_GUI_MOTIF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3402 "gui_motif",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3403 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3404 #ifdef FEAT_GUI_PHOTON
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3405 "gui_photon",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3406 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3407 #ifdef FEAT_GUI_MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3408 "gui_win32",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3409 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3410 #if defined(HAVE_ICONV_H) && defined(USE_ICONV)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3411 "iconv",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3412 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3413 "insert_expand",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3414 #ifdef FEAT_JOB_CHANNEL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3415 "job",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3416 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3417 #ifdef FEAT_JUMPLIST
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3418 "jumplist",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3419 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3420 #ifdef FEAT_KEYMAP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3421 "keymap",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3422 #endif
9690
4a7a88404076 commit https://github.com/vim/vim/commit/9532fe7fbe1b14531931e83bd9f8054efdcf7509
Christian Brabandt <cb@256bit.org>
parents: 9672
diff changeset
3423 "lambda", /* always with FEAT_EVAL, since 7.4.2120 with closure */
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3424 #ifdef FEAT_LANGMAP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3425 "langmap",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3426 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3427 #ifdef FEAT_LIBCALL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3428 "libcall",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3429 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3430 #ifdef FEAT_LINEBREAK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3431 "linebreak",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3432 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3433 #ifdef FEAT_LISP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3434 "lispindent",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3435 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3436 "listcmds",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3437 "localmap",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3438 #ifdef FEAT_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3439 # ifndef DYNAMIC_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3440 "lua",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3441 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3442 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3443 #ifdef FEAT_MENU
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3444 "menu",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3445 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3446 #ifdef FEAT_SESSION
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3447 "mksession",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3448 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3449 "modify_fname",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3450 "mouse",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3451 #ifdef FEAT_MOUSESHAPE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3452 "mouseshape",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3453 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3454 #if defined(UNIX) || defined(VMS)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3455 # ifdef FEAT_MOUSE_DEC
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3456 "mouse_dec",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3457 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3458 # ifdef FEAT_MOUSE_GPM
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3459 "mouse_gpm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3460 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3461 # ifdef FEAT_MOUSE_JSB
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3462 "mouse_jsbterm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3463 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3464 # ifdef FEAT_MOUSE_NET
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3465 "mouse_netterm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3466 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3467 # ifdef FEAT_MOUSE_PTERM
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3468 "mouse_pterm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3469 # endif
16058
012f03e583e2 patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15985
diff changeset
3470 # ifdef FEAT_MOUSE_XTERM
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3471 "mouse_sgr",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3472 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3473 # ifdef FEAT_SYSMOUSE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3474 "mouse_sysmouse",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3475 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3476 # ifdef FEAT_MOUSE_URXVT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3477 "mouse_urxvt",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3478 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3479 # ifdef FEAT_MOUSE_XTERM
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3480 "mouse_xterm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3481 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3482 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3483 "multi_byte",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3484 #ifdef FEAT_MBYTE_IME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3485 "multi_byte_ime",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3486 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3487 #ifdef FEAT_MULTI_LANG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3488 "multi_lang",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3489 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3490 #ifdef FEAT_MZSCHEME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3491 #ifndef DYNAMIC_MZSCHEME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3492 "mzscheme",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3493 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3494 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3495 #ifdef FEAT_NUM64
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3496 "num64",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3497 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3498 #ifdef FEAT_OLE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3499 "ole",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3500 #endif
14375
e5d7dd985b53 patch 8.1.0202: :version always shows +packages
Christian Brabandt <cb@256bit.org>
parents: 14368
diff changeset
3501 #ifdef FEAT_EVAL
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3502 "packages",
14375
e5d7dd985b53 patch 8.1.0202: :version always shows +packages
Christian Brabandt <cb@256bit.org>
parents: 14368
diff changeset
3503 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3504 #ifdef FEAT_PATH_EXTRA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3505 "path_extra",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3506 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3507 #ifdef FEAT_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3508 #ifndef DYNAMIC_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3509 "perl",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3510 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3511 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3512 #ifdef FEAT_PERSISTENT_UNDO
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3513 "persistent_undo",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3514 #endif
13123
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3515 #if defined(FEAT_PYTHON)
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3516 "python_compiled",
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3517 # if defined(DYNAMIC_PYTHON)
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3518 "python_dynamic",
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3519 # else
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3520 "python",
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
3521 "pythonx",
13123
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3522 # endif
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3523 #endif
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3524 #if defined(FEAT_PYTHON3)
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3525 "python3_compiled",
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3526 # if defined(DYNAMIC_PYTHON3)
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3527 "python3_dynamic",
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3528 # else
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3529 "python3",
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
3530 "pythonx",
13123
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3531 # endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3532 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3533 #ifdef FEAT_POSTSCRIPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3534 "postscript",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3535 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3536 #ifdef FEAT_PRINTER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3537 "printer",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3538 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3539 #ifdef FEAT_PROFILE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3540 "profile",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3541 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3542 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3543 "reltime",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3544 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3545 #ifdef FEAT_QUICKFIX
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3546 "quickfix",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3547 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3548 #ifdef FEAT_RIGHTLEFT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3549 "rightleft",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3550 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3551 #if defined(FEAT_RUBY) && !defined(DYNAMIC_RUBY)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3552 "ruby",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3553 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3554 "scrollbind",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3555 #ifdef FEAT_CMDL_INFO
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3556 "showcmd",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3557 "cmdline_info",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3558 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3559 #ifdef FEAT_SIGNS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3560 "signs",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3561 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3562 #ifdef FEAT_SMARTINDENT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3563 "smartindent",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3564 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3565 #ifdef STARTUPTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3566 "startuptime",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3567 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3568 #ifdef FEAT_STL_OPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3569 "statusline",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3570 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3571 #ifdef FEAT_NETBEANS_INTG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3572 "netbeans_intg",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3573 #endif
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
3574 #ifdef FEAT_SOUND
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
3575 "sound",
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
3576 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3577 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3578 "spell",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3579 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3580 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3581 "syntax",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3582 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3583 #if defined(USE_SYSTEM) || !defined(UNIX)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3584 "system",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3585 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3586 #ifdef FEAT_TAG_BINS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3587 "tag_binary",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3588 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3589 #ifdef FEAT_TCL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3590 # ifndef DYNAMIC_TCL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3591 "tcl",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3592 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3593 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3594 #ifdef FEAT_TERMGUICOLORS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3595 "termguicolors",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3596 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3597 #if defined(FEAT_TERMINAL) && !defined(MSWIN)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
3598 "terminal",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
3599 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3600 #ifdef TERMINFO
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3601 "terminfo",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3602 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3603 #ifdef FEAT_TERMRESPONSE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3604 "termresponse",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3605 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3606 #ifdef FEAT_TEXTOBJ
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3607 "textobjects",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3608 #endif
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
3609 #ifdef FEAT_TEXT_PROP
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
3610 "textprop",
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
3611 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3612 #ifdef HAVE_TGETENT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3613 "tgetent",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3614 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3615 #ifdef FEAT_TIMERS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3616 "timers",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3617 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3618 #ifdef FEAT_TITLE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3619 "title",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3620 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3621 #ifdef FEAT_TOOLBAR
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3622 "toolbar",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3623 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3624 #if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3625 "unnamedplus",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3626 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3627 "user-commands", /* was accidentally included in 5.4 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3628 "user_commands",
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14161
diff changeset
3629 #ifdef FEAT_VARTABS
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14161
diff changeset
3630 "vartabs",
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14161
diff changeset
3631 #endif
16223
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16213
diff changeset
3632 "vertsplit",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3633 #ifdef FEAT_VIMINFO
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3634 "viminfo",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3635 #endif
16223
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16213
diff changeset
3636 "vimscript-1",
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16213
diff changeset
3637 "vimscript-2",
16370
235a2b941498 patch 8.1.1190: has('vimscript-3') does not work
Bram Moolenaar <Bram@vim.org>
parents: 16362
diff changeset
3638 "vimscript-3",
18086
9d6832a5426f patch 8.1.2038: has('vimscript-4') is always 0
Bram Moolenaar <Bram@vim.org>
parents: 18080
diff changeset
3639 "vimscript-4",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3640 "virtualedit",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3641 "visual",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3642 "visualextra",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3643 "vreplace",
13454
1720b96e53b6 patch 8.0.1601: highlight test fails on Win32
Christian Brabandt <cb@256bit.org>
parents: 13438
diff changeset
3644 #ifdef FEAT_VTP
1720b96e53b6 patch 8.0.1601: highlight test fails on Win32
Christian Brabandt <cb@256bit.org>
parents: 13438
diff changeset
3645 "vtp",
1720b96e53b6 patch 8.0.1601: highlight test fails on Win32
Christian Brabandt <cb@256bit.org>
parents: 13438
diff changeset
3646 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3647 #ifdef FEAT_WILDIGN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3648 "wildignore",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3649 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3650 #ifdef FEAT_WILDMENU
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3651 "wildmenu",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3652 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3653 "windows",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3654 #ifdef FEAT_WAK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3655 "winaltkeys",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3656 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3657 #ifdef FEAT_WRITEBACKUP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3658 "writebackup",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3659 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3660 #ifdef FEAT_XIM
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3661 "xim",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3662 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3663 #ifdef FEAT_XFONTSET
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3664 "xfontset",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3665 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3666 #ifdef FEAT_XPM_W32
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3667 "xpm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3668 "xpm_w32", /* for backward compatibility */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3669 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3670 # if defined(HAVE_XPM)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3671 "xpm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3672 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3673 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3674 #ifdef USE_XSMP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3675 "xsmp",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3676 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3677 #ifdef USE_XSMP_INTERACT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3678 "xsmp_interact",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3679 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3680 #ifdef FEAT_XCLIPBOARD
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3681 "xterm_clipboard",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3682 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3683 #ifdef FEAT_XTERM_SAVE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3684 "xterm_save",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3685 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3686 #if defined(UNIX) && defined(FEAT_X11)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3687 "X11",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3688 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3689 NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3690 };
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3691
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3692 name = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3693 for (i = 0; has_list[i] != NULL; ++i)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3694 if (STRICMP(name, has_list[i]) == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3695 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3696 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3697 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3698 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3699
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3700 if (n == FALSE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3701 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3702 if (STRNICMP(name, "patch", 5) == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3703 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3704 if (name[5] == '-'
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3705 && STRLEN(name) >= 11
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3706 && vim_isdigit(name[6])
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3707 && vim_isdigit(name[8])
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3708 && vim_isdigit(name[10]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3709 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3710 int major = atoi((char *)name + 6);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3711 int minor = atoi((char *)name + 8);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3712
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3713 /* Expect "patch-9.9.01234". */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3714 n = (major < VIM_VERSION_MAJOR
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3715 || (major == VIM_VERSION_MAJOR
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3716 && (minor < VIM_VERSION_MINOR
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3717 || (minor == VIM_VERSION_MINOR
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3718 && has_patch(atoi((char *)name + 10))))));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3719 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3720 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3721 n = has_patch(atoi((char *)name + 5));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3722 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3723 else if (STRICMP(name, "vim_starting") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3724 n = (starting != 0);
10404
65e0537a4560 commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
3725 else if (STRICMP(name, "ttyin") == 0)
65e0537a4560 commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
3726 n = mch_input_isatty();
65e0537a4560 commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
3727 else if (STRICMP(name, "ttyout") == 0)
65e0537a4560 commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
3728 n = stdout_isatty;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3729 else if (STRICMP(name, "multi_byte_encoding") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3730 n = has_mbyte;
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3731 #if defined(FEAT_BEVAL) && defined(FEAT_GUI_MSWIN)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3732 else if (STRICMP(name, "balloon_multiline") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3733 n = multiline_balloon_available();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3734 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3735 #ifdef DYNAMIC_TCL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3736 else if (STRICMP(name, "tcl") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3737 n = tcl_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3738 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3739 #if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3740 else if (STRICMP(name, "iconv") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3741 n = iconv_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3742 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3743 #ifdef DYNAMIC_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3744 else if (STRICMP(name, "lua") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3745 n = lua_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3746 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3747 #ifdef DYNAMIC_MZSCHEME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3748 else if (STRICMP(name, "mzscheme") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3749 n = mzscheme_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3750 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3751 #ifdef DYNAMIC_RUBY
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3752 else if (STRICMP(name, "ruby") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3753 n = ruby_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3754 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3755 #ifdef DYNAMIC_PYTHON
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3756 else if (STRICMP(name, "python") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3757 n = python_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3758 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3759 #ifdef DYNAMIC_PYTHON3
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3760 else if (STRICMP(name, "python3") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3761 n = python3_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3762 #endif
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
3763 #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
3764 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
3765 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
3766 # 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
3767 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
3768 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
3769 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
3770 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
3771 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
3772 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
3773 # 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
3774 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
3775 # 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
3776 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
3777 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
3778 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3779 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3780 #ifdef DYNAMIC_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3781 else if (STRICMP(name, "perl") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3782 n = perl_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3783 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3784 #ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3785 else if (STRICMP(name, "gui_running") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3786 n = (gui.in_use || gui.starting);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3787 # ifdef FEAT_BROWSE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3788 else if (STRICMP(name, "browse") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3789 n = gui.in_use; /* gui_mch_browse() works when GUI is running */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3790 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3791 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3792 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3793 else if (STRICMP(name, "syntax_items") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3794 n = syntax_present(curwin);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3795 #endif
13314
65c3e8259124 patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
3796 #ifdef FEAT_VTP
65c3e8259124 patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents: 13298
diff changeset
3797 else if (STRICMP(name, "vcon") == 0)
14214
68166b841ee9 patch 8.1.0124: has('vcon') returns true even for non-win32 terminal
Christian Brabandt <cb@256bit.org>
parents: 14189
diff changeset
3798 n = is_term_win32() && has_vtp_working();
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3799 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3800 #ifdef FEAT_NETBEANS_INTG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3801 else if (STRICMP(name, "netbeans_enabled") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3802 n = netbeans_active();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3803 #endif
16527
5412fcd03ecb patch 8.1.1267: cannot check if GPM mouse support is working
Bram Moolenaar <Bram@vim.org>
parents: 16517
diff changeset
3804 #ifdef FEAT_MOUSE_GPM
5412fcd03ecb patch 8.1.1267: cannot check if GPM mouse support is working
Bram Moolenaar <Bram@vim.org>
parents: 16517
diff changeset
3805 else if (STRICMP(name, "mouse_gpm_enabled") == 0)
5412fcd03ecb patch 8.1.1267: cannot check if GPM mouse support is working
Bram Moolenaar <Bram@vim.org>
parents: 16517
diff changeset
3806 n = gpm_enabled();
5412fcd03ecb patch 8.1.1267: cannot check if GPM mouse support is working
Bram Moolenaar <Bram@vim.org>
parents: 16517
diff changeset
3807 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3808 #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
3809 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
3810 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
3811 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3812 #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
3813 else if (STRICMP(name, "conpty") == 0)
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
3814 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
3815 #endif
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
3816 #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
3817 else if (STRICMP(name, "clipboard_working") == 0)
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17676
diff changeset
3818 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
3819 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3820 }
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 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3823 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3824
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3825 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3826 * "haslocaldir()" function
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 void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3829 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
3830 {
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
3831 tabpage_T *tp = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3832 win_T *wp = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3833
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
3834 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
3835
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
3836 // 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
3837 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
3838 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
3839 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
3840 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
3841 else
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
3842 rettv->vval.v_number = 0;
9571
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3845 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3846 * "hasmapto()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3849 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
3850 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3851 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3852 char_u *mode;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3853 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3854 int abbr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3855
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3856 name = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3857 if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3858 mode = (char_u *)"nvo";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3859 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3860 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3861 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
3862 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
3863 abbr = (int)tv_get_number(&argvars[2]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3864 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3865
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3866 if (map_to_exists(name, mode, abbr))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3867 rettv->vval.v_number = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3868 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3869 rettv->vval.v_number = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3870 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3871
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3872 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3873 * "highlightID(name)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3874 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3875 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3876 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
3877 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3878 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
3879 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3880
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3881 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3882 * "highlight_exists()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3883 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3884 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3885 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
3886 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3887 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
3888 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3889
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3890 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3891 * "hostname()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3892 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3893 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3894 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
3895 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3896 char_u hostname[256];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3897
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3898 mch_get_host_name(hostname, 256);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3899 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3900 rettv->vval.v_string = vim_strsave(hostname);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3901 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3902
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3903 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3904 * iconv() function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3907 f_iconv(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3908 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3909 char_u buf1[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3910 char_u buf2[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3911 char_u *from, *to, *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3912 vimconv_T vimconv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3913
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3914 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3915 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3916
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3917 str = 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
3918 from = enc_canonize(enc_skip(tv_get_string_buf(&argvars[1], buf1)));
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3919 to = enc_canonize(enc_skip(tv_get_string_buf(&argvars[2], buf2)));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3920 vimconv.vc_type = CONV_NONE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3921 convert_setup(&vimconv, from, to);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3922
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3923 /* If the encodings are equal, no conversion needed. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3924 if (vimconv.vc_type == CONV_NONE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3925 rettv->vval.v_string = vim_strsave(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3926 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3927 rettv->vval.v_string = string_convert(&vimconv, str, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3928
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3929 convert_setup(&vimconv, NULL, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3930 vim_free(from);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3931 vim_free(to);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3932 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3933
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 * "index()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3936 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3937 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3938 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
3939 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3940 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3941 listitem_T *item;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3942 blob_T *b;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3943 long idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3944 int ic = FALSE;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3945 int error = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3946
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3947 rettv->vval.v_number = -1;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3948 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
3949 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3950 typval_T tv;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3951 int start = 0;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3952
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3953 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
3954 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3955 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
3956 if (error)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3957 return;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3958 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3959 b = argvars[0].vval.v_blob;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3960 if (b == NULL)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3961 return;
15468
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3962 if (start < 0)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3963 {
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3964 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
3965 if (start < 0)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3966 start = 0;
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3967 }
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3968
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3969 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
3970 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3971 tv.v_type = VAR_NUMBER;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3972 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
3973 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
3974 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3975 rettv->vval.v_number = idx;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3976 return;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3977 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3978 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3979 return;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3980 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3981 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
3982 {
15571
4af72c724093 patch 8.1.0793: incorrect error messages for functions that take a Blob
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
3983 emsg(_(e_listblobreq));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3984 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3985 }
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3986
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3987 l = argvars[0].vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3988 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3989 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3990 item = l->lv_first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3991 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3992 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3993 /* Start at specified item. Use the cached index that list_find()
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3994 * 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
3995 item = list_find(l, (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
3996 idx = l->lv_idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3997 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
3998 ic = (int)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
3999 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4000 item = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4001 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4002
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4003 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
4004 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
4005 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4006 rettv->vval.v_number = idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4007 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4008 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4009 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4010 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4011
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4012 static int inputsecret_flag = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4013
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4014 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4015 * "input()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4016 * Also handles inputsecret() when inputsecret is set.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4017 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4018 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4019 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
4020 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4021 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
4022 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4023
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4024 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4025 * "inputdialog()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4026 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4027 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4028 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
4029 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4030 #if defined(FEAT_GUI_TEXTDIALOG)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4031 /* Use a GUI dialog if the GUI is running and 'c' is not in 'guioptions' */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4032 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
4033 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4034 char_u *message;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4035 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4036 char_u *defstr = (char_u *)"";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4037
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4038 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
4039 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
4040 && (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
4041 vim_strncpy(IObuff, defstr, IOSIZE - 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4042 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4043 IObuff[0] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4044 if (message != NULL && defstr != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4045 && do_dialog(VIM_QUESTION, NULL, message,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4046 (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
4047 rettv->vval.v_string = vim_strsave(IObuff);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4048 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4049 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4050 if (message != NULL && defstr != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4051 && argvars[1].v_type != VAR_UNKNOWN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4052 && argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4053 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
4054 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
4055 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4056 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4057 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4058 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4059 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4060 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4061 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4062 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
4063 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4064
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4065 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4066 * "inputlist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4067 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4068 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4069 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
4070 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4071 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4072 int selected;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4073 int mouse_used;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4074
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4075 #ifdef NO_CONSOLE_INPUT
11848
f5968ca369b5 patch 8.0.0804: running tests fails when stdin is /dev/null
Christian Brabandt <cb@256bit.org>
parents: 11846
diff changeset
4076 /* While starting up, there is no place to enter text. When running tests
f5968ca369b5 patch 8.0.0804: running tests fails when stdin is /dev/null
Christian Brabandt <cb@256bit.org>
parents: 11846
diff changeset
4077 * with --not-a-term we assume feedkeys() will be used. */
f5968ca369b5 patch 8.0.0804: running tests fails when stdin is /dev/null
Christian Brabandt <cb@256bit.org>
parents: 11846
diff changeset
4078 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
4079 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4080 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4081 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
4082 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
4083 semsg(_(e_listarg), "inputlist()");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4084 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4085 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4086
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4087 msg_start();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4088 msg_row = Rows - 1; /* for when 'cmdheight' > 1 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4089 lines_left = Rows; /* avoid more prompt */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4090 msg_scroll = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4091 msg_clr_eos();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4092
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4093 for (li = argvars[0].vval.v_list->lv_first; li != NULL; li = li->li_next)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4094 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
4095 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
4096 msg_putchar('\n');
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4097 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4098
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4099 /* Ask for choice. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4100 selected = prompt_for_number(&mouse_used);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4101 if (mouse_used)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4102 selected -= lines_left;
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 = selected;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4107 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
4108
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4109 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4110 * "inputrestore()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4111 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4112 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4113 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
4114 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4115 if (ga_userinput.ga_len > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4116 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4117 --ga_userinput.ga_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4118 restore_typeahead((tasave_T *)(ga_userinput.ga_data)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4119 + ga_userinput.ga_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4120 /* default return is zero == OK */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4121 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4122 else if (p_verbose > 1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4123 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
4124 verb_msg(_("called inputrestore() more often than inputsave()"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4125 rettv->vval.v_number = 1; /* Failed */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4126 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4127 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4128
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4129 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4130 * "inputsave()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4131 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4132 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4133 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
4134 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4135 /* Add an entry to the stack of typeahead storage. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4136 if (ga_grow(&ga_userinput, 1) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4137 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4138 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
4139 + ga_userinput.ga_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4140 ++ga_userinput.ga_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4141 /* default return is zero == OK */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4142 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4143 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4144 rettv->vval.v_number = 1; /* Failed */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4145 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4146
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4147 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4148 * "inputsecret()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4149 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4150 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4151 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
4152 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4153 ++cmdline_star;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4154 ++inputsecret_flag;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4155 f_input(argvars, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4156 --cmdline_star;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4157 --inputsecret_flag;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4158 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4159
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4160 /*
18699
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
4161 * "interrupt()" function
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
4162 */
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
4163 static void
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
4164 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
4165 {
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
4166 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
4167 }
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
4168
1febd1aa9930 patch 8.1.2341: not so easy to interrupt a script programatically
Bram Moolenaar <Bram@vim.org>
parents: 18687
diff changeset
4169 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4170 * "invert(expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4171 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4172 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4173 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
4174 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4175 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
4176 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4179 * Return TRUE if typeval "tv" is locked: Either that value is locked itself
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4180 * or it refers to a List or Dictionary that is locked.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4181 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4182 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4183 tv_islocked(typval_T *tv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4184 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4185 return (tv->v_lock & VAR_LOCKED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4186 || (tv->v_type == VAR_LIST
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4187 && tv->vval.v_list != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4188 && (tv->vval.v_list->lv_lock & VAR_LOCKED))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4189 || (tv->v_type == VAR_DICT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4190 && tv->vval.v_dict != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4191 && (tv->vval.v_dict->dv_lock & VAR_LOCKED));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4192 }
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 * "islocked()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4196 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4197 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4198 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
4199 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4200 lval_T lv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4201 char_u *end;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4202 dictitem_T *di;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4203
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4204 rettv->vval.v_number = -1;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4205 end = get_lval(tv_get_string(&argvars[0]), NULL, &lv, FALSE, FALSE,
10912
fd1760f8c215 patch 8.0.0345: islocked('d.changedtick') does not work
Christian Brabandt <cb@256bit.org>
parents: 10889
diff changeset
4206 GLV_NO_AUTOLOAD | GLV_READ_ONLY, FNE_CHECK_START);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4207 if (end != NULL && lv.ll_name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4208 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4209 if (*end != NUL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
4210 emsg(_(e_trailing));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4211 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4212 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4213 if (lv.ll_tv == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4214 {
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
4215 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
4216 if (di != NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4217 {
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
4218 /* Consider a variable locked when:
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
4219 * 1. the variable itself is locked
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
4220 * 2. the value of the variable is locked.
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
4221 * 3. the List or Dict value is locked.
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
4222 */
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
4223 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
4224 || tv_islocked(&di->di_tv));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4225 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4226 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4227 else if (lv.ll_range)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
4228 emsg(_("E786: Range not allowed"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4229 else if (lv.ll_newkey != NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
4230 semsg(_(e_dictkey), lv.ll_newkey);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4231 else if (lv.ll_list != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4232 /* List item. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4233 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
4234 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4235 /* Dictionary item. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4236 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
4237 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4238 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4239
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4240 clear_lval(&lv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4241 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4242
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4243 #if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4244 /*
16213
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4245 * "isinf()" function
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4246 */
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4247 static void
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4248 f_isinf(typval_T *argvars, typval_T *rettv)
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4249 {
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4250 if (argvars[0].v_type == VAR_FLOAT && isinf(argvars[0].vval.v_float))
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4251 rettv->vval.v_number = argvars[0].vval.v_float > 0.0 ? 1 : -1;
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4252 }
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4253
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4254 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4255 * "isnan()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4256 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4257 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4258 f_isnan(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4259 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4260 rettv->vval.v_number = argvars[0].v_type == VAR_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4261 && isnan(argvars[0].vval.v_float);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4262 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4263 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4264
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4265 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4266 * "last_buffer_nr()" function.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4267 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4268 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4269 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
4270 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4271 int n = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4272 buf_T *buf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4273
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9636
diff changeset
4274 FOR_ALL_BUFFERS(buf)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4275 if (n < buf->b_fnum)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4276 n = buf->b_fnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4277
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4278 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4279 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4280
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 * "len()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4285 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
4286 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4287 switch (argvars[0].v_type)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4288 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4289 case VAR_STRING:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4290 case VAR_NUMBER:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4291 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
4292 tv_get_string(&argvars[0]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4293 break;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4294 case VAR_BLOB:
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4295 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
4296 break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4297 case VAR_LIST:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4298 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
4299 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4300 case VAR_DICT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4301 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
4302 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4303 case VAR_UNKNOWN:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4304 case VAR_SPECIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4305 case VAR_FLOAT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4306 case VAR_FUNC:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4307 case VAR_PARTIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4308 case VAR_JOB:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4309 case VAR_CHANNEL:
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
4310 emsg(_("E701: Invalid type for len()"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4311 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4312 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4313 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4314
10620
2198b53b9ffe patch 8.0.0199: compiler warnings for libcall
Christian Brabandt <cb@256bit.org>
parents: 10567
diff changeset
4315 static void
2198b53b9ffe patch 8.0.0199: compiler warnings for libcall
Christian Brabandt <cb@256bit.org>
parents: 10567
diff changeset
4316 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
4317 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4318 #ifdef FEAT_LIBCALL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4319 char_u *string_in;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4320 char_u **string_result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4321 int nr_result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4322 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4323
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4324 rettv->v_type = type;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4325 if (type != VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4326 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4327
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4328 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4329 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4330
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4331 #ifdef FEAT_LIBCALL
10226
7a4fb555c83a commit https://github.com/vim/vim/commit/9af418427652562384744648d7d173a4bfebba95
Christian Brabandt <cb@256bit.org>
parents: 10207
diff changeset
4332 /* 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
4333 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
4334 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4335 string_in = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4336 if (argvars[2].v_type == VAR_STRING)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4337 string_in = argvars[2].vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4338 if (type == VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4339 string_result = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4340 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4341 string_result = &rettv->vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4342 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
4343 argvars[1].vval.v_string,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4344 string_in,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4345 argvars[2].vval.v_number,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4346 string_result,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4347 &nr_result) == OK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4348 && type == VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4349 rettv->vval.v_number = nr_result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4350 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4351 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4352 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4353
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4354 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4355 * "libcall()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4356 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4357 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4358 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
4359 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4360 libcall_common(argvars, rettv, VAR_STRING);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4361 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4362
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4363 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4364 * "libcallnr()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4367 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
4368 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4369 libcall_common(argvars, rettv, VAR_NUMBER);
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4372 /*
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4373 * "line(string, [winid])" function
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4374 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4375 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4376 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
4377 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4378 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
4379 pos_T *fp = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4380 int fnum;
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4381 int id;
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4382 tabpage_T *tp;
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4383 win_T *wp;
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4384 win_T *save_curwin;
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4385 tabpage_T *save_curtab;
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4386
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4387 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
4388 {
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4389 // 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
4390 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
4391 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
4392 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
4393 {
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4394 if (switch_win_noblock(&save_curwin, &save_curtab, wp, tp, TRUE)
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4395 == OK)
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4396 {
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4397 check_cursor();
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4398 fp = var2fpos(&argvars[0], TRUE, &fnum);
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4399 }
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4400 restore_win_noblock(save_curwin, save_curtab, TRUE);
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4401 }
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4402 }
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4403 else
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4404 // use current window
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4405 fp = var2fpos(&argvars[0], TRUE, &fnum);
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4406
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4407 if (fp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4408 lnum = fp->lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4409 rettv->vval.v_number = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4410 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4411
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4412 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4413 * "line2byte(lnum)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4414 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4415 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4416 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
4417 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4418 #ifndef FEAT_BYTEOFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4419 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4420 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4421 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4422
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4423 lnum = tv_get_lnum(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4424 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
4425 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4426 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4427 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
4428 if (rettv->vval.v_number >= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4429 ++rettv->vval.v_number;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4430 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4431 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4432
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4433 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4434 * "localtime()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4435 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4436 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4437 f_localtime(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4438 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4439 rettv->vval.v_number = (varnumber_T)time(NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4440 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4441
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4442 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4443 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4444 * "log()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4445 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4446 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4447 f_log(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4448 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4449 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4450
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4451 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4452 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4453 rettv->vval.v_float = log(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4454 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4455 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4456 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4457
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4458 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4459 * "log10()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4460 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4461 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4462 f_log10(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4463 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4464 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4465
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4466 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4467 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4468 rettv->vval.v_float = log10(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4469 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4470 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4471 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4472 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4473
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4474 #ifdef FEAT_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4475 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4476 * "luaeval()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4479 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
4480 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4481 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4482 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4483
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
4484 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
4485 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
4486
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4487 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
4488 do_luaeval(str, argvars + 1, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4489 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4490 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4491
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4492 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4493 * "maparg()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4494 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4495 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4496 f_maparg(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4497 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4498 get_maparg(argvars, rettv, TRUE);
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4501 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4502 * "mapcheck()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4503 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4504 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4505 f_mapcheck(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4506 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4507 get_maparg(argvars, rettv, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4508 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4509
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4510 typedef enum
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4511 {
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4512 MATCH_END, /* matchend() */
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4513 MATCH_MATCH, /* match() */
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4514 MATCH_STR, /* matchstr() */
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4515 MATCH_LIST, /* matchlist() */
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4516 MATCH_POS /* matchstrpos() */
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4517 } matchtype_T;
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4518
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4519 static void
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4520 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
4521 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4522 char_u *str = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4523 long len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4524 char_u *expr = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4525 char_u *pat;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4526 regmatch_T regmatch;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4527 char_u patbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4528 char_u strbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4529 char_u *save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4530 long start = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4531 long nth = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4532 colnr_T startcol = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4533 int match = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4534 list_T *l = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4535 listitem_T *li = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4536 long idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4537 char_u *tofree = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4538
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4539 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4540 save_cpo = p_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4541 p_cpo = (char_u *)"";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4542
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4543 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
4544 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
4545 {
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4546 /* type MATCH_LIST: return empty list when there are no matches.
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4547 * 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
4548 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4549 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
4550 if (type == MATCH_POS
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4551 && (list_append_string(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4552 (char_u *)"", 0) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4553 || list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4554 (varnumber_T)-1) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4555 || list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4556 (varnumber_T)-1) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4557 || list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4558 (varnumber_T)-1) == FAIL))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4559 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4560 list_free(rettv->vval.v_list);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4561 rettv->vval.v_list = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4562 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4563 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4564 }
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4565 else if (type == MATCH_STR)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4566 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4567 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4568 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4569 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4570
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4571 if (argvars[0].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4572 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4573 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
4574 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4575 li = l->lv_first;
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 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4578 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4579 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
4580 len = (long)STRLEN(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4581 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4582
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4583 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
4584 if (pat == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4585 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4586
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4587 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4588 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4589 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4590
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4591 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
4592 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4593 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4594 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4595 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4596 li = list_find(l, start);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4597 if (li == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4598 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4599 idx = l->lv_idx; /* use the cached index */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4600 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4601 else
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 if (start < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4604 start = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4605 if (start > len)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4606 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4607 /* When "count" argument is there ignore matches before "start",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4608 * otherwise skip part of the string. Differs when pattern is "^"
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4609 * or "\<". */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4610 if (argvars[3].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4611 startcol = start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4612 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4613 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4614 str += start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4615 len -= start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4616 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4617 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4618
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4619 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
4620 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
4621 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4622 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4623 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4624
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4625 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
4626 if (regmatch.regprog != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4627 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4628 regmatch.rm_ic = p_ic;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4629
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4630 for (;;)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4631 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4632 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4633 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4634 if (li == NULL)
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 match = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4637 break;
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 vim_free(tofree);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4640 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
4641 if (str == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4642 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4643 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4644
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4645 match = vim_regexec_nl(&regmatch, str, (colnr_T)startcol);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4646
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4647 if (match && --nth <= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4648 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4649 if (l == NULL && !match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4650 break;
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 /* Advance to just after the match. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4653 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4654 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4655 li = li->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4656 ++idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4657 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4658 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4659 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4660 startcol = (colnr_T)(regmatch.startp[0]
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4661 + (*mb_ptr2len)(regmatch.startp[0]) - str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4662 if (startcol > (colnr_T)len
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4663 || str + startcol <= regmatch.startp[0])
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4664 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4665 match = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4666 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4667 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4668 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4669 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4670
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4671 if (match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4672 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4673 if (type == MATCH_POS)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4674 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4675 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
4676 listitem_T *li2 = li1->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4677 listitem_T *li3 = li2->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4678 listitem_T *li4 = li3->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4679
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4680 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
4681 li1->li_tv.vval.v_string = vim_strnsave(regmatch.startp[0],
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4682 (int)(regmatch.endp[0] - regmatch.startp[0]));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4683 li3->li_tv.vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4684 (varnumber_T)(regmatch.startp[0] - expr);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4685 li4->li_tv.vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4686 (varnumber_T)(regmatch.endp[0] - expr);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4687 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4688 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
4689 }
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4690 else if (type == MATCH_LIST)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4691 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4692 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4693
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4694 /* return list with matched string and submatches */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4695 for (i = 0; i < NSUBEXP; ++i)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4696 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4697 if (regmatch.endp[i] == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4698 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4699 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
4700 (char_u *)"", 0) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4701 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4702 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4703 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
4704 regmatch.startp[i],
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4705 (int)(regmatch.endp[i] - regmatch.startp[i]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4706 == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4707 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4708 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4709 }
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4710 else if (type == MATCH_STR)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4711 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4712 /* return matched string */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4713 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4714 copy_tv(&li->li_tv, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4715 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4716 rettv->vval.v_string = vim_strnsave(regmatch.startp[0],
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4717 (int)(regmatch.endp[0] - regmatch.startp[0]));
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 else if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4720 rettv->vval.v_number = idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4721 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4722 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4723 if (type != MATCH_END)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4724 rettv->vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4725 (varnumber_T)(regmatch.startp[0] - str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4726 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4727 rettv->vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4728 (varnumber_T)(regmatch.endp[0] - str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4729 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
4730 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4731 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4732 vim_regfree(regmatch.regprog);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4733 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4734
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4735 theend:
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4736 if (type == MATCH_POS && l == NULL && rettv->vval.v_list != NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4737 /* matchstrpos() without a list: drop the second item. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4738 listitem_remove(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4739 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
4740 vim_free(tofree);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4741 p_cpo = save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4742 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4743
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 * "match()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4746 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4747 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4748 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
4749 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4750 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
4751 }
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 * "matchend()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4755 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4756 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4757 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
4758 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4759 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
4760 }
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 * "matchlist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4764 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4765 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4766 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
4767 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4768 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
4769 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4772 * "matchstr()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4775 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
4776 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4777 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
4778 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4779
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4780 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4781 * "matchstrpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4782 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4783 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4784 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
4785 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4786 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
4787 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4788
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4789 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4790 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
4791 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4792 varnumber_T n = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4793 varnumber_T i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4794 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4795
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4796 if (argvars[0].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4797 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4798 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4799 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4800
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4801 l = argvars[0].vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4802 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4803 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4804 li = l->lv_first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4805 if (li != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4806 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4807 n = tv_get_number_chk(&li->li_tv, &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4808 for (;;)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4809 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4810 li = li->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4811 if (li == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4812 break;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4813 i = tv_get_number_chk(&li->li_tv, &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4814 if (domax ? i > n : i < n)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4815 n = i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4816 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4817 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4818 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4819 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4820 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
4821 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4822 dict_T *d;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4823 int first = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4824 hashitem_T *hi;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4825 int todo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4826
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4827 d = argvars[0].vval.v_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4828 if (d != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4829 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4830 todo = (int)d->dv_hashtab.ht_used;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4831 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
4832 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4833 if (!HASHITEM_EMPTY(hi))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4834 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4835 --todo;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4836 i = tv_get_number_chk(&HI2DI(hi)->di_tv, &error);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4837 if (first)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4838 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4839 n = i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4840 first = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4841 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4842 else if (domax ? i > n : i < n)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4843 n = i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4844 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4845 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4846 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4847 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4848 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
4849 semsg(_(e_listdictarg), domax ? "max()" : "min()");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4850 rettv->vval.v_number = error ? 0 : n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4851 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4852
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4853 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4854 * "max()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4855 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4856 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4857 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
4858 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4859 max_min(argvars, rettv, TRUE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4860 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4861
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4862 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4863 * "min()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4864 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4865 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4866 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
4867 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4868 max_min(argvars, rettv, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4869 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4870
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4871 #if defined(FEAT_MZSCHEME) || defined(PROTO)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4872 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4873 * "mzeval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4874 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4875 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4876 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
4877 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4878 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4879 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4880
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
4881 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
4882 return;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4883 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
4884 do_mzeval(str, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4885 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4886
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4887 void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4888 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
4889 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4890 typval_T argvars[3];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4891
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4892 argvars[0].v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4893 argvars[0].vval.v_string = name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4894 copy_tv(args, &argvars[1]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4895 argvars[2].v_type = VAR_UNKNOWN;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4896 f_call(argvars, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4897 clear_tv(&argvars[1]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4898 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4899 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4900
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4901 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4902 * "nextnonblank()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4903 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4904 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4905 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
4906 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4907 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4908
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4909 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
4910 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4911 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
4912 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4913 lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4914 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4915 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4916 if (*skipwhite(ml_get(lnum)) != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4917 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4918 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4919 rettv->vval.v_number = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4920 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4921
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4922 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4923 * "nr2char()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4924 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4925 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4926 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
4927 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4928 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4929
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4930 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4931 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4932 int utf8 = 0;
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 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
4935 utf8 = (int)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
4936 if (utf8)
15967
ddd82b1c9e9d patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents: 15955
diff changeset
4937 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
4938 else
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4939 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
4940 }
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4941 else
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4942 {
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4943 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
4944 buf[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4945 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4946 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4947 rettv->vval.v_string = vim_strsave(buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4948 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4949
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4950 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4951 * "or(expr, expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4952 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4953 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4954 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
4955 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4956 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
4957 | 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
4958 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4959
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4960 #ifdef FEAT_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4961 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4962 * "perleval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4963 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4964 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4965 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
4966 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4967 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4968 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4969
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4970 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
4971 do_perleval(str, 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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4974
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4975 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4976 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4977 * "pow()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4978 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4979 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4980 f_pow(typval_T *argvars, typval_T *rettv)
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 float_T fx = 0.0, fy = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4983
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4984 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4985 if (get_float_arg(argvars, &fx) == OK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4986 && get_float_arg(&argvars[1], &fy) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4987 rettv->vval.v_float = pow(fx, fy);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4988 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4989 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4990 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4991 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4992
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4993 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4994 * "prevnonblank()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4995 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4996 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4997 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
4998 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4999 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5000
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5001 lnum = tv_get_lnum(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5002 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
5003 lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5004 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5005 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
5006 --lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5007 rettv->vval.v_number = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5008 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5009
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5010 /* This dummy va_list is here because:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5011 * - passing a NULL pointer doesn't work when va_list isn't a pointer
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5012 * - locally in the function results in a "used before set" warning
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5013 * - using va_start() to initialize it gives "function with fixed args" error */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5014 static va_list ap;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5015
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5016 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5017 * "printf()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5018 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5019 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5020 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
5021 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5022 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5023 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5024 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5025 int saved_did_emsg = did_emsg;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5026 char *fmt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5027
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5028 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5029 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5030
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5031 /* Get the required length, allocate the buffer and do it for real. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5032 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
5033 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
5034 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
5035 if (!did_emsg)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5036 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5037 s = alloc(len + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5038 if (s != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5039 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5040 rettv->vval.v_string = s;
11653
67cf0d45b006 patch 8.0.0709: libvterm cannot use vsnprintf()
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
5041 (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
5042 ap, argvars + 1);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5043 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5044 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5045 did_emsg |= saved_did_emsg;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5046 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5047
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5048 /*
17756
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5049 * "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
5050 */
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5051 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
5052 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
5053 {
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5054 if (rettv_dict_alloc(rettv) != OK)
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5055 return;
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5056 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
5057 }
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5058
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5059 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5060 * "pumvisible()" 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_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
5064 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5065 if (pum_visible())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5066 rettv->vval.v_number = 1;
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 #ifdef FEAT_PYTHON3
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 * "py3eval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5072 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5073 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5074 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
5075 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5076 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5077 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5078
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5079 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
5080 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5081
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5082 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
5083 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
5084
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5085 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
5086 do_py3eval(str, rettv);
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 #endif
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 #ifdef FEAT_PYTHON
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 * "pyeval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5093 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5094 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5095 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
5096 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5097 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5098 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5099
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5100 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
5101 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5102
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5103 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
5104 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
5105
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5106 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
5107 do_pyeval(str, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5108 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5109 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5110
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5111 #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
5112 /*
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5113 * "pyxeval()" function
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5114 */
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5115 static void
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5116 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
5117 {
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5118 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
5119 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5120
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5121 # 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
5122 init_pyxversion();
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5123 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
5124 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
5125 else
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5126 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
5127 # 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
5128 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
5129 # 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
5130 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
5131 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5132 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5133 #endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5134
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5135 /*
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5136 * "rand()" function
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5137 */
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5138 static void
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5139 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
5140 {
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5141 list_T *l = NULL;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5142 UINT32_T x, y, z, w, t;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5143 static int rand_seed_initialized = FALSE;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5144 static UINT32_T xyzw[4] = {123456789, 362436069, 521288629, 88675123};
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5145
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5146 #define SHUFFLE_XORSHIFT128 \
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5147 t = x ^ (x << 11); \
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5148 x = y; y = z; z = w; \
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5149 w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5150
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5151 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
5152 {
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5153 // When argument is not given, return random number initialized
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5154 // statically.
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5155 if (!rand_seed_initialized)
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5156 {
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5157 xyzw[0] = (varnumber_T)time(NULL);
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5158 rand_seed_initialized = TRUE;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5159 }
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5160
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5161 x = xyzw[0];
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5162 y = xyzw[1];
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5163 z = xyzw[2];
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5164 w = xyzw[3];
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5165 SHUFFLE_XORSHIFT128;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5166 xyzw[0] = x;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5167 xyzw[1] = y;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5168 xyzw[2] = z;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5169 xyzw[3] = w;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5170 }
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5171 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
5172 {
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5173 listitem_T *lx, *ly, *lz, *lw;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5174
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5175 l = argvars[0].vval.v_list;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5176 if (list_len(l) != 4)
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5177 goto theend;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5178
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5179 lx = list_find(l, 0L);
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5180 ly = list_find(l, 1L);
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5181 lz = list_find(l, 2L);
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5182 lw = list_find(l, 3L);
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5183 if (lx->li_tv.v_type != VAR_NUMBER) goto theend;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5184 if (ly->li_tv.v_type != VAR_NUMBER) goto theend;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5185 if (lz->li_tv.v_type != VAR_NUMBER) goto theend;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5186 if (lw->li_tv.v_type != VAR_NUMBER) goto theend;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5187 x = (UINT32_T)lx->li_tv.vval.v_number;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5188 y = (UINT32_T)ly->li_tv.vval.v_number;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5189 z = (UINT32_T)lz->li_tv.vval.v_number;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5190 w = (UINT32_T)lw->li_tv.vval.v_number;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5191 SHUFFLE_XORSHIFT128;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5192 lx->li_tv.vval.v_number = (varnumber_T)x;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5193 ly->li_tv.vval.v_number = (varnumber_T)y;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5194 lz->li_tv.vval.v_number = (varnumber_T)z;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5195 lw->li_tv.vval.v_number = (varnumber_T)w;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5196 }
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5197 else
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5198 goto theend;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5199
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5200 rettv->v_type = VAR_NUMBER;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5201 rettv->vval.v_number = (varnumber_T)w;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5202 return;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5203
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5204 theend:
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5205 semsg(_(e_invarg2), tv_get_string(&argvars[0]));
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5206 }
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5207
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
5208 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5209 * "range()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5210 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5211 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5212 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
5213 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5214 varnumber_T start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5215 varnumber_T end;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5216 varnumber_T stride = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5217 varnumber_T i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5218 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5219
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5220 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
5221 if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5222 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5223 end = start - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5224 start = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5225 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5226 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5227 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5228 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
5229 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
5230 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
5231 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5232
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5233 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5234 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5235 if (stride == 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5236 emsg(_("E726: Stride is zero"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5237 else if (stride > 0 ? end + 1 < start : end - 1 > start)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5238 emsg(_("E727: Start past end"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5239 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5240 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5241 if (rettv_list_alloc(rettv) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5242 for (i = start; stride > 0 ? i <= end : i >= end; i += stride)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5243 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
5244 (varnumber_T)i) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5245 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5246 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5247 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5248
14004
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5249 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
5250 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
5251 {
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5252 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
5253
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5254 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
5255 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
5256 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
5257 }
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5258
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5259 /*
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5260 * "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
5261 */
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5262 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
5263 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
5264 {
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5265 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
5266 }
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5267
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5268 /*
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5269 * "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
5270 */
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5271 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
5272 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
5273 {
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5274 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
5275 }
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5276
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5277 #if defined(FEAT_RELTIME)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5278 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5279 * Convert a List to proftime_T.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5280 * Return FAIL when there is something wrong.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5281 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5282 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5283 list2proftime(typval_T *arg, proftime_T *tm)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5284 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5285 long n1, n2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5286 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5287
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5288 if (arg->v_type != VAR_LIST || arg->vval.v_list == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5289 || arg->vval.v_list->lv_len != 2)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5290 return FAIL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5291 n1 = list_find_nr(arg->vval.v_list, 0L, &error);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5292 n2 = list_find_nr(arg->vval.v_list, 1L, &error);
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5293 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5294 tm->HighPart = n1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5295 tm->LowPart = n2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5296 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5297 tm->tv_sec = n1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5298 tm->tv_usec = n2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5299 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5300 return error ? FAIL : OK;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5301 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5302 #endif /* FEAT_RELTIME */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5303
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5304 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5305 * "reltime()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5306 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5307 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5308 f_reltime(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
5309 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5310 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5311 proftime_T res;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5312 proftime_T start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5313
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5314 if (argvars[0].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5315 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5316 /* No arguments: get current time. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5317 profile_start(&res);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5318 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5319 else if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5320 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5321 if (list2proftime(&argvars[0], &res) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5322 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5323 profile_end(&res);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5324 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5325 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5326 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5327 /* Two arguments: compute the difference. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5328 if (list2proftime(&argvars[0], &start) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5329 || list2proftime(&argvars[1], &res) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5330 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5331 profile_sub(&res, &start);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5332 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5333
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5334 if (rettv_list_alloc(rettv) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5335 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5336 long n1, n2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5337
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5338 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5339 n1 = res.HighPart;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5340 n2 = res.LowPart;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5341 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5342 n1 = res.tv_sec;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5343 n2 = res.tv_usec;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5344 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5345 list_append_number(rettv->vval.v_list, (varnumber_T)n1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5346 list_append_number(rettv->vval.v_list, (varnumber_T)n2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5347 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5348 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5349 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5350
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5351 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5352 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5353 * "reltimefloat()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5354 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5355 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5356 f_reltimefloat(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5357 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5358 # ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5359 proftime_T tm;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5360 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5361
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5362 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5363 rettv->vval.v_float = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5364 # ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5365 if (list2proftime(&argvars[0], &tm) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5366 rettv->vval.v_float = profile_float(&tm);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5367 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5368 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5369 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5370
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5371 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5372 * "reltimestr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5373 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5374 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5375 f_reltimestr(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5376 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5377 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5378 proftime_T tm;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5379 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5380
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5381 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5382 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5383 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5384 if (list2proftime(&argvars[0], &tm) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5385 rettv->vval.v_string = vim_strsave((char_u *)profile_msg(&tm));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5386 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5387 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5388
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5389 #if defined(FEAT_CLIENTSERVER) && defined(FEAT_X11)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5390 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5391 make_connection(void)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5392 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5393 if (X_DISPLAY == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5394 # ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5395 && !gui.in_use
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5396 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5397 )
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5398 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5399 x_force_connect = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5400 setup_term_clip();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5401 x_force_connect = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5402 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5403 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5404
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5405 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5406 check_connection(void)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5407 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5408 make_connection();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5409 if (X_DISPLAY == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5410 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5411 emsg(_("E240: No connection to the X server"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5412 return FAIL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5413 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5414 return OK;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5415 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5416 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5417
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5418 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5419 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5420 remote_common(typval_T *argvars, typval_T *rettv, int expr)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5421 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5422 char_u *server_name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5423 char_u *keys;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5424 char_u *r = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5425 char_u buf[NUMBUFLEN];
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5426 int timeout = 0;
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5427 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5428 HWND w;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5429 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5430 Window w;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5431 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5432
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5433 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5434 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5435
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5436 # ifdef FEAT_X11
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5437 if (check_connection() == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5438 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5439 # endif
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5440 if (argvars[2].v_type != VAR_UNKNOWN
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5441 && 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
5442 timeout = tv_get_number(&argvars[3]);
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5443
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5444 server_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
5445 if (server_name == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5446 return; /* type error; errmsg already given */
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5447 keys = tv_get_string_buf(&argvars[1], buf);
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5448 # ifdef MSWIN
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5449 if (serverSendToVim(server_name, keys, &r, &w, expr, timeout, TRUE) < 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5450 # else
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5451 if (serverSendToVim(X_DISPLAY, server_name, keys, &r, &w, expr, timeout,
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5452 0, TRUE) < 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5453 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5454 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5455 if (r != NULL)
12399
de1ae9d8ef57 patch 8.0.1079: memory leak when remote_foreground() fails
Christian Brabandt <cb@256bit.org>
parents: 12389
diff changeset
5456 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5457 emsg((char *)r); // sending worked but evaluation failed
12399
de1ae9d8ef57 patch 8.0.1079: memory leak when remote_foreground() fails
Christian Brabandt <cb@256bit.org>
parents: 12389
diff changeset
5458 vim_free(r);
de1ae9d8ef57 patch 8.0.1079: memory leak when remote_foreground() fails
Christian Brabandt <cb@256bit.org>
parents: 12389
diff changeset
5459 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5460 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5461 semsg(_("E241: Unable to send to %s"), server_name);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5462 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5463 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5464
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5465 rettv->vval.v_string = r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5466
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5467 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5468 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5469 dictitem_T v;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5470 char_u str[30];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5471 char_u *idvar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5472
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5473 idvar = tv_get_string_chk(&argvars[2]);
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5474 if (idvar != NULL && *idvar != NUL)
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5475 {
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5476 sprintf((char *)str, PRINTF_HEX_LONG_U, (long_u)w);
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5477 v.di_tv.v_type = VAR_STRING;
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5478 v.di_tv.vval.v_string = vim_strsave(str);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5479 set_var(idvar, &v.di_tv, FALSE);
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5480 vim_free(v.di_tv.vval.v_string);
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5481 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5482 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5483 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5484 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5485
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5486 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5487 * "remote_expr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5488 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5489 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5490 f_remote_expr(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5491 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5492 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5493 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5494 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5495 remote_common(argvars, rettv, TRUE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5496 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5497 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5498
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5499 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5500 * "remote_foreground()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5501 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5502 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5503 f_remote_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
5504 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5505 #ifdef FEAT_CLIENTSERVER
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5506 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5507 /* On Win32 it's done in this application. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5508 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5509 char_u *server_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
5510
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5511 if (server_name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5512 serverForeground(server_name);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5513 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5514 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5515 /* Send a foreground() expression to the server. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5516 argvars[1].v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5517 argvars[1].vval.v_string = vim_strsave((char_u *)"foreground()");
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5518 argvars[2].v_type = VAR_UNKNOWN;
12399
de1ae9d8ef57 patch 8.0.1079: memory leak when remote_foreground() fails
Christian Brabandt <cb@256bit.org>
parents: 12389
diff changeset
5519 rettv->v_type = VAR_STRING;
de1ae9d8ef57 patch 8.0.1079: memory leak when remote_foreground() fails
Christian Brabandt <cb@256bit.org>
parents: 12389
diff changeset
5520 rettv->vval.v_string = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5521 remote_common(argvars, rettv, TRUE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5522 vim_free(argvars[1].vval.v_string);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5523 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5524 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5525 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5526
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5527 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5528 f_remote_peek(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5529 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5530 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5531 dictitem_T v;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5532 char_u *s = NULL;
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5533 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5534 long_u n = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5535 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5536 char_u *serverid;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5537
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5538 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5539 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5540 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5541 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5542 }
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5543 serverid = tv_get_string_chk(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5544 if (serverid == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5545 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5546 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5547 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5548 }
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5549 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5550 sscanf((const char *)serverid, SCANF_HEX_LONG_U, &n);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5551 if (n == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5552 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5553 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5554 {
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5555 s = serverGetReply((HWND)n, FALSE, FALSE, FALSE, 0);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5556 rettv->vval.v_number = (s != NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5557 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5558 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5559 if (check_connection() == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5560 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5561
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5562 rettv->vval.v_number = serverPeekReply(X_DISPLAY,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5563 serverStrToWin(serverid), &s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5564 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5565
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5566 if (argvars[1].v_type != VAR_UNKNOWN && rettv->vval.v_number > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5567 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5568 char_u *retvar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5569
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5570 v.di_tv.v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5571 v.di_tv.vval.v_string = vim_strsave(s);
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5572 retvar = tv_get_string_chk(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5573 if (retvar != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5574 set_var(retvar, &v.di_tv, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5575 vim_free(v.di_tv.vval.v_string);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5576 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5577 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5578 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5579 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5580 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5581
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5582 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5583 f_remote_read(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5584 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5585 char_u *r = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5586
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5587 #ifdef FEAT_CLIENTSERVER
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5588 char_u *serverid = tv_get_string_chk(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5589
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5590 if (serverid != NULL && !check_restricted() && !check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5591 {
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5592 int timeout = 0;
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5593 # ifdef MSWIN
11215
2e4877acfe0a patch 8.0.0494: build failure with older compiler on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11211
diff changeset
5594 /* The server's HWND is encoded in the 'id' parameter */
2e4877acfe0a patch 8.0.0494: build failure with older compiler on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11211
diff changeset
5595 long_u n = 0;
2e4877acfe0a patch 8.0.0494: build failure with older compiler on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11211
diff changeset
5596 # endif
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5597
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5598 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
5599 timeout = tv_get_number(&argvars[1]);
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5600
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5601 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5602 sscanf((char *)serverid, SCANF_HEX_LONG_U, &n);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5603 if (n != 0)
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5604 r = serverGetReply((HWND)n, FALSE, TRUE, TRUE, timeout);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5605 if (r == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5606 # else
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5607 if (check_connection() == FAIL
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5608 || serverReadReply(X_DISPLAY, serverStrToWin(serverid),
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5609 &r, FALSE, timeout) < 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5610 # endif
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5611 emsg(_("E277: Unable to read a server reply"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5612 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5613 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5614 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5615 rettv->vval.v_string = r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5616 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5617
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5618 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5619 * "remote_send()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5620 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5621 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5622 f_remote_send(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5623 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5624 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5625 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5626 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5627 remote_common(argvars, rettv, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5628 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5629 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5630
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5631 /*
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5632 * "remote_startserver()" function
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5633 */
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5634 static void
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5635 f_remote_startserver(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5636 {
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5637 #ifdef FEAT_CLIENTSERVER
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5638 char_u *server = tv_get_string_chk(&argvars[0]);
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5639
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5640 if (server == NULL)
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5641 return; /* type error; errmsg already given */
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5642 if (serverName != NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5643 emsg(_("E941: already started a server"));
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5644 else
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5645 {
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5646 # ifdef FEAT_X11
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5647 if (check_connection() == OK)
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5648 serverRegisterName(X_DISPLAY, server);
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5649 # else
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5650 serverSetName(server);
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5651 # endif
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5652 }
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5653 #else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5654 emsg(_("E942: +clientserver feature not available"));
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5655 #endif
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5656 }
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5657
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5658 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5659 * "rename({from}, {to})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5660 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5661 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5662 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
5663 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5664 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5665
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5666 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5667 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5668 else
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5669 rettv->vval.v_number = vim_rename(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
5670 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
5671 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5672
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5673 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5674 * "repeat()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5675 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5676 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5677 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
5678 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5679 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5680 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5681 int slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5682 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5683 char_u *r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5684 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5685
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5686 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
5687 if (argvars[0].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5688 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5689 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
5690 while (n-- > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5691 if (list_extend(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5692 argvars[0].vval.v_list, NULL) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5693 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5694 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5695 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5696 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5697 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5698 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5699 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5700
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5701 slen = (int)STRLEN(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5702 len = slen * n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5703 if (len <= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5704 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5705
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5706 r = alloc(len + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5707 if (r != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5708 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5709 for (i = 0; i < n; i++)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5710 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
5711 r[len] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5712 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5713
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5714 rettv->vval.v_string = r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5715 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5716 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5717
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5718 #define SP_NOMOVE 0x01 /* don't move cursor */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5719 #define SP_REPEAT 0x02 /* repeat to find outer pair */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5720 #define SP_RETCOUNT 0x04 /* return matchcount */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5721 #define SP_SETPCMARK 0x08 /* set previous context mark */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5722 #define SP_START 0x10 /* accept match at start position */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5723 #define SP_SUBPAT 0x20 /* return nr of matching sub-pattern */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5724 #define SP_END 0x40 /* leave cursor at end of match */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5725 #define SP_COLUMN 0x80 /* start at cursor column */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5726
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5727 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5728 * Get flags for a search function.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5729 * Possibly sets "p_ws".
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5730 * 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
5731 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5732 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5733 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
5734 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5735 int dir = FORWARD;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5736 char_u *flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5737 char_u nbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5738 int mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5739
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5740 if (varp->v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5741 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5742 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
5743 if (flags == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5744 return 0; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5745 while (*flags != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5746 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5747 switch (*flags)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5748 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5749 case 'b': dir = BACKWARD; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5750 case 'w': p_ws = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5751 case 'W': p_ws = FALSE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5752 default: mask = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5753 if (flagsp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5754 switch (*flags)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5755 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5756 case 'c': mask = SP_START; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5757 case 'e': mask = SP_END; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5758 case 'm': mask = SP_RETCOUNT; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5759 case 'n': mask = SP_NOMOVE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5760 case 'p': mask = SP_SUBPAT; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5761 case 'r': mask = SP_REPEAT; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5762 case 's': mask = SP_SETPCMARK; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5763 case 'z': mask = SP_COLUMN; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5764 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5765 if (mask == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5766 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5767 semsg(_(e_invarg2), flags);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5768 dir = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5769 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5770 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5771 *flagsp |= mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5772 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5773 if (dir == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5774 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5775 ++flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5776 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5777 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5778 return dir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5779 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5780
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5781 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5782 * Shared by search() and searchpos() functions.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5783 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5784 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5785 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
5786 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5787 int flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5788 char_u *pat;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5789 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5790 pos_T save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5791 int save_p_ws = p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5792 int dir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5793 int retval = 0; /* default: FAIL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5794 long lnum_stop = 0;
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
5795 #ifdef FEAT_RELTIME
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5796 proftime_T tm;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5797 long time_limit = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5798 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5799 int options = SEARCH_KEEP;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5800 int subpatnum;
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
5801 searchit_arg_T sia;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5802
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5803 pat = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5804 dir = get_search_arg(&argvars[1], flagsp); /* may set p_ws */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5805 if (dir == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5806 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5807 flags = *flagsp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5808 if (flags & SP_START)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5809 options |= SEARCH_START;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5810 if (flags & SP_END)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5811 options |= SEARCH_END;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5812 if (flags & SP_COLUMN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5813 options |= SEARCH_COL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5814
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5815 /* Optional arguments: line number to stop searching and timeout. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5816 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
5817 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5818 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
5819 if (lnum_stop < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5820 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5821 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5822 if (argvars[3].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5823 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5824 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
5825 if (time_limit < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5826 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5827 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5828 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5829 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5830
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5831 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5832 /* Set the time limit, if there is one. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5833 profile_setlimit(time_limit, &tm);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5834 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5835
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5836 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5837 * 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
5838 * 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
5839 * 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
5840 * 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
5841 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5842 if (((flags & (SP_REPEAT | SP_RETCOUNT)) != 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5843 || ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK)))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5844 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5845 semsg(_(e_invarg2), tv_get_string(&argvars[1]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5846 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5847 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5848
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5849 pos = save_cursor = curwin->w_cursor;
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
5850 vim_memset(&sia, 0, sizeof(sia));
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
5851 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
5852 #ifdef FEAT_RELTIME
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
5853 sia.sa_tm = &tm;
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
5854 #endif
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
5855 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
5856 options, RE_SEARCH, &sia);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5857 if (subpatnum != FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5858 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5859 if (flags & SP_SUBPAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5860 retval = subpatnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5861 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5862 retval = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5863 if (flags & SP_SETPCMARK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5864 setpcmark();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5865 curwin->w_cursor = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5866 if (match_pos != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5867 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5868 /* Store the match cursor position */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5869 match_pos->lnum = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5870 match_pos->col = pos.col + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5871 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5872 /* "/$" will put the cursor after the end of the line, may need to
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5873 * correct that here */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5874 check_cursor();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5875 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5876
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5877 /* If 'n' flag is used: restore cursor position. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5878 if (flags & SP_NOMOVE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5879 curwin->w_cursor = save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5880 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5881 curwin->w_set_curswant = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5882 theend:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5883 p_ws = save_p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5884
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5885 return retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5886 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5887
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5888 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5889
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5890 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5891 * round() is not in C90, use ceil() or floor() instead.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5892 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5893 float_T
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5894 vim_round(float_T f)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5895 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5896 return f > 0 ? floor(f + 0.5) : ceil(f - 0.5);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5897 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5898
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5899 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5900 * "round({float})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5901 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5902 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5903 f_round(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5904 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5905 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5906
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5907 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5908 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5909 rettv->vval.v_float = vim_round(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5910 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5911 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5912 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5913 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5914
16103
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5915 #ifdef FEAT_RUBY
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5916 /*
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5917 * "rubyeval()" function
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5918 */
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5919 static void
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5920 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
5921 {
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5922 char_u *str;
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5923 char_u buf[NUMBUFLEN];
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5924
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5925 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
5926 do_rubyeval(str, rettv);
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5927 }
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5928 #endif
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5929
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5930 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5931 * "screenattr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5932 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5933 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5934 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
5935 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5936 int row;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5937 int col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5938 int c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5939
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5940 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
5941 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
5942 if (row < 0 || row >= screen_Rows
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5943 || col < 0 || col >= screen_Columns)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5944 c = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5945 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5946 c = ScreenAttrs[LineOffset[row] + col];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5947 rettv->vval.v_number = c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5948 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5949
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5950 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5951 * "screenchar()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5952 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5953 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5954 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
5955 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5956 int row;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5957 int col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5958 int off;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5959 int c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5960
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5961 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
5962 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
5963 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
5964 c = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5965 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5966 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5967 off = LineOffset[row] + col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5968 if (enc_utf8 && ScreenLinesUC[off] != 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5969 c = ScreenLinesUC[off];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5970 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5971 c = ScreenLines[off];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5972 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5973 rettv->vval.v_number = c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5974 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5975
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5976 /*
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5977 * "screenchars()" function
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5978 */
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5979 static void
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5980 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
5981 {
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5982 int row;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5983 int col;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5984 int off;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5985 int c;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5986 int i;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5987
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5988 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
5989 return;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5990 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
5991 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
5992 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
5993 return;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5994
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5995 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
5996 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
5997 c = ScreenLinesUC[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5998 else
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
5999 c = ScreenLines[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6000 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
6001
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6002 if (enc_utf8)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6003
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6004 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
6005 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
6006 (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
6007 }
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6008
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6009 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6010 * "screencol()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6011 *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6012 * 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
6013 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6014 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6015 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
6016 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6017 rettv->vval.v_number = screen_screencol() + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6018 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6019
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6020 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6021 * "screenrow()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6022 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6023 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6024 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
6025 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6026 rettv->vval.v_number = screen_screenrow() + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6027 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6028
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6029 /*
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6030 * "screenstring()" function
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6031 */
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6032 static void
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6033 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
6034 {
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6035 int row;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6036 int col;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6037 int off;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6038 int c;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6039 int i;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6040 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
6041 int buflen = 0;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6042
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6043 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
6044 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
6045
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6046 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
6047 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
6048 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
6049 return;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6050
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6051 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
6052 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
6053 c = ScreenLinesUC[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6054 else
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6055 c = ScreenLines[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6056 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
6057
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6058 if (enc_utf8)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6059 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
6060 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
6061
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6062 buf[buflen] = NUL;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6063 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
6064 }
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6065
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6066 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6067 * "search()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6068 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6069 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6070 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
6071 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6072 int flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6073
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6074 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
6075 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6076
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6077 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6078 * "searchdecl()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6079 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6080 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6081 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
6082 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6083 int locally = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6084 int thisblock = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6085 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6086 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6087
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6088 rettv->vval.v_number = 1; /* default: FAIL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6089
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6090 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
6091 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6092 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6093 locally = (int)tv_get_number_chk(&argvars[1], &error) == 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6094 if (!error && 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
6095 thisblock = (int)tv_get_number_chk(&argvars[2], &error) != 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6096 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6097 if (!error && name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6098 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
6099 locally, thisblock, SEARCH_KEEP) == FAIL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6100 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6101
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6102 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6103 * Used by searchpair() and searchpairpos()
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6104 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6105 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6106 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
6107 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6108 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
6109 typval_T *skip;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6110 int save_p_ws = p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6111 int dir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6112 int flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6113 char_u nbuf1[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6114 char_u nbuf2[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6115 int retval = 0; /* default: FAIL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6116 long lnum_stop = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6117 long time_limit = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6118
14189
0181a2cad0a1 patch 8.1.0112: no error when using bad arguments with searchpair()
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
6119 /* Get the three pattern arguments: start, middle, end. Will result in an
0181a2cad0a1 patch 8.1.0112: no error when using bad arguments with searchpair()
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
6120 * 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
6121 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
6122 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
6123 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
6124 if (spat == NULL || mpat == NULL || epat == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6125 goto theend; /* type error */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6126
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6127 /* Handle the optional fourth argument: flags */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6128 dir = get_search_arg(&argvars[3], &flags); /* may set p_ws */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6129 if (dir == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6130 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6131
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6132 /* Don't accept SP_END or SP_SUBPAT.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6133 * Only one of the SP_NOMOVE or SP_SETPCMARK flags can be set.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6134 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6135 if ((flags & (SP_END | SP_SUBPAT)) != 0
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6136 || ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK)))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6137 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6138 semsg(_(e_invarg2), tv_get_string(&argvars[3]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6139 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6140 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6141
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6142 /* Using 'r' implies 'W', otherwise it doesn't work. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6143 if (flags & SP_REPEAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6144 p_ws = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6145
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6146 /* Optional fifth argument: skip expression */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6147 if (argvars[3].v_type == VAR_UNKNOWN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6148 || 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
6149 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
6150 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
6151 {
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6152 skip = &argvars[4];
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6153 if (skip->v_type != VAR_FUNC && skip->v_type != VAR_PARTIAL
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6154 && skip->v_type != VAR_STRING)
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6155 {
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6156 /* Type error */
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6157 semsg(_(e_invarg2), tv_get_string(&argvars[4]));
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
6158 goto theend;
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6159 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6160 if (argvars[5].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6161 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6162 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
6163 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
6164 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6165 semsg(_(e_invarg2), tv_get_string(&argvars[5]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6166 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
6167 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6168 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6169 if (argvars[6].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6170 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6171 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
6172 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
6173 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6174 semsg(_(e_invarg2), tv_get_string(&argvars[6]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6175 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
6176 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6177 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6178 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6179 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6180 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6181
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6182 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
6183 match_pos, lnum_stop, time_limit);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6184
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6185 theend:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6186 p_ws = save_p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6187
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6188 return retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6189 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6190
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6191 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6192 * "searchpair()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6193 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6194 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6195 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
6196 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6197 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
6198 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6199
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6200 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6201 * "searchpairpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6202 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6203 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6204 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
6205 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6206 pos_T match_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6207 int lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6208 int col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6209
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6210 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6211 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6212
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6213 if (searchpair_cmn(argvars, &match_pos) > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6214 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6215 lnum = match_pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6216 col = match_pos.col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6217 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6218
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6219 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
6220 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
6221 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6222
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6223 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6224 * Search for a start/middle/end thing.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6225 * 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
6226 * Returns 0 or -1 for no match,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6227 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6228 long
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6229 do_searchpair(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6230 char_u *spat, /* start pattern */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6231 char_u *mpat, /* middle pattern */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6232 char_u *epat, /* end pattern */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6233 int dir, /* BACKWARD or FORWARD */
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
6234 typval_T *skip, /* skip expression */
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6235 int flags, /* SP_SETPCMARK and other SP_ values */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6236 pos_T *match_pos,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6237 linenr_T lnum_stop, /* stop at this line if not zero */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6238 long time_limit UNUSED) /* stop after this many msec */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6239 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6240 char_u *save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6241 char_u *pat, *pat2 = NULL, *pat3 = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6242 long retval = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6243 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6244 pos_T firstpos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6245 pos_T foundpos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6246 pos_T save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6247 pos_T save_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6248 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6249 int r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6250 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
6251 int use_skip = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6252 int err;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6253 int options = SEARCH_KEEP;
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6254 #ifdef FEAT_RELTIME
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6255 proftime_T tm;
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6256 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6257
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6258 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6259 save_cpo = p_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6260 p_cpo = empty_option;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6261
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6262 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6263 /* Set the time limit, if there is one. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6264 profile_setlimit(time_limit, &tm);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6265 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6266
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6267 /* Make two search patterns: start/end (pat2, for in nested pairs) and
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6268 * 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
6269 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
6270 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
6271 if (pat2 == NULL || pat3 == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6272 goto theend;
10514
1435e45ee6fa commit https://github.com/vim/vim/commit/6e450a57541676036203a72d40b2e604e938371e
Christian Brabandt <cb@256bit.org>
parents: 10501
diff changeset
6273 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
6274 if (*mpat == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6275 STRCPY(pat3, pat2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6276 else
10514
1435e45ee6fa commit https://github.com/vim/vim/commit/6e450a57541676036203a72d40b2e604e938371e
Christian Brabandt <cb@256bit.org>
parents: 10501
diff changeset
6277 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
6278 spat, epat, mpat);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6279 if (flags & SP_START)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6280 options |= SEARCH_START;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6281
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
6282 if (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
6283 {
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6284 /* Empty string means to not use the skip expression. */
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6285 if (skip->v_type == VAR_STRING || skip->v_type == VAR_FUNC)
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6286 use_skip = skip->vval.v_string != 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
6287 && *skip->vval.v_string != NUL;
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6288 }
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6289
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6290 save_cursor = curwin->w_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6291 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
6292 CLEAR_POS(&firstpos);
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11105
diff changeset
6293 CLEAR_POS(&foundpos);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6294 pat = pat3;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6295 for (;;)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6296 {
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6297 searchit_arg_T sia;
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6298
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6299 vim_memset(&sia, 0, sizeof(sia));
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6300 sia.sa_stop_lnum = lnum_stop;
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6301 #ifdef FEAT_RELTIME
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6302 sia.sa_tm = &tm;
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6303 #endif
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
6304 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
6305 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
6306 if (n == FAIL || (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos)))
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6307 /* didn't find it or found the first match again: FAIL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6308 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6309
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6310 if (firstpos.lnum == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6311 firstpos = pos;
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11105
diff changeset
6312 if (EQUAL_POS(pos, foundpos))
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6313 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6314 /* Found the same position again. Can happen with a pattern that
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6315 * has "\zs" at the end and searching backwards. Advance one
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6316 * character and try again. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6317 if (dir == BACKWARD)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6318 decl(&pos);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6319 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6320 incl(&pos);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6321 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6322 foundpos = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6323
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6324 /* clear the start flag to avoid getting stuck here */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6325 options &= ~SEARCH_START;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6326
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6327 /* 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
6328 if (use_skip)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6329 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6330 save_pos = curwin->w_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6331 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
6332 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
6333 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
6334 curwin->w_cursor = save_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6335 if (err)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6336 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6337 /* Evaluating {skip} caused an error, break here. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6338 curwin->w_cursor = save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6339 retval = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6340 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6341 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6342 if (r)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6343 continue;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6344 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6345
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6346 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
6347 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6348 /* Found end when searching backwards or start when searching
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6349 * forward: nested pair. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6350 ++nest;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6351 pat = pat2; /* nested, don't search for middle */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6352 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6353 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6354 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6355 /* Found end when searching forward or start when searching
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6356 * backward: end of (nested) pair; or found middle in outer pair. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6357 if (--nest == 1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6358 pat = pat3; /* outer level, search for middle */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6359 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6360
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6361 if (nest == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6362 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6363 /* Found the match: return matchcount or line number. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6364 if (flags & SP_RETCOUNT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6365 ++retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6366 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6367 retval = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6368 if (flags & SP_SETPCMARK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6369 setpcmark();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6370 curwin->w_cursor = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6371 if (!(flags & SP_REPEAT))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6372 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6373 nest = 1; /* search for next unmatched */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6374 }
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6377 if (match_pos != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6378 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6379 /* Store the match cursor position */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6380 match_pos->lnum = curwin->w_cursor.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6381 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
6382 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6383
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6384 /* If 'n' flag is used or search failed: restore cursor position. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6385 if ((flags & SP_NOMOVE) || retval == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6386 curwin->w_cursor = save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6387
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6388 theend:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6389 vim_free(pat2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6390 vim_free(pat3);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6391 if (p_cpo == empty_option)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6392 p_cpo = save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6393 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6394 /* Darn, evaluating the {skip} expression changed the value. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6395 free_string_option(save_cpo);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6396
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6397 return retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6398 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6399
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6400 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6401 * "searchpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6402 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6403 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6404 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
6405 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6406 pos_T match_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6407 int lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6408 int col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6409 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6410 int flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6411
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6412 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6413 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6414
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6415 n = search_cmn(argvars, &match_pos, &flags);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6416 if (n > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6417 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6418 lnum = match_pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6419 col = match_pos.col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6420 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6421
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6422 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
6423 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
6424 if (flags & SP_SUBPAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6425 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
6426 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6427
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6428 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6429 f_server2client(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6430 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6431 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6432 char_u buf[NUMBUFLEN];
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6433 char_u *server = 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
6434 char_u *reply = 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
6435
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6436 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6437 if (server == NULL || reply == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6438 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6439 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6440 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6441 # ifdef FEAT_X11
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6442 if (check_connection() == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6443 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6444 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6445
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6446 if (serverSendReply(server, reply) < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6447 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6448 emsg(_("E258: Unable to send to client"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6449 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6450 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6451 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6452 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6453 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6454 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6455 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6456
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6457 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6458 f_serverlist(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6459 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6460 char_u *r = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6461
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6462 #ifdef FEAT_CLIENTSERVER
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
6463 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6464 r = serverGetVimNames();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6465 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6466 make_connection();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6467 if (X_DISPLAY != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6468 r = serverGetVimNames(X_DISPLAY);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6469 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6470 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6471 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6472 rettv->vval.v_string = r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6473 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6474
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6475 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6476 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
6477 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6478 dict_T *d;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6479 dictitem_T *di;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6480 char_u *csearch;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6481
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6482 if (argvars[0].v_type != VAR_DICT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6483 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6484 emsg(_(e_dictreq));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6485 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6486 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6487
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6488 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
6489 {
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
6490 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
6491 if (csearch != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6492 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6493 if (enc_utf8)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6494 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6495 int pcc[MAX_MCO];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6496 int c = utfc_ptr2char(csearch, pcc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6497
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6498 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
6499 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6500 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6501 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
6502 csearch, mb_ptr2len(csearch));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6503 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6504
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6505 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
6506 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
6507 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
6508 ? FORWARD : BACKWARD);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6509
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6510 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
6511 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
6512 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
6513 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6514 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6515
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6516 /*
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6517 * "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
6518 */
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6519 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
6520 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
6521 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6522 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
6523 char_u valbuf[NUMBUFLEN];
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6524 char_u *name = tv_get_string_buf(&argvars[0], namebuf);
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6525
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6526 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
6527 && argvars[1].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
6528 vim_unsetenv(name);
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6529 else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6530 vim_setenv(name, tv_get_string_buf(&argvars[1], valbuf));
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6531 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6532
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6533 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6534 * "setfperm({fname}, {mode})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6535 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6536 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6537 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
6538 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6539 char_u *fname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6540 char_u modebuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6541 char_u *mode_str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6542 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6543 int mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6544 int mode = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6545
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6546 rettv->vval.v_number = 0;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6547 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
6548 if (fname == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6549 return;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6550 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
6551 if (mode_str == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6552 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6553 if (STRLEN(mode_str) != 9)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6554 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6555 semsg(_(e_invarg2), mode_str);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6556 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6557 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6558
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6559 mask = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6560 for (i = 8; i >= 0; --i)
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 if (mode_str[i] != '-')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6563 mode |= mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6564 mask = mask << 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6565 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6566 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
6567 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6568
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6569 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6570 * "setpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6571 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6572 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6573 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
6574 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6575 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6576 int fnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6577 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6578 colnr_T curswant = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6579
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6580 rettv->vval.v_number = -1;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6581 name = tv_get_string_chk(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6582 if (name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6583 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6584 if (list2fpos(&argvars[1], &pos, &fnum, &curswant) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6585 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6586 if (--pos.col < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6587 pos.col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6588 if (name[0] == '.' && name[1] == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6589 {
10732
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6590 /* set cursor; "fnum" is ignored */
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6591 curwin->w_cursor = pos;
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6592 if (curswant >= 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6593 {
10732
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6594 curwin->w_curswant = curswant - 1;
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6595 curwin->w_set_curswant = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6596 }
10732
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6597 check_cursor();
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6598 rettv->vval.v_number = 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6599 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6600 else if (name[0] == '\'' && name[1] != NUL && name[2] == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6601 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6602 /* set mark */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6603 if (setmark_pos(name[1], &pos, fnum) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6604 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6605 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6606 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6607 emsg(_(e_invarg));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6608 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6609 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6610 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6611
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6612 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6613 * "setreg()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6614 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6615 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6616 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
6617 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6618 int regname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6619 char_u *strregname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6620 char_u *stropt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6621 char_u *strval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6622 int append;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6623 char_u yank_type;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6624 long block_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6625
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6626 block_len = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6627 yank_type = MAUTO;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6628 append = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6629
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6630 strregname = tv_get_string_chk(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6631 rettv->vval.v_number = 1; /* FAIL is default */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6632
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6633 if (strregname == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6634 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6635 regname = *strregname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6636 if (regname == 0 || regname == '@')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6637 regname = '"';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6638
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6639 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6640 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6641 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
6642 if (stropt == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6643 return; /* type error */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6644 for (; *stropt != NUL; ++stropt)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6645 switch (*stropt)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6646 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6647 case 'a': case 'A': /* append */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6648 append = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6649 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6650 case 'v': case 'c': /* character-wise selection */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6651 yank_type = MCHAR;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6652 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6653 case 'V': case 'l': /* line-wise selection */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6654 yank_type = MLINE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6655 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6656 case 'b': case Ctrl_V: /* block-wise selection */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6657 yank_type = MBLOCK;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6658 if (VIM_ISDIGIT(stropt[1]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6659 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6660 ++stropt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6661 block_len = getdigits(&stropt) - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6662 --stropt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6663 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6664 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6665 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6666 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6667
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6668 if (argvars[1].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6669 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6670 char_u **lstval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6671 char_u **allocval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6672 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6673 char_u **curval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6674 char_u **curallocval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6675 list_T *ll = argvars[1].vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6676 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6677 int len;
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 /* If the list is NULL handle like an empty list. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6680 len = ll == NULL ? 0 : ll->lv_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6681
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6682 /* First half: use for pointers to result lines; second half: use for
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6683 * 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
6684 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
6685 if (lstval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6686 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6687 curval = lstval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6688 allocval = lstval + len + 2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6689 curallocval = allocval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6690
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6691 for (li = ll == NULL ? NULL : ll->lv_first; li != NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6692 li = li->li_next)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6693 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6694 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
6695 if (strval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6696 goto free_lstval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6697 if (strval == buf)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6698 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6699 /* Need to make a copy, next tv_get_string_buf_chk() will
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6700 * overwrite the string. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6701 strval = vim_strsave(buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6702 if (strval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6703 goto free_lstval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6704 *curallocval++ = strval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6705 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6706 *curval++ = strval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6707 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6708 *curval++ = NULL;
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 write_reg_contents_lst(regname, lstval, -1,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6711 append, yank_type, block_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6712 free_lstval:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6713 while (curallocval > allocval)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6714 vim_free(*--curallocval);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6715 vim_free(lstval);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6716 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6717 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6718 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6719 strval = tv_get_string_chk(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6720 if (strval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6721 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6722 write_reg_contents_ex(regname, strval, -1,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6723 append, yank_type, block_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6724 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6725 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6726 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6727
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6728 /*
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6729 * "settagstack()" function
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6730 */
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6731 static void
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6732 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
6733 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6734 static char *e_invact2 = N_("E962: Invalid action: '%s'");
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6735 win_T *wp;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6736 dict_T *d;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6737 int action = 'r';
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6738
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6739 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
6740
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6741 // 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
6742 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
6743 if (wp == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6744 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6745
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6746 // 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
6747 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
6748 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6749 emsg(_(e_dictreq));
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6750 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6751 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6752 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
6753 if (d == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6754 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6755
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6756 // 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
6757 // 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
6758 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
6759 action = 'r';
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6760 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
6761 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6762 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
6763 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
6764 if (actstr == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6765 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6766 if ((*actstr == 'r' || *actstr == 'a') && actstr[1] == NUL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6767 action = *actstr;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6768 else
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6769 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6770 semsg(_(e_invact2), actstr);
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6771 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6772 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6773 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6774 else
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6775 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6776 emsg(_(e_stringreq));
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6777 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6778 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6779
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6780 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
6781 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
6782 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6783
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6784 #ifdef FEAT_CRYPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6785 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6786 * "sha256({string})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6787 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6788 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6789 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
6790 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6791 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6792
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6793 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6794 rettv->vval.v_string = vim_strsave(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6795 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
6796 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6797 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6798 #endif /* FEAT_CRYPT */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6799
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6800 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6801 * "shellescape({string})" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6804 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
6805 {
11484
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11461
diff changeset
6806 int do_special = non_zero_arg(&argvars[1]);
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11461
diff changeset
6807
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6808 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
6809 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
6810 rettv->v_type = VAR_STRING;
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
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 * shiftwidth() function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6815 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6816 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6817 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
6818 {
15062
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6819 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
6820
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6821 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
6822 {
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6823 long col;
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6824
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6825 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
6826 if (col < 0)
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6827 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
6828 #ifdef FEAT_VARTABS
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6829 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
6830 return;
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6831 #endif
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6832 }
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6833
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6834 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
6835 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6836
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6837 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6838 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6839 * "sin()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6840 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6841 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6842 f_sin(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6843 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6844 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6845
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6846 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6847 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6848 rettv->vval.v_float = sin(f);
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 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6851 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6852
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6853 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6854 * "sinh()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6855 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6856 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6857 f_sinh(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6858 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6859 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6860
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6861 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6862 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6863 rettv->vval.v_float = sinh(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6864 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6865 rettv->vval.v_float = 0.0;
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6868
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6869 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6870 * "soundfold({word})" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6873 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
6874 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6875 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6876
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6877 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
6878 s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6879 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6880 rettv->vval.v_string = eval_soundfold(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6881 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6882 rettv->vval.v_string = vim_strsave(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6883 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6884 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6885
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6886 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6887 * "spellbadword()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6888 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6889 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6890 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
6891 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6892 char_u *word = (char_u *)"";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6893 hlf_T attr = HLF_COUNT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6894 int len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6895
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6896 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6897 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6898
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6899 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6900 if (argvars[0].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6901 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6902 /* Find the start and length of the badly spelled word. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6903 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
6904 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
6905 {
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6906 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
6907 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
6908 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6909 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6910 else if (curwin->w_p_spell && *curbuf->b_s.b_p_spl != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6911 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6912 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
6913 int capcol = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6914
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6915 if (str != NULL)
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 /* Check the argument for spelling. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6918 while (*str != NUL)
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 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
6921 if (attr != HLF_COUNT)
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 word = str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6924 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6925 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6926 str += len;
14368
e78ce11f310b patch 8.1.0199: spellbadword() does not check for caps error
Christian Brabandt <cb@256bit.org>
parents: 14343
diff changeset
6927 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
6928 len = 0;
9571
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6931 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6932 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6933
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6934 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
6935 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
6936 attr == HLF_SPB ? "bad" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6937 attr == HLF_SPR ? "rare" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6938 attr == HLF_SPL ? "local" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6939 attr == HLF_SPC ? "caps" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6940 ""), -1);
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6944 * "spellsuggest()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6945 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6946 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6947 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
6948 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6949 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6950 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6951 int typeerr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6952 int maxcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6953 garray_T ga;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6954 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6955 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6956 int need_capital = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6957 #endif
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 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6960 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6961
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6962 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6963 if (curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6964 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6965 str = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6966 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6967 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6968 maxcount = (int)tv_get_number_chk(&argvars[1], &typeerr);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6969 if (maxcount <= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6970 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6971 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6972 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6973 need_capital = (int)tv_get_number_chk(&argvars[2], &typeerr);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6974 if (typeerr)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6975 return;
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 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6979 maxcount = 25;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6980
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6981 spell_suggest_list(&ga, str, maxcount, need_capital, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6982
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6983 for (i = 0; i < ga.ga_len; ++i)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6984 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6985 str = ((char_u **)ga.ga_data)[i];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6986
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6987 li = listitem_alloc();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6988 if (li == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6989 vim_free(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6990 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6991 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6992 li->li_tv.v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6993 li->li_tv.v_lock = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6994 li->li_tv.vval.v_string = str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6995 list_append(rettv->vval.v_list, li);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6996 }
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 ga_clear(&ga);
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 #endif
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7003 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7004 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
7005 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7006 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7007 char_u *end;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7008 char_u *pat = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7009 regmatch_T regmatch;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7010 char_u patbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7011 char_u *save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7012 int match;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7013 colnr_T col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7014 int keepempty = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7015 int typeerr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7016
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7017 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7018 save_cpo = p_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7019 p_cpo = (char_u *)"";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7020
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7021 str = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7022 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7023 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7024 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
7025 if (pat == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7026 typeerr = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7027 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
7028 keepempty = (int)tv_get_number_chk(&argvars[2], &typeerr);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7029 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7030 if (pat == NULL || *pat == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7031 pat = (char_u *)"[\\x01- ]\\+";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7032
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7033 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7034 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7035 if (typeerr)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7036 return;
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 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
7039 if (regmatch.regprog != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7040 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7041 regmatch.rm_ic = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7042 while (*str != NUL || keepempty)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7043 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7044 if (*str == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7045 match = FALSE; /* empty item at the end */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7046 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7047 match = vim_regexec_nl(&regmatch, str, col);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7048 if (match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7049 end = regmatch.startp[0];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7050 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7051 end = str + STRLEN(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7052 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
7053 && *str != NUL && match && end < regmatch.endp[0]))
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 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
7056 (int)(end - str)) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7057 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7058 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7059 if (!match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7060 break;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7061 // Advance to just after the match.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7062 if (regmatch.endp[0] > str)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7063 col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7064 else
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7065 // 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
7066 col = (*mb_ptr2len)(regmatch.endp[0]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7067 str = regmatch.endp[0];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7068 }
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 vim_regfree(regmatch.regprog);
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7073 p_cpo = save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7074 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7075
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7076 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7077 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7078 * "sqrt()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7079 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7080 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7081 f_sqrt(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7082 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7083 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7084
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7085 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7086 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7087 rettv->vval.v_float = sqrt(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7088 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7089 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7090 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7091
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7092 /*
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7093 * "srand()" function
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7094 */
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7095 static void
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7096 f_srand(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
7097 {
18703
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7098 static int dev_urandom_state = -1; // FAIL or OK once tried
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7099
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7100 if (rettv_list_alloc(rettv) == FAIL)
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7101 return;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7102 if (argvars[0].v_type == VAR_UNKNOWN)
18703
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7103 {
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7104 if (dev_urandom_state != FAIL)
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7105 {
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7106 int fd = open("/dev/urandom", O_RDONLY);
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7107 struct {
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7108 union {
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7109 UINT32_T number;
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7110 char bytes[sizeof(UINT32_T)];
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7111 } cont;
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7112 } buf;
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7113
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7114 // Attempt reading /dev/urandom.
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7115 if (fd == -1)
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7116 dev_urandom_state = FAIL;
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7117 else
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7118 {
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7119 buf.cont.number = 0;
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7120 if (read(fd, buf.cont.bytes, sizeof(UINT32_T))
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7121 != sizeof(UINT32_T))
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7122 dev_urandom_state = FAIL;
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7123 else
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7124 {
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7125 dev_urandom_state = OK;
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7126 list_append_number(rettv->vval.v_list,
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7127 (varnumber_T)buf.cont.number);
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7128 }
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7129 close(fd);
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7130 }
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7131
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7132 }
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7133 if (dev_urandom_state != OK)
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7134 // Reading /dev/urandom doesn't work, fall back to time().
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7135 list_append_number(rettv->vval.v_list, (varnumber_T)vim_time());
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7136 }
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7137 else
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7138 {
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7139 int error = FALSE;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7140 UINT32_T x = (UINT32_T)tv_get_number_chk(&argvars[0], &error);
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7141
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7142 if (error)
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7143 return;
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7144
18703
aef98a646d3e patch 8.1.2343: using time() for srand() is not very random
Bram Moolenaar <Bram@vim.org>
parents: 18701
diff changeset
7145 list_append_number(rettv->vval.v_list, (varnumber_T)x);
18701
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7146 }
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7147 list_append_number(rettv->vval.v_list, 362436069);
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7148 list_append_number(rettv->vval.v_list, 521288629);
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7149 list_append_number(rettv->vval.v_list, 88675123);
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7150 }
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7151
128662297ddf patch 8.1.2342: random number generator in Vim script is slow
Bram Moolenaar <Bram@vim.org>
parents: 18699
diff changeset
7152 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7153 * "str2float()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7154 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7155 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7156 f_str2float(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7157 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7158 char_u *p = skipwhite(tv_get_string(&argvars[0]));
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7159 int isneg = (*p == '-');
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7160
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7161 if (*p == '+' || *p == '-')
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7162 p = skipwhite(p + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7163 (void)string2float(p, &rettv->vval.v_float);
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7164 if (isneg)
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7165 rettv->vval.v_float *= -1;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7166 rettv->v_type = VAR_FLOAT;
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7169
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7170 /*
16235
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7171 * "str2list()" function
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7172 */
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7173 static void
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7174 f_str2list(typval_T *argvars, typval_T *rettv)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7175 {
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7176 char_u *p;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7177 int utf8 = FALSE;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7178
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7179 if (rettv_list_alloc(rettv) == FAIL)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7180 return;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7181
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7182 if (argvars[1].v_type != VAR_UNKNOWN)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7183 utf8 = (int)tv_get_number_chk(&argvars[1], NULL);
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7184
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7185 p = tv_get_string(&argvars[0]);
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7186
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7187 if (has_mbyte || utf8)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7188 {
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7189 int (*ptr2len)(char_u *);
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7190 int (*ptr2char)(char_u *);
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7191
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7192 if (utf8 || enc_utf8)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7193 {
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7194 ptr2len = utf_ptr2len;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7195 ptr2char = utf_ptr2char;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7196 }
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7197 else
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7198 {
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7199 ptr2len = mb_ptr2len;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7200 ptr2char = mb_ptr2char;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7201 }
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7202
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7203 for ( ; *p != NUL; p += (*ptr2len)(p))
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7204 list_append_number(rettv->vval.v_list, (*ptr2char)(p));
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7205 }
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7206 else
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7207 for ( ; *p != NUL; ++p)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7208 list_append_number(rettv->vval.v_list, *p);
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7209 }
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7210
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7211 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7212 * "str2nr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7213 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7214 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7215 f_str2nr(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7216 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7217 int base = 10;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7218 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7219 varnumber_T n;
18080
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
7220 int what = 0;
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7221 int isneg;
9571
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 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7224 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7225 base = (int)tv_get_number(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7226 if (base != 2 && base != 8 && base != 10 && base != 16)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7227 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
7228 emsg(_(e_invarg));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7229 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7230 }
18080
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
7231 if (argvars[2].v_type != VAR_UNKNOWN && tv_get_number(&argvars[2]))
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
7232 what |= STR2NR_QUOTE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7233 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7234
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7235 p = skipwhite(tv_get_string(&argvars[0]));
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7236 isneg = (*p == '-');
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7237 if (*p == '+' || *p == '-')
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7238 p = skipwhite(p + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7239 switch (base)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7240 {
18080
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
7241 case 2: what |= STR2NR_BIN + STR2NR_FORCE; break;
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
7242 case 8: what |= STR2NR_OCT + STR2NR_FORCE; break;
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
7243 case 16: what |= STR2NR_HEX + STR2NR_FORCE; break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7244 }
16706
77bcb5055fec patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents: 16700
diff changeset
7245 vim_str2nr(p, NULL, NULL, what, &n, NULL, 0, FALSE);
77bcb5055fec patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents: 16700
diff changeset
7246 // Text after the number is silently ignored.
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7247 if (isneg)
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7248 rettv->vval.v_number = -n;
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7249 else
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7250 rettv->vval.v_number = n;
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7251
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7252 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7253
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7254 #ifdef HAVE_STRFTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7255 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7256 * "strftime({format}[, {time}])" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7257 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7258 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7259 f_strftime(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7260 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7261 char_u result_buf[256];
16621
7ad3fc329e08 patch 8.1.1313: warnings for using localtime() and ctime()
Bram Moolenaar <Bram@vim.org>
parents: 16606
diff changeset
7262 struct tm tmval;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7263 struct tm *curtime;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7264 time_t seconds;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7265 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7266
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7267 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7268
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7269 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7270 if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7271 seconds = time(NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7272 else
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7273 seconds = (time_t)tv_get_number(&argvars[1]);
17135
d03a52e02f1a patch 8.1.1567: localtime_r() does not respond to $TZ changes
Bram Moolenaar <Bram@vim.org>
parents: 17123
diff changeset
7274 curtime = vim_localtime(&seconds, &tmval);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7275 /* MSVC returns NULL for an invalid value of seconds. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7276 if (curtime == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7277 rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7278 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7279 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7280 vimconv_T conv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7281 char_u *enc;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7282
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7283 conv.vc_type = CONV_NONE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7284 enc = enc_locale();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7285 convert_setup(&conv, p_enc, enc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7286 if (conv.vc_type != CONV_NONE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7287 p = string_convert(&conv, p, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7288 if (p != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7289 (void)strftime((char *)result_buf, sizeof(result_buf),
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7290 (char *)p, curtime);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7291 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7292 result_buf[0] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7293
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7294 if (conv.vc_type != CONV_NONE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7295 vim_free(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7296 convert_setup(&conv, enc, p_enc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7297 if (conv.vc_type != CONV_NONE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7298 rettv->vval.v_string = string_convert(&conv, result_buf, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7299 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7300 rettv->vval.v_string = vim_strsave(result_buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7301
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7302 /* Release conversion descriptors */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7303 convert_setup(&conv, NULL, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7304 vim_free(enc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7305 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7306 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7307 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7308
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7309 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7310 * "strgetchar()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7311 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7312 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7313 f_strgetchar(typval_T *argvars, typval_T *rettv)
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 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7316 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7317 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7318 int charidx;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7319 int byteidx = 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7320
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7321 rettv->vval.v_number = -1;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7322 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
7323 if (str == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7324 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7325 len = (int)STRLEN(str);
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7326 charidx = (int)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
7327 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7328 return;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7329
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7330 while (charidx >= 0 && byteidx < len)
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7331 {
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7332 if (charidx == 0)
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7333 {
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7334 rettv->vval.v_number = mb_ptr2char(str + byteidx);
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7335 break;
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7336 }
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7337 --charidx;
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7338 byteidx += MB_CPTR2LEN(str + byteidx);
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7339 }
9571
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7342 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7343 * "stridx()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7344 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7345 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7346 f_stridx(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7347 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7348 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7349 char_u *needle;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7350 char_u *haystack;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7351 char_u *save_haystack;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7352 char_u *pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7353 int start_idx;
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 needle = tv_get_string_chk(&argvars[1]);
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7356 save_haystack = haystack = tv_get_string_buf_chk(&argvars[0], buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7357 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7358 if (needle == NULL || haystack == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7359 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7360
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7361 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7362 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7363 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7364
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7365 start_idx = (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
7366 if (error || start_idx >= (int)STRLEN(haystack))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7367 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7368 if (start_idx >= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7369 haystack += start_idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7370 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7371
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7372 pos = (char_u *)strstr((char *)haystack, (char *)needle);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7373 if (pos != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7374 rettv->vval.v_number = (varnumber_T)(pos - save_haystack);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7375 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7376
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 * "string()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7379 */
15219
dada0b389d4f patch 8.1.0619: :echomsg and :echoerr do not handle List and Dict
Bram Moolenaar <Bram@vim.org>
parents: 15211
diff changeset
7380 void
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7381 f_string(typval_T *argvars, typval_T *rettv)
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 char_u *tofree;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7384 char_u numbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7385
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7386 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7387 rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7388 get_copyID());
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7389 /* Make a copy if we have a value but it's not in allocated memory. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7390 if (rettv->vval.v_string != NULL && tofree == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7391 rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7392 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7395 * "strlen()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7396 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7397 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7398 f_strlen(typval_T *argvars, typval_T *rettv)
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 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
7401 tv_get_string(&argvars[0])));
9571
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7404 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7405 * "strchars()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7406 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7407 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7408 f_strchars(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7409 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7410 char_u *s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7411 int skipcc = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7412 varnumber_T len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7413 int (*func_mb_ptr2char_adv)(char_u **pp);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7414
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7415 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
7416 skipcc = (int)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
7417 if (skipcc < 0 || skipcc > 1)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
7418 emsg(_(e_invarg));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7419 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7420 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7421 func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7422 while (*s != NUL)
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 func_mb_ptr2char_adv(&s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7425 ++len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7426 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7427 rettv->vval.v_number = len;
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7430
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 * "strdisplaywidth()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7435 f_strdisplaywidth(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7436 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7437 char_u *s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7438 int col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7439
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7440 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
7441 col = (int)tv_get_number(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7442
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7443 rettv->vval.v_number = (varnumber_T)(linetabsize_col(col, s) - col);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7444 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7445
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7446 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7447 * "strwidth()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7448 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7449 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7450 f_strwidth(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7451 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7452 char_u *s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7453
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7454 rettv->vval.v_number = (varnumber_T)(mb_string2cells(s, -1));
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7457 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7458 * "strcharpart()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7459 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7460 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7461 f_strcharpart(typval_T *argvars, typval_T *rettv)
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 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7464 int nchar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7465 int nbyte = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7466 int charlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7467 int len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7468 int slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7469 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7470
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7471 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7472 slen = (int)STRLEN(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7473
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7474 nchar = (int)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
7475 if (!error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7476 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7477 if (nchar > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7478 while (nchar > 0 && nbyte < slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7479 {
9898
bff8a09016a5 commit https://github.com/vim/vim/commit/d3c907b5d2b352482b580a0cf687cbbea4c19ea1
Christian Brabandt <cb@256bit.org>
parents: 9881
diff changeset
7480 nbyte += MB_CPTR2LEN(p + nbyte);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7481 --nchar;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7484 nbyte = nchar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7485 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7486 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7487 charlen = (int)tv_get_number(&argvars[2]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7488 while (charlen > 0 && nbyte + len < slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7489 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7490 int off = nbyte + len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7491
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7492 if (off < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7493 len += 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7494 else
9898
bff8a09016a5 commit https://github.com/vim/vim/commit/d3c907b5d2b352482b580a0cf687cbbea4c19ea1
Christian Brabandt <cb@256bit.org>
parents: 9881
diff changeset
7495 len += MB_CPTR2LEN(p + off);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7496 --charlen;
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7499 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7500 len = slen - nbyte; /* default: all bytes that are available. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7501 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7502
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7503 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7504 * Only return the overlap between the specified part and the actual
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7505 * string.
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 if (nbyte < 0)
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 len += nbyte;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7510 nbyte = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7511 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7512 else if (nbyte > slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7513 nbyte = slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7514 if (len < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7515 len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7516 else if (nbyte + len > slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7517 len = slen - nbyte;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7518
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7519 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7520 rettv->vval.v_string = vim_strnsave(p + nbyte, len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7521 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7522
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7523 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7524 * "strpart()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7527 f_strpart(typval_T *argvars, typval_T *rettv)
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 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7530 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7531 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7532 int slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7533 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7534
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7535 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7536 slen = (int)STRLEN(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7537
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7538 n = (int)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
7539 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7540 len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7541 else 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
7542 len = (int)tv_get_number(&argvars[2]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7543 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7544 len = slen - n; /* default len: all bytes that are available. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7545
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 * Only return the overlap between the specified part and the actual
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7548 * string.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7549 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7550 if (n < 0)
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 len += n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7553 n = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7554 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7555 else if (n > slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7556 n = slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7557 if (len < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7558 len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7559 else if (n + len > slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7560 len = slen - n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7561
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7562 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7563 rettv->vval.v_string = vim_strnsave(p + n, len);
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
18669
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7566 #ifdef HAVE_STRPTIME
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7567 /*
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7568 * "strptime({format}, {timestring})" function
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7569 */
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7570 static void
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7571 f_strptime(typval_T *argvars, typval_T *rettv)
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7572 {
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7573 struct tm tmval;
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7574 char_u *fmt;
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7575 char_u *str;
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7576 vimconv_T conv;
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7577 char_u *enc;
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7578
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7579 vim_memset(&tmval, NUL, sizeof(tmval));
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7580 fmt = tv_get_string(&argvars[0]);
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7581 str = tv_get_string(&argvars[1]);
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7582
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7583 conv.vc_type = CONV_NONE;
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7584 enc = enc_locale();
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7585 convert_setup(&conv, p_enc, enc);
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7586 if (conv.vc_type != CONV_NONE)
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7587 fmt = string_convert(&conv, fmt, NULL);
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7588 if (fmt == NULL
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7589 || strptime((char *)str, (char *)fmt, &tmval) == NULL
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7590 || (rettv->vval.v_number = mktime(&tmval)) == -1)
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7591 rettv->vval.v_number = 0;
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7592
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7593 if (conv.vc_type != CONV_NONE)
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7594 vim_free(fmt);
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7595 convert_setup(&conv, NULL, NULL);
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7596 vim_free(enc);
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7597 }
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7598 #endif
9007e9896303 patch 8.1.2326: cannot parse a date/time string
Bram Moolenaar <Bram@vim.org>
parents: 18623
diff changeset
7599
9571
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 * "strridx()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7602 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7603 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7604 f_strridx(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7605 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7606 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7607 char_u *needle;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7608 char_u *haystack;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7609 char_u *rest;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7610 char_u *lastmatch = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7611 int haystack_len, end_idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7612
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7613 needle = tv_get_string_chk(&argvars[1]);
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7614 haystack = tv_get_string_buf_chk(&argvars[0], buf);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7615
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7616 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7617 if (needle == NULL || haystack == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7618 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7619
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7620 haystack_len = (int)STRLEN(haystack);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7621 if (argvars[2].v_type != VAR_UNKNOWN)
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 /* Third argument: upper limit for index */
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7624 end_idx = (int)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
7625 if (end_idx < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7626 return; /* can never find a match */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7627 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7628 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7629 end_idx = haystack_len;
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 if (*needle == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7632 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7633 /* Empty string matches past the end. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7634 lastmatch = haystack + end_idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7635 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7636 else
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 for (rest = haystack; *rest != '\0'; ++rest)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7639 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7640 rest = (char_u *)strstr((char *)rest, (char *)needle);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7641 if (rest == NULL || rest > haystack + end_idx)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7642 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7643 lastmatch = rest;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7644 }
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 if (lastmatch == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7648 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7649 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7650 rettv->vval.v_number = (varnumber_T)(lastmatch - haystack);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7651 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7654 * "strtrans()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7657 f_strtrans(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7658 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7659 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
7660 rettv->vval.v_string = transstr(tv_get_string(&argvars[0]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7661 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7664 * "submatch()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7665 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7666 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7667 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
7668 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7669 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7670 int no;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7671 int retList = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7672
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7673 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
7674 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7675 return;
9923
935e13935848 commit https://github.com/vim/vim/commit/989f592f7ffcbafdc4ec35cee4dc65bd053e2077
Christian Brabandt <cb@256bit.org>
parents: 9919
diff changeset
7676 if (no < 0 || no >= NSUBEXP)
935e13935848 commit https://github.com/vim/vim/commit/989f592f7ffcbafdc4ec35cee4dc65bd053e2077
Christian Brabandt <cb@256bit.org>
parents: 9919
diff changeset
7677 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
7678 semsg(_("E935: invalid submatch number: %d"), 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
7679 return;
9923
935e13935848 commit https://github.com/vim/vim/commit/989f592f7ffcbafdc4ec35cee4dc65bd053e2077
Christian Brabandt <cb@256bit.org>
parents: 9919
diff changeset
7680 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7681 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
7682 retList = (int)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
7683 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7684 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7685
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7686 if (retList == 0)
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 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7689 rettv->vval.v_string = reg_submatch(no);
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 else
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 rettv->v_type = VAR_LIST;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7694 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
7695 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7696 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7697
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7698 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7699 * "substitute()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7700 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7701 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7702 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
7703 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7704 char_u patbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7705 char_u subbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7706 char_u flagsbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7707
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7708 char_u *str = 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
7709 char_u *pat = tv_get_string_buf_chk(&argvars[1], patbuf);
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7710 char_u *sub = NULL;
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7711 typval_T *expr = NULL;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7712 char_u *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
7713
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7714 if (argvars[2].v_type == VAR_FUNC || argvars[2].v_type == VAR_PARTIAL)
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7715 expr = &argvars[2];
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7716 else
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7717 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
7718
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7719 rettv->v_type = VAR_STRING;
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7720 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
7721 || flg == NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7722 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7723 else
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7724 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
7725 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7726
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7727 /*
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7728 * "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
7729 */
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7730 static void
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7731 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
7732 {
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7733 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
7734 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
7735 }
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7736
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7737 /*
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7738 * "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
7739 */
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7740 static void
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7741 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
7742 {
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7743 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
7744
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7745 rettv->v_type = VAR_STRING;
15355
73b153ed5af8 patch 8.1.0685: get_buf_tv() is named inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 15343
diff changeset
7746 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
7747 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
7748 || 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
7749 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
7750 else
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7751 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
7752 }
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7753
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7754 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7755 * "synID(lnum, col, trans)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7756 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7757 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7758 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
7759 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7760 int id = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7761 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7762 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7763 colnr_T col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7764 int trans;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7765 int transerr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7766
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7767 lnum = tv_get_lnum(argvars); /* -1 on type error */
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7768 col = (linenr_T)tv_get_number(&argvars[1]) - 1; /* -1 on type error */
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7769 trans = (int)tv_get_number_chk(&argvars[2], &transerr);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7770
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7771 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
7772 && 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
7773 id = syn_get_id(curwin, lnum, (colnr_T)col, trans, NULL, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7774 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7775
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7776 rettv->vval.v_number = id;
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
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 * "synIDattr(id, what [, mode])" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7781 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7782 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7783 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
7784 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7785 char_u *p = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7786 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7787 int id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7788 char_u *what;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7789 char_u *mode;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7790 char_u modebuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7791 int modec;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7792
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7793 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
7794 what = tv_get_string(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7795 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7796 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7797 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
7798 modec = TOLOWER_ASC(mode[0]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7799 if (modec != 't' && modec != 'c' && modec != 'g')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7800 modec = 0; /* replace invalid with current */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7801 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7802 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7803 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7804 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7805 if (USE_24BIT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7806 modec = 'g';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7807 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7808 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7809 if (t_colors > 1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7810 modec = 'c';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7811 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7812 modec = 't';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7813 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7814
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7815 switch (TOLOWER_ASC(what[0]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7816 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7817 case 'b':
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7818 if (TOLOWER_ASC(what[1]) == 'g') /* bg[#] */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7819 p = highlight_color(id, what, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7820 else /* bold */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7821 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
7822 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7823
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7824 case 'f': /* fg[#] or font */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7825 p = highlight_color(id, what, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7826 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7827
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7828 case 'i':
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7829 if (TOLOWER_ASC(what[1]) == 'n') /* inverse */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7830 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
7831 else /* italic */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7832 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
7833 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7834
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7835 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
7836 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
7837 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7838
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7839 case 'r': /* reverse */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7840 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
7841 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7842
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7843 case 's':
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7844 if (TOLOWER_ASC(what[1]) == 'p') /* sp[#] */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7845 p = highlight_color(id, what, modec);
12317
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
7846 /* strikeout */
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
7847 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
7848 TOLOWER_ASC(what[2]) == 'r')
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
7849 p = highlight_has_attr(id, HL_STRIKETHROUGH, modec);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7850 else /* standout */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7851 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
7852 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7853
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7854 case 'u':
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7855 if (STRLEN(what) <= 5 || TOLOWER_ASC(what[5]) != 'c')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7856 /* underline */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7857 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
7858 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7859 /* undercurl */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7860 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
7861 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7862 }
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 if (p != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7865 p = vim_strsave(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7866 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7867 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7868 rettv->vval.v_string = p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7869 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7870
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7871 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7872 * "synIDtrans(id)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7873 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7874 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7875 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
7876 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7877 int id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7878
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7879 #ifdef FEAT_SYN_HL
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7880 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
7881
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7882 if (id > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7883 id = syn_get_final_id(id);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7884 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7885 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7886 id = 0;
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 rettv->vval.v_number = id;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7891 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7892 * "synconcealed(lnum, col)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7893 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7894 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7895 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
7896 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7897 #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
7898 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7899 colnr_T col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7900 int syntax_flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7901 int cchar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7902 int matchid = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7903 char_u str[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7904 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7905
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
7906 rettv_list_set(rettv, NULL);
9571
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 #if defined(FEAT_SYN_HL) && defined(FEAT_CONCEAL)
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7909 lnum = tv_get_lnum(argvars); /* -1 on type error */
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7910 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
7911
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7912 vim_memset(str, NUL, sizeof(str));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7913
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7914 if (rettv_list_alloc(rettv) != FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7915 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7916 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
7917 && 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
7918 && curwin->w_p_cole > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7919 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7920 (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
7921 syntax_flags = get_syntax_info(&matchid);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7922
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7923 /* get the conceal character */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7924 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
7925 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7926 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
7927 if (cchar == NUL && curwin->w_p_cole == 1)
cbceef33af7a patch 8.0.0659: no test for conceal mode
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
7928 cchar = (lcs_conceal == NUL) ? ' ' : lcs_conceal;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7929 if (cchar != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7930 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7931 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7932 (*mb_char2bytes)(cchar, str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7933 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7934 str[0] = cchar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7935 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7936 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7937 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7938
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7939 list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7940 (syntax_flags & HL_CONCEAL) != 0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7941 /* -1 to auto-determine strlen */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7942 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
7943 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
7944 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7945 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7946 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7947
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7948 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7949 * "synstack(lnum, col)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7950 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7951 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7952 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
7953 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7954 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7955 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7956 colnr_T col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7957 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7958 int id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7959 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7960
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
7961 rettv_list_set(rettv, NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7962
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7963 #ifdef FEAT_SYN_HL
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7964 lnum = tv_get_lnum(argvars); /* -1 on type error */
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7965 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
7966
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7967 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
7968 && 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
7969 && rettv_list_alloc(rettv) != FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7970 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7971 (void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL, TRUE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7972 for (i = 0; ; ++i)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7973 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7974 id = syn_get_stack_item(i);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7975 if (id < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7976 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7977 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
7978 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7979 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7980 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7981 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7982 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7983
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7984 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7985 * "tabpagebuflist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7986 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7987 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7988 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
7989 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7990 tabpage_T *tp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7991 win_T *wp = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7992
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7993 if (argvars[0].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7994 wp = firstwin;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7995 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7996 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7997 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
7998 if (tp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7999 wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8000 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8001 if (wp != NULL && rettv_list_alloc(rettv) != FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8002 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8003 for (; wp != NULL; wp = wp->w_next)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8004 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
8005 wp->w_buffer->b_fnum) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8006 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8007 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8008 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8009
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8010 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8011 * "tagfiles()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8012 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8013 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8014 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
8015 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8016 char_u *fname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8017 tagname_T tn;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8018 int first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8019
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8020 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8021 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8022 fname = alloc(MAXPATHL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8023 if (fname == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8024 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8025
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8026 for (first = TRUE; ; first = FALSE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8027 if (get_tagfname(&tn, first, fname) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8028 || 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
8029 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8030 tagname_free(&tn);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8031 vim_free(fname);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8032 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8033
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8034 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8035 * "taglist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8036 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8037 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8038 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
8039 {
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents: 11215
diff changeset
8040 char_u *fname = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8041 char_u *tag_pattern;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8042
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8043 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
8044
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8045 rettv->vval.v_number = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8046 if (*tag_pattern == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8047 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8048
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents: 11215
diff changeset
8049 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
8050 fname = tv_get_string(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8051 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
8052 (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
8053 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8054
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8055 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8056 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8057 * "tan()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8058 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8059 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8060 f_tan(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8061 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8062 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8063
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8064 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8065 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8066 rettv->vval.v_float = tan(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8067 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8068 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8069 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8070
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8071 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8072 * "tanh()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8073 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8074 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8075 f_tanh(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8076 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8077 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8078
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8079 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8080 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8081 rettv->vval.v_float = tanh(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8082 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8083 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8084 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8085 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8086
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8087 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8088 * "tolower(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8089 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8090 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8091 f_tolower(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8092 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8093 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
8094 rettv->vval.v_string = strlow_save(tv_get_string(&argvars[0]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8095 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8096
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8097 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8098 * "toupper(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8099 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8100 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8101 f_toupper(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8102 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8103 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
8104 rettv->vval.v_string = strup_save(tv_get_string(&argvars[0]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8105 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8106
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8107 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8108 * "tr(string, fromstr, tostr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8109 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8110 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8111 f_tr(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8112 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8113 char_u *in_str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8114 char_u *fromstr;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8115 char_u *tostr;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8116 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8117 int inlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8118 int fromlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8119 int tolen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8120 int idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8121 char_u *cpstr;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8122 int cplen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8123 int first = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8124 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8125 char_u buf2[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8126 garray_T ga;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8127
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8128 in_str = 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
8129 fromstr = tv_get_string_buf_chk(&argvars[1], buf);
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8130 tostr = tv_get_string_buf_chk(&argvars[2], buf2);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8131
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8132 /* Default return value: empty string. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8133 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8134 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8135 if (fromstr == NULL || tostr == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8136 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8137 ga_init2(&ga, (int)sizeof(char), 80);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8138
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8139 if (!has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8140 /* not multi-byte: fromstr and tostr must be the same length */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8141 if (STRLEN(fromstr) != STRLEN(tostr))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8142 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8143 error:
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
8144 semsg(_(e_invarg2), fromstr);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8145 ga_clear(&ga);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8146 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8147 }
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 /* fromstr and tostr have to contain the same number of chars */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8150 while (*in_str != NUL)
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 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8153 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8154 inlen = (*mb_ptr2len)(in_str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8155 cpstr = in_str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8156 cplen = inlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8157 idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8158 for (p = fromstr; *p != NUL; p += fromlen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8159 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8160 fromlen = (*mb_ptr2len)(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8161 if (fromlen == inlen && STRNCMP(in_str, p, inlen) == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8162 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8163 for (p = tostr; *p != NUL; p += tolen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8164 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8165 tolen = (*mb_ptr2len)(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8166 if (idx-- == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8167 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8168 cplen = tolen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8169 cpstr = p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8170 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8171 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8172 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8173 if (*p == NUL) /* tostr is shorter than fromstr */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8174 goto error;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8175 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8176 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8177 ++idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8178 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8179
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8180 if (first && cpstr == in_str)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8181 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8182 /* Check that fromstr and tostr have the same number of
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8183 * (multi-byte) characters. Done only once when a character
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8184 * of in_str doesn't appear in fromstr. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8185 first = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8186 for (p = tostr; *p != NUL; p += tolen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8187 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8188 tolen = (*mb_ptr2len)(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8189 --idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8190 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8191 if (idx != 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8192 goto error;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8193 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8194
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8195 (void)ga_grow(&ga, cplen);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8196 mch_memmove((char *)ga.ga_data + ga.ga_len, cpstr, (size_t)cplen);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8197 ga.ga_len += cplen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8198
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8199 in_str += inlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8200 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8201 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8202 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8203 /* When not using multi-byte chars we can do it faster. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8204 p = vim_strchr(fromstr, *in_str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8205 if (p != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8206 ga_append(&ga, tostr[p - fromstr]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8207 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8208 ga_append(&ga, *in_str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8209 ++in_str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8210 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8211 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8212
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8213 /* add a terminating NUL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8214 (void)ga_grow(&ga, 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8215 ga_append(&ga, NUL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8216
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8217 rettv->vval.v_string = ga.ga_data;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8218 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8219
13513
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8220 /*
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8221 * "trim({expr})" function
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8222 */
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8223 static void
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8224 f_trim(typval_T *argvars, typval_T *rettv)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8225 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8226 char_u buf1[NUMBUFLEN];
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8227 char_u buf2[NUMBUFLEN];
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8228 char_u *head = tv_get_string_buf_chk(&argvars[0], buf1);
13513
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8229 char_u *mask = NULL;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8230 char_u *tail;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8231 char_u *prev;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8232 char_u *p;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8233 int c1;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8234
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8235 rettv->v_type = VAR_STRING;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8236 if (head == NULL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8237 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8238 rettv->vval.v_string = NULL;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8239 return;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8240 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8241
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8242 if (argvars[1].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
8243 mask = tv_get_string_buf_chk(&argvars[1], buf2);
13513
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8244
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8245 while (*head != NUL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8246 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8247 c1 = PTR2CHAR(head);
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8248 if (mask == NULL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8249 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8250 if (c1 > ' ' && c1 != 0xa0)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8251 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8252 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8253 else
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8254 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8255 for (p = mask; *p != NUL; MB_PTR_ADV(p))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8256 if (c1 == PTR2CHAR(p))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8257 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8258 if (*p == NUL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8259 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8260 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8261 MB_PTR_ADV(head);
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8262 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8263
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8264 for (tail = head + STRLEN(head); tail > head; tail = prev)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8265 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8266 prev = tail;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8267 MB_PTR_BACK(head, prev);
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8268 c1 = PTR2CHAR(prev);
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8269 if (mask == NULL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8270 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8271 if (c1 > ' ' && c1 != 0xa0)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8272 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8273 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8274 else
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8275 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8276 for (p = mask; *p != NUL; MB_PTR_ADV(p))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8277 if (c1 == PTR2CHAR(p))
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8278 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8279 if (*p == NUL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8280 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8281 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8282 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8283 rettv->vval.v_string = vim_strnsave(head, (int)(tail - head));
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8284 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8285
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8286 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8287 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8288 * "trunc({float})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8289 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8290 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8291 f_trunc(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8292 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8293 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8294
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8295 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8296 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8297 /* trunc() is not in C90, use floor() or ceil() instead. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8298 rettv->vval.v_float = f > 0 ? floor(f) : ceil(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8299 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8300 rettv->vval.v_float = 0.0;
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8303
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8304 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8305 * "type(expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8306 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8307 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8308 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
8309 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8310 int n = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8311
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8312 switch (argvars[0].v_type)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8313 {
9587
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8314 case VAR_NUMBER: n = VAR_TYPE_NUMBER; break;
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8315 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
8316 case VAR_PARTIAL:
9587
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8317 case VAR_FUNC: n = VAR_TYPE_FUNC; break;
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8318 case VAR_LIST: n = VAR_TYPE_LIST; break;
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8319 case VAR_DICT: n = VAR_TYPE_DICT; break;
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8320 case VAR_FLOAT: n = VAR_TYPE_FLOAT; break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8321 case VAR_SPECIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8322 if (argvars[0].vval.v_number == VVAL_FALSE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8323 || argvars[0].vval.v_number == VVAL_TRUE)
9587
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8324 n = VAR_TYPE_BOOL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8325 else
9587
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8326 n = VAR_TYPE_NONE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8327 break;
9587
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8328 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
8329 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
8330 case VAR_BLOB: n = VAR_TYPE_BLOB; break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8331 case VAR_UNKNOWN:
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10277
diff changeset
8332 internal_error("f_type(UNKNOWN)");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8333 n = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8334 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8335 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8336 rettv->vval.v_number = n;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8339 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8340 * "virtcol(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8341 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8342 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8343 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
8344 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8345 colnr_T vcol = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8346 pos_T *fp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8347 int fnum = curbuf->b_fnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8348
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8349 fp = var2fpos(&argvars[0], FALSE, &fnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8350 if (fp != NULL && fp->lnum <= curbuf->b_ml.ml_line_count
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8351 && fnum == curbuf->b_fnum)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8352 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8353 getvvcol(curwin, fp, NULL, NULL, &vcol);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8354 ++vcol;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8355 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8356
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8357 rettv->vval.v_number = vcol;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8358 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8359
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8360 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8361 * "visualmode()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8364 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
8365 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8366 char_u str[2];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8367
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8368 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8369 str[0] = curbuf->b_visual_mode_eval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8370 str[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8371 rettv->vval.v_string = vim_strsave(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8372
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8373 /* A non-zero number or non-empty string argument: reset mode. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8374 if (non_zero_arg(&argvars[0]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8375 curbuf->b_visual_mode_eval = NUL;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8378 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8379 * "wildmenumode()" function
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 void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8382 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
8383 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8384 #ifdef FEAT_WILDMENU
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8385 if (wild_menu_showing)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8386 rettv->vval.v_number = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8387 #endif
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8390 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8391 * "wordcount()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8392 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8393 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8394 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
8395 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8396 if (rettv_dict_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8397 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8398 cursor_pos_info(rettv->vval.v_dict);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8399 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8400
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8401 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8402 * "xor(expr, expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8403 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8404 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8405 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
8406 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8407 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
8408 ^ 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
8409 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8410
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8411 #endif /* FEAT_EVAL */